From 43813db855a6be9ff0bede754595cd181d24c0cd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 10:46:44 -0800 Subject: [PATCH 001/264] Scripts: paths, path points and colors for scripts Document.pathItems lists a document's paths and makes empty paths, rectangles, rounded rectangles, ellipses, polygons and stars with the parameter order and defaults of the PathItems help page. A PathItem reads and changes its points, closed state, fill rule, area, length, fill and stroke colors, stroke options and overprint, and translates, rotates and resizes. PathPoints and PathPoint read and set each point's anchor, handles and type. RGBColor, CMYKColor, GrayColor, LabColor and NoColor make colors; a gradient, spot or pattern paint reads as GradientColor, SpotColor or PatternColor. Each change runs an existing command (path.create, the shape.* commands, path.setAnchors, path.close, path.setFillRule, paint.setFill, paint.setStroke, stroke.set, object.setOverprint, object.move, object.rotate, object.scale) inside the run's one undo step, and puts back the selection and the paint for new art. A value that changes nothing runs no command; a bad value throws and changes nothing. path.setAnchors now makes an anchor a corner when it is given `smooth: false`; before, the key was ignored and handles in line made it smooth. --- crates/engine/src/cmd/create.rs | 3 +- crates/engine/src/cmd/path.rs | 2 +- crates/engine/src/script/dom.rs | 22 +- crates/engine/src/script/dom/colors.rs | 154 +++ crates/engine/src/script/dom/paths.rs | 1223 +++++++++++++++++ crates/engine/src/tests.rs | 1 + crates/engine/src/tests/script_dom.rs | 8 +- crates/engine/src/tests/script_dom_paths.rs | 602 ++++++++ .../tests/it/script_host_vs_scriptcheck.rs | 39 +- docs/mcp.md | 50 +- docs/target-app-parity.md | 3 +- 11 files changed, 2090 insertions(+), 17 deletions(-) create mode 100644 crates/engine/src/script/dom/colors.rs create mode 100644 crates/engine/src/script/dom/paths.rs create mode 100644 crates/engine/src/tests/script_dom_paths.rs diff --git a/crates/engine/src/cmd/create.rs b/crates/engine/src/cmd/create.rs index 0ce38be40b..103eb44f8d 100644 --- a/crates/engine/src/cmd/create.rs +++ b/crates/engine/src/cmd/create.rs @@ -850,7 +850,8 @@ pub(crate) fn anchor_from_json(v: &Value, cmd: &str) -> Result { }; let mut anchor = Anchor::with_handles(p, handle("in")?, handle("out")?); match v.get("smooth").filter(|b| !b.is_null()) { - None | Some(Value::Bool(false)) => {} + None => {} + Some(Value::Bool(false)) => anchor.kind = AnchorKind::Corner, Some(Value::Bool(true)) => anchor.kind = AnchorKind::Smooth, Some(_) => return Err(bad(cmd, "anchor `smooth` must be true or false")), } diff --git a/crates/engine/src/cmd/path.rs b/crates/engine/src/cmd/path.rs index d32594d92d..d747f34989 100644 --- a/crates/engine/src/cmd/path.rs +++ b/crates/engine/src/cmd/path.rs @@ -68,7 +68,7 @@ pub fn specs() -> Vec { "Set Anchors", [], None, - "{id, subpaths: [{anchors: [{x,y,in?,out?}], closed}]} replace a path's geometry", + "{id, subpaths: [{anchors: [{x,y,in?,out?,smooth?: bool (left out: smooth when both handles are pulled out and in line)}], closed}]} replace a path's geometry", has_doc, set_anchors ), diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index b986dfcf2d..03b236c0e1 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -38,6 +38,9 @@ use vectorcraft_js::{Data, HostClass, HostError, HostFunction, HostItem, HostMem use super::{HISTORY_LOST, Host, Link, Savepoint, command, command_value, current, data_size}; use crate::{DocState, Document, NodeId, NodeKind, Session}; +mod colors; +mod paths; + /// The error for a member read or called with no document open. pub const NO_ACTIVE_DOCUMENT: &str = "No active document"; /// The error for an object that was deleted, or that came from an earlier run. @@ -91,6 +94,8 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; pub(super) struct State { coords: Cell, items: RefCell>, + /// The last list of a document's paths ([`paths`]), kept while that document is unchanged. + paths: RefCell>, saving: Cell, } @@ -151,7 +156,7 @@ fn method(link: &Link, f: Member) -> HostMember { } /// A member the help pages list that is not available yet: reading or assigning it throws, after -/// the check that a document or page item `this` is still there. +/// the check that a document, page item or path point `this` is still there. fn later(link: &Link, class: &'static str, name: &'static str) -> (String, HostMember) { let message = format!("{class}.{name} is not available yet"); let l = link.clone(); @@ -162,9 +167,12 @@ fn later(link: &Link, class: &'static str, name: &'static str) -> (String, HostM "Document" => { doc_of(&h, arg(&a, 0), "Document")?; } - "PageItem" => { + "PageItem" | "PathItem" => { item_of(&h, arg(&a, 0))?; } + "PathPoint" => { + paths::this_point(&h, &a)?; + } _ => {} } Err(HostError::Error(message.clone())) @@ -1740,9 +1748,10 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("convertCoordinate", method(l, doc_convert)), ("pageItems", get(l, doc_page_items)), ("selection", property(l, doc_selection, doc_set_selection)), + ("pathItems", get(l, paths::doc_path_items)), ]); document.extend( - ["layers", "artboards", "pathItems", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "saveAs", "close"] + ["layers", "artboards", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "saveAs", "close"] .into_iter() .map(|m| later(l, "Document", m)), ); @@ -1809,7 +1818,12 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), .map(|m| later(l, "PageItem", m)), ); classes.push(class("PageItem", None, page_item, None)); - classes.extend(ITEM_CLASSES.iter().map(|c| class(c, Some("PageItem"), Vec::new(), None))); + classes.extend( + ITEM_CLASSES.iter().map(|c| class(c, Some("PageItem"), if *c == "PathItem" { paths::path_item_members(l) } else { Vec::new() }, None)), + ); + classes.extend(paths::classes(l)); + classes.extend(colors::classes(l)); + paths::install_enums(realm)?; classes.push(class("Layer", None, named(vec![("typename", get(l, layer_typename)), ("name", get(l, layer_name))]), None)); realm.define_host_classes(classes, vec![("app".into(), host_ref("Application", &[]))]) } diff --git a/crates/engine/src/script/dom/colors.rs b/crates/engine/src/script/dom/colors.rs new file mode 100644 index 0000000000..40421c5d38 --- /dev/null +++ b/crates/engine/src/script/dom/colors.rs @@ -0,0 +1,154 @@ +//! The color classes of the script object model, as the help pages +//! , +//! , +//! , +//! and +//! describe them. +//! +//! A color is plain data: `new RGBColor()` gives an object with `typename` and its components, +//! which the script can change, and reading `fillColor` or `strokeColor` gives a new one each time. +//! Components are checked when a color is assigned to an object, and a value out of range throws a +//! `RangeError` with nothing changed. +//! +//! VectorCraft's own rules, which the help pages do not state: components left out count as 0; +//! `new cmykColor()` is the same as `new CMYKColor()`; `LabColor.l` is 0 to 100 and `a` and `b` +//! are -128 to 128. `GrayColor.gray` runs from 0 (black) to 100 (white), as the GrayColor page +//! says. `GradientColor`, `SpotColor` and `PatternColor` can be read from an object but not +//! assigned yet. + +use std::rc::Rc; + +use serde_json::Value; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_js::{Data, HostClass, HostError, HostFunction}; + +use super::{Link, current, num, text}; + +/// The classes whose objects can be read from a fill or stroke but not assigned yet. +const LATER: &[&str] = &["GradientColor", "SpotColor", "PatternColor"]; + +/// The components of each color class, with the value `new` gives them. +const CLASSES: &[(&str, &[&str])] = &[ + ("RGBColor", &["red", "green", "blue"]), + ("CMYKColor", &["cyan", "magenta", "yellow", "black"]), + ("GrayColor", &["gray"]), + ("LabColor", &["l", "a", "b"]), + ("NoColor", &[]), + ("GradientColor", &[]), + ("SpotColor", &["tint"]), + ("PatternColor", &[]), +]; + +fn color_object(class: &str, values: &[(&str, f64)]) -> Data { + let mut items = vec![("typename".to_string(), text(class))]; + items.extend(values.iter().map(|(k, v)| ((*k).to_string(), num(*v)))); + Data::Object(items) +} + +/// A component as the script sees it: `v` times `scale`, rounded to 4 decimals. +fn shown(v: f32, scale: f64) -> f64 { + (f64::from(v) * scale * 1e4).round() / 1e4 +} + +/// The color object for a solid color. +fn of_color(c: &Color) -> Data { + match *c { + Color::Rgb { r, g, b } => color_object("RGBColor", &[("red", shown(r, 255.0)), ("green", shown(g, 255.0)), ("blue", shown(b, 255.0))]), + Color::Cmyk { c, m, y, k } => color_object( + "CMYKColor", + &[("cyan", shown(c, 100.0)), ("magenta", shown(m, 100.0)), ("yellow", shown(y, 100.0)), ("black", shown(k, 100.0))], + ), + Color::Gray { k } => color_object("GrayColor", &[("gray", shown(1.0 - k, 100.0))]), + Color::Lab { l, a, b } => color_object("LabColor", &[("l", shown(l, 1.0)), ("a", shown(a, 1.0)), ("b", shown(b, 1.0))]), + } +} + +/// What reading `fillColor` or `strokeColor` gives for `paint`: a new color object, a `SpotColor` +/// with its `tint` for a color linked to a global or spot swatch. +pub(super) fn of_paint(paint: &Paint) -> Data { + match paint { + Paint::None => color_object("NoColor", &[]), + Paint::Solid { swatch: Some(_), tint, .. } => color_object("SpotColor", &[("tint", shown(*tint, 100.0))]), + Paint::Solid { color, .. } => of_color(color), + Paint::Gradient(_) => color_object("GradientColor", &[]), + Paint::Pattern { .. } => color_object("PatternColor", &[]), + } +} + +/// The component `key` of color object `o`, from `min` to `max` (0 when it is left out). +fn component(o: &[(String, Data)], class: &str, key: &str, min: f64, max: f64) -> std::result::Result { + match o.iter().find(|(k, _)| k == key).map(|(_, v)| v) { + None | Some(Data::Undefined) => Ok(0.0), + Some(Data::Number(n)) if n.is_finite() && (min..=max).contains(n) => Ok(*n), + Some(Data::Number(_)) => Err(HostError::Range(format!("{class}.{key} must be from {min} to {max}"))), + Some(_) => Err(HostError::Type(format!("{class}.{key} must be a number"))), + } +} + +#[allow(clippy::cast_possible_truncation)] +fn unit(v: f64, scale: f64) -> f32 { + (v / scale) as f32 +} + +/// The color a script assigned, checked: `None` for a `NoColor`. `what` names the property. +pub(super) fn assigned(d: &Data, what: &str) -> std::result::Result, HostError> { + let Data::Object(o) = d else { return Err(HostError::Type(format!("{what} must be a color object"))) }; + let class = match o.iter().find(|(k, _)| k == "typename").map(|(_, v)| v) { + Some(Data::String(s)) => s.as_str(), + _ => return Err(HostError::Type(format!("{what} must be a color object"))), + }; + let c = |key: &str, min: f64, max: f64| component(o, class, key, min, max); + Ok(Some(match class { + "NoColor" => return Ok(None), + "RGBColor" => { + Color::Rgb { r: unit(c("red", 0.0, 255.0)?, 255.0), g: unit(c("green", 0.0, 255.0)?, 255.0), b: unit(c("blue", 0.0, 255.0)?, 255.0) } + } + "CMYKColor" => Color::Cmyk { + c: unit(c("cyan", 0.0, 100.0)?, 100.0), + m: unit(c("magenta", 0.0, 100.0)?, 100.0), + y: unit(c("yellow", 0.0, 100.0)?, 100.0), + k: unit(c("black", 0.0, 100.0)?, 100.0), + }, + "GrayColor" => Color::Gray { k: unit(100.0 - c("gray", 0.0, 100.0)?, 100.0) }, + "LabColor" => Color::Lab { l: unit(c("l", 0.0, 100.0)?, 1.0), a: unit(c("a", -128.0, 128.0)?, 1.0), b: unit(c("b", -128.0, 128.0)?, 1.0) }, + l if LATER.contains(&l) => return Err(HostError::Error(format!("assigning a {l} is not available yet"))), + _ => return Err(HostError::Type(format!("{what} must be a color object"))), + })) +} + +/// `color` as `paint.setFill` and `paint.setStroke` take it. +pub(super) fn param(color: &Color) -> Value { + serde_json::to_value(color).unwrap_or(Value::Null) +} + +/// The constructors of the color classes, and `cmykColor`. +pub(super) fn classes(link: &Link) -> Vec { + let make = |name: &str, components: &'static [&'static str]| { + let l = link.clone(); + let class = name.to_string(); + let f: HostFunction = Rc::new(move |_| { + current(&l)?.charge_call(64)?; + let zeros: Vec<(&str, f64)> = components.iter().map(|k| (*k, if *k == "tint" { 100.0 } else { 0.0 })).collect(); + Ok(color_object(&class, &zeros)) + }); + f + }; + let mut out: Vec = CLASSES + .iter() + .map(|(name, components)| HostClass { + name: (*name).into(), + parent: None, + members: Vec::new(), + index: None, + construct: Some(make(name, components)), + }) + .collect(); + out.push(HostClass { + name: "cmykColor".into(), + parent: None, + members: Vec::new(), + index: None, + construct: Some(make("CMYKColor", CLASSES[1].1)), + }); + out +} diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs new file mode 100644 index 0000000000..ac643ce370 --- /dev/null +++ b/crates/engine/src/script/dom/paths.rs @@ -0,0 +1,1223 @@ +//! Paths and their points in the script object model, as the help pages +//! , +//! , +//! and +//! describe them. +//! +//! A `PathPoints` object holds its path's handle, and a `PathPoint` the path's handle and the +//! point's index, counted across the path's subpaths in order. Each read looks the path up again. +//! Every change runs one command (`path.setAnchors` for the geometry), inside the run's one undo +//! step, and a change that changes nothing runs no command. +//! +//! VectorCraft's own rules, which the help pages do not state: +//! - `Document.pathItems` lists the document's paths in the order of `pageItems`, paths inside +//! groups and compound paths included. +//! - A change to the geometry or paint of a path that is hidden or locked, or that is in a hidden +//! or locked layer or group, throws `Cannot edit` with nothing changed. +//! - A path in a compound path or compound shape reads that owner's paint, which the paint +//! commands change in its place. A paint or stroke change leaves the paint for new art, the +//! active proxy and the recent colors as they were. +//! - `closed` is true when every subpath of the path is closed, and assigning it opens or closes +//! them all. +//! - `pathItems.add()` makes a path with no points on top of the active layer, painted as new art +//! is. `filled` and `stroked` set to true give a path with no fill or stroke new art's fill or +//! stroke (solid, gradient or pattern), or black when new art has none. `PathPoints.add()` adds +//! a corner point with no handles at the last point, or at `[0, 0]` on a path with no points. +//! Removing the last points leaves the path, with no points. +//! - A point whose index is past the end of its path throws `Stale path point`. +//! - Shape creators take sizes and radii that are finite and not negative; `sides` is a whole +//! number from 3 to 1000 and `points` one from 2 to 1000. `inscribed` true throws an error that +//! says it is not available yet. `rotateAbout` and `scaleAbout` default to +//! `Transformation.CENTER`. +//! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and +//! `changeStrokePattern` given as different values throw an error; gradients move with the art, +//! so `changeFillGradients` false throws an error that says it is not available yet. + +use std::rc::Rc; + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::pattern::pattern_paint; +use vectorcraft_doc::{GraphicStyle, LineCap, LineJoin}; +use vectorcraft_geom::path::{Anchor, AnchorKind, FillRule, PathData, SubPath}; +use vectorcraft_geom::{Point, Rect}; +use vectorcraft_js::{Data, HostClass, HostError, HostItem, HostMember, Realm, RunError, host_ref}; +use vectorcraft_tools::params::gradient_params; + +use super::{ + Answer, Coords, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, coordinate, doc_of, edit_item, editable, find_doc, + float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, point, property, + this_doc, typename_of, whole, with_doc, +}; +use crate::{DocState, NodeId, NodeKind}; + +/// The error of a point whose index is past the end of its path. +pub const STALE_POINT: &str = "Stale path point"; +/// The most points `setEntirePath` takes. +pub const MAX_POINTS: usize = 100_000; +/// The most lengths `strokeDashes` takes. +pub const MAX_DASHES: usize = 64; +/// The largest stroke weight a script may set, in points. +pub const MAX_STROKE_WIDTH: f64 = 1000.0; + +/// The enumerations of paths, as frozen objects whose members are `"Name.MEMBER"` strings. +pub(super) const ENUMS: &[(&str, &[&str])] = &[ + ("PointType", &["CORNER", "SMOOTH"]), + ("PathPointSelection", &["ANCHORPOINT", "LEFTDIRECTION", "LEFTRIGHTPOINT", "NOSELECTION", "RIGHTDIRECTION"]), + ("StrokeCap", &["BUTTENDCAP", "PROJECTINGENDCAP", "ROUNDENDCAP"]), + ("StrokeJoin", &["BEVELENDJOIN", "MITERENDJOIN", "ROUNDENDJOIN"]), + ("PolarityValues", &["NEGATIVE", "POSITIVE"]), + ("Transformation", &["BOTTOM", "BOTTOMLEFT", "BOTTOMRIGHT", "CENTER", "DOCUMENTORIGIN", "LEFT", "RIGHT", "TOP", "TOPLEFT", "TOPRIGHT"]), +]; + +/// Adds the enumerations of [`ENUMS`] to `realm`. +pub(super) fn install_enums(realm: &mut Realm) -> std::result::Result<(), RunError> { + for (name, members) in ENUMS { + let items = members.iter().map(|m| (m.to_string(), HostItem::Value(Data::String(format!("{name}.{m}"))))).collect(); + realm.define_host_object(name, items)?; + } + Ok(()) +} + +fn cannot_edit(id: NodeId) -> HostError { + HostError::Error(format!("Cannot edit PathItem {}: it, or a layer or group it is in, is hidden or locked", id.0)) +} + +/// The path `d` names, which must still be in its document. +fn path_of(h: &super::Host, d: &Data) -> std::result::Result { + let item = item_of(h, d)?; + let is_path = with_doc(h, item.doc, |_, st| st.doc.node(item.id).is_some_and(|n| matches!(n.kind, NodeKind::Path { .. }))); + if is_path { Ok(item) } else { Err(HostError::Type("this is not a PathItem".into())) } +} + +fn this_path(h: &super::Host, a: &[Data]) -> std::result::Result { + path_of(h, arg(a, 0)) +} + +/// The path of the run `run`, document `uid` and id parts `high` and `low`, as a handle gives them. +fn path_at(h: &super::Host, run: f64, uid: f64, high: f64, low: f64) -> std::result::Result { + let doc = find_doc(h, run, uid).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; + let id = id_of(high, low).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; + path_of(h, &path_ref(h, Item { doc, id })) +} + +/// Reads the path of `item` with `f`. +fn read_path(h: &super::Host, item: Item, f: impl FnOnce(&DocState, &crate::doc::Node, &PathData) -> T) -> std::result::Result { + with_doc(h, item.doc, |_, st| match st.doc.node(item.id) { + Some(n) => match n.path_data() { + Some(pd) => Ok(f(st, n, pd)), + None => Err(HostError::Type("this is not a PathItem".into())), + }, + None => Err(HostError::Error(STALE_ITEM.into())), + }) +} + +fn path_ref(h: &super::Host, item: Item) -> Data { + let [high, low] = id_parts(item.id); + host_ref("PathItem", &[float(h.run), float(item.doc.uid), high, low]) +} + +/// How many points a path has, across its subpaths. +fn point_count(pd: &PathData) -> usize { + pd.subpaths.iter().map(|sp| sp.anchors.len()).sum() +} + +/// The subpath and the place in it of point `i`. +fn locate(pd: &PathData, mut i: usize) -> Option<(usize, usize)> { + for (s, sp) in pd.subpaths.iter().enumerate() { + if i < sp.anchors.len() { + return Some((s, i)); + } + i -= sp.anchors.len(); + } + None +} + +fn anchor_json(a: &Anchor) -> Value { + json!({"x": a.p.x, "y": a.p.y, "in": [a.h_in.x, a.h_in.y], "out": [a.h_out.x, a.h_out.y], "smooth": a.kind == AnchorKind::Smooth}) +} + +/// Gives the path of `item` the subpaths `subs` with `path.setAnchors`, unless it has them. +fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::Result<(), HostError> { + let (same, ok) = read_path(h, item, |st, _, pd| (pd.subpaths == subs, editable(&st.doc, item.id)))?; + if same { + return Ok(()); + } + if !ok { + return Err(cannot_edit(item.id)); + } + let subpaths: Vec = + subs.iter().map(|sp| json!({"anchors": sp.anchors.iter().map(anchor_json).collect::>(), "closed": sp.closed})).collect(); + edit_item(h, item, "path.setAnchors", &json!({"id": item.id.0, "subpaths": subpaths}))?; + Ok(()) +} + +/// Runs `id` with `params` and `ids: [item]` on the item, which must be one the user could edit. +/// The paint for new art, the active Fill or Stroke proxy, the last color and gradient and the +/// recent colors, which `paint.setFill`, `paint.setStroke` and `stroke.set` also set, are put +/// back afterwards, so the edit changes only the path. +fn edit_path(h: &super::Host, item: Item, id: &str, mut params: Value) -> std::result::Result { + let ok = with_doc(h, item.doc, |_, st| editable(&st.doc, item.id)); + if !ok { + return Err(cannot_edit(item.id)); + } + if let Some(o) = params.as_object_mut() { + o.insert("ids".into(), json!([item.id.0])); + } + keeping_paint(h, || edit_item(h, item, id, ¶ms)) +} + +/// Runs `f`, then puts back the paint for new art, the active Fill or Stroke proxy, the last color +/// and gradient and the recent colors as they were before it. +fn keeping_paint(h: &super::Host, f: impl FnOnce() -> T) -> T { + let kept = { + let s = h.session.borrow(); + (s.paint.clone(), s.fill_active, s.last_solid, s.last_gradient.clone(), s.recent_colors.clone()) + }; + let r = f(); + let mut s = h.session.borrow_mut(); + (s.paint, s.fill_active, s.last_solid, s.last_gradient, s.recent_colors) = kept; + r +} + +// ---- Document.pathItems ---- + +/// The ids of a document's paths, in the order of its page items. +fn path_items(h: &super::Host, st: &DocState) -> Rc> { + if let Some((uid, doc, ids)) = &*h.dom.paths.borrow() + && *uid == st.uid + && std::sync::Arc::ptr_eq(doc, &st.doc) + { + return ids.clone(); + } + let all = super::page_items(h, st); + let ids: Rc> = + Rc::new(all.iter().copied().filter(|i| st.doc.node(*i).is_some_and(|n| matches!(n.kind, NodeKind::Path { .. }))).collect()); + *h.dom.paths.borrow_mut() = Some((st.uid, st.doc.clone(), ids.clone())); + ids +} + +pub(super) fn doc_path_items(h: &super::Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + Ok(host_ref("PathItems", &[float(h.run), float(doc.uid)])) +} + +fn items_doc(h: &super::Host, a: &[Data]) -> std::result::Result { + doc_of(h, arg(a, 0), "PathItems") +} + +fn items_length(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + Ok(num(float(with_doc(h, doc, |_, st| path_items(h, st).len()) as u64))) +} + +fn items_parent(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + Ok(host_ref("Document", &[float(h.run), float(doc.uid)])) +} + +fn items_at(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let Data::Number(n) = arg(a, 1) else { return Ok(Data::Undefined) }; + let Some(i) = whole(*n).and_then(|i| usize::try_from(i).ok()) else { return Ok(Data::Undefined) }; + Ok(with_doc(h, doc, |_, st| path_items(h, st).get(i).map_or(Data::Undefined, |id| super::item_ref(h, st, *id)))) +} + +fn items_by_name(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let Data::String(name) = arg(a, 1) else { return Err(HostError::Type("give a name, as a string".into())) }; + with_doc(h, doc, |_, st| { + let ids = path_items(h, st); + h.charge_call(ids.len() as u64)?; + let id = ids.iter().find(|i| st.doc.node(**i).and_then(|n| n.name.as_deref()) == Some(name.as_str())); + id.map(|id| super::item_ref(h, st, *id)).ok_or_else(|| HostError::Error(NOT_FOUND.into())) + }) +} + +fn items_index(h: &super::Host, a: &[Data]) -> Answer { + match arg(a, 1) { + Data::String(_) => items_by_name(h, a), + Data::Number(_) => match items_at(h, a)? { + Data::Undefined => Err(HostError::Error(NOT_FOUND.into())), + d => Ok(d), + }, + _ => Err(HostError::Type("give a name or an index".into())), + } +} + +/// `pathItems.removeAll()`: deletes every path of the document in one command. A hidden or locked +/// path, or one in a hidden or locked layer or group, stops it before anything is deleted. +fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let (ids, refused) = with_doc(h, doc, |_, st| { + let ids = path_items(h, st); + let refused: Vec = ids.iter().filter(|i| !editable(&st.doc, **i)).map(|i| i.0).take(20).collect(); + (ids, refused) + }); + if !refused.is_empty() { + let list = refused.iter().map(u64::to_string).collect::>().join(", "); + return Err(HostError::Error(format!("cannot delete hidden or locked paths: {list}"))); + } + if !ids.is_empty() { + on_doc(h, doc.uid, true, |h| command(h, "edit.clear", &json!({"ids": ids.iter().map(|i| i.0).collect::>()})))?; + } + Ok(Data::Undefined) +} + +/// The id in the result of a command that made an object. +fn made_id(r: &Data) -> std::result::Result { + let id = match r { + Data::Object(o) => o.iter().find(|(k, _)| k == "id").and_then(|(_, v)| if let Data::Number(n) = v { whole(*n) } else { None }), + _ => None, + }; + id.map(NodeId).ok_or_else(|| HostError::Error("the path was not made".into())) +} + +/// Runs the command `id` that makes a path in `doc`, the selection kept, and reverses the new +/// path's direction when `reversed`. → the new path. +fn make(h: &super::Host, doc: Doc, id: &str, params: &Value, reversed: bool) -> Answer { + let made = on_doc(h, doc.uid, true, |h| { + let id = made_id(&command(h, id, params)?)?; + if reversed { + command(h, "path.reverse", &json!({"ids": [id.0]}))?; + } + Ok(id) + })?; + let s = h.session.borrow(); + let st = s.documents().iter().find(|d| d.uid == doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + Ok(super::item_ref(h, st, made)) +} + +/// Argument `i`, or `default` when it is left out. +fn number_or(a: &[Data], i: usize, default: f64, what: &str) -> std::result::Result { + given(arg(a, i)).map_or(Ok(default), |d| number(d, what)) +} + +/// A size or radius: finite and not negative. +fn size(a: &[Data], i: usize, default: Option, what: &str) -> std::result::Result { + let v = match (given(arg(a, i)), default) { + (Some(d), _) => number(d, what)?, + (None, Some(v)) => v, + (None, None) => return Err(HostError::Type(format!("{what} must be a finite number"))), + }; + if !(0.0..=super::MAX_SIZE).contains(&v) { + return Err(HostError::Range(format!("{what} must be from 0 to 3999856 points"))); + } + Ok(v) +} + +/// A whole number argument from `min` to `max`. +fn count(a: &[Data], i: usize, default: f64, min: f64, max: f64, what: &str) -> std::result::Result { + let v = number_or(a, i, default, what)?; + if v.fract() != 0.0 || !(min..=max).contains(&v) { + return Err(HostError::Range(format!("{what} must be a whole number from {min} to {max}"))); + } + Ok(v) +} + +fn flag(a: &[Data], i: usize, what: &str) -> std::result::Result { + given(arg(a, i)).map_or(Ok(false), |d| boolean(d, what)) +} + +/// The top-left corner, in document coordinates, of a box whose top-left corner the script gives. +fn corner(h: &super::Host, doc: Doc, left: f64, top: f64) -> std::result::Result { + with_doc(h, doc, |_, st| Ok(frame(st)?.to_document(h.dom.coords.get(), [left, top]))) +} + +/// `rectangle(top, left, width, height, reversed?)`. +fn items_rectangle(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let top = coordinate(arg(a, 1), "top")?; + let left = coordinate(arg(a, 2), "left")?; + let (w, ht) = (size(a, 3, None, "width")?, size(a, 4, None, "height")?); + let reversed = flag(a, 5, "reversed")?; + let p = corner(h, doc, left, top)?; + make(h, doc, "shape.rectangle", &json!({"x": p.x, "y": p.y, "width": w, "height": ht}), reversed) +} + +/// The anchors of a rectangle `r` with elliptical corners of radii `rx` and `ry`, clockwise on the +/// page from the top of the left side. +fn rounded(r: Rect, rx: f64, ry: f64) -> Vec { + const K: f64 = 0.552_284_749_830_793_4; + let (rx, ry) = (rx.min(r.width() / 2.0), ry.min(r.height() / 2.0)); + let (kx, ky) = (rx * K, ry * K); + let a = |p: Point, h_in: Point, h_out: Point| Anchor { p, h_in, h_out, kind: AnchorKind::Corner }; + let (x0, y0, x1, y1) = (r.x0, r.y0, r.x1, r.y1); + let mut out = vec![ + a(Point::new(x0, y0 + ry), Point::new(x0, y0 + ry), Point::new(x0, y0 + ry - ky)), + a(Point::new(x0 + rx, y0), Point::new(x0 + rx - kx, y0), Point::new(x0 + rx, y0)), + a(Point::new(x1 - rx, y0), Point::new(x1 - rx, y0), Point::new(x1 - rx + kx, y0)), + a(Point::new(x1, y0 + ry), Point::new(x1, y0 + ry - ky), Point::new(x1, y0 + ry)), + a(Point::new(x1, y1 - ry), Point::new(x1, y1 - ry), Point::new(x1, y1 - ry + ky)), + a(Point::new(x1 - rx, y1), Point::new(x1 - rx + kx, y1), Point::new(x1 - rx, y1)), + a(Point::new(x0 + rx, y1), Point::new(x0 + rx, y1), Point::new(x0 + rx - kx, y1)), + a(Point::new(x0, y1 - ry), Point::new(x0, y1 - ry + ky), Point::new(x0, y1 - ry)), + ]; + out.dedup_by(|b, a| { + b.p.distance(a.p) < 1e-9 && { + a.h_out = b.h_out; + true + } + }); + if out.len() > 1 + && out.first().zip(out.last()).is_some_and(|(f, l)| f.p.distance(l.p) < 1e-9) + && let Some(l) = out.pop() + && let Some(f) = out.first_mut() + { + f.h_in = l.h_in; + } + out +} + +/// `roundedRectangle(top, left, width, height, horizontalRadius = 15, verticalRadius = 20, +/// reversed = false)`: a closed path with `path.create`. +fn items_rounded_rectangle(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let top = coordinate(arg(a, 1), "top")?; + let left = coordinate(arg(a, 2), "left")?; + let (w, ht) = (size(a, 3, None, "width")?, size(a, 4, None, "height")?); + let (rx, ry) = (size(a, 5, Some(15.0), "horizontalRadius")?, size(a, 6, Some(20.0), "verticalRadius")?); + let reversed = flag(a, 7, "reversed")?; + let p = corner(h, doc, left, top)?; + let anchors: Vec = rounded(Rect::new(p.x, p.y, p.x + w, p.y + ht), rx, ry).iter().map(anchor_json).collect(); + make(h, doc, "path.create", &json!({"anchors": anchors, "closed": true}), reversed) +} + +/// `ellipse(top = 100, left = 100, width = 50, height = 100, reversed = false, inscribed)`. +fn items_ellipse(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let top = given(arg(a, 1)).map_or(Ok(100.0), |d| coordinate(d, "top"))?; + let left = given(arg(a, 2)).map_or(Ok(100.0), |d| coordinate(d, "left"))?; + let (w, ht) = (size(a, 3, Some(50.0), "width")?, size(a, 4, Some(100.0), "height")?); + let reversed = flag(a, 5, "reversed")?; + if flag(a, 6, "inscribed")? { + return Err(HostError::Error("ellipse with inscribed true is not available yet".into())); + } + let p = corner(h, doc, left, top)?; + make(h, doc, "shape.ellipse", &json!({"x": p.x, "y": p.y, "width": w, "height": ht}), reversed) +} + +/// The center of a polygon or star, in document coordinates. +fn center(h: &super::Host, doc: Doc, a: &[Data]) -> std::result::Result { + let x = given(arg(a, 1)).map_or(Ok(200.0), |d| coordinate(d, "centerX"))?; + let y = given(arg(a, 2)).map_or(Ok(300.0), |d| coordinate(d, "centerY"))?; + corner(h, doc, x, y) +} + +/// `polygon(centerX = 200, centerY = 300, radius = 50, sides = 8, reversed = false)`. +fn items_polygon(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let c = center(h, doc, a)?; + let r = size(a, 3, Some(50.0), "radius")?; + let sides = count(a, 4, 8.0, 3.0, 1000.0, "sides")?; + let reversed = flag(a, 5, "reversed")?; + make(h, doc, "shape.polygon", &json!({"cx": c.x, "cy": c.y, "radius": r, "sides": sides}), reversed) +} + +/// `star(centerX = 200, centerY = 300, radius = 50, innerRadius = 20, points = 5, reversed = +/// false)`. +fn items_star(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let c = center(h, doc, a)?; + let r1 = size(a, 3, Some(50.0), "radius")?; + let r2 = size(a, 4, Some(20.0), "innerRadius")?; + let points = count(a, 5, 5.0, 2.0, 1000.0, "points")?; + let reversed = flag(a, 6, "reversed")?; + make(h, doc, "shape.star", &json!({"cx": c.x, "cy": c.y, "radius1": r1, "radius2": r2, "points": points}), reversed) +} + +/// `pathItems.add()`: a path with no points, from `path.create` with empty path data, painted as +/// new art. When new art has no fill and no stroke, the black stroke `path.create` gives an open +/// path is set back to none in the same step. +fn items_add(h: &super::Host, a: &[Data]) -> Answer { + let doc = items_doc(h, a)?; + let made = on_doc(h, doc.uid, true, |h| { + let unpainted = { + let ap = h.session.borrow().new_art(); + ap.fill_paint().is_none() && ap.stroke_paint().is_none() + }; + let id = made_id(&command(h, "path.create", &json!({"d": ""}))?)?; + if unpainted { + keeping_paint(h, || command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]})))?; + } + Ok(id) + })?; + let s = h.session.borrow(); + let st = s.documents().iter().find(|d| d.uid == doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + Ok(super::item_ref(h, st, made)) +} + +// ---- PathItem geometry ---- + +fn path_points(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + let [high, low] = id_parts(item.id); + Ok(host_ref("PathPoints", &[float(h.run), float(item.doc.uid), high, low])) +} + +fn path_closed(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |_, _, pd| Data::Bool(!pd.subpaths.is_empty() && pd.subpaths.iter().all(|sp| sp.closed))) +} + +fn path_set_closed(h: &super::Host, a: &[Data]) -> Answer { + let closed = boolean(arg(a, 1), "closed")?; + let item = this_path(h, a)?; + let subs = read_path(h, item, |_, _, pd| pd.subpaths.iter().map(|sp| SubPath { anchors: sp.anchors.clone(), closed }).collect())?; + write_path(h, item, subs)?; + Ok(Data::Undefined) +} + +/// Whether the path fills by the even-odd rule: its compound path's rule when it is a member of one, +/// as `path.setFillRule` sets it there. +fn path_evenodd(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |st, n, _| { + let owner = st.doc.parent_of(item.id).and_then(|p| st.doc.node(p)).filter(|p| matches!(p.kind, NodeKind::Compound { .. })).unwrap_or(n); + Data::Bool(matches!(owner.kind, NodeKind::Path { rule: FillRule::EvenOdd, .. } | NodeKind::Compound { rule: FillRule::EvenOdd, .. })) + }) +} + +fn path_set_evenodd(h: &super::Host, a: &[Data]) -> Answer { + let on = boolean(arg(a, 1), "evenodd")?; + let item = this_path(h, a)?; + if path_evenodd(h, a)? != Data::Bool(on) { + edit_path(h, item, "path.setFillRule", json!({"rule": if on { "evenOdd" } else { "nonZero" }}))?; + } + Ok(Data::Undefined) +} + +/// The area in square points: negative when the path runs counterclockwise on the page. +fn path_area(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |_, _, pd| num(pd.subpaths.iter().map(SubPath::signed_area).sum())) +} + +fn path_length(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |_, _, pd| num(pd.length())) +} + +fn path_guides(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |_, n, _| Data::Bool(matches!(n.kind, NodeKind::Path { guide: true, .. }))) +} + +fn path_clipping(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + read_path(h, item, |_, n, _| Data::Bool(matches!(n.kind, NodeKind::Path { clipping: true, .. }))) +} + +/// `setEntirePath([[x, y], ...])`: corner points with no handles in place of every point, in one +/// subpath that stays closed when the path was. +fn path_set_entire(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + let Data::Array(list) = arg(a, 1) else { return Err(HostError::Type("setEntirePath needs an array of [x, y] points".into())) }; + if list.len() > MAX_POINTS { + return Err(HostError::Range(format!("setEntirePath takes at most {MAX_POINTS} points"))); + } + let script: Vec<[f64; 2]> = list.iter().map(|d| point(d, "each point")).collect::>()?; + let (f, closed) = read_path(h, item, |st, _, pd| (frame(st), !pd.subpaths.is_empty() && pd.subpaths.iter().all(|sp| sp.closed)))?; + let (f, c) = (f?, h.dom.coords.get()); + let anchors: Vec = script.iter().map(|p| Anchor::corner(f.to_document(c, *p))).collect(); + let subs = if anchors.is_empty() { Vec::new() } else { vec![SubPath::new(anchors, closed)] }; + write_path(h, item, subs)?; + Ok(Data::Undefined) +} + +// ---- PathItem paint ---- + +/// The top fill's paint and the top stroke's paint, width, cap, join, miter limit, dashes and +/// offset, and the overprint flags of both. +struct Look { + fill: Paint, + fill_overprint: bool, + stroke: Paint, + width: f64, + cap: LineCap, + join: LineJoin, + miter: f64, + dashes: Vec, + offset: f64, + stroke_overprint: bool, +} + +/// The look of `item`, read from its compound path or compound shape when it is a member of one, +/// since the paint commands paint that owner in its place. +fn look(h: &super::Host, item: Item) -> std::result::Result { + read_path(h, item, |st, n, _| { + let d = &st.doc; + let owner = d + .parent_of(item.id) + .and_then(|p| d.node(p)) + .filter(|p| matches!(p.kind, NodeKind::Compound { .. }) || p.is_compound_shape()) + .unwrap_or(n); + let ap = &owner.appearance; + let fill = ap.fill(); + let stroke = ap.stroke(); + Look { + fill: fill.map_or(Paint::None, |f| f.paint.clone()), + fill_overprint: fill.is_some_and(|f| f.overprint), + stroke: stroke.map_or(Paint::None, |s| s.paint.clone()), + width: stroke.map_or(0.0, |s| s.width), + cap: stroke.map_or(LineCap::default(), |s| s.cap), + join: stroke.map_or(LineJoin::default(), |s| s.join), + miter: stroke.map_or(10.0, |s| s.miter_limit), + dashes: stroke.and_then(|s| s.dash.as_ref()).map_or_else(Vec::new, |d| d.pattern.clone()), + offset: stroke.and_then(|s| s.dash.as_ref()).map_or(0.0, |d| d.offset), + stroke_overprint: stroke.is_some_and(|s| s.overprint), + } + }) +} + +fn this_look(h: &super::Host, a: &[Data]) -> std::result::Result<(Item, Look), HostError> { + let item = this_path(h, a)?; + Ok((item, look(h, item)?)) +} + +fn path_filled(h: &super::Host, a: &[Data]) -> Answer { + Ok(Data::Bool(!this_look(h, a)?.1.fill.is_none())) +} + +fn path_stroked(h: &super::Host, a: &[Data]) -> Answer { + Ok(Data::Bool(!this_look(h, a)?.1.stroke.is_none())) +} + +/// Sets the fill (`fill`) or the stroke to `color`, or to none, with `paint.setFill` or +/// `paint.setStroke`. +fn set_paint(h: &super::Host, item: Item, fill: bool, color: Option) -> std::result::Result<(), HostError> { + let id = if fill { "paint.setFill" } else { "paint.setStroke" }; + let params = match color { + Some(c) => json!({"color": colors::param(&c)}), + None => json!({"none": true}), + }; + edit_path(h, item, id, params)?; + Ok(()) +} + +/// The paint new art gets for its fill or stroke, as `paint.setFill` or `paint.setStroke` params for +/// the path `item`: a solid color, linked to its global or spot swatch while the document has that +/// swatch; a gradient, a placed one moved onto the path's bounds as new art takes it; or a pattern. +/// A fill or stroke of none gives black. A pattern that its swatch does not give as new art has it +/// (its own placement, or a pattern the document does not have) throws an error. +fn new_art_params(h: &super::Host, item: Item, fill: bool) -> std::result::Result { + let mut ap = h.session.borrow().new_art(); + let top = |ap: &vectorcraft_doc::Appearance| if fill { ap.fill_paint() } else { ap.stroke_paint() }; + let what = if fill { "filled" } else { "stroked" }; + let paint = top(&ap); + match &paint { + Paint::None => Ok(json!({"color": colors::param(&Color::BLACK)})), + Paint::Solid { color, swatch: Some(name), tint } => { + let linked = read_path(h, item, |st, _, _| st.doc.swatch(name).is_some())?; + Ok(match linked { + true if *tint < 1.0 => json!({"swatch": name, "tint": f64::from(*tint) * 100.0}), + true => json!({"swatch": name}), + false => json!({"color": colors::param(color)}), + }) + } + Paint::Solid { color, .. } => Ok(json!({"color": colors::param(color)})), + Paint::Gradient(g) => { + let mut g = g.clone(); + if g.geom.is_some() || g.freeform.is_some() { + match read_path(h, item, |_, n, _| n.geometric_bounds())? { + Some(b) => { + ap.rebase_gradients(GraphicStyle::UNIT_BOX, b); + if let Paint::Gradient(placed) = top(&ap) { + g = placed; + } + } + None => (g.geom, g.freeform) = (None, None), + } + } + Ok(json!({"gradient": gradient_params(&g), "keepModel": true})) + } + Paint::Pattern { pattern, .. } => { + let given = read_path(h, item, |st, _, _| { + let d = &st.doc; + d.swatch(pattern).map(|sw| sw.paint.clone()).or_else(|| d.pattern(pattern).map(|_| pattern_paint(pattern))) + })?; + match given { + Some(p) if p == paint => Ok(json!({"swatch": pattern})), + Some(_) => Err(HostError::Error(format!( + "Cannot set {what}: new art's pattern `{pattern}` has a placement of its own, which is not available yet" + ))), + None => Err(HostError::Error(format!("Cannot set {what}: new art's pattern `{pattern}` is not in this document"))), + } + } + } +} + +fn set_painted(h: &super::Host, a: &[Data], fill: bool) -> Answer { + let on = boolean(arg(a, 1), if fill { "filled" } else { "stroked" })?; + let (item, look) = this_look(h, a)?; + let now = if fill { !look.fill.is_none() } else { !look.stroke.is_none() }; + if now != on { + let params = if on { new_art_params(h, item, fill)? } else { json!({"none": true}) }; + edit_path(h, item, if fill { "paint.setFill" } else { "paint.setStroke" }, params)?; + } + Ok(Data::Undefined) +} + +fn path_set_filled(h: &super::Host, a: &[Data]) -> Answer { + set_painted(h, a, true) +} + +fn path_set_stroked(h: &super::Host, a: &[Data]) -> Answer { + set_painted(h, a, false) +} + +fn path_fill_color(h: &super::Host, a: &[Data]) -> Answer { + Ok(colors::of_paint(&this_look(h, a)?.1.fill)) +} + +fn path_stroke_color(h: &super::Host, a: &[Data]) -> Answer { + Ok(colors::of_paint(&this_look(h, a)?.1.stroke)) +} + +fn set_color(h: &super::Host, a: &[Data], fill: bool) -> Answer { + let color = colors::assigned(arg(a, 1), if fill { "fillColor" } else { "strokeColor" })?; + let (item, look) = this_look(h, a)?; + let now = if fill { &look.fill } else { &look.stroke }; + let same = match (&color, now) { + (None, Paint::None) => true, + (Some(c), Paint::Solid { color, swatch: None, .. }) => c == color, + _ => false, + }; + if !same { + set_paint(h, item, fill, color)?; + } + Ok(Data::Undefined) +} + +fn path_set_fill_color(h: &super::Host, a: &[Data]) -> Answer { + set_color(h, a, true) +} + +fn path_set_stroke_color(h: &super::Host, a: &[Data]) -> Answer { + set_color(h, a, false) +} + +/// Runs `stroke.set` with `params` on the path, unless `same`. +fn set_stroke_option(h: &super::Host, item: Item, same: bool, params: Value) -> Answer { + if !same { + edit_path(h, item, "stroke.set", params)?; + } + Ok(Data::Undefined) +} + +fn path_stroke_width(h: &super::Host, a: &[Data]) -> Answer { + Ok(num(this_look(h, a)?.1.width)) +} + +fn path_set_stroke_width(h: &super::Host, a: &[Data]) -> Answer { + let w = number(arg(a, 1), "strokeWidth")?; + if !(0.0..=MAX_STROKE_WIDTH).contains(&w) { + return Err(HostError::Range("strokeWidth must be from 0 to 1000 points".into())); + } + let (item, look) = this_look(h, a)?; + set_stroke_option(h, item, (look.width - w).abs() < 1e-9, json!({"weight": w})) +} + +const CAPS: &[(LineCap, &str, &str)] = &[ + (LineCap::Butt, "StrokeCap.BUTTENDCAP", "butt"), + (LineCap::Round, "StrokeCap.ROUNDENDCAP", "round"), + (LineCap::Square, "StrokeCap.PROJECTINGENDCAP", "square"), +]; + +const JOINS: &[(LineJoin, &str, &str)] = &[ + (LineJoin::Bevel, "StrokeJoin.BEVELENDJOIN", "bevel"), + (LineJoin::Round, "StrokeJoin.ROUNDENDJOIN", "round"), + (LineJoin::Miter, "StrokeJoin.MITERENDJOIN", "miter"), +]; + +fn path_stroke_cap(h: &super::Host, a: &[Data]) -> Answer { + let cap = this_look(h, a)?.1.cap; + Ok(Data::String(CAPS.iter().find(|c| c.0 == cap).map_or("StrokeCap.BUTTENDCAP", |c| c.1).into())) +} + +fn path_set_stroke_cap(h: &super::Host, a: &[Data]) -> Answer { + let found = match arg(a, 1) { + Data::String(s) => CAPS.iter().find(|c| c.1 == s), + _ => None, + }; + let Some(&(cap, _, name)) = found else { return Err(HostError::Type("strokeCap must be a StrokeCap value".into())) }; + let (item, look) = this_look(h, a)?; + set_stroke_option(h, item, look.cap == cap, json!({"cap": name})) +} + +fn path_stroke_join(h: &super::Host, a: &[Data]) -> Answer { + let join = this_look(h, a)?.1.join; + Ok(Data::String(JOINS.iter().find(|j| j.0 == join).map_or("StrokeJoin.MITERENDJOIN", |j| j.1).into())) +} + +fn path_set_stroke_join(h: &super::Host, a: &[Data]) -> Answer { + let found = match arg(a, 1) { + Data::String(s) => JOINS.iter().find(|j| j.1 == s), + _ => None, + }; + let Some(&(join, _, name)) = found else { return Err(HostError::Type("strokeJoin must be a StrokeJoin value".into())) }; + let (item, look) = this_look(h, a)?; + set_stroke_option(h, item, look.join == join, json!({"join": name})) +} + +fn path_miter(h: &super::Host, a: &[Data]) -> Answer { + Ok(num(this_look(h, a)?.1.miter)) +} + +fn path_set_miter(h: &super::Host, a: &[Data]) -> Answer { + let v = number(arg(a, 1), "strokeMiterLimit")?; + if !(1.0..=500.0).contains(&v) { + return Err(HostError::Range("strokeMiterLimit must be from 1 to 500".into())); + } + let (item, look) = this_look(h, a)?; + set_stroke_option(h, item, (look.miter - v).abs() < 1e-9, json!({"miterLimit": v})) +} + +fn path_dashes(h: &super::Host, a: &[Data]) -> Answer { + Ok(Data::Array(this_look(h, a)?.1.dashes.into_iter().map(num).collect())) +} + +/// `strokeDashes = [lengths]`: at most [`MAX_DASHES`] finite lengths that are not negative and +/// not all 0; `[]` or `{}` gives a solid line. +fn path_set_dashes(h: &super::Host, a: &[Data]) -> Answer { + let lengths: Vec = match arg(a, 1) { + Data::Object(o) if o.is_empty() => Vec::new(), + Data::Array(list) if list.len() > MAX_DASHES => return Err(HostError::Range(format!("strokeDashes takes at most {MAX_DASHES} lengths"))), + Data::Array(list) => list.iter().map(|d| number(d, "each dash length")).collect::>()?, + _ => return Err(HostError::Type("strokeDashes must be an array of lengths".into())), + }; + if lengths.iter().any(|l| !(0.0..=MAX_STROKE_WIDTH * 1000.0).contains(l)) { + return Err(HostError::Range("each dash length must be from 0 to 1000000 points".into())); + } + if !lengths.is_empty() && lengths.iter().all(|l| *l == 0.0) { + return Err(HostError::Range("strokeDashes needs a length that is not 0".into())); + } + let (item, look) = this_look(h, a)?; + let dash = if lengths.is_empty() { Value::Null } else { json!(lengths) }; + set_stroke_option(h, item, look.dashes == lengths, json!({"dash": dash})) +} + +fn path_dash_offset(h: &super::Host, a: &[Data]) -> Answer { + Ok(num(this_look(h, a)?.1.offset)) +} + +fn path_set_dash_offset(h: &super::Host, a: &[Data]) -> Answer { + let v = number(arg(a, 1), "strokeDashOffset")?; + if v.abs() > MAX_STROKE_WIDTH * 1000.0 { + return Err(HostError::Range("strokeDashOffset must be from -1000000 to 1000000 points".into())); + } + let (item, look) = this_look(h, a)?; + if look.dashes.is_empty() && v != 0.0 { + return Err(HostError::Error("strokeDashOffset needs strokeDashes first".into())); + } + set_stroke_option(h, item, (look.offset - v).abs() < 1e-9, json!({"dashOffset": v})) +} + +fn path_fill_overprint(h: &super::Host, a: &[Data]) -> Answer { + Ok(Data::Bool(this_look(h, a)?.1.fill_overprint)) +} + +fn path_stroke_overprint(h: &super::Host, a: &[Data]) -> Answer { + Ok(Data::Bool(this_look(h, a)?.1.stroke_overprint)) +} + +fn set_overprint(h: &super::Host, a: &[Data], fill: bool) -> Answer { + let key = if fill { "fill" } else { "stroke" }; + let on = boolean(arg(a, 1), if fill { "fillOverprint" } else { "strokeOverprint" })?; + let (item, look) = this_look(h, a)?; + let (now, paint) = if fill { (look.fill_overprint, &look.fill) } else { (look.stroke_overprint, &look.stroke) }; + if now != on { + if paint.is_none() { + return Err(HostError::Error(format!("the path has no {key} to overprint"))); + } + edit_path(h, item, "object.setOverprint", json!({key: on}))?; + } + Ok(Data::Undefined) +} + +fn path_set_fill_overprint(h: &super::Host, a: &[Data]) -> Answer { + set_overprint(h, a, true) +} + +fn path_set_stroke_overprint(h: &super::Host, a: &[Data]) -> Answer { + set_overprint(h, a, false) +} + +// ---- PathItem transforms ---- + +/// The point of the path's geometric bounds `r`, in document coordinates, that a `Transformation` +/// value names (left out: the center). +fn about(h: &super::Host, item: Item, d: &Data, r: Rect) -> std::result::Result { + let name = match d { + Data::Undefined => "Transformation.CENTER", + Data::String(s) => s.as_str(), + _ => return Err(HostError::Type("give a Transformation value".into())), + }; + let (cx, cy) = ((r.x0 + r.x1) / 2.0, (r.y0 + r.y1) / 2.0); + Ok(match name.strip_prefix("Transformation.").unwrap_or("") { + "CENTER" => Point::new(cx, cy), + "TOP" => Point::new(cx, r.y0), + "BOTTOM" => Point::new(cx, r.y1), + "LEFT" => Point::new(r.x0, cy), + "RIGHT" => Point::new(r.x1, cy), + "TOPLEFT" => Point::new(r.x0, r.y0), + "TOPRIGHT" => Point::new(r.x1, r.y0), + "BOTTOMLEFT" => Point::new(r.x0, r.y1), + "BOTTOMRIGHT" => Point::new(r.x1, r.y1), + "DOCUMENTORIGIN" => with_doc(h, item.doc, |_, st| Ok::<_, HostError>(frame(st)?.to_document(Coords::Document, [0.0, 0.0])))?, + _ => return Err(HostError::Type("give a Transformation value".into())), + }) +} + +/// The `objects` and `patterns` options of a transform command from the four flags from `i`: +/// objects, fill patterns, fill gradients and stroke patterns, each left out or true or false. +fn transform_options(a: &[Data], i: usize, params: &mut Value) -> std::result::Result<(), HostError> { + let names = ["changePositions", "changeFillPatterns", "changeFillGradients", "changeStrokePattern"]; + let mut flags = [None; 4]; + for (k, name) in names.iter().enumerate() { + flags[k] = given(arg(a, i + k)).map(|d| boolean(d, name)).transpose()?; + } + if flags[2] == Some(false) { + return Err(HostError::Error(format!("{} false is not available yet: gradients move with the art", names[2]))); + } + if let (Some(f), Some(s)) = (flags[1], flags[3]) + && f != s + { + return Err(HostError::Error(format!("{} and {} must be the same here", names[1], names[3]))); + } + if let Some(o) = params.as_object_mut() { + if let Some(b) = flags[0] { + o.insert("objects".into(), json!(b)); + } + if let Some(b) = flags[1].or(flags[3]) { + o.insert("patterns".into(), json!(b)); + } + } + Ok(()) +} + +/// `translate(deltaX = 0, deltaY = 0, transformObjects?, transformFillPatterns?, ...)`. +fn path_translate(h: &super::Host, a: &[Data]) -> Answer { + let dx = given(arg(a, 1)).map_or(Ok(0.0), |d| coordinate(d, "deltaX"))?; + let dy = given(arg(a, 2)).map_or(Ok(0.0), |d| coordinate(d, "deltaY"))?; + let item = this_path(h, a)?; + let mut params = json!({"dx": dx, "dy": if h.dom.coords.get() == Coords::Document { -dy } else { dy }}); + transform_options(a, 3, &mut params)?; + if dx != 0.0 || dy != 0.0 { + edit_path(h, item, "object.move", params)?; + } + Ok(Data::Undefined) +} + +/// `rotate(angle, changePositions?, ..., rotateAbout?)`: counterclockwise on the page for a +/// positive angle. +fn path_rotate(h: &super::Host, a: &[Data]) -> Answer { + let angle = number(arg(a, 1), "angle")?; + let item = this_path(h, a)?; + let (r, _) = item_rect(h, item, false)?; + let origin = about(h, item, arg(a, 6), r)?; + let mut params = json!({"angle": angle, "origin": [origin.x, origin.y]}); + transform_options(a, 2, &mut params)?; + if angle.rem_euclid(360.0) != 0.0 { + edit_path(h, item, "object.rotate", params)?; + } + Ok(Data::Undefined) +} + +/// `resize(scaleX, scaleY, changePositions?, ..., changeLineWidths?, scaleAbout?)`: 100 is 100%; +/// `changeLineWidths` scales the stroke weight by that percent. +fn path_resize(h: &super::Host, a: &[Data]) -> Answer { + let sx = number(arg(a, 1), "scaleX")?; + let sy = number(arg(a, 2), "scaleY")?; + if sx == 0.0 || sy == 0.0 || sx.abs() > 100_000.0 || sy.abs() > 100_000.0 { + return Err(HostError::Range("scaleX and scaleY must not be 0 and at most 100000 percent".into())); + } + let widths = given(arg(a, 7)).map(|d| number(d, "changeLineWidths")).transpose()?; + if widths.is_some_and(|w| !(0.0..=100_000.0).contains(&w)) { + return Err(HostError::Range("changeLineWidths must be from 0 to 100000 percent".into())); + } + let item = this_path(h, a)?; + let (r, _) = item_rect(h, item, false)?; + let origin = about(h, item, arg(a, 8), r)?; + let mut params = json!({"sx": sx, "sy": sy, "origin": [origin.x, origin.y], "basis": "page", "strokes": false}); + transform_options(a, 3, &mut params)?; + let width = look(h, item)?.width; + let new_width = widths.map(|w| width * w / 100.0); + if new_width.is_some_and(|w| w > MAX_STROKE_WIDTH) { + return Err(HostError::Range("changeLineWidths would make the stroke weight more than 1000 points".into())); + } + if sx != 100.0 || sy != 100.0 { + edit_path(h, item, "object.scale", params)?; + } + if let Some(w) = new_width + && (w - width).abs() > 1e-9 + { + edit_path(h, item, "stroke.set", json!({"weight": w}))?; + } + Ok(Data::Undefined) +} + +// ---- PathPoints ---- + +fn points_path(h: &super::Host, a: &[Data]) -> std::result::Result { + let Some(handle) = handle_of(arg(a, 0), "PathPoints") else { return Err(HostError::Type("this is not a PathPoints".into())) }; + let [run, uid, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoints".into())) }; + path_at(h, *run, *uid, *high, *low) +} + +fn points_length(h: &super::Host, a: &[Data]) -> Answer { + let item = points_path(h, a)?; + read_path(h, item, |_, _, pd| num(float(point_count(pd) as u64))) +} + +fn points_parent(h: &super::Host, a: &[Data]) -> Answer { + let item = points_path(h, a)?; + Ok(path_ref(h, item)) +} + +fn point_ref(h: &super::Host, item: Item, i: usize) -> Data { + let [high, low] = id_parts(item.id); + host_ref("PathPoint", &[float(h.run), float(item.doc.uid), high, low, float(i as u64)]) +} + +fn points_at(h: &super::Host, a: &[Data]) -> Answer { + let item = points_path(h, a)?; + let Data::Number(n) = arg(a, 1) else { return Ok(Data::Undefined) }; + let Some(i) = whole(*n).and_then(|i| usize::try_from(i).ok()) else { return Ok(Data::Undefined) }; + let n = read_path(h, item, |_, _, pd| point_count(pd))?; + Ok(if i < n { point_ref(h, item, i) } else { Data::Undefined }) +} + +/// `index(key)`: the points are not named, so a key that is not a number throws `Not found`. +fn points_index(h: &super::Host, a: &[Data]) -> Answer { + match arg(a, 1) { + Data::Number(_) => match points_at(h, a)? { + Data::Undefined => Err(HostError::Error(NOT_FOUND.into())), + d => Ok(d), + }, + _ => Err(HostError::Error(NOT_FOUND.into())), + } +} + +fn points_add(h: &super::Host, a: &[Data]) -> Answer { + let item = points_path(h, a)?; + let (mut subs, n, origin) = read_path(h, item, |st, _, pd| { + let origin = frame(st).map(|f| f.to_document(h.dom.coords.get(), [0.0, 0.0])); + (pd.subpaths.clone(), point_count(pd), origin) + })?; + if n >= MAX_POINTS { + return Err(HostError::Range(format!("PathPoints.add takes a path to at most {MAX_POINTS} points"))); + } + let p = match subs.iter().rev().find_map(|sp| sp.anchors.last()) { + Some(last) => last.p, + None => origin?, + }; + match subs.last_mut() { + Some(sp) => sp.anchors.push(Anchor::corner(p)), + None => subs.push(SubPath::new(vec![Anchor::corner(p)], false)), + } + write_path(h, item, subs)?; + Ok(point_ref(h, item, n)) +} + +fn points_remove_all(h: &super::Host, a: &[Data]) -> Answer { + let item = points_path(h, a)?; + write_path(h, item, Vec::new())?; + Ok(Data::Undefined) +} + +// ---- PathPoint ---- + +/// The path and the index of the point `this` names, which must still be in the path. +pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(Item, usize), HostError> { + let Some(handle) = handle_of(arg(a, 0), "PathPoint") else { return Err(HostError::Type("this is not a PathPoint".into())) }; + let [run, uid, high, low, i] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; + let item = path_at(h, *run, *uid, *high, *low)?; + let i = whole(*i).and_then(|i| usize::try_from(i).ok()).ok_or_else(|| HostError::Error(STALE_POINT.into()))?; + let n = read_path(h, item, |_, _, pd| point_count(pd))?; + if i >= n { + return Err(HostError::Error(STALE_POINT.into())); + } + Ok((item, i)) +} + +/// Reads the anchor `this` names with `f`, given the frame and the coordinate system. +fn read_point(h: &super::Host, a: &[Data], f: impl FnOnce(&super::Frame, Coords, &Anchor) -> Data) -> Answer { + let (item, i) = this_point(h, a)?; + let c = h.dom.coords.get(); + read_path(h, item, |st, _, pd| { + let fr = frame(st)?; + let anchor = locate(pd, i).and_then(|(s, j)| pd.subpaths.get(s).and_then(|sp| sp.anchors.get(j))); + anchor.map(|an| f(&fr, c, an)).ok_or_else(|| HostError::Error(STALE_POINT.into())) + })? +} + +/// Changes the anchor `this` names with `f`, given the point the script assigned in document +/// coordinates (for a point property) or the value itself. +fn edit_point(h: &super::Host, a: &[Data], f: impl FnOnce(&mut Anchor)) -> Answer { + let (item, i) = this_point(h, a)?; + let mut subs = read_path(h, item, |_, _, pd| pd.subpaths.clone())?; + let (s, j) = read_path(h, item, |_, _, pd| locate(pd, i))?.ok_or_else(|| HostError::Error(STALE_POINT.into()))?; + if let Some(an) = subs.get_mut(s).and_then(|sp| sp.anchors.get_mut(j)) { + f(an); + } + write_path(h, item, subs)?; + Ok(Data::Undefined) +} + +/// The point the script assigned to a point property, in document coordinates. +fn assigned_point(h: &super::Host, a: &[Data], what: &str) -> std::result::Result { + let p = point(arg(a, 1), what)?; + let (item, _) = this_point(h, a)?; + let fr = with_doc(h, item.doc, |_, st| frame(st))?; + Ok(fr.to_document(h.dom.coords.get(), p)) +} + +fn pt_anchor(h: &super::Host, a: &[Data]) -> Answer { + read_point(h, a, |f, c, an| pair(f.to_script(c, an.p))) +} + +fn pt_set_anchor(h: &super::Host, a: &[Data]) -> Answer { + let p = assigned_point(h, a, "anchor")?; + edit_point(h, a, |an| an.p = p) +} + +fn pt_left(h: &super::Host, a: &[Data]) -> Answer { + read_point(h, a, |f, c, an| pair(f.to_script(c, an.h_in))) +} + +fn pt_set_left(h: &super::Host, a: &[Data]) -> Answer { + let p = assigned_point(h, a, "leftDirection")?; + edit_point(h, a, |an| an.h_in = p) +} + +fn pt_right(h: &super::Host, a: &[Data]) -> Answer { + read_point(h, a, |f, c, an| pair(f.to_script(c, an.h_out))) +} + +fn pt_set_right(h: &super::Host, a: &[Data]) -> Answer { + let p = assigned_point(h, a, "rightDirection")?; + edit_point(h, a, |an| an.h_out = p) +} + +fn pt_type(h: &super::Host, a: &[Data]) -> Answer { + read_point(h, a, |_, _, an| Data::String(if an.kind == AnchorKind::Smooth { "PointType.SMOOTH" } else { "PointType.CORNER" }.into())) +} + +fn pt_set_type(h: &super::Host, a: &[Data]) -> Answer { + let kind = match arg(a, 1) { + Data::String(s) if s == "PointType.CORNER" => AnchorKind::Corner, + Data::String(s) if s == "PointType.SMOOTH" => AnchorKind::Smooth, + _ => return Err(HostError::Type("pointType must be a PointType value".into())), + }; + edit_point(h, a, |an| an.kind = kind) +} + +fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { + let (item, _) = this_point(h, a)?; + Ok(path_ref(h, item)) +} + +/// `remove()`: deletes the point; a subpath left with no points goes too. +fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { + let (item, i) = this_point(h, a)?; + let mut subs = read_path(h, item, |_, _, pd| pd.subpaths.clone())?; + let (s, j) = read_path(h, item, |_, _, pd| locate(pd, i))?.ok_or_else(|| HostError::Error(STALE_POINT.into()))?; + if let Some(sp) = subs.get_mut(s) { + sp.anchors.remove(j); + if sp.anchors.is_empty() { + subs.remove(s); + } + } + write_path(h, item, subs)?; + Ok(Data::Undefined) +} + +// ---- Registration ---- + +/// The members `PathItem` adds to `PageItem`'s. +pub(super) fn path_item_members(l: &Link) -> Vec<(String, HostMember)> { + let mut m = named(vec![ + ("pathPoints", get(l, path_points)), + ("closed", property(l, path_closed, path_set_closed)), + ("evenodd", property(l, path_evenodd, path_set_evenodd)), + ("area", get(l, path_area)), + ("length", get(l, path_length)), + ("guides", get(l, path_guides)), + ("clipping", get(l, path_clipping)), + ("setEntirePath", method(l, path_set_entire)), + ("filled", property(l, path_filled, path_set_filled)), + ("fillColor", property(l, path_fill_color, path_set_fill_color)), + ("fillOverprint", property(l, path_fill_overprint, path_set_fill_overprint)), + ("stroked", property(l, path_stroked, path_set_stroked)), + ("strokeColor", property(l, path_stroke_color, path_set_stroke_color)), + ("strokeOverprint", property(l, path_stroke_overprint, path_set_stroke_overprint)), + ("strokeWidth", property(l, path_stroke_width, path_set_stroke_width)), + ("strokeCap", property(l, path_stroke_cap, path_set_stroke_cap)), + ("strokeJoin", property(l, path_stroke_join, path_set_stroke_join)), + ("strokeMiterLimit", property(l, path_miter, path_set_miter)), + ("strokeDashes", property(l, path_dashes, path_set_dashes)), + ("strokeDashOffset", property(l, path_dash_offset, path_set_dash_offset)), + ("translate", method(l, path_translate)), + ("rotate", method(l, path_rotate)), + ("resize", method(l, path_resize)), + ]); + m.extend(["selectedPathPoints", "polarity", "resolution"].into_iter().map(|n| later(l, "PathItem", n))); + m +} + +/// `PathItems`, `PathPoints` and `PathPoint`. +pub(super) fn classes(l: &Link) -> Vec { + vec![ + class( + "PathItems", + None, + named(vec![ + ("typename", typename_of("PathItems")), + ("length", get(l, items_length)), + ("parent", get(l, items_parent)), + ("index", method(l, items_index)), + ("getByName", method(l, items_by_name)), + ("removeAll", method(l, items_remove_all)), + ("add", method(l, items_add)), + ("rectangle", method(l, items_rectangle)), + ("roundedRectangle", method(l, items_rounded_rectangle)), + ("ellipse", method(l, items_ellipse)), + ("polygon", method(l, items_polygon)), + ("star", method(l, items_star)), + ]), + Some(super::function(l, items_at)), + ), + class( + "PathPoints", + None, + named(vec![ + ("typename", typename_of("PathPoints")), + ("length", get(l, points_length)), + ("parent", get(l, points_parent)), + ("index", method(l, points_index)), + ("add", method(l, points_add)), + ("removeAll", method(l, points_remove_all)), + ]), + Some(super::function(l, points_at)), + ), + class( + "PathPoint", + None, + { + let mut m = named(vec![ + ("typename", typename_of("PathPoint")), + ("parent", get(l, pt_parent)), + ("anchor", property(l, pt_anchor, pt_set_anchor)), + ("leftDirection", property(l, pt_left, pt_set_left)), + ("rightDirection", property(l, pt_right, pt_set_right)), + ("pointType", property(l, pt_type, pt_set_type)), + ("remove", method(l, pt_remove)), + ]); + m.push(later(l, "PathPoint", "selected")); + m + }, + None, + ), + ] +} diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index adcaefd59d..a611da1857 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -173,6 +173,7 @@ mod script_console; mod script_dialogs; mod script_dollar; mod script_dom; +mod script_dom_paths; mod script_engines; mod script_folder; mod script_include; diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 67bd373e2d..fc2cd6ce67 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -646,9 +646,11 @@ fn a_startup_preset_alone_gives_its_first_size() { #[test] fn page_item_members_not_built_yet_throw_on_read_and_assignment() { let (mut s, _, _) = doc(); - for source in - ["app.activeDocument.pageItems[0].blendingMode;", "app.activeDocument.pageItems[0].uuid = 'x';", "app.activeDocument.pageItems[0].rotate(5);"] - { + for source in [ + "app.activeDocument.pageItems[0].blendingMode;", + "app.activeDocument.pageItems[0].uuid = 'x';", + "app.activeDocument.pageItems[0].transform(5);", + ] { assert!(failure(&mut s, source).contains("is not available yet"), "{source}"); } assert!(failure(&mut s, "app.activeDocument.layers = 1;").contains("Document.layers is not available yet")); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs new file mode 100644 index 0000000000..9d9c0c5f7a --- /dev/null +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -0,0 +1,602 @@ +//! The script object model's paths, path points and colors. + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{LineCap, LineJoin}; +use vectorcraft_geom::path::AnchorKind; + +use crate::*; + +fn run(s: &mut Session, source: &str) -> Result { + s.execute("script.run", &json!({"source": source, "name": "t.js"})) +} + +/// What the run logged. +fn log(s: &mut Session, source: &str) -> Vec { + let r = run(s, source).unwrap_or_else(|e| panic!("{source}: {e}")); + r["log"].as_array().cloned().unwrap_or_default() +} + +/// The message of the run's failure. +fn failure(s: &mut Session, source: &str) -> String { + run(s, source).map(|r| panic!("{source} ran: {r}")).unwrap_err().to_string() +} + +fn rect(s: &mut Session, x: f64, y: f64, w: f64, h: f64) -> NodeId { + NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": y, "width": w, "height": h})).unwrap()["id"].as_u64().unwrap()) +} + +/// A 400 × 300 pt document with two rectangles. +fn doc() -> (Session, NodeId, NodeId) { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let a = rect(&mut s, 10.0, 20.0, 30.0, 40.0); + let b = rect(&mut s, 100.0, 100.0, 50.0, 50.0); + s.execute("select.none", &json!({})).unwrap(); + (s, a, b) +} + +fn undo_steps(s: &Session) -> usize { + s.active().unwrap().history.undo.len() +} + +/// The layers of the active document, to show that a failed run changed nothing. +fn art(s: &Session) -> String { + format!("{:?}", s.active().unwrap().doc.layers) +} + +fn node(s: &Session, id: NodeId) -> crate::doc::Node { + s.active().unwrap().doc.node(id).unwrap().clone() +} + +/// Each number of `v` rounded to 3 decimals, in place. +fn rounded(v: &Value) -> Value { + match v { + Value::Number(n) => { + let r = (n.as_f64().unwrap() * 1000.0).round() / 1000.0; + if r.fract() == 0.0 { json!(r as i64) } else { json!(r) } + } + Value::Array(a) => Value::Array(a.iter().map(rounded).collect()), + v => v.clone(), + } +} + +#[test] +fn path_items_are_live_and_list_only_paths() { + let (mut s, a, b) = doc(); + s.execute("object.setProps", &json!({"ids": [a.0], "name": "first"})).unwrap(); + s.execute("text.create", &json!({"x": 10, "y": 250, "text": "hi"})).unwrap(); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let out = log( + &mut s, + "var d = app.activeDocument, p = d.pathItems;\ + vc.log(p.length); vc.log(d.pageItems.length); vc.log(p.typename); vc.log(p.parent.typename);\ + vc.log(p[0].typename); vc.log(p[1].parent.typename); vc.log(p.getByName('first').name);\ + vc.log(p[2] === undefined && p[-1] === undefined);\ + var r = p.rectangle(100, 10, 5, 5); vc.log(p.length); vc.log(p[2].typename);", + ); + let expected = [json!(2), json!(4), json!("PathItems"), json!("Document"), json!("PathItem"), json!("GroupItem"), json!("first"), json!(true)]; + assert_eq!(out[..8], expected); + assert_eq!(out[8..], [json!(3), json!("PathItem")]); + assert!(failure(&mut s, "app.activeDocument.pathItems.getByName('none');").contains("Not found")); + assert!(failure(&mut s, "app.activeDocument.pathItems.index('none');").contains("Not found")); +} + +#[test] +fn path_items_remove_all_refuses_locked_paths_and_changes_nothing() { + let (mut s, a, _) = doc(); + s.execute("object.setProps", &json!({"ids": [a.0], "locked": true})).unwrap(); + let before = art(&s); + let e = failure(&mut s, "app.activeDocument.pathItems.removeAll();"); + assert!(e.contains("hidden or locked paths"), "{e}"); + assert_eq!(art(&s), before); + s.execute("object.setProps", &json!({"ids": [a.0], "locked": false})).unwrap(); + log(&mut s, "app.activeDocument.pathItems.removeAll();"); + assert_eq!(log(&mut s, "vc.log(app.activeDocument.pathItems.length);"), vec![json!(0)]); +} + +#[test] +fn shape_creators_use_documented_defaults_and_y_up() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let steps = undo_steps(&s); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems;\ + vc.log(p.rectangle(250, 10, 30, 40).geometricBounds);\ + vc.log(p.ellipse().geometricBounds);\ + var g = p.polygon(); vc.log(g.pathPoints.length); var b = g.geometricBounds; vc.log([(b[0] + b[2]) / 2, b[1]]);\ + vc.log(p.star().pathPoints.length); vc.log(p.star(0, 0, 10, 5, 7).pathPoints.length);\ + var r = p.roundedRectangle(250, 10, 100, 60); vc.log(r.pathPoints.length); vc.log(r.geometricBounds); vc.log(r.closed);\ + vc.log(p.roundedRectangle(250, 10, 100, 60, 0, 0).pathPoints.length);\ + vc.log(p.length);", + ); + let out: Vec = out.iter().map(rounded).collect(); + assert_eq!(out[0], json!([10, 250, 40, 210])); + assert_eq!(out[1], json!([100, 100, 150, 0])); + assert_eq!(out[2], json!(8)); + assert_eq!(out[3], json!([200, 350]), "the polygon is centered on (200, 300) and reaches 50 pt up"); + assert_eq!(out[4], json!(10)); + assert_eq!(out[5], json!(14)); + assert_eq!(out[6], json!(8)); + assert_eq!(out[7], json!([10, 250, 110, 190])); + assert_eq!(out[8], json!(true)); + assert_eq!(out[9], json!(4), "corners of radius 0 leave four points"); + assert_eq!(out[10], json!(7)); + assert_eq!(undo_steps(&s), steps + 1, "one undo step for the run"); + assert!(s.active().unwrap().selection.objects.is_empty(), "the selection stays as it was"); +} + +#[test] +fn shape_creators_reject_bad_sizes_without_change() { + let (mut s, _, _) = doc(); + let before = art(&s); + let steps = undo_steps(&s); + for (source, part) in [ + ("app.activeDocument.pathItems.rectangle(10, 10, -5, 10);", "width"), + ("app.activeDocument.pathItems.rectangle(10, 10, 5);", "height"), + ("app.activeDocument.pathItems.rectangle();", "top"), + ("app.activeDocument.pathItems.ellipse(0, 0, NaN);", "finite"), + ("app.activeDocument.pathItems.polygon(0, 0, 10, 2);", "sides"), + ("app.activeDocument.pathItems.polygon(0, 0, 10, 5.5);", "sides"), + ("app.activeDocument.pathItems.star(0, 0, 10, 5, 1001);", "points"), + ("app.activeDocument.pathItems.star(0, 0, 10, -5);", "innerRadius"), + ("app.activeDocument.pathItems.roundedRectangle(0, 0, 10, 10, -1);", "horizontalRadius"), + ("app.activeDocument.pathItems.rectangle(0, 0, 10, 10, 'yes');", "reversed"), + ("app.activeDocument.pathItems.rectangle(1e12, 0, 10, 10);", "outside the canvas"), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } + assert_eq!(art(&s), before); + assert_eq!(undo_steps(&s), steps); +} + +#[test] +fn set_entire_path_replaces_points_and_keeps_closed() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0];\ + p.setEntirePath([[0, 0], [10, 0], [10, 10]]); vc.log(p.pathPoints.length); vc.log(p.closed); vc.log(p.pathPoints[2].anchor);\ + var n = app.activeDocument.pathItems.add(); vc.log(n.pathPoints.length); vc.log(n.closed);\ + n.setEntirePath([[50, 50], [60, 50]]); vc.log(n.pathPoints.length); vc.log(n.closed); vc.log(n.length);\ + n.closed = true; vc.log(n.closed);", + ); + assert_eq!(out, vec![json!(3), json!(true), json!([10, 10]), json!(0), json!(false), json!(2), json!(false), json!(10), json!(true)]); + let n = node(&s, a); + let pd = n.path_data().unwrap(); + assert_eq!(pd.subpaths.len(), 1); + assert!(pd.subpaths[0].closed); + assert!(pd.subpaths[0].anchors.iter().all(|an| an.h_in == an.p && an.h_out == an.p && an.kind == AnchorKind::Corner)); +} + +#[test] +fn hostile_set_entire_path_input_is_bounded() { + let (mut s, _, _) = doc(); + let before = art(&s); + for (source, part) in [ + ("var a = []; for (var i = 0; i < 100001; i++) a.push([i % 100, 1]); app.activeDocument.pathItems[0].setEntirePath(a);", "at most"), + ("app.activeDocument.pathItems[0].setEntirePath([[0, 0], [NaN, 1]]);", "finite"), + ("app.activeDocument.pathItems[0].setEntirePath([[0, 0], [1]]);", "two numbers"), + ("app.activeDocument.pathItems[0].setEntirePath('0,0');", "array"), + ("app.activeDocument.pathItems[0].setEntirePath([[0, 1e13]]);", "outside the canvas"), + ( + "var o = {}; Object.defineProperty(o, 0, {get: function () { return 1; }}); app.activeDocument.pathItems[0].setEntirePath([o]);", + "two numbers", + ), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } + assert_eq!(art(&s), before); +} + +#[test] +fn path_point_setters_edit_one_anchor() { + let (mut s, a, _) = doc(); + let anchors_before = node(&s, a).path_data().unwrap().subpaths[0].anchors.to_vec(); + let out = log( + &mut s, + "var pp = app.activeDocument.pathItems[0].pathPoints, q = pp[1];\ + vc.log(pp.length); vc.log(pp.typename); vc.log(q.typename); vc.log(q.parent.typename); vc.log(q.anchor);\ + q.anchor = [45, 285]; vc.log(q.anchor); vc.log(q.leftDirection); vc.log(q.rightDirection);\ + q.rightDirection = [55, 285]; q.leftDirection = [35, 285]; vc.log(q.pointType);\ + q.pointType = PointType.SMOOTH; vc.log(q.pointType); q.pointType = PointType.CORNER; vc.log(q.pointType);\ + vc.log(pp.index(1).anchor);", + ); + assert_eq!(out[0], json!(4)); + assert_eq!(out[1], json!("PathPoints")); + assert_eq!(out[2], json!("PathPoint")); + assert_eq!(out[3], json!("PathItem")); + assert_eq!(out[5], json!([45, 285])); + assert_eq!(out[6], json!([40, 280]), "moving the anchor leaves its handles"); + assert_eq!(out[8], json!("PointType.CORNER"), "moving handles leaves the point type"); + assert_eq!(out[9], json!("PointType.SMOOTH")); + assert_eq!(out[10], json!("PointType.CORNER"), "a corner with handles in line stays a corner"); + assert_eq!(out[11], json!([45, 285])); + let anchors = node(&s, a).path_data().unwrap().subpaths[0].anchors.to_vec(); + for i in [0, 2, 3] { + assert_eq!(anchors[i], anchors_before[i], "point {i} did not change"); + } + assert!(failure(&mut s, "app.activeDocument.pathItems[0].pathPoints.index('a');").contains("Not found")); + assert!(failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].pointType = 'SMOOTH';").contains("PointType")); + assert!(failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].anchor = [1, 'x'];").contains("finite")); + assert_eq!(log(&mut s, "vc.log(app.activeDocument.pathItems[0].pathPoints.getByName === undefined);"), vec![json!(true)]); +} + +#[test] +fn path_point_wrapper_goes_stale_after_remove() { + let (mut s, _, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], pp = p.pathPoints, last = pp[3];\ + pp[0].remove(); vc.log(pp.length); vc.log(pp[0].anchor);\ + try { last.anchor; } catch (e) { vc.log(e.message); } try { last.selected; } catch (e) { vc.log(e.message); }\ + var n = pp.add(); vc.log(pp.length); vc.log(n.anchor);\ + pp.removeAll(); vc.log(pp.length); vc.log(app.activeDocument.pathItems.length);\ + p.remove(); try { pp.length; } catch (e) { vc.log(e.message); } try { p.closed; } catch (e) { vc.log(e.message); }\ + try { p.polarity; } catch (e) { vc.log(e.message); }", + ); + assert_eq!( + out, + vec![ + json!(3), + json!([40, 280]), + json!("Stale path point"), + json!("Stale path point"), + json!(4), + json!([10, 240]), + json!(0), + json!(2), + json!("Stale page item"), + json!("Stale page item"), + json!("Stale page item") + ] + ); +} + +#[test] +fn fill_color_round_trips_rgb_cmyk_gray_lab() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], c = new RGBColor(); vc.log(c.typename); vc.log([c.red, c.green, c.blue]);\ + c.red = 255; c.blue = 128; p.fillColor = c; var f = p.fillColor; vc.log([f.typename, f.red, f.green, f.blue]);\ + var k = new cmykColor(); k.cyan = 10; k.black = 50; p.strokeColor = k; var t = p.strokeColor; vc.log([t.typename, t.cyan, t.black]);\ + var g = new GrayColor(); g.gray = 25; p.fillColor = g; vc.log([p.fillColor.typename, p.fillColor.gray]);\ + var l = new LabColor(); l.l = 50; l.a = -20; l.b = 30; p.strokeColor = l; vc.log([p.strokeColor.l, p.strokeColor.a, p.strokeColor.b]);", + ); + assert_eq!(out[0], json!("RGBColor")); + assert_eq!(out[1], json!([0, 0, 0])); + assert_eq!(rounded(&out[2]), json!(["RGBColor", 255, 0, 128])); + assert_eq!(rounded(&out[3]), json!(["CMYKColor", 10, 50])); + assert_eq!(rounded(&out[4]), json!(["GrayColor", 25])); + assert_eq!(rounded(&out[5]), json!([50, -20, 30])); + let n = node(&s, a); + match n.appearance.fill_paint() { + Paint::Solid { color: Color::Gray { k }, .. } => assert!((k - 0.75).abs() < 1e-6, "gray 25 is 75% black ink, got {k}"), + p => panic!("fill is {p:?}"), + } +} + +#[test] +fn no_color_unfills_and_unstrokes() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; vc.log([p.filled, p.stroked]);\ + p.fillColor = new NoColor(); p.stroked = false; vc.log([p.filled, p.stroked, p.fillColor.typename]);\ + p.filled = true; vc.log(p.filled);", + ); + assert_eq!(out, vec![json!([true, true]), json!([false, false, "NoColor"]), json!(true)]); + let n = node(&s, a); + assert!(n.appearance.stroke_paint().is_none()); + assert!(!n.appearance.fill_paint().is_none()); +} + +#[test] +fn path_paint_edits_leave_new_art_and_recent_colors() { + let (mut s, _, _) = doc(); + let (paint, active, last, recent) = (s.paint.clone(), s.fill_active, s.last_solid, s.recent_colors.clone()); + log( + &mut s, + "var p = app.activeDocument.pathItems[0], c = new RGBColor(); c.red = 200; c.green = 10; c.blue = 30;\ + p.fillColor = c; p.strokeColor = c; p.strokeWidth = 7; p.strokeCap = StrokeCap.ROUNDENDCAP; p.filled = false;", + ); + assert_eq!(s.paint, paint, "the paint for new art"); + assert_eq!(s.fill_active, active); + assert_eq!(s.last_solid, last); + assert_eq!(s.recent_colors, recent); +} + +#[test] +fn compound_path_members_read_the_paint_they_are_given() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.compoundPath.make", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], c = new RGBColor(); c.red = 200; p.fillColor = c; p.strokeWidth = 4;\ + vc.log([p.fillColor.red, p.fillColor.green, p.strokeWidth]); vc.log(app.activeDocument.pathItems[1].fillColor.red);\ + p.evenodd = true; vc.log([p.evenodd, app.activeDocument.pathItems[1].evenodd]);", + ); + assert_eq!(rounded(&out[0]), json!([200, 0, 4])); + assert_eq!(rounded(&out[1]), json!(200), "the compound path paints every member"); + assert_eq!(out[2], json!([true, true]), "the compound path holds the fill rule"); +} + +#[test] +fn a_spot_color_reads_as_a_spot_color_and_keeps_its_link() { + let (mut s, a) = doc_with_paints(); + s.execute("paint.setFill", &json!({"ids": [a.0], "swatch": "Ink", "tint": 40})).unwrap(); + let before = node(&s, a).appearance.fill_paint(); + let out = log(&mut s, "var p = app.activeDocument.pathItems[0]; vc.log([p.fillColor.typename, p.fillColor.tint]);"); + assert_eq!(rounded(&out[0]), json!(["SpotColor", 40])); + assert!(failure(&mut s, "var p = app.activeDocument.pathItems[0]; p.fillColor = p.fillColor;").contains("SpotColor is not available yet")); + assert_eq!(node(&s, a).appearance.fill_paint(), before, "the fill stays linked to its swatch"); +} + +#[test] +fn filled_true_on_a_filled_path_runs_no_command() { + let (mut s, _, _) = doc(); + let steps = undo_steps(&s); + log( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.filled = true; p.stroked = true; p.fillColor = p.fillColor;\ + p.strokeWidth = p.strokeWidth; p.strokeCap = p.strokeCap; p.closed = true; p.evenodd = false; p.strokeDashes = [];\ + p.pathPoints[0].anchor = p.pathPoints[0].anchor; p.translate(0, 0); p.rotate(360); p.resize(100, 100);", + ); + assert_eq!(undo_steps(&s), steps, "values that change nothing add no step"); +} + +#[test] +fn an_added_point_follows_the_last_point_before_an_empty_subpath() { + let (mut s, a, _) = doc(); + let subpaths = json!([{"anchors": [{"x": 10, "y": 20}, {"x": 40, "y": 20}], "closed": false}, {"anchors": [], "closed": false}]); + s.execute("path.setAnchors", &json!({"id": a.0, "subpaths": subpaths})).unwrap(); + assert!(node(&s, a).path_data().is_some_and(|pd| pd.subpaths.len() == 2), "the empty subpath is kept"); + let out = log( + &mut s, + "var pp = app.activeDocument.pathItems[0].pathPoints; var n = pp.add(); vc.log(pp.length); vc.log(n.anchor); vc.log(pp[1].anchor);", + ); + assert_eq!(out[0], json!(3)); + assert_eq!(out[1], out[2], "the new point is at the last point"); +} + +#[test] +fn transforms_change_the_path_and_not_the_selected_one() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + let (before_a, before_b) = (node(&s, a).geometric_bounds(), node(&s, b).geometric_bounds()); + log(&mut s, "var p = app.activeDocument.pathItems[0]; p.translate(5, 0); p.rotate(90); p.resize(50, 50);"); + assert_ne!(node(&s, a).geometric_bounds(), before_a, "the path the script named changes"); + assert_eq!(node(&s, b).geometric_bounds(), before_b, "the selected path stays"); + assert_eq!(s.active().unwrap().selection.objects, [b], "the selection stays"); +} + +#[test] +fn an_added_path_takes_new_art_without_a_fill_or_stroke() { + let (mut s, _, _) = doc(); + s.execute("paint.setFill", &json!({"none": true})).unwrap(); + s.execute("paint.setStroke", &json!({"none": true})).unwrap(); + let unpainted = |s: &Session| { + let ap = s.new_art(); + matches!(ap.fill_paint(), Paint::None) && matches!(ap.stroke_paint(), Paint::None) + }; + assert!(unpainted(&s)); + let (steps, recent) = (undo_steps(&s), s.recent_colors.clone()); + let out = log(&mut s, "var n = app.activeDocument.pathItems.add(); vc.log(n.filled); vc.log(n.stroked); vc.log(n.pathPoints.length);"); + assert_eq!(out, [json!(false), json!(false), json!(0)]); + assert_eq!(undo_steps(&s), steps + 1, "one step for the run"); + assert!(unpainted(&s), "new art keeps no fill and no stroke"); + assert_eq!(s.recent_colors, recent); + s.execute("paint.setStroke", &json!({"color": "#ff0000"})).unwrap(); + let out = log(&mut s, "var n = app.activeDocument.pathItems.add(); vc.log(n.filled); vc.log(n.stroked); vc.log(n.strokeColor.red);"); + assert_eq!(out, [json!(false), json!(true), json!(255)], "a new-art stroke stays"); +} + +/// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke. +fn doc_with_paints() -> (Session, NodeId) { + let (mut s, a, _) = doc(); + let dot = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + s.execute("object.pattern.make", &json!({"ids": [dot.0], "name": "Dots", "width": 20, "height": 20, "edit": false})).unwrap(); + s.execute("select.set", &json!({"ids": [dot.0]})).unwrap(); + s.execute("edit.clear", &json!({})).unwrap(); + s.execute("swatch.new", &json!({"name": "Ink", "color": "#2a6fb0", "spot": true})).unwrap(); + s.execute("paint.setFill", &json!({"ids": [a.0], "none": true})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [a.0], "none": true})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + (s, a) +} + +#[test] +fn filled_and_stroked_true_give_the_new_art_paint() { + let kinds = [ + json!({"color": "#00ff00"}), + json!({"swatch": "Ink", "tint": 40}), + json!({"gradient": {"kind": "radial", "stops": [{"offset": 0, "color": "#ff0000"}, {"offset": 1, "color": "#0000ff"}]}}), + json!({"swatch": "Dots"}), + ]; + for fill in [true, false] { + for params in &kinds { + let (mut s, a) = doc_with_paints(); + s.execute(if fill { "paint.setFill" } else { "paint.setStroke" }, params).unwrap(); + let new_art = s.new_art(); + let want = if fill { new_art.fill_paint() } else { new_art.stroke_paint() }; + assert!(!matches!(want, Paint::None), "{params}: new art takes the paint"); + log(&mut s, if fill { "app.activeDocument.pathItems[0].filled = true;" } else { "app.activeDocument.pathItems[0].stroked = true;" }); + let n = node(&s, a); + let got = if fill { n.appearance.fill_paint() } else { n.appearance.stroke_paint() }; + assert_eq!(crate::cmd::gradient::unplaced(&got), want, "fill {fill}, {params}"); + } + } +} + +#[test] +fn filled_true_throws_for_a_new_art_pattern_it_cannot_give() { + let placed = vectorcraft_color::Paint::Pattern { pattern: "Dots".into(), xf: vectorcraft_geom::Affine::scale(2.0) }; + for (paint, says) in [(placed, "placement of its own"), (vectorcraft_doc::pattern::pattern_paint("Gone"), "not in this document")] { + for fill in [true, false] { + let (mut s, _) = doc_with_paints(); + if fill { + s.paint.fill = paint.clone(); + } else { + (s.paint.stroke, s.paint.stroke_width) = (paint.clone(), 1.0); + } + let (before, steps) = (art(&s), undo_steps(&s)); + let e = failure( + &mut s, + if fill { "app.activeDocument.pathItems[0].filled = true;" } else { "app.activeDocument.pathItems[0].stroked = true;" }, + ); + assert!(e.contains(says), "{e}"); + assert_eq!((art(&s), undo_steps(&s)), (before, steps), "nothing changes"); + } + } +} + +#[test] +fn stroke_options_map_to_stroke_set() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0];\ + p.strokeWidth = 4; p.strokeCap = StrokeCap.ROUNDENDCAP; p.strokeJoin = StrokeJoin.BEVELENDJOIN; p.strokeMiterLimit = 7;\ + p.strokeDashes = [6, 3]; p.strokeDashOffset = 2; p.evenodd = true; p.fillOverprint = true;\ + vc.log([p.strokeWidth, p.strokeCap, p.strokeJoin, p.strokeMiterLimit, p.strokeDashes, p.strokeDashOffset, p.evenodd, p.fillOverprint]);\ + p.strokeDashes = {}; vc.log(p.strokeDashes);", + ); + assert_eq!(out[0], json!([4, "StrokeCap.ROUNDENDCAP", "StrokeJoin.BEVELENDJOIN", 7, [6, 3], 2, true, true])); + assert_eq!(out[1], json!([])); + let n = node(&s, a); + let st = n.appearance.stroke().unwrap(); + assert_eq!((st.width, st.cap, st.join, st.miter_limit, st.dash.is_none()), (4.0, LineCap::Round, LineJoin::Bevel, 7.0, true)); + for (source, part) in [ + ("app.activeDocument.pathItems[0].strokeMiterLimit = 600;", "strokeMiterLimit"), + ("app.activeDocument.pathItems[0].strokeCap = 'round';", "StrokeCap"), + ("app.activeDocument.pathItems[0].strokeJoin = StrokeCap.ROUNDENDCAP;", "StrokeJoin"), + ("app.activeDocument.pathItems[0].strokeWidth = -1;", "strokeWidth"), + ("app.activeDocument.pathItems[0].strokeDashes = [0, 0];", "not 0"), + ("app.activeDocument.pathItems[0].strokeDashes = [1, -2];", "dash length"), + ("var d = []; for (var i = 0; i < 65; i++) d.push(1); app.activeDocument.pathItems[0].strokeDashes = d;", "at most 64"), + ("app.activeDocument.pathItems[0].strokeDashOffset = 3;", "strokeDashes first"), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } +} + +#[test] +fn bad_color_components_throw_and_change_nothing() { + let (mut s, _, _) = doc(); + let before = art(&s); + for (source, part) in [ + ("var c = new RGBColor(); c.red = 300; app.activeDocument.pathItems[0].fillColor = c;", "RGBColor.red"), + ("var c = new CMYKColor(); c.cyan = NaN; app.activeDocument.pathItems[0].fillColor = c;", "finite"), + ("var c = new CMYKColor(); c.cyan = -1; app.activeDocument.pathItems[0].fillColor = c;", "CMYKColor.cyan"), + ("var c = new GrayColor(); c.gray = '5'; app.activeDocument.pathItems[0].fillColor = c;", "GrayColor.gray"), + ("var c = new LabColor(); c.a = 200; app.activeDocument.pathItems[0].strokeColor = c;", "LabColor.a"), + ("app.activeDocument.pathItems[0].fillColor = {typename: 'Foo'};", "color object"), + ("app.activeDocument.pathItems[0].fillColor = 5;", "color object"), + ("app.activeDocument.pathItems[0].fillColor = new GradientColor();", "not available yet"), + ("app.activeDocument.pathItems[0].strokeColor = new SpotColor();", "not available yet"), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } + assert_eq!(art(&s), before); +} + +#[test] +fn locked_paths_and_wrong_objects_are_refused() { + let (mut s, a, _) = doc(); + s.execute("object.setProps", &json!({"ids": [a.0], "locked": true})).unwrap(); + let before = art(&s); + for (source, part) in [ + ("app.activeDocument.pathItems[0].fillColor = new NoColor();", "Cannot edit PathItem"), + ("app.activeDocument.pathItems[0].setEntirePath([[0, 0], [1, 1]]);", "Cannot edit PathItem"), + ("app.activeDocument.pathItems[0].pathPoints[0].anchor = [1, 1];", "Cannot edit PathItem"), + ("app.activeDocument.pathItems[0].strokeWidth = 3;", "Cannot edit PathItem"), + ("app.activeDocument.pathItems[0].translate(5, 5);", "Cannot edit PathItem"), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } + assert_eq!(art(&s), before); + s.execute("text.create", &json!({"x": 10, "y": 250, "text": "hi"})).unwrap(); + let e = failure(&mut s, "var t = app.activeDocument.pageItems[2]; Object.getOwnPropertyDescriptor(PathItem.prototype, 'closed').get.call(t);"); + assert!(e.contains("not a PathItem"), "{e}"); + let e = failure(&mut s, "Object.getOwnPropertyDescriptor(PathPoint.prototype, 'anchor').get.call({});"); + assert!(e.contains("not a PathPoint"), "{e}"); +} + +#[test] +fn rotate_positive_is_counterclockwise_and_transforms_move_and_scale() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let out = log( + &mut s, + "var n = app.activeDocument.pathItems.add(); n.setEntirePath([[100, 100], [110, 100]]);\ + n.rotate(90, true, true, true, true, Transformation.LEFT); vc.log(n.pathPoints[1].anchor);\ + n.translate(5, 10); vc.log(n.pathPoints[0].anchor);\ + var r = app.activeDocument.pathItems.rectangle(250, 10, 30, 40); r.strokeWidth = 2;\ + r.resize(200, 50, true, true, true, true, 300, Transformation.TOPLEFT); vc.log(r.geometricBounds); vc.log(r.strokeWidth);", + ); + let out: Vec = out.iter().map(rounded).collect(); + assert_eq!(out[0], json!([100, 110]), "a positive angle turns counterclockwise"); + assert_eq!(out[1], json!([105, 110]), "translate moves up for a positive deltaY"); + assert_eq!(out[2], json!([10, 250, 70, 230])); + assert_eq!(out[3], json!(6)); + assert!(failure(&mut s, "app.activeDocument.pathItems[0].rotate(10, true, true, true, true, 'CENTER');").contains("Transformation")); + assert!(failure(&mut s, "app.activeDocument.pathItems[0].resize(0, 100);").contains("scaleX")); + assert!(failure(&mut s, "app.activeDocument.pathItems[0].translate(1, 2, 'no');").contains("changePositions")); + let before = art(&s); + for (source, part) in [ + ("app.activeDocument.pathItems[0].translate(1, 2, true, true, false);", "changeFillGradients false"), + ("app.activeDocument.pathItems[0].rotate(10, true, true, true, false);", "must be the same"), + ("app.activeDocument.pathItems.ellipse(10, 10, 5, 5, false, true);", "inscribed"), + ( + "var ps = app.activeDocument.pathItems;\ + for (var i = 0; i < ps.length; i++) { if (ps[i].strokeWidth == 6) ps[i].resize(150, 100, true, true, true, true, 20000); }", + "more than 1000 points", + ), + ] { + let e = failure(&mut s, source); + assert!(e.contains(part), "{source}: {e}"); + } + assert_eq!(art(&s), before); +} + +#[test] +fn area_sign_follows_direction() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let out = log( + &mut s, + "var n = app.activeDocument.pathItems.add(); n.setEntirePath([[0, 0], [10, 0], [10, 10], [0, 10]]); n.closed = true;\ + vc.log(n.area); vc.log(n.length);\ + var r = app.activeDocument.pathItems.rectangle(100, 0, 10, 10), q = app.activeDocument.pathItems.rectangle(100, 0, 10, 10, true);\ + vc.log(r.area + q.area); vc.log(Math.abs(r.area));", + ); + let out: Vec = out.iter().map(rounded).collect(); + assert_eq!(out, vec![json!(-100), json!(40), json!(0), json!(100)]); +} + +#[test] +fn many_path_edits_are_one_undo_step() { + let (mut s, a, b) = doc(); + let steps = undo_steps(&s); + log( + &mut s, + "var p = app.activeDocument.pathItems, c = new RGBColor(); c.green = 200;\ + for (var i = 0; i < p.length; i++) { p[i].fillColor = c; p[i].strokeWidth = 3; p[i].pathPoints[0].anchor = [0, 0]; }", + ); + assert_eq!(undo_steps(&s), steps + 1); + s.execute("edit.undo", &json!({})).unwrap(); + for id in [a, b] { + assert!((node(&s, id).appearance.stroke_width() - 1.0).abs() < 1e-9); + } +} diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index ef7c97e951..828a97f585 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -75,7 +75,8 @@ const INSIDE: &[(&str, &str)] = &[ "", "app Application CoordinateSystem Document DocumentArtboardLayout DocumentColorSpace DocumentPresetType \ DocumentPreviewMode DocumentRasterResolution DocumentTransparencyGrid Documents ElementPlacement Layer PageItem \ - PageItems RulerUnits ZOrderMethod", + PageItems PathItem PathItems PathPoint PathPointSelection PathPoints PointType PolarityValues RulerUnits StrokeCap \ + StrokeJoin Transformation ZOrderMethod", ), ("Application.", "prototype"), ( @@ -89,7 +90,7 @@ const INSIDE: &[(&str, &str)] = &[ ( "Document.prototype.", "activeLayer activeLayer= artboards artboards= close close= constructor convertCoordinate documentColorSpace \ - groupItems groupItems= height layers layers= name pageItems parent pathItems pathItems= rulerOrigin rulerOrigin= \ + groupItems groupItems= height layers layers= name pageItems parent pathItems rulerOrigin rulerOrigin= \ rulerUnits saveAs saveAs= selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ views views= width", ), @@ -107,6 +108,25 @@ const INSIDE: &[(&str, &str)] = &[ transform= translate translate= typename uRL uRL= uuid uuid= visibilityVariable visibilityVariable= visibleBounds \ width width= wrapInside wrapInside= wrapOffset wrapOffset= wrapped wrapped= zOrder zOrderPosition", ), + ("PathItems.", "prototype"), + ("PathItems.prototype.", "add constructor ellipse getByName index length parent polygon rectangle removeAll roundedRectangle star typename"), + ("PathItem.", "prototype"), + ( + "PathItem.prototype.", + "area clipping closed closed= constructor evenodd evenodd= fillColor fillColor= fillOverprint fillOverprint= filled \ + filled= guides length pathPoints polarity polarity= resize resolution resolution= rotate selectedPathPoints \ + selectedPathPoints= setEntirePath strokeCap strokeCap= strokeColor strokeColor= strokeDashOffset strokeDashOffset= \ + strokeDashes strokeDashes= strokeJoin strokeJoin= strokeMiterLimit strokeMiterLimit= strokeOverprint strokeOverprint= \ + strokeWidth strokeWidth= stroked stroked= translate", + ), + ("PathPoints.", "prototype"), + ("PathPoints.prototype.", "add constructor index length parent removeAll typename"), + ("PathPoint.", "prototype"), + ( + "PathPoint.prototype.", + "anchor anchor= constructor leftDirection leftDirection= parent pointType pointType= remove rightDirection \ + rightDirection= selected selected= typename", + ), ("CoordinateSystem.", "ARTBOARDCOORDINATESYSTEM DOCUMENTCOORDINATESYSTEM"), ("DocumentArtboardLayout.", "Column GridByCol GridByRow RLGridByCol RLGridByRow RLRow Row"), ("DocumentColorSpace.", "CMYK RGB"), @@ -119,14 +139,21 @@ const INSIDE: &[(&str, &str)] = &[ TransparencyGridNone TransparencyGridOrange TransparencyGridPurple TransparencyGridRed", ), ("ElementPlacement.", "INSIDE PLACEAFTER PLACEATBEGINNING PLACEATEND PLACEBEFORE"), + ("PathPointSelection.", "ANCHORPOINT LEFTDIRECTION LEFTRIGHTPOINT NOSELECTION RIGHTDIRECTION"), + ("PointType.", "CORNER SMOOTH"), + ("PolarityValues.", "NEGATIVE POSITIVE"), ("RulerUnits.", "Centimeters Inches Millimeters Picas Pixels Points Qs Unknown"), + ("StrokeCap.", "BUTTENDCAP PROJECTINGENDCAP ROUNDENDCAP"), + ("StrokeJoin.", "BEVELENDJOIN MITERENDJOIN ROUNDENDJOIN"), + ("Transformation.", "BOTTOM BOTTOMLEFT BOTTOMRIGHT CENTER DOCUMENTORIGIN LEFT RIGHT TOP TOPLEFT TOPRIGHT"), ("ZOrderMethod.", "BRINGFORWARD BRINGTOFRONT SENDBACKWARD SENDTOBACK"), ]; -/// The classes the host adds with nothing but a prototype and its constructor: `DocumentPreset` -/// and the page item types. -const BARE_CLASSES: &str = "BlendItem CompoundPathItem DocumentPreset EnvelopeItem GraphItem GroupItem IntertwineItem MeshItem PathItem \ - PlacedDocumentItem PlacedItem RasterItem RepeatItem SymbolItem TextFrame"; +/// The classes the host adds with nothing but a prototype and its constructor: `DocumentPreset`, +/// the page item types other than `PathItem`, and the color classes. +const BARE_CLASSES: &str = "BlendItem CMYKColor CompoundPathItem DocumentPreset EnvelopeItem GradientColor GraphItem GrayColor GroupItem \ + IntertwineItem LabColor MeshItem NoColor PatternColor PlacedDocumentItem PlacedItem RGBColor RasterItem RepeatItem SpotColor \ + SymbolItem TextFrame cmykColor"; /// The name the checker does not read, which also stands for its members: `vc` is VectorCraft's /// own API, and what `vc.run` does depends on the command it runs. diff --git a/docs/mcp.md b/docs/mcp.md index c305916f6f..44d375ae2c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2675,7 +2675,55 @@ app through the global object `vc`, and writes to the Script Console and runs ot Document and PageItem pages list, such as `Document.layers`, `PageItem.blendingMode`, `PageItem.rotate` and `app.beep`, throw an error that says they are not available yet when they are read or assigned. Other members those pages list, such as `app.version` and `Document.save()`, and the members of the pages of the page-item kinds - themselves, such as a path's fill, are not defined yet and read as `undefined`. + themselves, such as a text frame's `contents`, are not defined yet and read as `undefined`. +- `Document.pathItems` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/) lists the document's paths in the + order of `pageItems`, paths inside groups and compound paths included, with `length`, `[i]`, `index(key)`, + `getByName(name)`, `removeAll()`, `add()` (a path with no points, from `path.create`, painted as new art; when new + art has no fill and no stroke, the path has neither), and the shape creators + `rectangle(top, left, width, height, reversed?)`, `roundedRectangle(top, left, width, height, horizontalRadius = 15, + verticalRadius = 20, reversed?)`, `ellipse(top = 100, left = 100, width = 50, height = 100, reversed?, inscribed?)`, + `polygon(centerX = 200, centerY = 300, radius = 50, sides = 8, reversed?)` and `star(centerX = 200, centerY = 300, + radius = 50, innerRadius = 20, points = 5, reversed?)`, which run `shape.rectangle`, `path.create`, + `shape.ellipse`, `shape.polygon` and `shape.star` (and `path.reverse` for `reversed`) and paint the new path as new + art is painted. A `PathItem` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/) adds to the page item + members `pathPoints`, `closed`, `evenodd`, `area` (negative for a path that runs counterclockwise), `length`, + `guides`, `clipping`, `setEntirePath(points)`, `filled`, `fillColor`, `fillOverprint`, `stroked`, `strokeColor`, + `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to 500), `strokeDashes`, + `strokeDashOffset`, `translate(deltaX?, deltaY?, ...)`, `rotate(angle, ..., rotateAbout?)` (counterclockwise for a + positive angle) and `resize(scaleX, scaleY, ..., changeLineWidths?, scaleAbout?)`. The geometry changes through + `path.setAnchors`, the fill and stroke through `paint.setFill` and `paint.setStroke`, the stroke options through + `stroke.set`, the fill rule through `path.setFillRule`, overprint through `object.setOverprint` and the transforms + through `object.move`, `object.rotate` and `object.scale`. `pathPoints` + (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and + `removeAll()`, and each `PathPoint` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/) has `anchor`, + `leftDirection` (the handle into the point), `rightDirection` (the handle out of it), `pointType`, `parent` and + `remove()`. `new RGBColor()` (0 to 255), `new CMYKColor()` (0 to 100), `new GrayColor()` (0 to 100, 0 black and 100 + white, as https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/ gives it), `new LabColor()` and `new NoColor()` + (https://ai-scripting.docsforadobe.dev/jsobjref/NoColor/) make plain color objects; assigning a `NoColor` removes + the fill or stroke. The enumerations `PointType`, `PathPointSelection`, `StrokeCap`, `StrokeJoin`, `PolarityValues` + and `Transformation` hold strings such as `"StrokeCap.ROUNDENDCAP"`. + VectorCraft's own rules: a point's index counts across the path's subpaths; `closed` is true when every subpath is + closed, and assigning it opens or closes them all; `setEntirePath` takes at most 100,000 points and gives corner + points with no handles, keeping the path closed when it was; moving `anchor` leaves its handles where they are, and + `pointType` changes only the type; `PathPoints.add()` adds a corner point at the last point, or at `[0, 0]`; a point + whose index is past the end of its path throws `Stale path point`. Color components left out count as 0, `new + cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of + range throws a `RangeError` when the color is assigned, with nothing changed. Reading `fillColor` or `strokeColor` + gives a new object each time, a `GradientColor`, `SpotColor` or `PatternColor` among them (a color linked to a + global or spot swatch reads as a `SpotColor` with its `tint`); assigning one of those throws an error that says it is not available yet. `filled = true` on a path without a fill gives it the fill new + art gets (a color, gradient or pattern), or black when new art has none, and `stroked = true` does the same with the + stroke; a new-art pattern with a placement of its own, or one missing from the document, throws an error. Sizes and + radii are finite and not negative, `sides` is a whole number from 3 to 1000, `points` one from 2 to 1000, + `strokeWidth` 0 to 1000 points (a `changeLineWidths` that would scale it past 1000 throws), `strokeDashes` at most + 64 lengths that are not all 0 (`[]` or `{}` for a solid line), and `rotateAbout` and `scaleAbout` default to + `Transformation.CENTER`. The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and + `changeStrokePattern` given as different values throw an error, and `changeFillGradients` false and `ellipse` with + `inscribed` true throw an error that says they are not available yet. A change to the geometry or paint of a path + that is hidden or locked, or that is in a hidden or locked layer or group, throws `Cannot edit` with nothing + changed. A path in a compound path or compound shape reads the fill, stroke and overprint of that compound path or + shape, which the paint commands paint in its place. A change to a path's paint or stroke leaves the paint for new + art, the active Fill or Stroke proxy and Recent Colors as they were. `selectedPathPoints`, `PathPoint.selected`, + `transform`, `polarity`, the gradient stops and the document's default paint are not available yet. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. - `$.evalFile(path, timeout?)` runs the file `path` names, relative to the file being run, in the same global diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3b252b56a6..81abb83e94 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1024,7 +1024,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Synthetic input validates complete gestures before queue mutation: at most 256 drag steps, 16 clicks and 1,024 pending events; up to 64 control requests per frame, with later requests retained for the next frame (#1709). - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. + - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From 55f615d0c92ae33ecd0ab754806a4efc5889e5d8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 13:32:25 -0800 Subject: [PATCH 002/264] Scripts: write path point edits with one command, keep colors exact - Changes to a path's points (closed, setEntirePath, pathPoints and each PathPoint) wait in the object model and are written by one path.setAnchors before any other member or command, before another path's points change, and when the script ends. A loop over 2,000 points now runs one command and makes one undo step. A path aligned to the pixel grid is written at each change so its points read snapped. - A color component reads with the fewest decimals, at least 4, that give the stored value back, so assigning a color read from a path leaves the path unchanged (RGB, CMYK, Gray and Lab, fill and stroke). - add() and the shape creators put the new path on top of the active layer whatever the drawing mode, and leave the mode as it was. - fillOverprint and strokeOverprint change the top fill or stroke only. - filled = true on a compound path member places the new-art gradient on the compound path's bounds. - An identity rotate or resize checks its arguments and runs no command, on an empty path too. - Tests for each of these, and for setAnchors reading smooth false as a corner. Docs: docs/mcp.md, docs/gaps.md, docs/roadmap.md, docs/target-app-parity.md. --- crates/engine/src/script/dom.rs | 39 ++- crates/engine/src/script/dom/colors.rs | 21 +- crates/engine/src/script/dom/paths.rs | 288 +++++++++++++------- crates/engine/src/script/mod.rs | 24 +- crates/engine/src/tests/script_dom_paths.rs | 220 ++++++++++++++- docs/gaps.md | 7 +- docs/mcp.md | 21 +- docs/roadmap.md | 2 +- docs/target-app-parity.md | 2 +- 9 files changed, 504 insertions(+), 120 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 03b236c0e1..c33b3cd47f 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -88,14 +88,17 @@ const DOCUMENT_COORDS: &str = "CoordinateSystem.DOCUMENTCOORDINATESYSTEM"; const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; /// What the object model keeps for one run: its coordinate system, the last list of a document's -/// page items, kept while that document is unchanged, and whether a call's own savepoint -/// ([`atomically`]) is open. +/// page items, kept while that document is unchanged, the point changes of a path not written yet, +/// and whether a call's own savepoint ([`atomically`]) is open. #[derive(Default)] pub(super) struct State { coords: Cell, items: RefCell>, /// The last list of a document's paths ([`paths`]), kept while that document is unchanged. paths: RefCell>, + /// A path and its subpaths with the point changes the run has made to it and not written yet + /// ([`flush`]). + pending: RefCell)>>, saving: Cell, } @@ -134,15 +137,34 @@ type Answer = std::result::Result; /// A member function: the run's host and the call's arguments, `this` first. type Member = fn(&Host, &[Data]) -> Answer; +/// A member function that first writes the point changes waiting in [`State`] ([`flush`]). fn function(link: &Link, f: Member) -> HostFunction { + call(link, f, true) +} + +/// A member function of the points of a path, which reads and adds to the point changes waiting in +/// [`State`] instead of writing them first. +fn point_function(link: &Link, f: Member) -> HostFunction { + call(link, f, false) +} + +fn call(link: &Link, f: Member, flushing: bool) -> HostFunction { let l = link.clone(); Rc::new(move |a: Vec| { let h = current(&l)?; h.charge_call(16 + a.iter().map(data_size).sum::())?; + if flushing { + flush(&h)?; + } f(&h, &a) }) } +/// Writes the point changes of a path that wait in [`State`] with one command ([`paths::flush`]). +pub(super) fn flush(h: &Host) -> std::result::Result<(), HostError> { + paths::flush(h) +} + fn get(link: &Link, f: Member) -> HostMember { HostMember::Get(function(link, f)) } @@ -155,6 +177,19 @@ fn method(link: &Link, f: Member) -> HostMember { HostMember::Method(function(link, f)) } +/// [`get`], [`property`] and [`method`] for a member of the points of a path ([`point_function`]). +fn point_get(link: &Link, f: Member) -> HostMember { + HostMember::Get(point_function(link, f)) +} + +fn point_property(link: &Link, g: Member, s: Member) -> HostMember { + HostMember::Property { get: point_function(link, g), set: point_function(link, s) } +} + +fn point_method(link: &Link, f: Member) -> HostMember { + HostMember::Method(point_function(link, f)) +} + /// A member the help pages list that is not available yet: reading or assigning it throws, after /// the check that a document, page item or path point `this` is still there. fn later(link: &Link, class: &'static str, name: &'static str) -> (String, HostMember) { diff --git a/crates/engine/src/script/dom/colors.rs b/crates/engine/src/script/dom/colors.rs index 40421c5d38..34c1496054 100644 --- a/crates/engine/src/script/dom/colors.rs +++ b/crates/engine/src/script/dom/colors.rs @@ -45,9 +45,24 @@ fn color_object(class: &str, values: &[(&str, f64)]) -> Data { Data::Object(items) } -/// A component as the script sees it: `v` times `scale`, rounded to 4 decimals. +/// A component as the script sees it: `exact` rounded to the fewest decimals, from 4 to 9, that +/// `back` turns into the stored `v` again, else `exact` itself, so that assigning a color read +/// from an object gives that object the same color. +fn shown_as(exact: f64, v: f32, back: impl Fn(f64) -> f32) -> f64 { + let mut scale = 1e4; + for _ in 4..=9 { + let r = (exact * scale).round() / scale; + if back(r) == v { + return r; + } + scale *= 10.0; + } + exact +} + +/// A component stored as `v`, from 0 to 1, that the script sees times `scale`. fn shown(v: f32, scale: f64) -> f64 { - (f64::from(v) * scale * 1e4).round() / 1e4 + shown_as(f64::from(v) * scale, v, |r| unit(r, scale)) } /// The color object for a solid color. @@ -58,7 +73,7 @@ fn of_color(c: &Color) -> Data { "CMYKColor", &[("cyan", shown(c, 100.0)), ("magenta", shown(m, 100.0)), ("yellow", shown(y, 100.0)), ("black", shown(k, 100.0))], ), - Color::Gray { k } => color_object("GrayColor", &[("gray", shown(1.0 - k, 100.0))]), + Color::Gray { k } => color_object("GrayColor", &[("gray", shown_as((1.0 - f64::from(k)) * 100.0, k, |g| unit(100.0 - g, 100.0)))]), Color::Lab { l, a, b } => color_object("LabColor", &[("l", shown(l, 1.0)), ("a", shown(a, 1.0)), ("b", shown(b, 1.0))]), } } diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index ac643ce370..29b0c909be 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -6,8 +6,10 @@ //! //! A `PathPoints` object holds its path's handle, and a `PathPoint` the path's handle and the //! point's index, counted across the path's subpaths in order. Each read looks the path up again. -//! Every change runs one command (`path.setAnchors` for the geometry), inside the run's one undo -//! step, and a change that changes nothing runs no command. +//! Every change runs one command inside the run's one undo step, and a change that changes nothing +//! runs no command. Changes to the points of one path wait in the run's [`super::State`] and are +//! written together with one `path.setAnchors` ([`flush`]) before any other member, command or +//! path's points are read or changed, and when the script ends. //! //! VectorCraft's own rules, which the help pages do not state: //! - `Document.pathItems` lists the document's paths in the order of `pageItems`, paths inside @@ -15,12 +17,14 @@ //! - A change to the geometry or paint of a path that is hidden or locked, or that is in a hidden //! or locked layer or group, throws `Cannot edit` with nothing changed. //! - A path in a compound path or compound shape reads that owner's paint, which the paint -//! commands change in its place. A paint or stroke change leaves the paint for new art, the -//! active proxy and the recent colors as they were. +//! commands change in its place, and a gradient that `filled = true` gives it is placed on that +//! owner's bounds. A paint or stroke change leaves the paint for new art, the active proxy and +//! the recent colors as they were. `fillOverprint` and `strokeOverprint` read and change the top +//! fill or stroke only. //! - `closed` is true when every subpath of the path is closed, and assigning it opens or closes //! them all. -//! - `pathItems.add()` makes a path with no points on top of the active layer, painted as new art -//! is. `filled` and `stroked` set to true give a path with no fill or stroke new art's fill or +//! - `pathItems.add()` and the shape creators make their path on top of the active layer, whatever +//! the drawing mode, painted as new art is; `add()` makes a path with no points. `filled` and `stroked` set to true give a path with no fill or stroke new art's fill or //! stroke (solid, gradient or pattern), or black when new art has none. `PathPoints.add()` adds //! a corner point with no handles at the last point, or at `[0, 0]` on a path with no points. //! Removing the last points leaves the path, with no points. @@ -28,7 +32,8 @@ //! - Shape creators take sizes and radii that are finite and not negative; `sides` is a whole //! number from 3 to 1000 and `points` one from 2 to 1000. `inscribed` true throws an error that //! says it is not available yet. `rotateAbout` and `scaleAbout` default to -//! `Transformation.CENTER`. +//! `Transformation.CENTER`. A transform that leaves the path where it is (`rotate(360)`, +//! `resize(100, 100)`) checks its arguments and runs no command, on a path with no points too. //! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and //! `changeStrokePattern` given as different values throw an error; gradients move with the art, //! so `changeFillGradients` false throws an error that says it is not available yet. @@ -46,8 +51,8 @@ use vectorcraft_tools::params::gradient_params; use super::{ Answer, Coords, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, coordinate, doc_of, edit_item, editable, find_doc, - float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, point, property, - this_doc, typename_of, whole, with_doc, + float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, point, point_get, + point_method, point_property, property, this_doc, typename_of, whole, with_doc, }; use crate::{DocState, NodeId, NodeKind}; @@ -117,14 +122,14 @@ fn path_ref(h: &super::Host, item: Item) -> Data { host_ref("PathItem", &[float(h.run), float(item.doc.uid), high, low]) } -/// How many points a path has, across its subpaths. -fn point_count(pd: &PathData) -> usize { - pd.subpaths.iter().map(|sp| sp.anchors.len()).sum() +/// How many points a path with the subpaths `subs` has. +fn point_count(subs: &[SubPath]) -> usize { + subs.iter().map(|sp| sp.anchors.len()).sum() } -/// The subpath and the place in it of point `i`. -fn locate(pd: &PathData, mut i: usize) -> Option<(usize, usize)> { - for (s, sp) in pd.subpaths.iter().enumerate() { +/// The subpath and the place in it of point `i`, among the subpaths `subs`. +fn locate(subs: &[SubPath], mut i: usize) -> Option<(usize, usize)> { + for (s, sp) in subs.iter().enumerate() { if i < sp.anchors.len() { return Some((s, i)); } @@ -137,14 +142,69 @@ fn anchor_json(a: &Anchor) -> Value { json!({"x": a.p.x, "y": a.p.y, "in": [a.h_in.x, a.h_in.y], "out": [a.h_out.x, a.h_out.y], "smooth": a.kind == AnchorKind::Smooth}) } -/// Gives the path of `item` the subpaths `subs` with `path.setAnchors`, unless it has them. -fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::Result<(), HostError> { - let (same, ok) = read_path(h, item, |st, _, pd| (pd.subpaths == subs, editable(&st.doc, item.id)))?; - if same { - return Ok(()); +fn same_path(a: Item, b: Item) -> bool { + a.doc.uid == b.doc.uid && a.id == b.id +} + +/// Reads the subpaths of the path of `item` with `f`, its waiting point changes included. +fn read_points(h: &super::Host, item: Item, f: impl FnOnce(&[SubPath]) -> T) -> std::result::Result { + if let Some((waiting, subs)) = &*h.dom.pending.borrow() + && same_path(*waiting, item) + { + return Ok(f(subs)); } - if !ok { - return Err(cannot_edit(item.id)); + read_path(h, item, |_, _, pd| f(&pd.subpaths)) +} + +/// Changes the subpaths of the path of `item` with `f`. The change waits in [`super::State`] with +/// the path's other point changes until [`flush`] writes them. The first change of a path writes +/// the waiting changes of another path first, and throws `Cannot edit` when the path is hidden or +/// locked, unless it changes nothing. A path that is aligned to the pixel grid, or is in an object +/// that is, is written at once, so that its points read as the grid snaps them. +fn edit_points(h: &super::Host, item: Item, f: impl FnOnce(&mut Vec) -> T) -> std::result::Result { + if let Some((waiting, subs)) = &mut *h.dom.pending.borrow_mut() + && same_path(*waiting, item) + { + return Ok(f(subs)); + } + flush(h)?; + let mut subs = read_path(h, item, |_, _, pd| pd.subpaths.clone())?; + let r = f(&mut subs); + let (same, ok, aligned) = read_path(h, item, |st, _, pd| { + let d = &st.doc; + let aligned = d.ancestry(item.id).is_some_and(|a| a.iter().chain([&item.id]).any(|i| d.node(*i).is_some_and(|n| n.extras().pixel_aligned))); + (pd.subpaths == subs, editable(d, item.id), aligned) + })?; + if !same { + if !ok { + return Err(cannot_edit(item.id)); + } + *h.dom.pending.borrow_mut() = Some((item, subs)); + if aligned { + flush(h)?; + } + } + Ok(r) +} + +/// Gives the path of `item` the subpaths `subs` ([`edit_points`]). +fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::Result<(), HostError> { + edit_points(h, item, |s| *s = subs) +} + +/// Writes the waiting point changes of a path ([`edit_points`]) with one `path.setAnchors`, unless +/// the path has those points already. +pub(super) fn flush(h: &super::Host) -> std::result::Result<(), HostError> { + let Some((item, subs)) = h.dom.pending.borrow_mut().take() else { return Ok(()) }; + let same = { + let s = h.session.borrow(); + let node = s.documents().iter().find(|d| d.uid == item.doc.uid).and_then(|st| st.doc.node(item.id)); + node.and_then(|n| n.path_data()).map(|pd| pd.subpaths == subs) + }; + match same { + Some(true) => return Ok(()), + Some(false) => {} + None => return Err(HostError::Error(STALE_ITEM.into())), } let subpaths: Vec = subs.iter().map(|sp| json!({"anchors": sp.anchors.iter().map(anchor_json).collect::>(), "closed": sp.closed})).collect(); @@ -152,7 +212,23 @@ fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::R Ok(()) } -/// Runs `id` with `params` and `ids: [item]` on the item, which must be one the user could edit. +/// The object whose paint the path `n` with id `id` shows: its compound path or compound shape +/// when it is a member of one, since the paint commands paint that owner in its place. +fn paint_owner<'a>(d: &'a crate::Document, id: NodeId, n: &'a crate::doc::Node) -> &'a crate::doc::Node { + d.parent_of(id).and_then(|p| d.node(p)).filter(|p| matches!(p.kind, NodeKind::Compound { .. }) || p.is_compound_shape()).unwrap_or(n) +} + +/// Runs `f` with the drawing mode set to normal, so that the paths it makes go on top of the active +/// layer, then puts the drawing mode back. +fn drawing_normally(h: &super::Host, f: impl FnOnce() -> T) -> T { + let kept = std::mem::replace(&mut h.session.borrow_mut().draw_mode, crate::DrawMode::Normal); + let r = f(); + h.session.borrow_mut().draw_mode = kept; + r +} + +/// Runs `id` with `params` and `ids: [item]` (unless `params` names its `ids`) on the item, which +/// must be one the user could edit. /// The paint for new art, the active Fill or Stroke proxy, the last color and gradient and the /// recent colors, which `paint.setFill`, `paint.setStroke` and `stroke.set` also set, are put /// back afterwards, so the edit changes only the path. @@ -162,7 +238,7 @@ fn edit_path(h: &super::Host, item: Item, id: &str, mut params: Value) -> std::r return Err(cannot_edit(item.id)); } if let Some(o) = params.as_object_mut() { - o.insert("ids".into(), json!([item.id.0])); + o.entry("ids").or_insert_with(|| json!([item.id.0])); } keeping_paint(h, || edit_item(h, item, id, ¶ms)) } @@ -273,11 +349,11 @@ fn made_id(r: &Data) -> std::result::Result { id.map(NodeId).ok_or_else(|| HostError::Error("the path was not made".into())) } -/// Runs the command `id` that makes a path in `doc`, the selection kept, and reverses the new -/// path's direction when `reversed`. → the new path. +/// Runs the command `id` that makes a path in `doc` on top of the active layer, the selection kept, +/// and reverses the new path's direction when `reversed`. → the new path. fn make(h: &super::Host, doc: Doc, id: &str, params: &Value, reversed: bool) -> Answer { let made = on_doc(h, doc.uid, true, |h| { - let id = made_id(&command(h, id, params)?)?; + let id = made_id(&drawing_normally(h, || command(h, id, params))?)?; if reversed { command(h, "path.reverse", &json!({"ids": [id.0]}))?; } @@ -426,8 +502,8 @@ fn items_star(h: &super::Host, a: &[Data]) -> Answer { make(h, doc, "shape.star", &json!({"cx": c.x, "cy": c.y, "radius1": r1, "radius2": r2, "points": points}), reversed) } -/// `pathItems.add()`: a path with no points, from `path.create` with empty path data, painted as -/// new art. When new art has no fill and no stroke, the black stroke `path.create` gives an open +/// `pathItems.add()`: a path with no points on top of the active layer, from `path.create` with +/// empty path data, painted as new art. When new art has no fill and no stroke, the black stroke `path.create` gives an open /// path is set back to none in the same step. fn items_add(h: &super::Host, a: &[Data]) -> Answer { let doc = items_doc(h, a)?; @@ -436,7 +512,7 @@ fn items_add(h: &super::Host, a: &[Data]) -> Answer { let ap = h.session.borrow().new_art(); ap.fill_paint().is_none() && ap.stroke_paint().is_none() }; - let id = made_id(&command(h, "path.create", &json!({"d": ""}))?)?; + let id = made_id(&drawing_normally(h, || command(h, "path.create", &json!({"d": ""})))?)?; if unpainted { keeping_paint(h, || command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]})))?; } @@ -457,14 +533,13 @@ fn path_points(h: &super::Host, a: &[Data]) -> Answer { fn path_closed(h: &super::Host, a: &[Data]) -> Answer { let item = this_path(h, a)?; - read_path(h, item, |_, _, pd| Data::Bool(!pd.subpaths.is_empty() && pd.subpaths.iter().all(|sp| sp.closed))) + read_points(h, item, |subs| Data::Bool(!subs.is_empty() && subs.iter().all(|sp| sp.closed))) } fn path_set_closed(h: &super::Host, a: &[Data]) -> Answer { let closed = boolean(arg(a, 1), "closed")?; let item = this_path(h, a)?; - let subs = read_path(h, item, |_, _, pd| pd.subpaths.iter().map(|sp| SubPath { anchors: sp.anchors.clone(), closed }).collect())?; - write_path(h, item, subs)?; + edit_points(h, item, |subs| subs.iter_mut().for_each(|sp| sp.closed = closed))?; Ok(Data::Undefined) } @@ -517,8 +592,9 @@ fn path_set_entire(h: &super::Host, a: &[Data]) -> Answer { return Err(HostError::Range(format!("setEntirePath takes at most {MAX_POINTS} points"))); } let script: Vec<[f64; 2]> = list.iter().map(|d| point(d, "each point")).collect::>()?; - let (f, closed) = read_path(h, item, |st, _, pd| (frame(st), !pd.subpaths.is_empty() && pd.subpaths.iter().all(|sp| sp.closed)))?; - let (f, c) = (f?, h.dom.coords.get()); + let f = with_doc(h, item.doc, |_, st| frame(st))?; + let closed = read_points(h, item, |subs| !subs.is_empty() && subs.iter().all(|sp| sp.closed))?; + let c = h.dom.coords.get(); let anchors: Vec = script.iter().map(|p| Anchor::corner(f.to_document(c, *p))).collect(); let subs = if anchors.is_empty() { Vec::new() } else { vec![SubPath::new(anchors, closed)] }; write_path(h, item, subs)?; @@ -546,13 +622,7 @@ struct Look { /// since the paint commands paint that owner in its place. fn look(h: &super::Host, item: Item) -> std::result::Result { read_path(h, item, |st, n, _| { - let d = &st.doc; - let owner = d - .parent_of(item.id) - .and_then(|p| d.node(p)) - .filter(|p| matches!(p.kind, NodeKind::Compound { .. }) || p.is_compound_shape()) - .unwrap_or(n); - let ap = &owner.appearance; + let ap = &paint_owner(&st.doc, item.id, n).appearance; let fill = ap.fill(); let stroke = ap.stroke(); Look { @@ -597,7 +667,8 @@ fn set_paint(h: &super::Host, item: Item, fill: bool, color: Option) -> s /// The paint new art gets for its fill or stroke, as `paint.setFill` or `paint.setStroke` params for /// the path `item`: a solid color, linked to its global or spot swatch while the document has that -/// swatch; a gradient, a placed one moved onto the path's bounds as new art takes it; or a pattern. +/// swatch; a gradient, a placed one moved onto the bounds of the path or of the compound path or +/// compound shape whose paint it shows, as new art takes it; or a pattern. /// A fill or stroke of none gives black. A pattern that its swatch does not give as new art has it /// (its own placement, or a pattern the document does not have) throws an error. fn new_art_params(h: &super::Host, item: Item, fill: bool) -> std::result::Result { @@ -619,7 +690,7 @@ fn new_art_params(h: &super::Host, item: Item, fill: bool) -> std::result::Resul Paint::Gradient(g) => { let mut g = g.clone(); if g.geom.is_some() || g.freeform.is_some() { - match read_path(h, item, |_, n, _| n.geometric_bounds())? { + match read_path(h, item, |st, n, _| paint_owner(&st.doc, item.id, n).geometric_bounds())? { Some(b) => { ap.rebase_gradients(GraphicStyle::UNIT_BOX, b); if let Paint::Gradient(placed) = top(&ap) { @@ -827,10 +898,15 @@ fn set_overprint(h: &super::Host, a: &[Data], fill: bool) -> Answer { let (item, look) = this_look(h, a)?; let (now, paint) = if fill { (look.fill_overprint, &look.fill) } else { (look.stroke_overprint, &look.stroke) }; if now != on { - if paint.is_none() { + // The top fill or stroke of the object `look` reads, as `item` names it to the command. + let top = read_path(h, item, |st, n, _| { + let owner = paint_owner(&st.doc, item.id, n); + owner.appearance.items.iter().rposition(|i| i.is_fill() == fill).map(|index| (owner.id, index)) + })?; + let (Some((owner, index)), false) = (top, paint.is_none()) else { return Err(HostError::Error(format!("the path has no {key} to overprint"))); - } - edit_path(h, item, "object.setOverprint", json!({key: on}))?; + }; + edit_path(h, item, "object.setOverprint", json!({key: on, "item": index, "ids": [owner.0]}))?; } Ok(Data::Undefined) } @@ -845,16 +921,23 @@ fn path_set_stroke_overprint(h: &super::Host, a: &[Data]) -> Answer { // ---- PathItem transforms ---- -/// The point of the path's geometric bounds `r`, in document coordinates, that a `Transformation` -/// value names (left out: the center). -fn about(h: &super::Host, item: Item, d: &Data, r: Rect) -> std::result::Result { +/// The member of `Transformation` that `d` names (left out: `CENTER`). +fn about_name(d: &Data) -> std::result::Result<&'static str, HostError> { let name = match d { Data::Undefined => "Transformation.CENTER", Data::String(s) => s.as_str(), _ => return Err(HostError::Type("give a Transformation value".into())), }; + let members = ENUMS.iter().find(|(e, _)| *e == "Transformation").map_or(&[][..], |(_, m)| *m); + let member = name.strip_prefix("Transformation.").and_then(|m| members.iter().find(|x| **x == m)); + member.copied().ok_or_else(|| HostError::Type("give a Transformation value".into())) +} + +/// The point of the path's geometric bounds `r`, in document coordinates, that the `Transformation` +/// member `name` ([`about_name`]) names. +fn about(h: &super::Host, item: Item, name: &str, r: Rect) -> std::result::Result { let (cx, cy) = ((r.x0 + r.x1) / 2.0, (r.y0 + r.y1) / 2.0); - Ok(match name.strip_prefix("Transformation.").unwrap_or("") { + Ok(match name { "CENTER" => Point::new(cx, cy), "TOP" => Point::new(cx, r.y0), "BOTTOM" => Point::new(cx, r.y1), @@ -914,11 +997,13 @@ fn path_translate(h: &super::Host, a: &[Data]) -> Answer { fn path_rotate(h: &super::Host, a: &[Data]) -> Answer { let angle = number(arg(a, 1), "angle")?; let item = this_path(h, a)?; - let (r, _) = item_rect(h, item, false)?; - let origin = about(h, item, arg(a, 6), r)?; - let mut params = json!({"angle": angle, "origin": [origin.x, origin.y]}); + let place = about_name(arg(a, 6))?; + let mut params = json!({"angle": angle}); transform_options(a, 2, &mut params)?; if angle.rem_euclid(360.0) != 0.0 { + let (r, _) = item_rect(h, item, false)?; + let origin = about(h, item, place, r)?; + params["origin"] = json!([origin.x, origin.y]); edit_path(h, item, "object.rotate", params)?; } Ok(Data::Undefined) @@ -937,9 +1022,8 @@ fn path_resize(h: &super::Host, a: &[Data]) -> Answer { return Err(HostError::Range("changeLineWidths must be from 0 to 100000 percent".into())); } let item = this_path(h, a)?; - let (r, _) = item_rect(h, item, false)?; - let origin = about(h, item, arg(a, 8), r)?; - let mut params = json!({"sx": sx, "sy": sy, "origin": [origin.x, origin.y], "basis": "page", "strokes": false}); + let place = about_name(arg(a, 8))?; + let mut params = json!({"sx": sx, "sy": sy, "basis": "page", "strokes": false}); transform_options(a, 3, &mut params)?; let width = look(h, item)?.width; let new_width = widths.map(|w| width * w / 100.0); @@ -947,6 +1031,9 @@ fn path_resize(h: &super::Host, a: &[Data]) -> Answer { return Err(HostError::Range("changeLineWidths would make the stroke weight more than 1000 points".into())); } if sx != 100.0 || sy != 100.0 { + let (r, _) = item_rect(h, item, false)?; + let origin = about(h, item, place, r)?; + params["origin"] = json!([origin.x, origin.y]); edit_path(h, item, "object.scale", params)?; } if let Some(w) = new_width @@ -967,7 +1054,7 @@ fn points_path(h: &super::Host, a: &[Data]) -> std::result::Result Answer { let item = points_path(h, a)?; - read_path(h, item, |_, _, pd| num(float(point_count(pd) as u64))) + read_points(h, item, |subs| num(float(point_count(subs) as u64))) } fn points_parent(h: &super::Host, a: &[Data]) -> Answer { @@ -984,7 +1071,7 @@ fn points_at(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; let Data::Number(n) = arg(a, 1) else { return Ok(Data::Undefined) }; let Some(i) = whole(*n).and_then(|i| usize::try_from(i).ok()) else { return Ok(Data::Undefined) }; - let n = read_path(h, item, |_, _, pd| point_count(pd))?; + let n = read_points(h, item, point_count)?; Ok(if i < n { point_ref(h, item, i) } else { Data::Undefined }) } @@ -1001,22 +1088,19 @@ fn points_index(h: &super::Host, a: &[Data]) -> Answer { fn points_add(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; - let (mut subs, n, origin) = read_path(h, item, |st, _, pd| { - let origin = frame(st).map(|f| f.to_document(h.dom.coords.get(), [0.0, 0.0])); - (pd.subpaths.clone(), point_count(pd), origin) - })?; + let origin = with_doc(h, item.doc, |_, st| frame(st).map(|f| f.to_document(h.dom.coords.get(), [0.0, 0.0]))); + let (n, last) = read_points(h, item, |subs| (point_count(subs), subs.iter().rev().find_map(|sp| sp.anchors.last()).map(|a| a.p)))?; if n >= MAX_POINTS { return Err(HostError::Range(format!("PathPoints.add takes a path to at most {MAX_POINTS} points"))); } - let p = match subs.iter().rev().find_map(|sp| sp.anchors.last()) { - Some(last) => last.p, + let p = match last { + Some(p) => p, None => origin?, }; - match subs.last_mut() { + edit_points(h, item, |subs| match subs.last_mut() { Some(sp) => sp.anchors.push(Anchor::corner(p)), None => subs.push(SubPath::new(vec![Anchor::corner(p)], false)), - } - write_path(h, item, subs)?; + })?; Ok(point_ref(h, item, n)) } @@ -1034,7 +1118,7 @@ pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(It let [run, uid, high, low, i] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; let item = path_at(h, *run, *uid, *high, *low)?; let i = whole(*i).and_then(|i| usize::try_from(i).ok()).ok_or_else(|| HostError::Error(STALE_POINT.into()))?; - let n = read_path(h, item, |_, _, pd| point_count(pd))?; + let n = read_points(h, item, point_count)?; if i >= n { return Err(HostError::Error(STALE_POINT.into())); } @@ -1045,9 +1129,9 @@ pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(It fn read_point(h: &super::Host, a: &[Data], f: impl FnOnce(&super::Frame, Coords, &Anchor) -> Data) -> Answer { let (item, i) = this_point(h, a)?; let c = h.dom.coords.get(); - read_path(h, item, |st, _, pd| { - let fr = frame(st)?; - let anchor = locate(pd, i).and_then(|(s, j)| pd.subpaths.get(s).and_then(|sp| sp.anchors.get(j))); + let fr = with_doc(h, item.doc, |_, st| frame(st))?; + read_points(h, item, |subs| { + let anchor = locate(subs, i).and_then(|(s, j)| subs.get(s).and_then(|sp| sp.anchors.get(j))); anchor.map(|an| f(&fr, c, an)).ok_or_else(|| HostError::Error(STALE_POINT.into())) })? } @@ -1056,12 +1140,13 @@ fn read_point(h: &super::Host, a: &[Data], f: impl FnOnce(&super::Frame, Coords, /// coordinates (for a point property) or the value itself. fn edit_point(h: &super::Host, a: &[Data], f: impl FnOnce(&mut Anchor)) -> Answer { let (item, i) = this_point(h, a)?; - let mut subs = read_path(h, item, |_, _, pd| pd.subpaths.clone())?; - let (s, j) = read_path(h, item, |_, _, pd| locate(pd, i))?.ok_or_else(|| HostError::Error(STALE_POINT.into()))?; - if let Some(an) = subs.get_mut(s).and_then(|sp| sp.anchors.get_mut(j)) { - f(an); - } - write_path(h, item, subs)?; + edit_points(h, item, |subs| { + if let Some((s, j)) = locate(subs, i) + && let Some(an) = subs.get_mut(s).and_then(|sp| sp.anchors.get_mut(j)) + { + f(an); + } + })?; Ok(Data::Undefined) } @@ -1121,15 +1206,16 @@ fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { /// `remove()`: deletes the point; a subpath left with no points goes too. fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { let (item, i) = this_point(h, a)?; - let mut subs = read_path(h, item, |_, _, pd| pd.subpaths.clone())?; - let (s, j) = read_path(h, item, |_, _, pd| locate(pd, i))?.ok_or_else(|| HostError::Error(STALE_POINT.into()))?; - if let Some(sp) = subs.get_mut(s) { - sp.anchors.remove(j); - if sp.anchors.is_empty() { - subs.remove(s); + edit_points(h, item, |subs| { + if let Some((s, j)) = locate(subs, i) + && let Some(sp) = subs.get_mut(s) + { + sp.anchors.remove(j); + if sp.anchors.is_empty() { + subs.remove(s); + } } - } - write_path(h, item, subs)?; + })?; Ok(Data::Undefined) } @@ -1138,14 +1224,14 @@ fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { /// The members `PathItem` adds to `PageItem`'s. pub(super) fn path_item_members(l: &Link) -> Vec<(String, HostMember)> { let mut m = named(vec![ - ("pathPoints", get(l, path_points)), - ("closed", property(l, path_closed, path_set_closed)), + ("pathPoints", point_get(l, path_points)), + ("closed", point_property(l, path_closed, path_set_closed)), ("evenodd", property(l, path_evenodd, path_set_evenodd)), ("area", get(l, path_area)), ("length", get(l, path_length)), ("guides", get(l, path_guides)), ("clipping", get(l, path_clipping)), - ("setEntirePath", method(l, path_set_entire)), + ("setEntirePath", point_method(l, path_set_entire)), ("filled", property(l, path_filled, path_set_filled)), ("fillColor", property(l, path_fill_color, path_set_fill_color)), ("fillOverprint", property(l, path_fill_overprint, path_set_fill_overprint)), @@ -1193,13 +1279,13 @@ pub(super) fn classes(l: &Link) -> Vec { None, named(vec![ ("typename", typename_of("PathPoints")), - ("length", get(l, points_length)), - ("parent", get(l, points_parent)), - ("index", method(l, points_index)), - ("add", method(l, points_add)), - ("removeAll", method(l, points_remove_all)), + ("length", point_get(l, points_length)), + ("parent", point_get(l, points_parent)), + ("index", point_method(l, points_index)), + ("add", point_method(l, points_add)), + ("removeAll", point_method(l, points_remove_all)), ]), - Some(super::function(l, points_at)), + Some(super::point_function(l, points_at)), ), class( "PathPoint", @@ -1207,12 +1293,12 @@ pub(super) fn classes(l: &Link) -> Vec { { let mut m = named(vec![ ("typename", typename_of("PathPoint")), - ("parent", get(l, pt_parent)), - ("anchor", property(l, pt_anchor, pt_set_anchor)), - ("leftDirection", property(l, pt_left, pt_set_left)), - ("rightDirection", property(l, pt_right, pt_set_right)), - ("pointType", property(l, pt_type, pt_set_type)), - ("remove", method(l, pt_remove)), + ("parent", point_get(l, pt_parent)), + ("anchor", point_property(l, pt_anchor, pt_set_anchor)), + ("leftDirection", point_property(l, pt_left, pt_set_left)), + ("rightDirection", point_property(l, pt_right, pt_set_right)), + ("pointType", point_property(l, pt_type, pt_set_type)), + ("remove", point_method(l, pt_remove)), ]); m.push(later(l, "PathPoint", "selected")); m diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index d228ff848f..37c4b8711d 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -1309,6 +1309,8 @@ fn command(host: &Host, id: &str, params: &Value) -> std::result::Result std::result::Result<(Data, Value), HostError> { + // Point changes that wait in the object model are written before any command runs. + dom::flush(host)?; let id = id.to_string(); let params = params.clone(); let session = host.session.clone(); @@ -1352,6 +1354,7 @@ fn command_value(host: &Host, id: &str, params: &Value) -> std::result::Result<( /// A bounded snapshot of the active document, or `null` with none open. A snapshot past the limits /// of a crossing throws a `RangeError`. fn vc_document(host: &Host) -> std::result::Result { + dom::flush(host)?; let s = host.session.borrow(); let Some(st) = s.active() else { return Ok(Data::Null) }; let ids: Vec = st.selection.objects.iter().take(1_000).map(|i| i.0).collect(); @@ -2472,6 +2475,7 @@ fn run_slice(s: &mut Session, job: &mut Job) -> std::result::Result std::result::Result std::result::Result RunError { + let message = match e { + HostError::Error(m) | HostError::Type(m) | HostError::Range(m) | HostError::Syntax(m) | HostError::Abort(m) => m, + HostError::Marked { error, .. } => return end_flush_error(*error), + HostError::Wait => "a host function waited for its result where the run cannot pause".into(), + }; + RunError { kind: RunErrorKind::Limit(LimitKind::Host), message, line: 0, column: 0, authored: false } +} + /// Tests: removes the session's running job while the session keeps its hold on it. → whether a /// job was removed. #[cfg(test)] diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 9d9c0c5f7a..004c02f4fc 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -344,13 +344,229 @@ fn a_spot_color_reads_as_a_spot_color_and_keeps_its_link() { fn filled_true_on_a_filled_path_runs_no_command() { let (mut s, _, _) = doc(); let steps = undo_steps(&s); - log( + let r = run( &mut s, "var p = app.activeDocument.pathItems[0]; p.filled = true; p.stroked = true; p.fillColor = p.fillColor;\ p.strokeWidth = p.strokeWidth; p.strokeCap = p.strokeCap; p.closed = true; p.evenodd = false; p.strokeDashes = [];\ p.pathPoints[0].anchor = p.pathPoints[0].anchor; p.translate(0, 0); p.rotate(360); p.resize(100, 100);", - ); + ) + .unwrap(); assert_eq!(undo_steps(&s), steps, "values that change nothing add no step"); + assert_eq!(r["slowestCommands"], json!([]), "and run no command"); +} + +#[test] +fn identity_transforms_of_an_empty_path_do_nothing() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + log( + &mut s, + "var n = app.activeDocument.pathItems.add(); n.rotate(360); n.rotate(0, true, true, true, true, Transformation.TOPLEFT);\ + n.resize(100, 100); n.resize(100, 100, true, true, true, true, 100, Transformation.BOTTOM); n.translate(0, 0);", + ); + for source in [ + "app.activeDocument.pathItems[0].rotate(360, true, true, true, true, 'CENTER');", + "app.activeDocument.pathItems[0].resize(100, 100, true, true, true, true, 100, 'x');", + ] { + assert!(failure(&mut s, source).contains("Transformation"), "{source}"); + } +} + +/// The paint of the fill (`fill`) or stroke of `id`. +fn paint_of(s: &Session, id: NodeId, fill: bool) -> Paint { + let n = node(s, id); + if fill { n.appearance.fill_paint() } else { n.appearance.stroke_paint() } +} + +#[test] +fn a_color_read_from_a_path_assigns_back_unchanged() { + let colors = [ + "var c = new RGBColor(); c.red = 0.00001; c.green = 200.123456789; c.blue = 1 / 3;", + "var c = new CMYKColor(); c.cyan = 100 / 3; c.magenta = 0.00001; c.yellow = 99.99999; c.black = 12.3456789;", + "var c = new GrayColor(); c.gray = 100 / 3;", + "var c = new GrayColor(); c.gray = 99.99999;", + "var c = new LabColor(); c.l = 12.3456789; c.a = -0.00001; c.b = 127.99999;", + ]; + for color in colors { + for prop in ["fillColor", "strokeColor"] { + let (mut s, a, _) = doc(); + log(&mut s, &format!("{color} app.activeDocument.pathItems[0].{prop} = c;")); + let (before, steps) = (paint_of(&s, a, prop == "fillColor"), undo_steps(&s)); + let r = run(&mut s, &format!("var p = app.activeDocument.pathItems[0]; p.{prop} = p.{prop};")).unwrap(); + assert_eq!(paint_of(&s, a, prop == "fillColor"), before, "{color} {prop}"); + assert_eq!((undo_steps(&s), &r["slowestCommands"]), (steps, &json!([])), "{color} {prop}"); + } + } + let (mut s, _, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], c = new RGBColor(); c.red = 200; c.green = 0.5; p.fillColor = c;\ + var g = new GrayColor(); g.gray = 25; p.strokeColor = g; vc.log([p.fillColor.red, p.fillColor.green, p.strokeColor.gray]);", + ); + assert_eq!(out, vec![json!([200, 0.5, 25])], "whole and short values read as they were given"); +} + +#[test] +fn many_point_edits_run_one_command() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let anchors: Vec = (0..2000).map(|i| json!({"x": f64::from(i) * 0.1, "y": 100})).collect(); + let id = NodeId(s.execute("path.create", &json!({"anchors": anchors, "closed": false})).unwrap()["id"].as_u64().unwrap()); + let steps = undo_steps(&s); + let r = run( + &mut s, + "var p = app.activeDocument.pathItems[0], pp = p.pathPoints;\ + for (var i = 0; i < pp.length; i++) { var a = pp[i].anchor; pp[i].rightDirection = [a[0] + 1, a[1]]; pp[i].anchor = [a[0], a[1] + 5]; }\ + vc.log(pp[1999].anchor); vc.log(pp[1999].rightDirection); pp[0].remove(); vc.log(pp.length); vc.log(p.pathPoints[0].anchor);", + ) + .unwrap(); + let out: Vec = r["log"].as_array().unwrap().iter().map(rounded).collect(); + assert_eq!(out, vec![json!([199.9, 205]), json!([200.9, 200]), json!(1999), json!([0.1, 205])]); + assert_eq!( + r["slowestCommands"].as_array().map(|c| c.iter().map(|c| (c["id"].clone(), c["calls"].clone())).collect::>()), + Some(vec![(json!("path.setAnchors"), json!(1))]), + "one command writes every point" + ); + let pd = node(&s, id).path_data().unwrap().clone(); + assert_eq!(pd.subpaths[0].anchors.len(), 1999); + assert!(pd.subpaths[0].anchors.iter().all(|a| (a.h_out.x - a.p.x - 1.0).abs() < 1e-9 && (a.h_out.y - a.p.y - 5.0).abs() < 1e-9)); + assert_eq!(undo_steps(&s), steps + 1); +} + +#[test] +fn point_edits_are_written_before_the_next_other_member_reads() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], q = app.activeDocument.pathItems[1];\ + p.pathPoints[0].anchor = [0, 300]; vc.log(p.geometricBounds); q.pathPoints[0].anchor = [90, 210];\ + p.pathPoints[1].anchor = [50, 300]; vc.log(q.geometricBounds); vc.log(p.geometricBounds);", + ); + let out: Vec = out.iter().map(rounded).collect(); + assert_eq!(out, vec![json!([0, 300, 40, 240]), json!([90, 210, 150, 150]), json!([0, 300, 50, 240])]); + assert_eq!(node(&s, a).path_data().unwrap().subpaths[0].anchors[1].p, vectorcraft_geom::Point::new(50.0, 0.0)); +} + +#[test] +fn closed_and_set_entire_path_join_the_point_edits_in_one_command() { + let (mut s, a, _) = doc(); + let r = run( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.setEntirePath([[0, 300], [40, 300], [40, 240]]); p.closed = false;\ + p.pathPoints[1].anchor = [50, 300]; vc.log(p.closed); p.closed = true; p.setEntirePath([[0, 300], [60, 300], [60, 240]]); vc.log(p.closed);", + ) + .unwrap(); + assert_eq!(r["log"], json!([false, true])); + assert_eq!( + r["slowestCommands"].as_array().map(|c| c.iter().map(|c| (c["id"].clone(), c["calls"].clone())).collect::>()), + Some(vec![(json!("path.setAnchors"), json!(1))]), + "one command writes every change" + ); + let pd = node(&s, a).path_data().unwrap().clone(); + assert!(pd.subpaths[0].closed); + assert_eq!(pd.subpaths[0].anchors.iter().map(|a| (a.p.x, a.p.y)).collect::>(), vec![(0.0, 0.0), (60.0, 0.0), (60.0, 60.0)]); +} + +#[test] +fn point_edits_of_a_pixel_aligned_path_read_as_the_grid_snaps_them() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute("object.setPixelAligned", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.setEntirePath([[10.3, 280.3], [40.3, 280.3], [40.3, 240.3], [10.3, 240.3]]);\ + vc.log(p.pathPoints[0].anchor); p.pathPoints[1].anchor = [40.4, 280.3]; vc.log(p.pathPoints[1].anchor);", + ); + let anchors = node(&s, a).path_data().unwrap().subpaths[0].anchors.to_vec(); + let stored = |i: usize| rounded(&json!([anchors[i].p.x, 300.0 - anchors[i].p.y])); + assert_ne!(rounded(&out[0]), json!([10.3, 280.3]), "the grid moves the point"); + assert_eq!((rounded(&out[0]), rounded(&out[1])), (stored(0), stored(1)), "points read as the path has them"); +} + +#[test] +fn added_paths_go_on_top_of_the_layer_whatever_the_drawing_mode() { + for mode in ["behind", "inside"] { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute("view.drawMode", &json!({"mode": mode})).unwrap(); + let drawing = s.draw_mode; + log( + &mut s, + "var d = app.activeDocument; d.pathItems.add().name = 'n'; d.pathItems.rectangle(10, 10, 5, 5).name = 'r';\ + d.pathItems.roundedRectangle(10, 10, 5, 5).name = 'q';", + ); + let st = s.active().unwrap(); + let children = st.doc.layers[0].children().unwrap(); + let names: Vec> = children.iter().rev().take(3).map(|c| c.name.as_deref()).collect(); + assert_eq!(names, [Some("q"), Some("r"), Some("n")], "{mode}: the new paths are on top of the layer"); + assert_eq!(s.draw_mode, drawing, "{mode}: the drawing mode stays"); + } +} + +#[test] +fn overprint_changes_the_top_fill_or_stroke_only() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute("appearance.addFill", &json!({})).unwrap(); + s.execute("appearance.addStroke", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.fillOverprint = true; p.strokeOverprint = true; vc.log([p.fillOverprint, p.strokeOverprint]);", + ); + assert_eq!(out, vec![json!([true, true])]); + let items = node(&s, a).appearance.items.clone(); + for fill in [true, false] { + let flags: Vec = items.iter().filter(|i| i.is_fill() == fill).map(|i| i.overprint()).collect(); + assert!(flags.len() >= 2, "{flags:?}"); + let (top, lower) = flags.split_last().unwrap(); + assert!(*top && lower.iter().all(|f| !f), "fill {fill}: only the top row overprints: {flags:?}"); + } +} + +#[test] +fn filled_true_on_a_compound_member_places_the_gradient_on_the_compound() { + for member in 0..2 { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("paint.setFill", &json!({"ids": [compound.0], "none": true})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let stops = json!([{"offset": 0, "color": "#ff0000"}, {"offset": 1, "color": "#0000ff"}]); + s.execute("paint.setFill", &json!({"gradient": {"kind": "linear", "stops": stops}})).unwrap(); + if let Paint::Gradient(g) = &mut s.paint.fill { + g.geom = Some(vectorcraft_color::GradientGeom { + start: vectorcraft_geom::Point::new(0.0, 0.5), + end: vectorcraft_geom::Point::new(1.0, 0.5), + aspect: 1.0, + focal: None, + }); + } + log(&mut s, &format!("app.activeDocument.pathItems[{member}].filled = true;")); + let b = node(&s, compound).geometric_bounds().unwrap(); + let Paint::Gradient(g) = node(&s, compound).appearance.fill_paint() else { panic!("member {member}: the compound has a gradient") }; + let geom = g.geom.unwrap(); + assert!((geom.start.x - b.x0).abs() < 1e-6 && (geom.end.x - b.x1).abs() < 1e-6, "member {member}: {geom:?} spans {b:?}"); + } +} + +#[test] +fn set_anchors_reads_smooth_false_as_a_corner() { + let (mut s, a, _) = doc(); + let anchor = |smooth: Value| { + let mut v = json!({"x": 20, "y": 20, "in": [10, 20], "out": [30, 20]}); + if !smooth.is_null() { + v["smooth"] = smooth; + } + v + }; + for (smooth, kind, read) in [(json!(false), AnchorKind::Corner, "PointType.CORNER"), (Value::Null, AnchorKind::Smooth, "PointType.SMOOTH")] { + let subpaths = json!([{"anchors": [anchor(smooth.clone()), {"x": 60, "y": 20}], "closed": false}]); + s.execute("path.setAnchors", &json!({"id": a.0, "subpaths": subpaths})).unwrap(); + assert_eq!(node(&s, a).path_data().unwrap().subpaths[0].anchors[0].kind, kind, "smooth {smooth}"); + assert_eq!(log(&mut s, "vc.log(app.activeDocument.pathItems[0].pathPoints[0].pointType);"), vec![json!(read)], "smooth {smooth}"); + } } #[test] diff --git a/docs/gaps.md b/docs/gaps.md index cd23b3096c..d8184b1a9b 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -807,9 +807,10 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi ## G6 Automation and scripting -- **Missing:** the rest of the document object model for scripts (layers, artboards, paths, type and the - other classes) and the `#engine` script directive (#1183 is open). Scripts have `app`, the open documents, new - documents, each document's selection and its page items. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` +- **Missing:** the rest of the document object model for scripts (layers, artboards, type, the selected path + points, gradient stops and the other classes) and the `#engine` script directive (#1183 is open). Scripts have + `app`, the open documents, new documents, each document's selection and its page items, and `Document.pathItems` + makes paths and reads and changes their points, colors, stroke options and transforms. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` runs a script in a named engine whose globals last between runs, File › Scripts lists the scripts of the Scripts folder, and Window › Script Console shows their output, errors and run reports. Actions, Batch, Variables (text, visibility, image and graph), data set CSV import and diff --git a/docs/mcp.md b/docs/mcp.md index 44d375ae2c..6c5e64789d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2685,7 +2685,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `polygon(centerX = 200, centerY = 300, radius = 50, sides = 8, reversed?)` and `star(centerX = 200, centerY = 300, radius = 50, innerRadius = 20, points = 5, reversed?)`, which run `shape.rectangle`, `path.create`, `shape.ellipse`, `shape.polygon` and `shape.star` (and `path.reverse` for `reversed`) and paint the new path as new - art is painted. A `PathItem` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/) adds to the page item + art is painted. `add()` and the shape creators put the new path on top of the active layer whatever the drawing + mode, which stays as it was. A `PathItem` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/) adds to the page item members `pathPoints`, `closed`, `evenodd`, `area` (negative for a path that runs counterclockwise), `length`, `guides`, `clipping`, `setEntirePath(points)`, `filled`, `fillColor`, `fillOverprint`, `stroked`, `strokeColor`, `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to 500), `strokeDashes`, @@ -2693,7 +2694,11 @@ app through the global object `vc`, and writes to the Script Console and runs ot positive angle) and `resize(scaleX, scaleY, ..., changeLineWidths?, scaleAbout?)`. The geometry changes through `path.setAnchors`, the fill and stroke through `paint.setFill` and `paint.setStroke`, the stroke options through `stroke.set`, the fill rule through `path.setFillRule`, overprint through `object.setOverprint` and the transforms - through `object.move`, `object.rotate` and `object.scale`. `pathPoints` + through `object.move`, `object.rotate` and `object.scale`. Changes to the points of a path (`closed`, + `setEntirePath`, `pathPoints` and each `PathPoint`) are written together with one `path.setAnchors` before the + script uses any other member or command, or the points of another path, and when the script ends; a path aligned + to the pixel grid, or in an object that is, is written at each change, so its points read as the grid snaps them. + `pathPoints` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and `removeAll()`, and each `PathPoint` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/) has `anchor`, `leftDirection` (the handle into the point), `rightDirection` (the handle out of it), `pointType`, `parent` and @@ -2708,15 +2713,19 @@ app through the global object `vc`, and writes to the Script Console and runs ot `pointType` changes only the type; `PathPoints.add()` adds a corner point at the last point, or at `[0, 0]`; a point whose index is past the end of its path throws `Stale path point`. Color components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of - range throws a `RangeError` when the color is assigned, with nothing changed. Reading `fillColor` or `strokeColor` - gives a new object each time, a `GradientColor`, `SpotColor` or `PatternColor` among them (a color linked to a + range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest + decimals, at least 4, that give the stored value back, so assigning a color read from a path leaves the path as it + was. Reading `fillColor` or `strokeColor` gives a new object each time, a `GradientColor`, `SpotColor` or `PatternColor` among them (a color linked to a global or spot swatch reads as a `SpotColor` with its `tint`); assigning one of those throws an error that says it is not available yet. `filled = true` on a path without a fill gives it the fill new art gets (a color, gradient or pattern), or black when new art has none, and `stroked = true` does the same with the - stroke; a new-art pattern with a placement of its own, or one missing from the document, throws an error. Sizes and + stroke; a new-art gradient goes on the bounds of the path, or of the compound path or compound shape whose paint + it shows, and a new-art pattern with a placement of its own, or one missing from the document, throws an error. + `fillOverprint` and `strokeOverprint` read and change the top fill or stroke only. Sizes and radii are finite and not negative, `sides` is a whole number from 3 to 1000, `points` one from 2 to 1000, `strokeWidth` 0 to 1000 points (a `changeLineWidths` that would scale it past 1000 throws), `strokeDashes` at most 64 lengths that are not all 0 (`[]` or `{}` for a solid line), and `rotateAbout` and `scaleAbout` default to - `Transformation.CENTER`. The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and + `Transformation.CENTER`. A transform that leaves the path where it is, such as `rotate(360)` or + `resize(100, 100)`, checks its arguments and runs no command, on a path with no points too. The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and `changeStrokePattern` given as different values throw an error, and `changeFillGradients` false and `ellipse` with `inscribed` true throw an error that says they are not available yet. A change to the geometry or paint of a path that is hidden or locked, or that is in a hidden or locked layer or group, throws `Cannot edit` with nothing diff --git a/docs/roadmap.md b/docs/roadmap.md index 3ddf3459a4..28192e13b9 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -196,7 +196,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG ``/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | | M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View (hiding the guides and the grid while it is on, #8363), middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 | | M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color (manual picker and canvas eyedropper from original pixels, no canvas View change, missed pixels keep the pick armed, Preview/Undo retained; #8068), Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 | -| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items; the rest of the script document model (layers, artboards, paths, type and the other classes) and batch work remain | 18–27 | +| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and `Document.pathItems` makes paths and reads and changes their points, colors, stroke options and transforms; the rest of the script document model (layers, artboards, type, the selected path points, gradient stops and the other classes) and batch work remain | 18–27 | | M14 | 1.0 polish (Asset Export tile context menus implemented for G12; preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset , UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Graphic Styles item context menus in thumbnail and list views with Options, Duplicate, Delete, Redefine, Break Link (#8755); Appearance panel row context menus for strokes, fills, effects, and root object row (Duplicate, Delete, Hide/Show, Edit Effect…, Clear Appearance, Reduce to Basic Appearance) with secondary click row selection (#8809); Character Styles and Paragraph Styles item context menus (panels::text_styles::tests::right_click_context_menu_*); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 | | — | Interaction fidelity pass (every tool's modifiers, Properties panel per context, isolation, nuance; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed) | ⬜ (new ruler-guide Alt orientation implemented; existing-guide Escape cancellation regression-tested; broader pass remains) | 60–90 | | — | Hardening at scale (big-file corpus, fuzzing, cross-platform + browser QA) | 🟡 PngSuite integrity and bounded fetching verified (#1729); real-world corpus/manual QA remain | 50–80 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 81abb83e94..72ed713051 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1025,7 +1025,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From 55f7dc920538db9a773dca99fd03429e3f0889c4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 13:51:09 -0800 Subject: [PATCH 003/264] Scripts: Document.saveAs, Document.exportFile and app.open with option classes Scripts save, export and open documents through Document.saveAs, Document.exportFile and app.open, with IllustratorSaveOptions, EPSSaveOptions, PDFSaveOptions, ExportOptionsPNG24, ExportOptionsJPEG, ExportOptionsSVG and a PDFFileOptions record, the ExportType and related enumerations, and app.userInteractionLevel. Each method runs file.saveAs, document.export or document.open inside the run's transaction. - A File argument reaches the host as its path only when the File class made it: the path is held in an internal slot that scripts cannot set, and a plain object that imitates a File is refused. - Each path is checked as a File opened for reading or writing would be, before the command runs, and the command's own reads and writes are then held to the script's grants, leaving out the open documents' files. A read-only file is not written over. - Options a command maps are applied; a listed option that is not mapped is accepted only at its documented default, and any other value, a bad type or an out-of-range number throws before anything is written. Without options, saveAs to a .ai, .eps or .pdf path and exportFile as PNG24, JPEG or SVG use the defaults a new options object holds. With pDFPreset named, a PDFSaveOptions option still at its default keeps the preset's value. A raster export at 100% has one pixel per point. - An export or save that writes several files, such as an SVG that writes its embedded images beside it or an EPS with a file per artboard, checks every path before writing the first. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/cmd/fileio/export_names.rs | 10 +- crates/engine/src/cmd/fileio/save.rs | 14 +- crates/engine/src/file_access.rs | 26 +- crates/engine/src/script/dom.rs | 11 +- crates/engine/src/script/dom/save_open.rs | 738 +++++++++++++++++++ crates/engine/src/script/files.rs | 36 + crates/engine/src/tests.rs | 1 + crates/engine/src/tests/script_save_open.rs | 510 +++++++++++++ crates/js/src/file_classes.rs | 93 ++- crates/js/src/heap.rs | 7 +- crates/js/src/host.rs | 12 +- crates/js/src/lib.rs | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + docs/mcp.md | 36 + docs/target-app-parity.md | 1 + 39 files changed, 1499 insertions(+), 22 deletions(-) create mode 100644 crates/engine/src/script/dom/save_open.rs create mode 100644 crates/engine/src/tests/script_save_open.rs diff --git a/crates/engine/src/cmd/fileio/export_names.rs b/crates/engine/src/cmd/fileio/export_names.rs index 5f2c14bfd5..48a8c828ab 100644 --- a/crates/engine/src/cmd/fileio/export_names.rs +++ b/crates/engine/src/cmd/fileio/export_names.rs @@ -73,7 +73,9 @@ pub(super) fn distinct_names_by(names: impl IntoIterator, key: im /// Write an export's files for the destination `path` → `{path, bytes, files?, linked?, …extra}` /// (`files`: every file when there are several; `linked`: the images it links to); with no path -/// → the same with `dataBase64` and `{name, dataBase64}` rows, named after `name`. +/// → the same with `dataBase64` and `{name, dataBase64}` rows, named after `name`. Every path is +/// checked against the file access in force before the first file is written, so a refused path +/// writes none of them. pub(super) fn write_encoded(path: Option<&str>, name: &str, doc: &vectorcraft_doc::Document, enc: &Encoded, extra: Value) -> Result { let files = enc.named(doc, path.unwrap_or(name)); let (main, linked) = files.split_at(enc.files.len()); @@ -82,6 +84,12 @@ pub(super) fn write_encoded(path: Option<&str>, name: &str, doc: &vectorcraft_do None => json!({ "name": name, "dataBase64": vectorcraft_format::base64_encode(bytes) }), }; if path.is_some() { + #[cfg(not(target_arch = "wasm32"))] + if files.len() > 1 { + for (p, _) in &files { + super::may_write(p)?; + } + } for (p, bytes) in &files { write_file(p, bytes)?; } diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index f03dc6fe0d..94187808c6 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -1044,7 +1044,8 @@ impl SaveJob { } /// [`SaveJob::write`], once `stop` has seen the paths of every file it writes to a path, in - /// order: when `stop` returns a value, nothing is written and that value is returned. Work + /// order: when `stop` returns a value, nothing is written and that value is returned. When a + /// save writes several files and the file access in force refuses one, none is written. Work /// canceled ([`crate::cancel`]) before the first file is written returns /// [`crate::EngineError::Cancelled`] and writes nothing; once the first file is written, the /// others are written too. @@ -1069,6 +1070,15 @@ impl SaveJob { if let Some(stopped) = stop(&files.iter().map(|(p, _)| p.as_str()).collect::>()) { return Ok(stopped); } + // Every path is checked against the file access in force before the first file is + // written. A refused file goes to `write` first, which refuses it with the error the + // caller gives (naming the path as the caller does), so none of the files is written. + #[cfg(not(target_arch = "wasm32"))] + if files.len() > 1 + && let Some((p, bytes)) = files.iter().find(|(p, _)| super::may_write(p).is_err()) + { + write(p, bytes)?; + } for (i, (p, bytes)) in files.iter().enumerate() { if i == 0 { write(p, bytes)?; @@ -1369,7 +1379,7 @@ pub(super) fn specs() -> Vec { "Save Document", [], None, - "{path?, format?: vectorcraft|template|pdf|svg|svgz|ai|eps (default: the path's extension, else the document's own format), options?: {…the format's options, see file.formatOptions; default: as last saved}, svg?: {…SVG options} (an SVG save keeps hidden layers, display:none, unless hiddenLayers is false), …the SVG and PDF options given flat instead (an option given flat or in svg and in options with different values is an error), compress?: bool (native, also in options: gzip; default: the useCompression preference; warnings name an option given flat or in options that the file doesn't read: a legacy .ai reads only its own options, and other .ai files don't read outlineText, hiddenObjects, transparentImages or preserveEditing), version?: 4 (3, 2 or 1: for older VectorCraft versions; 1 and 2 are never compressed), preview?: false (embed a PNG of the first artboard, at most 256 px), precision?: 0..9 (native: round path anchors and handles to this many decimal places, a smaller file; colors, transforms and type stay exact; default: exact, and a later save without it writes exactly again), separateArtboards?: false (native and .ai: also save each artboard of `range` to -. beside the file, holding that artboard and the art touching it; the result's files lists every file written), range?: \"1-3, 5\"|\"all\" (default; with separateArtboards), includeLinked?: false (keep linked files' own pixels, not just their previews; they stay linked), embedProfiles?: true (carry the ICC profiles loaded from files that the document is tagged with; opening the file installs them where missing), pdfCompatible?: true (native: also carry a PDF of every artboard; false omits it) | true for .ai (false: blank pages, only the native document; a .ai file's compress, default true, is its compression.compressText), modified?: Unix seconds|null (the File Info modified date, and created date when there is none, a save to a file stamps; default now, recorded in the journal so a replay matches; null: leave the dates)} → {path, format, bytes, warnings, files?: [path…] (the file and its artboards' files), linked?: [path…] (images an SVG links to)}. Save writes one artboard, except a .ai file and EPS (below): a .ai file is a PDF-compatible file of every artboard carrying the native document (preserveEditing always on; PDF options flat or in options), which document.open restores exactly, on the active artboard (the app's, else the one the document opened on; with editingData: false, the first); separateArtboards writes more files, one per artboard. EPS takes the options of document.exportEps: by default one file whose bounding box fits the visible art (the first artboard when no art shows), carrying the whole editable document; useArtboards: true (also when artboard, artboards or range names artboards; file.formatOptions then reports it true) makes the chosen artboard the page, drawn with its background color (without Use Artboards, only the first artboard's page when no art shows has its color), and with two or more chosen the file at the path is the central file of the visible art (again the first artboard when none shows) and each artboard is also written to _.eps beside it, holding that artboard; selectedOnly is refused; its PostScript appearance flattens transparency, as EPS requires. Without a path it writes the document's own file in its own format: a document opened from or saved as SVG/PDF/EPS saves as that again (warnings name what the format loses). No path known (never saved, converted from an older version, restored by Data Recovery, or another format) → {dataBase64, format, name, folder?, warnings} and the document stays modified. Under automation read roots, a reply leaves out the document's own file outside them when no path is given (files and linked then name the files by their file names), and a suggested folder outside them; an svg or svgz save (a document whose own format is SVG or SVGZ included), and a save whose file carries the native document (vectorcraft, template, eps, ai but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), is refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked), also by file.saveAs and file.saveCopy. A key that no save format takes, beside the path or in options, and an unknown key inside a PDF option's object or svg, are refused. A terminal filesystem permission/read-only refusal returns READ_ONLY_LOCATION: followed by the reason; recovery-copy failures keep their original error. Non-UI callers never open a save panel", + "{path?, format?: vectorcraft|template|pdf|svg|svgz|ai|eps (default: the path's extension, else the document's own format), options?: {…the format's options, see file.formatOptions; default: as last saved}, svg?: {…SVG options} (an SVG save keeps hidden layers, display:none, unless hiddenLayers is false), …the SVG and PDF options given flat instead (an option given flat or in svg and in options with different values is an error), compress?: bool (native, also in options: gzip; default: the useCompression preference; warnings name an option given flat or in options that the file doesn't read: a legacy .ai reads only its own options, and other .ai files don't read outlineText, hiddenObjects, transparentImages or preserveEditing), version?: 4 (3, 2 or 1: for older VectorCraft versions; 1 and 2 are never compressed), preview?: false (embed a PNG of the first artboard, at most 256 px), precision?: 0..9 (native: round path anchors and handles to this many decimal places, a smaller file; colors, transforms and type stay exact; default: exact, and a later save without it writes exactly again), separateArtboards?: false (native and .ai: also save each artboard of `range` to -. beside the file, holding that artboard and the art touching it; the result's files lists every file written), range?: \"1-3, 5\"|\"all\" (default; with separateArtboards), includeLinked?: false (keep linked files' own pixels, not just their previews; they stay linked), embedProfiles?: true (carry the ICC profiles loaded from files that the document is tagged with; opening the file installs them where missing), pdfCompatible?: true (native: also carry a PDF of every artboard; false omits it) | true for .ai (false: blank pages, only the native document; a .ai file's compress, default true, is its compression.compressText), modified?: Unix seconds|null (the File Info modified date, and created date when there is none, a save to a file stamps; default now, recorded in the journal so a replay matches; null: leave the dates)} → {path, format, bytes, warnings, files?: [path…] (the file and its artboards' files), linked?: [path…] (images an SVG links to)}. Save writes one artboard, except a .ai file and EPS (below): a .ai file is a PDF-compatible file of every artboard carrying the native document (preserveEditing always on; PDF options flat or in options), which document.open restores exactly, on the active artboard (the app's, else the one the document opened on; with editingData: false, the first); separateArtboards writes more files, one per artboard; when one of a save's files may not be written, none is written. EPS takes the options of document.exportEps: by default one file whose bounding box fits the visible art (the first artboard when no art shows), carrying the whole editable document; useArtboards: true (also when artboard, artboards or range names artboards; file.formatOptions then reports it true) makes the chosen artboard the page, drawn with its background color (without Use Artboards, only the first artboard's page when no art shows has its color), and with two or more chosen the file at the path is the central file of the visible art (again the first artboard when none shows) and each artboard is also written to _.eps beside it, holding that artboard; selectedOnly is refused; its PostScript appearance flattens transparency, as EPS requires. Without a path it writes the document's own file in its own format: a document opened from or saved as SVG/PDF/EPS saves as that again (warnings name what the format loses). No path known (never saved, converted from an older version, restored by Data Recovery, or another format) → {dataBase64, format, name, folder?, warnings} and the document stays modified. Under automation read roots, a reply leaves out the document's own file outside them when no path is given (files and linked then name the files by their file names), and a suggested folder outside them; an svg or svgz save (a document whose own format is SVG or SVGZ included), and a save whose file carries the native document (vectorcraft, template, eps, ai but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), is refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked), also by file.saveAs and file.saveCopy. A key that no save format takes, beside the path or in options, and an unknown key inside a PDF option's object or svg, are refused. A terminal filesystem permission/read-only refusal returns READ_ONLY_LOCATION: followed by the reason; recovery-copy failures keep their original error. Non-UI callers never open a save panel", has_doc, |s, p| save(s, SaveMode::Save, p) ), diff --git a/crates/engine/src/file_access.rs b/crates/engine/src/file_access.rs index c5ecee374e..4769146ad8 100644 --- a/crates/engine/src/file_access.rs +++ b/crates/engine/src/file_access.rs @@ -310,7 +310,9 @@ impl ScriptGate { Access::Read => self.read.allows(&real) || self.write.allows(&real), Access::Write => self.write.allows(&real), }; - scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real)) + // A read-only file is not written over, also where a rename could replace it. + let read_only = matches!(access, Access::Write) && std::fs::metadata(&real).is_ok_and(|m| m.is_file() && m.permissions().readonly()); + !read_only && (scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real))) }); if allowed { Ok(()) } else { Err(format!("Script file access denied: {path}")) } } @@ -957,6 +959,28 @@ mod tests { let _ = std::fs::remove_dir_all(base); } + #[test] + fn a_script_gate_does_not_write_over_a_read_only_file() { + let (base, _) = folders("gate-read-only"); + let out = base.join("out/kept.svg"); + std::fs::write(&out, "").unwrap(); + let gate = ScriptGate { read: ScriptScope::default(), write: ScriptScope::of_folder(&base.join("out")), documents: vec![], also: None }; + let (kept, fresh) = (s(out.clone()), s(base.join("out/new.svg"))); + let check = |p: &str| with_script_gate(gate.clone(), || (check_write(p).is_ok(), check_read(p).is_ok())); + assert_eq!(check(&kept), (true, true)); + let mut perms = std::fs::metadata(&out).unwrap().permissions(); + perms.set_readonly(true); + std::fs::set_permissions(&out, perms.clone()).unwrap(); + assert_eq!(check(&kept), (false, true), "a read-only file is read but not written"); + assert!(check(&fresh).0, "a new file next to it is written"); + let documents = ScriptGate { documents: vec![kept.clone()], ..gate.clone() }; + assert!(!with_script_gate(documents, || check_write(&kept).is_ok()), "also when it is an open document's file"); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + std::fs::set_permissions(&out, perms).unwrap(); + let _ = std::fs::remove_dir_all(base); + } + #[test] fn network_paths_are_told_by_name() { for p in [r"\\server\share\x.svg", "//server/share/x.svg", r"\\?\UNC\server\share\x.svg", r"\\?\unc\server\share"] { diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 241720f786..5e16f2a121 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -38,6 +38,8 @@ use vectorcraft_js::{Data, HostClass, HostError, HostFunction, HostItem, HostMem use super::{HISTORY_LOST, Host, Link, Savepoint, command, command_value, current, data_size}; use crate::{DocState, Document, NodeId, NodeKind, Session}; +mod save_open; + /// The error for a member read or called with no document open. pub const NO_ACTIVE_DOCUMENT: &str = "No active document"; /// The error for an object that was deleted, or that came from an earlier run. @@ -92,6 +94,8 @@ pub(super) struct State { coords: Cell, items: RefCell>, saving: Cell, + /// `app.userInteractionLevel` ([`save_open`]). + save_options: save_open::State, } impl State { @@ -1707,7 +1711,7 @@ const ENUMS: &[(&str, &[&str])] = &[ /// Adds `app`, its classes and the enumerations to `realm`; their members act for the run `link` /// holds. pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), RunError> { - for (name, members) in ENUMS { + for (name, members) in ENUMS.iter().chain(save_open::ENUMS) { let items = members.iter().map(|m| (m.to_string(), HostItem::Value(text(format!("{name}.{m}"))))).collect(); realm.define_host_object(name, items)?; } @@ -1721,6 +1725,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("getIsFileOpen", method(l, app_is_open)), ]); application.push(later(l, "Application", "beep")); + application.extend(save_open::application_members(l)); let preset = { let l = link.clone(); let f: HostFunction = Rc::new(move |a: Vec| { @@ -1761,10 +1766,11 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("selection", property(l, doc_selection, doc_set_selection)), ]); document.extend( - ["layers", "artboards", "pathItems", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "saveAs", "close"] + ["layers", "artboards", "pathItems", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "close"] .into_iter() .map(|m| later(l, "Document", m)), ); + document.extend(save_open::document_members(l)); classes.push(class("Document", None, document, None)); classes.push(class( "PageItems", @@ -1829,6 +1835,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ); classes.push(class("PageItem", None, page_item, None)); classes.extend(ITEM_CLASSES.iter().map(|c| class(c, Some("PageItem"), Vec::new(), None))); + classes.extend(save_open::classes(l)); classes.push(class("Layer", None, named(vec![("typename", get(l, layer_typename)), ("name", get(l, layer_name))]), None)); realm.define_host_classes(classes, vec![("app".into(), host_ref("Application", &[]))]) } diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs new file mode 100644 index 0000000000..ebdebc4c10 --- /dev/null +++ b/crates/engine/src/script/dom/save_open.rs @@ -0,0 +1,738 @@ +//! Saving, exporting and opening documents in the script object model: `Document.saveAs`, +//! `Document.exportFile`, `app.open` and `app.userInteractionLevel`, with the option classes the +//! help pages , +//! , +//! , +//! , +//! , +//! , +//! , +//! and +//! describe. +//! +//! Each method runs a command (`file.saveAs`, `document.export`, `document.open`) inside the run's +//! transaction. The file is a `File` object, and the method reads and writes only where that +//! `File` may ([`super::super::files`]): the path is checked before the command runs, and the +//! command's own reads and writes leave out the files of the open documents that `vc.run`'s +//! commands may use. +//! +//! VectorCraft's own rules, which the help pages do not state: +//! - `saveAs` without options saves in the format the path's extension names; it writes the file +//! at the path as given. Without options, `saveAs` to a `.ai`, `.eps` or `.pdf` path and +//! `exportFile` as PNG24, JPEG or SVG use the defaults a new options object of that class holds. +//! `exportFile` adds the format's extension unless the name already ends +//! with it (`.png`, `.jpg` or `.jpeg`, `.gif`, `.tif` or `.tiff`, `.svg`, `.svgz`), and writes +//! one file: the active artboard with `artBoardClipping`, otherwise the bounds of the visible art. +//! An SVG with `embedRasterImages` false also writes the document's embedded images beside it, +//! and when one of those files may not be written, none of them is. +//! - An option the classes here map is applied; a listed option that is not mapped is accepted at +//! the default its help page gives and throws an error that says it is not available yet at any +//! other value; a property the help pages do not list is left out. With `pDFPreset` named, a +//! `PDFSaveOptions` option still at a new object's default keeps the preset's value. +//! - `app.open(file, documentColorSpace?, options?)` takes `options` as a `PDFFileOptions` record: +//! an object with `pageToOpen` and `pDFCropToBox`, used for that call only. +//! - `app.userInteractionLevel` starts at `UserInteractionLevel.DISPLAYALERTS` in each run. The +//! commands a script runs never show a dialog, so the level does not change what they do, and it +//! never allows a file the script's grants do not. + +use std::cell::Cell; +use std::rc::Rc; + +use serde_json::{Map, Value, json}; +use vectorcraft_js::{Data, HostClass, HostError, HostFunction, HostMember}; + +use super::{ + Answer, Host, Link, MAX_TEXT_BYTES, NO_ACTIVE_DOCUMENT, arg, boolean, command, current, doc_ref, given, method, named, num, on_doc, property, + text, this_doc, whole, +}; + +/// The most a scale factor of an export takes, in percent. +pub const MAX_SCALE_PERCENT: f64 = 776.19; + +/// What the run keeps for these members: whether `userInteractionLevel` is `DONTDISPLAYALERTS`. +#[derive(Default)] +pub(in crate::script) struct State { + quiet: Cell, +} + +/// The enumerations these members use, as `dom`'s are made. +pub(super) const ENUMS: &[(&str, &[&str])] = &[ + ("ExportType", &["AutoCAD", "FLASH", "GIF", "JPEG", "PNG24", "PNG8", "SVG", "TIFF"]), + ( + "Compatibility", + &[ + "ILLUSTRATOR8", + "ILLUSTRATOR9", + "ILLUSTRATOR10", + "ILLUSTRATOR11", + "ILLUSTRATOR12", + "ILLUSTRATOR13", + "ILLUSTRATOR14", + "ILLUSTRATOR15", + "ILLUSTRATOR16", + "ILLUSTRATOR17", + "ILLUSTRATOR19", + "JAPANESEVERSION3", + ], + ), + ("PDFCompatibility", &["ACROBAT4", "ACROBAT5", "ACROBAT6", "ACROBAT7", "ACROBAT8"]), + ("PDFBoxType", &["PDFARTBOX", "PDFBLEEDBOX", "PDFBOUNDINGBOX", "PDFCROPBOX", "PDFMEDIABOX", "PDFTRIMBOX"]), + ("EPSPreview", &["BWTIFF", "COLORTIFF", "TRANSPARENTCOLORTIFF", "None"]), + ("EPSPostScriptLevelEnum", &["LEVEL2", "LEVEL3"]), + ("PDFOverprint", &["DISCARDPDFOVERPRINT", "PRESERVEPDFOVERPRINT"]), + ("UserInteractionLevel", &["DISPLAYALERTS", "DONTDISPLAYALERTS"]), +]; + +const DISPLAY: &str = "UserInteractionLevel.DISPLAYALERTS"; +const QUIET: &str = "UserInteractionLevel.DONTDISPLAYALERTS"; + +/// The default a listed option that is not mapped keeps: a value equal to it is accepted. +#[derive(Clone, Copy)] +enum Default { + Bool(bool), + Num(f64), + Text(&'static str), + /// An enumerated value, by its enumeration and member (`("DownsampleMethod", "NODOWNSAMPLE")` for + /// `DownsampleMethod.NODOWNSAMPLE`). + Member(&'static str, &'static str), + /// The help page gives no default: any value throws. + Unset, +} + +impl Default { + fn matches(self, d: &Data) -> bool { + match (self, d) { + (Default::Bool(a), Data::Bool(b)) => a == *b, + (Default::Num(a), Data::Number(b)) => (a - b).abs() < 1e-9, + (Default::Text(a), Data::String(b)) => a == b, + (Default::Member(e, m), Data::String(b)) => b.split_once('.').is_some_and(|(be, bm)| be == e && bm == m), + _ => false, + } + } +} + +/// A mapped option: from its name and value into the command's params, `Ok(false)` for a name it +/// does not map. +type Mapper = fn(&str, &Data, &mut Map) -> std::result::Result; + +/// An option class: its name, its mapped options, its listed options that are not mapped, and the +/// defaults a new object starts with. +struct OptionClass { + name: &'static str, + map: Mapper, + kept: &'static [(&'static str, Default)], + starts: fn() -> Vec<(&'static str, Data)>, +} + +fn not_available(class: &str, name: &str) -> HostError { + HostError::Error(format!("{class}.{name} is not available yet")) +} + +fn whole_in(d: &Data, what: &str, lo: u64, hi: u64) -> std::result::Result { + match d { + Data::Number(n) => { + whole(*n).filter(|n| (lo..=hi).contains(n)).ok_or_else(|| HostError::Range(format!("{what} must be a whole number from {lo} to {hi}"))) + } + _ => Err(HostError::Type(format!("{what} must be a number"))), + } +} + +/// The member of `enumeration` that `d` names (`"Enumeration.MEMBER"`), one of `members`. +fn member<'a>(d: &'a Data, enumeration: &str, members: &[&str], what: &str) -> std::result::Result<&'a str, HostError> { + let bad = || HostError::Type(format!("{what} must be a {enumeration} value")); + let Data::String(s) = d else { return Err(bad()) }; + let m = s.strip_prefix(enumeration).and_then(|r| r.strip_prefix('.')).ok_or_else(bad)?; + if members.contains(&m) { Ok(m) } else { Err(bad()) } +} + +/// A `Compatibility` value: the versions from 17 on are the file VectorCraft writes; older ones are +/// not available. +fn compatibility(class: &str, d: &Data) -> std::result::Result<(), HostError> { + let all = ENUMS.iter().find(|(n, _)| *n == "Compatibility").map_or(&[][..], |(_, m)| *m); + match member(d, "Compatibility", all, &format!("{class}.compatibility"))? { + "ILLUSTRATOR17" | "ILLUSTRATOR19" => Ok(()), + _ => Err(not_available(class, "compatibility")), + } +} + +/// An artboard range: a string, given to the command as `range` unless it is empty. +fn range(d: &Data, what: &str, p: &mut Map) -> std::result::Result<(), HostError> { + let Data::String(s) = d else { return Err(HostError::Type(format!("{what} must be a string"))) }; + if s.len() > MAX_TEXT_BYTES { + return Err(HostError::Range(format!("{what} is too long"))); + } + if !s.trim().is_empty() { + p.insert("range".into(), json!(s)); + } + Ok(()) +} + +// ---- Save options ---- + +fn ai_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("IllustratorSaveOptions.{name}"); + match name { + "compressed" => p.insert("compress".into(), json!(boolean(d, &what)?)), + "pdfCompatible" => p.insert("pdfCompatible".into(), json!(boolean(d, &what)?)), + "embedICCProfile" => p.insert("embedProfiles".into(), json!(boolean(d, &what)?)), + "compatibility" => { + compatibility("IllustratorSaveOptions", d)?; + None + } + _ => return Ok(false), + }; + Ok(true) +} + +const AI_KEPT: &[(&str, Default)] = &[ + ("artboardRange", Default::Text("")), + ("embedLinkedFiles", Default::Bool(false)), + ("flattenOutput", Default::Member("OutputFlattening", "PRESERVEAPPEARANCE")), + ("fontSubsetThreshold", Default::Num(100.0)), + ("saveMultipleArtboards", Default::Bool(false)), +]; + +fn ai_starts() -> Vec<(&'static str, Data)> { + vec![("compressed", Data::Bool(true)), ("pdfCompatible", Data::Bool(true)), ("embedICCProfile", Data::Bool(false))] +} + +fn eps_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("EPSSaveOptions.{name}"); + match name { + "cmykPostScript" => { + p.insert("cmykPostScript".into(), json!(boolean(d, &what)?)); + } + "includeDocumentThumbnails" => { + p.insert("thumbnails".into(), json!(boolean(d, &what)?)); + } + "postScript" => { + let level = if member(d, "EPSPostScriptLevelEnum", &["LEVEL2", "LEVEL3"], &what)? == "LEVEL2" { 2 } else { 3 }; + p.insert("level".into(), json!(level)); + } + "preview" => { + let (format, transparent) = match member(d, "EPSPreview", &["BWTIFF", "COLORTIFF", "TRANSPARENTCOLORTIFF", "None"], &what)? { + "BWTIFF" => ("tiffBw", None), + "COLORTIFF" => ("tiffColor", Some(false)), + "TRANSPARENTCOLORTIFF" => ("tiffColor", Some(true)), + _ => ("none", None), + }; + p.insert("previewFormat".into(), json!(format)); + if let Some(t) = transparent { + p.insert("transparentPreview".into(), json!(t)); + } + } + "overprint" => { + let keep = member(d, "PDFOverprint", &["DISCARDPDFOVERPRINT", "PRESERVEPDFOVERPRINT"], &what)? == "PRESERVEPDFOVERPRINT"; + p.insert("overprints".into(), json!(if keep { "preserve" } else { "discard" })); + } + "compatibility" => compatibility("EPSSaveOptions", d)?, + _ => return Ok(false), + } + Ok(true) +} + +const EPS_KEPT: &[(&str, Default)] = &[ + ("artboardRange", Default::Text("")), + ("compatibleGradientPrinting", Default::Bool(false)), + ("embedAllFonts", Default::Bool(false)), + ("embedLinkedFiles", Default::Unset), + ("flattenOuput", Default::Unset), + ("saveMultipleArtboards", Default::Bool(false)), +]; + +fn eps_starts() -> Vec<(&'static str, Data)> { + vec![("postScript", text("EPSPostScriptLevelEnum.LEVEL2")), ("overprint", text("PDFOverprint.PRESERVEPDFOVERPRINT"))] +} + +fn pdf_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("PDFSaveOptions.{name}"); + match name { + "pDFPreset" => { + let Data::String(s) = d else { return Err(HostError::Type(format!("{what} must be a string"))) }; + if s.len() > MAX_TEXT_BYTES { + return Err(HostError::Range(format!("{what} is too long"))); + } + p.insert("preset".into(), json!(s)); + } + "compatibility" => { + let version = match member(d, "PDFCompatibility", &["ACROBAT4", "ACROBAT5", "ACROBAT6", "ACROBAT7", "ACROBAT8"], &what)? { + "ACROBAT4" => "1.3", + "ACROBAT5" => "1.4", + "ACROBAT6" => "1.5", + "ACROBAT7" => "1.6", + _ => "1.7", + }; + p.insert("compatibility".into(), json!(version)); + } + "artboardRange" => range(d, &what, p)?, + "preserveEditability" => { + p.insert("preserveEditing".into(), json!(boolean(d, &what)?)); + } + "acrobatLayers" => { + p.insert("createLayers".into(), json!(boolean(d, &what)?)); + } + "compressArt" => { + p.insert("compression".into(), json!({"compressText": boolean(d, &what)?})); + } + _ => return Ok(false), + } + Ok(true) +} + +const PDF_KEPT: &[(&str, Default)] = &[ + ("bleedLink", Default::Bool(true)), + ("bleedOffsetRect", Default::Unset), + ("colorBars", Default::Bool(false)), + ("colorCompression", Default::Member("CompressionQuality", "None")), + ("colorConversionID", Default::Member("ColorConversion", "None")), + ("colorDestinationID", Default::Member("ColorDestination", "None")), + ("colorDownsampling", Default::Num(150.0)), + ("colorDownsamplingImageThreshold", Default::Num(225.0)), + ("colorDownsamplingMethod", Default::Member("DownsampleMethod", "NODOWNSAMPLE")), + ("colorProfileID", Default::Member("ColorProfile", "None")), + ("colorTileSize", Default::Num(256.0)), + ("documentPassword", Default::Text("")), + ("enableAccess", Default::Bool(true)), + ("enableCopy", Default::Bool(true)), + ("enableCopyAccess", Default::Bool(true)), + ("enablePlainText", Default::Bool(false)), + ("flattenerOptions", Default::Unset), + ("flattenerPreset", Default::Unset), + ("fontSubsetThreshold", Default::Num(100.0)), + ("generateThumbnails", Default::Bool(true)), + ("grayscaleCompression", Default::Member("CompressionQuality", "None")), + ("grayscaleDownsampling", Default::Num(150.0)), + ("grayscaleDownsamplingImageThreshold", Default::Num(225.0)), + ("grayscaleDownsamplingMethod", Default::Member("DownsampleMethod", "NODOWNSAMPLE")), + ("grayscaleTileSize", Default::Num(256.0)), + ("monochromeCompression", Default::Member("MonochromeCompression", "None")), + ("monochromeDownsampling", Default::Num(300.0)), + ("monochromeDownsamplingImageThreshold", Default::Num(450.0)), + ("monochromeDownsamplingMethod", Default::Member("DownsampleMethod", "NODOWNSAMPLE")), + ("offset", Default::Num(0.0)), + ("optimization", Default::Bool(false)), + ("outputCondition", Default::Unset), + ("outputConditionID", Default::Unset), + ("pageInformation", Default::Bool(false)), + ("pageMarksType", Default::Member("PageMarksTypes", "Roman")), + ("pDFAllowPrinting", Default::Member("PDFPrintAllowedEnum", "PRINT128HIGHRESOLUTION")), + ("pDFChangesAllowed", Default::Member("PDFChangesAllowedEnum", "CHANGE128ANYCHANGES")), + ("pDFXStandard", Default::Member("PDFXStandard", "PDFXNONE")), + ("pDFXStandardDescription", Default::Unset), + ("permissionPassword", Default::Text("")), + ("printerResolution", Default::Num(800.0)), + ("registrationMarks", Default::Bool(false)), + ("requireDocumentPassword", Default::Bool(false)), + ("requirePermissionPassword", Default::Bool(false)), + ("trapped", Default::Bool(false)), + ("trimMarks", Default::Bool(false)), + ("trimMarkWeight", Default::Member("PDFTrimMarkWeight", "TRIMMARKWEIGHT0125")), + ("viewAfterSaving", Default::Bool(false)), +]; + +fn pdf_starts() -> Vec<(&'static str, Data)> { + vec![ + ("compatibility", text("PDFCompatibility.ACROBAT5")), + ("artboardRange", text("")), + ("preserveEditability", Data::Bool(true)), + ("acrobatLayers", Data::Bool(false)), + ("compressArt", Data::Bool(true)), + ] +} + +const SAVE_CLASSES: &[(OptionClass, &str)] = &[ + (OptionClass { name: "IllustratorSaveOptions", map: ai_map, kept: AI_KEPT, starts: ai_starts }, "ai"), + (OptionClass { name: "EPSSaveOptions", map: eps_map, kept: EPS_KEPT, starts: eps_starts }, "eps"), + (OptionClass { name: "PDFSaveOptions", map: pdf_map, kept: PDF_KEPT, starts: pdf_starts }, "pdf"), +]; + +// ---- Export options ---- + +/// The raster options PNG24 and JPEG share: anti-aliasing, the clip to the artboard and the scale. +fn raster_map(class: &str, name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("{class}.{name}"); + match name { + "antiAliasing" => { + p.insert("antiAlias".into(), json!(if boolean(d, &what)? { "art" } else { "none" })); + } + "artBoardClipping" => { + p.insert("_clip".into(), json!(boolean(d, &what)?)); + } + "horizontalScale" | "verticalScale" => { + let n = match d { + Data::Number(n) if n.is_finite() => *n, + _ => return Err(HostError::Type(format!("{what} must be a finite number"))), + }; + if n <= 0.0 || n > MAX_SCALE_PERCENT { + return Err(HostError::Range(format!("{what} must be more than 0 and at most 776.19"))); + } + let key = if name == "horizontalScale" { "_h" } else { "_v" }; + p.insert(key.into(), json!(n)); + } + _ => return Ok(false), + } + Ok(true) +} + +fn png24_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + if name == "transparency" { + let clear = boolean(d, "ExportOptionsPNG24.transparency")?; + p.insert("background".into(), json!(if clear { "transparent" } else { "white" })); + return Ok(true); + } + raster_map("ExportOptionsPNG24", name, d, p) +} + +const PNG24_KEPT: &[(&str, Default)] = &[("matte", Default::Bool(true)), ("matteColor", Default::Unset), ("saveAsHTML", Default::Bool(false))]; + +fn png24_starts() -> Vec<(&'static str, Data)> { + vec![ + ("antiAliasing", Data::Bool(true)), + ("artBoardClipping", Data::Bool(false)), + ("horizontalScale", num(100.0)), + ("verticalScale", num(100.0)), + ("transparency", Data::Bool(true)), + ] +} + +fn jpeg_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + match name { + "qualitySetting" => { + p.insert("quality".into(), json!(whole_in(d, "ExportOptionsJPEG.qualitySetting", 0, 100)?)); + Ok(true) + } + "optimization" => { + let optimized = boolean(d, "ExportOptionsJPEG.optimization")?; + p.insert("method".into(), json!(if optimized { "optimized" } else { "baseline" })); + Ok(true) + } + _ => raster_map("ExportOptionsJPEG", name, d, p), + } +} + +const JPEG_KEPT: &[(&str, Default)] = + &[("blurAmount", Default::Num(0.0)), ("matte", Default::Bool(true)), ("matteColor", Default::Unset), ("saveAsHTML", Default::Bool(false))]; + +fn jpeg_starts() -> Vec<(&'static str, Data)> { + vec![ + ("antiAliasing", Data::Bool(true)), + ("horizontalScale", num(100.0)), + ("verticalScale", num(100.0)), + ("optimization", Data::Bool(true)), + ("qualitySetting", num(30.0)), + ] +} + +fn svg_map(name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("ExportOptionsSVG.{name}"); + match name { + "coordinatePrecision" => { + p.insert("decimals".into(), json!(whole_in(d, &what, 1, 7)?)); + } + "embedRasterImages" => { + p.insert("images".into(), json!(if boolean(d, &what)? { "embed" } else { "link" })); + } + "compressed" => { + p.insert("_svgz".into(), json!(boolean(d, &what)?)); + } + "preserveEditability" => { + p.insert("preserveEditing".into(), json!(boolean(d, &what)?)); + } + "includeVariablesAndDatasets" => { + p.insert("variableData".into(), json!(boolean(d, &what)?)); + } + _ => return Ok(false), + } + Ok(true) +} + +const SVG_KEPT: &[(&str, Default)] = &[ + ("artboardRange", Default::Text("")), + ("cssProperties", Default::Member("SVGCSSPropertyLocation", "STYLEATTRIBUTES")), + ("documentEncoding", Default::Member("SVGDocumentEncoding", "ASCII")), + ("DTD", Default::Member("SVGDTDVersion", "SVG1_1")), + ("fontSubsetting", Default::Member("SVGFontSubsetting", "ALLGLYPHS")), + ("fontType", Default::Member("SVGFontType", "CEFFONT")), + ("includeFileInfo", Default::Bool(false)), + ("includeUnusedStyles", Default::Bool(false)), + ("optimizeForSVGViewer", Default::Bool(false)), + ("saveMultipleArtboards", Default::Bool(false)), + ("slices", Default::Bool(false)), + ("sVGAutoKerning", Default::Bool(false)), + ("sVGTextOnPath", Default::Bool(false)), +]; + +fn svg_starts() -> Vec<(&'static str, Data)> { + vec![ + ("compressed", Data::Bool(false)), + ("coordinatePrecision", num(3.0)), + ("embedRasterImages", Data::Bool(false)), + ("includeVariablesAndDatasets", Data::Bool(false)), + ("preserveEditability", Data::Bool(false)), + ] +} + +const PNG24: OptionClass = OptionClass { name: "ExportOptionsPNG24", map: png24_map, kept: PNG24_KEPT, starts: png24_starts }; +const JPEG: OptionClass = OptionClass { name: "ExportOptionsJPEG", map: jpeg_map, kept: JPEG_KEPT, starts: jpeg_starts }; +const SVG: OptionClass = OptionClass { name: "ExportOptionsSVG", map: svg_map, kept: SVG_KEPT, starts: svg_starts }; + +/// An `ExportType`: the format `document.export` writes, the extensions a file name may already +/// end with (the first is added), and its option class (`None`: no options are taken). +struct ExportKind { + format: &'static str, + extensions: &'static [&'static str], + options: Option<&'static OptionClass>, +} + +fn export_kind(d: &Data) -> std::result::Result { + let all = ENUMS.iter().find(|(n, _)| *n == "ExportType").map_or(&[][..], |(_, m)| *m); + let raster = |format, extensions| ExportKind { format, extensions, options: None }; + Ok(match member(d, "ExportType", all, "exportType")? { + "PNG24" => ExportKind { format: "png", extensions: &["png"], options: Some(&PNG24) }, + "JPEG" => ExportKind { format: "jpg", extensions: &["jpg", "jpeg"], options: Some(&JPEG) }, + "SVG" => ExportKind { format: "svg", extensions: &["svg"], options: Some(&SVG) }, + "PNG8" => raster("png8", &["png"]), + "GIF" => raster("gif", &["gif"]), + "TIFF" => raster("tiff", &["tif", "tiff"]), + other => return Err(HostError::Error(format!("ExportType.{other} is not available yet"))), + }) +} + +/// The command's params for the options object `d` of `class`, read as the module's rules say. +fn options_params(class: &OptionClass, d: &Data) -> std::result::Result, HostError> { + let wrong = || HostError::Type(format!("the options must be an {} object", class.name)); + let Data::Object(items) = d else { return Err(wrong()) }; + if !items.iter().any(|(k, v)| k == "typename" && matches!(v, Data::String(s) if s == class.name)) { + return Err(wrong()); + } + // With a PDF preset named, an option still at a new object's default leaves the preset's value. + let preset = class.name == "PDFSaveOptions" && items.iter().any(|(k, v)| k == "pDFPreset" && matches!(v, Data::String(s) if !s.is_empty())); + let starts = if preset { (class.starts)() } else { Vec::new() }; + let mut p = Map::new(); + for (k, v) in items { + if k == "typename" || matches!(v, Data::Undefined) || starts.iter().any(|(n, s)| n == k && s == v) { + continue; + } + if (class.map)(k, v, &mut p)? { + continue; + } + match class.kept.iter().find(|(n, _)| n == k) { + Some((_, default)) if default.matches(v) => {} + Some(_) => return Err(not_available(class.name, k)), + None => {} + } + } + Ok(p) +} + +/// What `new Name()` gives for `class`: its `typename` and the defaults its help page gives for the +/// options mapped here. +fn fresh(class: &OptionClass) -> Data { + let mut items = vec![("typename".to_string(), text(class.name))]; + items.extend((class.starts)().into_iter().map(|(k, v)| (k.to_string(), v))); + Data::Object(items) +} + +/// The typename of an options object, when it has one. +fn typename(d: &Data) -> Option<&str> { + let Data::Object(items) = d else { return None }; + items.iter().find_map(|(k, v)| match (k.as_str(), v) { + ("typename", Data::String(s)) => Some(s.as_str()), + _ => None, + }) +} + +// ---- Files ---- + +/// The path of the `File` argument `d`, or a `TypeError` naming the method. +fn file_path<'a>(d: &'a Data, method: &str) -> std::result::Result<&'a str, HostError> { + vectorcraft_js::file_ref_path(d).ok_or_else(|| HostError::Type(format!("{method} needs a File"))) +} + +/// The error a refused path throws: the `File` error and the path. +fn refused(message: &str, path: &str) -> HostError { + HostError::Error(format!("{message}: {path}")) +} + +/// Runs `f` with the commands' reads and writes held to the script's own grants +/// ([`super::super::files::Disk::exact`]). +fn exactly(h: &Host, f: impl FnOnce() -> Answer) -> Answer { + h.disk.borrow_mut().exact = true; + let r = f(); + h.disk.borrow_mut().exact = false; + r +} + +/// The path to give a command for the real path `real`. +fn plain(real: std::path::PathBuf) -> String { + crate::cmd::findfiles::plain(real).to_string_lossy().into_owned() +} + +/// `document.saveAs(file, options?)`: `file.saveAs` on the document, in the format the options' +/// class names (`ai`, `eps`, `pdf`), or without options in the format of the path's extension. +fn doc_save_as(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + let path = file_path(arg(a, 1), "saveAs")?; + let mut p = Map::new(); + let given_options = given(arg(a, 2)).filter(|d| !matches!(d, Data::Null)); + // Without options, a path ending in `.ai`, `.eps` or `.pdf` takes the defaults a new options + // object of that format's class holds. + let extension = path.rsplit(['/', '\\']).next().and_then(|n| n.rsplit_once('.')).map(|(_, e)| e.to_ascii_lowercase()); + let by_extension = SAVE_CLASSES.iter().find(|(_, f)| Some(*f) == extension.as_deref()).map(|(c, _)| fresh(c)); + if let Some(o) = given_options.or(by_extension.as_ref()) { + let name = typename(o); + let Some((class, format)) = SAVE_CLASSES.iter().find(|(c, _)| Some(c.name) == name) else { + return Err(HostError::Type("saveAs options must be IllustratorSaveOptions, EPSSaveOptions or PDFSaveOptions".into())); + }; + let q = options_params(class, o)?; + p.insert("format".into(), json!(format)); + if *format == "ai" { + p.extend(q); + } else if !q.is_empty() { + p.insert("options".into(), Value::Object(q)); + } + } + let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?; + p.insert("path".into(), json!(plain(real))); + exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "file.saveAs", &Value::Object(p))))?; + Ok(Data::Undefined) +} + +/// `path` with the extension of `kind` added, unless its name already ends with one of them. +fn with_extension(path: &str, kind: &ExportKind, svgz: bool) -> String { + let extensions: &[&str] = if svgz { &["svgz"] } else { kind.extensions }; + let name = path.rsplit(['/', '\\']).next().unwrap_or(path).to_lowercase(); + match extensions.first() { + Some(first) if !extensions.iter().any(|e| name.ends_with(&format!(".{e}"))) => format!("{path}.{first}"), + _ => path.to_string(), + } +} + +/// `document.exportFile(file, exportType, options?)`: `document.export` of one file, which leaves +/// the document's path as it is. +fn doc_export_file(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + let path = file_path(arg(a, 1), "exportFile")?; + let kind = export_kind(arg(a, 2))?; + // Without options, an export takes the defaults a new options object of its class holds. + let mut p = match given(arg(a, 3)).filter(|d| !matches!(d, Data::Null)) { + None => match kind.options { + Some(class) => options_params(class, &fresh(class))?, + None => Map::new(), + }, + Some(o) => match kind.options { + Some(class) => options_params(class, o)?, + None => return Err(HostError::Error(format!("options for {} are not available yet", kind.format))), + }, + }; + let svgz = p.remove("_svgz").and_then(|v| v.as_bool()).unwrap_or(false); + let clip = p.remove("_clip").and_then(|v| v.as_bool()).unwrap_or(false); + let (hs, vs) = (p.remove("_h").and_then(|v| v.as_f64()).unwrap_or(100.0), p.remove("_v").and_then(|v| v.as_f64()).unwrap_or(100.0)); + if (hs - vs).abs() > 1e-9 { + return Err(HostError::Error("different horizontalScale and verticalScale are not available yet".into())); + } + // A raster file has one pixel per point at 100%, whatever the document's raster effects resolution. + if kind.format != "svg" { + p.insert("scale".into(), json!(hs / 100.0)); + } + let format = if svgz { "svgz" } else { kind.format }; + p.insert("format".into(), json!(format)); + if kind.format == "svg" { + p.insert("useArtboards".into(), json!(false)); + } else if clip { + let artboard = super::with_doc(h, doc, |_, st| super::active_artboard(st)); + p.insert("artboard".into(), json!(artboard)); + } else { + p.insert("useArtboards".into(), json!(false)); + } + let named = with_extension(path, &kind, svgz); + let real = h.disk.borrow().save_target(&named).map_err(|m| refused(m, &named))?; + p.insert("path".into(), json!(plain(real))); + exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "document.export", &Value::Object(p))))?; + Ok(Data::Undefined) +} + +/// `app.open(file, documentColorSpace?, options?)`: `document.open` of the file, which becomes +/// the active document. → the document. +fn app_open(h: &Host, a: &[Data]) -> Answer { + let path = file_path(arg(a, 1), "open")?; + let mut p = Map::new(); + if let Some(d) = given(arg(a, 2)).filter(|d| !matches!(d, Data::Null)) { + let mode = if member(d, "DocumentColorSpace", &["CMYK", "RGB"], "documentColorSpace")? == "RGB" { "rgb" } else { "cmyk" }; + p.insert("colorMode".into(), json!(mode)); + } + if let Some(o) = given(arg(a, 3)).filter(|d| !matches!(d, Data::Null)) { + let Data::Object(items) = o else { return Err(HostError::Type("open's options must be a PDFFileOptions record".into())) }; + if typename(o).is_some_and(|t| t != "PDFFileOptions") { + return Err(HostError::Type("open's options must be a PDFFileOptions record".into())); + } + for (k, v) in items { + match k.as_str() { + "pageToOpen" => { + p.insert("page".into(), json!(whole_in(v, "PDFFileOptions.pageToOpen", 1, 1_000_000)?)); + } + "pDFCropToBox" => { + let boxes = ["PDFARTBOX", "PDFBLEEDBOX", "PDFBOUNDINGBOX", "PDFCROPBOX", "PDFMEDIABOX", "PDFTRIMBOX"]; + let crop = match member(v, "PDFBoxType", &boxes, "PDFFileOptions.pDFCropToBox")? { + "PDFARTBOX" => "art", + "PDFBLEEDBOX" => "bleed", + "PDFBOUNDINGBOX" => "bounding", + "PDFCROPBOX" => "crop", + "PDFMEDIABOX" => "media", + _ => "trim", + }; + p.insert("cropTo".into(), json!(crop)); + } + _ => {} + } + } + } + let real = h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; + p.insert("path".into(), json!(plain(real))); + let r = exactly(h, || command(h, "document.open", &Value::Object(p)))?; + let index = match &r { + Data::Object(items) => items.iter().find_map(|(k, v)| match (k.as_str(), v) { + ("index", Data::Number(n)) => whole(*n).and_then(|i| usize::try_from(i).ok()), + _ => None, + }), + _ => None, + }; + let s = h.session.borrow(); + let st = index.and_then(|i| s.documents().get(i)).or_else(|| s.active()).ok_or_else(|| HostError::Error(NO_ACTIVE_DOCUMENT.into()))?; + Ok(doc_ref(h, st.uid)) +} + +fn app_interaction(h: &Host, _: &[Data]) -> Answer { + Ok(text(if h.dom.save_options.quiet.get() { QUIET } else { DISPLAY })) +} + +fn app_set_interaction(h: &Host, a: &[Data]) -> Answer { + let quiet = member(arg(a, 1), "UserInteractionLevel", &["DISPLAYALERTS", "DONTDISPLAYALERTS"], "userInteractionLevel")? == "DONTDISPLAYALERTS"; + h.dom.save_options.quiet.set(quiet); + Ok(Data::Undefined) +} + +/// The members these add to `Application`. +pub(super) fn application_members(l: &Link) -> Vec<(String, HostMember)> { + named(vec![("open", method(l, app_open)), ("userInteractionLevel", property(l, app_interaction, app_set_interaction))]) +} + +/// The members these add to `Document`. +pub(super) fn document_members(l: &Link) -> Vec<(String, HostMember)> { + named(vec![("saveAs", method(l, doc_save_as)), ("exportFile", method(l, doc_export_file))]) +} + +/// The option classes: each `new Name()` gives a record with its `typename` and the defaults its +/// help page gives for the options mapped here. +pub(super) fn classes(link: &Link) -> Vec { + let all = SAVE_CLASSES.iter().map(|(c, _)| c).chain([&PNG24, &JPEG, &SVG]); + all.map(|c| { + let l = link.clone(); + let f: HostFunction = Rc::new(move |_: Vec| { + current(&l)?.charge_call(64)?; + Ok(fresh(c)) + }); + HostClass { name: c.name.into(), parent: None, members: Vec::new(), index: None, construct: Some(f) } + }) + .collect() +} diff --git a/crates/engine/src/script/files.rs b/crates/engine/src/script/files.rs index c0694bbd81..40b1fe0465 100644 --- a/crates/engine/src/script/files.rs +++ b/crates/engine/src/script/files.rs @@ -115,6 +115,7 @@ pub(crate) const MASK_TOO_COSTLY: &str = "Script folder mask takes too many step pub(crate) const NOT_WRITABLE: &str = "Script file is not open for writing"; pub(crate) const UNENCODABLE: &str = "Script file cannot encode the text"; pub(crate) const WRITE_FAILED: &str = "Script file could not be written"; +pub(crate) const READ_ONLY: &str = "Script file is read-only"; pub(crate) const NOT_EMPTY: &str = "Script folder is not empty"; pub(crate) const NAME_TAKEN: &str = "Script file name is already in use"; pub(crate) const BAD_NAME: &str = "Script file name must be a name without a folder"; @@ -271,6 +272,9 @@ pub(crate) struct Disk { /// when they were last written to the grants file. kept: Vec<(std::path::PathBuf, bool, bool)>, recorded: usize, + /// While set, the gate of a command the script runs leaves out the files of the open documents + /// ([`Disk::gate`]): the command reads and writes only where the script's `File` objects may. + pub(crate) exact: bool, /// The write bits setting `readonly` cleared from each file in this run, by its device and /// inode, which a rename keeps, at most [`MAX_ENTRIES`] files: clearing `readonly` gives them back. #[cfg(unix)] @@ -324,6 +328,7 @@ impl Disk { ran_too_much: setup.engine_code.1, kept: Vec::new(), recorded: 0, + exact: false, #[cfg(unix)] cleared: HashMap::new(), }; @@ -457,6 +462,8 @@ impl Disk { /// The gate for a command the script runs: the places it reads and writes now, and the files of /// the open documents, `documents`. pub(crate) fn gate(&self, documents: Vec) -> crate::file_access::ScriptGate { + // A save, export or open of a `File` the script names reads and writes as its `File` would. + let documents = if self.exact { Vec::new() } else { documents }; crate::file_access::ScriptGate { read: self.scope.clone(), write: self.writes.clone(), documents, also: None } } @@ -676,6 +683,35 @@ impl Disk { } } + /// The real path a save or export of the document to `path` writes, as a `File` opened for + /// writing would write it ([`Disk::target`]), or why it may not: a folder is not a file, and a + /// read-only file is not written over. + pub(crate) fn save_target(&self, path: &str) -> Result { + let real = self.target(path, true)?; + match std::fs::metadata(&real) { + Ok(m) if !m.is_file() => Err(NOT_REGULAR), + Ok(m) if m.permissions().readonly() => Err(READ_ONLY), + _ => Ok(real), + } + } + + /// The real path of the file `path` that opening it as a document reads, as a `File` reads it + /// ([`ScriptScope::locate`]), or why it may not: it is not there, it is not a regular file, or + /// the script may not read it. + pub(crate) fn open_target(&self, path: &str) -> Result { + let p = self.checked(path)?; + let real = match self.scope.locate(p) { + Ok(real) => real, + Err(ScriptRead::Missing) => return Err(NOT_FOUND), + Err(ScriptRead::Refused | ScriptRead::TooLarge) => return Err(ACCESS_DENIED), + Err(ScriptRead::Failed(_)) => return Err(READ_FAILED), + }; + if !real.is_file() { + return Err(NOT_REGULAR); + } + Ok(real) + } + /// Counts `n` more bytes written in the run, which ends past [`MAX_RUN_BYTES`]. fn charge_write(&mut self, n: usize) -> Result<(), HostError> { self.written = self.written.saturating_add(n); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index adcaefd59d..436d74cf75 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -178,6 +178,7 @@ mod script_folder; mod script_include; mod script_io; mod script_run; +mod script_save_open; mod scripts; mod select_effects; mod select_ids_first; diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs new file mode 100644 index 0000000000..809fed0ef8 --- /dev/null +++ b/crates/engine/src/tests/script_save_open.rs @@ -0,0 +1,510 @@ +//! Saving, exporting and opening documents from a script: `Document.saveAs`, `Document.exportFile`, +//! `app.open`, their option classes and `app.userInteractionLevel`, and the file grants each path +//! goes through. + +use std::path::{Path, PathBuf}; + +use serde_json::{Value, json}; + +use crate::*; + +const DENIED: &str = "Script file access denied"; + +/// A fresh folder for test `name`, by its real path, with `main` for the script. +fn folder(name: &str) -> PathBuf { + let base = std::env::temp_dir().join(format!("vc-script-save-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&base); + std::fs::create_dir_all(base.join("main")).unwrap(); + std::fs::create_dir_all(base.join("outside")).unwrap(); + std::fs::canonicalize(&base).unwrap() +} + +/// A session whose scripts keep their data folders in `base/settings/Script Data`. +fn session(base: &Path) -> Session { + let mut s = Session::new(); + s.attach_script_data(base.join("settings/Script Data")); + s +} + +/// Runs `main/main.jsx` in `base` with the text `text` in `s`. +fn run(s: &mut Session, base: &Path, text: &str) -> Result { + let main = base.join("main/main.jsx"); + std::fs::write(&main, text.as_bytes()).unwrap(); + s.execute("script.run", &json!({"path": main.to_string_lossy()})) +} + +fn logged(s: &mut Session, base: &Path, text: &str) -> Value { + run(s, base, text).unwrap_or_else(|e| panic!("{text}: {e}"))["log"].clone() +} + +fn failure(s: &mut Session, base: &Path, text: &str) -> String { + run(s, base, text).map(|r| panic!("{text} ran: {r}")).unwrap_err().to_string() +} + +/// The script's data folder, where it may write. +fn data_folder(s: &mut Session, base: &Path) -> PathBuf { + PathBuf::from(logged(s, base, "vc.log(Folder.userData.fsName);")[0].as_str().unwrap()) +} + +fn quoted(p: &Path) -> String { + serde_json::to_string(&p.to_string_lossy()).unwrap() +} + +#[test] +fn save_as_export_file_and_open_write_and_read_where_the_script_may() { + let base = folder("happy"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}});\n\ + d.saveAs(new File(dir + '/a.svg'));\n\ + var o = new PDFSaveOptions(); vc.log([o.typename, o.compatibility, o.preserveEditability]);\n\ + o.compatibility = PDFCompatibility.ACROBAT7; o.viewAfterSaving = false; o.someOtherName = 3;\n\ + o.colorCompression = 'CompressionQuality.None';\n\ + d.saveAs(new File(dir + '/b.pdf'), o); vc.log(d.name);\n\ + var p = new ExportOptionsPNG24(); p.horizontalScale = p.verticalScale = 200; p.artBoardClipping = true;\n\ + d.exportFile(new File(dir + '/c'), ExportType.PNG24, p);\n\ + d.exportFile(new File(dir + '/e.JPG'), ExportType.JPEG);\n\ + var v = new ExportOptionsSVG(); v.compressed = true; v.coordinatePrecision = 2;\n\ + d.exportFile(new File(dir + '/f'), ExportType.SVG, v); vc.log(d.name);\n\ + var g = app.open(new File(dir + '/a.svg'));\n\ + vc.log([g.typename, app.documents.length, app.activeDocument.name === g.name, g.name]);\n\ + var u = [app.userInteractionLevel]; app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; u.push(app.userInteractionLevel); vc.log(u);" + ), + ); + assert_eq!(out[0], json!(["PDFSaveOptions", "PDFCompatibility.ACROBAT5", true])); + assert_eq!(out[1], json!("b.pdf"), "saveAs gives the document the new file"); + assert_eq!(out[2], json!("b.pdf"), "exportFile leaves the document's file as it is"); + assert_eq!(out[3], json!(["Document", 2, true, "a.svg"])); + assert_eq!(out[4], json!(["UserInteractionLevel.DISPLAYALERTS", "UserInteractionLevel.DONTDISPLAYALERTS"])); + assert!(std::fs::read_to_string(dir.join("a.svg")).unwrap().contains(" = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).filter(|p| *p != central).collect(); + boards.sort(); + assert!(central.is_file() && boards.len() == 2, "the central file and a file per artboard: {boards:?}"); + let board = boards.pop().unwrap(); + std::fs::remove_file(¢ral).unwrap(); + let mut perms = std::fs::metadata(&board).unwrap().permissions(); + perms.set_readonly(true); + std::fs::set_permissions(&board, perms.clone()).unwrap(); + let e = failure(&mut s, &base, &save); + assert!(e.contains(DENIED), "{e}"); + assert!(!central.exists(), "the central file is not written when an artboard's file may not be"); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + std::fs::set_permissions(&board, perms).unwrap(); + let _ = std::fs::remove_dir_all(base); +} + +/// Every path goes through the script's file grants, as a `File` opened for reading or writing. +#[test] +fn save_as_export_file_and_open_refuse_paths_outside_the_grants() { + let base = folder("refused"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + std::fs::write(base.join("outside/secret.svg"), "").unwrap(); + std::fs::write(base.join("settings/Script Grants.json"), "{}").unwrap(); + std::fs::write(dir.join("kept.svg"), "kept").unwrap(); + let mut perms = std::fs::metadata(dir.join("kept.svg")).unwrap().permissions(); + perms.set_readonly(true); + std::fs::set_permissions(dir.join("kept.svg"), perms).unwrap(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let undo = s.active().unwrap().history.undo.len(); + let outside = quoted(&base.join("outside/x.svg")); + let grants = quoted(&base.join("settings/Script Grants.json")); + let kept = quoted(&dir.join("kept.svg")); + let secret = quoted(&base.join("outside/secret.svg")); + let cases = [ + format!("app.activeDocument.saveAs(new File({outside}));"), + format!("app.activeDocument.exportFile(new File({outside}), ExportType.PNG24);"), + format!("app.activeDocument.saveAs(new File({grants}));"), + format!("app.open(new File({secret}));"), + format!("app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; app.activeDocument.saveAs(new File({outside}));"), + ]; + for case in &cases { + let e = failure(&mut s, &base, &format!("Folder.userData; {case}")); + assert!(e.contains(DENIED), "{case}: {e}"); + } + let e = failure(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({kept}));")); + assert!(e.contains("Script file is read-only"), "{e}"); + let e = failure(&mut s, &base, &format!("app.activeDocument.saveAs(new File({}));", quoted(&dir))); + assert!(e.contains("Script file") && !e.contains("ran"), "a folder is not saved over: {e}"); + assert_eq!(std::fs::read_to_string(dir.join("kept.svg")).unwrap(), "kept"); + assert_eq!(std::fs::read_to_string(base.join("settings/Script Grants.json")).unwrap(), "{}"); + assert!(!base.join("outside/x.svg").exists() && !base.join("outside/x.svg.png").exists()); + assert_eq!(s.documents().len(), 1); + assert_eq!(s.active().unwrap().path, None, "a refused save leaves the document's file as it is"); + assert_eq!(s.active().unwrap().history.undo.len(), undo, "and adds no undo step"); + let mut perms = std::fs::metadata(dir.join("kept.svg")).unwrap().permissions(); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + std::fs::set_permissions(dir.join("kept.svg"), perms).unwrap(); + let _ = std::fs::remove_dir_all(base); +} + +/// The file of an open document is not written or read through a script method unless the +/// script's grants take it, though `vc.run`'s commands may use it. +#[test] +fn an_open_documents_file_is_not_saved_over_without_a_grant() { + let base = folder("opendoc"); + let mut s = session(&base); + let path = base.join("outside/open.svg"); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + s.execute("file.saveAs", &json!({"path": path.to_string_lossy()})).unwrap(); + let before = std::fs::read(&path).unwrap(); + let e = failure(&mut s, &base, &format!("app.activeDocument.saveAs(new File({}));", quoted(&path))); + assert!(e.contains(DENIED), "{e}"); + let e = failure(&mut s, &base, &format!("app.activeDocument.exportFile(new File({}), ExportType.SVG);", quoted(&path))); + assert!(e.contains(DENIED), "{e}"); + assert_eq!(std::fs::read(&path).unwrap(), before); + let _ = std::fs::remove_dir_all(base); +} + +/// A file `open` reads besides the one it names, here an SVG's linked image, is read only where +/// the script's grants allow, though it is an open document's file. +#[test] +fn open_reads_linked_files_only_where_the_script_may() { + let base = folder("linked"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let linked = base.join("outside/linked.svg"); + std::fs::write(&linked, "").unwrap(); + s.execute("document.open", &json!({"path": linked.to_string_lossy()})).unwrap(); + assert!(s.active().unwrap().path.is_some(), "the linked file is an open document's file"); + let href = linked.to_string_lossy().replace('\\', "/"); + std::fs::write( + dir.join("page.svg"), + format!(""), + ) + .unwrap(); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&dir.join("page.svg")))); + assert_eq!(s.documents().len(), 2); + let ims = |s: &Session| { + let mut out = vec![]; + s.active().unwrap().doc.walk(|n| { + if let NodeKind::Image(im) = &n.kind { + out.push((im.width, im.height, im.link.as_ref().map(|l| (l.modified.is_some(), l.hash.is_some())))); + } + }); + out + }; + let kinds = |s: &Session| { + let mut out = vec![]; + s.active().unwrap().doc.walk(|n| out.push(format!("{:?}", n.kind).chars().take(12).collect::())); + out + }; + assert_eq!(ims(&s), vec![(64, 64, Some((false, false)))], "the linked file is a placeholder: {:?}", kinds(&s)); + // Opened by the app, a copy of the file reads its image. + std::fs::copy(dir.join("page.svg"), dir.join("copy.svg")).unwrap(); + s.execute("document.open", &json!({"path": dir.join("copy.svg").to_string_lossy()})).unwrap(); + assert!(ims(&s).is_empty() && kinds(&s).iter().any(|k| k.starts_with("Path")), "{:?}", kinds(&s)); + let _ = std::fs::remove_dir_all(base); +} + +/// An SVG export with `embedRasterImages` false writes the document's embedded image beside the +/// SVG, and when that file may not be written, the SVG is not written either. +#[test] +fn an_svg_export_writes_nothing_when_one_of_its_files_is_refused() { + let base = folder("svgimages"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let pic = base.join("outside/pic.png"); + std::fs::write(&pic, super::links::png(2, 2, [10, 200, 30])).unwrap(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + s.execute("file.place", &json!({"path": pic.to_string_lossy(), "link": false})).unwrap(); + let export = + format!("Folder.userData; app.activeDocument.exportFile(new File({}), ExportType.SVG, new ExportOptionsSVG());", quoted(&dir.join("a.svg"))); + logged(&mut s, &base, &export); + let svg = dir.join("a.svg"); + let mut images: Vec = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).filter(|p| *p != svg).collect(); + assert_eq!(images.len(), 1, "the embedded image is written beside the SVG: {images:?}"); + let image = images.remove(0); + std::fs::remove_file(&svg).unwrap(); + let mut perms = std::fs::metadata(&image).unwrap().permissions(); + perms.set_readonly(true); + std::fs::set_permissions(&image, perms.clone()).unwrap(); + let e = failure(&mut s, &base, &export); + assert!(e.contains(DENIED), "{e}"); + assert!(!svg.exists(), "the SVG is not written when its image may not be"); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + std::fs::set_permissions(&image, perms).unwrap(); + let _ = std::fs::remove_dir_all(base); +} + +/// A link inside a granted folder that leads out of it is followed and refused. +#[cfg(unix)] +#[test] +fn a_link_out_of_the_granted_folder_is_refused() { + let base = folder("link"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + std::os::unix::fs::symlink(base.join("outside"), dir.join("away")).unwrap(); + std::os::unix::fs::symlink(base.join("outside/target.svg"), dir.join("file.svg")).unwrap(); + std::fs::write(base.join("outside/read.svg"), "").unwrap(); + std::os::unix::fs::symlink(base.join("outside/read.svg"), dir.join("read.svg")).unwrap(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + for name in ["away/x.svg", "file.svg"] { + let e = failure(&mut s, &base, &format!("app.activeDocument.saveAs(new File({}));", quoted(&dir.join(name)))); + assert!(e.contains(DENIED), "{name}: {e}"); + } + let e = failure(&mut s, &base, &format!("app.open(new File({}));", quoted(&dir.join("read.svg")))); + assert!(e.contains(DENIED), "{e}"); + assert!(std::fs::read_dir(base.join("outside")).unwrap().count() == 1, "nothing is written outside"); + assert_eq!(s.documents().len(), 1); + let _ = std::fs::remove_dir_all(base); +} + +/// Bad arguments throw before anything is written or opened. +#[test] +fn bad_arguments_are_refused_with_an_error() { + let base = folder("bad"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let f = format!("new File({})", quoted(&dir.join("x.svg"))); + let huge = "a".repeat(5000); + let cases: Vec<(String, &str)> = vec![ + ("app.activeDocument.saveAs('x.svg');".into(), "saveAs needs a File"), + (format!("app.activeDocument.saveAs({{'\\u0000fileRef': {}}});", quoted(&dir.join("x.svg"))), "is not plain data"), + (format!("app.activeDocument.saveAs({f}, {{typename: 'Nope'}});"), "saveAs options must be"), + (format!("app.activeDocument.saveAs({f}, new ExportOptionsSVG());"), "saveAs options must be"), + (format!("var o = new IllustratorSaveOptions(); o.compressed = 'yes'; app.activeDocument.saveAs({f}, o);"), "must be true or false"), + ( + format!("var o = new IllustratorSaveOptions(); o.compatibility = Compatibility.ILLUSTRATOR8; app.activeDocument.saveAs({f}, o);"), + "is not available yet", + ), + ( + format!("var o = new PDFSaveOptions(); o.trimMarks = true; app.activeDocument.saveAs({f}, o);"), + "PDFSaveOptions.trimMarks is not available yet", + ), + ( + format!("var o = new PDFSaveOptions(); o.colorCompression = 'Unrelated.None'; app.activeDocument.saveAs({f}, o);"), + "PDFSaveOptions.colorCompression is not available yet", + ), + (format!("var o = new PDFSaveOptions(); o.pDFPreset = '{huge}'; app.activeDocument.saveAs({f}, o);"), "too long"), + (format!("var o = new EPSSaveOptions(); o.postScript = 'LEVEL2'; app.activeDocument.saveAs({f}, o);"), "EPSPostScriptLevelEnum"), + (format!("app.activeDocument.exportFile({f}, 'PNG24');"), "ExportType"), + (format!("app.activeDocument.exportFile({f}, ExportType.FLASH);"), "is not available yet"), + (format!("app.activeDocument.exportFile({f}, ExportType.PNG24, new ExportOptionsJPEG());"), "ExportOptionsPNG24"), + ( + format!( + "var p = new ExportOptionsPNG24(); p.horizontalScale = p.verticalScale = 1e9; app.activeDocument.exportFile({f}, ExportType.PNG24, p);" + ), + "at most", + ), + ( + format!("var p = new ExportOptionsPNG24(); p.horizontalScale = 50; app.activeDocument.exportFile({f}, ExportType.PNG24, p);"), + "not available yet", + ), + ( + format!("var p = new ExportOptionsJPEG(); p.qualitySetting = 101; app.activeDocument.exportFile({f}, ExportType.JPEG, p);"), + "from 0 to 100", + ), + (format!("app.activeDocument.exportFile({f}, ExportType.GIF, {{}});"), "not available yet"), + (format!("app.open({f}, 'RGB');"), "DocumentColorSpace"), + (format!("app.open({f}, undefined, {{pageToOpen: 0}});"), "from 1"), + (format!("app.open({f}, undefined, {{pDFCropToBox: 'art'}});"), "PDFBoxType"), + (format!("app.open({f}, undefined, 5);"), "PDFFileOptions"), + ("app.userInteractionLevel = 'quiet';".into(), "UserInteractionLevel"), + (format!("app.open({});", quoted(&dir.join("x.svg"))), "open needs a File"), + ]; + for (case, wanted) in &cases { + let e = failure(&mut s, &base, &format!("Folder.userData; {case}")); + assert!(e.contains(wanted), "{case}: {e}"); + } + let e = failure(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&dir.join("missing.svg")))); + assert!(e.contains(crate::script::files::NOT_FOUND), "{e}"); + assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 0, "nothing was written"); + assert_eq!(s.documents().len(), 1); + assert_eq!(s.active().unwrap().path, None); + let _ = std::fs::remove_dir_all(base); +} + +/// Only a `File` the `File` class made names a file. An object made from `File.prototype` and a +/// plain object throw a `TypeError`, and a `File` whose hidden path property a script set keeps its +/// own path, so nothing is written or opened at the path the script put there. +#[test] +fn a_forged_file_is_refused() { + let base = folder("forged"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + std::fs::write(dir.join("real.svg"), "").unwrap(); + std::fs::write(base.join("outside/secret.svg"), "").unwrap(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let (x, real) = (quoted(&dir.join("x.svg")), quoted(&dir.join("real.svg"))); + let (out, secret) = (quoted(&base.join("outside/x.svg")), quoted(&base.join("outside/secret.svg"))); + let calls = |f: &str, read: &str| { + [format!("app.activeDocument.saveAs({f});"), format!("app.activeDocument.exportFile({f}, ExportType.SVG);"), format!("app.open({read});")] + }; + for made in ["Object.create(File.prototype)", "{}"] { + let make = |p: &str| format!("(function () {{ var f = {made}; f.__vcPath = {p}; return f; }})()"); + for case in calls(&make(&x), &make(&real)) { + let text = format!("Folder.userData; try {{ {case} vc.log('ran'); }} catch (e) {{ vc.log([e.name, e.message]); }}"); + let log = logged(&mut s, &base, &text); + assert_eq!(log[0][0], json!("TypeError"), "{case}: {log}"); + assert!(log[0][1].as_str().unwrap().contains("needs a File"), "{case}: {log}"); + } + } + let moved = |from: &str, to: &str| format!("(function () {{ var f = new File({from}); f.__vcPath = {to}; return f; }})()"); + for case in calls(&moved(&out, &x), &moved(&secret, &real)) { + let e = failure(&mut s, &base, &format!("Folder.userData; {case}")); + assert!(e.contains(DENIED), "{case}: {e}"); + } + assert!(!dir.join("x.svg").exists() && !dir.join("x.svg.svg").exists(), "nothing is written at the forged path"); + assert!(std::fs::read_dir(base.join("outside")).unwrap().count() == 1); + assert_eq!(s.documents().len(), 1, "nothing is opened"); + assert_eq!(s.active().unwrap().path, None); + let _ = std::fs::remove_dir_all(base); +} + +/// A document from an earlier run is stale, and saving it throws. +#[test] +fn a_stale_document_is_not_saved() { + let base = folder("stale"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + run(&mut s, &base, "#targetengine keep\nvar held = app.activeDocument;").unwrap(); + let e = failure(&mut s, &base, &format!("#targetengine keep\nFolder.userData; held.saveAs(new File({}));", quoted(&dir.join("x.svg")))); + assert!(e.contains("Stale document"), "{e}"); + assert!(!dir.join("x.svg").exists()); + let _ = std::fs::remove_dir_all(base); +} + +/// `open` applies the page and crop box of its options to a PDF. +#[test] +fn open_takes_the_page_and_crop_box_of_its_options() { + let base = folder("pdf"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap(); + let pdf = dir.join("two.pdf"); + s.execute("file.saveAs", &json!({"path": pdf.to_string_lossy(), "format": "pdf"})).unwrap(); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var g = app.open(new File({}), DocumentColorSpace.CMYK, {{pageToOpen: 2, pDFCropToBox: PDFBoxType.PDFMEDIABOX}});\n\ + vc.log(g.documentColorSpace);", + quoted(&pdf) + ), + ); + assert_eq!(out, json!(["DocumentColorSpace.CMYK"])); + let e = failure(&mut s, &base, &format!("Folder.userData; app.open(new File({}), undefined, {{pageToOpen: 3}});", quoted(&pdf))); + assert!(!e.is_empty(), "a page the file does not have"); + assert_eq!(s.documents().len(), 2); + assert_eq!(s.active().unwrap().doc.artboards.len(), 1, "one page"); + let _ = std::fs::remove_dir_all(base); +} diff --git a/crates/js/src/file_classes.rs b/crates/js/src/file_classes.rs index c962bf9679..e46fd9f77d 100644 --- a/crates/js/src/file_classes.rs +++ b/crates/js/src/file_classes.rs @@ -7,8 +7,10 @@ //! `File` and `new Folder(path)` always a `Folder`, while `File(path)` gives a `Folder` when the //! host's `stat` says the path is a folder, and `Folder(path)` a `File` when it is a file. Two //! objects for one path are different objects. An object keeps its path in the host's platform -//! form, its `error` text, the id of the file it has open (or -1), the encoding set before `open` -//! and its line feed, in properties that are not enumerable; every name the getters give comes from +//! form in an internal slot that only the classes' own methods set ([`Class::FsEntry`]), so an +//! object a script makes with `Object.create(File.prototype)` is not a `File`. It keeps its `error` +//! text, the id of the file it has open (or -1), the encoding set before `open` and its line feed +//! in properties that are not enumerable; every name the getters give comes from //! the host's `parse` of that path. `Folder.current` is kept in the realm and starts at the host's //! `current`. //! @@ -47,7 +49,57 @@ impl Classes { } } -const PATH: &str = "__vcPath"; +/// The one key of the [`crate::Data`] object that stands for a `File` given to a member of a host +/// class ([`crate::HostClass`]), with the file's path in the host's platform form as its value. A +/// plain object a script made that carries the key is refused. +pub const FILE_REF_KEY: &str = "\u{0}fileRef"; + +/// The path of the `File` that `d` stands for ([`FILE_REF_KEY`]). +pub fn file_ref_path(d: &crate::Data) -> Option<&str> { + let crate::Data::Object(items) = d else { return None }; + match items.as_slice() { + [(k, crate::Data::String(path))] if k == FILE_REF_KEY => Some(path), + _ => None, + } +} + +impl Interp { + /// The [`crate::Data`] for `id` when it is a `File` the `File` class made (its prototype is + /// `File.prototype` and it holds its path in its [`Class::FsEntry`]), as [`file_ref_path`] reads + /// it; `None` for any other object, one made with `Object.create(File.prototype)` included. + pub(crate) fn file_ref_of(&self, id: ObjId) -> JsResult> { + let Some(c) = &self.files else { return Ok(None) }; + let o = self.object(id)?; + if o.proto != Some(c.file_proto) { + return Ok(None); + } + Ok(match &o.class { + Class::FsEntry(s) => Some(crate::Data::Object(vec![(FILE_REF_KEY.to_string(), crate::Data::String(s.to_rust_string()))])), + _ => None, + }) + } +} + +/// The path of `o` when the `File` or `Folder` class made it. +fn own_path(i: &Interp, o: ObjId) -> JsResult> { + Ok(match &i.object(o)?.class { + Class::FsEntry(s) => Some(Value::String(s.clone())), + _ => None, + }) +} + +/// Sets the path of the `File` or `Folder` `o` to `fs`, a path the host gave. +fn set_path(i: &mut Interp, o: ObjId, fs: Value) -> JsResult<()> { + let Value::String(s) = fs else { return Err(i.type_error("File: the host gave no path")) }; + i.rooted(&[Value::Object(o), Value::String(s.clone())], |i| i.reserve_heap(string_bytes(s.len())))?; + if let Some(ob) = i.heap.object_mut(o) + && let Class::FsEntry(path) = &mut ob.class + { + *path = s; + } + Ok(()) +} + const ERROR: &str = "__vcError"; const HANDLE: &str = "__vcHandle"; const RUN: &str = "__vcRun"; @@ -103,7 +155,7 @@ fn set_slot(i: &mut Interp, o: ObjId, name: &str, value: Value) -> JsResult<()> /// `Folder`. fn this_path(i: &mut Interp, this: &Value, what: &str) -> JsResult<(ObjId, Value)> { if let Some(o) = this.as_object() - && let path @ Value::String(_) = slot(i, o, PATH)? + && let Some(path) = own_path(i, o)? { return Ok((o, path)); } @@ -114,7 +166,7 @@ fn this_path(i: &mut Interp, this: &Value, what: &str) -> JsResult<(ObjId, Value /// `Folder`, or `String(x)`, which may hold URI escapes. fn path_text(i: &mut Interp, x: &Value) -> JsResult<(Value, bool)> { if let Some(o) = x.as_object() - && let path @ Value::String(_) = slot(i, o, PATH)? + && let Some(path) = own_path(i, o)? { return Ok((path, true)); } @@ -143,12 +195,12 @@ fn parsed(i: &mut Interp, this: &Value, what: &str, name: &str) -> JsResult JsResult { + let Value::String(path) = fs.clone() else { return Err(i.type_error("File: the host gave no path")) }; let line_feed = host_value(i, "lineFeed")?; - i.rooted(&[fs.clone(), line_feed.clone()], |i| { - i.reserve_heap(OBJECT_BYTES + 6 * PROP_BYTES)?; - let o = i.heap.alloc_object(Object::new(Class::Ordinary, Some(proto))); + i.rooted(&[fs, line_feed.clone()], |i| { + i.reserve_heap(OBJECT_BYTES + 5 * PROP_BYTES + string_bytes(path.len()))?; + let o = i.heap.alloc_object(Object::new(Class::FsEntry(path.clone()), Some(proto))); i.rooted(&[Value::Object(o)], |i| { - set_slot(i, o, PATH, fs.clone())?; set_slot(i, o, ERROR, Value::str(""))?; set_slot(i, o, HANDLE, Value::Number(-1.0))?; set_slot(i, o, RUN, Value::Number(-1.0))?; @@ -393,7 +445,7 @@ fn change_path(i: &mut Interp, this: Value, args: &[Value], _: bool) -> JsResult } let p = parse(i, &arg(args, 0))?; let fs = i.rooted(std::slice::from_ref(&p), |i| field(i, &p, "fs"))?; - set_slot(i, o, PATH, fs)?; + set_path(i, o, fs)?; Ok(Value::Bool(true)) } @@ -482,7 +534,7 @@ fn rename(i: &mut Interp, this: Value, args: &[Value], _: bool) -> JsResult JsResult), /// An object of a class a host defined ([`crate::host_classes`]). Host(crate::host_classes::HostObj), + /// A `File` or `Folder` ([`crate::file_classes`]) and its path in the host's platform form, + /// which only the classes' own methods set. + FsEntry(Str), } /// What an XML value is. @@ -314,7 +317,7 @@ impl Class { Class::XmlFilter(_) => "Object", Class::Math => "Math", Class::Json => "JSON", - Class::Ordinary | Class::ForIn(_) | Class::Host(_) => "Object", + Class::Ordinary | Class::ForIn(_) | Class::Host(_) | Class::FsEntry(_) => "Object", Class::Array { .. } => "Array", Class::Function(_) => "Function", Class::Error(_) => "Error", @@ -648,7 +651,7 @@ fn trace_object(o: &Object, work: &mut Vec, strings: &mut StringSizes) -> u extra = BOUND_ARG_BYTES * args.len(); } Class::Arguments(map) => work.push(map.env.0), - Class::String(s) => strings.add(s), + Class::String(s) | Class::FsEntry(s) => strings.add(s), Class::RegExp(re) => { if strings.seen.insert(Rc::as_ptr(re) as *const () as usize) { strings.bytes += re.heap_bytes(); diff --git a/crates/js/src/host.rs b/crates/js/src/host.rs index f34c9cff8e..a639dbd0cb 100644 --- a/crates/js/src/host.rs +++ b/crates/js/src/host.rs @@ -261,13 +261,21 @@ impl Interp { if r.ancestors.len() >= r.limits.depth { return Err(self.data_error(r, ErrorType::Range, "is nested too deep")); } + // A `File` reads as its path ([`crate::FILE_REF_KEY`]). + if r.hosted + && let Some(file) = self.file_ref_of(id)? + { + let len = crate::file_ref_path(&file).map_or(0, str::len); + self.charge_reading(r, len.saturating_mul(3).saturating_add(2))?; + return Ok(file); + } let shape = match &self.object(id)?.class { Class::Host(_) if r.hosted => { return self.host_ref_of(id)?.ok_or_else(|| Abrupt::Internal("host object without a class".into())); } Class::Host(_) => return Err(self.data_error(r, ErrorType::Type, "is an object of a host class, not plain data")), Class::Array { length, .. } => Shape::Array(*length), - Class::Ordinary => { + Class::Ordinary | Class::FsEntry(_) => { let o = self.object(id)?; if o.props.len() > r.limits.entries { return Err(self.data_error(r, ErrorType::Range, "has too many entries")); @@ -313,7 +321,7 @@ impl Interp { self.use_fuel()?; self.charge_reading(r, k.len().saturating_mul(3).saturating_add(8))?; let name = String::from_utf16_lossy(&k); - if r.hosted && name == crate::HOST_REF_KEY { + if r.hosted && (name == crate::HOST_REF_KEY || name == crate::FILE_REF_KEY) { return Err(self.data_error(r, ErrorType::Type, "is not plain data")); } r.path.push(Step::Name(k)); diff --git a/crates/js/src/lib.rs b/crates/js/src/lib.rs index 1d7af9e4fb..45f6aa61e4 100644 --- a/crates/js/src/lib.rs +++ b/crates/js/src/lib.rs @@ -81,6 +81,7 @@ pub use ast::{ }; pub use builtins::extensions::Localization; pub use error::{SyntaxError, TOO_DEEP, TOO_LONG}; +pub use file_classes::{FILE_REF_KEY, file_ref_path}; pub use host::{Arg, CallSite, Data, DataLimits, HostError, HostFunction, HostItem, ScriptItem, SiteFunction}; pub use host_classes::{HOST_REF_KEY, HostClass, HostMember, host_ref, host_ref_parts}; pub use lexer::{Goal, Lexer}; diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index e4271f7926..5e020a2116 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6607,6 +6607,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file could not be written No s’ha pogut escriure el fitxer de l’script @msg Script file dialogs need a person to answer them Els diàlegs de fitxers de l’script necessiten una persona que els respongui @msg Script file is not open for writing El fitxer de l’script no està obert per escriure-hi +@msg Script file is read-only El fitxer de l’script és només de lectura @msg Script file name is already in use El nom del fitxer de l’script ja està en ús @msg Script file name must be a name without a folder El nom del fitxer de l’script ha de ser un nom sense carpeta @msg Script file permission can be kept only for a script run from a file El permís de fitxers només es pot conservar per a un script executat des d’un fitxer diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 488df173c3..a0ae87170c 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5392,6 +5392,7 @@ liquify-list-end {0}, {1} {0} a {1} @msg Script file could not be written Soubor skriptu nelze zapsat @msg Script file dialogs need a person to answer them Dialogy souborů skriptu potřebují osobu, která na ně odpoví @msg Script file is not open for writing Soubor skriptu není otevřený pro zápis +@msg Script file is read-only Soubor skriptu je jen pro čtení @msg Script file name is already in use Název souboru skriptu se už používá @msg Script file name must be a name without a folder Název souboru skriptu musí být název bez složky @msg Script file permission can be kept only for a script run from a file Oprávnění k souborům lze zachovat jen pro skript spuštěný ze souboru diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 302ab6aa69..a068797076 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -87,6 +87,7 @@ @msg Script file could not be written Scriptfilen kunne ikke skrives @msg Script file dialogs need a person to answer them Scriptets fildialoger skal besvares af en person @msg Script file is not open for writing Scriptfilen er ikke åben for skrivning +@msg Script file is read-only Scriptfilen er skrivebeskyttet @msg Script file name is already in use Scriptfilens navn er allerede i brug @msg Script file name must be a name without a folder Scriptfilens navn skal være et navn uden en mappe @msg Script file permission can be kept only for a script run from a file Filtilladelsen kan kun beholdes for et script, der køres fra en fil diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9482345f18..ad2653ea36 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4968,6 +4968,7 @@ liquify-list-end {0}, {1} {0} und {1} @msg Script file could not be written Skriptdatei konnte nicht geschrieben werden @msg Script file dialogs need a person to answer them Dateidialoge von Skripten brauchen eine Person, die sie beantwortet @msg Script file is not open for writing Skriptdatei ist nicht zum Schreiben geöffnet +@msg Script file is read-only Skriptdatei ist schreibgeschützt @msg Script file name is already in use Name der Skriptdatei wird bereits verwendet @msg Script file name must be a name without a folder Name der Skriptdatei muss ein Name ohne Ordner sein @msg Script file permission can be kept only for a script run from a file Dateiberechtigung kann nur für ein Skript behalten werden, das aus einer Datei ausgeführt wird diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 434d0cc0b8..3ead7c9a10 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2805,6 +2805,7 @@ liquify-list-end {0}, {1} {0} και {1} @msg Script file could not be written Δεν ήταν δυνατή η εγγραφή του αρχείου του σεναρίου @msg Script file dialogs need a person to answer them Τα παράθυρα διαλόγου αρχείων του σεναρίου χρειάζονται ένα άτομο για να απαντήσει @msg Script file is not open for writing Το αρχείο του σεναρίου δεν είναι ανοιχτό για εγγραφή +@msg Script file is read-only Το αρχείο του σεναρίου είναι μόνο για ανάγνωση @msg Script file name is already in use Το όνομα του αρχείου του σεναρίου χρησιμοποιείται ήδη @msg Script file name must be a name without a folder Το όνομα του αρχείου του σεναρίου πρέπει να είναι όνομα χωρίς φάκελο @msg Script file permission can be kept only for a script run from a file Η άδεια αρχείων μπορεί να διατηρηθεί μόνο για σενάριο που εκτελείται από αρχείο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3f83e928e4..8003e265c2 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5079,6 +5079,7 @@ liquify-list-end {0}, {1} {0}, {1} @msg Script file could not be written No se pudo escribir el archivo del script @msg Script file dialogs need a person to answer them Los cuadros de diálogo de archivo del script necesitan que una persona los responda @msg Script file is not open for writing El archivo del script no está abierto para escritura +@msg Script file is read-only El archivo del script es de solo lectura @msg Script file name is already in use El nombre del archivo del script ya está en uso @msg Script file name must be a name without a folder El nombre del archivo del script debe ser un nombre sin carpeta @msg Script file permission can be kept only for a script run from a file El permiso de archivos solo se puede conservar para un script ejecutado desde un archivo diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a4d85b23e8..d8933598d0 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5320,6 +5320,7 @@ liquify-list-end {0}, {1} {0} ja {1} @msg Script file could not be written Komentosarjan tiedostoa ei voitu kirjoittaa @msg Script file dialogs need a person to answer them Komentosarjan tiedostovalintaikkunoihin tarvitaan vastaava henkilö @msg Script file is not open for writing Komentosarjan tiedosto ei ole auki kirjoittamista varten +@msg Script file is read-only Komentosarjan tiedosto on vain luku -tilassa @msg Script file name is already in use Komentosarjan tiedoston nimi on jo käytössä @msg Script file name must be a name without a folder Komentosarjan tiedoston nimen on oltava nimi ilman kansiota @msg Script file permission can be kept only for a script run from a file Tiedostolupa voidaan säilyttää vain tiedostosta suoritetulle komentosarjalle diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8f56486157..70e88ea0de 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5038,6 +5038,7 @@ liquify-list-end {0}, {1} {0} et {1} @msg Script file could not be written Le fichier du script n’a pas pu être écrit @msg Script file dialogs need a person to answer them Les boîtes de dialogue de fichiers du script ont besoin d’une personne pour y répondre @msg Script file is not open for writing Le fichier du script n’est pas ouvert en écriture +@msg Script file is read-only Le fichier du script est en lecture seule @msg Script file name is already in use Le nom du fichier du script est déjà utilisé @msg Script file name must be a name without a folder Le nom du fichier du script doit être un nom sans dossier @msg Script file permission can be kept only for a script run from a file L’autorisation d’accès aux fichiers ne peut être conservée que pour un script exécuté depuis un fichier diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index e9509d9202..d12d3d8a3b 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7754,6 +7754,7 @@ liquify-list-end {0}, {1} {0} और {1} @msg Script file could not be written स्क्रिप्ट फ़ाइल लिखी नहीं जा सकी @msg Script file dialogs need a person to answer them स्क्रिप्ट के फ़ाइल डायलॉग को उत्तर देने के लिए किसी व्यक्ति की ज़रूरत है @msg Script file is not open for writing स्क्रिप्ट फ़ाइल लिखने के लिए खुली नहीं है +@msg Script file is read-only स्क्रिप्ट फ़ाइल केवल पढ़ने के लिए है @msg Script file name is already in use स्क्रिप्ट फ़ाइल का नाम पहले से उपयोग में है @msg Script file name must be a name without a folder स्क्रिप्ट फ़ाइल का नाम बिना फ़ोल्डर वाला नाम होना चाहिए @msg Script file permission can be kept only for a script run from a file फ़ाइल अनुमति केवल फ़ाइल से चलाई गई स्क्रिप्ट के लिए रखी जा सकती है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 87f050ef0d..51a731132b 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5910,6 +5910,7 @@ liquify-list-end {0}, {1} {0} és {1} @msg Script file could not be written A parancsfájl fájlját nem sikerült írni @msg Script file dialogs need a person to answer them A parancsfájl fájlpárbeszédpaneleire egy személynek kell válaszolnia @msg Script file is not open for writing A parancsfájl fájlja nincs írásra megnyitva +@msg Script file is read-only A parancsfájl fájlja csak olvasható @msg Script file name is already in use A parancsfájl fájljának neve már használatban van @msg Script file name must be a name without a folder A parancsfájl fájljának neve mappa nélküli név kell legyen @msg Script file permission can be kept only for a script run from a file A fájlengedély csak fájlból futtatott parancsfájlnál tartható meg diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 924d3d80b5..7e041bfecb 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -8748,6 +8748,7 @@ breakText Glyphs Glif @msg Script file could not be written File skrip tidak dapat ditulis @msg Script file dialogs need a person to answer them Dialog file skrip memerlukan orang untuk menjawabnya @msg Script file is not open for writing File skrip tidak dibuka untuk ditulis +@msg Script file is read-only File skrip hanya dapat dibaca @msg Script file name is already in use Nama file skrip sudah digunakan @msg Script file name must be a name without a folder Nama file skrip harus berupa nama tanpa folder @msg Script file permission can be kept only for a script run from a file Izin file skrip hanya dapat disimpan untuk skrip yang dijalankan dari file diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 5f47e3f117..cc67a9be3a 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5106,6 +5106,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file could not be written Impossibile scrivere il file dello script @msg Script file dialogs need a person to answer them Le finestre di dialogo dei file dello script richiedono una persona che risponda @msg Script file is not open for writing Il file dello script non è aperto in scrittura +@msg Script file is read-only Il file dello script è di sola lettura @msg Script file name is already in use Il nome del file dello script è già in uso @msg Script file name must be a name without a folder Il nome del file dello script deve essere un nome senza cartella @msg Script file permission can be kept only for a script run from a file Il permesso sui file può essere mantenuto solo per uno script eseguito da un file diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 9a1b5f6354..2bd2dad0b2 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5941,6 +5941,7 @@ liquify-list-end {0}, {1} {0}、{1} @msg Script file could not be written スクリプトのファイルを書き込めませんでした @msg Script file dialogs need a person to answer them スクリプトのファイルダイアログには応答する人が必要です @msg Script file is not open for writing スクリプトのファイルが書き込み用に開かれていません +@msg Script file is read-only スクリプトのファイルは読み取り専用です @msg Script file name is already in use スクリプトのファイル名はすでに使用されています @msg Script file name must be a name without a folder スクリプトのファイル名はフォルダーを含まない名前にしてください @msg Script file permission can be kept only for a script run from a file ファイルの許可を保持できるのは、ファイルから実行したスクリプトだけです diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8eeacee621..6625e82912 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -8602,6 +8602,7 @@ liquify-list-end {0}, {1} {0} და {1} @msg Script file could not be written სკრიპტის ფაილის ჩაწერა ვერ მოხერხდა @msg Script file dialogs need a person to answer them სკრიპტის ფაილის დიალოგებს სჭირდება ადამიანი, რომელიც უპასუხებს @msg Script file is not open for writing სკრიპტის ფაილი ჩასაწერად გახსნილი არ არის +@msg Script file is read-only სკრიპტის ფაილი მხოლოდ წასაკითხია @msg Script file name is already in use სკრიპტის ფაილის სახელი უკვე გამოიყენება @msg Script file name must be a name without a folder სკრიპტის ფაილის სახელი უნდა იყოს სახელი საქაღალდის გარეშე @msg Script file permission can be kept only for a script run from a file ფაილების ნებართვის შენახვა შესაძლებელია მხოლოდ ფაილიდან გაშვებული სკრიპტისთვის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 57e0b8be10..6cc76d1ef5 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5870,6 +5870,7 @@ liquify-list-end {0}, {1} {0} 및 {1} @msg Script file could not be written 스크립트 파일을 쓸 수 없습니다 @msg Script file dialogs need a person to answer them 스크립트 파일 대화 상자에는 응답할 사람이 필요합니다 @msg Script file is not open for writing 스크립트 파일이 쓰기용으로 열려 있지 않습니다 +@msg Script file is read-only 스크립트 파일이 읽기 전용입니다 @msg Script file name is already in use 스크립트 파일 이름이 이미 사용 중입니다 @msg Script file name must be a name without a folder 스크립트 파일 이름은 폴더 없는 이름이어야 합니다 @msg Script file permission can be kept only for a script run from a file 파일 권한은 파일에서 실행한 스크립트에만 유지할 수 있습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 5ed5cdc3e0..9cec4dc19c 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -89,6 +89,7 @@ @msg Script file could not be written Het scriptbestand kon niet worden geschreven @msg Script file dialogs need a person to answer them Dialoogvensters voor scriptbestanden moeten door een persoon worden beantwoord @msg Script file is not open for writing Het scriptbestand is niet geopend voor schrijven +@msg Script file is read-only Het scriptbestand is alleen-lezen @msg Script file name is already in use De naam van het scriptbestand is al in gebruik @msg Script file name must be a name without a folder De naam van het scriptbestand moet een naam zonder map zijn @msg Script file permission can be kept only for a script run from a file Toestemming voor scriptbestanden kan alleen worden bewaard voor een script dat vanuit een bestand wordt uitgevoerd diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 74029133dc..82f4003b2e 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5211,6 +5211,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file could not be written Nie można zapisać pliku skryptu @msg Script file dialogs need a person to answer them Okna dialogowe plików skryptu wymagają osoby, która na nie odpowie @msg Script file is not open for writing Plik skryptu nie jest otwarty do zapisu +@msg Script file is read-only Plik skryptu jest tylko do odczytu @msg Script file name is already in use Nazwa pliku skryptu jest już używana @msg Script file name must be a name without a folder Nazwa pliku skryptu musi być nazwą bez folderu @msg Script file permission can be kept only for a script run from a file Uprawnienie do plików można zachować tylko dla skryptu uruchomionego z pliku diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index a1747af0b2..99e822eb99 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -6250,6 +6250,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file could not be written Não foi possível gravar o arquivo do script @msg Script file dialogs need a person to answer them As caixas de diálogo de arquivo do script precisam de uma pessoa para respondê-las @msg Script file is not open for writing O arquivo do script não está aberto para gravação +@msg Script file is read-only O arquivo do script é somente leitura @msg Script file name is already in use O nome do arquivo do script já está em uso @msg Script file name must be a name without a folder O nome do arquivo do script deve ser um nome sem pasta @msg Script file permission can be kept only for a script run from a file A permissão de arquivos só pode ser mantida para um script executado a partir de um arquivo diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ca0c8d5145..132428a948 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5101,6 +5101,7 @@ liquify-list-end {0}, {1} {0} и {1} @msg Script file could not be written Не удалось записать файл скрипта @msg Script file dialogs need a person to answer them Для ответа на файловые диалоги скрипта нужен человек @msg Script file is not open for writing Файл скрипта не открыт для записи +@msg Script file is read-only Файл скрипта доступен только для чтения @msg Script file name is already in use Имя файла скрипта уже используется @msg Script file name must be a name without a folder Имя файла скрипта должно быть именем без папки @msg Script file permission can be kept only for a script run from a file Разрешение на файлы можно сохранить только для скрипта, запущенного из файла diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index c26474cf93..3398eaf74f 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4977,6 +4977,7 @@ liquify-list-end {0}, {1} {0} och {1} @msg Script file could not be written Skriptets fil kunde inte skrivas @msg Script file dialogs need a person to answer them Skriptets fildialoger behöver en person som svarar på dem @msg Script file is not open for writing Skriptets fil är inte öppen för skrivning +@msg Script file is read-only Skriptets fil är skrivskyddad @msg Script file name is already in use Namnet på skriptets fil används redan @msg Script file name must be a name without a folder Namnet på skriptets fil måste vara ett namn utan mapp @msg Script file permission can be kept only for a script run from a file Filbehörighet kan bara behållas för ett skript som körs från en fil diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 82186ebcdd..b70ea0e97e 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4813,6 +4813,7 @@ liquify-list-end {0}, {1} {0} ve {1} @msg Script file could not be written Betiğin dosyası yazılamadı @msg Script file dialogs need a person to answer them Betiğin dosya iletişim kutularının yanıtlanması için bir kişi gerekir @msg Script file is not open for writing Betiğin dosyası yazmak için açık değil +@msg Script file is read-only Betiğin dosyası salt okunur @msg Script file name is already in use Betiğin dosya adı zaten kullanılıyor @msg Script file name must be a name without a folder Betiğin dosya adı klasör içermeyen bir ad olmalıdır @msg Script file permission can be kept only for a script run from a file Dosya izni yalnızca bir dosyadan çalıştırılan betik için saklanabilir diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index de3329ef10..9dabba9916 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5090,6 +5090,7 @@ liquify-list-end {0}, {1} {0} і {1} @msg Script file could not be written Не вдалося записати файл скрипту @msg Script file dialogs need a person to answer them Для відповіді на файлові діалоги скрипту потрібна людина @msg Script file is not open for writing Файл скрипту не відкрито для запису +@msg Script file is read-only Файл скрипту доступний лише для читання @msg Script file name is already in use Ім’я файлу скрипту вже використовується @msg Script file name must be a name without a folder Ім’я файлу скрипту має бути іменем без папки @msg Script file permission can be kept only for a script run from a file Дозвіл на файли можна зберегти лише для скрипту, запущеного з файлу diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 675143a8d6..cc9ec45896 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5600,6 +5600,7 @@ liquify-list-end {0}, {1} {0} và {1} @msg Script file could not be written Không thể ghi tệp của tập lệnh @msg Script file dialogs need a person to answer them Hộp thoại tệp của tập lệnh cần một người trả lời @msg Script file is not open for writing Tệp của tập lệnh chưa được mở để ghi +@msg Script file is read-only Tệp của tập lệnh ở chế độ chỉ đọc @msg Script file name is already in use Tên tệp của tập lệnh đã được sử dụng @msg Script file name must be a name without a folder Tên tệp của tập lệnh phải là một tên không có thư mục @msg Script file permission can be kept only for a script run from a file Chỉ có thể giữ quyền truy cập tệp cho tập lệnh chạy từ một tệp diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 57f6a4403b..11e409f42e 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5597,6 +5597,7 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file could not be written 无法写入脚本的文件 @msg Script file dialogs need a person to answer them 脚本的文件对话框需要有人回答 @msg Script file is not open for writing 脚本的文件未以写入方式打开 +@msg Script file is read-only 脚本的文件为只读 @msg Script file name is already in use 脚本的文件名已被使用 @msg Script file name must be a name without a folder 脚本的文件名必须是不含文件夹的名称 @msg Script file permission can be kept only for a script run from a file 只有从文件运行的脚本才能保留文件权限 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 9834c17ea6..287c85cfeb 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2952,6 +2952,7 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file could not be written 無法寫入指令碼的檔案 @msg Script file dialogs need a person to answer them 指令碼的檔案對話框需要有人回應 @msg Script file is not open for writing 指令碼的檔案未以寫入方式開啟 +@msg Script file is read-only 指令碼的檔案為唯讀 @msg Script file name is already in use 指令碼的檔案名稱已在使用中 @msg Script file name must be a name without a folder 指令碼的檔案名稱必須是不含資料夾的名稱 @msg Script file permission can be kept only for a script run from a file 只有從檔案執行的指令碼才能保留檔案權限 diff --git a/docs/mcp.md b/docs/mcp.md index 9bc2be8efc..3ead9da179 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2680,6 +2680,42 @@ app through the global object `vc`, and writes to the Script Console and runs ot `app.beep`, throw an error that says they are not available yet when they are read or assigned. Other members those pages list, such as `app.version` and `Document.save()`, and the members of the pages of the page-item kinds themselves, such as a path's fill, are not defined yet and read as `undefined`. +- `Document.saveAs(file, options?)` runs `file.saveAs`, and the document then has the new file. + `Document.exportFile(file, exportType, options?)` runs `document.export` and leaves the document's file as it is. + `app.open(file, documentColorSpace?, options?)` runs `document.open` and gives the new `Document` + (https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/). + `file` is a `File`. `new IllustratorSaveOptions()`, `new EPSSaveOptions()` and `new PDFSaveOptions()` pick the + format (https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, + https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/); + without options the path's extension picks it. Without options, `saveAs` to a `.ai`, `.eps` or `.pdf` path and + `exportFile` as `PNG24`, `JPEG` or `SVG` use the defaults a new options object of that class holds. `saveAs` maps `compressed`, `pdfCompatible`, `embedICCProfile` and + `compatibility` (`ILLUSTRATOR17` and `ILLUSTRATOR19`) of `.ai`; `cmykPostScript`, `includeDocumentThumbnails`, + `postScript`, `preview`, `overprint` and `compatibility` of EPS; and `pDFPreset`, `compatibility` (`ACROBAT4` to + `ACROBAT8` as PDF 1.3 to 1.7), `artboardRange`, `preserveEditability`, `acrobatLayers` and `compressArt` of PDF. + `exportType` is an `ExportType`: `PNG24`, `JPEG` and `SVG` take `new ExportOptionsPNG24()`, `new ExportOptionsJPEG()` + and `new ExportOptionsSVG()` (https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, + https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/), + with `antiAliasing`, `artBoardClipping`, `horizontalScale` and `verticalScale` (the same value, more than 0 and at + most 776.19; 100 writes one pixel per point whatever the raster effects resolution), `transparency` (PNG24), `qualitySetting` (0 to 100) and `optimization` (JPEG), and + `coordinatePrecision` (1 to 7), `embedRasterImages`, `compressed`, `preserveEditability` and + `includeVariablesAndDatasets` (SVG); `PNG8`, `GIF` and `TIFF` take no options. `app.open`'s + `options` is a `PDFFileOptions` record (https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/) with + `pageToOpen` and `pDFCropToBox`. `app.userInteractionLevel` is `UserInteractionLevel.DISPLAYALERTS` at the start of + each run. The enumerations `ExportType`, `Compatibility`, `PDFCompatibility`, `PDFBoxType`, `EPSPreview`, + `EPSPostScriptLevelEnum`, `PDFOverprint` and `UserInteractionLevel` hold strings such as `"ExportType.PNG24"`. + VectorCraft's own rules: each path is checked as a `File` opened for reading or writing is checked, before the + command runs. A path outside the script's folders throws `Script file access denied`, also when it is an open + document's file, a link that leads outside them, or the settings folder; a read-only file throws `Script file is + read-only`; and the files a command reads or writes besides the one named, such as an SVG's linked files, are + read and written only where the script's folders allow. `userInteractionLevel` does not change what a command + does or where it may read and write, since a command a script runs never shows a dialog. `exportFile` adds the + format's extension unless the name already ends with it (`.jpg` or `.jpeg`, `.tif` or `.tiff`, `.svgz` with + `compressed`), and writes one file: the active artboard with `artBoardClipping`, otherwise the bounds of the + visible art. An SVG with `embedRasterImages` false also writes the document's embedded images beside it, and + when one of those files may not be written, none of them is. A listed option that is not mapped is accepted at its help page's default, and any other value throws + an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`; properties the help + pages do not list are left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default + keeps the preset's value. A bad value throws an error before anything is written. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. - `$.evalFile(path, timeout?)` runs the file `path` names, relative to the file being run, in the same global diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3b252b56a6..0f5208319d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1025,6 +1025,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. + - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/ and https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ describe, and read and write only where the script's `File` objects may (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From 1548547fc1cc9579cf89bca212c29dbcfa0aaf09 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 14:42:22 -0800 Subject: [PATCH 004/264] Scripts: ask before keeping a run whose last point changes pass the growth allowance Point changes a script leaves waiting are written when its script ends. When that write went past the growth allowance in a run that can ask, the run was kept at once without asking. The run now waits with its script finished: Continue keeps it, and Stop puts every document back as a stopped run does. --- crates/engine/src/script/mod.rs | 69 ++++++++++++++++++++------- crates/engine/src/tests/script_run.rs | 50 ++++++++++++++++++- 2 files changed, 101 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index 37c4b8711d..82d013e076 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -1093,6 +1093,8 @@ struct Job { name: String, /// The file-access scope `script.run` came in, which every slice runs in. scope: crate::file_access::ScopeHandle, + /// The script has ended, and the run waits for the person's growth answer before it is kept. + finished: bool, } /// The `Data` for a JSON value, within `limits`. When it does not fit, the error is the place in @@ -1888,7 +1890,7 @@ impl Session { if h.waiting.replace(false) { h.continues.set(h.continues.get() + 1); h.allowance_objects.set(h.allowance_objects.get().saturating_add(growth_objects())); - h.allowance_bytes.set(h.allowance_bytes.get().saturating_add(GROWTH_BYTES)); + h.allowance_bytes.set(h.allowance_bytes.get().saturating_add(growth_bytes())); } }); } @@ -2026,7 +2028,7 @@ impl Session { bytes_kept: Cell::new(0), bridge: Cell::new(0), allowance_objects: Cell::new(growth_objects()), - allowance_bytes: Cell::new(GROWTH_BYTES), + allowance_bytes: Cell::new(growth_bytes()), continues: Cell::new(0), waiting: Cell::new(false), log: RefCell::new(Vec::new()), @@ -2130,7 +2132,7 @@ impl Session { } let scope = crate::file_access::ScopeHandle::capture(); let (run, line_name) = (host.run, host.name.clone()); - let job = Job { realm, host, link, engine, world: World::working(self), start_uids: open, name: name.clone(), scope }; + let job = Job { realm, host, link, engine, world: World::working(self), start_uids: open, name: name.clone(), scope, finished: false }; let id = NEXT_JOB.fetch_add(1, std::sync::atomic::Ordering::Relaxed); JOBS.with(|jobs| jobs.borrow_mut().insert(id, job)); self.script_key = Some(JobKey { id, run, name: line_name }); @@ -2159,6 +2161,17 @@ impl Session { self.script_key = Some(key); return None; } + // A run whose script ended past its growth allowance is kept once the person lets it go on, + // and put back when they stop it. + if job.finished { + if self.script_stop.is_set() { + let kind = LimitKind::Interrupted; + let e = + RunError { kind: RunErrorKind::Limit(kind), message: format!("limit reached: {kind:?}"), line: 0, column: 0, authored: false }; + return Some(self.script_failed(job, &e)); + } + return Some(self.script_ended(job)); + } // A stop while a dialog waits ends the run there; the interpreter cannot go on from the call. if job.realm.waits() { let kind = LimitKind::Interrupted; @@ -2178,24 +2191,35 @@ impl Session { self.script_key = Some(key); None } - Ok(Ok(Progress::Done(_))) if job.host.dialogs.unused() > 0 => { - let n = job.host.dialogs.unused(); - let kind = LimitKind::Host; - let message = if n == 1 { - format!("`answers` has {n} answer the script did not use") - } else { - format!("`answers` has {n} answers the script did not use") - }; - Some(self.script_failed(job, &RunError { kind: RunErrorKind::Limit(kind), message, line: 0, column: 0, authored: false })) - } - Ok(Ok(Progress::Done(_))) => { - let r = self.script_commit(job); - self.trim_histories(); - Some(r) + // The point changes written as the script ended went past the growth allowance. + Ok(Ok(Progress::Done(_))) if job.host.waiting.get() => { + job.finished = true; + JOBS.with(|jobs| jobs.borrow_mut().insert(key.id, job)); + self.script_key = Some(key); + None } + Ok(Ok(Progress::Done(_))) => Some(self.script_ended(job)), } } + /// Ends the run whose script has ended: it fails when answers it was given went unused, and is + /// kept otherwise. + fn script_ended(&mut self, job: Job) -> Result { + let n = job.host.dialogs.unused(); + if n > 0 { + let kind = LimitKind::Host; + let message = if n == 1 { + format!("`answers` has {n} answer the script did not use") + } else { + format!("`answers` has {n} answers the script did not use") + }; + return self.script_failed(job, &RunError { kind: RunErrorKind::Limit(kind), message, line: 0, column: 0, authored: false }); + } + let r = self.script_commit(job); + self.trim_histories(); + r + } + fn script_failed(&mut self, job: Job, e: &RunError) -> Result { job.host.dialogs.stopped(); job.host.disk.borrow_mut().picker = None; @@ -2531,6 +2555,15 @@ fn growth_objects() -> u64 { GROWTH_OBJECTS } +/// The bytes of new document data a run may keep before it is asked to continue or stop. +fn growth_bytes() -> u64 { + #[cfg(test)] + if let Some(n) = TEST_GROWTH_BYTES.with(Cell::get) { + return n; + } + GROWTH_BYTES +} + /// The limits of a command's result on its way to the script. fn result_limits() -> DataLimits { #[cfg(test)] @@ -2548,6 +2581,8 @@ thread_local! { pub(crate) static PANIC_IN_SLICE: Cell = const { Cell::new(false) }; /// Tests: the objects a run may add in place of [`GROWTH_OBJECTS`]. pub(crate) static TEST_GROWTH: Cell> = const { Cell::new(None) }; + /// Tests: the bytes a run may keep in place of [`GROWTH_BYTES`]. + pub(crate) static TEST_GROWTH_BYTES: Cell> = const { Cell::new(None) }; /// Tests: the heap of a named engine in place of [`ENGINE_HEAP_BYTES`]. pub(crate) static TEST_ENGINE_HEAP: Cell> = const { Cell::new(None) }; /// Tests: the bytes of source maps a named engine keeps, in place of [`KEPT_MAP_BYTES`]. diff --git a/crates/engine/src/tests/script_run.rs b/crates/engine/src/tests/script_run.rs index 02176c38c9..48f4aa02f9 100644 --- a/crates/engine/src/tests/script_run.rs +++ b/crates/engine/src/tests/script_run.rs @@ -5,7 +5,7 @@ use std::cell::Cell; use serde_json::{Value, json}; -use crate::script::{PANIC_IN_SLICE, TEST_GROWTH, TEST_RESULT_BYTES}; +use crate::script::{PANIC_IN_SLICE, TEST_GROWTH, TEST_GROWTH_BYTES, TEST_RESULT_BYTES}; use crate::*; fn rect(x: i64) -> Value { @@ -1020,6 +1020,54 @@ fn a_person_can_let_a_growing_run_go_on_or_stop_it() { assert_eq!(state(&s), before); } +#[test] +fn point_changes_written_as_the_script_ends_wait_for_the_growth_answer() { + // The point change waits in the object model until the script ends. + let source = "app.activeDocument.pathItems[0].pathPoints[0].anchor = [3, -4];"; + let mut s = two_docs(); + let start = s.documents()[1].doc.clone(); + assert_eq!(run(&mut s, source).unwrap()["ok"], true); + let added = start.retained_bytes_each(&s.documents()[1].doc).1 as u64; + assert!(added >= 3, "{added}"); + // The change goes past this allowance and stays within twice it. + TEST_GROWTH_BYTES.with(|g| g.set(Some(added * 2 / 3))); + let run_to_the_question = |s: &mut Session| { + s.script_frames = true; + run(s, source).unwrap(); + for _ in 0..1_000 { + if s.script_waiting() { + break; + } + assert!(s.script_pump().is_none()); + } + assert!(s.script_waiting()); + assert!(s.script_pump().is_none()); + assert!(s.script_running()); + }; + let mut s = two_docs(); + let before = state(&s); + let undo = s.documents()[1].history.undo.len(); + run_to_the_question(&mut s); + assert_eq!(state(&s), before); + s.script_continue(); + assert!(!s.script_waiting()); + let done = s.script_pump().expect("the run ends once it may go on"); + assert_eq!(done.unwrap()["ok"], true); + assert_eq!(s.documents()[1].history.undo.len(), undo + 1); + assert_ne!(state(&s), before); + + let mut s = two_docs(); + let before = state(&s); + run_to_the_question(&mut s); + assert_eq!(s.execute("script.stop", &json!({})).unwrap()["stopped"], true); + let ended = s.script_pump().expect("a stopped run ends"); + TEST_GROWTH_BYTES.with(|g| g.set(None)); + assert!(ended.is_err()); + assert_eq!(s.script_report().unwrap()["kind"], "stopped"); + assert!(!s.script_running()); + assert_eq!(state(&s), before); +} + #[test] fn a_run_waiting_to_grow_stops_at_the_next_slice_once_its_work_is_canceled() { TEST_GROWTH.with(|g| g.set(Some(20))); From 07d673898f156ffa517319b02cb3cc3a97966697 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 15:14:52 -0800 Subject: [PATCH 005/264] Scripts: a path point read before its path's points are removed is stale A PathPoint kept its index, so after `remove()` of an earlier point it read and changed the point that moved into its place. A point read before the script removed a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`) now throws `Stale path point`. --- crates/engine/src/script/dom.rs | 6 +++- crates/engine/src/script/dom/paths.rs | 33 +++++++++++++++++---- crates/engine/src/tests/script_dom_paths.rs | 26 ++++++++++++++++ docs/mcp.md | 4 ++- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 456d9d88b1..2e09f8cb5d 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -89,7 +89,8 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; /// What the object model keeps for one run: its coordinate system, the last list of a document's /// page items, kept while that document is unchanged, the point changes of a path not written yet, -/// and whether a call's own savepoint ([`atomically`]) is open. +/// how many times it removed or replaced each path's points, and whether a call's own savepoint +/// ([`atomically`]) is open. #[derive(Default)] pub(super) struct State { coords: Cell, @@ -99,6 +100,9 @@ pub(super) struct State { /// A path and its subpaths with the point changes the run has made to it and not written yet /// ([`flush`]). pending: RefCell)>>, + /// How many times the run has removed or replaced points of each path, by document uid and + /// path id ([`paths`]). + point_cuts: RefCell>, saving: Cell, } diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 29b0c909be..44c2304b38 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -28,7 +28,9 @@ //! stroke (solid, gradient or pattern), or black when new art has none. `PathPoints.add()` adds //! a corner point with no handles at the last point, or at `[0, 0]` on a path with no points. //! Removing the last points leaves the path, with no points. -//! - A point whose index is past the end of its path throws `Stale path point`. +//! - A point whose index is past the end of its path throws `Stale path point`, and so does a +//! point read before the run removed a point of its path or replaced its points +//! (`PathPoint.remove()`, `PathPoints.removeAll()`, `setEntirePath`). //! - Shape creators take sizes and radii that are finite and not negative; `sides` is a whole //! number from 3 to 1000 and `points` one from 2 to 1000. `inscribed` true throws an error that //! says it is not available yet. `rotateAbout` and `scaleAbout` default to @@ -56,7 +58,8 @@ use super::{ }; use crate::{DocState, NodeId, NodeKind}; -/// The error of a point whose index is past the end of its path. +/// The error of a point whose index is past the end of its path, or that was read before the run +/// removed or replaced points of its path. pub const STALE_POINT: &str = "Stale path point"; /// The most points `setEntirePath` takes. pub const MAX_POINTS: usize = 100_000; @@ -598,6 +601,7 @@ fn path_set_entire(h: &super::Host, a: &[Data]) -> Answer { let anchors: Vec = script.iter().map(|p| Anchor::corner(f.to_document(c, *p))).collect(); let subs = if anchors.is_empty() { Vec::new() } else { vec![SubPath::new(anchors, closed)] }; write_path(h, item, subs)?; + cut_points(h, item); Ok(Data::Undefined) } @@ -1064,7 +1068,20 @@ fn points_parent(h: &super::Host, a: &[Data]) -> Answer { fn point_ref(h: &super::Host, item: Item, i: usize) -> Data { let [high, low] = id_parts(item.id); - host_ref("PathPoint", &[float(h.run), float(item.doc.uid), high, low, float(i as u64)]) + host_ref("PathPoint", &[float(h.run), float(item.doc.uid), high, low, float(i as u64), float(point_cuts(h, item))]) +} + +/// How many times the run has removed or replaced points of `item`. +fn point_cuts(h: &super::Host, item: Item) -> u64 { + h.dom.point_cuts.borrow().get(&(item.doc.uid, item.id.0)).copied().unwrap_or(0) +} + +/// Notes that the run removed or replaced points of `item`, which makes the points read before +/// stale. +fn cut_points(h: &super::Host, item: Item) { + let mut cuts = h.dom.point_cuts.borrow_mut(); + let n = cuts.entry((item.doc.uid, item.id.0)).or_insert(0); + *n = n.saturating_add(1); } fn points_at(h: &super::Host, a: &[Data]) -> Answer { @@ -1107,16 +1124,21 @@ fn points_add(h: &super::Host, a: &[Data]) -> Answer { fn points_remove_all(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; write_path(h, item, Vec::new())?; + cut_points(h, item); Ok(Data::Undefined) } // ---- PathPoint ---- -/// The path and the index of the point `this` names, which must still be in the path. +/// The path and the index of the point `this` names, which must still be in the path, with no +/// point of the path removed or replaced since `this` was read. pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(Item, usize), HostError> { let Some(handle) = handle_of(arg(a, 0), "PathPoint") else { return Err(HostError::Type("this is not a PathPoint".into())) }; - let [run, uid, high, low, i] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; + let [run, uid, high, low, i, cuts] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; let item = path_at(h, *run, *uid, *high, *low)?; + if whole(*cuts) != Some(point_cuts(h, item)) { + return Err(HostError::Error(STALE_POINT.into())); + } let i = whole(*i).and_then(|i| usize::try_from(i).ok()).ok_or_else(|| HostError::Error(STALE_POINT.into()))?; let n = read_points(h, item, point_count)?; if i >= n { @@ -1216,6 +1238,7 @@ fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { } } })?; + cut_points(h, item); Ok(Data::Undefined) } diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 004c02f4fc..5aff4e48d1 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -258,6 +258,32 @@ fn path_point_wrapper_goes_stale_after_remove() { ); } +#[test] +fn points_read_before_a_removal_or_replacement_go_stale() { + let (mut s, _, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], q = app.activeDocument.pathItems[1];\ + var second = p.pathPoints[1], other = q.pathPoints[1]; p.pathPoints[0].remove();\ + try { second.anchor = [0, 0]; } catch (e) { vc.log(e.message); } try { second.anchor; } catch (e) { vc.log(e.message); }\ + vc.log(other.anchor); var first = p.pathPoints[0]; vc.log(first.anchor);\ + p.setEntirePath([[1, 1], [2, 2], [3, 3]]); try { first.anchor; } catch (e) { vc.log(e.message); }\ + var again = p.pathPoints[0]; vc.log(again.anchor); p.pathPoints.removeAll(); try { again.anchor; } catch (e) { vc.log(e.message); }", + ); + assert_eq!( + out, + vec![ + json!("Stale path point"), + json!("Stale path point"), + json!([150, 200]), + json!([40, 280]), + json!("Stale path point"), + json!([1, 1]), + json!("Stale path point") + ] + ); +} + #[test] fn fill_color_round_trips_rgb_cmyk_gray_lab() { let (mut s, a, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 7d1ff6defe..4b82232fb6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2715,7 +2715,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot closed, and assigning it opens or closes them all; `setEntirePath` takes at most 100,000 points and gives corner points with no handles, keeping the path closed when it was; moving `anchor` leaves its handles where they are, and `pointType` changes only the type; `PathPoints.add()` adds a corner point at the last point, or at `[0, 0]`; a point - whose index is past the end of its path throws `Stale path point`. Color components left out count as 0, `new + whose index is past the end of its path throws `Stale path point`, and so does a point read before the script removed + a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`). Color components left out + count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest decimals, at least 4, that give the stored value back, so assigning a color read from a path leaves the path as it From d14830b6b7f1060c9f0eceb9dc3cbe83c3d601a2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 17:23:24 -0800 Subject: [PATCH 006/264] Scripts: saveAs and exportFile refuse a file open for writing and scales under 1% A save or export to a file that a File object holds open for writing throws "Script file is open for writing", and a command the script runs does not write such a file besides the one named (an SVG's images), so the bytes the File writes at the end of the run do not replace the output. horizontalScale and verticalScale take 1 to 776.19, since a raster export writes at least 0.01 pixels per point. The script checker reports a document's saveAs and exportFile as file writes, and the host name check lists the save, export and open names, option classes and enumerations. --- crates/engine/src/file_access.rs | 26 ++++++-- crates/engine/src/script/dom/save_open.rs | 7 +- crates/engine/src/script/files.rs | 14 ++-- crates/engine/src/tests/script_save_open.rs | 66 ++++++++++++++++++- .../tests/it/script_host_vs_scriptcheck.rs | 29 ++++++-- crates/scriptcheck/src/analyze/features.rs | 12 +++- crates/scriptcheck/src/catalog.rs | 3 + crates/scriptcheck/src/tests.rs | 28 ++++++++ crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + docs/mcp.md | 11 ++-- 34 files changed, 198 insertions(+), 23 deletions(-) diff --git a/crates/engine/src/file_access.rs b/crates/engine/src/file_access.rs index 4769146ad8..afab0e95b0 100644 --- a/crates/engine/src/file_access.rs +++ b/crates/engine/src/file_access.rs @@ -284,6 +284,9 @@ pub(crate) struct ScriptGate { pub(crate) write: ScriptScope, /// The paths of the open documents' files, as the documents hold them. pub(crate) documents: Vec, + /// The real paths of the files the script's `File` objects hold open for writing, which a + /// command does not write: the run's end would write the objects' bytes over them. + pub(crate) held: Vec, /// Another gate a path must pass as well ([`ScopeHandle::within_current`]). pub(crate) also: Option>, } @@ -312,7 +315,8 @@ impl ScriptGate { }; // A read-only file is not written over, also where a rename could replace it. let read_only = matches!(access, Access::Write) && std::fs::metadata(&real).is_ok_and(|m| m.is_file() && m.permissions().readonly()); - !read_only && (scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real))) + let held = matches!(access, Access::Write) && self.held.contains(&real); + !read_only && !held && (scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real))) }); if allowed { Ok(()) } else { Err(format!("Script file access denied: {path}")) } } @@ -920,8 +924,13 @@ mod tests { #[test] fn a_narrowed_scope_keeps_the_script_gates_of_both() { let (base, _) = folders("narrowed-gate"); - let gate = - |dir: &str| ScriptGate { read: ScriptScope::of_folder(&base.join(dir)), write: ScriptScope::default(), documents: vec![], also: None }; + let gate = |dir: &str| ScriptGate { + read: ScriptScope::of_folder(&base.join(dir)), + write: ScriptScope::default(), + documents: vec![], + held: vec![], + also: None, + }; let (inside, other) = (s(base.join("in/a.svg")), s(base.join("outside/secret.svg"))); let reads = |saved: ScopeHandle, gate_here: Option| { let narrowed = match gate_here { @@ -944,7 +953,8 @@ mod tests { #[test] fn a_scope_narrowed_several_times_keeps_every_gate() { let (base, _) = folders("narrowed-thrice"); - let gate = |dir: &Path| ScriptGate { read: ScriptScope::of_folder(dir), write: ScriptScope::default(), documents: vec![], also: None }; + let gate = + |dir: &Path| ScriptGate { read: ScriptScope::of_folder(dir), write: ScriptScope::default(), documents: vec![], held: vec![], also: None }; let (inside, other) = (s(base.join("in/a.svg")), s(base.join("outside/secret.svg"))); let narrow = |saved: ScopeHandle, g: ScriptGate| with_script_gate(g, || saved.within_current()); let reads = |h: &ScopeHandle| h.clone().run(|| (check_read(&inside).is_ok(), check_read(&other).is_ok())); @@ -964,7 +974,13 @@ mod tests { let (base, _) = folders("gate-read-only"); let out = base.join("out/kept.svg"); std::fs::write(&out, "").unwrap(); - let gate = ScriptGate { read: ScriptScope::default(), write: ScriptScope::of_folder(&base.join("out")), documents: vec![], also: None }; + let gate = ScriptGate { + read: ScriptScope::default(), + write: ScriptScope::of_folder(&base.join("out")), + documents: vec![], + held: vec![], + also: None, + }; let (kept, fresh) = (s(out.clone()), s(base.join("out/new.svg"))); let check = |p: &str| with_script_gate(gate.clone(), || (check_write(p).is_ok(), check_read(p).is_ok())); assert_eq!(check(&kept), (true, true)); diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index ebdebc4c10..c76ae0f44e 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -48,6 +48,9 @@ use super::{ /// The most a scale factor of an export takes, in percent. pub const MAX_SCALE_PERCENT: f64 = 776.19; +/// The least a scale factor of a raster export takes, in percent: `document.export` writes at least +/// 0.01 pixels per point. +pub const MIN_SCALE_PERCENT: f64 = 1.0; /// What the run keeps for these members: whether `userInteractionLevel` is `DONTDISPLAYALERTS`. #[derive(Default)] @@ -363,8 +366,8 @@ fn raster_map(class: &str, name: &str, d: &Data, p: &mut Map) -> Data::Number(n) if n.is_finite() => *n, _ => return Err(HostError::Type(format!("{what} must be a finite number"))), }; - if n <= 0.0 || n > MAX_SCALE_PERCENT { - return Err(HostError::Range(format!("{what} must be more than 0 and at most 776.19"))); + if !(MIN_SCALE_PERCENT..=MAX_SCALE_PERCENT).contains(&n) { + return Err(HostError::Range(format!("{what} must be at least 1 and at most 776.19"))); } let key = if name == "horizontalScale" { "_h" } else { "_v" }; p.insert(key.into(), json!(n)); diff --git a/crates/engine/src/script/files.rs b/crates/engine/src/script/files.rs index 40b1fe0465..7886210567 100644 --- a/crates/engine/src/script/files.rs +++ b/crates/engine/src/script/files.rs @@ -116,6 +116,7 @@ pub(crate) const NOT_WRITABLE: &str = "Script file is not open for writing"; pub(crate) const UNENCODABLE: &str = "Script file cannot encode the text"; pub(crate) const WRITE_FAILED: &str = "Script file could not be written"; pub(crate) const READ_ONLY: &str = "Script file is read-only"; +pub(crate) const OPEN_FOR_WRITING: &str = "Script file is open for writing"; pub(crate) const NOT_EMPTY: &str = "Script folder is not empty"; pub(crate) const NAME_TAKEN: &str = "Script file name is already in use"; pub(crate) const BAD_NAME: &str = "Script file name must be a name without a folder"; @@ -460,11 +461,12 @@ impl Disk { } /// The gate for a command the script runs: the places it reads and writes now, and the files of - /// the open documents, `documents`. + /// the open documents, `documents`, but not the files its `File` objects hold open for writing. pub(crate) fn gate(&self, documents: Vec) -> crate::file_access::ScriptGate { // A save, export or open of a `File` the script names reads and writes as its `File` would. let documents = if self.exact { Vec::new() } else { documents }; - crate::file_access::ScriptGate { read: self.scope.clone(), write: self.writes.clone(), documents, also: None } + let held = self.open.values().filter_map(|o| o.target.clone()).collect(); + crate::file_access::ScriptGate { read: self.scope.clone(), write: self.writes.clone(), documents, held, also: None } } /// The files written since this was last asked, to name in the report. @@ -684,10 +686,14 @@ impl Disk { } /// The real path a save or export of the document to `path` writes, as a `File` opened for - /// writing would write it ([`Disk::target`]), or why it may not: a folder is not a file, and a - /// read-only file is not written over. + /// writing would write it ([`Disk::target`]), or why it may not: a folder is not a file, a + /// read-only file is not written over, and neither is a file a `File` object holds open for + /// writing, whose bytes the run's end would write over the saved file. pub(crate) fn save_target(&self, path: &str) -> Result { let real = self.target(path, true)?; + if self.open.values().any(|o| o.target.as_deref() == Some(real.as_path())) { + return Err(OPEN_FOR_WRITING); + } match std::fs::metadata(&real) { Ok(m) if !m.is_file() => Err(NOT_REGULAR), Ok(m) if m.permissions().readonly() => Err(READ_ONLY), diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 809fed0ef8..8518f14365 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -271,6 +271,32 @@ fn an_open_documents_file_is_not_saved_over_without_a_grant() { let _ = std::fs::remove_dir_all(base); } +/// A save or export to a file a `File` object holds open for writing throws, so the object's bytes +/// written at the end of the run do not replace the saved document. +#[test] +fn a_file_open_for_writing_is_not_saved_over() { + let base = folder("openhandle"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + for (name, call) in + [("a.svg", "app.activeDocument.saveAs(new File(p));"), ("b.png", "app.activeDocument.exportFile(new File(p), ExportType.PNG24);")] + { + let p = quoted(&dir.join(name)); + let log = logged( + &mut s, + &base, + &format!( + "Folder.userData; var p = {p}, w = new File(p); w.open('w'); w.write('pending');\ntry {{ {call} vc.log('ran'); }} catch (e) {{ vc.log(e.message); }}" + ), + ); + assert!(log[0].as_str().unwrap().contains(crate::script::files::OPEN_FOR_WRITING), "{name}: {log}"); + assert_eq!(std::fs::read_to_string(dir.join(name)).unwrap(), "pending", "{name}: the File's own bytes"); + assert_eq!(s.active().unwrap().path, None, "{name}: the document's file is unchanged"); + } + let _ = std::fs::remove_dir_all(base); +} + /// A file `open` reads besides the one it names, here an SVG's linked image, is read only where /// the script's grants allow, though it is an open document's file. #[test] @@ -282,7 +308,7 @@ fn open_reads_linked_files_only_where_the_script_may() { std::fs::write(&linked, "").unwrap(); s.execute("document.open", &json!({"path": linked.to_string_lossy()})).unwrap(); assert!(s.active().unwrap().path.is_some(), "the linked file is an open document's file"); - let href = linked.to_string_lossy().replace('\\', "/"); + let href = linked.to_string_lossy().replace('\\', "/").replace('&', "&").replace('<', "<").replace('\'', "'"); std::fs::write( dir.join("page.svg"), format!(""), @@ -343,6 +369,38 @@ fn an_svg_export_writes_nothing_when_one_of_its_files_is_refused() { let _ = std::fs::remove_dir_all(base); } +/// An export does not write a file it writes besides the one named, here an SVG's image, while a +/// `File` object holds it open for writing, and so writes nothing. +#[test] +fn an_svg_export_does_not_write_an_image_a_file_holds_open() { + let base = folder("svgheld"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let pic = base.join("outside/pic.png"); + std::fs::write(&pic, super::links::png(2, 2, [10, 200, 30])).unwrap(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + s.execute("file.place", &json!({"path": pic.to_string_lossy(), "link": false})).unwrap(); + let svg = dir.join("a.svg"); + let export = format!("app.activeDocument.exportFile(new File({}), ExportType.SVG, new ExportOptionsSVG());", quoted(&svg)); + logged(&mut s, &base, &format!("Folder.userData; {export}")); + let mut images: Vec = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).filter(|p| *p != svg).collect(); + assert_eq!(images.len(), 1, "the embedded image is written beside the SVG: {images:?}"); + let image = images.remove(0); + std::fs::remove_file(&svg).unwrap(); + let log = logged( + &mut s, + &base, + &format!( + "Folder.userData; var w = new File({}); w.open('w'); w.write('pending');\ntry {{ {export} vc.log('ran'); }} catch (e) {{ vc.log(e.message); }}", + quoted(&image) + ), + ); + assert!(log[0].as_str().unwrap().contains(DENIED), "{log}"); + assert!(!svg.exists(), "the SVG is not written when its image may not be"); + assert_eq!(std::fs::read_to_string(&image).unwrap(), "pending", "the File's own bytes"); + let _ = std::fs::remove_dir_all(base); +} + /// A link inside a granted folder that leads out of it is followed and refused. #[cfg(unix)] #[test] @@ -404,6 +462,12 @@ fn bad_arguments_are_refused_with_an_error() { ), "at most", ), + ( + format!( + "var p = new ExportOptionsPNG24(); p.horizontalScale = p.verticalScale = 0.5; app.activeDocument.exportFile({f}, ExportType.PNG24, p);" + ), + "at least 1", + ), ( format!("var p = new ExportOptionsPNG24(); p.horizontalScale = 50; app.activeDocument.exportFile({f}, ExportType.PNG24, p);"), "not available yet", diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index ef7c97e951..26b476a0b6 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -37,12 +37,14 @@ const OUTSIDE: &[(&str, &str, &str)] = &[ ("Folder.prototype.remove", "var d = new Folder(p); d.remove();", "filesWritten"), ("Folder.prototype.rename", "var d = new Folder(p); d.rename(q);", "filesWritten"), ("Folder.prototype.execute", "var d = new Folder(p); d.execute();", "filesOpened"), + ("Document.prototype.saveAs", "app.activeDocument.saveAs(f);", "filesWritten"), + ("Document.prototype.exportFile", "app.activeDocument.exportFile(f, ExportType.PNG24);", "filesWritten"), ]; /// The names the host adds that stay inside the document and the run, by the object that has them. /// Reading a file or a folder, a file dialog and a message to the person do not change anything /// outside it. The document model (`app`, its classes and the enumerations) acts on the open -/// documents; `Document.saveAs` and `close` throw "not available yet". +/// documents; `Document.close` throws "not available yet". `app.open` reads the file it is given. const INSIDE: &[(&str, &str)] = &[ ("", "$ File Folder alert confirm localize prompt toSource"), ("Object.prototype.", "toSource"), @@ -81,7 +83,7 @@ const INSIDE: &[(&str, &str)] = &[ ( "Application.prototype.", "activeDocument activeDocument= beep beep= constructor coordinateSystem coordinateSystem= documents getIsFileOpen \ - selection typename", + open selection typename userInteractionLevel userInteractionLevel=", ), ("Documents.", "prototype"), ("Documents.prototype.", "add addDocument constructor getByName index length parent typename"), @@ -90,7 +92,7 @@ const INSIDE: &[(&str, &str)] = &[ "Document.prototype.", "activeLayer activeLayer= artboards artboards= close close= constructor convertCoordinate documentColorSpace \ groupItems groupItems= height layers layers= name pageItems parent pathItems pathItems= rulerOrigin rulerOrigin= \ - rulerUnits saveAs saveAs= selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ + rulerUnits selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ views views= width", ), ("Layer.", "prototype"), @@ -121,12 +123,27 @@ const INSIDE: &[(&str, &str)] = &[ ("ElementPlacement.", "INSIDE PLACEAFTER PLACEATBEGINNING PLACEATEND PLACEBEFORE"), ("RulerUnits.", "Centimeters Inches Millimeters Picas Pixels Points Qs Unknown"), ("ZOrderMethod.", "BRINGFORWARD BRINGTOFRONT SENDBACKWARD SENDTOBACK"), + // The enumerations of saving, exporting and opening. + ("", "Compatibility EPSPostScriptLevelEnum EPSPreview ExportType PDFBoxType PDFCompatibility PDFOverprint UserInteractionLevel"), + ( + "Compatibility.", + "ILLUSTRATOR10 ILLUSTRATOR11 ILLUSTRATOR12 ILLUSTRATOR13 ILLUSTRATOR14 ILLUSTRATOR15 ILLUSTRATOR16 ILLUSTRATOR17 \ + ILLUSTRATOR19 ILLUSTRATOR8 ILLUSTRATOR9 JAPANESEVERSION3", + ), + ("EPSPostScriptLevelEnum.", "LEVEL2 LEVEL3"), + ("EPSPreview.", "BWTIFF COLORTIFF None TRANSPARENTCOLORTIFF"), + ("ExportType.", "AutoCAD FLASH GIF JPEG PNG24 PNG8 SVG TIFF"), + ("PDFBoxType.", "PDFARTBOX PDFBLEEDBOX PDFBOUNDINGBOX PDFCROPBOX PDFMEDIABOX PDFTRIMBOX"), + ("PDFCompatibility.", "ACROBAT4 ACROBAT5 ACROBAT6 ACROBAT7 ACROBAT8"), + ("PDFOverprint.", "DISCARDPDFOVERPRINT PRESERVEPDFOVERPRINT"), + ("UserInteractionLevel.", "DISPLAYALERTS DONTDISPLAYALERTS"), ]; -/// The classes the host adds with nothing but a prototype and its constructor: `DocumentPreset` -/// and the page item types. +/// The classes the host adds with nothing but a prototype and its constructor: `DocumentPreset`, +/// the page item types and the save and export option classes. const BARE_CLASSES: &str = "BlendItem CompoundPathItem DocumentPreset EnvelopeItem GraphItem GroupItem IntertwineItem MeshItem PathItem \ - PlacedDocumentItem PlacedItem RasterItem RepeatItem SymbolItem TextFrame"; + PlacedDocumentItem PlacedItem RasterItem RepeatItem SymbolItem TextFrame EPSSaveOptions ExportOptionsJPEG ExportOptionsPNG24 \ + ExportOptionsSVG IllustratorSaveOptions PDFSaveOptions"; /// The name the checker does not read, which also stands for its members: `vc` is VectorCraft's /// own API, and what `vc.run` does depends on the command it runs. diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 7bf8c9d203..354a0540aa 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -287,6 +287,16 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// `(` after a name: a call. fn call(&mut self, line: Option) { let [h0, h1, h2, h3] = self.h; + // `doc['saveAs'](f)`: a document method named by a string literal in brackets. + if is(h0, "]") + && is(h2, "[") + && let Some(name) = h1.filter(|s| s.kind == T::Str) + && catalog::DOM_FILE_WRITES.contains(&unquote(name.text, 32).as_str()) + { + self.acc.feature(FeatureId::FileWrite, line); + self.acc.outside(OutsideId::FilesWritten, line, None); + return; + } let Some(callee) = h0.filter(|s| s.kind == T::Ident) else { return }; let n = callee.text; if is(h1, ".") { @@ -301,7 +311,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.acc.feature(FeatureId::FileDialog, line); } else if catalog::FOLDER_READS.contains(&n) || (file && catalog::FILE_READS.contains(&n)) { self.acc.feature(FeatureId::FileRead, line); - } else if file && catalog::FILE_WRITES.contains(&n) { + } else if (file && catalog::FILE_WRITES.contains(&n)) || catalog::DOM_FILE_WRITES.contains(&n) { self.acc.feature(FeatureId::FileWrite, line); self.acc.outside(OutsideId::FilesWritten, line, None); } else if n == catalog::EXECUTE { diff --git a/crates/scriptcheck/src/catalog.rs b/crates/scriptcheck/src/catalog.rs index 6f25fe6df3..ee5b63dfb2 100644 --- a/crates/scriptcheck/src/catalog.rs +++ b/crates/scriptcheck/src/catalog.rs @@ -72,6 +72,9 @@ pub(crate) const REFLECT: &str = "reflect"; // The roots of the document model: https://ai-scripting.docsforadobe.dev/jsobjref/Application/ pub(crate) const DOM_ROOTS: [&str; 4] = ["app", "activeDocument", "documents", "selection"]; +// Document methods that write the file they are given: https://ai-scripting.docsforadobe.dev/jsobjref/Document/ +pub(crate) const DOM_FILE_WRITES: &[&str] = &["exportFile", "saveAs"]; + // Application methods that page doesn't list, named in public forum posts: // https://community.adobe.com/t5/illustrator-discussions/changes-in-cs6/td-p/4173362 (executeMenuCommand, // doScript, loadAction, unloadAction) and diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index cf71cefc0f..12e5527811 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -530,6 +530,34 @@ fn the_scripts_own_platform_names_are_not_the_platforms() { assert_eq!(r.outside.iter().map(|o| o.id).collect::>(), ["filesWritten"]); } +/// A document's `saveAs` and `exportFile` write the file they are given; `app.open` only reads one. +#[test] +fn save_as_and_export_file_write_a_file() { + let r = report(concat!( + "var f = new File(p);\n", + "var d = app.open(f);\n", + "d.saveAs(f);\n", + "app.activeDocument.exportFile(f, ExportType.PNG24);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 4][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[3, 4][..])]); +} + +/// `saveAs` and `exportFile` called with their names as string literals in brackets write the file +/// too; reading the method without calling it does not. +#[test] +fn save_as_and_export_file_in_brackets_write_a_file() { + let r = report(concat!( + "var f = new File(p);\n", + "app.activeDocument['open'](f);\n", + "app.activeDocument[\"saveAs\"](f);\n", + "var d = app.activeDocument; d['exportFile'] (f, ExportType.SVG);\n", + "var n = d['saveAs'];\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 4][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[3, 4][..])]); +} + /// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing /// them and setting them on another object does not. #[test] diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 5e020a2116..4cb24ffa76 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6608,6 +6608,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file dialogs need a person to answer them Els diàlegs de fitxers de l’script necessiten una persona que els respongui @msg Script file is not open for writing El fitxer de l’script no està obert per escriure-hi @msg Script file is read-only El fitxer de l’script és només de lectura +@msg Script file is open for writing El fitxer de l’script està obert per escriure-hi @msg Script file name is already in use El nom del fitxer de l’script ja està en ús @msg Script file name must be a name without a folder El nom del fitxer de l’script ha de ser un nom sense carpeta @msg Script file permission can be kept only for a script run from a file El permís de fitxers només es pot conservar per a un script executat des d’un fitxer diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index a0ae87170c..4ac10d6ac7 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5393,6 +5393,7 @@ liquify-list-end {0}, {1} {0} a {1} @msg Script file dialogs need a person to answer them Dialogy souborů skriptu potřebují osobu, která na ně odpoví @msg Script file is not open for writing Soubor skriptu není otevřený pro zápis @msg Script file is read-only Soubor skriptu je jen pro čtení +@msg Script file is open for writing Soubor skriptu je otevřený pro zápis @msg Script file name is already in use Název souboru skriptu se už používá @msg Script file name must be a name without a folder Název souboru skriptu musí být název bez složky @msg Script file permission can be kept only for a script run from a file Oprávnění k souborům lze zachovat jen pro skript spuštěný ze souboru diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index a068797076..5aab6605f6 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -88,6 +88,7 @@ @msg Script file dialogs need a person to answer them Scriptets fildialoger skal besvares af en person @msg Script file is not open for writing Scriptfilen er ikke åben for skrivning @msg Script file is read-only Scriptfilen er skrivebeskyttet +@msg Script file is open for writing Scriptfilen er åben for skrivning @msg Script file name is already in use Scriptfilens navn er allerede i brug @msg Script file name must be a name without a folder Scriptfilens navn skal være et navn uden en mappe @msg Script file permission can be kept only for a script run from a file Filtilladelsen kan kun beholdes for et script, der køres fra en fil diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index ad2653ea36..a0872671f8 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4969,6 +4969,7 @@ liquify-list-end {0}, {1} {0} und {1} @msg Script file dialogs need a person to answer them Dateidialoge von Skripten brauchen eine Person, die sie beantwortet @msg Script file is not open for writing Skriptdatei ist nicht zum Schreiben geöffnet @msg Script file is read-only Skriptdatei ist schreibgeschützt +@msg Script file is open for writing Skriptdatei ist zum Schreiben geöffnet @msg Script file name is already in use Name der Skriptdatei wird bereits verwendet @msg Script file name must be a name without a folder Name der Skriptdatei muss ein Name ohne Ordner sein @msg Script file permission can be kept only for a script run from a file Dateiberechtigung kann nur für ein Skript behalten werden, das aus einer Datei ausgeführt wird diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 3ead7c9a10..db00e18a27 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2806,6 +2806,7 @@ liquify-list-end {0}, {1} {0} και {1} @msg Script file dialogs need a person to answer them Τα παράθυρα διαλόγου αρχείων του σεναρίου χρειάζονται ένα άτομο για να απαντήσει @msg Script file is not open for writing Το αρχείο του σεναρίου δεν είναι ανοιχτό για εγγραφή @msg Script file is read-only Το αρχείο του σεναρίου είναι μόνο για ανάγνωση +@msg Script file is open for writing Το αρχείο του σεναρίου είναι ανοιχτό για εγγραφή @msg Script file name is already in use Το όνομα του αρχείου του σεναρίου χρησιμοποιείται ήδη @msg Script file name must be a name without a folder Το όνομα του αρχείου του σεναρίου πρέπει να είναι όνομα χωρίς φάκελο @msg Script file permission can be kept only for a script run from a file Η άδεια αρχείων μπορεί να διατηρηθεί μόνο για σενάριο που εκτελείται από αρχείο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 8003e265c2..28dd4a176c 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5080,6 +5080,7 @@ liquify-list-end {0}, {1} {0}, {1} @msg Script file dialogs need a person to answer them Los cuadros de diálogo de archivo del script necesitan que una persona los responda @msg Script file is not open for writing El archivo del script no está abierto para escritura @msg Script file is read-only El archivo del script es de solo lectura +@msg Script file is open for writing El archivo del script está abierto para escritura @msg Script file name is already in use El nombre del archivo del script ya está en uso @msg Script file name must be a name without a folder El nombre del archivo del script debe ser un nombre sin carpeta @msg Script file permission can be kept only for a script run from a file El permiso de archivos solo se puede conservar para un script ejecutado desde un archivo diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index d8933598d0..a56f4feca6 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5321,6 +5321,7 @@ liquify-list-end {0}, {1} {0} ja {1} @msg Script file dialogs need a person to answer them Komentosarjan tiedostovalintaikkunoihin tarvitaan vastaava henkilö @msg Script file is not open for writing Komentosarjan tiedosto ei ole auki kirjoittamista varten @msg Script file is read-only Komentosarjan tiedosto on vain luku -tilassa +@msg Script file is open for writing Komentosarjan tiedosto on auki kirjoittamista varten @msg Script file name is already in use Komentosarjan tiedoston nimi on jo käytössä @msg Script file name must be a name without a folder Komentosarjan tiedoston nimen on oltava nimi ilman kansiota @msg Script file permission can be kept only for a script run from a file Tiedostolupa voidaan säilyttää vain tiedostosta suoritetulle komentosarjalle diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 70e88ea0de..52ce992d66 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5039,6 +5039,7 @@ liquify-list-end {0}, {1} {0} et {1} @msg Script file dialogs need a person to answer them Les boîtes de dialogue de fichiers du script ont besoin d’une personne pour y répondre @msg Script file is not open for writing Le fichier du script n’est pas ouvert en écriture @msg Script file is read-only Le fichier du script est en lecture seule +@msg Script file is open for writing Le fichier du script est ouvert en écriture @msg Script file name is already in use Le nom du fichier du script est déjà utilisé @msg Script file name must be a name without a folder Le nom du fichier du script doit être un nom sans dossier @msg Script file permission can be kept only for a script run from a file L’autorisation d’accès aux fichiers ne peut être conservée que pour un script exécuté depuis un fichier diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index d12d3d8a3b..111037fda0 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7755,6 +7755,7 @@ liquify-list-end {0}, {1} {0} और {1} @msg Script file dialogs need a person to answer them स्क्रिप्ट के फ़ाइल डायलॉग को उत्तर देने के लिए किसी व्यक्ति की ज़रूरत है @msg Script file is not open for writing स्क्रिप्ट फ़ाइल लिखने के लिए खुली नहीं है @msg Script file is read-only स्क्रिप्ट फ़ाइल केवल पढ़ने के लिए है +@msg Script file is open for writing स्क्रिप्ट फ़ाइल लिखने के लिए खुली है @msg Script file name is already in use स्क्रिप्ट फ़ाइल का नाम पहले से उपयोग में है @msg Script file name must be a name without a folder स्क्रिप्ट फ़ाइल का नाम बिना फ़ोल्डर वाला नाम होना चाहिए @msg Script file permission can be kept only for a script run from a file फ़ाइल अनुमति केवल फ़ाइल से चलाई गई स्क्रिप्ट के लिए रखी जा सकती है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 51a731132b..78093bf132 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5911,6 +5911,7 @@ liquify-list-end {0}, {1} {0} és {1} @msg Script file dialogs need a person to answer them A parancsfájl fájlpárbeszédpaneleire egy személynek kell válaszolnia @msg Script file is not open for writing A parancsfájl fájlja nincs írásra megnyitva @msg Script file is read-only A parancsfájl fájlja csak olvasható +@msg Script file is open for writing A parancsfájl fájlja írásra meg van nyitva @msg Script file name is already in use A parancsfájl fájljának neve már használatban van @msg Script file name must be a name without a folder A parancsfájl fájljának neve mappa nélküli név kell legyen @msg Script file permission can be kept only for a script run from a file A fájlengedély csak fájlból futtatott parancsfájlnál tartható meg diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 7e041bfecb..5badf608d7 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -8749,6 +8749,7 @@ breakText Glyphs Glif @msg Script file dialogs need a person to answer them Dialog file skrip memerlukan orang untuk menjawabnya @msg Script file is not open for writing File skrip tidak dibuka untuk ditulis @msg Script file is read-only File skrip hanya dapat dibaca +@msg Script file is open for writing File skrip sedang dibuka untuk ditulis @msg Script file name is already in use Nama file skrip sudah digunakan @msg Script file name must be a name without a folder Nama file skrip harus berupa nama tanpa folder @msg Script file permission can be kept only for a script run from a file Izin file skrip hanya dapat disimpan untuk skrip yang dijalankan dari file diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index cc67a9be3a..9b6018956e 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5107,6 +5107,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file dialogs need a person to answer them Le finestre di dialogo dei file dello script richiedono una persona che risponda @msg Script file is not open for writing Il file dello script non è aperto in scrittura @msg Script file is read-only Il file dello script è di sola lettura +@msg Script file is open for writing Il file dello script è aperto in scrittura @msg Script file name is already in use Il nome del file dello script è già in uso @msg Script file name must be a name without a folder Il nome del file dello script deve essere un nome senza cartella @msg Script file permission can be kept only for a script run from a file Il permesso sui file può essere mantenuto solo per uno script eseguito da un file diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 2bd2dad0b2..348f7aa3f3 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5942,6 +5942,7 @@ liquify-list-end {0}, {1} {0}、{1} @msg Script file dialogs need a person to answer them スクリプトのファイルダイアログには応答する人が必要です @msg Script file is not open for writing スクリプトのファイルが書き込み用に開かれていません @msg Script file is read-only スクリプトのファイルは読み取り専用です +@msg Script file is open for writing スクリプトのファイルが書き込み用に開かれています @msg Script file name is already in use スクリプトのファイル名はすでに使用されています @msg Script file name must be a name without a folder スクリプトのファイル名はフォルダーを含まない名前にしてください @msg Script file permission can be kept only for a script run from a file ファイルの許可を保持できるのは、ファイルから実行したスクリプトだけです diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 6625e82912..50a7c83e6d 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -8603,6 +8603,7 @@ liquify-list-end {0}, {1} {0} და {1} @msg Script file dialogs need a person to answer them სკრიპტის ფაილის დიალოგებს სჭირდება ადამიანი, რომელიც უპასუხებს @msg Script file is not open for writing სკრიპტის ფაილი ჩასაწერად გახსნილი არ არის @msg Script file is read-only სკრიპტის ფაილი მხოლოდ წასაკითხია +@msg Script file is open for writing სკრიპტის ფაილი ჩასაწერად გახსნილია @msg Script file name is already in use სკრიპტის ფაილის სახელი უკვე გამოიყენება @msg Script file name must be a name without a folder სკრიპტის ფაილის სახელი უნდა იყოს სახელი საქაღალდის გარეშე @msg Script file permission can be kept only for a script run from a file ფაილების ნებართვის შენახვა შესაძლებელია მხოლოდ ფაილიდან გაშვებული სკრიპტისთვის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 6cc76d1ef5..0db12b4e59 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5871,6 +5871,7 @@ liquify-list-end {0}, {1} {0} 및 {1} @msg Script file dialogs need a person to answer them 스크립트 파일 대화 상자에는 응답할 사람이 필요합니다 @msg Script file is not open for writing 스크립트 파일이 쓰기용으로 열려 있지 않습니다 @msg Script file is read-only 스크립트 파일이 읽기 전용입니다 +@msg Script file is open for writing 스크립트 파일이 쓰기용으로 열려 있습니다 @msg Script file name is already in use 스크립트 파일 이름이 이미 사용 중입니다 @msg Script file name must be a name without a folder 스크립트 파일 이름은 폴더 없는 이름이어야 합니다 @msg Script file permission can be kept only for a script run from a file 파일 권한은 파일에서 실행한 스크립트에만 유지할 수 있습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 9cec4dc19c..929dc790fe 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -90,6 +90,7 @@ @msg Script file dialogs need a person to answer them Dialoogvensters voor scriptbestanden moeten door een persoon worden beantwoord @msg Script file is not open for writing Het scriptbestand is niet geopend voor schrijven @msg Script file is read-only Het scriptbestand is alleen-lezen +@msg Script file is open for writing Het scriptbestand is geopend voor schrijven @msg Script file name is already in use De naam van het scriptbestand is al in gebruik @msg Script file name must be a name without a folder De naam van het scriptbestand moet een naam zonder map zijn @msg Script file permission can be kept only for a script run from a file Toestemming voor scriptbestanden kan alleen worden bewaard voor een script dat vanuit een bestand wordt uitgevoerd diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 82f4003b2e..1f14688dd1 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5212,6 +5212,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file dialogs need a person to answer them Okna dialogowe plików skryptu wymagają osoby, która na nie odpowie @msg Script file is not open for writing Plik skryptu nie jest otwarty do zapisu @msg Script file is read-only Plik skryptu jest tylko do odczytu +@msg Script file is open for writing Plik skryptu jest otwarty do zapisu @msg Script file name is already in use Nazwa pliku skryptu jest już używana @msg Script file name must be a name without a folder Nazwa pliku skryptu musi być nazwą bez folderu @msg Script file permission can be kept only for a script run from a file Uprawnienie do plików można zachować tylko dla skryptu uruchomionego z pliku diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 99e822eb99..a70f1c64a6 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -6251,6 +6251,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file dialogs need a person to answer them As caixas de diálogo de arquivo do script precisam de uma pessoa para respondê-las @msg Script file is not open for writing O arquivo do script não está aberto para gravação @msg Script file is read-only O arquivo do script é somente leitura +@msg Script file is open for writing O arquivo do script está aberto para gravação @msg Script file name is already in use O nome do arquivo do script já está em uso @msg Script file name must be a name without a folder O nome do arquivo do script deve ser um nome sem pasta @msg Script file permission can be kept only for a script run from a file A permissão de arquivos só pode ser mantida para um script executado a partir de um arquivo diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 132428a948..1ffaea5dab 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5102,6 +5102,7 @@ liquify-list-end {0}, {1} {0} и {1} @msg Script file dialogs need a person to answer them Для ответа на файловые диалоги скрипта нужен человек @msg Script file is not open for writing Файл скрипта не открыт для записи @msg Script file is read-only Файл скрипта доступен только для чтения +@msg Script file is open for writing Файл скрипта открыт для записи @msg Script file name is already in use Имя файла скрипта уже используется @msg Script file name must be a name without a folder Имя файла скрипта должно быть именем без папки @msg Script file permission can be kept only for a script run from a file Разрешение на файлы можно сохранить только для скрипта, запущенного из файла diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 3398eaf74f..efb575f716 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4978,6 +4978,7 @@ liquify-list-end {0}, {1} {0} och {1} @msg Script file dialogs need a person to answer them Skriptets fildialoger behöver en person som svarar på dem @msg Script file is not open for writing Skriptets fil är inte öppen för skrivning @msg Script file is read-only Skriptets fil är skrivskyddad +@msg Script file is open for writing Skriptets fil är öppen för skrivning @msg Script file name is already in use Namnet på skriptets fil används redan @msg Script file name must be a name without a folder Namnet på skriptets fil måste vara ett namn utan mapp @msg Script file permission can be kept only for a script run from a file Filbehörighet kan bara behållas för ett skript som körs från en fil diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index b70ea0e97e..e353434aaa 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4814,6 +4814,7 @@ liquify-list-end {0}, {1} {0} ve {1} @msg Script file dialogs need a person to answer them Betiğin dosya iletişim kutularının yanıtlanması için bir kişi gerekir @msg Script file is not open for writing Betiğin dosyası yazmak için açık değil @msg Script file is read-only Betiğin dosyası salt okunur +@msg Script file is open for writing Betiğin dosyası yazmak için açık @msg Script file name is already in use Betiğin dosya adı zaten kullanılıyor @msg Script file name must be a name without a folder Betiğin dosya adı klasör içermeyen bir ad olmalıdır @msg Script file permission can be kept only for a script run from a file Dosya izni yalnızca bir dosyadan çalıştırılan betik için saklanabilir diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 9dabba9916..7e3b137acc 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5091,6 +5091,7 @@ liquify-list-end {0}, {1} {0} і {1} @msg Script file dialogs need a person to answer them Для відповіді на файлові діалоги скрипту потрібна людина @msg Script file is not open for writing Файл скрипту не відкрито для запису @msg Script file is read-only Файл скрипту доступний лише для читання +@msg Script file is open for writing Файл скрипту відкрито для запису @msg Script file name is already in use Ім’я файлу скрипту вже використовується @msg Script file name must be a name without a folder Ім’я файлу скрипту має бути іменем без папки @msg Script file permission can be kept only for a script run from a file Дозвіл на файли можна зберегти лише для скрипту, запущеного з файлу diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index cc9ec45896..9af45922ab 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5601,6 +5601,7 @@ liquify-list-end {0}, {1} {0} và {1} @msg Script file dialogs need a person to answer them Hộp thoại tệp của tập lệnh cần một người trả lời @msg Script file is not open for writing Tệp của tập lệnh chưa được mở để ghi @msg Script file is read-only Tệp của tập lệnh ở chế độ chỉ đọc +@msg Script file is open for writing Tệp của tập lệnh đang được mở để ghi @msg Script file name is already in use Tên tệp của tập lệnh đã được sử dụng @msg Script file name must be a name without a folder Tên tệp của tập lệnh phải là một tên không có thư mục @msg Script file permission can be kept only for a script run from a file Chỉ có thể giữ quyền truy cập tệp cho tập lệnh chạy từ một tệp diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 11e409f42e..dc6577be86 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5598,6 +5598,7 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file dialogs need a person to answer them 脚本的文件对话框需要有人回答 @msg Script file is not open for writing 脚本的文件未以写入方式打开 @msg Script file is read-only 脚本的文件为只读 +@msg Script file is open for writing 脚本的文件已以写入方式打开 @msg Script file name is already in use 脚本的文件名已被使用 @msg Script file name must be a name without a folder 脚本的文件名必须是不含文件夹的名称 @msg Script file permission can be kept only for a script run from a file 只有从文件运行的脚本才能保留文件权限 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 287c85cfeb..a97d0185e1 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2953,6 +2953,7 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file dialogs need a person to answer them 指令碼的檔案對話框需要有人回應 @msg Script file is not open for writing 指令碼的檔案未以寫入方式開啟 @msg Script file is read-only 指令碼的檔案為唯讀 +@msg Script file is open for writing 指令碼的檔案已以寫入方式開啟 @msg Script file name is already in use 指令碼的檔案名稱已在使用中 @msg Script file name must be a name without a folder 指令碼的檔案名稱必須是不含資料夾的名稱 @msg Script file permission can be kept only for a script run from a file 只有從檔案執行的指令碼才能保留檔案權限 diff --git a/docs/mcp.md b/docs/mcp.md index 3ead9da179..acb6c3317f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2558,7 +2558,8 @@ control character, in the first 8 KiB) or `tooLarge` (over 8 MiB). For a script, (`app.executeMenuCommand('…')`), each with a count and its lines, and `menuCommands.dynamic` counts the calls whose argument isn't a string literal. - `outside` lists what the script does outside the document: `filesWritten` (with the open modes used; setting a - File object's `length`, `hidden` or `readonly` counts too), `filesOpened` (files opened in other apps), `network`, + File object's `length`, `hidden` or `readonly` counts too, and so does a document's `saveAs` or `exportFile`), + `filesOpened` (files opened in other apps), `network`, `nativeCode`, `otherApps` (messages to other apps), `environment` (environment variables), `unseenCode` (`eval`, `new Function` and `$.evalFile`) and `preferences` (the reference app's preferences changed). - `problems` lists what would stop the script loading as written (strings, comments, regular expressions, @@ -2695,8 +2696,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `exportType` is an `ExportType`: `PNG24`, `JPEG` and `SVG` take `new ExportOptionsPNG24()`, `new ExportOptionsJPEG()` and `new ExportOptionsSVG()` (https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/), - with `antiAliasing`, `artBoardClipping`, `horizontalScale` and `verticalScale` (the same value, more than 0 and at - most 776.19; 100 writes one pixel per point whatever the raster effects resolution), `transparency` (PNG24), `qualitySetting` (0 to 100) and `optimization` (JPEG), and + with `antiAliasing`, `artBoardClipping`, `horizontalScale` and `verticalScale` (the same value, from 1 to + 776.19; 100 writes one pixel per point whatever the raster effects resolution), `transparency` (PNG24), `qualitySetting` (0 to 100) and `optimization` (JPEG), and `coordinatePrecision` (1 to 7), `embedRasterImages`, `compressed`, `preserveEditability` and `includeVariablesAndDatasets` (SVG); `PNG8`, `GIF` and `TIFF` take no options. `app.open`'s `options` is a `PDFFileOptions` record (https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/) with @@ -2706,7 +2707,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot VectorCraft's own rules: each path is checked as a `File` opened for reading or writing is checked, before the command runs. A path outside the script's folders throws `Script file access denied`, also when it is an open document's file, a link that leads outside them, or the settings folder; a read-only file throws `Script file is - read-only`; and the files a command reads or writes besides the one named, such as an SVG's linked files, are + read-only`; a file a `File` object holds open for writing throws `Script file is open for writing` on `saveAs` + and `exportFile`, and `Script file access denied` when a command would write it besides the file named; and the + files a command reads or writes besides the one named, such as an SVG's linked files, are read and written only where the script's folders allow. `userInteractionLevel` does not change what a command does or where it may read and write, since a command a script runs never shows a dialog. `exportFile` adds the format's extension unless the name already ends with it (`.jpg` or `.jpeg`, `.tif` or `.tiff`, `.svgz` with From bd945697e8088dc8e167787b7b91d183b7003465 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 18:06:28 -0800 Subject: [PATCH 007/264] Scripts: a path point read before a command changes its path is stale A PathPoint read before vc.run('path.setAnchors', ...) replaced its path's points stayed valid, so a later write changed the replacement's point at the same index. The object model now keeps each path whose points the script read and checks it after every command and when a point is used. When the path's points differ from the ones it last saw, or the path is gone, the points read before throw `Stale path point`. This covers any command run with vc.run, an undo, and a change that a later command reverses. Points stay valid through the object model's own changes to the path or to an object that holds it, such as translate(). docs/mcp.md and the module doc state the rule. --- crates/engine/src/script/dom.rs | 32 ++++-- crates/engine/src/script/dom/paths.rs | 106 +++++++++++++++++++- crates/engine/src/script/mod.rs | 3 + crates/engine/src/tests/script_dom_paths.rs | 38 +++++++ docs/mcp.md | 5 +- 5 files changed, 173 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 2e09f8cb5d..dd47eb00f3 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -89,8 +89,8 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; /// What the object model keeps for one run: its coordinate system, the last list of a document's /// page items, kept while that document is unchanged, the point changes of a path not written yet, -/// how many times it removed or replaced each path's points, and whether a call's own savepoint -/// ([`atomically`]) is open. +/// how many times each path's points went stale and each path as the run last saw its points, and +/// whether a call's own savepoint ([`atomically`]) is open. #[derive(Default)] pub(super) struct State { coords: Cell, @@ -100,9 +100,18 @@ pub(super) struct State { /// A path and its subpaths with the point changes the run has made to it and not written yet /// ([`flush`]). pending: RefCell)>>, - /// How many times the run has removed or replaced points of each path, by document uid and - /// path id ([`paths`]). + /// How many times the points the run read of each path went stale, by document uid and path id + /// ([`paths`]). point_cuts: RefCell>, + /// Each path whose points the run read, as the run last saw it, by document uid and path id + /// ([`paths`]). + point_nodes: RefCell>>, + /// Each document, by uid, as it was when the run last looked at all the paths in it whose + /// points it read ([`paths`]). + point_docs: RefCell>>, + /// The item the object model is changing ([`edit_item`]), whose points stay valid through the + /// change. + editing: Cell>, saving: Cell, } @@ -169,6 +178,12 @@ pub(super) fn flush(h: &Host) -> std::result::Result<(), HostError> { paths::flush(h) } +/// Notes the changes a command made to the points of the paths the run has read +/// ([`paths::see_all_points`]). +pub(super) fn see_points(h: &Host) { + paths::see_all_points(h) +} + fn get(link: &Link, f: Member) -> HostMember { HostMember::Get(function(link, f)) } @@ -621,9 +636,14 @@ fn on_doc( Ok(v) } -/// Runs `id` with `params` on the item's document, its selection kept. +/// Runs `id` with `params` on the item's document, its selection kept. The points the run read of +/// the item's paths stay valid through the change ([`paths::see_all_points`]). fn edit_item(h: &Host, item: Item, id: &str, params: &Value) -> std::result::Result { - on_doc(h, item.doc.uid, true, |h| command(h, id, params)) + paths::see_all_points(h); + let kept = h.dom.editing.replace(Some(item)); + let r = on_doc(h, item.doc.uid, true, |h| command(h, id, params)); + h.dom.editing.set(kept); + r } /// Reads the document of `doc` with `f`. diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 44c2304b38..32401db1d0 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -30,7 +30,10 @@ //! Removing the last points leaves the path, with no points. //! - A point whose index is past the end of its path throws `Stale path point`, and so does a //! point read before the run removed a point of its path or replaced its points -//! (`PathPoint.remove()`, `PathPoints.removeAll()`, `setEntirePath`). +//! (`PathPoint.remove()`, `PathPoints.removeAll()`, `setEntirePath`), or before anything other +//! than the object model changed the path's points (a command run with `vc.run`, such as +//! `path.setAnchors`, `object.move` or `edit.undo`). Points stay valid through the object +//! model's other changes to the path or to an object that holds it, such as `translate()`. //! - Shape creators take sizes and radii that are finite and not negative; `sides` is a whole //! number from 3 to 1000 and `points` one from 2 to 1000. `inscribed` true throws an error that //! says it is not available yet. `rotateAbout` and `scaleAbout` default to @@ -41,6 +44,7 @@ //! so `changeFillGradients` false throws an error that says it is not available yet. use std::rc::Rc; +use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_color::{Color, Paint}; @@ -1071,19 +1075,113 @@ fn point_ref(h: &super::Host, item: Item, i: usize) -> Data { host_ref("PathPoint", &[float(h.run), float(item.doc.uid), high, low, float(i as u64), float(point_cuts(h, item))]) } -/// How many times the run has removed or replaced points of `item`. +/// How many times the points read of `item` have gone stale, after [`see_points`] notes a change +/// made to them since the run last saw them. fn point_cuts(h: &super::Host, item: Item) -> u64 { - h.dom.point_cuts.borrow().get(&(item.doc.uid, item.id.0)).copied().unwrap_or(0) + let key = (item.doc.uid, item.id.0); + see_points(h, key, || false); + h.dom.point_cuts.borrow().get(&key).copied().unwrap_or(0) } /// Notes that the run removed or replaced points of `item`, which makes the points read before /// stale. fn cut_points(h: &super::Host, item: Item) { + cut_key(h, (item.doc.uid, item.id.0)); +} + +/// [`cut_points`] for the path of document uid and path id `key`. +fn cut_key(h: &super::Host, key: (u64, u64)) { let mut cuts = h.dom.point_cuts.borrow_mut(); - let n = cuts.entry((item.doc.uid, item.id.0)).or_insert(0); + let n = cuts.entry(key).or_insert(0); *n = n.saturating_add(1); } +/// The node of `id` in `d`, as the document holds it. +fn node_arc(d: &crate::Document, id: NodeId) -> Option<&Arc> { + let at = d.index_path(id)?; + let (first, rest) = at.split_first()?; + let mut cur = d.layers.get(*first)?; + for &i in rest { + cur = cur.children()?.get(i)?; + } + Some(cur) +} + +/// Keeps the path of document uid and path id `key` as it is now, the first time the run reads its +/// points and after each later look. When its points differ from the ones the run last saw, the +/// points read before go stale, unless `own`: the object model made the change +/// ([`see_all_points`]), which `own` is asked only after a change. The kept node is shared with +/// the document, so a node whose pointer is unchanged has unchanged points, and any change to it +/// makes a new node. +fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { + let node = { + let s = h.session.borrow(); + s.documents().iter().find(|d| d.uid == key.0).and_then(|st| node_arc(&st.doc, NodeId(key.1)).cloned()) + }; + // A path that is gone makes its points stale, so that an undo that brings it back leaves them + // stale. + let Some(node) = node else { + if h.dom.point_nodes.borrow_mut().remove(&key).is_some() { + cut_key(h, key); + } + return; + }; + let changed = match h.dom.point_nodes.borrow_mut().insert(key, node.clone()) { + Some(old) => !Arc::ptr_eq(&old, &node) && old.path_data().map(|pd| &pd.subpaths) != node.path_data().map(|pd| &pd.subpaths), + None => false, + }; + if changed && !own() { + cut_key(h, key); + } +} + +/// [`see_points`] for each path whose points the run has read, after each command, so that a +/// change that a later command reverses still makes the points stale. Paths under the object that +/// the object model is changing ([`super::State`]), or that object itself, take the change as the +/// object model's own, and their points stay valid. A document that is the one the run last looked +/// at is skipped, as are its paths. +pub(super) fn see_all_points(h: &super::Host) { + let keys: Vec<(u64, u64)> = { + let seen = h.dom.point_nodes.borrow(); + if seen.is_empty() { + return; + } + let s = h.session.borrow(); + let mut docs = h.dom.point_docs.borrow_mut(); + // The documents that changed since the last look, kept as they are now. + let mut changed = std::collections::HashSet::new(); + for (uid, _) in seen.keys() { + if changed.contains(uid) { + continue; + } + match s.documents().iter().find(|d| d.uid == *uid) { + Some(st) if docs.get(uid).is_some_and(|d| Arc::ptr_eq(d, &st.doc)) => {} + Some(st) => { + docs.insert(*uid, st.doc.clone()); + changed.insert(*uid); + } + None => { + docs.remove(uid); + changed.insert(*uid); + } + } + } + seen.keys().copied().filter(|(uid, _)| changed.contains(uid)).collect() + }; + let editing = h.dom.editing.get(); + for (uid, id) in keys { + let own = || match editing { + Some(e) if e.doc.uid == uid => { + let s = h.session.borrow(); + let id = NodeId(id); + id == e.id || s.documents().iter().find(|d| d.uid == uid).and_then(|st| st.doc.ancestry(id)).is_some_and(|a| a.contains(&e.id)) + } + _ => false, + }; + see_points(h, (uid, id), own); + } +} + fn points_at(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; let Data::Number(n) = arg(a, 1) else { return Ok(Data::Undefined) }; diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index 82d013e076..3019b147b8 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -1350,6 +1350,9 @@ fn command_value(host: &Host, id: &str, params: &Value) -> std::result::Result<( return Err(HostError::Abort(HISTORY_LOST.to_string())); } } + if crossed.is_ok() { + dom::see_points(host); + } crossed.map(|data| (data, value)) } diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 5aff4e48d1..2dbf3263b9 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -284,6 +284,44 @@ fn points_read_before_a_removal_or_replacement_go_stale() { ); } +#[test] +fn points_read_before_a_command_changes_the_path_go_stale() { + let (mut s, a, _) = doc(); + let source = format!( + "function A(x, y) {{ return {{x: x, y: y, in: [x, y], out: [x, y], smooth: false}}; }}\ + var p = app.activeDocument.pathItems[0], id = {id}, first = p.pathPoints[1];\ + vc.run('path.setAnchors', {{id: id, subpaths: [{{anchors: [A(0, 0), A(20, 0), A(20, 20), A(0, 20)], closed: true}}]}});\ + try {{ first.anchor = [1, 1]; }} catch (e) {{ vc.log(e.message); }} try {{ first.anchor; }} catch (e) {{ vc.log(e.message); }}\ + var second = p.pathPoints[1]; vc.log(second.anchor);\ + vc.run('stroke.set', {{ids: [id], weight: 3}}); vc.log(second.anchor);\ + p.translate(5, 0); vc.log(second.anchor);\ + vc.run('object.move', {{ids: [id], dx: 5, dy: 0}}); try {{ second.anchor; }} catch (e) {{ vc.log(e.message); }}\ + var third = p.pathPoints[1]; vc.log(third.anchor);\ + vc.run('object.move', {{ids: [id], dx: 5, dy: 0}}); vc.run('edit.undo');\ + try {{ third.anchor; }} catch (e) {{ vc.log(e.message); }} vc.log(p.pathPoints.length);\ + var fourth = p.pathPoints[1]; vc.run('edit.clear', {{ids: [id]}}); vc.run('edit.undo');\ + try {{ fourth.anchor; }} catch (e) {{ vc.log(e.message); }} vc.log(p.pathPoints.length);", + id = a.0 + ); + let out = log(&mut s, &source); + assert_eq!( + out, + vec![ + json!("Stale path point"), + json!("Stale path point"), + json!([20, 300]), + json!([20, 300]), + json!([25, 300]), + json!("Stale path point"), + json!([30, 300]), + json!("Stale path point"), + json!(4), + json!("Stale path point"), + json!(4) + ] + ); +} + #[test] fn fill_color_round_trips_rgb_cmyk_gray_lab() { let (mut s, a, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 4b82232fb6..9371a4857d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2716,7 +2716,10 @@ app through the global object `vc`, and writes to the Script Console and runs ot points with no handles, keeping the path closed when it was; moving `anchor` leaves its handles where they are, and `pointType` changes only the type; `PathPoints.add()` adds a corner point at the last point, or at `[0, 0]`; a point whose index is past the end of its path throws `Stale path point`, and so does a point read before the script removed - a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`). Color components left out + a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`), or before anything other + than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`, + `object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an + object that holds it, such as `translate()`. Color components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest From bb931b5df738740dfe129c5eb4e6df5e96ba6802 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 18:23:50 -0800 Subject: [PATCH 008/264] Scripts: file.new rejects rows that are not a whole number from 1 to 1000 artboardLayout.rows rounded a fractional count and lowered a count over 1000 to 1000, so file.new made a different grid from the one asked for. It now throws for both, and docs/mcp.md states the range. --- crates/engine/src/cmd/newdoc.rs | 18 +++++++++++++++--- crates/engine/src/tests/newdoc.rs | 2 ++ crates/engine/src/tests/script_dom.rs | 2 +- docs/mcp.md | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index 983ef4041d..ee2767d1df 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -371,12 +371,24 @@ impl DocSettings { return Ok(()); } let o = l.as_object().ok_or_else(|| bad(cmd, "artboardLayout must be {layout?, columns?, spacing?, rightToLeft?}"))?; - let count = |v: &Value| v.as_f64().filter(|c| c.is_finite() && *c >= 1.0).map(|c| c.round().min(MAX_ARTBOARDS as f64) as u32); for (k, v) in o { match k.as_str() { "layout" => self.layout = v.as_str().and_then(ArtboardLayout::parse).ok_or_else(bad_layout)?, - "columns" => self.columns = count(v).ok_or_else(|| bad(cmd, "artboardLayout.columns must be 1 or more"))?, - "rows" => self.rows = count(v).ok_or_else(|| bad(cmd, "artboardLayout.rows must be 1 or more"))?, + "columns" => { + self.columns = v + .as_f64() + .filter(|c| c.is_finite() && *c >= 1.0) + .ok_or_else(|| bad(cmd, "artboardLayout.columns must be 1 or more"))? + .round() + .min(MAX_ARTBOARDS as f64) as u32 + } + "rows" => { + self.rows = v + .as_f64() + .filter(|r| r.fract() == 0.0 && (1.0..=MAX_ARTBOARDS as f64).contains(r)) + .map(|r| r as u32) + .ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be a whole number from 1 to {MAX_ARTBOARDS}")))? + } "spacing" => { self.spacing = v .as_f64() diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index edf27aaf2a..a438430379 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -161,6 +161,8 @@ fn ppi_overprint_preview_and_bad_params() { json!({"artboardLayout": {"layout": "spiral"}}), json!({"artboardLayout": {"columns": 0}}), json!({"artboardLayout": {"rows": 0}}), + json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1.5}}), + json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1001}}), json!({"artboardLayout": {"tiles": 2}}), json!({"units": "furlongs"}), json!({"width": 160000, "artboards": 1000}), diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 774ff2b165..e1288b233c 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -483,7 +483,7 @@ fn file_new_takes_the_rows_of_a_grid_by_column() { assert_eq!((by_row.rows, by_row.to_json()["artboardLayout"].get("rows")), (0, None), "{layout}"); } let e = s.execute("file.new", &json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0}})).unwrap_err().to_string(); - assert!(e.contains("rows must be 1 or more"), "{e}"); + assert!(e.contains("rows must be a whole number from 1 to 1000"), "{e}"); for layout in ["gridByRow", "row", "column"] { let e = s.execute("file.new", &json!({"artboardLayout": {"layout": layout, "rows": 2}})).unwrap_err().to_string(); assert!(e.contains("rows needs the gridByColumn layout"), "{layout}: {e}"); diff --git a/docs/mcp.md b/docs/mcp.md index 9371a4857d..3b2ec0f6b1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -8918,7 +8918,7 @@ and goes back to Document Setup, whose OK runs `document.setup`; its Cancel goes `file.new` takes everything New Document sets: `preset` (a name from `file.newPresets`), `name`, `width`/`height` (points, or lengths such as `"210 mm"`), `units`, `orientation`, `artboards` with `artboardLayout {layout, columns, -rows, spacing, rightToLeft}` (`rows` gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is +rows, spacing, rightToLeft}` (`rows`, a whole number from 1 to 1000, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is an error with another layout; a preset keeps the rows, and `file.newPresets` lists them as set even when there are fewer artboards, until `columns` without `rows`, or another layout, is given; New Document's Columns shows the columns the rows give the current number of artboards, and New Document drops the rows when Columns or the layout changes), From 74fefce46fdeaf76acb857d58f0bce7f77b71ba8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 18:50:26 -0800 Subject: [PATCH 009/264] Scripts: assigning selected keeps other objects' direct-selected anchors Setting a page item's `selected` rebuilt the selection with select.set, which selects every object whole, so the direct-selected anchors and segments of the other selected objects were lost. When another object has some, the selection is now rebuilt the way an edit restores it, with only the item added or removed. --- crates/engine/src/script/dom.rs | 22 +++++++++++++++++++++- crates/engine/src/tests/script_dom.rs | 15 +++++++++++++++ docs/mcp.md | 3 ++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index dd47eb00f3..6544309c8c 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -1373,7 +1373,27 @@ fn item_set_selected(h: &Host, a: &[Data]) -> Answer { } else { ids.retain(|i| *i != item.id); } - set_selection(h, item.doc, ids) + // The direct-selected anchors and segments of the other objects stay selected. + let partial = with_doc(h, item.doc, |_, st| { + let sel = &st.selection; + let plain = sel.target.is_none() && sel.symbol_part.is_none() && sel.on_path_member.is_none() && sel.slices.is_empty(); + (plain && ids.iter().any(|i| sel.anchors.contains_key(i) || sel.segments.contains_key(i))).then(|| { + let mut next = sel.clone(); + next.objects.clone_from(&ids); + next.anchors.retain(|i, _| ids.contains(i)); + next.segments.retain(|i, _| ids.contains(i)); + next.key = next.key.filter(|k| ids.contains(k)); + next.key_anchor = next.key_anchor.filter(|(k, _)| ids.contains(k)); + (st.doc.clone(), next) + }) + }); + match partial { + Some((doc, next)) => { + on_doc(h, item.doc.uid, false, |h| restore_selection(h, &doc, &next))?; + Ok(Data::Undefined) + } + None => set_selection(h, item.doc, ids), + } } /// The item's geometric bounds (`visual`: its visible bounds) in document coordinates and the diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index e1288b233c..36a06aa78e 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -536,6 +536,21 @@ fn an_edit_keeps_direct_selected_anchors() { assert!(s.journal.iter().any(|(id, _)| id == "select.anchorsMany"), "the journal holds the restore"); } +#[test] +fn selecting_an_item_keeps_the_direct_selected_anchors_of_others() { + let (mut s, a, b) = doc(); + s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 1]], "mode": "set"})).unwrap(); + s.execute("select.add", &json!({"ids": [b.0]})).unwrap(); + let anchors = s.active().unwrap().selection.anchors.clone(); + assert!(anchors.contains_key(&a)); + log(&mut s, "app.activeDocument.pageItems[1].selected = false;"); + let sel = &s.active().unwrap().selection; + assert_eq!((sel.objects.clone(), sel.anchors.clone()), (vec![a], anchors.clone())); + log(&mut s, "app.activeDocument.pageItems[1].selected = true;"); + let sel = &s.active().unwrap().selection; + assert_eq!((sel.objects.clone(), sel.anchors.get(&a)), (vec![a, b], anchors.get(&a))); +} + #[test] fn an_edit_keeps_the_order_of_a_mixed_selection() { let (mut s, a, b) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 3b2ec0f6b1..e59fa68b9d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2672,7 +2672,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `Not found`; and `app.activeDocument` with no document open throws `No active document`. `Document.selection` takes one page item, a list of at most 10,000, `null` or `[]`, and an object that cannot be selected throws `Cannot select` with - nothing changed. `getIsFileOpen` compares the path with the open documents' files as text (in a Windows path, + nothing changed. Assigning a page item's `selected` leaves the direct-selected anchors and segments of the other + selected objects selected. `getIsFileOpen` compares the path with the open documents' files as text (in a Windows path, letter case is ignored and `\` matches `/`) and does not resolve the path it is given. A document counts only when the automation read roots allow its file, and that check can look the document's file up on disk. A path with `..`, a network path, a NUL character or more than 4,096 bytes throws an error. Some members the Application, From f31cb42fd8ed8ceaa094d980e010883e1560ee72 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 01:49:59 -0800 Subject: [PATCH 010/264] Scripts: unlisted save, export and open options throw, and an object's own saveAs is not a file write - saveAs, exportFile and app.open throw " has no option " for a property their option class's help page does not list, instead of leaving it out. An undefined property is still left out, and PDFFileOptions also takes its read-only typename and parent. - The script checker no longer reports a file write for saveAs or exportFile called on a variable holding the script's own object literal that defines that method, with `.` or in brackets. It reports it again once the method is assigned or deleted, the object is indexed with a computed key, or another name may hold the object. - The read-only file test checks the open-document grant on its own, with no folder scope that also covers the file. --- crates/engine/src/file_access.rs | 7 ++- crates/engine/src/script/dom/save_open.rs | 22 +++++-- crates/engine/src/tests/script_save_open.rs | 15 ++++- crates/scriptcheck/src/analyze.rs | 54 ++++++++++++++++++ crates/scriptcheck/src/analyze/features.rs | 63 ++++++++++++++++++++- crates/scriptcheck/src/tests.rs | 51 +++++++++++++++++ docs/mcp.md | 5 +- 7 files changed, 203 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/file_access.rs b/crates/engine/src/file_access.rs index 9e05d92ce7..0eeed498e2 100644 --- a/crates/engine/src/file_access.rs +++ b/crates/engine/src/file_access.rs @@ -992,14 +992,17 @@ mod tests { }; let (kept, fresh) = (s(out.clone()), s(base.join("out/new.svg"))); let check = |p: &str| with_script_gate(gate.clone(), || (check_write(p).is_ok(), check_read(p).is_ok())); + // The open document's file is the only grant: no folder scope covers it. + let documents = ScriptGate { write: ScriptScope::default(), documents: vec![kept.clone()], ..gate.clone() }; + let document_write = || with_script_gate(documents.clone(), || check_write(&kept).is_ok()); assert_eq!(check(&kept), (true, true)); + assert!(document_write(), "an open document's file is written"); let mut perms = std::fs::metadata(&out).unwrap().permissions(); perms.set_readonly(true); std::fs::set_permissions(&out, perms.clone()).unwrap(); assert_eq!(check(&kept), (false, true), "a read-only file is read but not written"); assert!(check(&fresh).0, "a new file next to it is written"); - let documents = ScriptGate { documents: vec![kept.clone()], ..gate.clone() }; - assert!(!with_script_gate(documents, || check_write(&kept).is_ok()), "also when it is an open document's file"); + assert!(!document_write(), "also when it is an open document's file"); #[allow(clippy::permissions_set_readonly_false)] perms.set_readonly(false); std::fs::set_permissions(&out, perms).unwrap(); diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index c76ae0f44e..f54c2f3f0b 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -27,10 +27,12 @@ //! and when one of those files may not be written, none of them is. //! - An option the classes here map is applied; a listed option that is not mapped is accepted at //! the default its help page gives and throws an error that says it is not available yet at any -//! other value; a property the help pages do not list is left out. With `pDFPreset` named, a -//! `PDFSaveOptions` option still at a new object's default keeps the preset's value. +//! other value; a property the help pages do not list throws an error that names it, unless it is +//! `undefined`. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default +//! keeps the preset's value. //! - `app.open(file, documentColorSpace?, options?)` takes `options` as a `PDFFileOptions` record: -//! an object with `pageToOpen` and `pDFCropToBox`, used for that call only. +//! an object with `pageToOpen` and `pDFCropToBox`, used for that call only. Any other property +//! but `typename` and `parent` throws the same error, unless it is `undefined`. //! - `app.userInteractionLevel` starts at `UserInteractionLevel.DISPLAYALERTS` in each run. The //! commands a script runs never show a dialog, so the level does not change what they do, and it //! never allows a file the script's grants do not. @@ -131,6 +133,11 @@ fn not_available(class: &str, name: &str) -> HostError { HostError::Error(format!("{class}.{name} is not available yet")) } +/// The error a property that the help page of `class` does not list throws. +fn not_an_option(class: &str, name: &str) -> HostError { + HostError::Error(format!("{class} has no option {name}")) +} + fn whole_in(d: &Data, what: &str, lo: u64, hi: u64) -> std::result::Result { match d { Data::Number(n) => { @@ -522,7 +529,7 @@ fn options_params(class: &OptionClass, d: &Data) -> std::result::Result {} Some(_) => return Err(not_available(class.name, k)), - None => {} + None => return Err(not_an_option(class.name, k)), } } Ok(p) @@ -670,6 +677,9 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { return Err(HostError::Type("open's options must be a PDFFileOptions record".into())); } for (k, v) in items { + if matches!(v, Data::Undefined) { + continue; + } match k.as_str() { "pageToOpen" => { p.insert("page".into(), json!(whole_in(v, "PDFFileOptions.pageToOpen", 1, 1_000_000)?)); @@ -686,7 +696,9 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { }; p.insert("cropTo".into(), json!(crop)); } - _ => {} + // The read-only members the help page lists. + "typename" | "parent" => {} + _ => return Err(not_an_option("PDFFileOptions", k)), } } } diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 8518f14365..9eabe077de 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -64,7 +64,7 @@ fn save_as_export_file_and_open_write_and_read_where_the_script_may() { vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}});\n\ d.saveAs(new File(dir + '/a.svg'));\n\ var o = new PDFSaveOptions(); vc.log([o.typename, o.compatibility, o.preserveEditability]);\n\ - o.compatibility = PDFCompatibility.ACROBAT7; o.viewAfterSaving = false; o.someOtherName = 3;\n\ + o.compatibility = PDFCompatibility.ACROBAT7; o.viewAfterSaving = false; o.pDFXStandardDescription = undefined;\n\ o.colorCompression = 'CompressionQuality.None';\n\ d.saveAs(new File(dir + '/b.pdf'), o); vc.log(d.name);\n\ var p = new ExportOptionsPNG24(); p.horizontalScale = p.verticalScale = 200; p.artBoardClipping = true;\n\ @@ -481,6 +481,12 @@ fn bad_arguments_are_refused_with_an_error() { (format!("app.open({f}, undefined, {{pageToOpen: 0}});"), "from 1"), (format!("app.open({f}, undefined, {{pDFCropToBox: 'art'}});"), "PDFBoxType"), (format!("app.open({f}, undefined, 5);"), "PDFFileOptions"), + (format!("var o = new PDFSaveOptions(); o.trimMark = true; app.activeDocument.saveAs({f}, o);"), "PDFSaveOptions has no option trimMark"), + ( + format!("var p = new ExportOptionsPNG24(); p.transparancy = false; app.activeDocument.exportFile({f}, ExportType.PNG24, p);"), + "ExportOptionsPNG24 has no option transparancy", + ), + (format!("app.open({f}, undefined, {{pageToOpne: 2}});"), "PDFFileOptions has no option pageToOpne"), ("app.userInteractionLevel = 'quiet';".into(), "UserInteractionLevel"), (format!("app.open({});", quoted(&dir.join("x.svg"))), "open needs a File"), ]; @@ -560,7 +566,7 @@ fn open_takes_the_page_and_crop_box_of_its_options() { &mut s, &base, &format!( - "Folder.userData; var g = app.open(new File({}), DocumentColorSpace.CMYK, {{pageToOpen: 2, pDFCropToBox: PDFBoxType.PDFMEDIABOX}});\n\ + "Folder.userData; var g = app.open(new File({}), DocumentColorSpace.CMYK, {{pageToOpen: 2, pDFCropToBox: PDFBoxType.PDFMEDIABOX, typename: 'PDFFileOptions', later: undefined}});\n\ vc.log(g.documentColorSpace);", quoted(&pdf) ), @@ -570,5 +576,10 @@ fn open_takes_the_page_and_crop_box_of_its_options() { assert!(!e.is_empty(), "a page the file does not have"); assert_eq!(s.documents().len(), 2); assert_eq!(s.active().unwrap().doc.artboards.len(), 1, "one page"); + // Options left undefined are left out: the file opens as it does without options. + let undefined = format!("Folder.userData; app.open(new File({}), undefined, {{pageToOpen: undefined, pDFCropToBox: undefined}});", quoted(&pdf)); + logged(&mut s, &base, &undefined); + assert_eq!(s.documents().len(), 3); + assert_eq!(s.active().unwrap().doc.artboards.len(), 2, "both pages"); let _ = std::fs::remove_dir_all(base); } diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 5d01cc8438..6c3177f498 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -495,6 +495,8 @@ struct Saved { shadowed: Option, /// It was a platform name the script had a meaning of its own for. own: bool, + /// What it held in [`Analyzer::writers`], 0 for nothing. + writer: u8, } /// The open brackets and their lines, up to [`crate::Limits::nesting`]; the brackets past that are @@ -566,6 +568,16 @@ struct Analyzer<'s, 'a, 'l> { maybe_files: HashSet, /// `maybe_files` ran out of room: no variable counts as holding a Folder object. maybe_files_full: bool, + /// The variables holding an object literal of the script's own that defines a method named as a + /// document method that writes a file (`{saveAs: …}`), each with a bit per method it defines (bit + /// `i` for `catalog::DOM_FILE_WRITES[i]`): a call of that method on them writes nothing. + writers: HashMap, + /// The object literals being assigned to a variable, the innermost last, each with the bracket + /// depth inside its `{`, up to [`crate::Limits::nesting`] of them. + objects: Vec<(String, usize)>, + /// What the receiver before the last `[` read defines in [`Analyzer::writers`], 0 for a receiver + /// that is not such a variable. + index_receiver: u8, /// The platform names ([`platform_name`]) the script declares or assigns a meaning of its own /// for: they no longer stand for the platform's objects. own_names: HashSet, @@ -637,6 +649,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { folders: known.folders.clone(), maybe_files: known.files.difference(&known.folders).cloned().collect(), maybe_files_full: false, + writers: HashMap::new(), + objects: vec![], + index_receiver: 0, own_names: HashSet::new(), scopes: vec![], declared, @@ -742,6 +757,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.group_step(&t, started, before); self.paren_step(&t, before); self.assignment(&t, started); + self.object_key(&t); self.features(&t); self.newer(&t); self.module_check(&t); @@ -841,6 +857,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { fn bind(&mut self, name: String, path: String) { self.files.remove(&name); self.folders.remove(&name); + self.writers.remove(&name); if self.bound.contains_key(&name) || self.acc.room(self.bound.len()) { self.bound.insert(name, path); } @@ -850,6 +867,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { fn hold_file(&mut self, name: String, folder: bool) { self.bound.remove(&name); self.folders.remove(&name); + self.writers.remove(&name); if !folder && !self.maybe_files.contains(&name) { if self.acc.room(self.maybe_files.len()) { self.maybe_files.insert(name.clone()); @@ -973,6 +991,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { local: false, shadowed, own: self.own_names.contains(name), + writer: self.writers.get(name).copied().unwrap_or(0), } } @@ -1007,6 +1026,11 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else { self.own_names.remove(&name); } + if saved.writer != 0 { + self.writers.insert(name.clone(), saved.writer); + } else { + self.writers.remove(&name); + } if let Some(hidden) = saved.shadowed && let Some(i) = catalog::DOM_ROOTS.iter().position(|r| *r == name) && let Some(s) = self.shadowed.get_mut(i) @@ -1056,6 +1080,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.bound.remove(name); self.files.remove(name); self.folders.remove(name); + self.writers.remove(name); self.hide_root(name); } @@ -1249,6 +1274,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { local: false, shadowed: catalog::DOM_ROOTS.contains(&name).then_some(true), own: platform_name(name), + writer: 0, }; let outside = std::mem::replace(&mut c.saved, empty); if let Some(scope) = self.scopes.last_mut() { @@ -1272,6 +1298,12 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.start_value(a.name, Operand::Done(Held::File { folder: false })); } else if !a.after_new && t.is("(") { self.start_group(a.name); + } else if !a.after_new && t.is("{") { + // An object literal: its keys are read at the depth inside its `{` ([`Self::object_key`]). + self.unbind(&a.name); + if self.objects.len() < self.acc.limits.nesting { + self.objects.push((a.name, self.depth())); + } } else { self.unbind(&a.name); } @@ -1310,6 +1342,28 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } + /// `t` in an object literal assigned to a variable: a `:` directly inside its braces after a key + /// that names a document method writing a file (`{saveAs: …}`, `{'exportFile': …}`) makes the + /// variable one of [`Analyzer::writers`]. A closing brace ends the literals it closes. + fn object_key(&mut self, t: &Sig<'s>) { + let depth = self.depth(); + while self.objects.pop_if(|(_, d)| *d > depth).is_some() {} + if !t.is(":") { + return; + } + let [h0, h1, ..] = self.h; + let Some(name) = self.objects.last().filter(|(_, d)| *d == depth).map(|(n, _)| n.clone()) else { return }; + let key = match h0 { + Some(k) if k.kind == T::Ident => Cow::Borrowed(k.text), + Some(k) if k.kind == T::Str => Cow::Owned(unquote(k.text, 32)), + _ => return, + }; + let Some(i) = catalog::DOM_FILE_WRITES.iter().position(|m| *m == key.as_ref()) else { return }; + if (is(h1, "{") || is(h1, ",")) && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) { + *self.writers.entry(name).or_insert(0) |= 1 << i; + } + } + /// The variable that `t` changes to a number or a string, nothing the check follows, and whether /// the change waits for the value on the right. `name += …` and the other compound assignments /// (ECMA-262 3rd edition, section 11.13.2) store their result after that value is read, so the diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 7eb89a1fbe..d17a580560 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -84,6 +84,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } } + self.writer_use(t); match t.kind { T::Ident => self.name(t, line), T::Punct => self.punct(t, line), @@ -272,6 +273,8 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { let name = h0.map(|s| unquote(s.text, 16)).unwrap_or_default(); self.setter(&name, h2, h3, line); } + // `local['saveAs']`: what the object before the bracket defines, for a call that may follow. + "[" => self.index_receiver = self.writer_bits(h0, h1), "(" => self.call(line), // `Name.prototype["+"] = …` defines an operator. "=" => { @@ -292,8 +295,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { // `doc['saveAs'](f)`: a document method named by a string literal in brackets. if is(h0, "]") && is(h2, "[") - && let Some(name) = h1.filter(|s| s.kind == T::Str) - && catalog::DOM_FILE_WRITES.contains(&unquote(name.text, 32).as_str()) + && let Some(method) = h1.filter(|s| s.kind == T::Str).map(|s| unquote(s.text, 32)) + && catalog::DOM_FILE_WRITES.contains(&method.as_str()) + && !Self::defines(self.index_receiver, &method) { self.acc.feature(FeatureId::FileWrite, line); self.acc.outside(OutsideId::FilesWritten, line, None); @@ -313,7 +317,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.acc.feature(FeatureId::FileDialog, line); } else if catalog::FOLDER_READS.contains(&n) || (file && catalog::FILE_READS.contains(&n)) { self.acc.feature(FeatureId::FileRead, line); - } else if (file && catalog::FILE_WRITES.contains(&n)) || catalog::DOM_FILE_WRITES.contains(&n) { + } else if (file && catalog::FILE_WRITES.contains(&n)) + || (catalog::DOM_FILE_WRITES.contains(&n) && !Self::defines(self.writer_bits(h2, h3), n)) + { self.acc.feature(FeatureId::FileWrite, line); self.acc.outside(OutsideId::FilesWritten, line, None); } else if n == catalog::EXECUTE { @@ -336,6 +342,57 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } + /// The methods that `receiver`, which `before` comes before, defines when it is a variable holding + /// an object literal of the script's own ([`Analyzer::writers`]), not a property of the same name; + /// 0 for anything else. A receiver the check does not follow may be a document. + fn writer_bits(&self, receiver: Option>, before: Option>) -> u8 { + match receiver { + Some(r) if r.kind == T::Ident && !member_mark(before) => self.writers.get(r.text).copied().unwrap_or(0), + _ => 0, + } + } + + /// A variable of [`Analyzer::writers`] used before `t` in any way but a member (`local.name`, + /// `local['name']`) or an assignment to it ([`Analyzer::assignment`]), or whose `saveAs` or + /// `exportFile` is assigned: another name may hold its object, or its methods may change, so its + /// own methods are no longer known (`var b = local`, `f(local)`, `local.saveAs = w`, + /// `local[k] = w`, `delete local.saveAs`). + fn writer_use(&mut self, t: &Sig<'s>) { + let [h0, h1, h2, h3] = self.h; + let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before) != 0).map(|s| s.text); + let changes = t.kind == T::Punct && (t.text == "=" || COMPOUND.contains(&t.text) || matches!(t.text, "++" | "--")); + let key = t.is(":") && (is(h1, "{") || is(h1, ",")); + let escaped = if word(h0, "delete") { + // `delete local…` + writer(Some(*t), h0) + } else if let Some(name) = writer(h0, h1) { + // `local` followed by anything but a member, its own assignment or an object key's `:`. + (!t.is(".") && !t.is("[") && !t.is("=") && !key).then_some(name) + } else if is(h1, ".") && changes && h0.is_some_and(|m| catalog::DOM_FILE_WRITES.contains(&m.text)) { + // `local.saveAs = …` + writer(h2, h3) + } else if is(h0, "[") { + // `local[k]` with a key that is not a string literal. + writer(h1, h2).filter(|_| t.kind != T::Str) + } else if is(h1, "[") && h0.is_some_and(|s| s.kind == T::Str) { + // `local['name' + k]`. + writer(h2, h3).filter(|_| !t.is("]")) + } else if is(h0, "]") && is(h2, "[") && changes && h1.is_some_and(|m| catalog::DOM_FILE_WRITES.contains(&unquote(m.text, 32).as_str())) { + // `local['saveAs'] = …` + writer(h3, None) + } else { + None + }; + if let Some(name) = escaped { + self.writers.remove(name); + } + } + + /// Whether `bits` ([`Self::writer_bits`]) has `method`: the receiver's own `method` is called. + fn defines(bits: u8, method: &str) -> bool { + catalog::DOM_FILE_WRITES.iter().position(|m| *m == method).is_some_and(|i| bits & (1 << i) != 0) + } + /// Whether `receiver`, which `before` comes before, is a variable holding a File or Folder object /// (not a property of the same name), or a File or Folder object made in place or held in /// grouping parentheses ([`Sig::file`]). diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index e985fa3d0f..9148f0e93f 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -558,6 +558,57 @@ fn save_as_and_export_file_in_brackets_write_a_file() { assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[3, 4][..])]); } +/// `saveAs` and `exportFile` called on an object literal of the script's own that defines them write +/// nothing, with `.` or in brackets. On a document, on a variable the check does not follow, on one +/// assigned something else since, and for a method the literal does not define, they write the file. +#[test] +fn the_scripts_own_save_as_writes_no_file() { + let r = report(concat!( + "var f = new File(p);\n", + "var local = {saveAs: function () {}, 'n': 1};\n", + "local.saveAs(f);\n", + "local['saveAs'](f);\n", + "app.activeDocument.saveAs(f);\n", + "local.exportFile(f);\n", + "other.saveAs(f);\n", + "local = app.activeDocument;\n", + "local.saveAs(f);\n", + "var t = {x: 1, a: ok ? saveAs : 0, 'exportFile': function () {}};\n", + "t['exportFile'](f);\n", + "t.saveAs(f);\n", + "var activeDocument = {saveAs: function () {}};\n", + "app.activeDocument['saveAs'](f);\n", + "app.activeDocument.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[5, 6, 7, 9, 12, 14, 15][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[5, 6, 7, 9, 12, 14, 15][..])]); +} + +/// Once the script replaces or deletes such a method, indexes the object with a computed key, or +/// lets another name hold the object, its `saveAs` may write a file again. +#[test] +fn a_changed_or_shared_own_save_as_writes_a_file() { + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {}}, b = {saveAs: function () {}}, c = {saveAs: function () {}};\n", + "var d = {saveAs: function () {}}, e = {saveAs: function () {}}, g = {saveAs: function () {}};\n", + "a.saveAs(f); b['saveAs'](f); a.n = 1; a.n;\n", + "a.saveAs = app.activeDocument.saveAs;\n", + "b['saveAs'] = w;\n", + "c[k] = w;\n", + "delete d.saveAs;\n", + "var h = e;\n", + "use(g);\n", + "a.saveAs(f);\n", + "b.saveAs(f);\n", + "c.saveAs(f);\n", + "d.saveAs(f);\n", + "e.saveAs(f);\n", + "g['saveAs'](f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16][..])); +} + /// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing /// them and setting them on another object does not. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 4e00790a15..5dd133dc00 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2726,8 +2726,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot `compressed`), and writes one file: the active artboard with `artBoardClipping`, otherwise the bounds of the visible art. An SVG with `embedRasterImages` false also writes the document's embedded images beside it, and when one of those files may not be written, none of them is. A listed option that is not mapped is accepted at its help page's default, and any other value throws - an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`; properties the help - pages do not list are left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default + an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`. A property the help + pages do not list throws an error that names it (`PDFFileOptions` also accepts its read-only `typename` and + `parent`), and an `undefined` one is left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default keeps the preset's value. A bad value throws an error before anything is written. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. From b82dddc71da4b3b4a9508a2add57df9665bbf1a5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 01:54:03 -0800 Subject: [PATCH 011/264] Docs: G6 and M13 list Document.saveAs, Document.exportFile and app.open --- docs/gaps.md | 3 ++- docs/roadmap.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index cd23b3096c..cecbd9c4c4 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -809,7 +809,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Missing:** the rest of the document object model for scripts (layers, artboards, paths, type and the other classes) and the `#engine` script directive (#1183 is open). Scripts have `app`, the open documents, new - documents, each document's selection and its page items. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` + documents, each document's selection and its page items, and save, export and open documents with + `Document.saveAs`, `Document.exportFile` and `app.open`. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` runs a script in a named engine whose globals last between runs, File › Scripts lists the scripts of the Scripts folder, and Window › Script Console shows their output, errors and run reports. Actions, Batch, Variables (text, visibility, image and graph), data set CSV import and diff --git a/docs/roadmap.md b/docs/roadmap.md index 3ddf3459a4..40c4518f52 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -196,7 +196,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG ``/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | | M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View (hiding the guides and the grid while it is on, #8363), middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 | | M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color (manual picker and canvas eyedropper from original pixels, no canvas View change, missed pixels keep the pick armed, Preview/Undo retained; #8068), Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 | -| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items; the rest of the script document model (layers, artboards, paths, type and the other classes) and batch work remain | 18–27 | +| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and save, export and open documents with `Document.saveAs`, `Document.exportFile` and `app.open`; the rest of the script document model (layers, artboards, paths, type and the other classes) and batch work remain | 18–27 | | M14 | 1.0 polish (Asset Export tile context menus implemented for G12; preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset , UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Graphic Styles item context menus in thumbnail and list views with Options, Duplicate, Delete, Redefine, Break Link (#8755); Appearance panel row context menus for strokes, fills, effects, and root object row (Duplicate, Delete, Hide/Show, Edit Effect…, Clear Appearance, Reduce to Basic Appearance) with secondary click row selection (#8809); Character Styles and Paragraph Styles item context menus (panels::text_styles::tests::right_click_context_menu_*); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 | | — | Interaction fidelity pass (every tool's modifiers, Properties panel per context, isolation, nuance; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed) | ⬜ (new ruler-guide Alt orientation implemented; existing-guide Escape cancellation regression-tested; broader pass remains) | 60–90 | | — | Hardening at scale (big-file corpus, fuzzing, cross-platform + browser QA) | 🟡 PngSuite integrity and bounded fetching verified (#1729); real-world corpus/manual QA remain | 50–80 | From 3a80afcb37c0a9236ba3a7c342c734e9b98a2911 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 01:59:25 -0800 Subject: [PATCH 012/264] Scripts: only a function expression makes an object's saveAs its own The script checker treats a saveAs or exportFile key of the script's own object literal as the script's own method only when its value is a function expression. A key holding another value, such as a document's method, is still reported as a file write when called, and so is a key whose last value in the literal is not a function expression. --- crates/scriptcheck/src/analyze.rs | 23 ++++++++++++++++------- crates/scriptcheck/src/tests.rs | 8 ++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 6c3177f498..dae8816eb1 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -1342,24 +1342,33 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } - /// `t` in an object literal assigned to a variable: a `:` directly inside its braces after a key - /// that names a document method writing a file (`{saveAs: …}`, `{'exportFile': …}`) makes the - /// variable one of [`Analyzer::writers`]. A closing brace ends the literals it closes. + /// `t` in an object literal assigned to a variable: a function expression directly inside its + /// braces as the value of a key that names a document method writing a file + /// (`{saveAs: function …}`, `{'exportFile': function …}`) makes the variable one of + /// [`Analyzer::writers`], and any other value of that key (`{saveAs: d.saveAs}`) takes the method + /// out again. A closing brace ends the literals it closes. fn object_key(&mut self, t: &Sig<'s>) { let depth = self.depth(); while self.objects.pop_if(|(_, d)| *d > depth).is_some() {} - if !t.is(":") { + let [h0, h1, h2, _] = self.h; + if !is(h0, ":") || !(is(h2, "{") || is(h2, ",")) { return; } - let [h0, h1, ..] = self.h; let Some(name) = self.objects.last().filter(|(_, d)| *d == depth).map(|(n, _)| n.clone()) else { return }; - let key = match h0 { + let key = match h1 { Some(k) if k.kind == T::Ident => Cow::Borrowed(k.text), Some(k) if k.kind == T::Str => Cow::Owned(unquote(k.text, 32)), _ => return, }; let Some(i) = catalog::DOM_FILE_WRITES.iter().position(|m| *m == key.as_ref()) else { return }; - if (is(h1, "{") || is(h1, ",")) && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) { + if !t.word("function") { + let left = self.writers.get(&name).map_or(0, |bits| bits & !(1 << i)); + if left == 0 { + self.writers.remove(&name); + } else { + self.writers.insert(name, left); + } + } else if self.writers.contains_key(&name) || self.acc.room(self.writers.len()) { *self.writers.entry(name).or_insert(0) |= 1 << i; } } diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 9148f0e93f..8d6bac9fa0 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -585,7 +585,8 @@ fn the_scripts_own_save_as_writes_no_file() { } /// Once the script replaces or deletes such a method, indexes the object with a computed key, or -/// lets another name hold the object, its `saveAs` may write a file again. +/// lets another name hold the object, its `saveAs` may write a file again, and so may a `saveAs` key +/// whose last value in the literal is not a function expression. #[test] fn a_changed_or_shared_own_save_as_writes_a_file() { let r = report(concat!( @@ -605,8 +606,11 @@ fn a_changed_or_shared_own_save_as_writes_a_file() { "d.saveAs(f);\n", "e.saveAs(f);\n", "g['saveAs'](f);\n", + "var m = {saveAs: d.saveAs}, n = {saveAs: function () {}, saveAs: d.saveAs};\n", + "m.saveAs(f);\n", + "n.saveAs(f);\n", )); - assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16][..])); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16, 18, 19][..])); } /// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing From 5f444df2957c0abdad17d6b37ab7063104c7b322 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 02:48:26 -0800 Subject: [PATCH 013/264] Save: a refused file ends a save of several files after the writer refuses it When the file access in force refuses one of the files a save writes, the save gives that file to its writer for the error, as before, and then returns the error even when the writer did not refuse it, so the other files are not written. --- crates/engine/src/cmd/fileio/save.rs | 2 + crates/engine/src/tests/script_save_open.rs | 41 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index 94187808c6..550b52f414 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -1078,6 +1078,8 @@ impl SaveJob { && let Some((p, bytes)) = files.iter().find(|(p, _)| super::may_write(p).is_err()) { write(p, bytes)?; + // A writer that does not check the file access writes none of the others. + return Err(super::may_write(p).err().unwrap_or_else(|| crate::EngineError::Other(format!("file access denied: {p}")))); } for (i, (p, bytes)) in files.iter().enumerate() { if i == 0 { diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 9eabe077de..126c7c3947 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -207,6 +207,47 @@ fn a_save_writes_nothing_when_one_of_its_files_is_refused() { let _ = std::fs::remove_dir_all(base); } +/// When the writer a save is given does not check the file access itself, a save of several files +/// still writes none of them after the refused one. +#[test] +fn a_refused_file_stops_a_save_whose_writer_does_not_check() { + use crate::cmd::fileio::{SaveMode, save_job, save_plan}; + use crate::file_access::{ScriptGate, ScriptScope, with_script_gate}; + let base = folder("unchecked"); + let dir = base.join("outside"); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap(); + s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 20})).unwrap(); + let params = json!({"path": dir.join("a.eps").to_string_lossy(), "format": "eps", "useArtboards": true}); + let plan = save_plan(&s, SaveMode::SaveAs, ¶ms).unwrap(); + let job = save_job(&mut s, plan).unwrap(); + let gate = ScriptGate { read: ScriptScope::default(), write: ScriptScope::of_folder(&dir), documents: vec![], held: vec![], also: None }; + let (mut refused, mut written) = (None, vec![]); + let make_read_only = |paths: &[&str]| { + let last = paths.last().map(|p| p.to_string()).unwrap(); + std::fs::write(&last, b"").unwrap(); + let mut perms = std::fs::metadata(&last).unwrap().permissions(); + perms.set_readonly(true); + std::fs::set_permissions(&last, perms).unwrap(); + refused = Some(last); + None + }; + let r = with_script_gate(gate, || { + job.write_unless(make_read_only, |p, _| { + written.push(p.to_string()); + Ok(()) + }) + }); + assert!(r.is_err(), "{r:?}"); + let refused = refused.unwrap(); + assert_eq!(written, std::slice::from_ref(&refused), "only the refused file went to the writer"); + let mut perms = std::fs::metadata(&refused).unwrap().permissions(); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + std::fs::set_permissions(&refused, perms).unwrap(); + let _ = std::fs::remove_dir_all(base); +} + /// Every path goes through the script's file grants, as a `File` opened for reading or writing. #[test] fn save_as_export_file_and_open_refuse_paths_outside_the_grants() { From c4edd76fc8b929b5dd86ddfb29d01e3197dc1d27 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 03:00:50 -0800 Subject: [PATCH 014/264] Scripts: only a whole var value makes an object's saveAs the script's own The checker treats `x.saveAs(f)` as the script's own method only when `x` was declared by a `var` statement, directly in a function body or the global code, whose first name takes an object literal with a `saveAs` or `exportFile` function as its whole value. The name counts from the end of the statement. - A literal given in a branch (`if (c) var e = {...}`), one the value goes on from (`{...} && doc`), one given by an assignment or to a later name of the statement, and a call inside the literal keep reporting the write. - A function that gives an outer variable another value removes the exemption after the function body. --- crates/scriptcheck/src/analyze.rs | 76 +++++++++++++++++++++++-------- crates/scriptcheck/src/tests.rs | 35 ++++++++++++-- 2 files changed, 88 insertions(+), 23 deletions(-) diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index dae8816eb1..9056752744 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -266,6 +266,20 @@ struct Assign { after_new: bool, } +/// `name = {`: an object literal assigned to a variable. +struct ObjectValue { + name: String, + /// The bracket depth inside its `{`. + depth: usize, + /// The document methods writing a file that it defines with a function expression, a bit each + /// ([`Analyzer::writers`]). + bits: u8, + /// It is the value of the first name a `var` statement declares, and the statement is directly + /// in a function body or the global code, not in a block and not after `if (…)`, `else`, `do` or + /// a loop's parentheses: only then does the variable hold `bits` after it. + whole: bool, +} + /// What a value the check follows holds: a member chain, or a File or Folder object (`folder` when it /// is a Folder object whatever the path names: [`Operand::file_step`]). enum Held { @@ -572,9 +586,12 @@ struct Analyzer<'s, 'a, 'l> { /// document method that writes a file (`{saveAs: …}`), each with a bit per method it defines (bit /// `i` for `catalog::DOM_FILE_WRITES[i]`): a call of that method on them writes nothing. writers: HashMap, - /// The object literals being assigned to a variable, the innermost last, each with the bracket - /// depth inside its `{`, up to [`crate::Limits::nesting`] of them. - objects: Vec<(String, usize)>, + /// The object literals being assigned to a variable, the innermost last, up to + /// [`crate::Limits::nesting`] of them. + objects: Vec, + /// An object literal whose `}` the last token was, with the methods it defines: the variable + /// holds them when the next token ends the `var` statement's value. + closed: Option<(String, u8)>, /// What the receiver before the last `[` read defines in [`Analyzer::writers`], 0 for a receiver /// that is not such a variable. index_receiver: u8, @@ -651,6 +668,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { maybe_files_full: false, writers: HashMap::new(), objects: vec![], + closed: None, index_receiver: 0, own_names: HashSet::new(), scopes: vec![], @@ -1026,8 +1044,11 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else { self.own_names.remove(&name); } - if saved.writer != 0 { - self.writers.insert(name.clone(), saved.writer); + // An outer variable the body assigned keeps only the methods it still has: the body may have + // given it another value. + let writer = if saved.local { saved.writer } else { saved.writer & self.writers.get(&name).copied().unwrap_or(0) }; + if writer != 0 { + self.writers.insert(name.clone(), writer); } else { self.writers.remove(&name); } @@ -1301,8 +1322,15 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else if !a.after_new && t.is("{") { // An object literal: its keys are read at the depth inside its `{` ([`Self::object_key`]). self.unbind(&a.name); + let [_, _, declaration, before] = self.h; + let depth = self.depth(); + let body = self.scopes.last().map_or(0, |s| s.depth); + let starts = before.is_none() + || [";", "{", "}"].iter().any(|p| is(before, p)) + || (declaration.is_some_and(|d| d.nl) && !is(before, ")") && !word(before, "else") && !word(before, "do")); + let whole = word(declaration, "var") && starts && depth.checked_sub(1) == Some(body); if self.objects.len() < self.acc.limits.nesting { - self.objects.push((a.name, self.depth())); + self.objects.push(ObjectValue { name: a.name, depth, bits: 0, whole }); } } else { self.unbind(&a.name); @@ -1344,32 +1372,40 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// `t` in an object literal assigned to a variable: a function expression directly inside its /// braces as the value of a key that names a document method writing a file - /// (`{saveAs: function …}`, `{'exportFile': function …}`) makes the variable one of - /// [`Analyzer::writers`], and any other value of that key (`{saveAs: d.saveAs}`) takes the method - /// out again. A closing brace ends the literals it closes. + /// (`{saveAs: function …}`, `{'exportFile': function …}`) counts the method for the literal, and + /// any other value of that key (`{saveAs: d.saveAs}`) takes it out again. A closing brace ends + /// the literals it closes. The variable of a [`ObjectValue::whole`] literal joins + /// [`Analyzer::writers`] only when the token after its `}` ends the value (`;`, `,` or a line + /// break), so a call inside the literal, and a value that goes on (`{…} && d`), see the variable + /// as it was. fn object_key(&mut self, t: &Sig<'s>) { + if let Some((name, bits)) = self.closed.take() + && (t.is(";") || t.is(",") || (t.nl && !goes_on_with(t))) + && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) + { + self.writers.insert(name, bits); + } let depth = self.depth(); - while self.objects.pop_if(|(_, d)| *d > depth).is_some() {} + while let Some(o) = self.objects.pop_if(|o| o.depth > depth) { + if o.whole && o.bits != 0 && o.depth == depth.saturating_add(1) { + self.closed = Some((o.name, o.bits)); + } + } let [h0, h1, h2, _] = self.h; if !is(h0, ":") || !(is(h2, "{") || is(h2, ",")) { return; } - let Some(name) = self.objects.last().filter(|(_, d)| *d == depth).map(|(n, _)| n.clone()) else { return }; let key = match h1 { Some(k) if k.kind == T::Ident => Cow::Borrowed(k.text), Some(k) if k.kind == T::Str => Cow::Owned(unquote(k.text, 32)), _ => return, }; let Some(i) = catalog::DOM_FILE_WRITES.iter().position(|m| *m == key.as_ref()) else { return }; - if !t.word("function") { - let left = self.writers.get(&name).map_or(0, |bits| bits & !(1 << i)); - if left == 0 { - self.writers.remove(&name); - } else { - self.writers.insert(name, left); - } - } else if self.writers.contains_key(&name) || self.acc.room(self.writers.len()) { - *self.writers.entry(name).or_insert(0) |= 1 << i; + let Some(o) = self.objects.last_mut().filter(|o| o.depth == depth) else { return }; + if t.word("function") { + o.bits |= 1 << i; + } else { + o.bits &= !(1 << i); } } diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 8d6bac9fa0..8140371f93 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -591,8 +591,8 @@ fn the_scripts_own_save_as_writes_no_file() { fn a_changed_or_shared_own_save_as_writes_a_file() { let r = report(concat!( "var f = new File(p);\n", - "var a = {saveAs: function () {}}, b = {saveAs: function () {}}, c = {saveAs: function () {}};\n", - "var d = {saveAs: function () {}}, e = {saveAs: function () {}}, g = {saveAs: function () {}};\n", + "var a = {saveAs: function () {}}; var b = {saveAs: function () {}}; var c = {saveAs: function () {}};\n", + "var d = {saveAs: function () {}}; var e = {saveAs: function () {}}; var g = {saveAs: function () {}};\n", "a.saveAs(f); b['saveAs'](f); a.n = 1; a.n;\n", "a.saveAs = app.activeDocument.saveAs;\n", "b['saveAs'] = w;\n", @@ -606,13 +606,42 @@ fn a_changed_or_shared_own_save_as_writes_a_file() { "d.saveAs(f);\n", "e.saveAs(f);\n", "g['saveAs'](f);\n", - "var m = {saveAs: d.saveAs}, n = {saveAs: function () {}, saveAs: d.saveAs};\n", + "var m = {saveAs: d.saveAs}; var n = {saveAs: function () {}, saveAs: d.saveAs};\n", "m.saveAs(f);\n", "n.saveAs(f);\n", )); assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16, 18, 19][..])); } +/// Only a `var` statement directly in a function body or the global code that gives its first name +/// the literal as its whole value makes the literal's `saveAs` the script's own, from the end of the +/// statement. A literal given in a branch, one the value goes on from, one given by an assignment +/// or to a later name of the statement, a call inside the literal, and a variable a function gave +/// another value keep reporting the write. +#[test] +fn only_a_whole_var_value_makes_save_as_the_scripts_own() { + let r = report(concat!( + "var f = new File(p);\n", + "var d = {saveAs: function () {}};\n", + "function choose() { d = null; d = app.activeDocument; }\n", + "d.saveAs(f);\n", + "var e = app.activeDocument;\n", + "if (flag) var e = {saveAs: function () {}};\n", + "e.saveAs(f);\n", + "if (flag) { var e2 = {saveAs: function () {}}; }\n", + "e2.saveAs(f);\n", + "var g = {saveAs: function () {}} && app.activeDocument;\n", + "g.saveAs(f);\n", + "var h = app.activeDocument;\n", + "h = {saveAs: function () {}, value: h.saveAs(f)};\n", + "var k = {saveAs: function () {}, value: k.saveAs(f)};\n", + "k.saveAs(f);\n", + "var x = 1, y = {saveAs: function () {}};\n", + "y.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7, 9, 11, 13, 14, 17][..])); +} + /// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing /// them and setting them on another object does not. #[test] From ff4fc193f8e438256a720b52932613f179e4ab6f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 03:08:00 -0800 Subject: [PATCH 015/264] Scripts: a later saveAs value in brackets ends the exemption A literal such as `{saveAs: function () {}, saveAs: (doc.saveAs)}` kept the first key's exemption, because the value's opening bracket had already raised the depth when the key was read. The key is now read at the depth outside that bracket, so the later value replaces the function and `n['saveAs'](f)` is reported as a file write. --- crates/scriptcheck/src/analyze.rs | 4 +++- crates/scriptcheck/src/tests.rs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 9056752744..bb10272e62 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -1401,7 +1401,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { _ => return, }; let Some(i) = catalog::DOM_FILE_WRITES.iter().position(|m| *m == key.as_ref()) else { return }; - let Some(o) = self.objects.last_mut().filter(|o| o.depth == depth) else { return }; + // A value that starts with a bracket has opened it already: the key is at the depth outside it. + let at = if t.is("(") || t.is("[") || t.is("{") { depth.saturating_sub(1) } else { depth }; + let Some(o) = self.objects.last_mut().filter(|o| o.depth == at) else { return }; if t.word("function") { o.bits |= 1 << i; } else { diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 8140371f93..bc03f6ab07 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -609,8 +609,11 @@ fn a_changed_or_shared_own_save_as_writes_a_file() { "var m = {saveAs: d.saveAs}; var n = {saveAs: function () {}, saveAs: d.saveAs};\n", "m.saveAs(f);\n", "n.saveAs(f);\n", + "var q = {saveAs: function () {}, saveAs: (d.saveAs)}; var s = {saveAs: function () {}, saveAs: [w][0]};\n", + "q['saveAs'](f);\n", + "s.saveAs(f);\n", )); - assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16, 18, 19][..])); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16, 18, 19, 21, 22][..])); } /// Only a `var` statement directly in a function body or the global code that gives its first name From 9034e0d6d8b20307614dcab0b28e4d6a691a17d6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 03:20:43 -0800 Subject: [PATCH 016/264] Scripts: a saveAs value that goes on after the function body writes a file The script checker treats a saveAs or exportFile key of the script's own object literal as the script's own method only when the key's whole value is one function expression: `function`, an optional name, the parameters and the body, followed by `,` or the literal's closing brace. A value that goes on after the body, such as `function () {} && doc.saveAs`, a call of the function or a conditional, leaves the method reported as a file write. The variable takes the literal's methods before the token after the literal closes a function body, so a literal given to the body's own variable on the body's last line no longer hides a save on the outer variable of the same name. --- crates/scriptcheck/src/analyze.rs | 92 ++++++++++++++++++++++++------- crates/scriptcheck/src/tests.rs | 27 +++++++++ 2 files changed, 98 insertions(+), 21 deletions(-) diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index bb10272e62..0e355d94f2 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -271,13 +271,58 @@ struct ObjectValue { name: String, /// The bracket depth inside its `{`. depth: usize, - /// The document methods writing a file that it defines with a function expression, a bit each - /// ([`Analyzer::writers`]). + /// The document methods writing a file that it defines with a single function expression as the + /// key's whole value, a bit each ([`Analyzer::writers`]). bits: u8, /// It is the value of the first name a `var` statement declares, and the statement is directly /// in a function body or the global code, not in a block and not after `if (…)`, `else`, `do` or /// a loop's parentheses: only then does the variable hold `bits` after it. whole: bool, + /// The bit of the method whose value is being read, and how far that value has been read. + value: Option<(u8, Value)>, +} + +/// How far the value of an object literal's key that names a document method writing a file has been +/// read, by the tokens directly inside the literal's braces. +#[derive(Clone, Copy, PartialEq, Eq)] +enum Value { + /// `function`. + Function, + /// The function expression's name. + Name, + /// The `(` of its parameters. + Params, + /// The `{` of its body: the value is the function expression when `,` or the literal's `}` comes + /// next. + Body, + /// Anything else, or anything after the body. + Other, +} + +impl ObjectValue { + /// `t`, a token directly inside the literal's braces: a `,` or the closing `}` ends the value + /// being read, and gives the literal the method only when the value is a single function + /// expression (`function () {} && d.saveAs`, `function () {}(f)` and `function () {}.call` give + /// it nothing). + fn step(&mut self, t: &Sig) { + let Some((bit, value)) = self.value else { return }; + if t.is(",") || t.is("}") { + if value == Value::Body { + self.bits |= bit; + } else { + self.bits &= !bit; + } + self.value = None; + return; + } + let next = match value { + Value::Function if t.kind == T::Ident => Value::Name, + Value::Function | Value::Name if t.is("(") => Value::Params, + Value::Params if t.is("{") => Value::Body, + _ => Value::Other, + }; + self.value = Some((bit, next)); + } } /// What a value the check follows holds: a member chain, or a File or Folder object (`folder` when it @@ -753,6 +798,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { // `t` ends, holds the value, or nothing the check follows, before `t` starts a member chain or // closes a function body. self.settle_groups(&t); + self.settle_literal(&t); // A line break ends a `var` statement when it is outside the statement's brackets, and the // tokens on either side of it don't go on with the expression. if t.nl && self.var_depth == Some(self.depth()) && !goes_on_after(self.h[0]) && !goes_on_with(&t) { @@ -775,7 +821,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.group_step(&t, started, before); self.paren_step(&t, before); self.assignment(&t, started); - self.object_key(&t); + self.object_key(&t, before); self.features(&t); self.newer(&t); self.module_check(&t); @@ -1330,7 +1376,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { || (declaration.is_some_and(|d| d.nl) && !is(before, ")") && !word(before, "else") && !word(before, "do")); let whole = word(declaration, "var") && starts && depth.checked_sub(1) == Some(body); if self.objects.len() < self.acc.limits.nesting { - self.objects.push(ObjectValue { name: a.name, depth, bits: 0, whole }); + self.objects.push(ObjectValue { name: a.name, depth, bits: 0, whole, value: None }); } } else { self.unbind(&a.name); @@ -1370,21 +1416,30 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } - /// `t` in an object literal assigned to a variable: a function expression directly inside its - /// braces as the value of a key that names a document method writing a file - /// (`{saveAs: function …}`, `{'exportFile': function …}`) counts the method for the literal, and - /// any other value of that key (`{saveAs: d.saveAs}`) takes it out again. A closing brace ends - /// the literals it closes. The variable of a [`ObjectValue::whole`] literal joins - /// [`Analyzer::writers`] only when the token after its `}` ends the value (`;`, `,` or a line - /// break), so a call inside the literal, and a value that goes on (`{…} && d`), see the variable - /// as it was. - fn object_key(&mut self, t: &Sig<'s>) { + /// The variable of the [`ObjectValue::whole`] literal whose `}` the token before `t` was joins + /// [`Analyzer::writers`] when `t` ends the value (`;`, `,` or a line break). It is read before `t` + /// closes a function body, so a literal given to the body's own variable stays inside the body. + fn settle_literal(&mut self, t: &Sig<'s>) { if let Some((name, bits)) = self.closed.take() && (t.is(";") || t.is(",") || (t.nl && !goes_on_with(t))) && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) { self.writers.insert(name, bits); } + } + + /// `t` in an object literal assigned to a variable, `before` the bracket depth before `t`: a single + /// function expression directly inside its braces as the whole value of a key that names a + /// document method writing a file (`{saveAs: function … {…}, …}`, `{'exportFile': function … {…}}`) + /// counts the method for the literal, and any other value of that key (`{saveAs: d.saveAs}`, + /// `{saveAs: function () {} && d.saveAs}`) takes it out again ([`ObjectValue::step`]). A closing + /// brace ends the literals it closes. The variable joins [`Analyzer::writers`] only after the + /// literal ([`Analyzer::settle_literal`]), so a call inside the literal, and a value that goes on + /// (`{…} && d`), see the variable as it was. + fn object_key(&mut self, t: &Sig<'s>, before: usize) { + if let Some(o) = self.objects.last_mut().filter(|o| o.depth == before) { + o.step(t); + } let depth = self.depth(); while let Some(o) = self.objects.pop_if(|o| o.depth > depth) { if o.whole && o.bits != 0 && o.depth == depth.saturating_add(1) { @@ -1401,14 +1456,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { _ => return, }; let Some(i) = catalog::DOM_FILE_WRITES.iter().position(|m| *m == key.as_ref()) else { return }; - // A value that starts with a bracket has opened it already: the key is at the depth outside it. - let at = if t.is("(") || t.is("[") || t.is("{") { depth.saturating_sub(1) } else { depth }; - let Some(o) = self.objects.last_mut().filter(|o| o.depth == at) else { return }; - if t.word("function") { - o.bits |= 1 << i; - } else { - o.bits &= !(1 << i); - } + // A value that starts with a bracket has opened it already: the key is at the depth before it. + let Some(o) = self.objects.last_mut().filter(|o| o.depth == before) else { return }; + o.value = Some((1 << i, if t.word("function") { Value::Function } else { Value::Other })); } /// The variable that `t` changes to a number or a string, nothing the check follows, and whether diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index bc03f6ab07..76d78f822b 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -645,6 +645,33 @@ fn only_a_whole_var_value_makes_save_as_the_scripts_own() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7, 9, 11, 13, 14, 17][..])); } +/// A `saveAs` key's value is a method of the script's own only when the whole value is one function +/// expression: a value that goes on after the function's body, and a literal inside another, leave +/// `saveAs` writing the file. A literal given to a function body's own variable at the end of the body +/// leaves the outer variable as it was. +#[test] +fn a_value_that_goes_on_after_the_function_writes_a_file() { + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {} && app.activeDocument.saveAs};\n", + "var b = {saveAs: function () {}(f), n: 1};\n", + "var c = {saveAs: function () {} ? x : y};\n", + "var e = {saveAs: function () {}.call};\n", + "var k = {exportFile: function w(x) { return x; }, saveAs: function () {}};\n", + "var m = {o: {saveAs: function () {}}};\n", + "var q = app.activeDocument; function r() { var q = {saveAs: function () {}}\n", + "}\n", + "a.saveAs(f);\n", + "b.saveAs(f);\n", + "c.saveAs(f);\n", + "e.saveAs(f);\n", + "k.saveAs(f); k.exportFile(f);\n", + "m.saveAs(f);\n", + "q.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[10, 11, 12, 13, 15, 16][..])); +} + /// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing /// them and setting them on another object does not. #[test] From 262090d75a065873e87a84411ccf2b044c785e80 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 11:06:19 -0800 Subject: [PATCH 017/264] Scripts: path points read and set their selection, and guides can be assigned PathPoint.selected and PathItem.selectedPathPoints threw an error that said they were not available yet, and PathItem.guides could only be read. selected now reads PathPointSelection.ANCHORPOINT for a selected anchor point and NOSELECTION otherwise, and assigning either adds or removes the point with select.anchorsMany, keeping the other selected objects and anchors. Every point of a path selected as a whole counts as selected. Direction handles cannot be selected on their own, so the handle values throw an error. selectedPathPoints lists the selected points in pathPoints order. Assigning guides makes the path a guide or a path again with view.guides.make or view.guides.release, keeping the selection; a value that is not a boolean throws a TypeError, and a clipping path cannot be made a guide. A value the point or path already has runs no command. https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/ --- crates/engine/src/script/dom/paths.rs | 146 ++++++++++++++++-- crates/engine/src/tests/script_dom_paths.rs | 99 ++++++++++++ .../tests/it/script_host_vs_scriptcheck.rs | 4 +- docs/gaps.md | 4 +- docs/mcp.md | 26 +++- docs/roadmap.md | 2 +- docs/target-app-parity.md | 2 +- 7 files changed, 254 insertions(+), 29 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 32401db1d0..a3b75cc6ff 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -39,6 +39,11 @@ //! says it is not available yet. `rotateAbout` and `scaleAbout` default to //! `Transformation.CENTER`. A transform that leaves the path where it is (`rotate(360)`, //! `resize(100, 100)`) checks its arguments and runs no command, on a path with no points too. +//! - `PathPoint.selected` and `selectedPathPoints` count every point of a path selected as a whole +//! as a selected anchor point, and not the endpoints of selected segments; a path in a selected +//! group is not selected as a whole. Direction handles are not selected on their own, so +//! `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error that says they are not +//! available yet. A clipping path cannot be made a guide. //! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and //! `changeStrokePattern` given as different values throw an error; gradients move with the art, //! so `changeFillGradients` false throws an error that says it is not available yet. @@ -585,6 +590,39 @@ fn path_guides(h: &super::Host, a: &[Data]) -> Answer { read_path(h, item, |_, n, _| Data::Bool(matches!(n.kind, NodeKind::Path { guide: true, .. }))) } +/// `guides = true` makes the path a guide with `view.guides.make`, and `false` makes it a path again +/// with `view.guides.release`; the selection stays as it was. A clipping path cannot be a guide. +fn path_set_guides(h: &super::Host, a: &[Data]) -> Answer { + let on = boolean(arg(a, 1), "guides")?; + let item = this_path(h, a)?; + let (now, clipping) = read_path(h, item, |_, n, _| match &n.kind { + NodeKind::Path { guide, clipping, .. } => (*guide, *clipping), + _ => (false, false), + })?; + if now == on { + return Ok(Data::Undefined); + } + if !with_doc(h, item.doc, |_, st| editable(&st.doc, item.id)) { + return Err(cannot_edit(item.id)); + } + if !on { + edit_path(h, item, "view.guides.release", json!({}))?; + return Ok(Data::Undefined); + } + if clipping { + return Err(HostError::Error(format!("Cannot make PathItem {} a guide: it is a clipping path", item.id.0))); + } + see_all_points(h); + let kept = h.dom.editing.replace(Some(item)); + let r = on_doc(h, item.doc.uid, true, |h| { + command(h, "select.set", &json!({"ids": [item.id.0]}))?; + command(h, "view.guides.make", &json!({})) + }); + h.dom.editing.set(kept); + r?; + Ok(Data::Undefined) +} + fn path_clipping(h: &super::Host, a: &[Data]) -> Answer { let item = this_path(h, a)?; read_path(h, item, |_, n, _| Data::Bool(matches!(n.kind, NodeKind::Path { clipping: true, .. }))) @@ -1323,6 +1361,86 @@ fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { Ok(path_ref(h, item)) } +/// The point at index `i` of `subs` is a selected anchor point of the path `id` in `sel`: every +/// point of a path selected as a whole is, and of a path with direct-selected anchors only those +/// anchors are. The endpoints of selected segments are not. +fn anchor_selected(sel: &crate::doc::Selection, id: NodeId, subs: &[SubPath], i: usize) -> bool { + if !sel.contains(id) || sel.segments.contains_key(&id) { + return false; + } + match sel.partial(id) { + None => true, + Some(picked) => locate(subs, i).is_some_and(|r| picked.contains(&r)), + } +} + +/// `selected`: `PathPointSelection.ANCHORPOINT` when the point is a selected anchor point +/// ([`anchor_selected`]), otherwise `PathPointSelection.NOSELECTION`. +fn pt_selected(h: &super::Host, a: &[Data]) -> Answer { + let (item, i) = this_point(h, a)?; + let on = read_path(h, item, |st, _, pd| anchor_selected(&st.selection, item.id, &pd.subpaths, i))?; + Ok(Data::String(if on { "PathPointSelection.ANCHORPOINT" } else { "PathPointSelection.NOSELECTION" }.into())) +} + +/// The `PathPointSelection` values that select a point's direction handles. +const HANDLE_SELECTIONS: &[&str] = &["PathPointSelection.LEFTDIRECTION", "PathPointSelection.RIGHTDIRECTION", "PathPointSelection.LEFTRIGHTPOINT"]; + +/// `selected = PathPointSelection.ANCHORPOINT` adds the point to the direct-selected anchors, and +/// `NOSELECTION` removes it, with `select.anchorsMany`; the other selected objects and anchors stay +/// selected. A value the point has already runs no command. Direction handles cannot be selected, +/// so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error. +fn pt_set_selected(h: &super::Host, a: &[Data]) -> Answer { + let on = match arg(a, 1) { + Data::String(s) if s == "PathPointSelection.ANCHORPOINT" => true, + Data::String(s) if s == "PathPointSelection.NOSELECTION" => false, + Data::String(s) if HANDLE_SELECTIONS.contains(&s.as_str()) => { + return Err(HostError::Error(format!("PathPoint.selected = {s} is not available yet: only anchor points can be selected"))); + } + _ => return Err(HostError::Type("selected must be a PathPointSelection value".into())), + }; + let (item, i) = this_point(h, a)?; + let (now, at, selectable) = with_doc(h, item.doc, |_, st| { + let subs = st.doc.node(item.id).and_then(|n| n.path_data()).map_or(&[][..], |pd| &pd.subpaths[..]); + let selectable = crate::cmd::select::is_selectable(&st.doc, st.isolation, &st.doc.locked_artboards(), item.id); + (anchor_selected(&st.selection, item.id, subs, i), locate(subs, i), selectable) + }); + if now == on { + return Ok(Data::Undefined); + } + let Some((s, j)) = at else { return Err(HostError::Error(STALE_POINT.into())) }; + if on && !selectable { + return Err(HostError::Error(format!("Cannot select PathItem {}", item.id.0))); + } + let params = json!({"items": [{"id": item.id.0, "anchors": [[s, j]]}], "mode": if on { "add" } else { "subtract" }}); + on_doc(h, item.doc.uid, false, |h| command(h, "select.anchorsMany", ¶ms))?; + Ok(Data::Undefined) +} + +/// `selectedPathPoints`: the points that are selected anchor points ([`anchor_selected`]), in the +/// order of `pathPoints`. +fn path_selected_points(h: &super::Host, a: &[Data]) -> Answer { + let item = this_path(h, a)?; + let picked: Vec = read_path(h, item, |st, _, pd| { + let sel = &st.selection; + if !sel.contains(item.id) || sel.segments.contains_key(&item.id) { + return Vec::new(); + } + let mut out = Vec::new(); + let mut first = 0; + for (s, sp) in pd.subpaths.iter().enumerate() { + let n = sp.anchors.len(); + out.extend((0..n).filter(|j| sel.partial(item.id).is_none_or(|p| p.contains(&(s, *j)))).map(|j| first + j)); + first += n; + } + out + })?; + h.charge_call(picked.len() as u64)?; + let [high, low] = id_parts(item.id); + let cuts = float(point_cuts(h, item)); + let points = picked.into_iter().map(|i| host_ref("PathPoint", &[float(h.run), float(item.doc.uid), high, low, float(i as u64), cuts])).collect(); + Ok(Data::Array(points)) +} + /// `remove()`: deletes the point; a subpath left with no points goes too. fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { let (item, i) = this_point(h, a)?; @@ -1350,7 +1468,7 @@ pub(super) fn path_item_members(l: &Link) -> Vec<(String, HostMember)> { ("evenodd", property(l, path_evenodd, path_set_evenodd)), ("area", get(l, path_area)), ("length", get(l, path_length)), - ("guides", get(l, path_guides)), + ("guides", property(l, path_guides, path_set_guides)), ("clipping", get(l, path_clipping)), ("setEntirePath", point_method(l, path_set_entire)), ("filled", property(l, path_filled, path_set_filled)), @@ -1368,8 +1486,9 @@ pub(super) fn path_item_members(l: &Link) -> Vec<(String, HostMember)> { ("translate", method(l, path_translate)), ("rotate", method(l, path_rotate)), ("resize", method(l, path_resize)), + ("selectedPathPoints", get(l, path_selected_points)), ]); - m.extend(["selectedPathPoints", "polarity", "resolution"].into_iter().map(|n| later(l, "PathItem", n))); + m.extend(["polarity", "resolution"].into_iter().map(|n| later(l, "PathItem", n))); m } @@ -1411,19 +1530,16 @@ pub(super) fn classes(l: &Link) -> Vec { class( "PathPoint", None, - { - let mut m = named(vec![ - ("typename", typename_of("PathPoint")), - ("parent", point_get(l, pt_parent)), - ("anchor", point_property(l, pt_anchor, pt_set_anchor)), - ("leftDirection", point_property(l, pt_left, pt_set_left)), - ("rightDirection", point_property(l, pt_right, pt_set_right)), - ("pointType", point_property(l, pt_type, pt_set_type)), - ("remove", point_method(l, pt_remove)), - ]); - m.push(later(l, "PathPoint", "selected")); - m - }, + named(vec![ + ("typename", typename_of("PathPoint")), + ("parent", point_get(l, pt_parent)), + ("anchor", point_property(l, pt_anchor, pt_set_anchor)), + ("leftDirection", point_property(l, pt_left, pt_set_left)), + ("rightDirection", point_property(l, pt_right, pt_set_right)), + ("pointType", point_property(l, pt_type, pt_set_type)), + ("selected", property(l, pt_selected, pt_set_selected)), + ("remove", point_method(l, pt_remove)), + ]), None, ), ] diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 2dbf3263b9..abe9a1374a 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -880,3 +880,102 @@ fn many_path_edits_are_one_undo_step() { assert!((node(&s, id).appearance.stroke_width() - 1.0).abs() < 1e-9); } } + +fn selected_anchors(s: &Session, id: NodeId) -> Option> { + s.active().unwrap().selection.anchors.get(&id).map(|set| set.iter().copied().collect()) +} + +#[test] +fn path_point_selected_selects_and_deselects_anchor_points() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + let steps = undo_steps(&s); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], pp = p.pathPoints;\ + vc.log(pp[1].selected); vc.log(p.selectedPathPoints.length);\ + pp[1].selected = PathPointSelection.ANCHORPOINT; pp[2].selected = PathPointSelection.ANCHORPOINT;\ + vc.log(pp[1].selected); vc.log(pp[0].selected); vc.log(p.selected);\ + var sp = p.selectedPathPoints; vc.log(sp.length); vc.log(sp[1].anchor.join() == pp[2].anchor.join());", + ); + assert_eq!( + out, + vec![ + json!("PathPointSelection.NOSELECTION"), + json!(0), + json!("PathPointSelection.ANCHORPOINT"), + json!("PathPointSelection.NOSELECTION"), + json!(true), + json!(2), + json!(true) + ] + ); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1), (0, 2)])); + assert!(s.active().unwrap().selection.contains(b), "the other selected object stays selected"); + assert_eq!(undo_steps(&s), steps, "a selection change is not an undo step"); + let r = run( + &mut s, + "var pp = app.activeDocument.pathItems[0].pathPoints;\ + pp[1].selected = PathPointSelection.ANCHORPOINT; pp[0].selected = PathPointSelection.NOSELECTION;", + ) + .unwrap(); + assert_eq!((undo_steps(&s), &r["slowestCommands"]), (steps, &json!([])), "a value the point has runs no command"); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[1].selected = PathPointSelection.NOSELECTION;"); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 2)])); +} + +#[test] +fn a_path_selected_as_a_whole_has_every_point_selected() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; vc.log(p.selectedPathPoints.length); vc.log(p.pathPoints[3].selected);\ + p.pathPoints[0].selected = PathPointSelection.NOSELECTION; vc.log(p.selectedPathPoints.length);\ + vc.log(app.activeDocument.pathItems[1].selectedPathPoints.length);", + ); + assert_eq!(out, vec![json!(4), json!("PathPointSelection.ANCHORPOINT"), json!(3), json!(0)]); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1), (0, 2), (0, 3)])); +} + +#[test] +fn path_point_selected_refuses_handles_bad_values_and_locked_paths() { + let (mut s, a, _) = doc(); + let e = failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.LEFTDIRECTION;"); + assert!(e.contains("not available yet"), "{e}"); + let e = failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = true;"); + assert!(e.contains("PathPointSelection"), "{e}"); + s.execute("object.setProps", &json!({"ids": [a.0], "locked": true})).unwrap(); + let e = failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.ANCHORPOINT;"); + assert!(e.contains("Cannot select"), "{e}"); + assert!(s.active().unwrap().selection.is_empty()); +} + +fn is_guide(s: &Session, id: NodeId) -> bool { + matches!(node(s, id).kind, NodeKind::Path { guide: true, .. }) +} + +#[test] +fn assigning_guides_makes_and_releases_a_guide() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + let steps = undo_steps(&s); + let out = log(&mut s, "var p = app.activeDocument.pathItems[0]; p.guides = true; vc.log(p.guides);"); + assert_eq!(out, vec![json!(true)]); + assert!(is_guide(&s, a)); + assert_eq!(s.active().unwrap().selection.objects, vec![b], "the selection stays as it was"); + assert_eq!(undo_steps(&s), steps + 1); + let r = run(&mut s, "app.activeDocument.pathItems[0].guides = true;").unwrap(); + assert_eq!((undo_steps(&s), &r["slowestCommands"]), (steps + 1, &json!([])), "a value the path has runs no command"); + log(&mut s, "app.activeDocument.pathItems[0].guides = false;"); + assert!(!is_guide(&s, a)); + assert_eq!(s.active().unwrap().selection.objects, vec![b]); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = 1;"); + assert!(e.contains("guides"), "{e}"); + assert!(!is_guide(&s, a)); + // A path in a group becomes a guide on its own. + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[1].guides = true;"); + assert!(is_guide(&s, b) && !is_guide(&s, a)); +} diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 24417b2c21..aba7f93c69 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -122,8 +122,8 @@ const INSIDE: &[(&str, &str)] = &[ ( "PathItem.prototype.", "area clipping closed closed= constructor evenodd evenodd= fillColor fillColor= fillOverprint fillOverprint= filled \ - filled= guides length pathPoints polarity polarity= resize resolution resolution= rotate selectedPathPoints \ - selectedPathPoints= setEntirePath strokeCap strokeCap= strokeColor strokeColor= strokeDashOffset strokeDashOffset= \ + filled= guides guides= length pathPoints polarity polarity= resize resolution resolution= rotate selectedPathPoints \ + setEntirePath strokeCap strokeCap= strokeColor strokeColor= strokeDashOffset strokeDashOffset= \ strokeDashes strokeDashes= strokeJoin strokeJoin= strokeMiterLimit strokeMiterLimit= strokeOverprint strokeOverprint= \ strokeWidth strokeWidth= stroked stroked= translate", ), diff --git a/docs/gaps.md b/docs/gaps.md index d8184b1a9b..ab16cd29ed 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -807,8 +807,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi ## G6 Automation and scripting -- **Missing:** the rest of the document object model for scripts (layers, artboards, type, the selected path - points, gradient stops and the other classes) and the `#engine` script directive (#1183 is open). Scripts have +- **Missing:** the rest of the document object model for scripts (layers, artboards, type, gradient + stops and the other classes) and the `#engine` script directive (#1183 is open). Scripts have `app`, the open documents, new documents, each document's selection and its page items, and `Document.pathItems` makes paths and reads and changes their points, colors, stroke options and transforms. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` runs a script in a named engine whose globals last between runs, diff --git a/docs/mcp.md b/docs/mcp.md index e3d4e634ed..a9b066a528 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2700,8 +2700,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot art is painted. `add()` and the shape creators put the new path on top of the active layer whatever the drawing mode, which stays as it was. A `PathItem` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/) adds to the page item members `pathPoints`, `closed`, `evenodd`, `area` (negative for a path that runs counterclockwise), `length`, - `guides`, `clipping`, `setEntirePath(points)`, `filled`, `fillColor`, `fillOverprint`, `stroked`, `strokeColor`, - `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to 500), `strokeDashes`, + `guides`, `clipping`, `selectedPathPoints`, `setEntirePath(points)`, `filled`, `fillColor`, `fillOverprint`, + `stroked`, `strokeColor`, `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to 500), `strokeDashes`, `strokeDashOffset`, `translate(deltaX?, deltaY?, ...)`, `rotate(angle, ..., rotateAbout?)` (counterclockwise for a positive angle) and `resize(scaleX, scaleY, ..., changeLineWidths?, scaleAbout?)`. The geometry changes through `path.setAnchors`, the fill and stroke through `paint.setFill` and `paint.setStroke`, the stroke options through @@ -2713,9 +2713,14 @@ app through the global object `vc`, and writes to the Script Console and runs ot `pathPoints` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and `removeAll()`, and each `PathPoint` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/) has `anchor`, - `leftDirection` (the handle into the point), `rightDirection` (the handle out of it), `pointType`, `parent` and - `remove()`. `new RGBColor()` (0 to 255), `new CMYKColor()` (0 to 100), `new GrayColor()` (0 to 100, 0 black and 100 - white, as https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/ gives it), `new LabColor()` and `new NoColor()` + `leftDirection` (the handle into the point), `rightDirection` (the handle out of it), `pointType`, `selected`, + `parent` and `remove()`. Assigning `guides` makes the path a guide with `view.guides.make` (`true`) or a path again + with `view.guides.release` (`false`), with the selection kept; a value that is not a boolean throws a `TypeError`. + `PathPoint.selected` reads `PathPointSelection.ANCHORPOINT` for a selected anchor point and + `PathPointSelection.NOSELECTION` otherwise; assigning `ANCHORPOINT` adds the point to the direct-selected anchors and + `NOSELECTION` removes it, through `select.anchorsMany`, with the other selected objects and anchors kept. + `selectedPathPoints` lists the points that read `ANCHORPOINT`, in the order of `pathPoints`. `new RGBColor()` (0 to + 255), `new CMYKColor()` (0 to 100), `new GrayColor()` (0 to 100, 0 black and 100 white, as https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/ gives it), `new LabColor()` and `new NoColor()` (https://ai-scripting.docsforadobe.dev/jsobjref/NoColor/) make plain color objects; assigning a `NoColor` removes the fill or stroke. The enumerations `PointType`, `PathPointSelection`, `StrokeCap`, `StrokeJoin`, `PolarityValues` and `Transformation` hold strings such as `"StrokeCap.ROUNDENDCAP"`. @@ -2727,7 +2732,12 @@ app through the global object `vc`, and writes to the Script Console and runs ot a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`), or before anything other than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`, `object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an - object that holds it, such as `translate()`. Color components left out + object that holds it, such as `translate()`. Every point of a path selected as a whole is a selected anchor point, + and the endpoints of selected segments are not; a path is selected as a whole only when it is itself selected, not + when a group that holds it is. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, + `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and selecting + a point of a path that cannot be selected throws `Cannot select`. A clipping path cannot be made a guide, and + `guides = true` on one throws an error. Color components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest @@ -2748,8 +2758,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot that is hidden or locked, or that is in a hidden or locked layer or group, throws `Cannot edit` with nothing changed. A path in a compound path or compound shape reads the fill, stroke and overprint of that compound path or shape, which the paint commands paint in its place. A change to a path's paint or stroke leaves the paint for new - art, the active Fill or Stroke proxy and Recent Colors as they were. `selectedPathPoints`, `PathPoint.selected`, - `transform`, `polarity`, the gradient stops and the document's default paint are not available yet. + art, the active Fill or Stroke proxy and Recent Colors as they were. `transform`, `polarity`, the gradient stops and + the document's default paint are not available yet. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. - `$.evalFile(path, timeout?)` runs the file `path` names, relative to the file being run, in the same global diff --git a/docs/roadmap.md b/docs/roadmap.md index 28192e13b9..48cb17110f 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -196,7 +196,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG ``/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | | M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View (hiding the guides and the grid while it is on, #8363), middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 | | M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color (manual picker and canvas eyedropper from original pixels, no canvas View change, missed pixels keep the pick armed, Preview/Undo retained; #8068), Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 | -| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and `Document.pathItems` makes paths and reads and changes their points, colors, stroke options and transforms; the rest of the script document model (layers, artboards, type, the selected path points, gradient stops and the other classes) and batch work remain | 18–27 | +| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and `Document.pathItems` makes paths and reads and changes their points, colors, stroke options and transforms; the rest of the script document model (layers, artboards, type, gradient stops and the other classes) and batch work remain | 18–27 | | M14 | 1.0 polish (Asset Export tile context menus implemented for G12; preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset , UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Graphic Styles item context menus in thumbnail and list views with Options, Duplicate, Delete, Redefine, Break Link (#8755); Appearance panel row context menus for strokes, fills, effects, and root object row (Duplicate, Delete, Hide/Show, Edit Effect…, Clear Appearance, Reduce to Basic Appearance) with secondary click row selection (#8809); Character Styles and Paragraph Styles item context menus (panels::text_styles::tests::right_click_context_menu_*); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 | | — | Interaction fidelity pass (every tool's modifiers, Properties panel per context, isolation, nuance; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed) | ⬜ (new ruler-guide Alt orientation implemented; existing-guide Escape cancellation regression-tested; broader pass remains) | 60–90 | | — | Hardening at scale (big-file corpus, fuzzing, cross-platform + browser QA) | 🟡 PngSuite integrity and bounded fetching verified (#1729); real-world corpus/manual QA remain | 50–80 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 72ed713051..7be0c39261 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1025,7 +1025,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From dd748796249d63527774b005a7dbe184e1f19e44 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 11:56:32 -0800 Subject: [PATCH 018/264] Scripts: guides refuse compound members and locked guides in both directions Assigning PathItem.guides on a path inside a compound path made every path in that compound a guide, because Make Guides acts on the compound that holds a selected member; it now throws an error that says it is not available yet, as duplicate and zOrder do for compound members. While guides are locked, assigning false threw and assigning true succeeded; now either value throws when it would change the path. A path that cannot be selected, for example one outside the isolated group or on a locked artboard, throws Cannot edit before any command runs. Assigning the value a path already has runs no command and throws no error. These are VectorCraft's own rules, and docs/mcp.md lists them with the other rules of its own. Tests cover a compound path member, a clipping path, a locked and a hidden path, the guide lock in both directions, a path in a group of two, and the TypeError name for a value that is not a boolean. --- crates/engine/src/script/dom/paths.rs | 24 +++++++- crates/engine/src/tests/script_dom_paths.rs | 65 +++++++++++++++++++-- docs/mcp.md | 7 ++- 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index a3b75cc6ff..bf61be91a5 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -43,7 +43,9 @@ //! as a selected anchor point, and not the endpoints of selected segments; a path in a selected //! group is not selected as a whole. Direction handles are not selected on their own, so //! `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error that says they are not -//! available yet. A clipping path cannot be made a guide. +//! available yet. A clipping path cannot be made a guide. Assigning `guides` on a path inside a +//! compound path throws an error that says it is not available yet, on a path that cannot be +//! edited or selected throws `Cannot edit`, and while guides are locked throws an error. //! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and //! `changeStrokePattern` given as different values throw an error; gradients move with the art, //! so `changeFillGradients` false throws an error that says it is not available yet. @@ -590,8 +592,13 @@ fn path_guides(h: &super::Host, a: &[Data]) -> Answer { read_path(h, item, |_, n, _| Data::Bool(matches!(n.kind, NodeKind::Path { guide: true, .. }))) } +/// The error of assigning `guides` on a path inside a compound path. +pub const COMPOUND_MEMBER_GUIDES: &str = "Changing guides on a path inside a compound path is not available yet"; + /// `guides = true` makes the path a guide with `view.guides.make`, and `false` makes it a path again -/// with `view.guides.release`; the selection stays as it was. A clipping path cannot be a guide. +/// with `view.guides.release`; the selection stays as it was. A clipping path cannot be a guide, a +/// path inside a compound path throws [`COMPOUND_MEMBER_GUIDES`], and while guides are locked both +/// values throw an error. fn path_set_guides(h: &super::Host, a: &[Data]) -> Answer { let on = boolean(arg(a, 1), "guides")?; let item = this_path(h, a)?; @@ -602,9 +609,20 @@ fn path_set_guides(h: &super::Host, a: &[Data]) -> Answer { if now == on { return Ok(Data::Undefined); } - if !with_doc(h, item.doc, |_, st| editable(&st.doc, item.id)) { + let (member, editable, selectable) = with_doc(h, item.doc, |_, st| { + let member = st.doc.parent_of(item.id).and_then(|p| st.doc.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Compound { .. })); + let selectable = crate::cmd::select::is_selectable(&st.doc, st.isolation, &st.doc.locked_artboards(), item.id); + (member, editable(&st.doc, item.id), selectable) + }); + if member { + return Err(HostError::Error(COMPOUND_MEMBER_GUIDES.into())); + } + if !editable || (on && !selectable) { return Err(cannot_edit(item.id)); } + if h.session.borrow().menu.guides_locked { + return Err(HostError::Error(format!("Cannot change guides on PathItem {}: guides are locked", item.id.0))); + } if !on { edit_path(h, item, "view.guides.release", json!({}))?; return Ok(Data::Undefined); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index abe9a1374a..b8fdf6673d 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -938,6 +938,15 @@ fn a_path_selected_as_a_whole_has_every_point_selected() { assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1), (0, 2), (0, 3)])); } +#[test] +fn a_path_in_a_selected_group_is_not_selected_as_a_whole() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let out = log(&mut s, "var ps = app.activeDocument.pathItems; vc.log([ps[0].selectedPathPoints.length, ps[1].selectedPathPoints.length]);"); + assert_eq!(out, vec![json!([0, 0])]); +} + #[test] fn path_point_selected_refuses_handles_bad_values_and_locked_paths() { let (mut s, a, _) = doc(); @@ -970,12 +979,58 @@ fn assigning_guides_makes_and_releases_a_guide() { log(&mut s, "app.activeDocument.pathItems[0].guides = false;"); assert!(!is_guide(&s, a)); assert_eq!(s.active().unwrap().selection.objects, vec![b]); - let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = 1;"); - assert!(e.contains("guides"), "{e}"); + let out = log(&mut s, "try { app.activeDocument.pathItems[0].guides = 1; } catch (e) { vc.log(e.name); }"); + assert_eq!(out, vec![json!("TypeError")]); assert!(!is_guide(&s, a)); - // A path in a group becomes a guide on its own. - s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + // A path in a group becomes a guide on its own; the other path in the group stays a path. + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); s.execute("object.group", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); log(&mut s, "app.activeDocument.pathItems[1].guides = true;"); - assert!(is_guide(&s, b) && !is_guide(&s, a)); + assert!(is_guide(&s, a) != is_guide(&s, b), "only the assigned path in the group is a guide"); +} + +#[test] +fn assigning_guides_refuses_compound_members_clipping_paths_and_paths_that_cannot_be_edited() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.compoundPath.make", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + assert!(e.contains("compound path"), "{e}"); + assert_eq!((art(&s), is_guide(&s, a), is_guide(&s, b)), (before, false, false), "no member of the compound path changed"); + + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.clippingMask.make", &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let e = failure(&mut s, "var ps = app.activeDocument.pathItems; for (var i = 0; i < ps.length; i++) if (ps[i].clipping) ps[i].guides = true;"); + assert!(e.contains("clipping path"), "{e}"); + assert_eq!(art(&s), before); + + for cmd in ["object.lock", "object.hide"] { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute(cmd, &json!({})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + assert!(e.contains("Cannot edit"), "{cmd}: {e}"); + assert!(!is_guide(&s, a), "{cmd}"); + } +} + +#[test] +fn assigning_guides_throws_in_both_directions_while_guides_are_locked() { + let (mut s, a, b) = doc(); + log(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + assert!(is_guide(&s, a)); + s.set_guides_locked(true); + let steps = undo_steps(&s); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = false;"); + assert!(e.contains("guides are locked"), "{e}"); + let e = failure(&mut s, "app.activeDocument.pathItems[1].guides = true;"); + assert!(e.contains("guides are locked"), "{e}"); + assert_eq!((is_guide(&s, a), is_guide(&s, b), undo_steps(&s)), (true, false, steps)); } diff --git a/docs/mcp.md b/docs/mcp.md index a9b066a528..78a863a2b1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2720,7 +2720,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `PathPointSelection.NOSELECTION` otherwise; assigning `ANCHORPOINT` adds the point to the direct-selected anchors and `NOSELECTION` removes it, through `select.anchorsMany`, with the other selected objects and anchors kept. `selectedPathPoints` lists the points that read `ANCHORPOINT`, in the order of `pathPoints`. `new RGBColor()` (0 to - 255), `new CMYKColor()` (0 to 100), `new GrayColor()` (0 to 100, 0 black and 100 white, as https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/ gives it), `new LabColor()` and `new NoColor()` + 255), `new CMYKColor()` (0 to 100), `new GrayColor()` (0 to 100, 0 black and 100 white, as + https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/ gives it), `new LabColor()` and `new NoColor()` (https://ai-scripting.docsforadobe.dev/jsobjref/NoColor/) make plain color objects; assigning a `NoColor` removes the fill or stroke. The enumerations `PointType`, `PathPointSelection`, `StrokeCap`, `StrokeJoin`, `PolarityValues` and `Transformation` hold strings such as `"StrokeCap.ROUNDENDCAP"`. @@ -2737,7 +2738,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot when a group that holds it is. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and selecting a point of a path that cannot be selected throws `Cannot select`. A clipping path cannot be made a guide, and - `guides = true` on one throws an error. Color components left out + `guides = true` on one throws an error; assigning `guides` on a path inside a compound path throws an error that says + it is not available yet, on a path that is hidden, locked or cannot be selected throws `Cannot edit`, and while + guides are locked throws an error for either value. Color components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest From fbc057f8b0ee3f5cbca178e9c114b3c873f6a5ea Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 12:36:17 -0800 Subject: [PATCH 019/264] Scripts: points of a path in a selected group read as selected PathPoint.selected and PathItem.selectedPathPoints now count a path as selected as a whole when a group or compound path that holds it is selected, as the canvas shows its anchors. Assigning PathPointSelection.NOSELECTION to a point of such a path throws an error that says it is not available yet, and ANCHORPOINT on it runs no command, so the selection is not left holding both the group and one of its paths. Selecting a point of a guide while guides are locked throws an error instead of running a selection that the guide lock undoes. Assigning guides = false on a path that cannot be selected (outside the isolated object) throws Cannot edit, as guides = true does. Reading PathPoint.selected no longer writes the point changes waiting for its path unless they add or remove points, so a loop that reads selected and moves the selected anchors writes the path once. --- crates/engine/src/script/dom/paths.rs | 79 ++++++++++++---- crates/engine/src/tests/script_dom_paths.rs | 100 ++++++++++++++++++-- docs/mcp.md | 16 ++-- 3 files changed, 162 insertions(+), 33 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index bf61be91a5..db0352750b 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -41,11 +41,13 @@ //! `resize(100, 100)`) checks its arguments and runs no command, on a path with no points too. //! - `PathPoint.selected` and `selectedPathPoints` count every point of a path selected as a whole //! as a selected anchor point, and not the endpoints of selected segments; a path in a selected -//! group is not selected as a whole. Direction handles are not selected on their own, so -//! `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error that says they are not -//! available yet. A clipping path cannot be made a guide. Assigning `guides` on a path inside a -//! compound path throws an error that says it is not available yet, on a path that cannot be -//! edited or selected throws `Cannot edit`, and while guides are locked throws an error. +//! group or compound path is selected as a whole. Direction handles are not selected on their +//! own, so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error that says they +//! are not available yet, and so does `NOSELECTION` on a point of a path in a selected group or +//! compound path. Selecting a point of a guide while guides are locked throws an error. A +//! clipping path cannot be made a guide. Assigning `guides` on a path inside a compound path +//! throws an error that says it is not available yet, on a path that cannot be edited or +//! selected throws `Cannot edit` for both values, and while guides are locked throws an error. //! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and //! `changeStrokePattern` given as different values throw an error; gradients move with the art, //! so `changeFillGradients` false throws an error that says it is not available yet. @@ -617,7 +619,7 @@ fn path_set_guides(h: &super::Host, a: &[Data]) -> Answer { if member { return Err(HostError::Error(COMPOUND_MEMBER_GUIDES.into())); } - if !editable || (on && !selectable) { + if !editable || !selectable { return Err(cannot_edit(item.id)); } if h.session.borrow().menu.guides_locked { @@ -1379,10 +1381,20 @@ fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { Ok(path_ref(h, item)) } +/// Whether the path `id` is not selected itself but a group or compound path that holds it is, +/// which selects the path as a whole. +fn held_selected(d: &crate::Document, sel: &crate::doc::Selection, id: NodeId) -> bool { + !sel.contains(id) && d.ancestry(id).is_some_and(|a| a.iter().any(|i| *i != id && sel.contains(*i) && d.node(*i).is_some_and(|n| !n.is_layer()))) +} + /// The point at index `i` of `subs` is a selected anchor point of the path `id` in `sel`: every -/// point of a path selected as a whole is, and of a path with direct-selected anchors only those -/// anchors are. The endpoints of selected segments are not. -fn anchor_selected(sel: &crate::doc::Selection, id: NodeId, subs: &[SubPath], i: usize) -> bool { +/// point of a path selected as a whole is (a path is when a group or compound path that holds it +/// is selected, `held`), and of a path with direct-selected anchors only those anchors are. The +/// endpoints of selected segments are not. +fn anchor_selected(sel: &crate::doc::Selection, id: NodeId, held: bool, subs: &[SubPath], i: usize) -> bool { + if held { + return true; + } if !sel.contains(id) || sel.segments.contains_key(&id) { return false; } @@ -1392,11 +1404,27 @@ fn anchor_selected(sel: &crate::doc::Selection, id: NodeId, subs: &[SubPath], i: } } +/// Whether the subpaths `a` and `b` have the same number of points in the same subpaths, so that a +/// point index names the same anchor in both. +fn same_layout(a: &[SubPath], b: &[SubPath]) -> bool { + a.len() == b.len() && a.iter().zip(b).all(|(x, y)| x.anchors.len() == y.anchors.len()) +} + /// `selected`: `PathPointSelection.ANCHORPOINT` when the point is a selected anchor point -/// ([`anchor_selected`]), otherwise `PathPointSelection.NOSELECTION`. +/// ([`anchor_selected`]), otherwise `PathPointSelection.NOSELECTION`. The point changes waiting in +/// [`super::State`] are written first only when they add or remove points of this path, since +/// the selection names anchors by their place in the document's path. fn pt_selected(h: &super::Host, a: &[Data]) -> Answer { let (item, i) = this_point(h, a)?; - let on = read_path(h, item, |st, _, pd| anchor_selected(&st.selection, item.id, &pd.subpaths, i))?; + let moved = match &*h.dom.pending.borrow() { + Some((waiting, subs)) if same_path(*waiting, item) => !read_path(h, item, |_, _, pd| same_layout(subs, &pd.subpaths))?, + _ => false, + }; + if moved { + super::flush(h)?; + } + let on = + read_path(h, item, |st, _, pd| anchor_selected(&st.selection, item.id, held_selected(&st.doc, &st.selection, item.id), &pd.subpaths, i))?; Ok(Data::String(if on { "PathPointSelection.ANCHORPOINT" } else { "PathPointSelection.NOSELECTION" }.into())) } @@ -1406,7 +1434,9 @@ const HANDLE_SELECTIONS: &[&str] = &["PathPointSelection.LEFTDIRECTION", "PathPo /// `selected = PathPointSelection.ANCHORPOINT` adds the point to the direct-selected anchors, and /// `NOSELECTION` removes it, with `select.anchorsMany`; the other selected objects and anchors stay /// selected. A value the point has already runs no command. Direction handles cannot be selected, -/// so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error. +/// so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error, and so does +/// `NOSELECTION` on a path selected through a group or compound path that holds it, and +/// `ANCHORPOINT` on a guide while guides are locked. fn pt_set_selected(h: &super::Host, a: &[Data]) -> Answer { let on = match arg(a, 1) { Data::String(s) if s == "PathPointSelection.ANCHORPOINT" => true, @@ -1417,18 +1447,30 @@ fn pt_set_selected(h: &super::Host, a: &[Data]) -> Answer { _ => return Err(HostError::Type("selected must be a PathPointSelection value".into())), }; let (item, i) = this_point(h, a)?; - let (now, at, selectable) = with_doc(h, item.doc, |_, st| { - let subs = st.doc.node(item.id).and_then(|n| n.path_data()).map_or(&[][..], |pd| &pd.subpaths[..]); + let (now, at, selectable, held, guide) = with_doc(h, item.doc, |_, st| { + let node = st.doc.node(item.id); + let subs = node.and_then(|n| n.path_data()).map_or(&[][..], |pd| &pd.subpaths[..]); + let guide = node.is_some_and(|n| matches!(n.kind, NodeKind::Path { guide: true, .. })); let selectable = crate::cmd::select::is_selectable(&st.doc, st.isolation, &st.doc.locked_artboards(), item.id); - (anchor_selected(&st.selection, item.id, subs, i), locate(subs, i), selectable) + let held = held_selected(&st.doc, &st.selection, item.id); + (anchor_selected(&st.selection, item.id, held, subs, i), locate(subs, i), selectable, held, guide) }); if now == on { return Ok(Data::Undefined); } let Some((s, j)) = at else { return Err(HostError::Error(STALE_POINT.into())) }; + if held { + return Err(HostError::Error(format!( + "PathPoint.selected = PathPointSelection.NOSELECTION is not available yet on PathItem {}: the group or compound path that holds it is selected", + item.id.0 + ))); + } if on && !selectable { return Err(HostError::Error(format!("Cannot select PathItem {}", item.id.0))); } + if on && guide && h.session.borrow().menu.guides_locked { + return Err(HostError::Error(format!("Cannot select PathItem {}: guides are locked", item.id.0))); + } let params = json!({"items": [{"id": item.id.0, "anchors": [[s, j]]}], "mode": if on { "add" } else { "subtract" }}); on_doc(h, item.doc.uid, false, |h| command(h, "select.anchorsMany", ¶ms))?; Ok(Data::Undefined) @@ -1440,14 +1482,15 @@ fn path_selected_points(h: &super::Host, a: &[Data]) -> Answer { let item = this_path(h, a)?; let picked: Vec = read_path(h, item, |st, _, pd| { let sel = &st.selection; - if !sel.contains(item.id) || sel.segments.contains_key(&item.id) { + let held = held_selected(&st.doc, sel, item.id); + if !held && (!sel.contains(item.id) || sel.segments.contains_key(&item.id)) { return Vec::new(); } let mut out = Vec::new(); let mut first = 0; for (s, sp) in pd.subpaths.iter().enumerate() { let n = sp.anchors.len(); - out.extend((0..n).filter(|j| sel.partial(item.id).is_none_or(|p| p.contains(&(s, *j)))).map(|j| first + j)); + out.extend((0..n).filter(|j| held || sel.partial(item.id).is_none_or(|p| p.contains(&(s, *j)))).map(|j| first + j)); first += n; } out @@ -1555,7 +1598,7 @@ pub(super) fn classes(l: &Link) -> Vec { ("leftDirection", point_property(l, pt_left, pt_set_left)), ("rightDirection", point_property(l, pt_right, pt_set_right)), ("pointType", point_property(l, pt_type, pt_set_type)), - ("selected", property(l, pt_selected, pt_set_selected)), + ("selected", HostMember::Property { get: super::point_function(l, pt_selected), set: super::function(l, pt_set_selected) }), ("remove", point_method(l, pt_remove)), ]), None, diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index b8fdf6673d..43ce225e82 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -939,12 +939,39 @@ fn a_path_selected_as_a_whole_has_every_point_selected() { } #[test] -fn a_path_in_a_selected_group_is_not_selected_as_a_whole() { - let (mut s, a, b) = doc(); - s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); - s.execute("object.group", &json!({})).unwrap(); - let out = log(&mut s, "var ps = app.activeDocument.pathItems; vc.log([ps[0].selectedPathPoints.length, ps[1].selectedPathPoints.length]);"); - assert_eq!(out, vec![json!([0, 0])]); +fn a_path_in_a_selected_group_or_compound_path_is_selected_as_a_whole() { + for make in ["object.group", "object.compoundPath.make"] { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute(make, &json!({})).unwrap(); + let sel = format!("{:?}", s.active().unwrap().selection); + let steps = undo_steps(&s); + let out = log( + &mut s, + "var ps = app.activeDocument.pathItems; vc.log([ps[0].selectedPathPoints.length, ps[1].selectedPathPoints.length]);\ + vc.log(ps[0].pathPoints[2].selected); ps[0].pathPoints[2].selected = PathPointSelection.ANCHORPOINT;\ + try { ps[0].pathPoints[2].selected = PathPointSelection.NOSELECTION; } catch (e) { vc.log(e.message); }", + ); + assert_eq!(out[..2], [json!([4, 4]), json!("PathPointSelection.ANCHORPOINT")], "{make}"); + assert!(out[2].as_str().is_some_and(|m| m.contains("not available yet")), "{make}: {out:?}"); + assert_eq!(format!("{:?}", s.active().unwrap().selection), sel, "{make}: the selection stays as it was"); + assert_eq!(undo_steps(&s), steps, "{make}"); + } +} + +#[test] +fn reading_selected_while_moving_points_writes_the_path_once() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + let r = run( + &mut s, + "var pp = app.activeDocument.pathItems[0].pathPoints;\ + for (var i = 0; i < pp.length; i++) if (pp[i].selected == PathPointSelection.ANCHORPOINT) pp[i].anchor = [pp[i].anchor[0] + 1, pp[i].anchor[1]];", + ) + .unwrap(); + let calls: Vec = + r["slowestCommands"].as_array().unwrap().iter().filter(|c| c["id"] == "path.setAnchors").map(|c| c["calls"].as_u64().unwrap()).collect(); + assert_eq!(calls, vec![1], "{r}"); } #[test] @@ -960,6 +987,60 @@ fn path_point_selected_refuses_handles_bad_values_and_locked_paths() { assert!(s.active().unwrap().selection.is_empty()); } +/// The ways an editable path cannot be selected: on a locked artboard, and outside the isolated +/// object. +const UNSELECTABLE: [&str; 2] = ["locked artboard", "isolation"]; + +/// Makes the paths of [`doc`] other than `b` editable but not selectable, as `case` names. +fn lock_out(s: &mut Session, case: &str, b: NodeId) { + if case == "isolation" { + s.execute("object.isolate", &json!({"id": b.0})).unwrap(); + } else { + s.execute("artboard.setProps", &json!({"index": 0, "locked": true})).unwrap(); + } +} + +#[test] +fn path_point_selected_refuses_paths_on_locked_artboards_and_outside_isolation() { + for case in UNSELECTABLE { + let (mut s, a, b) = doc(); + lock_out(&mut s, case, b); + let e = failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.ANCHORPOINT;"); + assert!(e.contains("Cannot select"), "{case}: {e}"); + assert!(!s.active().unwrap().selection.contains(a), "{case}"); + } +} + +#[test] +fn selecting_a_point_of_a_guide_throws_while_guides_are_locked() { + let (mut s, a, _) = doc(); + log(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + s.set_guides_locked(true); + let e = failure(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.ANCHORPOINT;"); + assert!(e.contains("guides are locked"), "{e}"); + assert!(!s.active().unwrap().selection.contains(a)); +} + +#[test] +fn assigning_guides_refuses_paths_that_cannot_be_selected() { + for case in UNSELECTABLE { + let (mut s, a, b) = doc(); + lock_out(&mut s, case, b); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + assert!(e.contains("Cannot edit"), "{case}: {e}"); + assert!(!is_guide(&s, a), "{case}"); + } + // A guide is on no locked artboard, so only isolation keeps a guide from being released. + let (mut s, a, b) = doc(); + log(&mut s, "app.activeDocument.pathItems[0].guides = true;"); + assert!(is_guide(&s, a)); + lock_out(&mut s, "isolation", b); + let steps = undo_steps(&s); + let e = failure(&mut s, "app.activeDocument.pathItems[0].guides = false;"); + assert!(e.contains("Cannot edit"), "{e}"); + assert_eq!((is_guide(&s, a), undo_steps(&s)), (true, steps), "the guide stays a guide"); +} + fn is_guide(s: &Session, id: NodeId) -> bool { matches!(node(s, id).kind, NodeKind::Path { guide: true, .. }) } @@ -986,8 +1067,11 @@ fn assigning_guides_makes_and_releases_a_guide() { s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); s.execute("object.group", &json!({})).unwrap(); s.execute("select.none", &json!({})).unwrap(); - log(&mut s, "app.activeDocument.pathItems[1].guides = true;"); - assert!(is_guide(&s, a) != is_guide(&s, b), "only the assigned path in the group is a guide"); + log(&mut s, "var p = app.activeDocument.pathItems[1]; p.name = 'assigned'; p.guides = true;"); + let (assigned, other) = if node(&s, a).name.as_deref() == Some("assigned") { (a, b) } else { (b, a) }; + assert_eq!(node(&s, assigned).name.as_deref(), Some("assigned")); + assert_eq!((is_guide(&s, assigned), is_guide(&s, other)), (true, false), "only the assigned path in the group is a guide"); + assert!(s.active().unwrap().selection.is_empty(), "the selection stays as it was"); } #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 78a863a2b1..103c6f7ee8 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2734,13 +2734,15 @@ app through the global object `vc`, and writes to the Script Console and runs ot than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`, `object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an object that holds it, such as `translate()`. Every point of a path selected as a whole is a selected anchor point, - and the endpoints of selected segments are not; a path is selected as a whole only when it is itself selected, not - when a group that holds it is. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, - `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and selecting - a point of a path that cannot be selected throws `Cannot select`. A clipping path cannot be made a guide, and - `guides = true` on one throws an error; assigning `guides` on a path inside a compound path throws an error that says - it is not available yet, on a path that is hidden, locked or cannot be selected throws `Cannot edit`, and while - guides are locked throws an error for either value. Color components left out + and the endpoints of selected segments are not; a path in a selected group or compound path is selected as a whole. + Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, `RIGHTDIRECTION` or `LEFTRIGHTPOINT` + to `selected` throws an error that says it is not available yet, and so does assigning `NOSELECTION` to a point of a + path in a selected group or compound path. Selecting a point of a path that cannot be selected throws `Cannot + select`, and selecting a point of a guide while guides are locked throws an error. A clipping path cannot be made a + guide, and `guides = true` on one throws an error; assigning `guides` on a path inside a compound path throws an + error that says it is not available yet, assigning either value on a path that is hidden, locked or cannot be + selected throws `Cannot edit`, and assigning either value while guides are locked throws an error. Color + components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest From 496ac0c785e928c33b3f39c0cf251ecd06863007 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 13:14:01 -0800 Subject: [PATCH 020/264] Scripts: state the segment and no-change rules of selected and guides Assigning PathPointSelection.ANCHORPOINT to a point of a path with selected segments replaces that path's segment selection, as select.anchorsMany does for any anchor pick on such a path; the module doc, the setter's doc and docs/mcp.md now say so. docs/mcp.md also says that changing PathPoint.selected adds no undo step, and that assigning guides the value a path already has runs no command, which is why a hidden, locked or compound-member path, or locked guides, throw only for the other value. The touched lines of the PathItem paragraph are rewrapped to its width. New tests cover a point added by the script and selected in the same run, selectedPathPoints after an added point, a path with a selected segment, and assigning guides its current value while guides are locked. --- crates/engine/src/script/dom/paths.rs | 27 +++++++++------- crates/engine/src/tests/script_dom_paths.rs | 34 +++++++++++++++++++++ docs/mcp.md | 33 ++++++++++---------- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index db0352750b..ddd0853d3a 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -44,10 +44,12 @@ //! group or compound path is selected as a whole. Direction handles are not selected on their //! own, so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error that says they //! are not available yet, and so does `NOSELECTION` on a point of a path in a selected group or -//! compound path. Selecting a point of a guide while guides are locked throws an error. A -//! clipping path cannot be made a guide. Assigning `guides` on a path inside a compound path -//! throws an error that says it is not available yet, on a path that cannot be edited or -//! selected throws `Cannot edit` for both values, and while guides are locked throws an error. +//! compound path. Selecting a point of a path with selected segments replaces that path's +//! segment selection. Selecting a point of a guide while guides are locked throws an error. A +//! clipping path cannot be made a guide. Assigning `guides` a value the path does not have +//! throws an error that says it is not available yet on a path inside a compound path, throws +//! `Cannot edit` on a path that cannot be edited or selected, and throws an error while guides +//! are locked; assigning the value the path has runs no command. //! - The transforms take one setting for fill and stroke patterns, so `changeFillPatterns` and //! `changeStrokePattern` given as different values throw an error; gradients move with the art, //! so `changeFillGradients` false throws an error that says it is not available yet. @@ -598,9 +600,10 @@ fn path_guides(h: &super::Host, a: &[Data]) -> Answer { pub const COMPOUND_MEMBER_GUIDES: &str = "Changing guides on a path inside a compound path is not available yet"; /// `guides = true` makes the path a guide with `view.guides.make`, and `false` makes it a path again -/// with `view.guides.release`; the selection stays as it was. A clipping path cannot be a guide, a -/// path inside a compound path throws [`COMPOUND_MEMBER_GUIDES`], and while guides are locked both -/// values throw an error. +/// with `view.guides.release`; the selection stays as it was. A value the path has already runs no +/// command and throws no error. Otherwise a clipping path cannot be a guide, a path inside a +/// compound path throws [`COMPOUND_MEMBER_GUIDES`], and while guides are locked both values throw +/// an error. fn path_set_guides(h: &super::Host, a: &[Data]) -> Answer { let on = boolean(arg(a, 1), "guides")?; let item = this_path(h, a)?; @@ -1433,10 +1436,12 @@ const HANDLE_SELECTIONS: &[&str] = &["PathPointSelection.LEFTDIRECTION", "PathPo /// `selected = PathPointSelection.ANCHORPOINT` adds the point to the direct-selected anchors, and /// `NOSELECTION` removes it, with `select.anchorsMany`; the other selected objects and anchors stay -/// selected. A value the point has already runs no command. Direction handles cannot be selected, -/// so `LEFTDIRECTION`, `RIGHTDIRECTION` and `LEFTRIGHTPOINT` throw an error, and so does -/// `NOSELECTION` on a path selected through a group or compound path that holds it, and -/// `ANCHORPOINT` on a guide while guides are locked. +/// selected, except that selecting an anchor of a path with selected segments replaces that path's +/// segment selection, as `select.anchorsMany` does. A value the point has already runs no command. +/// Direction handles cannot be selected, so `LEFTDIRECTION`, `RIGHTDIRECTION` and +/// `LEFTRIGHTPOINT` throw an error, and so does `NOSELECTION` on a path selected through a group or +/// compound path that holds it, and `ANCHORPOINT` on a guide while guides are locked. The setter +/// writes the waiting point changes first, as every member that is not a point function does. fn pt_set_selected(h: &super::Host, a: &[Data]) -> Answer { let on = match arg(a, 1) { Data::String(s) if s == "PathPointSelection.ANCHORPOINT" => true, diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 43ce225e82..17d9969387 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -974,6 +974,38 @@ fn reading_selected_while_moving_points_writes_the_path_once() { assert_eq!(calls, vec![1], "{r}"); } +#[test] +fn selection_reads_and_writes_see_points_the_script_added() { + let (mut s, a, _) = doc(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], q = p.pathPoints.add(); q.selected = PathPointSelection.ANCHORPOINT;\ + vc.log(q.selected); vc.log(p.selectedPathPoints.length);", + ); + assert_eq!(out, vec![json!("PathPointSelection.ANCHORPOINT"), json!(1)]); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 4)])); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + let out = log(&mut s, "var p = app.activeDocument.pathItems[0]; p.pathPoints.add(); vc.log([p.selectedPathPoints.length, p.pathPoints.length]);"); + assert_eq!(out, vec![json!([6, 6])]); +} + +#[test] +fn selecting_a_point_of_a_path_with_selected_segments_replaces_the_segments() { + let (mut s, a, _) = doc(); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 1]], "mode": "set"})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; vc.log(p.selectedPathPoints.length);\ + p.pathPoints[1].selected = PathPointSelection.NOSELECTION;", + ); + assert_eq!(out, vec![json!(0)]); + assert!(s.active().unwrap().selection.segments.contains_key(&a), "a value the point has leaves the segments selected"); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].selected = PathPointSelection.ANCHORPOINT;"); + let sel = &s.active().unwrap().selection; + assert!(!sel.segments.contains_key(&a)); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 0)])); +} + #[test] fn path_point_selected_refuses_handles_bad_values_and_locked_paths() { let (mut s, a, _) = doc(); @@ -1117,4 +1149,6 @@ fn assigning_guides_throws_in_both_directions_while_guides_are_locked() { let e = failure(&mut s, "app.activeDocument.pathItems[1].guides = true;"); assert!(e.contains("guides are locked"), "{e}"); assert_eq!((is_guide(&s, a), is_guide(&s, b), undo_steps(&s)), (true, false, steps)); + log(&mut s, "var ps = app.activeDocument.pathItems; ps[0].guides = true; ps[1].guides = false;"); + assert_eq!((is_guide(&s, a), is_guide(&s, b), undo_steps(&s)), (true, false, steps), "a value the path has runs no command"); } diff --git a/docs/mcp.md b/docs/mcp.md index 103c6f7ee8..319609005f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2701,15 +2701,16 @@ app through the global object `vc`, and writes to the Script Console and runs ot mode, which stays as it was. A `PathItem` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/) adds to the page item members `pathPoints`, `closed`, `evenodd`, `area` (negative for a path that runs counterclockwise), `length`, `guides`, `clipping`, `selectedPathPoints`, `setEntirePath(points)`, `filled`, `fillColor`, `fillOverprint`, - `stroked`, `strokeColor`, `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to 500), `strokeDashes`, - `strokeDashOffset`, `translate(deltaX?, deltaY?, ...)`, `rotate(angle, ..., rotateAbout?)` (counterclockwise for a - positive angle) and `resize(scaleX, scaleY, ..., changeLineWidths?, scaleAbout?)`. The geometry changes through - `path.setAnchors`, the fill and stroke through `paint.setFill` and `paint.setStroke`, the stroke options through - `stroke.set`, the fill rule through `path.setFillRule`, overprint through `object.setOverprint` and the transforms - through `object.move`, `object.rotate` and `object.scale`. Changes to the points of a path (`closed`, - `setEntirePath`, `pathPoints` and each `PathPoint`) are written together with one `path.setAnchors` before the - script uses any other member or command, or the points of another path, and when the script ends; a path aligned - to the pixel grid, or in an object that is, is written at each change, so its points read as the grid snaps them. + `stroked`, `strokeColor`, `strokeOverprint`, `strokeWidth`, `strokeCap`, `strokeJoin`, `strokeMiterLimit` (1 to + 500), `strokeDashes`, `strokeDashOffset`, `translate(deltaX?, deltaY?, ...)`, `rotate(angle, ..., rotateAbout?)` + (counterclockwise for a positive angle) and `resize(scaleX, scaleY, ..., changeLineWidths?, scaleAbout?)`. The + geometry changes through `path.setAnchors`, the fill and stroke through `paint.setFill` and `paint.setStroke`, the + stroke options through `stroke.set`, the fill rule through `path.setFillRule`, overprint through + `object.setOverprint` and the transforms through `object.move`, `object.rotate` and `object.scale`. Changes to the + points of a path (`closed`, `setEntirePath`, `pathPoints` and each `PathPoint`) are written together with one + `path.setAnchors` before the script uses any other member or command, or the points of another path, and when the + script ends; a path aligned to the pixel grid, or in an object that is, is written at each change, so its points + read as the grid snaps them. `pathPoints` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and `removeAll()`, and each `PathPoint` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/) has `anchor`, @@ -2737,13 +2738,13 @@ app through the global object `vc`, and writes to the Script Console and runs ot and the endpoints of selected segments are not; a path in a selected group or compound path is selected as a whole. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and so does assigning `NOSELECTION` to a point of a - path in a selected group or compound path. Selecting a point of a path that cannot be selected throws `Cannot - select`, and selecting a point of a guide while guides are locked throws an error. A clipping path cannot be made a - guide, and `guides = true` on one throws an error; assigning `guides` on a path inside a compound path throws an - error that says it is not available yet, assigning either value on a path that is hidden, locked or cannot be - selected throws `Cannot edit`, and assigning either value while guides are locked throws an error. Color - components left out - count as 0, `new + path in a selected group or compound path. Selecting a point of a path with selected segments replaces that path's + segment selection. Changing `selected` adds no undo step. Selecting a point of a path that cannot be selected + throws `Cannot select`, and selecting a point of a guide while guides are locked throws an error. A clipping path + cannot be made a guide, and `guides = true` on one throws an error. Assigning `guides` the value a path already + has runs no command. Assigning the other value throws an error that says it is not available yet on a path inside + a compound path, throws `Cannot edit` on a path that is hidden, locked or cannot be selected, and throws an error + while guides are locked. Color components left out count as 0, `new cmykColor()` makes a `CMYKColor`, `LabColor.l` is 0 to 100 and `a` and `b` are -128 to 128, and a component out of range throws a `RangeError` when the color is assigned, with nothing changed. A component reads with the fewest decimals, at least 4, that give the stored value back, so assigning a color read from a path leaves the path as it From e8a0aa6ba444a89c622056f5f8d95f911556f3e5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 19:01:40 -0800 Subject: [PATCH 021/264] Scripts: documents give their file, folder and saved state, close, and save several artboards - Document.fullName is a File for the document's file, and Document.path a Folder for its folder. A document without a file has a fullName of a File for its name in Folder.current and a path of "". Both throw `Script file access denied` with the document's name when the automation read roots do not allow the file. - Document.saved reads whether the document has unsaved changes. Setting it runs the new command document.setSaved, which records the document as saved or as changed without saving it and adds no undo step. - Document.close(saveOptions) closes a document without unsaved changes with any SaveOptions value. With unsaved changes, SaveOptions.DONOTSAVECHANGES closes it without them, and SaveOptions.SAVECHANGES saves them first with file.saveAs, in the format the file's extension names and after the write-access check saveAs makes, and throws for a document without a file (a converted or recovered one included). SaveOptions.PROMPTTOSAVECHANGES, the default, throws, since a script cannot show the prompt. - The script checker reports SaveOptions.SAVECHANGES under filesWritten wherever the script reads it. - A pDFPreset in square brackets, such as [Smallest File Size], names the built-in preset of the name inside them. - artboardRange takes a whole number from 1 as well as a string; any other number throws. - With saveMultipleArtboards true, a .ai or EPS save also writes each artboard of the range to a file of its own. Without it the range is not used, but text that is not a range of artboard numbers throws. Document page: https://ai-scripting.docsforadobe.dev/jsobjref/Document/ --- crates/engine/src/cmd/edit.rs | 29 ++ crates/engine/src/script/dom.rs | 2 +- crates/engine/src/script/dom/save_open.rs | 240 +++++++++++++++- crates/engine/src/tests/script_save_open.rs | 257 ++++++++++++++++++ .../tests/it/script_host_vs_scriptcheck.rs | 18 +- crates/js/src/file_classes.rs | 31 +++ crates/js/src/host.rs | 10 +- crates/js/src/lib.rs | 2 +- crates/scriptcheck/src/analyze/features.rs | 17 ++ crates/scriptcheck/src/catalog.rs | 6 + crates/scriptcheck/src/tests.rs | 19 ++ docs/gaps.md | 3 +- docs/mcp.md | 40 ++- docs/roadmap.md | 2 +- docs/target-app-parity.md | 2 +- 15 files changed, 649 insertions(+), 29 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index ccee814d90..81c201d95f 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -39,6 +39,15 @@ pub fn specs() -> Vec { has_doc, doc_move ), + cmd!( + "document.setSaved", + "Set Saved State", + [], + None, + "{index?: the document (default: the current one), saved: true or false} records the document as saved (true: Close asks nothing until the next edit) or as having unsaved changes (false), without saving it or adding an undo step; a document already in that state is left as it is", + has_doc, + doc_set_saved + ), cmd!(query "document.inspect", "Inspect Document", [], None, "{depth?, childLimit?, ids?: [id…] (list just these nodes, of any level, in this order, under `nodes` in place of `layers`; an unknown id is an error; at most 10000), kind?: panel label such as Layer; Group; Path; Type or Image (exact, ignoring case; list every such node under `nodes`, each with `path`, its ancestor ids with the layer first, searching the subtrees of `ids` when given), limit?: at most this many entries of the list, offset?: entries skipped first (default 0; with `ids`, `kind`, `limit` or `offset` the reply adds `total`, the entries before paging)} → path (the document's file; null when automation read roots are in force and the file is outside them), layer tree (each node: id, name, kind, visible, locked, bounds, opacity (0–1) and opacityPct (0–100 %, the scale object.setProps takes) when below 1, blend when not Normal, fill, stroke and strokeWidth of objects and compound paths; a compound path's members have compoundMember: true instead of paint, which is the compound's), artboards, selection, history (a sliced tree reports childCount); without the scope options the reply is the whole layer tree", has_doc, doc_inspect), cmd!(query "document.node", "Inspect Object", [], None, "{id, summary?: compact summary, depth?: child levels in the summary (default all), childLimit?: children shown per node (default all; a level that shows fewer reports childCount)} → one object", has_doc, doc_node), cmd!(query "document.find", "Find Objects", [], None, "{name?: substring of the Layers panel name, kind?: panel label such as Group; Path; Type or Image (exact), text?: substring of type content, within?: [x, y, width, height] (an object's geometric bounds inside this rectangle, edges included; document points as document.inspect's bounds; layers never match this or the size filters), intersects?: [x, y, width, height] (bounds touching or overlapping it), minWidth?, maxWidth?, minHeight?, maxHeight?: pt (the bounds' size), minThickness?, maxThickness?: pt (the smaller of the bounds' width and height), minArea?, maxArea?: pt² (the bounds' width × height), minAnchors?, maxAnchors?: anchor points of a path (a compound path's members together; other objects never match), select?: bool (also select the matches, leaving out hidden and locked ones, those inside another match, and a compound path's members unless the compound path is isolated; Select > Reselect repeats it), limit?: max matches listed (default 100, 0 counts only)} → {matches: [{id, name, kind, path}], total, selected (with select: the count selected)}; at least one filter, all of them matching", has_doc, doc_find), @@ -257,6 +266,26 @@ fn doc_activate(s: &mut Session, p: &Value) -> Result { if s.set_active(i) { ok() } else { Err(bad("document.activate", "no such document")) } } +fn doc_set_saved(s: &mut Session, p: &Value) -> Result { + const C: &str = "document.setSaved"; + let i = opt_u64(p, C, "index")?.map(index).or(s.active_index()).ok_or(EngineError::NoDocument)?; + let saved = match p.get("saved") { + None | Some(Value::Null) => return Err(bad(C, "missing `saved`: true or false")), + Some(Value::Bool(b)) => *b, + Some(_) => return Err(bad(C, "`saved` must be true or false")), + }; + let uid = s.documents().get(i).map(|d| d.uid).ok_or_else(|| bad(C, "no such document"))?; + let st = s.document_mut(uid).ok_or_else(|| bad(C, "no such document"))?; + if st.is_dirty() == saved { + if saved { + st.mark_saved(); + } else { + st.mark_unsaved(); + } + } + ok() +} + fn doc_move(s: &mut Session, p: &Value) -> Result { let n = s.documents().len(); let from = match p.get("from") { diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 8e6c46e87d..e4a3e3a638 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -1865,7 +1865,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("selection", property(l, doc_selection, doc_set_selection)), ]); document.extend( - ["layers", "artboards", "pathItems", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "close"] + ["layers", "artboards", "pathItems", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer"] .into_iter() .map(|m| later(l, "Document", m)), ); diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index f54c2f3f0b..b2c9a56378 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -1,5 +1,6 @@ //! Saving, exporting and opening documents in the script object model: `Document.saveAs`, -//! `Document.exportFile`, `app.open` and `app.userInteractionLevel`, with the option classes the +//! `Document.exportFile`, `Document.fullName`, `Document.path`, `Document.saved`, +//! `Document.close`, `app.open` and `app.userInteractionLevel`, with the option classes the //! help pages , //! , //! , @@ -29,7 +30,25 @@ //! the default its help page gives and throws an error that says it is not available yet at any //! other value; a property the help pages do not list throws an error that names it, unless it is //! `undefined`. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default -//! keeps the preset's value. +//! keeps the preset's value. A `pDFPreset` in square brackets names the built-in preset of the +//! name inside them; the default preset's name and `[PDF/X-4:2008]` name VectorCraft Default and +//! PDF/X-4:2010. +//! - `artboardRange` is a string, or a number read as `String(number)`. With +//! `saveMultipleArtboards` true, a `.ai` save also writes each artboard of the range (all when it +//! is empty) to a file of its own, `-.ai`. An EPS save of a range of two or +//! more artboards writes the file at the path and `_.eps` for each of them, and an EPS +//! save of one artboard writes only the file at the path, holding that artboard. Without +//! `saveMultipleArtboards` the range is not used, but a value that is not written as a range of +//! artboard numbers throws. +//! - `Document.path` is a `Folder` for the folder of the document's file. A document that has no +//! file has a `fullName` of a `File` for its name in `Folder.current` and a `path` of `""`. +//! `fullName` and `path` of a document whose file the automation read roots do not allow throw +//! `Script file access denied`. Setting `Document.saved` runs `document.setSaved`. +//! - `Document.close` with unsaved changes closes without them with +//! `SaveOptions.DONOTSAVECHANGES`, and saves them to the document's file first with +//! `SaveOptions.SAVECHANGES`, which throws for a document that has no file (a converted or +//! recovered one included). `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws, since a +//! script cannot show the prompt. //! - `app.open(file, documentColorSpace?, options?)` takes `options` as a `PDFFileOptions` record: //! an object with `pageToOpen` and `pDFCropToBox`, used for that call only. Any other property //! but `typename` and `parent` throws the same error, unless it is `undefined`. @@ -44,8 +63,8 @@ use serde_json::{Map, Value, json}; use vectorcraft_js::{Data, HostClass, HostError, HostFunction, HostMember}; use super::{ - Answer, Host, Link, MAX_TEXT_BYTES, NO_ACTIVE_DOCUMENT, arg, boolean, command, current, doc_ref, given, method, named, num, on_doc, property, - text, this_doc, whole, + Answer, Host, Link, MAX_TEXT_BYTES, NO_ACTIVE_DOCUMENT, arg, boolean, command, current, doc_ref, get, given, method, named, num, on_doc, + property, text, this_doc, whole, }; /// The most a scale factor of an export takes, in percent. @@ -86,6 +105,7 @@ pub(super) const ENUMS: &[(&str, &[&str])] = &[ ("EPSPostScriptLevelEnum", &["LEVEL2", "LEVEL3"]), ("PDFOverprint", &["DISCARDPDFOVERPRINT", "PRESERVEPDFOVERPRINT"]), ("UserInteractionLevel", &["DISPLAYALERTS", "DONTDISPLAYALERTS"]), + ("SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"]), ]; const DISPLAY: &str = "UserInteractionLevel.DISPLAYALERTS"; @@ -165,9 +185,17 @@ fn compatibility(class: &str, d: &Data) -> std::result::Result<(), HostError> { } } -/// An artboard range: a string, given to the command as `range` unless it is empty. +/// An artboard range: a string, or a whole number from 1 read as `String(number)` reads it, given to +/// the command as `range` unless it is empty. Any other number throws. fn range(d: &Data, what: &str, p: &mut Map) -> std::result::Result<(), HostError> { - let Data::String(s) = d else { return Err(HostError::Type(format!("{what} must be a string"))) }; + let s = match d { + Data::String(s) => s.clone(), + Data::Number(n) => { + whole(*n).filter(|n| *n >= 1).ok_or_else(|| HostError::Range(format!("{what} must be a whole number from 1 or a range")))?; + vectorcraft_js::number_to_string(*n) + } + _ => return Err(HostError::Type(format!("{what} must be a string or a number"))), + }; if s.len() > MAX_TEXT_BYTES { return Err(HostError::Range(format!("{what} is too long"))); } @@ -189,17 +217,76 @@ fn ai_map(name: &str, d: &Data, p: &mut Map) -> std::result::Resu compatibility("IllustratorSaveOptions", d)?; None } + "artboardRange" | "saveMultipleArtboards" => return artboards_map("IllustratorSaveOptions", name, d, p), _ => return Ok(false), }; Ok(true) } +/// `artboardRange` and `saveMultipleArtboards` of a `.ai` or EPS save, as `range` and +/// [`MULTIPLE`] until [`artboard_files`] reads them together. +fn artboards_map(class: &str, name: &str, d: &Data, p: &mut Map) -> std::result::Result { + let what = format!("{class}.{name}"); + if name == "artboardRange" { + range(d, &what, p)?; + } else { + p.insert(MULTIPLE.into(), json!(boolean(d, &what)?)); + } + Ok(true) +} + +/// The key [`artboards_map`] keeps `saveMultipleArtboards` under. +const MULTIPLE: &str = "_multiple"; + +/// The params of a `.ai` (`format` `ai`) or EPS save for `saveMultipleArtboards` and +/// `artboardRange`: with `saveMultipleArtboards` true, the range (all when it is empty) goes to +/// `separateArtboards` of a `.ai` save or `useArtboards` of an EPS save, which write the artboards' +/// files; otherwise the range is not used, as the help pages say, but one that is not written as a +/// range ([`written_as_range`]) still throws. +fn artboard_files(format: &str, q: &mut Map) -> std::result::Result<(), HostError> { + let multiple = q.remove(MULTIPLE).and_then(|v| v.as_bool()).unwrap_or(false); + if !multiple { + if let Some(Value::String(r)) = q.remove("range") + && !r.trim().eq_ignore_ascii_case("all") + && !written_as_range(&r) + { + return Err(HostError::Range(format!("artboardRange `{r}` is not a range of artboard numbers"))); + } + } else if format == "ai" { + q.insert("separateArtboards".into(), json!(true)); + } else { + q.insert("useArtboards".into(), json!(true)); + } + Ok(()) +} + +/// Whether `r` is written as an artboard range, whatever artboards a document has: parts separated +/// by commas, each a number from 1, or two of them joined by `-` or `–` with either one left out +/// and the first no greater than the second. +fn written_as_range(r: &str) -> bool { + // A number of digits alone, from 1; past `u64` it counts as the largest. + let num = |t: &str| -> Option> { + let t = t.trim(); + if t.is_empty() { + return Some(None); + } + let n = t.bytes().all(|b| b.is_ascii_digit()).then(|| t.parse::().unwrap_or(u64::MAX))?; + (n >= 1).then_some(Some(n)) + }; + r.split(',').map(str::trim).filter(|p| !p.is_empty()).all(|part| match part.replace('\u{2013}', "-").split_once('-') { + Some((a, b)) => match (num(a), num(b)) { + (Some(Some(a)), Some(Some(b))) => a <= b, + (Some(a), Some(b)) => a.is_some() || b.is_some(), + _ => false, + }, + None => matches!(num(part), Some(Some(_))), + }) +} + const AI_KEPT: &[(&str, Default)] = &[ - ("artboardRange", Default::Text("")), ("embedLinkedFiles", Default::Bool(false)), ("flattenOutput", Default::Member("OutputFlattening", "PRESERVEAPPEARANCE")), ("fontSubsetThreshold", Default::Num(100.0)), - ("saveMultipleArtboards", Default::Bool(false)), ]; fn ai_starts() -> Vec<(&'static str, Data)> { @@ -236,18 +323,17 @@ fn eps_map(name: &str, d: &Data, p: &mut Map) -> std::result::Res p.insert("overprints".into(), json!(if keep { "preserve" } else { "discard" })); } "compatibility" => compatibility("EPSSaveOptions", d)?, + "artboardRange" | "saveMultipleArtboards" => return artboards_map("EPSSaveOptions", name, d, p), _ => return Ok(false), } Ok(true) } const EPS_KEPT: &[(&str, Default)] = &[ - ("artboardRange", Default::Text("")), ("compatibleGradientPrinting", Default::Bool(false)), ("embedAllFonts", Default::Bool(false)), ("embedLinkedFiles", Default::Unset), ("flattenOuput", Default::Unset), - ("saveMultipleArtboards", Default::Bool(false)), ]; fn eps_starts() -> Vec<(&'static str, Data)> { @@ -578,6 +664,29 @@ fn plain(real: std::path::PathBuf) -> String { crate::cmd::findfiles::plain(real).to_string_lossy().into_owned() } +/// The built-in preset names scripts use that VectorCraft's built-in presets name otherwise, and the +/// preset each one names here. +const PRESET_ALIASES: &[(&str, &str)] = &[ + ("Illustrator Default", vectorcraft_pdf::DEFAULT_PRESET), // brand-ok: the preset name scripts use + ("PDF/X-4:2008", "PDF/X-4:2010"), +]; + +/// A `pDFPreset` in square brackets (`[Smallest File Size]`) names the built-in preset of the name +/// inside the brackets, or the one [`PRESET_ALIASES`] gives for it. A preset the name already +/// names, a saved preset called `[Name]` included, is left as it is, and any other name is left for +/// the save to refuse. +fn builtin_preset_name(h: &Host, q: &mut Map) { + let Some(name) = q.get("preset").and_then(Value::as_str) else { return }; + let s = h.session.borrow(); + if crate::cmd::fileio::pdf::find_preset(name, &s.prefs.pdf_presets).is_some() { + return; + } + let Some(inside) = name.trim().strip_prefix('[').and_then(|n| n.strip_suffix(']')) else { return }; + let inside = PRESET_ALIASES.iter().find(|(alias, _)| alias.eq_ignore_ascii_case(inside.trim())).map_or(inside, |(_, to)| to); + let Some(builtin) = vectorcraft_pdf::builtin_preset(inside) else { return }; + q.insert("preset".into(), json!(builtin.name)); +} + /// `document.saveAs(file, options?)`: `file.saveAs` on the document, in the format the options' /// class names (`ai`, `eps`, `pdf`), or without options in the format of the path's extension. fn doc_save_as(h: &Host, a: &[Data]) -> Answer { @@ -594,7 +703,12 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer { let Some((class, format)) = SAVE_CLASSES.iter().find(|(c, _)| Some(c.name) == name) else { return Err(HostError::Type("saveAs options must be IllustratorSaveOptions, EPSSaveOptions or PDFSaveOptions".into())); }; - let q = options_params(class, o)?; + let mut q = options_params(class, o)?; + if *format == "pdf" { + builtin_preset_name(h, &mut q); + } else { + artboard_files(format, &mut q)?; + } p.insert("format".into(), json!(format)); if *format == "ai" { p.extend(q); @@ -717,6 +831,101 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { Ok(doc_ref(h, st.uid)) } +/// The document's file, `None` for a document that has none, or `Script file access denied` with +/// the document's name when the automation read roots do not allow the file to be named +/// ([`crate::file_access::check_read`]), as `app.getIsFileOpen` reads them. +fn shown_file(st: &crate::DocState) -> std::result::Result, HostError> { + match st.path.as_deref() { + Some(p) if crate::file_access::check_read(p).is_err() => { + Err(HostError::Error(format!("{}: {}", super::super::files::ACCESS_DENIED, st.title()))) + } + p => Ok(p), + } +} + +/// `document.fullName`: a `File` for the document's file, or, for a document that has none, a +/// `File` for its name in `Folder.current`. +fn doc_full_name(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + super::with_doc(h, doc, |_, st| { + Ok(match shown_file(st)? { + Some(p) => vectorcraft_js::file_ref(p), + None => vectorcraft_js::file_ref(&st.title()), + }) + }) +} + +/// `document.path`: a `Folder` for the folder of the document's file, or an empty string for a +/// document that has none. +fn doc_path(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + let folder = super::with_doc(h, doc, |_, st| { + Ok(shown_file(st)?.and_then(|p| { + let parent = std::path::Path::new(p).parent()?.to_string_lossy().into_owned(); + (!parent.is_empty()).then_some(parent) + })) + })?; + Ok(folder.map_or_else(|| text(""), |f| vectorcraft_js::folder_ref(&f))) +} + +/// `document.saved`: whether the document has no changes since it was opened or last saved. +fn doc_saved(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + Ok(Data::Bool(super::with_doc(h, doc, |_, st| !st.is_dirty()))) +} + +/// `document.saved = value`: `document.setSaved`, which records the document as saved or as having +/// unsaved changes without saving it. +fn doc_set_saved(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + let saved = boolean(arg(a, 1), "Document.saved")?; + command(h, "document.setSaved", &json!({"index": doc.index, "saved": saved}))?; + Ok(Data::Undefined) +} + +/// The error `close` gives for a document with unsaved changes with +/// `SaveOptions.PROMPTTOSAVECHANGES`. +const UNSAVED_CHANGES: &str = + "the document has unsaved changes: save them first, or close with SaveOptions.SAVECHANGES or SaveOptions.DONOTSAVECHANGES"; + +/// The error `close(SaveOptions.SAVECHANGES)` gives for a document with unsaved changes that has +/// no file to save to. +const NO_FILE_TO_SAVE: &str = + "the document has unsaved changes and no file to save them to: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; + +/// `document.close(saveOptions?)`: `file.close` of the document. A document without unsaved +/// changes closes with any `SaveOptions`. With unsaved changes, `SaveOptions.DONOTSAVECHANGES` +/// closes it without them; `SaveOptions.SAVECHANGES` saves them to the document's file with +/// `file.saveAs` in the format its extension names, after the write-access check `saveAs` makes of +/// the path, and then closes it, and throws [`NO_FILE_TO_SAVE`] +/// for a document that has no file, a converted or recovered one included; and +/// `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws [`UNSAVED_CHANGES`], since a script +/// cannot show the prompt. +fn doc_close(h: &Host, a: &[Data]) -> Answer { + let doc = this_doc(h, a)?; + let how = match given(arg(a, 1)).filter(|d| !matches!(d, Data::Null)) { + Some(d) => member(d, "SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"], "saveOptions")?, + None => "PROMPTTOSAVECHANGES", + }; + let (dirty, file) = super::with_doc(h, doc, |_, st| (st.is_dirty(), st.path.clone().filter(|_| !st.converted && !st.recovered))); + if dirty { + match how { + "DONOTSAVECHANGES" => {} + "SAVECHANGES" => { + let path = file.ok_or_else(|| HostError::Error(NO_FILE_TO_SAVE.into()))?; + // A refusal names the document, as `fullName` does when the read roots hide its file. + let name = super::with_doc(h, doc, |_, st| st.title()); + let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?; + let p = json!({"path": plain(real)}); + exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "file.saveAs", &p)))?; + } + _ => return Err(HostError::Error(UNSAVED_CHANGES.into())), + } + } + command(h, "file.close", &json!({"index": doc.index}))?; + Ok(Data::Undefined) +} + fn app_interaction(h: &Host, _: &[Data]) -> Answer { Ok(text(if h.dom.save_options.quiet.get() { QUIET } else { DISPLAY })) } @@ -734,7 +943,14 @@ pub(super) fn application_members(l: &Link) -> Vec<(String, HostMember)> { /// The members these add to `Document`. pub(super) fn document_members(l: &Link) -> Vec<(String, HostMember)> { - named(vec![("saveAs", method(l, doc_save_as)), ("exportFile", method(l, doc_export_file))]) + named(vec![ + ("saveAs", method(l, doc_save_as)), + ("exportFile", method(l, doc_export_file)), + ("fullName", get(l, doc_full_name)), + ("path", get(l, doc_path)), + ("saved", property(l, doc_saved, doc_set_saved)), + ("close", method(l, doc_close)), + ]) } /// The option classes: each `new Name()` gives a record with its `typename` and the defaults its diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 126c7c3947..4389838807 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -477,6 +477,7 @@ fn bad_arguments_are_refused_with_an_error() { let cases: Vec<(String, &str)> = vec![ ("app.activeDocument.saveAs('x.svg');".into(), "saveAs needs a File"), (format!("app.activeDocument.saveAs({{'\\u0000fileRef': {}}});", quoted(&dir.join("x.svg"))), "is not plain data"), + (format!("app.activeDocument.saveAs({{'\\u0000folderRef': {}}});", quoted(&dir)), "is not plain data"), (format!("app.activeDocument.saveAs({f}, {{typename: 'Nope'}});"), "saveAs options must be"), (format!("app.activeDocument.saveAs({f}, new ExportOptionsSVG());"), "saveAs options must be"), (format!("var o = new IllustratorSaveOptions(); o.compressed = 'yes'; app.activeDocument.saveAs({f}, o);"), "must be true or false"), @@ -624,3 +625,259 @@ fn open_takes_the_page_and_crop_box_of_its_options() { assert_eq!(s.active().unwrap().doc.artboards.len(), 2, "both pages"); let _ = std::fs::remove_dir_all(base); } + +/// `fullName` and `path` name the document's file and folder once it has one, `saved` follows its +/// changes, and `close` with `SaveOptions.DONOTSAVECHANGES` closes it. +#[test] +fn full_name_path_saved_and_close_follow_the_documents_file() { + let base = folder("fullname"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.log([d.fullName instanceof File, d.fullName.name === d.name, d.fullName.fsName === new File(d.name).fsName, d.path === '', d.saved]);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}}); vc.log(d.saved);\n\ + d.saveAs(new File(dir + '/a.svg'));\n\ + vc.log([d.fullName instanceof File, d.fullName.fsName, d.fullName.name, d.path instanceof Folder, d.path.fsName, d.saved]);\n\ + vc.run('shape.rectangle', {{x: 20, y: 20, width: 5, height: 5}}); vc.log(d.saved);\n\ + var e = ''; try {{ d.close(); }} catch (x) {{ e = String(x); }} vc.log([e, app.documents.length]);\n\ + var before = new File(dir + '/a.svg').length; d.close(SaveOptions.SAVECHANGES);\n\ + vc.log([app.documents.length, new File(dir + '/a.svg').length > before]);\n\ + var n = app.documents.add(DocumentColorSpace.RGB, 200, 100); vc.run('shape.rectangle', {{x: 10, y: 10, width: 5, height: 5}});\n\ + e = ''; try {{ n.close(SaveOptions.SAVECHANGES); }} catch (x) {{ e = String(x); }} vc.log([e, app.documents.length]);\n\ + n.close(SaveOptions.DONOTSAVECHANGES); vc.log(app.documents.length);" + ), + ); + assert_eq!(out[0], json!([true, true, true, true, true]), "an untouched document that has no file"); + assert_eq!(out[1], json!(false), "an edit leaves changes to save"); + let file = dir.join("a.svg"); + assert_eq!( + out[2], + json!([true, file.to_string_lossy(), "a.svg", true, dir.to_string_lossy(), true]), + "after saveAs the document's file and folder" + ); + assert_eq!(out[3], json!(false)); + assert!(out[4][0].as_str().unwrap().contains("unsaved changes"), "{}", out[4]); + assert_eq!(out[4][1], json!(1), "without SaveOptions the document stays open"); + assert_eq!(out[5], json!([0, true]), "SAVECHANGES saves the edit to the document's file and closes it"); + assert!(out[6][0].as_str().unwrap().contains("no file to save"), "{}", out[6]); + assert_eq!(out[6][1], json!(1), "SAVECHANGES without a file leaves the document open"); + assert_eq!(out[7], json!(0)); + assert!(s.documents().is_empty()); + let e = failure(&mut s, &base, "app.documents.add(); app.activeDocument.close('DONOTSAVECHANGES');"); + assert!(e.contains("SaveOptions"), "{e}"); + let _ = std::fs::remove_dir_all(base); +} + +/// A document without unsaved changes closes with `SaveOptions.SAVECHANGES` and with no argument. +#[test] +fn a_document_without_unsaved_changes_closes_with_any_save_options() { + let base = folder("closeclean"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}}); d.saveAs(new File(dir + '/a.svg'));\n\ + var e = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.log([d.saved, e.saved, app.documents.length]);\n\ + d.close(SaveOptions.SAVECHANGES); vc.log(app.documents.length);\n\ + e.close(); vc.log(app.documents.length);" + ), + ); + assert_eq!(out, json!([[true, true, 2], 1, 0])); + let _ = std::fs::remove_dir_all(base); +} + +/// Setting `Document.saved` records the document's saved state without saving it: `true` lets +/// `close()` close a document with edits, and `false` makes an untouched one ask. +#[test] +fn setting_saved_records_the_saved_state() { + let base = folder("setsaved"); + let mut s = session(&base); + data_folder(&mut s, &base); + let out = logged( + &mut s, + &base, + "var d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {x: 10, y: 10, width: 50, height: 20});\n\ + vc.log(d.saved); d.saved = true; vc.log(d.saved); d.close(); vc.log(app.documents.length);\n\ + var e = app.documents.add(DocumentColorSpace.RGB, 200, 100); vc.log(e.saved); e.saved = false; vc.log(e.saved);\n\ + var m = ''; try { e.close(); } catch (x) { m = String(x); } vc.log([m, app.documents.length]);\n\ + m = ''; try { e.saved = 'yes'; } catch (x) { m = String(x); } vc.log(m);", + ); + assert_eq!(out[0], json!(false), "an edit leaves changes to save"); + assert_eq!(out[1], json!(true)); + assert_eq!(out[2], json!(0), "close() closes a document set as saved"); + assert_eq!(out[3], json!(true)); + assert_eq!(out[4], json!(false)); + assert!(out[5][0].as_str().unwrap().contains("unsaved changes"), "{}", out[5]); + assert_eq!(out[5][1], json!(1), "a document set as unsaved stays open"); + assert!(out[6].as_str().unwrap().contains("true or false"), "{}", out[6]); + assert!(s.active().unwrap().is_dirty(), "the state stays after the run"); + let _ = std::fs::remove_dir_all(base); +} + +/// With automation read roots that leave out the document's file, `fullName` and `path` throw +/// instead of naming another file. +#[test] +fn full_name_and_path_leave_out_a_file_outside_the_read_roots() { + let base = folder("fullnameroots"); + let mut s = session(&base); + data_folder(&mut s, &base); + let file = base.join("outside/hidden.svg"); + s.execute("file.new", &json!({})).unwrap(); + s.execute("document.save", &json!({"path": file.to_string_lossy()})).unwrap(); + let query = "var d = app.activeDocument; vc.log([d.fullName.name, d.fullName.fsName, d.path === '' ? '' : d.path.fsName]);"; + let out = logged(&mut s, &base, query); + let outside = base.join("outside"); + assert_eq!(out[0], json!(["hidden.svg", file.to_string_lossy(), outside.to_string_lossy()]), "no read roots: the whole path"); + let roots = crate::file_access::AutomationRoots::new(&[&base.join("main"), &base.join("settings")], &[&base.join("settings")]).unwrap().unwrap(); + let hidden = "var d = app.activeDocument, r = [];\n\ + try { r.push(d.fullName.fsName); } catch (e) { r.push(e.message); }\n\ + try { r.push(String(d.path)); } catch (e) { r.push(e.message); }\n\ + vc.log(r);"; + let out = crate::file_access::confine(Some(&roots), || logged(&mut s, &base, hidden)); + for m in out[0].as_array().unwrap() { + let m = m.as_str().unwrap(); + assert!(m.starts_with(DENIED) && m.ends_with("hidden.svg"), "{m}"); + assert!(!m.contains("outside"), "the folder outside the read roots is not named: {m}"); + } + let before = std::fs::read(&file).unwrap(); + let e = failure( + &mut s, + &base, + "vc.run('shape.rectangle', {x: 10, y: 10, width: 50, height: 20}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(e.contains(DENIED) && !e.contains("outside"), "SAVECHANGES does not write a file the script may not: {e}"); + assert_eq!(std::fs::read(&file).unwrap(), before, "the file is left as it was"); + assert_eq!(s.documents().len(), 1, "the document stays open"); + let _ = std::fs::remove_dir_all(base); +} + +/// A `pDFPreset` in square brackets names the built-in preset of the name inside them, and a name +/// that is not a preset either way is refused. +#[test] +fn a_bracketed_pdf_preset_names_the_built_in_preset() { + let base = folder("brackets"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}});\n\ + var o = new PDFSaveOptions(); o.pDFPreset = '[Smallest File Size]'; d.saveAs(new File(dir + '/small.pdf'), o);\n\ + o.pDFPreset = '[Illustrator Default]'; d.saveAs(new File(dir + '/default.pdf'), o);\n\ + o.pDFPreset = '[PDF/X-4:2008]'; d.saveAs(new File(dir + '/x4.pdf'), o);" + ), + ); + let small = std::fs::read(dir.join("small.pdf")).unwrap(); + assert!(String::from_utf8_lossy(&small[..200.min(small.len())]).contains("/Linearized 1"), "Smallest File Size writes a linearized file"); + assert!(dir.join("default.pdf").is_file()); + let x4 = String::from_utf8_lossy(&std::fs::read(dir.join("x4.pdf")).unwrap()).into_owned(); + assert!(x4.contains("PDF/X-4"), "the PDF/X-4 preset writes a PDF/X-4 file"); + for bad in ["[Nope]", "[Basic Default]", "[Ilustrator Default]"] { + let e = failure( + &mut s, + &base, + &format!("Folder.userData; var o = new PDFSaveOptions(); o.pDFPreset = '{bad}'; app.activeDocument.saveAs(new File({d} + '/n.pdf'), o);"), + ); + assert!(e.contains("unknown PDF preset"), "{bad}: {e}"); + } + let _ = std::fs::remove_dir_all(base); +} + +/// A number given as `artboardRange` is read as `String(number)` reads it. +#[test] +fn a_number_artboard_range_names_that_artboard() { + let base = folder("rangenumber"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('artboard.new', {{x: 300, y: 0, width: 60, height: 80}});\n\ + var o = new PDFSaveOptions(); o.artboardRange = 2; d.saveAs(new File(dir + '/two.pdf'), o);" + ), + ); + let pdf = vectorcraft_pdf::import(&std::fs::read(dir.join("two.pdf")).unwrap()).unwrap(); + assert_eq!(pdf.artboards.len(), 1, "one page"); + let r = pdf.artboards[0].rect; + assert!((r.width() - 60.0).abs() < 0.01 && (r.height() - 80.0).abs() < 0.01, "the second artboard: {r:?}"); + let _ = std::fs::remove_dir_all(base); +} + +/// With `saveMultipleArtboards`, a `.ai` or EPS save also writes a file for each artboard of +/// `artboardRange`; without it the range is not used, and only a value that is not written as a +/// range throws. +#[test] +fn save_multiple_artboards_writes_a_file_per_artboard() { + let base = folder("multiple"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let names = |sub: &str| { + let mut v: Vec = std::fs::read_dir(dir.join(sub)).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect(); + v.sort(); + v + }; + logged( + &mut s, + &base, + &format!( + "Folder.userData; var dir = {d}, d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('artboard.new', {{x: 300, y: 0, width: 60, height: 80}});\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}});\n\ + var names = ['ai', 'eps', 'aione', 'epsone', 'aioff'];\n\ + for (var i = 0; i < names.length; i++) new Folder(dir + '/' + names[i]).create();\n\ + var a = new IllustratorSaveOptions(); a.saveMultipleArtboards = true; d.saveAs(new File(dir + '/ai/a.ai'), a);\n\ + var e = new EPSSaveOptions(); e.saveMultipleArtboards = true; d.saveAs(new File(dir + '/eps/a.eps'), e);\n\ + a.artboardRange = '2'; d.saveAs(new File(dir + '/aione/a.ai'), a);\n\ + e.artboardRange = 2; d.saveAs(new File(dir + '/epsone/a.eps'), e);\n\ + a.saveMultipleArtboards = false; d.saveAs(new File(dir + '/aioff/a.ai'), a);" + ), + ); + assert_eq!(names("ai"), ["a-Artboard-1.ai", "a-Artboard-2.ai", "a.ai"], "the file and one for each of the two artboards"); + assert_eq!(names("eps"), ["a.eps", "a_Artboard-1.eps", "a_Artboard-2.eps"], "the central file and one for each of the two artboards"); + assert_eq!(names("aione"), ["a-Artboard-2.ai", "a.ai"], "the file and one for artboard 2"); + assert_eq!(names("epsone"), ["a.eps"], "one artboard: its file alone"); + let eps = String::from_utf8_lossy(&std::fs::read(dir.join("epsone/a.eps")).unwrap()).into_owned(); + let bbox = eps.lines().find(|l| l.starts_with("%%BoundingBox:")).unwrap_or_default(); + assert_eq!(bbox.split_whitespace().skip(1).collect::>(), ["0", "0", "60", "80"], "the file holds artboard 2: {bbox}"); + assert_eq!(names("aioff"), ["a.ai"], "without saveMultipleArtboards the range is not used"); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var a = new IllustratorSaveOptions(); a.artboardRange = 3; \ + app.activeDocument.saveAs(new File({d} + '/aioff/c.ai'), a);" + ), + ); + assert!(dir.join("aioff/c.ai").is_file(), "a range past the document's artboards is not used and does not stop the save"); + for bad in ["'abc'", "'0-'", "'3-1'", "'-'", "-1", "2.5", "0"] { + let e = failure( + &mut s, + &base, + &format!( + "Folder.userData; var a = new IllustratorSaveOptions(); a.artboardRange = {bad}; \ + app.activeDocument.saveAs(new File({d} + '/aioff/b.ai'), a);" + ), + ); + assert!(e.contains("range"), "{bad}: {e}"); + } + assert!(!dir.join("aioff/b.ai").exists(), "a bad range writes nothing"); + let _ = std::fs::remove_dir_all(base); +} diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index a0794be35c..d20c3ab3e6 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -39,12 +39,15 @@ const OUTSIDE: &[(&str, &str, &str)] = &[ ("Folder.prototype.execute", "var d = new Folder(p); d.execute();", "filesOpened"), ("Document.prototype.saveAs", "app.activeDocument.saveAs(f);", "filesWritten"), ("Document.prototype.exportFile", "app.activeDocument.exportFile(f, ExportType.PNG24);", "filesWritten"), + ("SaveOptions.SAVECHANGES", "app.activeDocument.close(SaveOptions.SAVECHANGES);", "filesWritten"), ]; /// The names the host adds that stay inside the document and the run, by the object that has them. /// Reading a file or a folder, a file dialog and a message to the person do not change anything /// outside it. The document model (`app`, its classes and the enumerations) acts on the open -/// documents; `Document.close` throws "not available yet". `app.open` reads the file it is given. +/// documents; `Document.close` closes a document, and saves it to its own file only when it is given +/// `SaveOptions.SAVECHANGES`, which has its row above. `Document.fullName` and +/// `Document.path` only name its file and folder. `app.open` reads the file it is given. const INSIDE: &[(&str, &str)] = &[ ("", "$ File Folder alert confirm localize prompt toSource"), ("Object.prototype.", "toSource"), @@ -98,9 +101,9 @@ const INSIDE: &[(&str, &str)] = &[ ("Document.", "prototype"), ( "Document.prototype.", - "activeLayer activeLayer= artboards artboards= close close= constructor convertCoordinate documentColorSpace \ - groupItems groupItems= height layers layers= name pageItems parent pathItems pathItems= rulerOrigin rulerOrigin= \ - rulerUnits selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ + "activeLayer activeLayer= artboards artboards= close constructor convertCoordinate documentColorSpace fullName \ + groupItems groupItems= height layers layers= name pageItems parent path pathItems pathItems= rulerOrigin rulerOrigin= \ + rulerUnits saved saved= selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ views views= width", ), ("Layer.", "prototype"), @@ -132,7 +135,11 @@ const INSIDE: &[(&str, &str)] = &[ ("RulerUnits.", "Centimeters Inches Millimeters Picas Pixels Points Qs Unknown"), ("ZOrderMethod.", "BRINGFORWARD BRINGTOFRONT SENDBACKWARD SENDTOBACK"), // The enumerations of saving, exporting and opening. - ("", "Compatibility EPSPostScriptLevelEnum EPSPreview ExportType PDFBoxType PDFCompatibility PDFOverprint UserInteractionLevel"), + ( + "", + "Compatibility EPSPostScriptLevelEnum EPSPreview ExportType PDFBoxType PDFCompatibility PDFOverprint SaveOptions \ + UserInteractionLevel", + ), ( "Compatibility.", "ILLUSTRATOR10 ILLUSTRATOR11 ILLUSTRATOR12 ILLUSTRATOR13 ILLUSTRATOR14 ILLUSTRATOR15 ILLUSTRATOR16 ILLUSTRATOR17 \ @@ -144,6 +151,7 @@ const INSIDE: &[(&str, &str)] = &[ ("PDFBoxType.", "PDFARTBOX PDFBLEEDBOX PDFBOUNDINGBOX PDFCROPBOX PDFMEDIABOX PDFTRIMBOX"), ("PDFCompatibility.", "ACROBAT4 ACROBAT5 ACROBAT6 ACROBAT7 ACROBAT8"), ("PDFOverprint.", "DISCARDPDFOVERPRINT PRESERVEPDFOVERPRINT"), + ("SaveOptions.", "DONOTSAVECHANGES PROMPTTOSAVECHANGES"), ("UserInteractionLevel.", "DISPLAYALERTS DONTDISPLAYALERTS"), ]; diff --git a/crates/js/src/file_classes.rs b/crates/js/src/file_classes.rs index f4f2064812..8083e6f46c 100644 --- a/crates/js/src/file_classes.rs +++ b/crates/js/src/file_classes.rs @@ -54,6 +54,11 @@ impl Classes { /// plain object a script made that carries the key is refused. pub const FILE_REF_KEY: &str = "\u{0}fileRef"; +/// The one key of the [`crate::Data`] object a host gives for a `Folder`, with the folder's path in +/// the host's platform form as its value. A plain object a script made that carries the key is +/// refused. +pub const FOLDER_REF_KEY: &str = "\u{0}folderRef"; + /// The path of the `File` that `d` stands for ([`FILE_REF_KEY`]). pub fn file_ref_path(d: &crate::Data) -> Option<&str> { let crate::Data::Object(items) = d else { return None }; @@ -63,7 +68,33 @@ pub fn file_ref_path(d: &crate::Data) -> Option<&str> { } } +/// What a host gives for a `File` at `path`, in the host's platform form: the script receives a +/// `File` object for it. +pub fn file_ref(path: &str) -> crate::Data { + crate::Data::Object(vec![(FILE_REF_KEY.to_string(), crate::Data::String(path.to_string()))]) +} + +/// What a host gives for a `Folder` at `path`, in the host's platform form: the script receives a +/// `Folder` object for it. +pub fn folder_ref(path: &str) -> crate::Data { + crate::Data::Object(vec![(FOLDER_REF_KEY.to_string(), crate::Data::String(path.to_string()))]) +} + impl Interp { + /// A new `File` (or, with `folder`, a `Folder`) for `path`, a path in the host's platform form + /// that a host gave ([`file_ref`], [`folder_ref`]). The host's `parse` reads it from + /// `Folder.current`, as it reads the path of `new File()`, so a relative path names a file there. + pub(crate) fn write_fs_ref(&mut self, path: &str, folder: bool) -> JsResult { + let c = classes(self)?; + let proto = if folder { c.folder_proto } else { c.file_proto }; + let text = Value::str(path); + let fs = self.rooted(std::slice::from_ref(&text), |i| { + let p = parse_text(i, text.clone(), true)?; + i.rooted(std::slice::from_ref(&p), |i| field(i, &p, "fs")) + })?; + instance(self, proto, fs) + } + /// The [`crate::Data`] for `id` when it is a `File` the `File` class made (its prototype is /// `File.prototype` and it holds its path in its [`Class::FsEntry`]), as [`file_ref_path`] reads /// it; `None` for any other object, one made with `Object.create(File.prototype)` included. diff --git a/crates/js/src/host.rs b/crates/js/src/host.rs index a639dbd0cb..76a36d25c6 100644 --- a/crates/js/src/host.rs +++ b/crates/js/src/host.rs @@ -321,7 +321,7 @@ impl Interp { self.use_fuel()?; self.charge_reading(r, k.len().saturating_mul(3).saturating_add(8))?; let name = String::from_utf16_lossy(&k); - if r.hosted && (name == crate::HOST_REF_KEY || name == crate::FILE_REF_KEY) { + if r.hosted && (name == crate::HOST_REF_KEY || name == crate::FILE_REF_KEY || name == crate::FOLDER_REF_KEY) { return Err(self.data_error(r, ErrorType::Type, "is not plain data")); } r.path.push(Step::Name(k)); @@ -345,6 +345,14 @@ impl Interp { if depth > self.data_limits.depth { return Err(self.throw(ErrorType::Range, "a host value is nested too deep")); } + // A host member's `File` or `Folder` ([`crate::file_ref`], [`crate::folder_ref`]). + if self.write_hosted + && let Data::Object(items) = &d + && let [(k, Data::String(path))] = items.as_slice() + && (k == crate::FILE_REF_KEY || k == crate::FOLDER_REF_KEY) + { + return self.write_fs_ref(path, k == crate::FOLDER_REF_KEY); + } Ok(match d { Data::Undefined => Value::Undefined, Data::Null => Value::Null, diff --git a/crates/js/src/lib.rs b/crates/js/src/lib.rs index 45f6aa61e4..9d32e92b26 100644 --- a/crates/js/src/lib.rs +++ b/crates/js/src/lib.rs @@ -81,7 +81,7 @@ pub use ast::{ }; pub use builtins::extensions::Localization; pub use error::{SyntaxError, TOO_DEEP, TOO_LONG}; -pub use file_classes::{FILE_REF_KEY, file_ref_path}; +pub use file_classes::{FILE_REF_KEY, FOLDER_REF_KEY, file_ref, file_ref_path, folder_ref}; pub use host::{Arg, CallSite, Data, DataLimits, HostError, HostFunction, HostItem, ScriptItem, SiteFunction}; pub use host_classes::{HOST_REF_KEY, HostClass, HostMember, host_ref, host_ref_parts}; pub use lexer::{Goal, Lexer}; diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index d17a580560..492bf4eb19 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -130,6 +130,13 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } + /// `SaveOptions.SAVECHANGES` read at `line`: a `Document.close` given it saves the document to + /// its own file, and the value may reach `close` through a variable or an argument. + fn save_changes(&mut self, line: Option) { + self.acc.feature(FeatureId::FileWrite, line); + self.acc.outside(OutsideId::FilesWritten, line, None); + } + /// A File object's `length`, `hidden` or `readonly` set at `line`: the file changes. fn file_setter(&mut self, line: Option) { self.acc.feature(FeatureId::FileWrite, line); @@ -200,6 +207,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else if of(catalog::FOLDER) && catalog::FOLDER_PLACES.contains(&n) { self.acc.feature(FeatureId::FilePlaces, line); } + if n == catalog::SAVE_CHANGES { + self.save_changes(line); + } if n == catalog::ON_DRAW { self.acc.feature(FeatureId::ScriptuiDrawing, line); } @@ -419,6 +429,13 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { if t.text.contains(catalog::ACTION_TEXT) { self.acc.feature(FeatureId::Actions, line); } + // `SaveOptions['SAVECHANGES']`, or the value written as the string `"SaveOptions.SAVECHANGES"`. + let value = unquote(t.text, 32); + if value == catalog::SAVE_CHANGES + || value.strip_prefix(catalog::SAVE_OPTIONS).and_then(|r| r.strip_prefix('.')) == Some(catalog::SAVE_CHANGES) + { + self.save_changes(line); + } let compares = h0.is_some_and(|s| s.kind == T::Punct && matches!(s.text, "==" | "===" | "!=" | "!==")); if compares && word(h1, "typename") && is(h2, ".") { let name = unquote(t.text, self.acc.limits.echo.saturating_add(1)); diff --git a/crates/scriptcheck/src/catalog.rs b/crates/scriptcheck/src/catalog.rs index a73dd557d6..7ed0a20efd 100644 --- a/crates/scriptcheck/src/catalog.rs +++ b/crates/scriptcheck/src/catalog.rs @@ -77,6 +77,12 @@ pub(crate) const DOM_ROOTS: [&str; 4] = ["app", "activeDocument", "documents", " // Document methods that write the file they are given: https://ai-scripting.docsforadobe.dev/jsobjref/Document/ pub(crate) const DOM_FILE_WRITES: &[&str] = &["exportFile", "saveAs"]; +// The save option of `Document.close` that saves the document to its own file: +// https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and +// https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/ (SaveOptions). +pub(crate) const SAVE_CHANGES: &str = "SAVECHANGES"; +pub(crate) const SAVE_OPTIONS: &str = "SaveOptions"; + // Application methods that page doesn't list, named in public forum posts: // https://community.adobe.com/t5/illustrator-discussions/changes-in-cs6/td-p/4173362 (executeMenuCommand, // doScript, loadAction, unloadAction) and diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 76d78f822b..1596b37eed 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -543,6 +543,25 @@ fn save_as_and_export_file_write_a_file() { assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[3, 4][..])]); } +/// `SaveOptions.SAVECHANGES` makes a document's `close` save it to its own file, read directly, in +/// brackets, as a string or through a variable; closing without it, and the other save options, +/// write nothing. +#[test] +fn closing_with_save_changes_writes_a_file() { + let r = report(concat!( + "app.activeDocument.close();\n", + "app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);\n", + "app.activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES);\n", + "app.activeDocument.close(SaveOptions.SAVECHANGES);\n", + "var how = SaveOptions['SAVECHANGES'];\n", + "documents[0].close(how);\n", + "documents[1].close('SaveOptions.SAVECHANGES');\n", + "var w = new Window('dialog'); w.close(1);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 5, 7][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[4, 5, 7][..])]); +} + /// `saveAs` and `exportFile` called with their names as string literals in brackets write the file /// too; reading the method without calling it does not. #[test] diff --git a/docs/gaps.md b/docs/gaps.md index cecbd9c4c4..46a4d063b5 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -810,7 +810,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Missing:** the rest of the document object model for scripts (layers, artboards, paths, type and the other classes) and the `#engine` script directive (#1183 is open). Scripts have `app`, the open documents, new documents, each document's selection and its page items, and save, export and open documents with - `Document.saveAs`, `Document.exportFile` and `app.open`. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` + `Document.saveAs`, `Document.exportFile` and `app.open`, read a document's `fullName`, `path` and `saved`, and + close it with `Document.close`. File › Scripts › Other Script… and `script.run` run JavaScript files over the command registry, `#targetengine` runs a script in a named engine whose globals last between runs, File › Scripts lists the scripts of the Scripts folder, and Window › Script Console shows their output, errors and run reports. Actions, Batch, Variables (text, visibility, image and graph), data set CSV import and diff --git a/docs/mcp.md b/docs/mcp.md index 5dd133dc00..ed7af26ab5 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2562,7 +2562,8 @@ control character, in the first 8 KiB) or `tooLarge` (over 8 MiB). For a script, - `outside` lists what the script does outside the document: `filesWritten` (with the open modes used; setting a File object's `length`, `hidden` or `readonly` counts too, on any object that may be a File object; only `new Folder(…)` and the `Folder` places such as `Folder.temp`, other than `Folder.current`, are left out; a - document's `saveAs` or `exportFile` counts too), `filesOpened` (files opened in other apps), `network`, + document's `saveAs` or `exportFile` counts too, and so does `SaveOptions.SAVECHANGES` wherever the script reads it, + since `close` given it saves the document to its file), `filesOpened` (files opened in other apps), `network`, `nativeCode`, `otherApps` (messages to other apps), `environment` (environment variables), `unseenCode` (`eval`, `new Function` and `$.evalFile`) and `preferences` (the reference app's preferences changed). - `problems` lists what would stop the script loading as written (strings, comments, regular expressions, @@ -2700,9 +2701,14 @@ app through the global object `vc`, and writes to the Script Console and runs ot https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/); without options the path's extension picks it. Without options, `saveAs` to a `.ai`, `.eps` or `.pdf` path and `exportFile` as `PNG24`, `JPEG` or `SVG` use the defaults a new options object of that class holds. `saveAs` maps `compressed`, `pdfCompatible`, `embedICCProfile` and - `compatibility` (`ILLUSTRATOR17` and `ILLUSTRATOR19`) of `.ai`; `cmykPostScript`, `includeDocumentThumbnails`, - `postScript`, `preview`, `overprint` and `compatibility` of EPS; and `pDFPreset`, `compatibility` (`ACROBAT4` to + `compatibility` (`ILLUSTRATOR17` and `ILLUSTRATOR19`), `saveMultipleArtboards` and `artboardRange` of `.ai`; + `cmykPostScript`, `includeDocumentThumbnails`, `postScript`, `preview`, `overprint`, `compatibility`, + `saveMultipleArtboards` and `artboardRange` of EPS; and `pDFPreset`, `compatibility` (`ACROBAT4` to `ACROBAT8` as PDF 1.3 to 1.7), `artboardRange`, `preserveEditability`, `acrobatLayers` and `compressArt` of PDF. + As the `.ai` and EPS help pages say, `artboardRange` is used only with `saveMultipleArtboards` true, and an + empty range means every artboard. `Document.fullName` is a `File` for the document's file, `Document.saved` is + true when the document has no unsaved changes and can be set, and `Document.close(saveOptions?)` closes the + document with the given `SaveOptions` (https://ai-scripting.docsforadobe.dev/jsobjref/Document/). `exportType` is an `ExportType`: `PNG24`, `JPEG` and `SVG` take `new ExportOptionsPNG24()`, `new ExportOptionsJPEG()` and `new ExportOptionsSVG()` (https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/), @@ -2713,7 +2719,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `options` is a `PDFFileOptions` record (https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/) with `pageToOpen` and `pDFCropToBox`. `app.userInteractionLevel` is `UserInteractionLevel.DISPLAYALERTS` at the start of each run. The enumerations `ExportType`, `Compatibility`, `PDFCompatibility`, `PDFBoxType`, `EPSPreview`, - `EPSPostScriptLevelEnum`, `PDFOverprint` and `UserInteractionLevel` hold strings such as `"ExportType.PNG24"`. + `EPSPostScriptLevelEnum`, `PDFOverprint`, `SaveOptions` and `UserInteractionLevel` hold strings such as + `"ExportType.PNG24"`. VectorCraft's own rules: each path is checked as a `File` opened for reading or writing is checked, before the command runs. A path outside the script's folders throws `Script file access denied`, also when it is an open document's file, a link that leads outside them, or the settings folder; a read-only file throws `Script file is @@ -2729,7 +2736,26 @@ app through the global object `vc`, and writes to the Script Console and runs ot an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`. A property the help pages do not list throws an error that names it (`PDFFileOptions` also accepts its read-only `typename` and `parent`), and an `undefined` one is left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default - keeps the preset's value. A bad value throws an error before anything is written. + keeps the preset's value. A `pDFPreset` in square brackets, such as `[Smallest File Size]`, names the built-in + preset of the name inside them; the default preset's name in brackets names VectorCraft Default, and + `[PDF/X-4:2008]` names PDF/X-4:2010. Any other name throws `unknown PDF preset`. `artboardRange` takes + a whole number from 1 as well as a string, read as `String(number)` reads it; any other number throws. With `saveMultipleArtboards` true, a `.ai` range + (every artboard when it is empty) goes to `file.saveAs`'s `separateArtboards`, which also writes each of its + artboards to `-.ai`, and an EPS range goes to `useArtboards`, which writes + `_.eps` for each of two or more artboards beside the file at the path, and for one artboard + writes only the file at the path, holding that artboard. Without `saveMultipleArtboards`, a `.ai` or EPS + `artboardRange` is not checked against the document's artboards, but one that is not written as a range of + artboard numbers (such as `abc` or `0-`) throws. `Document.path` is a `Folder` for the folder of the document's + file. A document that has no file has a `fullName` of a `File` for its name in `Folder.current` and a `path` of + `""`. `fullName` and `path` of a document whose file the automation read roots do not allow throw + `Script file access denied`. Setting `saved` runs `document.setSaved`: `true` records the document as saved + without saving it, so `close()` then closes it, and `false` records it as having unsaved changes; neither adds an + undo step. With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`; + `SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format its extension + names and after the same write-access check of the path as `saveAs`, and throws an error + and leaves the document open when the document has no file (a converted or recovered document included); and + `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot + show the prompt. A bad value throws an error before anything is written. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. - `$.evalFile(path, timeout?)` runs the file `path` names, relative to the file being run, in the same global @@ -8998,7 +9024,9 @@ document. With no document open they fail with "no document open". `document.act the current one. `document.move {from?, to}` reorders open documents the way dragging a document tab along the tab strip does: `from` defaults to the current document, `to` is the destination index, documents between them shift by one, the current document stays current, and each document keeps its own view (#5663). It is an engine command, so headless and -remote `command_list` both list it. `file.close {index}` on a document other than the current one leaves the current +remote `command_list` both list it. `document.setSaved {index?, saved}` records a document as saved (`true`) or as +having unsaved changes (`false`) without saving it and without an undo step; a script's `Document.saved = value` runs +it. `file.close {index}` on a document other than the current one leaves the current document current, and its tool keeps its state; closing the current document makes the document in the next tab current, or the one before it when it was the last tab. In the desktop app a modified document comes to the front first, to ask whether to save it. diff --git a/docs/roadmap.md b/docs/roadmap.md index 40c4518f52..2ea3d51b15 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -196,7 +196,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG ``/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | | M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View (hiding the guides and the grid while it is on, #8363), middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 | | M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color (manual picker and canvas eyedropper from original pixels, no canvas View change, missed pixels keep the pick armed, Preview/Undo retained; #8068), Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 | -| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and save, export and open documents with `Document.saveAs`, `Document.exportFile` and `app.open`; the rest of the script document model (layers, artboards, paths, type and the other classes) and batch work remain | 18–27 | +| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; scripts have `app`, the open documents, new documents, each document's selection and its page items, and save, export, open and close documents with `Document.saveAs`, `Document.exportFile`, `app.open` and `Document.close`; the rest of the script document model (layers, artboards, paths, type and the other classes) and batch work remain | 18–27 | | M14 | 1.0 polish (Asset Export tile context menus implemented for G12; preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset , UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Graphic Styles item context menus in thumbnail and list views with Options, Duplicate, Delete, Redefine, Break Link (#8755); Appearance panel row context menus for strokes, fills, effects, and root object row (Duplicate, Delete, Hide/Show, Edit Effect…, Clear Appearance, Reduce to Basic Appearance) with secondary click row selection (#8809); Character Styles and Paragraph Styles item context menus (panels::text_styles::tests::right_click_context_menu_*); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 | | — | Interaction fidelity pass (every tool's modifiers, Properties panel per context, isolation, nuance; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed) | ⬜ (new ruler-guide Alt orientation implemented; existing-guide Escape cancellation regression-tested; broader pass remains) | 60–90 | | — | Hardening at scale (big-file corpus, fuzzing, cross-platform + browser QA) | 🟡 PngSuite integrity and bounded fetching verified (#1729); real-world corpus/manual QA remain | 50–80 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 123604eaec..aaf9712151 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1026,7 +1026,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/ and https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ describe, and read and write only where the script's `File` objects may (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. + - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe, and read and write only where the script's `File` objects may (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From a278d6a837885531f878d72d1ac0773f052e1f2b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 21:51:12 -0800 Subject: [PATCH 022/264] Scripts: a path in a selected group reads as selected with its own picks too When a group or compound path is selected together with one of its paths, and that path also has its own anchor or segment pick, selectedPathPoints and PathPoint.selected now report the path as selected as a whole, as docs/mcp.md says for a path in a selected group. Before, the path's own pick was reported instead. --- crates/engine/src/script/dom/paths.rs | 6 +++--- crates/engine/src/tests/script_dom_paths.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index ddd0853d3a..0942ebe880 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -1384,10 +1384,10 @@ fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { Ok(path_ref(h, item)) } -/// Whether the path `id` is not selected itself but a group or compound path that holds it is, -/// which selects the path as a whole. +/// Whether a group or compound path that holds the path `id` is selected, which selects the path +/// as a whole whatever the path's own selection is. fn held_selected(d: &crate::Document, sel: &crate::doc::Selection, id: NodeId) -> bool { - !sel.contains(id) && d.ancestry(id).is_some_and(|a| a.iter().any(|i| *i != id && sel.contains(*i) && d.node(*i).is_some_and(|n| !n.is_layer()))) + d.ancestry(id).is_some_and(|a| a.iter().any(|i| *i != id && sel.contains(*i) && d.node(*i).is_some_and(|n| !n.is_layer()))) } /// The point at index `i` of `subs` is a selected anchor point of the path `id` in `sel`: every diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index 17d9969387..bb73f4175d 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -959,6 +959,20 @@ fn a_path_in_a_selected_group_or_compound_path_is_selected_as_a_whole() { } } +#[test] +fn a_path_in_a_selected_group_reads_as_a_whole_when_its_own_anchors_are_also_picked() { + let (mut s, a, b) = doc(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let group = s.active().unwrap().doc.parent_of(a).unwrap(); + s.execute("select.set", &json!({"ids": [group.0, a.0]})).unwrap(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 1]]}], "mode": "subtract"})).unwrap(); + assert!(s.active().unwrap().selection.contains(group), "the group stays selected"); + assert!(s.active().unwrap().selection.partial(a).is_some(), "the path has its own anchor selection"); + let out = log(&mut s, "var p = app.activeDocument.pathItems[0]; vc.log([p.selectedPathPoints.length, p.pathPoints[1].selected]);"); + assert_eq!(out, vec![json!([4, "PathPointSelection.ANCHORPOINT"])]); +} + #[test] fn reading_selected_while_moving_points_writes_the_path_once() { let (mut s, a, _) = doc(); From 3ef4b97983b1b021bcdc74617287d6adbfcd89a0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 21:58:26 -0800 Subject: [PATCH 023/264] Scripts: closing with SAVECHANGES keeps the document's format, and an empty artboardRange is refused Document.close(SaveOptions.SAVECHANGES) now saves in the format the document was last saved in, so a PDF saved to a file whose extension names another format stays a PDF. An artboardRange with no parts, such as ',' or ' , ', now throws, as a range used for the save does. --- crates/engine/src/script/dom/save_open.rs | 29 ++++++++++++--------- crates/engine/src/tests/script_save_open.rs | 25 +++++++++++++++++- docs/mcp.md | 4 +-- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index b2c9a56378..d94122c702 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -260,8 +260,8 @@ fn artboard_files(format: &str, q: &mut Map) -> std::result::Resu Ok(()) } -/// Whether `r` is written as an artboard range, whatever artboards a document has: parts separated -/// by commas, each a number from 1, or two of them joined by `-` or `–` with either one left out +/// Whether `r` is written as an artboard range, whatever artboards a document has: one or more +/// parts separated by commas, each a number from 1, or two of them joined by `-` or `–` with either one left out /// and the first no greater than the second. fn written_as_range(r: &str) -> bool { // A number of digits alone, from 1; past `u64` it counts as the largest. @@ -273,14 +273,16 @@ fn written_as_range(r: &str) -> bool { let n = t.bytes().all(|b| b.is_ascii_digit()).then(|| t.parse::().unwrap_or(u64::MAX))?; (n >= 1).then_some(Some(n)) }; - r.split(',').map(str::trim).filter(|p| !p.is_empty()).all(|part| match part.replace('\u{2013}', "-").split_once('-') { - Some((a, b)) => match (num(a), num(b)) { - (Some(Some(a)), Some(Some(b))) => a <= b, - (Some(a), Some(b)) => a.is_some() || b.is_some(), - _ => false, - }, - None => matches!(num(part), Some(Some(_))), - }) + let mut parts = r.split(',').map(str::trim).filter(|p| !p.is_empty()).peekable(); + parts.peek().is_some() + && parts.all(|part| match part.replace('\u{2013}', "-").split_once('-') { + Some((a, b)) => match (num(a), num(b)) { + (Some(Some(a)), Some(Some(b))) => a <= b, + (Some(a), Some(b)) => a.is_some() || b.is_some(), + _ => false, + }, + None => matches!(num(part), Some(Some(_))), + }) } const AI_KEPT: &[(&str, Default)] = &[ @@ -896,7 +898,7 @@ const NO_FILE_TO_SAVE: &str = /// `document.close(saveOptions?)`: `file.close` of the document. A document without unsaved /// changes closes with any `SaveOptions`. With unsaved changes, `SaveOptions.DONOTSAVECHANGES` /// closes it without them; `SaveOptions.SAVECHANGES` saves them to the document's file with -/// `file.saveAs` in the format its extension names, after the write-access check `saveAs` makes of +/// `file.saveAs` in the format the document was last saved in, after the write-access check `saveAs` makes of /// the path, and then closes it, and throws [`NO_FILE_TO_SAVE`] /// for a document that has no file, a converted or recovered one included; and /// `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws [`UNSAVED_CHANGES`], since a script @@ -907,7 +909,8 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { Some(d) => member(d, "SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"], "saveOptions")?, None => "PROMPTTOSAVECHANGES", }; - let (dirty, file) = super::with_doc(h, doc, |_, st| (st.is_dirty(), st.path.clone().filter(|_| !st.converted && !st.recovered))); + let (dirty, file, format) = + super::with_doc(h, doc, |_, st| (st.is_dirty(), st.path.clone().filter(|_| !st.converted && !st.recovered), st.format)); if dirty { match how { "DONOTSAVECHANGES" => {} @@ -916,7 +919,7 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { // A refusal names the document, as `fullName` does when the read roots hide its file. let name = super::with_doc(h, doc, |_, st| st.title()); let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?; - let p = json!({"path": plain(real)}); + let p = json!({"path": plain(real), "format": format}); exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "file.saveAs", &p)))?; } _ => return Err(HostError::Error(UNSAVED_CHANGES.into())), diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 4389838807..478f68855b 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -696,6 +696,29 @@ fn a_document_without_unsaved_changes_closes_with_any_save_options() { let _ = std::fs::remove_dir_all(base); } +/// `close(SaveOptions.SAVECHANGES)` saves in the format the document was last saved in, not the +/// one its file's extension names. +#[test] +fn closing_with_save_changes_keeps_the_documents_format() { + let base = folder("closeformat"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}}); d.saveAs(new File({d} + '/p.svg'), new PDFSaveOptions());\n\ + vc.run('shape.rectangle', {{x: 20, y: 20, width: 5, height: 5}}); d.close(SaveOptions.SAVECHANGES); vc.log(app.documents.length);" + ), + ); + let bytes = std::fs::read(dir.join("p.svg")).unwrap_or_default(); + assert!(bytes.starts_with(b"%PDF"), "the save on close keeps the PDF format"); + assert!(s.documents().is_empty()); + let _ = std::fs::remove_dir_all(base); +} + /// Setting `Document.saved` records the document's saved state without saving it: `true` lets /// `close()` close a document with edits, and `false` makes an untouched one ask. #[test] @@ -867,7 +890,7 @@ fn save_multiple_artboards_writes_a_file_per_artboard() { ), ); assert!(dir.join("aioff/c.ai").is_file(), "a range past the document's artboards is not used and does not stop the save"); - for bad in ["'abc'", "'0-'", "'3-1'", "'-'", "-1", "2.5", "0"] { + for bad in ["'abc'", "'0-'", "'3-1'", "'-'", "','", "' , '", "-1", "2.5", "0"] { let e = failure( &mut s, &base, diff --git a/docs/mcp.md b/docs/mcp.md index ed7af26ab5..c7757d4464 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2751,8 +2751,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot `Script file access denied`. Setting `saved` runs `document.setSaved`: `true` records the document as saved without saving it, so `close()` then closes it, and `false` records it as having unsaved changes; neither adds an undo step. With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`; - `SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format its extension - names and after the same write-access check of the path as `saveAs`, and throws an error + `SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format the document + was last saved in and after the same write-access check of the path as `saveAs`, and throws an error and leaves the document open when the document has no file (a converted or recovered document included); and `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot show the prompt. A bad value throws an error before anything is written. From ab85d735c949791cf49d2b1bc6b5172af8f30cdf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:00:02 -0800 Subject: [PATCH 024/264] New Document: Columns follows a preset's rows in the framework dialog The New Document dialog that main moved to the framework showed a preset's stored column count for a grid by column made with file.new's rows, and kept the rows when the layout or Columns changed. Columns now shows the columns those rows give the current number of artboards, a new layout keeps that count, and a new column count replaces the rows, as the dialog did before the move. --- crates/ui-egui/src/dialogs/new_document.rs | 53 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/new_document.rs b/crates/ui-egui/src/dialogs/new_document.rs index e60e9e0b3a..eb37e9674d 100644 --- a/crates/ui-egui/src/dialogs/new_document.rs +++ b/crates/ui-egui/src/dialogs/new_document.rs @@ -469,6 +469,31 @@ fn advanced(ui: &mut egui::Ui, s: &mut DocSettings) { } } +/// The columns Columns shows: those a grid by column made with `file.new`'s `rows` gives the +/// current number of artboards, otherwise the stored count, at least 1 and at most the artboards. +fn shown_columns(s: &DocSettings) -> u32 { + if s.layout == ArtboardLayout::GridByColumn && s.rows > 0 { + return u32::try_from(s.grid_columns()).unwrap_or(MAX_ARTBOARDS); + } + s.columns.max(1).min(s.artboards.max(1)) +} + +/// Sets the artboard layout. A new layout replaces the rows of a preset made with `file.new`'s +/// `rows` with the column count Columns showed for them. +fn set_layout(s: &mut DocSettings, layout: ArtboardLayout) { + if s.rows > 0 { + s.columns = shown_columns(s); + s.rows = 0; + } + s.layout = layout; +} + +/// Sets the column count, which replaces the rows of a preset made with `file.new`'s `rows`. +fn set_columns(s: &mut DocSettings, columns: u32) { + s.rows = 0; + s.columns = columns; +} + /// More Settings' pop-up: the artboard layout, spacing and columns. All three are off with one /// artboard, Columns also for the row and column layouts; columns stay within the artboards. fn more_settings(ui: &mut egui::Ui, s: &mut DocSettings, lengths: LengthUnits) { @@ -479,7 +504,7 @@ fn more_settings(ui: &mut egui::Ui, s: &mut DocSettings, lengths: LengthUnits) { Field::new(layout.clone()).show(ui, |ui, _| { let entries: Vec> = ArtboardLayout::ALL.iter().map(|l| Entry::new(*l, text(tl!(l.label())))).collect(); if let Some(l) = Segmented::new(layout.clone(), Bind::given(s.layout), &entries).enabled(several).show(ui).value().copied() { - s.layout = l; + set_layout(s, l); } }); let rtl = Checkbox::new(Bind::given(s.right_to_left)).label(right_to_left).enabled(several).show(ui); @@ -494,10 +519,10 @@ fn more_settings(ui: &mut egui::Ui, s: &mut DocSettings, lengths: LengthUnits) { }); Field::new(columns.clone()).show(ui, |ui, _| { let n = f64::from(s.artboards.max(1)); - let shown = f64::from(s.columns.max(1)).min(n); + let shown = f64::from(shown_columns(s)); let field = NumberField::new(columns.clone(), Bind::given(Some(shown))).range(1.0..=n).step(1.0).commit_decimals(0).enabled(several && grid); if let Some(v) = field.show(ui).value().copied().flatten().filter(|v| v.is_finite()) { - s.columns = v.round().clamp(1.0, n) as u32; + set_columns(s, v.round().clamp(1.0, n) as u32); } }); } @@ -1005,4 +1030,26 @@ mod tests { assert!(!dir.join("Print.vectorcraft").exists()); let _ = std::fs::remove_dir_all(&dir); } + + /// A preset made with `file.new`'s `rows`: Columns shows the columns those rows give the + /// current artboards, and a new layout keeps them while a new column count replaces the rows. + #[test] + fn columns_follow_a_presets_rows_until_the_layout_or_columns_change() { + let made = |layout, artboards| DocSettings { layout, artboards, columns: 2, rows: 4, ..DocSettings::default() }; + for (artboards, shown) in [(5, 2), (9, 3), (2, 1)] { + assert_eq!(shown_columns(&made(ArtboardLayout::GridByColumn, artboards)), shown, "{artboards} artboards"); + } + assert_eq!(shown_columns(&made(ArtboardLayout::GridByRow, 9)), 2, "a grid by row shows the stored columns"); + for to in [ArtboardLayout::GridByRow, ArtboardLayout::Row, ArtboardLayout::Column] { + let mut s = made(ArtboardLayout::GridByColumn, 9); + set_layout(&mut s, to); + assert_eq!((s.layout, s.columns, s.rows), (to, 3, 0), "{to:?}"); + } + let mut s = made(ArtboardLayout::GridByRow, 9); + set_layout(&mut s, ArtboardLayout::GridByColumn); + assert_eq!((s.columns, s.rows, shown_columns(&s)), (2, 0, 2), "the columns a grid by row showed stay"); + let mut s = made(ArtboardLayout::GridByColumn, 9); + set_columns(&mut s, 5); + assert_eq!((s.columns, s.rows, shown_columns(&s)), (5, 0, 5)); + } } From 1c7fc27b42a1a8438c868b704dc45eb933b8f6f9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:18:13 -0800 Subject: [PATCH 025/264] Scripts: app.selectTool picks a tool app.selectTool(name) takes a tool's id (pen), its label (Pen Tool) or a tool name in the form scripts pass, returns true, and makes that tool the current tool when the run ends without an error. The tool chosen last in a run counts, and a run that fails leaves the tool as it was. An unknown name throws, a name that is not a string throws a TypeError, and a name over 4,096 bytes throws a RangeError. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/script/dom.rs | 77 ++++++++++++++++++++++++++- crates/engine/src/script/mod.rs | 8 +++ crates/engine/src/tests/script_dom.rs | 29 ++++++++++ docs/mcp.md | 8 ++- docs/target-app-parity.md | 2 +- 5 files changed, 121 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index cb901014b5..a3456e8590 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -25,6 +25,9 @@ //! - `app.activeDocument` with no document open throws `No active document`. //! - Assigning `Document.selection` takes one object, a list of them, `null` or `[]`; every object //! must be one of that document's that can be selected, or nothing changes. +//! - `app.selectTool(name)` takes a tool's id, its label, or a name of the list cited at +//! [`TOOL_NAME_PREFIX`], and the tool becomes the current tool when the run ends without an +//! error. A run that fails leaves the tool as it was. //! - Members the help pages list that are not here yet throw an error that says so. use std::cell::{Cell, RefCell}; @@ -88,7 +91,8 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; /// What the object model keeps for one run: its coordinate system, the lists of page items and the /// answers of which objects are on a locked artboard for the last [`ITEM_LISTS`] documents read, /// each kept while its document is unchanged, whether a call's own savepoint ([`atomically`]) is -/// open, and the settings of each `DocumentPreset` the run made. +/// open, the settings of each `DocumentPreset` the run made, and the tool `app.selectTool` chose +/// last. #[derive(Default)] pub(super) struct State { coords: Cell, @@ -96,6 +100,7 @@ pub(super) struct State { locked: RefCell>, saving: Cell, presets: RefCell>>, + tool: Cell>, } impl State { @@ -103,6 +108,12 @@ impl State { pub(super) fn saving(&self) -> bool { self.saving.get() } + + /// The id of the tool `app.selectTool` chose last in the run, which becomes the current tool + /// when the run ends without an error. + pub(super) fn chosen_tool(&self) -> Option<&'static str> { + self.tool.get() + } } /// Runs `f`, whose commands are kept together or put back together: when `f` fails, every @@ -732,6 +743,69 @@ fn app_is_open(h: &Host, a: &[Data]) -> Answer { Ok(Data::Bool(open)) } +/// The start of the tool names that scripts pass to `app.selectTool`, as the list at +/// gives them. +const TOOL_NAME_PREFIX: &str = "Adobe "; // brand-ok: the start of the tool names scripts pass + +/// The names on that list, without [`TOOL_NAME_PREFIX`], whose words differ from the label of the +/// VectorCraft tool they choose, with that tool's id. Names whose words are a VectorCraft tool's +/// label (`Pen Tool`) choose that tool without a row here. The pairs are VectorCraft's own. +const TOOL_NAMES: &[(&str, &str)] = &[ + ("Select Tool", "selection"), + ("Direct Select Tool", "directSelection"), + ("Direct Object Select Tool", "groupSelection"), + ("Direct Lasso Tool", "lasso"), + ("Path Type Tool", "typeOnPath"), + ("Vertical Path Type Tool", "verticalTypeOnPath"), + ("Line Tool", "lineSegment"), + ("Shape Construction Regular Polygon Tool", "polygon"), + ("Shape Construction Star Tool", "star"), + ("Shape Construction Spiral Tool", "spiral"), + ("Brush Tool", "paintbrush"), + ("Freehand Tool", "pencil"), + ("Freehand Smooth Tool", "smooth"), + ("Freehand Erase Tool", "pathEraser"), + ("Corner Join Tool", "join"), + ("Knife Tool", "knife"), + ("New Twirl Tool", "twirl"), + ("Cyrstallize Tool", "crystallize"), + ("Planar Paintbucket Tool", "livePaintBucket"), + ("Planar Face Select Tool", "livePaintSelection"), + ("Mesh Editing Tool", "mesh"), + ("Gradient Vector Tool", "gradient"), + ("Crop Tool", "artboard"), + ("Slice Select Tool", "sliceSelection"), + ("Scroll Tool", "hand"), + ("Page Tool", "printTiling"), +]; + +/// The id of the tool `name` names: a tool's id (`pen`), its label (`Pen Tool`), or a name of the +/// list [`TOOL_NAME_PREFIX`] cites. +fn tool_named(name: &str) -> Option<&'static str> { + let tools = || vectorcraft_tools::catalog::all_tools(); + if let Some(t) = tools().find(|t| t.id == name || t.label == name) { + return Some(t.id); + } + let rest = name.strip_prefix(TOOL_NAME_PREFIX)?; + if let Some((_, id)) = TOOL_NAMES.iter().find(|(n, _)| *n == rest) { + return vectorcraft_tools::tool_info(id).map(|t| t.id); + } + tools().find(|t| t.label == rest).map(|t| t.id) +} + +/// `app.selectTool(name)`: chooses the tool `name` names ([`tool_named`]) and gives `true`. The +/// tool becomes the current tool when the run ends without an error, as a choice on the toolbar +/// does; the tool chosen last in a run is the one that counts. A name no tool has throws. +fn app_select_tool(h: &Host, a: &[Data]) -> Answer { + let Data::String(name) = arg(a, 1) else { return Err(HostError::Type("selectTool needs a tool name, as a string".into())) }; + if name.len() > MAX_TEXT_BYTES { + return Err(HostError::Range("the tool name is too long".into())); + } + let id = tool_named(name).ok_or_else(|| HostError::Error(format!("No tool is named \"{name}\"")))?; + h.dom.tool.set(Some(id)); + Ok(Data::Bool(true)) +} + // ---- Documents ---- fn docs_length(h: &Host, _: &[Data]) -> Answer { @@ -1948,6 +2022,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("selection", get(l, app_selection)), ("coordinateSystem", property(l, app_coords, app_set_coords)), ("getIsFileOpen", method(l, app_is_open)), + ("selectTool", method(l, app_select_tool)), ]); application.push(later(l, "Application", "beep")); let preset = { diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index affacab584..dc4bd20008 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -2291,7 +2291,15 @@ impl Session { }); host.more_written(&mut report); close_run(self, host, &mut report, console::Ending::Finished); + let tool = host.dom.chosen_tool(); self.end_job(job, false); + // The tool `app.selectTool` chose last becomes the current tool, as a choice on the + // toolbar makes it; the run's changes are kept when the tool cannot be chosen. + if let Some(id) = tool + && let Err(e) = self.select_tool(id, self.last_view) + { + report["toolError"] = json!(e.to_string()); + } self.script_report = Some(report.clone()); Ok(report) } diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 60e3a71521..a0c6e8afbc 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1314,6 +1314,35 @@ fn prototype_changes_cannot_forge_a_page_item() { assert_eq!(s.active().unwrap().doc.node(a).unwrap().name, None); } +#[test] +fn select_tool_makes_the_named_tool_current_when_the_run_ends() { + let (mut s, _, _) = doc(); + assert_eq!(s.tool_id(), "selection"); + // A tool's id, its label and a name in the form scripts pass all choose it; the last one counts. + assert_eq!(log(&mut s, "vc.log(app.selectTool('pen'));"), vec![json!(true)]); + assert_eq!(s.tool_id(), "pen"); + log(&mut s, "app.selectTool('Rectangle Tool');"); + assert_eq!(s.tool_id(), "rectangle"); + log(&mut s, "app.selectTool('Adobe Ellipse Tool'); app.selectTool('Adobe Direct Select Tool');"); + assert_eq!(s.tool_id(), "directSelection"); + log(&mut s, "app.selectTool('Adobe Select Tool');"); + assert_eq!(s.tool_id(), "selection"); + // An unknown name throws, a caught error chooses nothing, and a run that fails leaves the tool. + assert!(failure(&mut s, "app.selectTool('No Such Tool');").contains("No tool is named \"No Such Tool\"")); + assert!(failure(&mut s, "app.selectTool('Adobe ');").contains("No tool is named")); + let out = log(&mut s, "try { app.selectTool('pencil tool'); } catch (e) { vc.log(e.message); }"); + assert_eq!(out, vec![json!("No tool is named \"pencil tool\"")]); + assert!(failure(&mut s, "app.selectTool('pen'); throw new Error('stop');").contains("stop")); + let out = log(&mut s, "try { app.selectTool(5); } catch (e) { vc.log(e.name); }"); + assert_eq!(out, vec![json!("TypeError")]); + assert!(failure(&mut s, "app.selectTool(new Array(5000).join('a'));").contains("too long")); + assert_eq!(s.tool_id(), "selection"); + // With no document open the tool is chosen too. + let mut empty = Session::new(); + log(&mut empty, "app.selectTool('Adobe Freehand Tool');"); + assert_eq!(empty.tool_id(), "pencil"); +} + #[test] fn unsupported_members_say_so() { let (mut s, _, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 4685f408d7..5b4d5b342b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2622,7 +2622,13 @@ app through the global object `vc`, and writes to the Script Console and runs ot - `vc.log(value)` adds a value to the report and a line to the Script Console. - `app` is the application object the help page https://ai-scripting.docsforadobe.dev/jsobjref/Application/ describes: `app.documents`, `app.activeDocument` (assigning an open document makes it the active one), - `app.selection`, `app.coordinateSystem` and `app.getIsFileOpen(path)`. `app.documents` + `app.selection`, `app.coordinateSystem`, `app.getIsFileOpen(path)` and `app.selectTool(name)`. `selectTool` + (https://community.adobe.com/questions-652/what-s-new-in-illustrator-scripting-cc2020-769942) takes a tool's id + (`pen`), its label (`Pen Tool`) or a tool name in the form that thread lists, returns `true`, and makes the tool it + names the current tool when the run ends without an error; the tool chosen last in a run is the one that counts, + and a run that fails leaves the tool as it was. A name no tool has throws `No tool is named ""`, a name that + is not a string throws a `TypeError`, and a name of more than 4,096 bytes throws a `RangeError`. Which tool each + name in that thread chooses is VectorCraft's own reading; names with no VectorCraft tool throw. `app.documents` (https://ai-scripting.docsforadobe.dev/jsobjref/Documents/) has `length`, `[i]`, `index(key)`, `getByName(name)` and `add(colorSpace?, width?, height?, numArtBoards?, artboardLayout?, artboardSpacing?, artboardRowsOrCols?)`, which runs `file.new` (`artboardRowsOrCols` is the number of rows for `GridByCol` and `RLGridByCol`, and of diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3b252b56a6..607fd49b5e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1024,7 +1024,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Synthetic input validates complete gestures before queue mutation: at most 256 drag steps, 16 clicks and 1,024 pending events; up to 64 control requests per frame, with later requests retained for the next frame (#1709). - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. + - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). `app.selectTool(name)` makes the named tool the current tool when the run ends (https://community.adobe.com/questions-652/what-s-new-in-illustrator-scripting-cc2020-769942). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From 24d91e2acf564c5124618e7357e6f0abe202fa19 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 22:31:57 -0800 Subject: [PATCH 026/264] Script checker: app.selectTool counts as the document model, not a feature only the reference app has --- crates/scriptcheck/src/catalog.rs | 2 +- crates/scriptcheck/src/tests.rs | 2 +- docs/mcp.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/scriptcheck/src/catalog.rs b/crates/scriptcheck/src/catalog.rs index 0045c764f2..c1203504ca 100644 --- a/crates/scriptcheck/src/catalog.rs +++ b/crates/scriptcheck/src/catalog.rs @@ -181,7 +181,7 @@ features! { ScriptuiDrawing "scriptui.drawing" Dialogs, ScriptuiPalette "scriptui.palette" HostOnly, ScriptuiWindow "scriptui.window" Dialogs, - SelectTool "selectTool" HostOnly, + SelectTool "selectTool" Dom, Socket "socket" HostOnly, UnitValue "unitValue" Language, Xml "xml" HostOnly, diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 6985791fe1..2d57f40f94 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -1521,7 +1521,7 @@ fn declarations_past_a_limit_hold_from_where_they_stand() { fn application_methods_are_features_not_members() { let r = report("app.executeMenuCommand('acmecopyall');\napp.selectTool('acme');\n"); assert!(r.members.is_empty(), "{:?}", r.members); - assert_eq!(r.needs, [Need::MenuCommands, Need::HostOnly]); + assert_eq!(r.needs, [Need::Dom, Need::MenuCommands]); } #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 350d017c4f..6902e16314 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2563,9 +2563,9 @@ control character, in the first 8 KiB) or `tooLarge` (over 8 MiB). For a script, - `needs` lists what the script needs from the app that runs it: `language` (the script language's own objects and directives, such as `$`, `alert`, `UnitValue`, `#target` and `#targetengine`), `dom` (the reference app's - document model), `files`, `menuCommands`, `dialogs`, and `hostOnly` (features only the reference app has: - palettes, BridgeTalk, sockets, native code, XMP, the XML object and E4X, operator overloading, reflection, actions - and `selectTool`). + document model, `app.selectTool` included), `files`, `menuCommands`, `dialogs`, and `hostOnly` (features only the + reference app has: palettes, BridgeTalk, sockets, native code, XMP, the XML object and E4X, operator overloading, + reflection and actions). - `directives` lists the `#include`, `#includepath`, `#script`, `#strict`, `#target` and `#targetengine` lines, and `targets` splits each `#target` line's application specifier into `app`, `instance`, `version` and `locale`. A directive is read where it starts a line, written `#name` or `//@name`. From 7f7effc8fbd8695a9ba30e649a14b7fc687ffe1a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 23:59:51 -0800 Subject: [PATCH 027/264] Scripts: New Document profiles are read without following a link, and review fixes - A New Document profile is opened without following a link (O_NOFOLLOW on Unix, FILE_FLAG_OPEN_REPARSE_POINT on Windows), and its kind and bytes are read from that open file. A link put in the profile's place after the plain-file check is refused instead of read. - Page item and layer handles go stale when their document is reverted. - controlBounds holds the control points of the object's paths. - PageItems.toString() throws Stale document for a collection kept from an earlier run. - Assigning an object the opacity it reports runs no command, except on a graph mark or label whose graph keeps another opacity. - An object-model edit and the steps that restore the selection, layer and active document succeed or fail together. - hasOwnProperty and propertyIsEnumerable stop at an unavailable member that hides one of a parent class. - Assigning a name that a non-extensible host object inherits no longer looks the name up with the object's indexer. - The Application prototype inventory lists selectTool. - docs/mcp.md names the Stale document error, and the parity line says the tool changes only when the run ends without an error. --- crates/engine/Cargo.toml | 7 +- crates/engine/src/cmd/newdoc.rs | 6 +- crates/engine/src/script/dom.rs | 80 +++++++++++++++---- crates/engine/src/store.rs | 46 +++++++++++ crates/engine/src/tests/script_dom.rs | 77 ++++++++++++++++-- crates/engine/src/tests/store.rs | 18 +++++ .../tests/it/script_host_vs_scriptcheck.rs | 2 +- crates/js/src/host_classes.rs | 14 +++- crates/js/src/host_tests.rs | 19 +++++ crates/js/src/interp.rs | 13 +-- docs/mcp.md | 7 +- docs/target-app-parity.md | 2 +- 12 files changed, 252 insertions(+), 39 deletions(-) diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 7e6028b045..bb8277a9ab 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -70,10 +70,11 @@ serde_json = { workspace = true } thiserror = { workspace = true } log = { workspace = true } -# Whether a recovery area folder is this account's own (`FolderStore::own_area`). Already in -# Cargo.lock (tempfile, ui-egui), so this adds no new crate. +# Whether a recovery area folder is this account's own (`FolderStore::own_area`), and opening a +# file without following a link (`store::read_capped_plain`). Already in Cargo.lock (tempfile, +# ui-egui), so this adds no new crate. [target.'cfg(unix)'.dependencies] -rustix = { workspace = true, features = ["std", "process"] } +rustix = { workspace = true, features = ["std", "process", "fs"] } # Whether a recovery area's lock file is still the one that was opened (`FolderStore::still_named`), # and whether two paths a script names are one file (`script::files`). Already in Cargo.lock diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index 8272f7d8cb..47dd425555 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -1017,11 +1017,13 @@ impl Session { match std::fs::symlink_metadata(&path) { Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None), // A link is refused: the script's gate does not check where it leads. - Ok(m) if !m.file_type().is_file() => return Err("not a plain file".to_string()), + Ok(m) if !m.file_type().is_file() => return Err(crate::store::NOT_PLAIN.to_string()), _ => {} } crate::file_access::check_read(&file).map_err(denied)?; - crate::store::read_capped(&path, MAX_PROFILE_BYTES).map(Some) + // Read without following a link, so a link put in the file's place since the check + // above is refused too. + crate::store::read_capped_plain(&path, MAX_PROFILE_BYTES).map(Some) })?; let Some(bytes) = read else { return Ok(None) }; // The color profiles the file carries are installed where missing, as opening it installs diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 1f4d8de478..ca7bc3ba77 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -367,6 +367,14 @@ fn find_doc(h: &Host, run: f64, uid: f64) -> Option { s.documents().iter().position(|d| d.uid == uid).map(|index| Doc { index, uid }) } +/// [`find_doc`] for the handle of an object in a document: none as well when the document was +/// reverted since the handle was made, as its objects were read again from its file. +fn find_doc_of_object(h: &Host, run: f64, uid: f64, reverts: f64) -> Option { + let doc = find_doc(h, run, uid)?; + let s = h.session.borrow(); + (whole(reverts) == Some(s.documents()[doc.index].reverts)).then_some(doc) +} + /// The document `d` names: a `Document` or a `PageItems` object. fn doc_of(h: &Host, d: &Data, class: &str) -> std::result::Result { let Some(handle) = handle_of(d, class) else { return Err(HostError::Type(format!("this is not a {class}"))) }; @@ -379,8 +387,8 @@ fn doc_of(h: &Host, d: &Data, class: &str) -> std::result::Result std::result::Result { let Some(handle) = handle_of(d, "PageItem") else { return Err(HostError::Type("this is not a page item".into())) }; - let [run, uid, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a page item".into())) }; - let doc = find_doc(h, *run, *uid).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; + let [run, uid, reverts, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a page item".into())) }; + let doc = find_doc_of_object(h, *run, *uid, *reverts).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; let id = id_of(*high, *low).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; let s = h.session.borrow(); let st = &s.documents()[doc.index]; @@ -418,8 +426,8 @@ fn doc_ref(h: &Host, uid: u64) -> Data { fn item_ref(h: &Host, st: &DocState, id: NodeId) -> Data { match st.doc.node(id) { Some(n) => match typename(n) { - Some(t) => host_ref(t, &[float(h.run), float(st.uid), id_parts(id)[0], id_parts(id)[1]]), - None => host_ref("Layer", &[float(h.run), float(st.uid), id_parts(id)[0], id_parts(id)[1]]), + Some(t) => host_ref(t, &[float(h.run), float(st.uid), float(st.reverts), id_parts(id)[0], id_parts(id)[1]]), + None => host_ref("Layer", &[float(h.run), float(st.uid), float(st.reverts), id_parts(id)[0], id_parts(id)[1]]), }, None => Data::Null, } @@ -653,12 +661,24 @@ fn restore_layer(h: &Host, uid: u64, layer: Option, rows: &[NodeId]) -> /// commands changed it (commands given ids select them first), direct-selected anchors, segments, /// ruler guides, slices, the key, a Layers panel target and an object chosen inside a dynamic /// symbol instance or an Objects on Path group included, less the objects that are now deleted, -/// hidden or locked. +/// hidden or locked. `f`'s commands and the steps that put things back succeed or fail together +/// ([`atomically`]): when putting back the selection, the layer or the active document fails, `f`'s +/// changes are undone as well. fn on_doc( h: &Host, uid: u64, keep_selection: bool, f: impl FnOnce(&Host) -> std::result::Result, +) -> std::result::Result { + atomically(h, |h| on_doc_steps(h, uid, keep_selection, f)) +} + +/// The steps of [`on_doc`]. +fn on_doc_steps( + h: &Host, + uid: u64, + keep_selection: bool, + f: impl FnOnce(&Host) -> std::result::Result, ) -> std::result::Result { let (index, active, before, layer) = { let s = h.session.borrow(); @@ -1452,6 +1472,11 @@ fn items_typename(h: &Host, a: &[Data]) -> Answer { Ok(text("PageItems")) } +fn items_to_string(h: &Host, a: &[Data]) -> Answer { + items_doc(h, a)?; + Ok(text("[PageItems]")) +} + fn items_parent(h: &Host, a: &[Data]) -> Answer { let doc = items_doc(h, a)?; Ok(doc_ref(h, doc.uid)) @@ -1654,9 +1679,9 @@ fn item_set_opacity(h: &Host, a: &[Data]) -> Answer { if !(0.0..=100.0).contains(&v) { return Err(HostError::Range("opacity must be from 0 to 100".into())); } - // A value the getter reports for the item's opacity sends the opacity it has, and - // `object.setProps` finds the no-op itself: an opacity a graph mark or label already has still - // replaces the one the graph keeps for its series or kind. + // A value the getter reports for the item's opacity runs no command, unless the item is a graph + // mark or label whose graph keeps another opacity for its series or kind: then the opacity the + // item has is sent, and replaces the one the graph keeps. // The opacity the item already has may be assigned while its layer is hidden or locked, unless // it would still replace the opacity a graph keeps for the item's series or kind. let item = this_item(h, a)?; @@ -1671,7 +1696,7 @@ fn item_set_opacity(h: &Host, a: &[Data]) -> Answer { if now.is_none() || keeps_other { refuse_in_closed_layer(h, item)?; } - set_props(h, a, |_| false, json!({"opacity": now.unwrap_or(v)})) + set_props(h, a, |_| now.is_some() && !keeps_other, json!({"opacity": now.unwrap_or(v)})) } fn item_selected(h: &Host, a: &[Data]) -> Answer { @@ -1717,6 +1742,31 @@ fn item_visible(h: &Host, a: &[Data]) -> Answer { bounds(h, a, true) } +/// `controlBounds`: the visible bounds, grown to hold the control points of the item's paths. +fn item_control(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; + let (r, f) = with_doc(h, item.doc, |_, st| { + let control = st.doc.node(item.id).and_then(control_points_box); + Ok::<_, HostError>((vectorcraft_geom::union_opt(st.doc.bounds_of(&[item.id], true), control), frame(st)?)) + })?; + match r { + Some(r) => Ok(f.bounds(h.dom.coords.get(), r)), + None => Ok(Data::Array(vec![num(0.0), num(0.0), num(0.0), num(0.0)])), + } +} + +/// The box of the control points of the paths in `n`, the visible members of its groups and +/// compound paths included; none for other art. +fn control_points_box(n: &crate::doc::Node) -> Option { + match &n.kind { + NodeKind::Path { path, .. } => path.control_bounds(), + NodeKind::Group { .. } | NodeKind::Compound { .. } => { + n.children()?.iter().filter(|c| c.visible).fold(None, |acc, c| vectorcraft_geom::union_opt(acc, control_points_box(c))) + } + _ => None, + } +} + fn item_position(h: &Host, a: &[Data]) -> Answer { let item = this_item(h, a)?; match item_rect(h, item, false)? { @@ -1895,13 +1945,13 @@ fn destination(h: &Host, item: Item, target: &Data, how: &Data) -> std::result:: let how = placement_of(how)?; let beside = matches!(how, Placement::Above | Placement::Below); let handle = handle_of(target, "PageItem").or_else(|| handle_of(target, "Layer")); - let Some(&[run, uid, high, low]) = handle.as_deref() else { + let Some(&[run, uid, reverts, high, low]) = handle.as_deref() else { if handle_of(target, "Document").is_some() { return Err(HostError::Error("a document as the relative object is not available yet".into())); } return Err(HostError::Type("the relative object must be a page item or a layer".into())); }; - let doc = find_doc(h, run, uid).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; + let doc = find_doc_of_object(h, run, uid, reverts).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; if doc.uid != item.doc.uid { return Err(HostError::Error(CROSS_DOCUMENT.into())); } @@ -2069,8 +2119,8 @@ fn item_z_order(h: &Host, a: &[Data]) -> Answer { fn layer_name(h: &Host, a: &[Data]) -> Answer { let Some(handle) = handle_of(arg(a, 0), "Layer") else { return Err(HostError::Type("this is not a Layer".into())) }; - let [run, uid, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a Layer".into())) }; - let doc = find_doc(h, *run, *uid).ok_or_else(|| HostError::Error(STALE_DOCUMENT.into()))?; + let [run, uid, reverts, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a Layer".into())) }; + let doc = find_doc_of_object(h, *run, *uid, *reverts).ok_or_else(|| HostError::Error(STALE_DOCUMENT.into()))?; let id = id_of(*high, *low).unwrap_or(NodeId(u64::MAX)); with_doc(h, doc, |_, st| st.doc.node(id).map(|n| text(n.name.clone().unwrap_or_default())).ok_or_else(|| HostError::Error(STALE_ITEM.into()))) } @@ -2223,7 +2273,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("index", method(l, items_index)), ("getByName", method(l, items_by_name)), ("removeAll", method(l, items_remove_all)), - ("toString", class_text("PageItems")), + ("toString", method(l, items_to_string)), ]), Some(function(l, items_at)), )); @@ -2243,7 +2293,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("height", property(l, item_height, item_set_height)), ("geometricBounds", get(l, item_geometric)), ("visibleBounds", get(l, item_visible)), - ("controlBounds", get(l, item_visible)), + ("controlBounds", get(l, item_control)), ("editable", get(l, item_editable)), ("zOrderPosition", get(l, item_z_order_position)), ("duplicate", method(l, item_duplicate)), diff --git a/crates/engine/src/store.rs b/crates/engine/src/store.rs index 7afab7426d..703597dc45 100644 --- a/crates/engine/src/store.rs +++ b/crates/engine/src/store.rs @@ -187,6 +187,52 @@ fn read_past_cap(path: &Path, max: u64) -> std::io::Result> { Ok(bytes) } +/// What [`read_capped_plain`] tells a path that is not a plain file. +pub(crate) const NOT_PLAIN: &str = "not a plain file"; + +/// The content of `path` when it is a plain file of at most `max` bytes. The file is opened without +/// following a link at `path` (on Windows a junction or other reparse point is opened itself), and +/// its kind and bytes are read from that open file, so a link put at `path` after an earlier check +/// is refused with [`NOT_PLAIN`] rather than read. +pub(crate) fn read_capped_plain(path: &Path, max: u64) -> Result, String> { + let file = open_no_link(path).map_err(|e| match std::fs::symlink_metadata(path) { + Ok(m) if !m.file_type().is_file() || reparse_point(&m) => NOT_PLAIN.to_string(), + _ => e.to_string(), + })?; + let m = file.metadata().map_err(|e| e.to_string())?; + if !m.file_type().is_file() || reparse_point(&m) { + return Err(NOT_PLAIN.to_string()); + } + let mut bytes = vec![]; + file.take(max + 1).read_to_end(&mut bytes).map_err(|e| e.to_string())?; + if bytes.len() as u64 > max { + return Err(too_large(max)); + } + Ok(bytes) +} + +/// `path` opened for reading, without following a link there. A pipe put in its place does not hold +/// the open up. +#[cfg(unix)] +fn open_no_link(path: &Path) -> std::io::Result { + use std::os::unix::fs::OpenOptionsExt; + let flags = rustix::fs::OFlags::NOFOLLOW | rustix::fs::OFlags::NONBLOCK; + std::fs::OpenOptions::new().read(true).custom_flags(flags.bits() as i32).open(path) +} + +/// `path` opened for reading; a link or junction there is opened itself, not its target. +#[cfg(windows)] +fn open_no_link(path: &Path) -> std::io::Result { + use std::os::windows::fs::OpenOptionsExt; + const FILE_FLAG_OPEN_REPARSE_POINT: u32 = 0x0020_0000; + std::fs::OpenOptions::new().read(true).custom_flags(FILE_FLAG_OPEN_REPARSE_POINT).open(path) +} + +#[cfg(not(any(unix, windows)))] +fn open_no_link(path: &Path) -> std::io::Result { + std::fs::File::open(path) +} + /// What a file over its cap is told (a detail after the file's name, in the log or an error). fn too_large(max: u64) -> String { format!("larger than {max} bytes") diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 4deef14b04..516992c07e 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -155,6 +155,27 @@ fn page_item_size_setters_on_a_rotated_object_give_the_page_aligned_size() { assert_eq!(format!("{:?}", s.active().unwrap().doc.node(b)), other, "the other object stays as it was"); } +/// `controlBounds` holds a curve's handles, which reach past the curve; for a rectangle it is the +/// visible bounds. +#[test] +fn control_bounds_hold_the_handles_of_a_curve() { + let (mut s, _, _) = doc(); + s.execute("path.create", &json!({"d": "M100 200 C100 100 200 100 200 200"})).unwrap(); + let out = log( + &mut s, + "var p = app.activeDocument.pageItems, c = p[0], r = p[1];\ + function h(b) { return b[1] - b[3]; }\ + vc.log([h(c.visibleBounds), h(c.controlBounds), c.controlBounds[0] <= c.visibleBounds[0]]);\ + vc.log(String(r.controlBounds) === String(r.visibleBounds));", + ); + let heights = out[0].as_array().unwrap(); + let (visible, control) = (heights[0].as_f64().unwrap(), heights[1].as_f64().unwrap()); + // The curve rises 75 pt and its handles 100 pt; half the stroke's weight reaches above the curve. + assert!(control - visible > 20.0 && control - visible <= 25.0 + 1e-6, "{out:?}"); + assert_eq!(heights[2], json!(true), "{out:?}"); + assert_eq!(out[1], json!(true), "{out:?}"); +} + #[test] fn convert_coordinate_pair_is_inverse_and_y_up() { let mut s = Session::new(); @@ -270,6 +291,7 @@ fn assigning_the_reported_opacity_changes_nothing() { assert_eq!(out, vec![json!(33.3333)]); assert_eq!(s.active().unwrap().doc.node(a).unwrap().opacity, before); assert_eq!(undo_steps(&s), steps); + assert_eq!(s.script_report().unwrap()["slowestCommands"], json!([]), "the assignment runs no command"); // A value close to the reported one but not equal to it is still applied. s.execute("object.setProps", &json!({"id": a.0, "opacity": 50})).unwrap(); let (before, steps) = (s.active().unwrap().doc.node(a).unwrap().opacity, undo_steps(&s)); @@ -285,6 +307,14 @@ fn selection_assignment_is_atomic_across_invalid_items() { let e = failure(&mut s, "var p = app.activeDocument.pageItems; app.activeDocument.selection = [p[0], p[1]];"); assert!(e.contains("Cannot select PathItem"), "{e}"); assert!(s.active().unwrap().selection.objects.is_empty()); + // With the valid item first and the error caught, the run sees the selection unchanged. + let out = log( + &mut s, + "var d = app.activeDocument, p = d.pageItems; try { d.selection = [p[1], p[0]]; vc.log('assigned'); }\ + catch (e) { vc.log(String(e).indexOf('Cannot select PathItem') >= 0); } vc.log(d.selection.length);", + ); + assert_eq!(out, vec![json!(true), json!(0)]); + assert!(s.active().unwrap().selection.objects.is_empty()); s.execute("object.setProps", &json!({"ids": [b.0], "locked": false})).unwrap(); let out = log( &mut s, @@ -680,9 +710,13 @@ fn a_listed_preset_keeps_more_rows_than_artboards() { fn stale_documents_throw_on_every_member() { let (mut s, _, _) = doc(); run(&mut s, "#targetengine keep\nvar d = app.activeDocument, p = d.pageItems, l = p[0].parent;").unwrap(); - for (member, message) in - [("d.typename", "Stale document"), ("d.parent", "Stale document"), ("p.typename", "Stale document"), ("l.typename", "Stale")] - { + for (member, message) in [ + ("d.typename", "Stale document"), + ("d.parent", "Stale document"), + ("p.typename", "Stale document"), + ("p.toString()", "Stale document"), + ("l.typename", "Stale"), + ] { let e = failure(&mut s, &format!("#targetengine keep\n{member};")); assert!(e.contains(message), "{member}: {e}"); } @@ -1192,6 +1226,27 @@ fn wrappers_go_stale_after_delete_and_undo() { assert!(e.contains("Stale page item"), "{e}"); } +/// Reverting a document reads its objects again from its file, so the page items and layers taken +/// before the revert are stale, even where the file has an object under the same id. +#[test] +fn page_items_and_layers_go_stale_when_their_document_is_reverted() { + let (mut s, _, _) = doc(); + let path = std::env::temp_dir().join(format!("vc-dom-revert-{}.{}", std::process::id(), vectorcraft_format::EXTENSION)); + s.execute("document.save", &json!({"path": path.to_string_lossy()})).unwrap(); + for (taken, read, message) in [("p[0]", "i.name", "Stale page item"), ("p[0].parent", "i.typename", "Stale")] { + let source = format!("var p = app.activeDocument.pageItems, i = {taken}; p[1].name = 'x'; vc.run('file.revert', {{}}); {read};"); + let e = failure(&mut s, &source); + assert!(e.contains(message), "{taken}: {e}"); + } + let out = log( + &mut s, + "app.activeDocument.pageItems[1].name = 'x'; vc.run('file.revert', {}); var p = app.activeDocument.pageItems;\ + vc.log([p.length, p[0].typename, p[1].name]);", + ); + assert_eq!(out, vec![json!([2, "PathItem", ""])]); + let _ = std::fs::remove_file(path); +} + #[test] fn remove_all_refuses_locked_art_before_deleting_anything() { let (mut s, a, b) = doc(); @@ -1199,6 +1254,14 @@ fn remove_all_refuses_locked_art_before_deleting_anything() { let e = failure(&mut s, "app.activeDocument.pageItems.removeAll();"); assert!(e.contains(&b.0.to_string()), "{e}"); assert_eq!(s.active().unwrap().doc.layers[0].children().unwrap().len(), 2); + // With the error caught, the run that goes on still has both objects. + let out = log( + &mut s, + "var p = app.activeDocument.pageItems; try { p.removeAll(); vc.log('removed'); }\ + catch (e) { vc.log(String(e).indexOf('cannot delete hidden or locked objects') >= 0); } vc.log(p.length);", + ); + assert_eq!(out, vec![json!(true), json!(2)]); + assert_eq!(s.active().unwrap().doc.layers[0].children().unwrap().len(), 2); s.execute("object.setProps", &json!({"ids": [b.0], "locked": false})).unwrap(); // A locked object inside an unlocked group stops it too. s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); @@ -1345,8 +1408,9 @@ fn get_is_file_open_cannot_probe_outside_script_scope() { let (mut s, _, _) = doc(); let path = std::env::temp_dir().join(format!("vc-dom-open-{}.svg", std::process::id())); s.execute("document.save", &json!({"path": path.to_string_lossy()})).unwrap(); - let p = path.to_string_lossy().replace('\\', "\\\\"); - let query = format!("vc.log(app.getIsFileOpen('{p}')); vc.log(app.getIsFileOpen('{p}.other'));"); + let p = path.to_string_lossy(); + let (saved, other) = (json!(p), json!(format!("{p}.other"))); + let query = format!("vc.log(app.getIsFileOpen({saved})); vc.log(app.getIsFileOpen({other}));"); let out = log(&mut s, &query); assert_eq!(out, vec![json!(true), json!(false)]); // Read roots that leave out the document's file: the same path does not count. @@ -1652,6 +1716,9 @@ fn a_collection_read_with_a_name_gives_the_named_object() { vc.log(m);", ); assert_eq!(out, vec![json!([true, "n", true, false, true]), json!([true, true, false]), json!(["Not found", "Not found"])]); + // A name the collection inherits is not looked up as an object's name when it is assigned. + let out = log(&mut s, "Object.prototype.tag = 1; var p = app.activeDocument.pageItems; p.tag = 2; vc.log(p.tag);"); + assert_eq!(out, vec![json!(1)]); } /// `opacity`, `hidden`, `locked` and the position and size setters on an object in a hidden or diff --git a/crates/engine/src/tests/store.rs b/crates/engine/src/tests/store.rs index 21967473bb..dfc603dc59 100644 --- a/crates/engine/src/tests/store.rs +++ b/crates/engine/src/tests/store.rs @@ -157,6 +157,24 @@ fn a_write_reads_the_file_it_replaces_only_one_byte_past_the_new_length() { assert!(holds(&[][..], &[])); } +#[cfg(unix)] +#[test] +fn a_plain_capped_read_refuses_a_link_and_reads_a_plain_file() { + use crate::store::{NOT_PLAIN, read_capped_plain}; + let root = fresh_dir("plain-read"); + let target = root.join("target.bin"); + std::fs::write(&target, b"outside").unwrap(); + let link = root.join("profile.vectorcraft"); + std::os::unix::fs::symlink(&target, &link).unwrap(); + assert_eq!(read_capped_plain(&link, 100), Err(NOT_PLAIN.to_string())); + let folder = root.join("folder"); + std::fs::create_dir(&folder).unwrap(); + assert_eq!(read_capped_plain(&folder, 100), Err(NOT_PLAIN.to_string())); + assert_eq!(read_capped_plain(&target, 100), Ok(b"outside".to_vec())); + assert_eq!(read_capped_plain(&target, 7), Ok(b"outside".to_vec())); + assert!(read_capped_plain(&target, 6).is_err()); +} + #[test] fn a_saved_preset_replaces_an_oversized_file_in_its_place() { let root = fresh_dir("oversized-put"); diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 4368ce29b7..aacf3017d5 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -83,7 +83,7 @@ const INSIDE: &[(&str, &str)] = &[ ( "Application.prototype.", "activeDocument activeDocument= beep beep= constructor coordinateSystem coordinateSystem= documents getIsFileOpen \ - selection selection= toString typename", + selection selection= selectTool toString typename", ), ("DocumentPreset.", "prototype"), ( diff --git a/crates/js/src/host_classes.rs b/crates/js/src/host_classes.rs index 206f781ef3..a25e0e531a 100644 --- a/crates/js/src/host_classes.rs +++ b/crates/js/src/host_classes.rs @@ -91,6 +91,9 @@ pub(crate) struct Entry { parent: Option, /// The names of the members `hasOwnProperty` reports: every member but the unavailable ones. own: Rc>, + /// The names of the unavailable members, which hide a member of the same name that a parent + /// class has. + unavailable: Rc>, } impl Entry { @@ -143,7 +146,8 @@ pub fn host_ref_parts(d: &Data) -> Option<(&str, Vec)> { impl Interp { /// Whether `k` is a member that `hasOwnProperty` reports on `id`: `id` is an object of a host - /// class, and `k` names an available member of that class or of a class it descends from. + /// class, and `k` names an available member of the nearest class that declares `k`, that class + /// or one it descends from. pub(crate) fn is_host_member(&self, id: ObjId, k: &[u16]) -> JsResult { let Class::Host(h) = &self.object(id)?.class else { return Ok(false) }; let mut class = Some(h.class); @@ -152,6 +156,9 @@ impl Interp { if e.own.contains(k) { return Ok(true); } + if e.unavailable.contains(k) { + return Ok(false); + } class = e.parent; } Ok(false) @@ -307,7 +314,7 @@ fn install_class(i: &mut Interp, class: HostClass) -> JsResult<()> { let r = fill_class(i, proto, &class); i.temp_roots.truncate(mark); let ctor = r?; - let members = class.members.iter().filter(|(_, m)| !matches!(m, HostMember::Unavailable(_))).map(|(name, _)| key(name)).collect(); + let (unavailable, members): (Vec<_>, Vec<_>) = class.members.iter().partition(|(_, m)| matches!(m, HostMember::Unavailable(_))); i.host_classes.push(Entry { name: class.name.as_str().into(), proto, @@ -315,7 +322,8 @@ fn install_class(i: &mut Interp, class: HostClass) -> JsResult<()> { index: class.index, family, parent: parent_class, - own: Rc::new(members), + own: Rc::new(members.into_iter().map(|(name, _)| key(name)).collect()), + unavailable: Rc::new(unavailable.into_iter().map(|(name, _)| key(name)).collect()), }); let global = i.global; i.define(global, key(&class.name), Prop::Data { value: Value::Object(ctor), flags: crate::heap::HIDDEN }) diff --git a/crates/js/src/host_tests.rs b/crates/js/src/host_tests.rs index ba0e005ce0..ce695b7e06 100644 --- a/crates/js/src/host_tests.rs +++ b/crates/js/src/host_tests.rs @@ -717,6 +717,25 @@ fn objects_of_a_host_class_report_its_available_members_as_their_own() { ); } +#[test] +fn an_unavailable_member_hides_the_member_its_parent_class_has() { + let mut r = realm(1_000_000); + let value: HostFunction = Rc::new(|_| Ok(Data::Number(1.0))); + let missing: HostFunction = Rc::new(|_| Err(HostError::Error("not here yet".into()))); + let class = |name: &str, parent: Option<&str>, member: HostMember| HostClass { + name: name.into(), + parent: parent.map(Into::into), + members: vec![("size".to_string(), member)], + index: None, + construct: None, + }; + let classes = vec![class("Base", None, HostMember::Get(value)), class("Leaf", Some("Base"), HostMember::Unavailable(missing))]; + let objects = vec![("it".into(), host_ref("Leaf", &[1.0])), ("base".into(), host_ref("Base", &[2.0]))]; + r.define_host_classes(classes, objects).unwrap(); + r.start("[it.hasOwnProperty('size'), it.propertyIsEnumerable('size'), base.hasOwnProperty('size')].join()").unwrap(); + assert_eq!(finish(&mut r, 1_000_000).0.unwrap(), JsValue::String("false,false,true".into())); +} + #[test] fn a_converted_function_reads_each_argument_as_its_list_says() { let mut r = realm(1_000_000); diff --git a/crates/js/src/interp.rs b/crates/js/src/interp.rs index f7cb2896a2..f10f0e9566 100644 --- a/crates/js/src/interp.rs +++ b/crates/js/src/interp.rs @@ -1859,16 +1859,17 @@ impl Interp { None => {} } let proto = self.object(id)?.proto; - match proto.map(|p| self.find_property(p, &k)).transpose()?.flatten() { + let inherited = match proto.map(|p| self.find_property(p, &k)).transpose()?.flatten() { Some(Prop::Accessor { set: Some(s), .. }) => return self.call(&Value::Object(s), &Value::Object(id), &[v]).map(drop), Some(Prop::Accessor { set: None, .. }) => return self.reject(throw, &k, "it has only a getter"), Some(Prop::Data { flags, .. }) if flags & WRITABLE == 0 => return self.reject(throw, &k, "it is read-only"), - _ => {} - } + found => found.is_some(), + }; if !self.object(id)?.extensible { - // A name that an object of a host class with an indexer lacks is read with the indexer - // first, so assigning it throws what reading it throws. - if array_index(&k).is_none() + // A name that an object of a host class with an indexer lacks, on it and its prototypes, + // is read with the indexer first, so assigning it throws what reading it throws. + if !inherited + && array_index(&k).is_none() && let Some(f) = self.host_indexer(id)? { self.host_index(&f, id, Self::indexer_key(&k), false)?; diff --git a/docs/mcp.md b/docs/mcp.md index 6902e16314..e221d601d1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2709,7 +2709,7 @@ app through the global object `vc`, and writes to the Script Console and runs ot or removes only that object, as `select.add` and `select.toggle` do, and the other objects stay selected as they were), `opacity` (0 to 100), `position`, `left`, `top`, `width`, `height`, `geometricBounds`, `visibleBounds`, `controlBounds` (the - visible bounds), `editable` (false for an object that is hidden or locked, in a hidden or locked layer or group, + visible bounds, grown to hold the control points of the object's paths), `editable` (false for an object that is hidden or locked, in a hidden or locked layer or group, or on a locked artboard), `zOrderPosition`, `duplicate(relativeObject?, insertionLocation?)`, `move(relativeObject, insertionLocation?)`, `remove()` and `zOrder(method)` (https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/). `move` runs `node.move`, and `duplicate` runs @@ -2761,8 +2761,9 @@ app through the global object `vc`, and writes to the Script Console and runs ot for kinds the help pages give no class. Each change runs a command and joins the run's one undo step for each changed document. A value that changes nothing runs no command, and a change to another document leaves the active tab as it was. A command that selects the objects it changes leaves the current layer and the highlighted Layers - panel rows as they were before the change. A bad value throws an error and changes nothing. An object that was - deleted, or that a named engine kept from an earlier run, throws `Stale page item`. `remove()` on an object that + panel rows as they were before the change. A bad value throws an error and changes nothing. A page item that was + deleted, or that a named engine kept from an earlier run, throws `Stale page item`, and a document or a page item + collection that a named engine kept from an earlier run throws `Stale document`. `remove()` on an object that is hidden or locked, is inside a hidden or locked layer or group, or is a group that holds one, and `removeAll()` when any object is, throw `cannot delete hidden or locked objects` and delete nothing. `remove()` on an object on a locked artboard, and `removeAll()` when any object is on one, throw `cannot delete objects on a locked artboard` diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7d6ec78683..db38ae94f7 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1033,7 +1033,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Synthetic input validates complete gestures before queue mutation: at most 256 drag steps, 16 clicks and 1,024 pending events; up to 64 control requests per frame, with later requests retained for the next frame (#1709). - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). A script can check a member with `hasOwnProperty`, and can read a collection by name and name `activeDocument`, `documents` and `selection` without `app.` (https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/). `app.selectTool(name)` makes the named tool the current tool when the run ends (https://community.adobe.com/questions-652/what-s-new-in-illustrator-scripting-cc2020-769942). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. + - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). A script can check a member with `hasOwnProperty`, and can read a collection by name and name `activeDocument`, `documents` and `selection` without `app.` (https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/). `app.selectTool(name)` makes the named tool the current tool when the run ends without an error (https://community.adobe.com/questions-652/what-s-new-in-illustrator-scripting-cc2020-769942). Layers, paths, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From e97b0b49ae6d94acaad0ed4a2fe75832bf32ce13 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 00:31:11 -0800 Subject: [PATCH 028/264] Scripts: Document default fill and stroke members and scaleFactor A script that read or assigned a document's defaultFillColor, defaultStrokeWidth or another default paint member, or read scaleFactor, got undefined. The twelve default members now read and set the fill, stroke and stroke options of the next object drawn, and scaleFactor reads 1. - appearance.setNewArt sets new art's fill, stroke and stroke options whatever is selected, leaving the selection, its art, the active proxy and Recent Colors as they were. Every value is checked before anything changes. - The default members run it only when the value changes. A bad value throws an error with nothing changed. - paths.rs shares its dash length checks with defaultStrokeDashes. --- crates/engine/src/cmd/newart.rs | 131 ++++++++++- crates/engine/src/script/dom.rs | 2 + crates/engine/src/script/dom/defaults.rs | 212 ++++++++++++++++++ crates/engine/src/script/dom/paths.rs | 26 ++- crates/engine/src/tests.rs | 1 + crates/engine/src/tests/newart.rs | 69 ++++++ .../engine/src/tests/script_dom_defaults.rs | 144 ++++++++++++ .../tests/it/script_host_vs_scriptcheck.rs | 9 +- docs/mcp.md | 23 +- docs/target-app-parity.md | 3 +- 10 files changed, 605 insertions(+), 15 deletions(-) create mode 100644 crates/engine/src/script/dom/defaults.rs create mode 100644 crates/engine/src/tests/script_dom_defaults.rs diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index a42088e7e3..56e7e4dfe8 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -6,7 +6,8 @@ //! and strokes, effects, opacity and blend mode, and the link to the style) or, with the Appearance //! panel's New Art Has Basic Appearance off, the whole appearance of the last selection. With the //! option on (the default) an inherited appearance gives new art its top stroke's options only, -//! and a change of selection loads only the proxies. `paint.default` resets it. +//! and a change of selection loads only the proxies. `paint.default` resets it, and +//! `appearance.setNewArt` sets its fill, stroke and stroke options whatever is selected. //! //! A document whose Default Graphic Style no longer has the shipped look (a New Document profile //! redefined it) gives the reset that style's fills, strokes and effects instead, and `file.new` @@ -20,7 +21,7 @@ use vectorcraft_doc::{Appearance, AppearanceItem, ColorMode, DEFAULT_GRAPHIC_STY use vectorcraft_tools::PaintDefaults; use super::gradient::unplaced; -use super::{CommandSpec, Result, Session, always, cmd, switch_or}; +use super::{CommandSpec, Result, Session, always, bad, cmd, switch_or}; pub fn specs() -> Vec { vec![ @@ -42,9 +43,135 @@ pub fn specs() -> Vec { always, describe ), + cmd!( + "appearance.setNewArt", + "Set New Art Appearance", + [], + None, + "{fill?: {color?, none?, swatch?, tint?, gradient?, keepModel?} (a paint as paint.setFill takes it), stroke?: (a paint, as fill), weight?: 0..1000 pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?: 1..500, dash?: [lengths, each 0..1000000 pt, at most 64, not all 0]|null (null: a solid line), dashOffset?: -1000000..1000000 pt (with a dash pattern), fillOverprint?: bool, strokeOverprint?: bool} set the fill, stroke and stroke options the next object drawn gets, whatever is selected: the selection and its art, the active proxy and the recent colors stay as they are. A stroke painted on new art without one gets a 1 pt weight unless `weight` is given. A bad value is an error with nothing changed, and so is any change while New Art Has Basic Appearance is off and an object is selected (new art takes that object's appearance then) → {changed: whether the next object drawn looks different}", + always, + set_new_art + ), ] } +/// The most dash and gap lengths `appearance.setNewArt` takes. +const MAX_DASHES: usize = 64; +/// The largest dash, gap or dash offset `appearance.setNewArt` takes, in points. +const MAX_DASH_LENGTH: f64 = 1_000_000.0; + +/// `appearance.setNewArt`: new art's fill, stroke and stroke options, every value checked before +/// anything changes. +fn set_new_art(s: &mut Session, p: &Value) -> Result { + const C: &str = "appearance.setNewArt"; + let paint = |key: &str, fill: bool| -> Result> { + let Some(v) = p.get(key) else { return Ok(None) }; + if !v.is_object() { + return Err(bad(C, format!("{key} must be a paint object (color, none, swatch or gradient), got {v}"))); + } + if v.get("tint").is_some() && v.get("swatch").is_none() { + return Err(bad(C, format!("{key}: `tint` goes with a global or spot `swatch`"))); + } + let given = super::paint::paint_from(s, v)?.ok_or_else(|| bad(C, format!("{key}: give color, none, swatch or gradient")))?; + if !fill && matches!(&given, Paint::Gradient(g) if g.gradient.dither) && v.get("swatch").and_then(Value::as_str).is_none() { + return Err(bad(C, "`dither` applies to gradient fills")); + } + Ok(Some(unplaced(&given))) + }; + let (fill, stroke) = (paint("fill", true)?, paint("stroke", false)?); + let number = |key: &str, min: f64, max: f64| -> Result<()> { + match p.get(key) { + None => Ok(()), + Some(v) if v.as_f64().is_some_and(|n| n.is_finite() && (min..=max).contains(&n)) => Ok(()), + Some(v) => Err(bad(C, format!("{key} must be a number from {min} to {max}, got {v}"))), + } + }; + number("weight", 0.0, 1000.0)?; + number("miterLimit", 1.0, 500.0)?; + number("dashOffset", -MAX_DASH_LENGTH, MAX_DASH_LENGTH)?; + for key in ["cap", "join"] { + if p.get(key).is_some_and(|v| !v.is_string()) { + return Err(bad(C, format!("{key} must be a name"))); + } + } + match p.get("dash") { + None | Some(Value::Null) => {} + Some(Value::Array(a)) if a.len() > MAX_DASHES => return Err(bad(C, format!("dash takes at most {MAX_DASHES} lengths"))), + Some(Value::Array(a)) => { + if !a.iter().all(|v| v.as_f64().is_some_and(|n| n.is_finite() && (0.0..=MAX_DASH_LENGTH).contains(&n))) { + return Err(bad(C, format!("each dash length must be a number from 0 to {MAX_DASH_LENGTH}"))); + } + if !a.is_empty() && a.iter().all(|v| v.as_f64() == Some(0.0)) { + return Err(bad(C, "dash needs a length that is not 0")); + } + } + Some(v) => return Err(bad(C, format!("dash must be a list of lengths or null, got {v}"))), + } + let flag = |key: &str| -> Result> { + p.get(key).map(|v| v.as_bool().ok_or_else(|| bad(C, format!("{key} must be true or false, got {v}")))).transpose() + }; + let (fill_overprint, stroke_overprint) = (flag("fillOverprint")?, flag("strokeOverprint")?); + let options: serde_json::Map = + ["weight", "cap", "join", "miterLimit", "dash", "dashOffset"].iter().filter_map(|k| Some((k.to_string(), p.get(*k)?.clone()))).collect(); + let change = super::stroke::StrokeChange::parse(&Value::Object(options), C)?; + let dashed = match p.get("dash") { + Some(Value::Array(a)) => !a.is_empty(), + Some(_) => false, + None => s.new_art().stroke().is_some_and(|st| st.dash.is_some()), + }; + if p.get("dashOffset").and_then(Value::as_f64).is_some_and(|o| o != 0.0) && !dashed { + return Err(bad(C, "dashOffset needs a dash pattern")); + } + let nothing = fill.is_none() && stroke.is_none() && change.is_empty() && fill_overprint.is_none() && stroke_overprint.is_none(); + if !nothing && !s.prefs.new_art_basic && !s.bucket_paints() && s.active().is_some_and(|st| !st.selection.subjects().is_empty()) { + return Err(bad( + C, + "with New Art Has Basic Appearance off, new art takes the selected object's appearance: deselect it or turn the option on", + )); + } + let look = |s: &Session| { + let (opacity, blend, style) = s.new_art_transparency(); + (s.new_art(), opacity, blend, style.map(str::to_string)) + }; + let (before, was) = (s.paint.clone(), look(s)); + if let Some(f) = fill { + s.paint.fill = f; + } + if let Some(st) = stroke { + if !st.is_none() && s.paint.stroke.is_none() && s.paint.stroke_width == 0.0 { + s.paint.stroke_width = 1.0; + } + s.paint.stroke = st; + } + if let Some(w) = change.weight { + s.paint.stroke_width = w; + } + if !change.is_empty() + && let Some(st) = s.new_art_stroke_mut() + { + change.apply(st); + } + if let Some(on) = fill_overprint { + let t = s.new_art_template_mut(); + if t.fill().is_none() { + t.items.insert(0, AppearanceItem::Fill(FillLayer::new(Paint::None))); + } + if let Some(f) = t.fill_mut() { + f.overprint = on; + } + } + if let Some(on) = stroke_overprint + && let Some(st) = s.new_art_stroke_mut() + { + st.overprint = on; + } + let changed = look(s) != was; + if !changed { + s.paint = before; + } + Ok(json!({ "changed": changed })) +} + /// `t` reduced to a basic appearance: an empty fill under its top stroke (options kept, without /// its own transparency or effects). fn basic_of(t: &Appearance) -> Appearance { diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 8b2267a5d8..8cc774bd92 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -39,6 +39,7 @@ use super::{HISTORY_LOST, Host, Link, Savepoint, command, command_value, current use crate::{DocState, Document, NodeId, NodeKind, Session}; mod colors; +mod defaults; mod paths; /// The error for a member read or called with no document open. @@ -1928,6 +1929,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(), ("selection", property(l, doc_selection, doc_set_selection)), ("pathItems", get(l, paths::doc_path_items)), ]); + document.extend(defaults::document_members(l)); document.extend( ["layers", "artboards", "groupItems", "textFrames", "swatches", "symbols", "views", "activeLayer", "saveAs", "close"] .into_iter() diff --git a/crates/engine/src/script/dom/defaults.rs b/crates/engine/src/script/dom/defaults.rs new file mode 100644 index 0000000000..fe8eb5c3f3 --- /dev/null +++ b/crates/engine/src/script/dom/defaults.rs @@ -0,0 +1,212 @@ +//! A document's default fill and stroke in the script object model, the `Document` members whose +//! names start with `default` that the help page +//! describes, and `scaleFactor`. +//! +//! The defaults are what the next object drawn gets ([`crate::Session::new_art`]), the same for +//! every open document, as the help page says of these global settings. Reading one reads new +//! art's top fill or stroke, and assigning one runs `appearance.setNewArt`, which leaves the +//! selection, its art, the active proxy and the recent colors as they were. A value that changes +//! nothing runs no command, and a bad value throws an error with nothing changed. +//! +//! VectorCraft's own rules, which the help page does not state: +//! - A color is new art's fill or stroke itself: assigning a color also makes `defaultFilled` or +//! `defaultStroked` true, and assigning a `NoColor` makes it false. `defaultFilled` or +//! `defaultStroked` set to true with no default fill or stroke gives black. +//! - An RGB color is stored in the color mode of the document in front, as `paint.setFill` stores +//! it. +//! - `defaultStrokeWidth` is 0 to 1000 points, a dash or gap 0 to 1,000,000 points (at most 64 of +//! them, not all 0), and `defaultStrokeDashOffset` -1,000,000 to 1,000,000 points, which needs a +//! dash pattern unless it is 0. +//! - While New Art Has Basic Appearance is off and an object is selected, assigning a default +//! throws an error, since new art then takes that object's appearance. +//! - `scaleFactor` is 1: VectorCraft draws every document at its own size. + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{Appearance, LineCap, LineJoin}; +use vectorcraft_js::{Data, HostError, HostMember}; + +use super::paths::{CAPS, JOINS, MAX_STROKE_WIDTH, dash_lengths}; +use super::{Answer, Host, Link, arg, boolean, colors, command, get, num, number, property, this_doc}; + +/// New art's appearance, after the check that the document `this` names is still open. +fn new_art(h: &Host, a: &[Data]) -> std::result::Result { + this_doc(h, a)?; + Ok(h.session.borrow().new_art()) +} + +/// Runs `appearance.setNewArt` with `params`, unless `same`. +fn set(h: &Host, same: bool, params: Value) -> Answer { + if !same { + command(h, "appearance.setNewArt", ¶ms)?; + } + Ok(Data::Undefined) +} + +fn top_paint(ap: &Appearance, fill: bool) -> Paint { + if fill { ap.fill_paint() } else { ap.stroke_paint() } +} + +fn default_color(h: &Host, a: &[Data], fill: bool) -> Answer { + Ok(colors::of_paint(&top_paint(&new_art(h, a)?, fill))) +} + +fn set_default_color(h: &Host, a: &[Data], fill: bool) -> Answer { + let what = if fill { "defaultFillColor" } else { "defaultStrokeColor" }; + let color = colors::assigned(arg(a, 1), what)?; + let now = top_paint(&new_art(h, a)?, fill); + let same = match (&color, &now) { + (None, Paint::None) => true, + (Some(c), Paint::Solid { color, swatch: None, .. }) => c == color, + _ => false, + }; + let paint = match color { + Some(c) => json!({"color": colors::param(&c)}), + None => json!({"none": true}), + }; + let key = if fill { "fill" } else { "stroke" }; + set(h, same, json!({ key: paint })) +} + +fn default_painted(h: &Host, a: &[Data], fill: bool) -> Answer { + Ok(Data::Bool(!top_paint(&new_art(h, a)?, fill).is_none())) +} + +fn set_default_painted(h: &Host, a: &[Data], fill: bool) -> Answer { + let on = boolean(arg(a, 1), if fill { "defaultFilled" } else { "defaultStroked" })?; + let now = !top_paint(&new_art(h, a)?, fill).is_none(); + let paint = if on { json!({"color": colors::param(&Color::BLACK)}) } else { json!({"none": true}) }; + let key = if fill { "fill" } else { "stroke" }; + set(h, now == on, json!({ key: paint })) +} + +fn default_overprint(h: &Host, a: &[Data], fill: bool) -> Answer { + let ap = new_art(h, a)?; + Ok(Data::Bool(if fill { ap.fill().is_some_and(|f| f.overprint) } else { ap.stroke().is_some_and(|s| s.overprint) })) +} + +fn set_default_overprint(h: &Host, a: &[Data], fill: bool) -> Answer { + let (key, what) = if fill { ("fillOverprint", "defaultFillOverprint") } else { ("strokeOverprint", "defaultStrokeOverprint") }; + let on = boolean(arg(a, 1), what)?; + let now = default_overprint(h, a, fill)? == Data::Bool(on); + set(h, now, json!({ key: on })) +} + +/// New art's top stroke option `f` reads, or `none` when new art has no stroke. +fn stroke_option(h: &Host, a: &[Data], none: T, f: impl FnOnce(&vectorcraft_doc::StrokeLayer) -> T) -> std::result::Result { + Ok(new_art(h, a)?.stroke().map_or(none, f)) +} + +fn default_stroke_width(h: &Host, a: &[Data]) -> Answer { + this_doc(h, a)?; + Ok(num(h.session.borrow().paint.stroke_width)) +} + +fn set_default_stroke_width(h: &Host, a: &[Data]) -> Answer { + let w = number(arg(a, 1), "defaultStrokeWidth")?; + if !(0.0..=MAX_STROKE_WIDTH).contains(&w) { + return Err(HostError::Range("defaultStrokeWidth must be from 0 to 1000 points".into())); + } + this_doc(h, a)?; + let now = h.session.borrow().paint.stroke_width; + set(h, (now - w).abs() < 1e-9, json!({"weight": w})) +} + +fn default_cap(h: &Host, a: &[Data]) -> Answer { + let cap = stroke_option(h, a, LineCap::default(), |s| s.cap)?; + Ok(Data::String(CAPS.iter().find(|c| c.0 == cap).map_or("StrokeCap.BUTTENDCAP", |c| c.1).into())) +} + +fn set_default_cap(h: &Host, a: &[Data]) -> Answer { + let found = match arg(a, 1) { + Data::String(s) => CAPS.iter().find(|c| c.1 == s), + _ => None, + }; + let Some(&(cap, _, name)) = found else { return Err(HostError::Type("defaultStrokeCap must be a StrokeCap value".into())) }; + let now = stroke_option(h, a, LineCap::default(), |s| s.cap)?; + set(h, now == cap, json!({"cap": name})) +} + +fn default_join(h: &Host, a: &[Data]) -> Answer { + let join = stroke_option(h, a, LineJoin::default(), |s| s.join)?; + Ok(Data::String(JOINS.iter().find(|j| j.0 == join).map_or("StrokeJoin.MITERENDJOIN", |j| j.1).into())) +} + +fn set_default_join(h: &Host, a: &[Data]) -> Answer { + let found = match arg(a, 1) { + Data::String(s) => JOINS.iter().find(|j| j.1 == s), + _ => None, + }; + let Some(&(join, _, name)) = found else { return Err(HostError::Type("defaultStrokeJoin must be a StrokeJoin value".into())) }; + let now = stroke_option(h, a, LineJoin::default(), |s| s.join)?; + set(h, now == join, json!({"join": name})) +} + +fn default_miter(h: &Host, a: &[Data]) -> Answer { + Ok(num(stroke_option(h, a, 10.0, |s| s.miter_limit)?)) +} + +fn set_default_miter(h: &Host, a: &[Data]) -> Answer { + let v = number(arg(a, 1), "defaultStrokeMiterLimit")?; + if !(1.0..=500.0).contains(&v) { + return Err(HostError::Range("defaultStrokeMiterLimit must be from 1 to 500".into())); + } + let now = stroke_option(h, a, 10.0, |s| s.miter_limit)?; + set(h, (now - v).abs() < 1e-9, json!({"miterLimit": v})) +} + +fn dashes(h: &Host, a: &[Data]) -> std::result::Result, HostError> { + stroke_option(h, a, Vec::new(), |s| s.dash.as_ref().map_or_else(Vec::new, |d| d.pattern.clone())) +} + +fn default_dashes(h: &Host, a: &[Data]) -> Answer { + Ok(Data::Array(dashes(h, a)?.into_iter().map(num).collect())) +} + +fn set_default_dashes(h: &Host, a: &[Data]) -> Answer { + let lengths = dash_lengths(arg(a, 1), "defaultStrokeDashes")?; + let now = dashes(h, a)?; + let dash = if lengths.is_empty() { Value::Null } else { json!(lengths) }; + set(h, now == lengths, json!({"dash": dash})) +} + +fn default_dash_offset(h: &Host, a: &[Data]) -> Answer { + Ok(num(stroke_option(h, a, 0.0, |s| s.dash.as_ref().map_or(0.0, |d| d.offset))?)) +} + +fn set_default_dash_offset(h: &Host, a: &[Data]) -> Answer { + let v = number(arg(a, 1), "defaultStrokeDashOffset")?; + if v.abs() > MAX_STROKE_WIDTH * 1000.0 { + return Err(HostError::Range("defaultStrokeDashOffset must be from -1000000 to 1000000 points".into())); + } + if dashes(h, a)?.is_empty() && v != 0.0 { + return Err(HostError::Error("defaultStrokeDashOffset needs defaultStrokeDashes first".into())); + } + let now = stroke_option(h, a, 0.0, |s| s.dash.as_ref().map_or(0.0, |d| d.offset))?; + set(h, (now - v).abs() < 1e-9, json!({"dashOffset": v})) +} + +fn scale_factor(h: &Host, a: &[Data]) -> Answer { + this_doc(h, a)?; + Ok(num(1.0)) +} + +/// The `Document` members of this module. +pub(super) fn document_members(l: &Link) -> Vec<(String, HostMember)> { + let members: Vec<(&str, HostMember)> = vec![ + ("defaultFillColor", property(l, |h, a| default_color(h, a, true), |h, a| set_default_color(h, a, true))), + ("defaultFilled", property(l, |h, a| default_painted(h, a, true), |h, a| set_default_painted(h, a, true))), + ("defaultFillOverprint", property(l, |h, a| default_overprint(h, a, true), |h, a| set_default_overprint(h, a, true))), + ("defaultStrokeColor", property(l, |h, a| default_color(h, a, false), |h, a| set_default_color(h, a, false))), + ("defaultStroked", property(l, |h, a| default_painted(h, a, false), |h, a| set_default_painted(h, a, false))), + ("defaultStrokeOverprint", property(l, |h, a| default_overprint(h, a, false), |h, a| set_default_overprint(h, a, false))), + ("defaultStrokeWidth", property(l, default_stroke_width, set_default_stroke_width)), + ("defaultStrokeCap", property(l, default_cap, set_default_cap)), + ("defaultStrokeJoin", property(l, default_join, set_default_join)), + ("defaultStrokeMiterLimit", property(l, default_miter, set_default_miter)), + ("defaultStrokeDashes", property(l, default_dashes, set_default_dashes)), + ("defaultStrokeDashOffset", property(l, default_dash_offset, set_default_dash_offset)), + ("scaleFactor", get(l, scale_factor)), + ]; + members.into_iter().map(|(k, m)| (k.to_string(), m)).collect() +} diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 32401db1d0..29b5e44719 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -797,13 +797,15 @@ fn path_set_stroke_width(h: &super::Host, a: &[Data]) -> Answer { set_stroke_option(h, item, (look.width - w).abs() < 1e-9, json!({"weight": w})) } -const CAPS: &[(LineCap, &str, &str)] = &[ +/// Each stroke cap, its `StrokeCap` value and its name in `stroke.set`. +pub(super) const CAPS: &[(LineCap, &str, &str)] = &[ (LineCap::Butt, "StrokeCap.BUTTENDCAP", "butt"), (LineCap::Round, "StrokeCap.ROUNDENDCAP", "round"), (LineCap::Square, "StrokeCap.PROJECTINGENDCAP", "square"), ]; -const JOINS: &[(LineJoin, &str, &str)] = &[ +/// Each stroke join, its `StrokeJoin` value and its name in `stroke.set`. +pub(super) const JOINS: &[(LineJoin, &str, &str)] = &[ (LineJoin::Bevel, "StrokeJoin.BEVELENDJOIN", "bevel"), (LineJoin::Round, "StrokeJoin.ROUNDENDJOIN", "round"), (LineJoin::Miter, "StrokeJoin.MITERENDJOIN", "miter"), @@ -856,21 +858,27 @@ fn path_dashes(h: &super::Host, a: &[Data]) -> Answer { Ok(Data::Array(this_look(h, a)?.1.dashes.into_iter().map(num).collect())) } -/// `strokeDashes = [lengths]`: at most [`MAX_DASHES`] finite lengths that are not negative and -/// not all 0; `[]` or `{}` gives a solid line. -fn path_set_dashes(h: &super::Host, a: &[Data]) -> Answer { - let lengths: Vec = match arg(a, 1) { +/// The dash and gap lengths a script assigned to `what`: at most [`MAX_DASHES`] finite lengths +/// that are not negative and not all 0; `[]` or `{}` gives a solid line. +pub(super) fn dash_lengths(d: &Data, what: &str) -> std::result::Result, HostError> { + let lengths: Vec = match d { Data::Object(o) if o.is_empty() => Vec::new(), - Data::Array(list) if list.len() > MAX_DASHES => return Err(HostError::Range(format!("strokeDashes takes at most {MAX_DASHES} lengths"))), + Data::Array(list) if list.len() > MAX_DASHES => return Err(HostError::Range(format!("{what} takes at most {MAX_DASHES} lengths"))), Data::Array(list) => list.iter().map(|d| number(d, "each dash length")).collect::>()?, - _ => return Err(HostError::Type("strokeDashes must be an array of lengths".into())), + _ => return Err(HostError::Type(format!("{what} must be an array of lengths"))), }; if lengths.iter().any(|l| !(0.0..=MAX_STROKE_WIDTH * 1000.0).contains(l)) { return Err(HostError::Range("each dash length must be from 0 to 1000000 points".into())); } if !lengths.is_empty() && lengths.iter().all(|l| *l == 0.0) { - return Err(HostError::Range("strokeDashes needs a length that is not 0".into())); + return Err(HostError::Range(format!("{what} needs a length that is not 0"))); } + Ok(lengths) +} + +/// `strokeDashes = [lengths]`, as [`dash_lengths`] takes them. +fn path_set_dashes(h: &super::Host, a: &[Data]) -> Answer { + let lengths = dash_lengths(arg(a, 1), "strokeDashes")?; let (item, look) = this_look(h, a)?; let dash = if lengths.is_empty() { Value::Null } else { json!(lengths) }; set_stroke_option(h, item, look.dashes == lengths, json!({"dash": dash})) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index a611da1857..6826625700 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -173,6 +173,7 @@ mod script_console; mod script_dialogs; mod script_dollar; mod script_dom; +mod script_dom_defaults; mod script_dom_paths; mod script_engines; mod script_folder; diff --git a/crates/engine/src/tests/newart.rs b/crates/engine/src/tests/newart.rs index 583a5f43d8..ef0f0c8b50 100644 --- a/crates/engine/src/tests/newart.rs +++ b/crates/engine/src/tests/newart.rs @@ -299,3 +299,72 @@ fn fill_line_gives_a_new_line_the_current_fill() { assert_ne!(s.paint.fill, Paint::None); assert!(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 1, "y2": 1, "fill": "yes"})).is_err()); } + +/// `appearance.setNewArt` sets what the next object gets while the selection keeps its own look. +#[test] +fn set_new_art_changes_the_next_object_and_not_the_selection() { + let mut s = session(); + let picked = rect(&mut s, 20.0); + run(&mut s, "select.set", json!({"ids": [picked.0]})); + let (look, undo, recent, active) = (node(&s, picked).appearance, undo_len(&s), s.recent_colors.clone(), s.fill_active); + let r = run( + &mut s, + "appearance.setNewArt", + json!({"fill": {"color": "#ff0000"}, "stroke": {"none": true}, "weight": 4, "cap": "round", "dash": [3, 1], "dashOffset": 1, "fillOverprint": true}), + ); + assert_eq!(r, json!({"changed": true})); + assert_eq!(node(&s, picked).appearance, look, "the selected art kept its look"); + assert_eq!(s.doc().unwrap().selection.objects, vec![picked]); + assert_eq!((undo_len(&s), &s.recent_colors, s.fill_active), (undo, &recent, active)); + run(&mut s, "select.none", json!({})); + let id = rect(&mut s, 200.0); + let ap = node(&s, id).appearance; + let (fill, st) = (ap.fill().unwrap(), ap.stroke().unwrap()); + assert_eq!(fill.paint, Paint::solid(vectorcraft_color::Color::rgb(1.0, 0.0, 0.0))); + assert!(fill.overprint); + assert_eq!((st.paint.clone(), st.width, st.cap), (Paint::None, 4.0, LineCap::Round)); + assert_eq!(st.dash, Some(Dash { pattern: vec![3.0, 1.0], offset: 1.0, ..Default::default() })); + // The same values again change nothing. + assert_eq!(run(&mut s, "appearance.setNewArt", json!({"weight": 4, "cap": "round"})), json!({"changed": false})); +} + +#[test] +fn set_new_art_refuses_bad_values_with_nothing_changed() { + let mut s = session(); + let before = s.paint.clone(); + for params in [ + json!({"weight": -1}), + json!({"weight": 1001}), + json!({"weight": "3"}), + json!({"miterLimit": 0.5}), + json!({"cap": "flat"}), + json!({"join": 2}), + json!({"dash": [0, 0]}), + json!({"dash": [-1]}), + json!({"dash": "4 2"}), + json!({"dashOffset": 2}), + json!({"fill": "#ff0000"}), + json!({"fill": {}}), + json!({"fill": {"color": "#ff0000"}, "weight": -1}), + json!({"stroke": {"tint": 50, "color": "#000000"}}), + json!({"fillOverprint": "yes"}), + json!({"widht": 3}), + ] { + assert!(s.execute("appearance.setNewArt", ¶ms).is_err(), "accepted {params}"); + assert_eq!(s.paint, before, "changed new art for {params}"); + } +} + +#[test] +fn set_new_art_refuses_while_new_art_takes_the_selected_look() { + let mut s = session(); + let picked = rect(&mut s, 20.0); + run(&mut s, "appearance.setNewArtBasic", json!({"on": false})); + run(&mut s, "select.set", json!({"ids": [picked.0]})); + let before = s.paint.clone(); + assert!(s.execute("appearance.setNewArt", &json!({"weight": 7})).is_err()); + assert_eq!(s.paint, before); + run(&mut s, "select.none", json!({})); + assert_eq!(run(&mut s, "appearance.setNewArt", json!({"weight": 7})), json!({"changed": true})); + assert_eq!(s.new_art().stroke().unwrap().width, 7.0); +} diff --git a/crates/engine/src/tests/script_dom_defaults.rs b/crates/engine/src/tests/script_dom_defaults.rs new file mode 100644 index 0000000000..cc6c53eb4e --- /dev/null +++ b/crates/engine/src/tests/script_dom_defaults.rs @@ -0,0 +1,144 @@ +//! The script object model's document defaults for new art and `scaleFactor`. + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::LineCap; + +use crate::*; + +fn run(s: &mut Session, source: &str) -> Result { + s.execute("script.run", &json!({"source": source, "name": "t.js"})) +} + +/// What the run logged. +fn log(s: &mut Session, source: &str) -> Vec { + let r = run(s, source).unwrap_or_else(|e| panic!("{source}: {e}")); + r["log"].as_array().cloned().unwrap_or_default() +} + +/// A 400 × 300 pt document with one rectangle, selected. +fn doc() -> (Session, NodeId) { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let r = s.execute("shape.rectangle", &json!({"x": 10, "y": 20, "width": 30, "height": 40})).unwrap(); + let id = NodeId(r["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + (s, id) +} + +fn undo_steps(s: &Session) -> usize { + s.active().unwrap().history.undo.len() +} + +fn node(s: &Session, id: NodeId) -> crate::doc::Node { + s.active().unwrap().doc.node(id).unwrap().clone() +} + +#[test] +fn a_wider_default_stroke_goes_to_the_next_path_drawn() { + let (mut s, picked) = doc(); + let (look, steps) = (node(&s, picked).appearance, undo_steps(&s)); + let r = run(&mut s, "var d = app.activeDocument; var w = d.defaultStrokeWidth; d.defaultStrokeWidth += 1; vc.log(d.defaultStrokeWidth > w);") + .unwrap(); + assert_eq!(r["log"], json!([true])); + assert_eq!(undo_steps(&s), steps, "a default alone is no undo step"); + assert_eq!(node(&s, picked).appearance, look, "the selected path kept its stroke"); + let wider = s.new_art().stroke().unwrap().width; + let out = log(&mut s, "var p = app.activeDocument.pathItems.rectangle(200, 100, 50, 50); vc.log(p.strokeWidth);"); + assert_eq!(out.iter().map(Value::as_f64).collect::>(), vec![Some(wider)]); + assert!(wider > 1.0); +} + +#[test] +fn a_bad_default_throws_and_changes_nothing() { + let (mut s, _) = doc(); + let before = s.paint.clone(); + for (source, name) in [ + ("app.activeDocument.defaultStrokeWidth = -1", "RangeError"), + ("app.activeDocument.defaultStrokeWidth = 1001", "RangeError"), + ("app.activeDocument.defaultStrokeWidth = 'wide'", "TypeError"), + ("app.activeDocument.defaultStrokeMiterLimit = 0", "RangeError"), + ("app.activeDocument.defaultStrokeCap = 'round'", "TypeError"), + ("app.activeDocument.defaultStrokeJoin = 1", "TypeError"), + ("app.activeDocument.defaultStrokeDashes = [0, 0]", "RangeError"), + ("app.activeDocument.defaultStrokeDashes = '4 2'", "TypeError"), + ("app.activeDocument.defaultStrokeDashOffset = 3", "Error"), + ("app.activeDocument.defaultFillColor = 5", "TypeError"), + ("var c = new RGBColor(); c.red = 300; app.activeDocument.defaultStrokeColor = c", "RangeError"), + ("app.activeDocument.defaultFilled = 1", "TypeError"), + ("app.activeDocument.defaultStrokeOverprint = 'yes'", "TypeError"), + ] { + let out = log(&mut s, &format!("try {{ {source}; vc.log('ran'); }} catch (e) {{ vc.log(e.name); }}")); + assert_eq!(out, vec![json!(name)], "{source}"); + assert_eq!(s.paint, before, "{source} changed new art"); + } +} + +#[test] +fn default_colors_and_flags_read_back_and_paint_the_next_path() { + let (mut s, picked) = doc(); + let look = node(&s, picked).appearance; + let out = log( + &mut s, + "var d = app.activeDocument, c = new RGBColor(); c.red = 255;\ + d.defaultFillColor = c; vc.log(d.defaultFillColor.typename); vc.log(d.defaultFillColor.red); vc.log(d.defaultFilled);\ + d.defaultStroked = false; vc.log(d.defaultStroked); vc.log(d.defaultStrokeColor.typename);\ + d.defaultStrokeColor = new GrayColor(); vc.log(d.defaultStroked);\ + d.defaultFillColor = new NoColor(); vc.log(d.defaultFilled); d.defaultFilled = true; vc.log(d.defaultFilled);\ + d.defaultFillColor = c;", + ); + assert_eq!(out, vec![json!("RGBColor"), json!(255), json!(true), json!(false), json!("NoColor"), json!(true), json!(false), json!(true)]); + assert_eq!(node(&s, picked).appearance, look); + let id = NodeId(s.execute("shape.rectangle", &json!({"x": 200, "y": 20, "width": 30, "height": 40})).unwrap()["id"].as_u64().unwrap()); + let ap = node(&s, id).appearance; + assert_eq!(ap.fill_paint(), Paint::solid(Color::rgb(1.0, 0.0, 0.0))); + assert!(!ap.stroke_paint().is_none()); +} + +#[test] +fn default_stroke_options_read_back_and_a_same_value_runs_no_command() { + let (mut s, _) = doc(); + let out = log( + &mut s, + "var d = app.activeDocument; d.defaultStrokeCap = StrokeCap.ROUNDENDCAP; d.defaultStrokeJoin = StrokeJoin.BEVELENDJOIN;\ + d.defaultStrokeMiterLimit = 7; d.defaultStrokeDashes = [6, 2]; d.defaultStrokeDashOffset = 1;\ + d.defaultStrokeOverprint = true; d.defaultFillOverprint = true;\ + vc.log([d.defaultStrokeCap, d.defaultStrokeJoin, d.defaultStrokeMiterLimit, d.defaultStrokeDashes, d.defaultStrokeDashOffset,\ + d.defaultStrokeOverprint, d.defaultFillOverprint]);", + ); + assert_eq!(out, vec![json!(["StrokeCap.ROUNDENDCAP", "StrokeJoin.BEVELENDJOIN", 7, [6, 2], 1, true, true])]); + let st = s.new_art().stroke().unwrap().clone(); + assert_eq!((st.cap, st.miter_limit, st.overprint), (LineCap::Round, 7.0, true)); + let r = run( + &mut s, + "var d = app.activeDocument; d.defaultStrokeCap = StrokeCap.ROUNDENDCAP; d.defaultStrokeMiterLimit = 7;\ + d.defaultStrokeDashes = [6, 2]; d.defaultStrokeOverprint = true; d.defaultStrokeWidth = d.defaultStrokeWidth;\ + d.defaultFillColor = d.defaultFillColor;", + ) + .unwrap(); + assert_eq!(r["slowestCommands"], json!([]), "the same values run no command"); + // `{}` and `[]` give a solid line. + assert_eq!(log(&mut s, "var d = app.activeDocument; d.defaultStrokeDashes = {}; vc.log(d.defaultStrokeDashes.length);"), vec![json!(0)]); +} + +#[test] +fn scale_factor_is_one_and_read_only() { + let (mut s, _) = doc(); + let out = log(&mut s, "var d = app.activeDocument; vc.log(d.scaleFactor); d.scaleFactor = 4; vc.log(d.scaleFactor);"); + assert_eq!(out, vec![json!(1), json!(1)]); +} + +#[test] +fn defaults_refuse_while_new_art_takes_the_selected_look() { + let (mut s, _) = doc(); + s.execute("appearance.setNewArtBasic", &json!({"on": false})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + s.execute("select.all", &json!({})).unwrap(); + let before = s.paint.clone(); + let out = log( + &mut s, + "try { app.activeDocument.defaultStrokeWidth = 9; } catch (e) { vc.log(e.message.indexOf('New Art Has Basic Appearance') >= 0); }", + ); + assert_eq!(out, vec![json!(true)]); + assert_eq!(s.paint, before); +} diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 24417b2c21..3c67918b7e 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -97,9 +97,14 @@ const INSIDE: &[(&str, &str)] = &[ ("Document.", "prototype"), ( "Document.prototype.", - "activeLayer activeLayer= artboards artboards= close close= constructor convertCoordinate documentColorSpace \ + "activeLayer activeLayer= artboards artboards= close close= constructor convertCoordinate defaultFillColor \ + defaultFillColor= defaultFillOverprint defaultFillOverprint= defaultFilled defaultFilled= defaultStrokeCap \ + defaultStrokeCap= defaultStrokeColor defaultStrokeColor= defaultStrokeDashOffset defaultStrokeDashOffset= \ + defaultStrokeDashes defaultStrokeDashes= defaultStrokeJoin defaultStrokeJoin= defaultStrokeMiterLimit \ + defaultStrokeMiterLimit= defaultStrokeOverprint defaultStrokeOverprint= defaultStrokeWidth defaultStrokeWidth= \ + defaultStroked defaultStroked= documentColorSpace \ groupItems groupItems= height layers layers= name pageItems parent pathItems rulerOrigin rulerOrigin= \ - rulerUnits saveAs saveAs= selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ + rulerUnits saveAs saveAs= scaleFactor selection selection= swatches swatches= symbols symbols= textFrames textFrames= typename \ views views= width", ), ("Layer.", "prototype"), diff --git a/docs/mcp.md b/docs/mcp.md index e3d4e634ed..ee0e5b2372 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2749,7 +2749,22 @@ app through the global object `vc`, and writes to the Script Console and runs ot changed. A path in a compound path or compound shape reads the fill, stroke and overprint of that compound path or shape, which the paint commands paint in its place. A change to a path's paint or stroke leaves the paint for new art, the active Fill or Stroke proxy and Recent Colors as they were. `selectedPathPoints`, `PathPoint.selected`, - `transform`, `polarity`, the gradient stops and the document's default paint are not available yet. + `transform`, `polarity` and the gradient stops are not available yet. +- A `Document`'s default paint members (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) read and set what + the next object drawn gets, as `appearance.newArt` reports it, the same for every open document: `defaultFillColor`, + `defaultFilled`, `defaultFillOverprint`, `defaultStrokeColor`, `defaultStroked`, `defaultStrokeOverprint`, + `defaultStrokeWidth`, `defaultStrokeCap`, `defaultStrokeJoin`, `defaultStrokeMiterLimit`, `defaultStrokeDashes` + (`[]` or `{}` for a solid line) and `defaultStrokeDashOffset`. Assigning one runs `appearance.setNewArt`, which + leaves the selection, its art, the active Fill or Stroke proxy and Recent Colors as they were and adds no undo step. + A value that changes nothing runs no command, and a bad value throws an error with nothing changed. VectorCraft's + own rules: assigning a color also makes `defaultFilled` or `defaultStroked` true, and a `NoColor` makes it false; + `defaultFilled` or `defaultStroked` set to true with no fill or stroke gives black; an RGB color is stored in the + front document's color mode, as `paint.setFill` stores it; `defaultStrokeWidth` is 0 to 1000 points, a dash or gap 0 + to 1,000,000 points (at most 64, not all 0), and `defaultStrokeDashOffset` -1,000,000 to 1,000,000 points, which + needs a dash pattern unless it is 0; while New Art Has Basic Appearance is off and an object is selected, assigning + a default throws an error, since new art then takes that object's appearance. `scaleFactor` + (https://www.indesignjs.de/indesignapi/illustrator/illustrator.d.ts lists it as read-only) is always 1, since + VectorCraft draws every document at its own size; after an assignment it still reads 1. - `$.write(...values)` writes the values to the Script Console with no separator, each as `String(value)` gives it, and `$.writeln(...values)` does the same and ends the line. Each call counts as a host call. - `$.evalFile(path, timeout?)` runs the file `path` names, relative to the file being run, in the same global @@ -8810,6 +8825,12 @@ colorized) changes nothing. With the option off (`appearance.setNewArtBasic {on: whole appearance of the last selected object. `appearance.newArt` reports what the next object gets; `paint.default` resets it. `appearance.setNewArtBasic` rejects an `on` value that is not a boolean. Omitting `on` toggles the current preference. +`appearance.setNewArt {fill?, stroke?, weight?, cap?, join?, miterLimit?, dash?, dashOffset?, fillOverprint?, +strokeOverprint?}` sets new art's fill, stroke and stroke options whatever is selected, and leaves the selection, its +art, the active proxy and Recent Colors as they were. `fill` and `stroke` take a paint as `paint.setFill` does; a +stroke painted on new art without one gets a 1 pt weight unless `weight` is given. Every value is checked before +anything changes, and any change while New Art Has Basic Appearance is off and an object is selected is an error. It +returns `{changed}`, false when the next object would look the same. ```json {"name":"run_command","arguments":{"command":"select.none","params":{}}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 72ed713051..56b8b1d8fd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1025,7 +1025,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Layers, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops and the document's default paint are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: a document's `default*` members (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) read and set the fill, stroke and stroke options of the next object drawn through `appearance.setNewArt`, leaving the selection and its art as they were, and `scaleFactor` reads 1 (`docs/mcp.md`). `crates/engine/src/tests/script_dom_defaults.rs`. - Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`. - Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`. - Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`. From 9c12aceb6966474b23fbfbf05a02cf2f35df0cf1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 13:20:46 -0800 Subject: [PATCH 029/264] Scripts: format the merged object class list in heap.rs --- crates/js/src/heap.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/js/src/heap.rs b/crates/js/src/heap.rs index b7b0dd4a63..64f16c12a2 100644 --- a/crates/js/src/heap.rs +++ b/crates/js/src/heap.rs @@ -337,13 +337,9 @@ impl Class { Class::XmlFilter(_) => "Object", Class::Math => "Math", Class::Json => "JSON", - Class::Ordinary - | Class::ForIn(_) - | Class::Host(_) - | Class::FsEntry(_) - | Class::Symbol(_) - | Class::Iterator(_) - | Class::IterRecord(_) => "Object", + Class::Ordinary | Class::ForIn(_) | Class::Host(_) | Class::FsEntry(_) | Class::Symbol(_) | Class::Iterator(_) | Class::IterRecord(_) => { + "Object" + } Class::Array { .. } => "Array", Class::Function(_) => "Function", Class::Error(_) => "Error", From f5afa0b84a470580fc7d81aed2ec6bc5042d08cf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 10:06:44 -0800 Subject: [PATCH 030/264] Scripts: review fixes for the document defaults and the object model - appearance.setNewArt is listed among the commands a plug-in may call, so every_command_is_reviewed passes. - appearance.setNewArt refuses `tint` on a pattern that has no swatch entry, and its help and docs/mcp.md say an omitted `weight` keeps the stored weight. - The dash checks of appearance.setNewArt, strokeDashes and defaultStrokeDashes share one helper. - defaultStrokeWidth, defaultStrokeMiterLimit and defaultStrokeDashOffset compare exactly, so a slightly different value reaches new art. - An RGB default in a CMYK document is compared in the document's color mode, and a color read back from a path or a default (a Gray too small for its value to name) assigns back without a command. - addDocument starts from the profile's built-in first preset even when a saved preset has the same name. - A saved preset's rows are read as at most 1000. - The page item and path lists are kept for each open document, the selection list stops at its limit, the typename of a removed PathPoint and of a stale PathPoints or PathItems throws, and an item edit whose selection cannot be restored is undone with it. - A path's subpath starts are counted once and kept while its points keep their layout, so reading or setting each of its points in turn no longer walks every subpath for each point. - A run that ended while waiting for a growth answer is checked against its allowance again before it is kept. - docs/mcp.md says which file limits apply to reading a profile's file. --- crates/engine/src/cmd/newart.rs | 48 ++++- crates/engine/src/cmd/newdoc.rs | 11 +- crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/src/script/dom.rs | 88 +++++++-- crates/engine/src/script/dom/colors.rs | 18 ++ crates/engine/src/script/dom/defaults.rs | 12 +- crates/engine/src/script/dom/paths.rs | 178 ++++++++++++++---- crates/engine/src/script/mod.rs | 11 ++ crates/engine/src/tests/newart.rs | 15 ++ crates/engine/src/tests/newdoc.rs | 8 + crates/engine/src/tests/script_dom.rs | 14 +- .../engine/src/tests/script_dom_defaults.rs | 35 +++- crates/engine/src/tests/script_dom_paths.rs | 66 ++++++- docs/mcp.md | 9 +- 14 files changed, 425 insertions(+), 89 deletions(-) diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index a2c117a1ee..96e8ffcb4a 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -63,7 +63,7 @@ pub fn specs() -> Vec { "Set New Art Appearance", [], None, - "{fill?: {color?, none?, swatch?, tint?, gradient?, keepModel?} (a paint as paint.setFill takes it), stroke?: (a paint, as fill), weight?: 0..1000 pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?: 1..500, dash?: [lengths, each 0..1000000 pt, at most 64, not all 0]|null (null: a solid line), dashOffset?: -1000000..1000000 pt (with a dash pattern), fillOverprint?: bool, strokeOverprint?: bool} set the fill, stroke and stroke options the next object drawn gets, whatever is selected: the selection and its art, the active proxy and the recent colors stay as they are. A stroke painted on new art without one gets a 1 pt weight unless `weight` is given. A bad value is an error with nothing changed, and so is any change while New Art Has Basic Appearance is off and an object is selected (new art takes that object's appearance then) → {changed: whether the next object drawn looks different}", + "{fill?: {color?, none?, swatch?, tint?, gradient?, keepModel?} (a paint as paint.setFill takes it), stroke?: (a paint, as fill), weight?: 0..1000 pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?: 1..500, dash?: [lengths, each 0..1000000 pt, at most 64, not all 0]|null (null: a solid line), dashOffset?: -1000000..1000000 pt (with a dash pattern), fillOverprint?: bool, strokeOverprint?: bool} set the fill, stroke and stroke options the next object drawn gets, whatever is selected: the selection and its art, the active proxy and the recent colors stay as they are. Without `weight` the stored stroke weight stays; a stroke painted on new art without one gets 1 pt only when that stored weight is 0. A bad value is an error with nothing changed, and so is any change while New Art Has Basic Appearance is off and an object is selected (new art takes that object's appearance then) → {changed: whether the next object drawn looks different}", always, set_new_art ), @@ -75,6 +75,38 @@ const MAX_DASHES: usize = 64; /// The largest dash, gap or dash offset `appearance.setNewArt` takes, in points. const MAX_DASH_LENGTH: f64 = 1_000_000.0; +/// What [`dash_fault`] finds wrong with a list of dash and gap lengths. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) enum DashFault { + /// More than [`MAX_DASHES`] lengths. + TooMany, + /// A length that is not a number from 0 to [`MAX_DASH_LENGTH`]. + OutOfRange, + /// Lengths that are all 0. + AllZero, +} + +/// What is wrong with the dash and gap lengths `lengths`, which `appearance.setNewArt` and the +/// scripts' `strokeDashes` and `defaultStrokeDashes` check the same way; `None` when they are good. +/// An empty list (a solid line) is good. +pub(crate) fn dash_fault(lengths: &[f64]) -> Option { + if lengths.len() > MAX_DASHES { + Some(DashFault::TooMany) + } else if !lengths.iter().all(|n| n.is_finite() && (0.0..=MAX_DASH_LENGTH).contains(n)) { + Some(DashFault::OutOfRange) + } else if !lengths.is_empty() && lengths.iter().all(|n| *n == 0.0) { + Some(DashFault::AllZero) + } else { + None + } +} + +/// `c` as `appearance.setNewArt` stores it without `keepModel`: an RGB color in the color mode of +/// the document in front. +pub(crate) fn stored_color(s: &Session, c: vectorcraft_color::Color) -> vectorcraft_color::Color { + super::paint::new_color(s, &json!({}), c) +} + /// `appearance.setNewArt`: new art's fill, stroke and stroke options, every value checked before /// anything changes. fn set_new_art(s: &mut Session, p: &Value) -> Result { @@ -84,7 +116,8 @@ fn set_new_art(s: &mut Session, p: &Value) -> Result { if !v.is_object() { return Err(bad(C, format!("{key} must be a paint object (color, none, swatch or gradient), got {v}"))); } - if v.get("tint").is_some() && v.get("swatch").is_none() { + let pattern_only = |name: &str| s.doc().is_ok_and(|st| st.doc.swatch(name).is_none() && st.doc.pattern(name).is_some()); + if v.get("tint").is_some() && v.get("swatch").and_then(Value::as_str).is_none_or(pattern_only) { return Err(bad(C, format!("{key}: `tint` goes with a global or spot `swatch`"))); } let given = super::paint::paint_from(s, v)?.ok_or_else(|| bad(C, format!("{key}: give color, none, swatch or gradient")))?; @@ -113,11 +146,12 @@ fn set_new_art(s: &mut Session, p: &Value) -> Result { None | Some(Value::Null) => {} Some(Value::Array(a)) if a.len() > MAX_DASHES => return Err(bad(C, format!("dash takes at most {MAX_DASHES} lengths"))), Some(Value::Array(a)) => { - if !a.iter().all(|v| v.as_f64().is_some_and(|n| n.is_finite() && (0.0..=MAX_DASH_LENGTH).contains(&n))) { - return Err(bad(C, format!("each dash length must be a number from 0 to {MAX_DASH_LENGTH}"))); - } - if !a.is_empty() && a.iter().all(|v| v.as_f64() == Some(0.0)) { - return Err(bad(C, "dash needs a length that is not 0")); + let lengths: Option> = a.iter().map(Value::as_f64).collect(); + match lengths.map_or(Some(DashFault::OutOfRange), |l| dash_fault(&l)) { + None => {} + Some(DashFault::TooMany) => return Err(bad(C, format!("dash takes at most {MAX_DASHES} lengths"))), + Some(DashFault::OutOfRange) => return Err(bad(C, format!("each dash length must be a number from 0 to {MAX_DASH_LENGTH}"))), + Some(DashFault::AllZero) => return Err(bad(C, "dash needs a length that is not 0")), } } Some(v) => return Err(bad(C, format!("dash must be a list of lengths or null, got {v}"))), diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index 1efa443bd5..b628fbbf0e 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -171,8 +171,9 @@ pub struct DocSettings { pub layout: ArtboardLayout, /// Columns of a grid layout. pub columns: u32, - /// Rows of a grid by column, in place of `columns` when more than 0. - #[serde(skip_serializing_if = "is_zero")] + /// Rows of a grid by column, in place of `columns` when more than 0, up to `MAX_ARTBOARDS` (a + /// saved or Recent preset's larger value is read as `MAX_ARTBOARDS`). + #[serde(skip_serializing_if = "is_zero", deserialize_with = "de_rows")] pub rows: u32, /// Space between artboards, points: 0 to `MAX_SPACING` (a saved or Recent preset's value /// outside that range is read as the nearer end). @@ -594,6 +595,12 @@ fn de_artboards<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result>(d: D) -> std::result::Result { + Ok(u32::deserialize(d)?.min(MAX_ARTBOARDS)) +} + /// A saved or Recent preset's artboard spacing, kept to 0 to [`MAX_SPACING`] points. fn de_spacing<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result { Ok(f64::deserialize(d)?.clamp(0.0, MAX_SPACING)) diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index ec7d3ac989..083647fed4 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -103,6 +103,7 @@ pub(super) const ALLOWED: &[&str] = &[ "appearance.removeItem", "appearance.setActiveItem", "appearance.setItem", + "appearance.setNewArt", "appearance.showAllHidden", "appearance.targetContents", "appearance.transfer", diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 8cc774bd92..5acf370734 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -96,12 +96,15 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM"; #[derive(Default)] pub(super) struct State { coords: Cell, - items: RefCell>, - /// The last list of a document's paths ([`paths`]), kept while that document is unchanged. - paths: RefCell>, + items: RefCell>, + /// The last list of each document's paths ([`paths`]), kept while that document is unchanged. + paths: RefCell>, /// A path and its subpaths with the point changes the run has made to it and not written yet /// ([`flush`]). pending: RefCell)>>, + /// The index of the first point of each subpath of the path whose points the run read last, + /// and what they were counted from ([`paths`]). + point_starts: RefCell>)>>, /// How many times the points the run read of each path went stale, by document uid and path id /// ([`paths`]). point_cuts: RefCell>, @@ -148,6 +151,24 @@ fn atomically(h: &Host, f: impl FnOnce(&Host) -> std::result::Result, Rc>); +/// The most documents whose lists [`State`] keeps at once, the least recently listed going first. +const KEPT_LISTS: usize = 8; + +/// The list kept in `lists` for the document `st`, while that document is unchanged. +fn kept_list(lists: &RefCell>, st: &DocState) -> Option>> { + lists.borrow().iter().find(|(uid, doc, _)| *uid == st.uid && Arc::ptr_eq(doc, &st.doc)).map(|(_, _, ids)| ids.clone()) +} + +/// Keeps `ids` in `lists` as the list of the document `st`, in place of the one it had. +fn keep_list(lists: &RefCell>, st: &DocState, ids: &Rc>) { + let mut l = lists.borrow_mut(); + l.retain(|(uid, ..)| *uid != st.uid); + if l.len() >= KEPT_LISTS { + l.remove(0); + } + l.push((st.uid, st.doc.clone(), ids.clone())); +} + type Answer = std::result::Result; /// A member function: the run's host and the call's arguments, `this` first. @@ -396,13 +417,11 @@ fn item_ref(h: &Host, st: &DocState, id: NodeId) -> Data { } } -/// The ids of a document's page items in paint order ([`State`] keeps the last list). +/// The ids of a document's page items in paint order ([`State`] keeps the last list of each +/// document). fn page_items(h: &Host, st: &DocState) -> Rc> { - if let Some((uid, doc, ids)) = &*h.dom.items.borrow() - && *uid == st.uid - && Arc::ptr_eq(doc, &st.doc) - { - return ids.clone(); + if let Some(ids) = kept_list(&h.dom.items, st) { + return ids; } fn walk(nodes: &[Arc], out: &mut Vec) { for n in nodes { @@ -420,7 +439,7 @@ fn page_items(h: &Host, st: &DocState) -> Rc> { let mut ids = Vec::new(); walk(&st.doc.layers, &mut ids); let ids = Rc::new(ids); - *h.dom.items.borrow_mut() = Some((st.uid, st.doc.clone(), ids.clone())); + keep_list(&h.dom.items, st, &ids); ids } @@ -639,12 +658,13 @@ fn on_doc( Ok(v) } -/// Runs `id` with `params` on the item's document, its selection kept. The points the run read of -/// the item's paths stay valid through the change ([`paths::see_all_points`]). +/// Runs `id` with `params` on the item's document, its selection kept, as one change: when the +/// selection cannot be put back, the edit is undone too. The points the run read of the item's +/// paths stay valid through the change ([`paths::see_all_points`]). fn edit_item(h: &Host, item: Item, id: &str, params: &Value) -> std::result::Result { paths::see_all_points(h); let kept = h.dom.editing.replace(Some(item)); - let r = on_doc(h, item.doc.uid, true, |h| command(h, id, params)); + let r = atomically(h, |h| on_doc(h, item.doc.uid, true, |h| command(h, id, params))); h.dom.editing.set(kept); r } @@ -934,6 +954,22 @@ fn startup_preset(name: &str) -> Option<(Option<&'static str>, Option<&'static s }) } +/// The `file.newPresets` fields `addDocument` gives `file.new`: those of the profile's first +/// built-in preset with `presetSettings` over them. +const BUILT_IN_SETTINGS: &[&str] = &[ + "width", + "height", + "units", + "artboards", + "artboardLayout", + "bleed", + "backgroundContents", + "colorMode", + "rasterEffectsPpi", + "previewMode", + "alignNewObjectsToPixelGrid", +]; + /// `documents.addDocument(startupPreset, presetSettings?, showOptionsDialog?)`: a new document from /// the New Document profile `startupPreset` names, with the settings `presetSettings` gives in /// place of the profile's. @@ -977,15 +1013,26 @@ fn docs_add_document(h: &Host, a: &[Data]) -> Answer { Some(Data::Bool(true)) => return Err(HostError::Error(DIALOG_UNAVAILABLE.into())), Some(_) => return Err(HostError::Type("showOptionsDialog must be true or false".into())), } - // The document starts from the first preset of the profile's category (Print: Letter). - let first = profile.and_then(|n| crate::cmd::newdoc::category(&h.session.borrow(), n)?.into_iter().next()); - if let Some(first) = first { - p.insert("preset".into(), json!(first.name)); - } - p.insert("profile".into(), profile.map_or(Value::Null, |n| json!(n))); if let Some(m) = mode { p.entry("colorMode").or_insert_with(|| json!(m)); } + // The document starts from the first built-in preset of the profile's category (Print: + // Letter) with `presetSettings` over it, given in full so that a saved preset of the same name + // does not stand in for it. Settings `file.new` refuses are left for it to report. + let first = profile.and_then(|n| crate::cmd::newdoc::category(&h.session.borrow(), n)?.into_iter().next()); + if let Some(first) = first { + p.insert("preset".into(), json!(first.name)); + if let Ok(full) = first.with_params(&Value::Object(p.clone()), "file.new") + && let Value::Object(settings) = full.to_json() + { + for key in BUILT_IN_SETTINGS { + if let Some(v) = settings.get(*key) { + p.insert((*key).into(), v.clone()); + } + } + } + } + p.insert("profile".into(), profile.map_or(Value::Null, |n| json!(n))); // A profile whose file could not be read throws, and the document `file.new` made with the // defaults is put back, with the Recent sizes as they were. atomically(h, |h| { @@ -1193,7 +1240,8 @@ fn doc_selection(h: &Host, a: &[Data]) -> Answer { fn selection_of(h: &Host, uid: u64) -> Answer { let s = h.session.borrow(); let st = s.documents().iter().find(|d| d.uid == uid).ok_or_else(|| HostError::Error(STALE_DOCUMENT.into()))?; - let ids: Vec = st.selection.objects.iter().copied().filter(|i| st.doc.node(*i).and_then(typename).is_some()).collect(); + let ids: Vec = + st.selection.objects.iter().copied().filter(|i| st.doc.node(*i).and_then(typename).is_some()).take(MAX_LISTED + 1).collect(); if ids.is_empty() { return Ok(Data::Null); } diff --git a/crates/engine/src/script/dom/colors.rs b/crates/engine/src/script/dom/colors.rs index 34c1496054..41726c938f 100644 --- a/crates/engine/src/script/dom/colors.rs +++ b/crates/engine/src/script/dom/colors.rs @@ -90,6 +90,24 @@ pub(super) fn of_paint(paint: &Paint) -> Data { } } +/// Whether assigning the color object `d`, read as `assigned`, leaves the paint `now` as it is: a +/// `NoColor` on no paint, or on an unlinked color either a color equal to it once `store` makes +/// it what the document stores, or the components reading `now` gives (a Gray value read back can +/// stand for an ink amount that no Gray value names exactly). +pub(super) fn unchanged(d: &Data, assigned: Option, now: &Paint, store: impl FnOnce(Color) -> Color) -> bool { + match (assigned, now) { + (None, Paint::None) => true, + (Some(c), Paint::Solid { color, swatch: None, .. }) => store(c) == *color || shows(d, &of_color(color)), + _ => false, + } +} + +/// Whether the color object `d` has the class and every component of `shown`. +fn shows(d: &Data, shown: &Data) -> bool { + let (Data::Object(a), Data::Object(b)) = (d, shown) else { return false }; + b.iter().all(|(k, v)| a.iter().any(|(n, w)| n == k && w == v)) +} + /// The component `key` of color object `o`, from `min` to `max` (0 when it is left out). fn component(o: &[(String, Data)], class: &str, key: &str, min: f64, max: f64) -> std::result::Result { match o.iter().find(|(k, _)| k == key).map(|(_, v)| v) { diff --git a/crates/engine/src/script/dom/defaults.rs b/crates/engine/src/script/dom/defaults.rs index fe8eb5c3f3..861c5acbd1 100644 --- a/crates/engine/src/script/dom/defaults.rs +++ b/crates/engine/src/script/dom/defaults.rs @@ -55,11 +55,7 @@ fn set_default_color(h: &Host, a: &[Data], fill: bool) -> Answer { let what = if fill { "defaultFillColor" } else { "defaultStrokeColor" }; let color = colors::assigned(arg(a, 1), what)?; let now = top_paint(&new_art(h, a)?, fill); - let same = match (&color, &now) { - (None, Paint::None) => true, - (Some(c), Paint::Solid { color, swatch: None, .. }) => c == color, - _ => false, - }; + let same = colors::unchanged(arg(a, 1), color, &now, |c| crate::cmd::newart::stored_color(&h.session.borrow(), c)); let paint = match color { Some(c) => json!({"color": colors::param(&c)}), None => json!({"none": true}), @@ -109,7 +105,7 @@ fn set_default_stroke_width(h: &Host, a: &[Data]) -> Answer { } this_doc(h, a)?; let now = h.session.borrow().paint.stroke_width; - set(h, (now - w).abs() < 1e-9, json!({"weight": w})) + set(h, now == w, json!({"weight": w})) } fn default_cap(h: &Host, a: &[Data]) -> Answer { @@ -152,7 +148,7 @@ fn set_default_miter(h: &Host, a: &[Data]) -> Answer { return Err(HostError::Range("defaultStrokeMiterLimit must be from 1 to 500".into())); } let now = stroke_option(h, a, 10.0, |s| s.miter_limit)?; - set(h, (now - v).abs() < 1e-9, json!({"miterLimit": v})) + set(h, now == v, json!({"miterLimit": v})) } fn dashes(h: &Host, a: &[Data]) -> std::result::Result, HostError> { @@ -183,7 +179,7 @@ fn set_default_dash_offset(h: &Host, a: &[Data]) -> Answer { return Err(HostError::Error("defaultStrokeDashOffset needs defaultStrokeDashes first".into())); } let now = stroke_option(h, a, 0.0, |s| s.dash.as_ref().map_or(0.0, |d| d.offset))?; - set(h, (now - v).abs() < 1e-9, json!({"dashOffset": v})) + set(h, now == v, json!({"dashOffset": v})) } fn scale_factor(h: &Host, a: &[Data]) -> Answer { diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 2b0419234f..d3faca29a3 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -69,7 +69,7 @@ use vectorcraft_tools::params::gradient_params; use super::{ Answer, Coords, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, coordinate, doc_of, edit_item, editable, find_doc, float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, point, point_get, - point_method, point_property, property, this_doc, typename_of, whole, with_doc, + point_method, point_property, property, this_doc, whole, with_doc, }; use crate::{DocState, NodeId, NodeKind}; @@ -140,9 +140,63 @@ fn path_ref(h: &super::Host, item: Item) -> Data { host_ref("PathItem", &[float(h.run), float(item.doc.uid), high, low]) } -/// How many points a path with the subpaths `subs` has. -fn point_count(subs: &[SubPath]) -> usize { - subs.iter().map(|sp| sp.anchors.len()).sum() +/// The index of the first point of each subpath of `subs`, followed by the number of points. +fn starts(subs: &[SubPath]) -> Vec { + let mut out = Vec::with_capacity(subs.len() + 1); + let mut n = 0; + for sp in subs { + out.push(n); + n += sp.anchors.len(); + } + out.push(n); + out +} + +/// The subpath and the place in it of point `i`, given the [`starts`] of a path's subpaths. +fn locate_at(starts: &[usize], i: usize) -> Option<(usize, usize)> { + if i >= *starts.last()? { + return None; + } + let s = starts.partition_point(|first| *first <= i).checked_sub(1)?; + Some((s, i - starts.get(s)?)) +} + +/// What the [`starts`] that [`super::State`] keeps were counted from: a path's node as its document +/// holds it, by document uid, or the waiting point changes of a path ([`edit_points`]). +pub(super) enum Counted { + Node(u64, Arc), + Waiting(Item), +} + +/// The [`starts`] of the path of `item`, its waiting point changes included. They are kept while +/// the path's node is the same one, or until the waiting changes add or remove points. +fn point_starts(h: &super::Host, item: Item) -> std::result::Result>, HostError> { + let waiting = matches!(&*h.dom.pending.borrow(), Some((w, _)) if same_path(*w, item)); + if waiting { + if let Some((Counted::Waiting(k), kept)) = &*h.dom.point_starts.borrow() + && same_path(*k, item) + { + return Ok(kept.clone()); + } + let counted = Rc::new(read_points(h, item, starts)?); + *h.dom.point_starts.borrow_mut() = Some((Counted::Waiting(item), counted.clone())); + return Ok(counted); + } + let node = with_doc(h, item.doc, |_, st| node_arc(&st.doc, item.id).cloned()).ok_or_else(|| HostError::Error(STALE_ITEM.into()))?; + if let Some((Counted::Node(uid, kept_node), kept)) = &*h.dom.point_starts.borrow() + && *uid == item.doc.uid + && Arc::ptr_eq(kept_node, &node) + { + return Ok(kept.clone()); + } + let counted = Rc::new(starts(&node.path_data().ok_or_else(|| HostError::Type("this is not a PathItem".into()))?.subpaths)); + *h.dom.point_starts.borrow_mut() = Some((Counted::Node(item.doc.uid, node), counted.clone())); + Ok(counted) +} + +/// How many points the path of `item` has, its waiting point changes included ([`point_starts`]). +fn points_of(h: &super::Host, item: Item) -> std::result::Result { + Ok(point_starts(h, item)?.last().copied().unwrap_or(0)) } /// The subpath and the place in it of point `i`, among the subpaths `subs`. @@ -180,6 +234,7 @@ fn read_points(h: &super::Host, item: Item, f: impl FnOnce(&[SubPath]) -> T) /// locked, unless it changes nothing. A path that is aligned to the pixel grid, or is in an object /// that is, is written at once, so that its points read as the grid snaps them. fn edit_points(h: &super::Host, item: Item, f: impl FnOnce(&mut Vec) -> T) -> std::result::Result { + forget_waiting_starts(h); if let Some((waiting, subs)) = &mut *h.dom.pending.borrow_mut() && same_path(*waiting, item) { @@ -205,6 +260,33 @@ fn edit_points(h: &super::Host, item: Item, f: impl FnOnce(&mut Vec) Ok(r) } +/// Drops the [`starts`] that [`super::State`] keeps of waiting point changes, which a change can +/// make wrong. +fn forget_waiting_starts(h: &super::Host) { + let mut kept = h.dom.point_starts.borrow_mut(); + if matches!(&*kept, Some((Counted::Waiting(_), _))) { + *kept = None; + } +} + +/// Changes the anchor at index `i` of the path of `item` with `f` ([`edit_points`]). The change +/// adds and removes no points, so the [`starts`] of the path stay kept. +fn edit_anchor(h: &super::Host, item: Item, i: usize, f: impl FnOnce(&mut Anchor)) -> std::result::Result<(), HostError> { + let counted = point_starts(h, item)?; + let at = locate_at(&counted, i); + edit_points(h, item, |subs| { + if let Some((s, j)) = at + && let Some(an) = subs.get_mut(s).and_then(|sp| sp.anchors.get_mut(j)) + { + f(an); + } + })?; + if matches!(&*h.dom.pending.borrow(), Some((w, _)) if same_path(*w, item)) { + *h.dom.point_starts.borrow_mut() = Some((Counted::Waiting(item), counted)); + } + Ok(()) +} + /// Gives the path of `item` the subpaths `subs` ([`edit_points`]). fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::Result<(), HostError> { edit_points(h, item, |s| *s = subs) @@ -214,6 +296,7 @@ fn write_path(h: &super::Host, item: Item, subs: Vec) -> std::result::R /// the path has those points already. pub(super) fn flush(h: &super::Host) -> std::result::Result<(), HostError> { let Some((item, subs)) = h.dom.pending.borrow_mut().take() else { return Ok(()) }; + forget_waiting_starts(h); let same = { let s = h.session.borrow(); let node = s.documents().iter().find(|d| d.uid == item.doc.uid).and_then(|st| st.doc.node(item.id)); @@ -278,16 +361,13 @@ fn keeping_paint(h: &super::Host, f: impl FnOnce() -> T) -> T { /// The ids of a document's paths, in the order of its page items. fn path_items(h: &super::Host, st: &DocState) -> Rc> { - if let Some((uid, doc, ids)) = &*h.dom.paths.borrow() - && *uid == st.uid - && std::sync::Arc::ptr_eq(doc, &st.doc) - { - return ids.clone(); + if let Some(ids) = super::kept_list(&h.dom.paths, st) { + return ids; } let all = super::page_items(h, st); let ids: Rc> = Rc::new(all.iter().copied().filter(|i| st.doc.node(*i).is_some_and(|n| matches!(n.kind, NodeKind::Path { .. }))).collect()); - *h.dom.paths.borrow_mut() = Some((st.uid, st.doc.clone(), ids.clone())); + super::keep_list(&h.dom.paths, st, &ids); ids } @@ -300,6 +380,12 @@ fn items_doc(h: &super::Host, a: &[Data]) -> std::result::Result doc_of(h, arg(a, 0), "PathItems") } +/// `typename` of the paths of a document that is still open. +fn items_typename(h: &super::Host, a: &[Data]) -> Answer { + items_doc(h, a)?; + Ok(Data::String("PathItems".into())) +} + fn items_length(h: &super::Host, a: &[Data]) -> Answer { let doc = items_doc(h, a)?; Ok(num(float(with_doc(h, doc, |_, st| path_items(h, st).len()) as u64))) @@ -818,12 +904,7 @@ fn set_color(h: &super::Host, a: &[Data], fill: bool) -> Answer { let color = colors::assigned(arg(a, 1), if fill { "fillColor" } else { "strokeColor" })?; let (item, look) = this_look(h, a)?; let now = if fill { &look.fill } else { &look.stroke }; - let same = match (&color, now) { - (None, Paint::None) => true, - (Some(c), Paint::Solid { color, swatch: None, .. }) => c == color, - _ => false, - }; - if !same { + if !colors::unchanged(arg(a, 1), color, now, |c| c) { set_paint(h, item, fill, color)?; } Ok(Data::Undefined) @@ -928,13 +1009,13 @@ pub(super) fn dash_lengths(d: &Data, what: &str) -> std::result::Result Data::Array(list) => list.iter().map(|d| number(d, "each dash length")).collect::>()?, _ => return Err(HostError::Type(format!("{what} must be an array of lengths"))), }; - if lengths.iter().any(|l| !(0.0..=MAX_STROKE_WIDTH * 1000.0).contains(l)) { - return Err(HostError::Range("each dash length must be from 0 to 1000000 points".into())); + use crate::cmd::newart::DashFault; + match crate::cmd::newart::dash_fault(&lengths) { + None => Ok(lengths), + Some(DashFault::TooMany) => Err(HostError::Range(format!("{what} takes at most {MAX_DASHES} lengths"))), + Some(DashFault::OutOfRange) => Err(HostError::Range("each dash length must be from 0 to 1000000 points".into())), + Some(DashFault::AllZero) => Err(HostError::Range(format!("{what} needs a length that is not 0"))), } - if !lengths.is_empty() && lengths.iter().all(|l| *l == 0.0) { - return Err(HostError::Range(format!("{what} needs a length that is not 0"))); - } - Ok(lengths) } /// `strokeDashes = [lengths]`, as [`dash_lengths`] takes them. @@ -1129,9 +1210,15 @@ fn points_path(h: &super::Host, a: &[Data]) -> std::result::Result Answer { + points_path(h, a)?; + Ok(Data::String("PathPoints".into())) +} + fn points_length(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; - read_points(h, item, |subs| num(float(point_count(subs) as u64))) + Ok(num(float(points_of(h, item)? as u64))) } fn points_parent(h: &super::Host, a: &[Data]) -> Answer { @@ -1255,7 +1342,7 @@ fn points_at(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; let Data::Number(n) = arg(a, 1) else { return Ok(Data::Undefined) }; let Some(i) = whole(*n).and_then(|i| usize::try_from(i).ok()) else { return Ok(Data::Undefined) }; - let n = read_points(h, item, point_count)?; + let n = points_of(h, item)?; Ok(if i < n { point_ref(h, item, i) } else { Data::Undefined }) } @@ -1273,18 +1360,33 @@ fn points_index(h: &super::Host, a: &[Data]) -> Answer { fn points_add(h: &super::Host, a: &[Data]) -> Answer { let item = points_path(h, a)?; let origin = with_doc(h, item.doc, |_, st| frame(st).map(|f| f.to_document(h.dom.coords.get(), [0.0, 0.0]))); - let (n, last) = read_points(h, item, |subs| (point_count(subs), subs.iter().rev().find_map(|sp| sp.anchors.last()).map(|a| a.p)))?; + let mut counted = point_starts(h, item)?; + let n = counted.last().copied().unwrap_or(0); if n >= MAX_POINTS { return Err(HostError::Range(format!("PathPoints.add takes a path to at most {MAX_POINTS} points"))); } + let last = read_points(h, item, |subs| subs.iter().rev().find_map(|sp| sp.anchors.last()).map(|a| a.p))?; let p = match last { Some(p) => p, None => origin?, }; + // The kept starts are dropped, so that `counted` is their only copy and grows in place. + *h.dom.point_starts.borrow_mut() = None; edit_points(h, item, |subs| match subs.last_mut() { Some(sp) => sp.anchors.push(Anchor::corner(p)), None => subs.push(SubPath::new(vec![Anchor::corner(p)], false)), })?; + if matches!(&*h.dom.pending.borrow(), Some((w, _)) if same_path(*w, item)) { + let grown = Rc::make_mut(&mut counted); + if grown.len() > 1 { + if let Some(total) = grown.last_mut() { + *total += 1; + } + } else { + *grown = vec![0, 1]; + } + *h.dom.point_starts.borrow_mut() = Some((Counted::Waiting(item), counted)); + } Ok(point_ref(h, item, n)) } @@ -1307,8 +1409,7 @@ pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(It return Err(HostError::Error(STALE_POINT.into())); } let i = whole(*i).and_then(|i| usize::try_from(i).ok()).ok_or_else(|| HostError::Error(STALE_POINT.into()))?; - let n = read_points(h, item, point_count)?; - if i >= n { + if i >= points_of(h, item)? { return Err(HostError::Error(STALE_POINT.into())); } Ok((item, i)) @@ -1319,8 +1420,9 @@ fn read_point(h: &super::Host, a: &[Data], f: impl FnOnce(&super::Frame, Coords, let (item, i) = this_point(h, a)?; let c = h.dom.coords.get(); let fr = with_doc(h, item.doc, |_, st| frame(st))?; + let at = locate_at(&point_starts(h, item)?, i); read_points(h, item, |subs| { - let anchor = locate(subs, i).and_then(|(s, j)| subs.get(s).and_then(|sp| sp.anchors.get(j))); + let anchor = at.and_then(|(s, j)| subs.get(s).and_then(|sp| sp.anchors.get(j))); anchor.map(|an| f(&fr, c, an)).ok_or_else(|| HostError::Error(STALE_POINT.into())) })? } @@ -1329,13 +1431,7 @@ fn read_point(h: &super::Host, a: &[Data], f: impl FnOnce(&super::Frame, Coords, /// coordinates (for a point property) or the value itself. fn edit_point(h: &super::Host, a: &[Data], f: impl FnOnce(&mut Anchor)) -> Answer { let (item, i) = this_point(h, a)?; - edit_points(h, item, |subs| { - if let Some((s, j)) = locate(subs, i) - && let Some(an) = subs.get_mut(s).and_then(|sp| sp.anchors.get_mut(j)) - { - f(an); - } - })?; + edit_anchor(h, item, i, f)?; Ok(Data::Undefined) } @@ -1392,6 +1488,12 @@ fn pt_parent(h: &super::Host, a: &[Data]) -> Answer { Ok(path_ref(h, item)) } +/// `typename` of a point that is still on its path. +fn pt_typename(h: &super::Host, a: &[Data]) -> Answer { + this_point(h, a)?; + Ok(Data::String("PathPoint".into())) +} + /// Whether a group or compound path that holds the path `id` is selected, which selects the path /// as a whole whatever the path's own selection is. fn held_selected(d: &crate::Document, sel: &crate::doc::Selection, id: NodeId) -> bool { @@ -1573,7 +1675,7 @@ pub(super) fn classes(l: &Link) -> Vec { "PathItems", None, named(vec![ - ("typename", typename_of("PathItems")), + ("typename", get(l, items_typename)), ("length", get(l, items_length)), ("parent", get(l, items_parent)), ("index", method(l, items_index)), @@ -1592,7 +1694,7 @@ pub(super) fn classes(l: &Link) -> Vec { "PathPoints", None, named(vec![ - ("typename", typename_of("PathPoints")), + ("typename", point_get(l, points_typename)), ("length", point_get(l, points_length)), ("parent", point_get(l, points_parent)), ("index", point_method(l, points_index)), @@ -1605,7 +1707,7 @@ pub(super) fn classes(l: &Link) -> Vec { "PathPoint", None, named(vec![ - ("typename", typename_of("PathPoint")), + ("typename", point_get(l, pt_typename)), ("parent", point_get(l, pt_parent)), ("anchor", point_property(l, pt_anchor, pt_set_anchor)), ("leftDirection", point_property(l, pt_left, pt_set_left)), diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index 9bdd211b3f..f2e4144e43 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -2227,6 +2227,17 @@ impl Session { RunError { kind: RunErrorKind::Limit(kind), message: format!("limit reached: {kind:?}"), line: 0, column: 0, authored: false }; return Some(self.script_failed(job, &e)); } + // One more allowance may still leave the growth past it: the person is asked again + // while they may be, and past that the run ends unkept. + if let Err(HostError::Abort(message)) = job.host.charge_growth(0, 0) { + let e = RunError { kind: RunErrorKind::Limit(LimitKind::Host), message, line: 0, column: 0, authored: false }; + return Some(self.script_failed(job, &e)); + } + if job.host.waiting.get() { + JOBS.with(|jobs| jobs.borrow_mut().insert(key.id, job)); + self.script_key = Some(key); + return None; + } return Some(self.script_ended(job)); } // A stop while a dialog waits ends the run there; the interpreter cannot go on from the call. diff --git a/crates/engine/src/tests/newart.rs b/crates/engine/src/tests/newart.rs index 231d2681da..40613d1e3c 100644 --- a/crates/engine/src/tests/newart.rs +++ b/crates/engine/src/tests/newart.rs @@ -1,6 +1,8 @@ //! The new-art template (M3.65): Stroke panel options and graphic styles chosen with nothing //! selected, New Art Has Basic Appearance and `paint.default`. +use std::sync::Arc; + use serde_json::{Value, json}; use vectorcraft_color::{BlendMode, Paint}; use vectorcraft_doc::{Appearance, Dash, LineCap, Node}; @@ -396,6 +398,19 @@ fn set_new_art_refuses_bad_values_with_nothing_changed() { } } +#[test] +fn set_new_art_refuses_a_tint_on_a_pattern_without_a_swatch_entry() { + let mut s = session(); + let id = rect(&mut s, 20.0); + let name = run(&mut s, "object.pattern.make", json!({"ids": [id.0], "edit": false}))["name"].as_str().unwrap().to_string(); + run(&mut s, "select.none", json!({})); + Arc::make_mut(&mut s.doc_mut().unwrap().doc).remove_swatch(&name); + let before = s.paint.clone(); + assert!(s.execute("appearance.setNewArt", &json!({"fill": {"swatch": name, "tint": 50}})).is_err(), "accepted a tint on {name}"); + assert_eq!(s.paint, before); + assert_eq!(run(&mut s, "appearance.setNewArt", json!({"fill": {"swatch": name}})), json!({"changed": true})); +} + #[test] fn set_new_art_refuses_while_new_art_takes_the_selected_look() { let mut s = session(); diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index 1cb2025325..e09d19ecce 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -1037,3 +1037,11 @@ fn the_new_layer_takes_an_id_no_profile_art_has() { // Ids given out later skip the symbol's art too. assert!(d.peek_next_id() > d.layers[0].id.0 && d.peek_next_id() > next); } + +#[test] +fn a_saved_presets_rows_are_read_within_the_artboard_limit() { + let rows = |n: u32| serde_json::from_value::(json!({"rows": n})).unwrap().rows; + assert_eq!(rows(1001), crate::cmd::newdoc::MAX_ARTBOARDS, "file.new takes the listed rows again"); + assert_eq!(rows(0), 0, "0 stays: columns in their place"); + assert_eq!(rows(12), 12, "more rows than artboards stay"); +} diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 69ba1973db..b317349fcc 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -805,6 +805,16 @@ fn note_is_the_attributes_note() { assert!(failure(&mut s, "app.activeDocument.pageItems[0].note = new Array(5000).join('n');").contains("too long")); } +#[test] +fn a_profile_starts_from_its_built_in_preset_and_not_a_saved_one_of_the_same_name() { + let mut s = Session::new(); + s.execute("file.newPresets.save", &json!({"name": "Letter", "width": 100, "height": 50, "units": "Millimeters", "colorMode": "rgb"})).unwrap(); + let out = log(&mut s, "var d = app.documents.addDocument('Print'); vc.log([d.width, d.height, d.documentColorSpace]);"); + assert_eq!(out, vec![json!([612, 792, "DocumentColorSpace.CMYK"])]); + let out = log(&mut s, "var p = new DocumentPreset(); p.width = 300; var d = app.documents.addDocument('Print', p); vc.log([d.width, d.height]);"); + assert_eq!(out, vec![json!([300, 792])], "presetSettings goes over the built-in preset"); +} + #[test] fn document_preset_applies_only_its_given_fields() { let mut s = Session::new(); @@ -1019,8 +1029,8 @@ fn get_is_file_open_cannot_probe_outside_script_scope() { let (mut s, _, _) = doc(); let path = std::env::temp_dir().join(format!("vc-dom-open-{}.svg", std::process::id())); s.execute("document.save", &json!({"path": path.to_string_lossy()})).unwrap(); - let p = path.to_string_lossy().replace('\\', "\\\\"); - let query = format!("vc.log(app.getIsFileOpen('{p}')); vc.log(app.getIsFileOpen('{p}.other'));"); + let (p, other) = (json!(path.to_string_lossy()), json!(format!("{}.other", path.to_string_lossy()))); + let query = format!("vc.log(app.getIsFileOpen({p})); vc.log(app.getIsFileOpen({other}));"); let out = log(&mut s, &query); assert_eq!(out, vec![json!(true), json!(false)]); // Read roots that leave out the document's file: the same path does not count. diff --git a/crates/engine/src/tests/script_dom_defaults.rs b/crates/engine/src/tests/script_dom_defaults.rs index cc6c53eb4e..a3bdc447e0 100644 --- a/crates/engine/src/tests/script_dom_defaults.rs +++ b/crates/engine/src/tests/script_dom_defaults.rs @@ -38,15 +38,14 @@ fn node(s: &Session, id: NodeId) -> crate::doc::Node { fn a_wider_default_stroke_goes_to_the_next_path_drawn() { let (mut s, picked) = doc(); let (look, steps) = (node(&s, picked).appearance, undo_steps(&s)); - let r = run(&mut s, "var d = app.activeDocument; var w = d.defaultStrokeWidth; d.defaultStrokeWidth += 1; vc.log(d.defaultStrokeWidth > w);") - .unwrap(); - assert_eq!(r["log"], json!([true])); + let wider = s.paint.stroke_width + 1.0; + let r = run(&mut s, "var d = app.activeDocument; d.defaultStrokeWidth += 1; vc.log(d.defaultStrokeWidth);").unwrap(); + assert_eq!(r["log"][0].as_f64(), Some(wider)); assert_eq!(undo_steps(&s), steps, "a default alone is no undo step"); assert_eq!(node(&s, picked).appearance, look, "the selected path kept its stroke"); - let wider = s.new_art().stroke().unwrap().width; + assert_eq!(s.new_art().stroke().unwrap().width, wider); let out = log(&mut s, "var p = app.activeDocument.pathItems.rectangle(200, 100, 50, 50); vc.log(p.strokeWidth);"); assert_eq!(out.iter().map(Value::as_f64).collect::>(), vec![Some(wider)]); - assert!(wider > 1.0); } #[test] @@ -121,6 +120,32 @@ fn default_stroke_options_read_back_and_a_same_value_runs_no_command() { assert_eq!(log(&mut s, "var d = app.activeDocument; d.defaultStrokeDashes = {}; vc.log(d.defaultStrokeDashes.length);"), vec![json!(0)]); } +#[test] +fn a_slightly_different_number_reaches_new_art() { + let (mut s, _) = doc(); + log(&mut s, "var d = app.activeDocument; d.defaultStrokeWidth = 1; d.defaultStrokeMiterLimit = 7; d.defaultStrokeDashes = [6, 2];"); + log( + &mut s, + "var d = app.activeDocument; d.defaultStrokeWidth = 1.0000000005; d.defaultStrokeMiterLimit = 7.0000000005;\ + d.defaultStrokeDashOffset = 0.0000000005;", + ); + let st = s.new_art().stroke().unwrap().clone(); + assert_eq!(st.width, 1.000_000_000_5); + assert_eq!(st.miter_limit, 7.000_000_000_5); + assert_eq!(st.dash.map(|d| d.offset), Some(0.000_000_000_5)); +} + +#[test] +fn an_rgb_default_in_a_cmyk_document_runs_no_command_the_second_time() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300, "colorMode": "cmyk"})).unwrap(); + let set = "var d = app.activeDocument, c = new RGBColor(); c.red = 200; c.green = 40; c.blue = 90; d.defaultFillColor = c;"; + let first = run(&mut s, set).unwrap(); + assert_ne!(first["slowestCommands"], json!([]), "the first assignment changes new art"); + let again = run(&mut s, set).unwrap(); + assert_eq!(again["slowestCommands"], json!([]), "the same RGB value runs no command"); +} + #[test] fn scale_factor_is_one_and_read_only() { let (mut s, _) = doc(); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index bb73f4175d..ce088ea01c 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -282,6 +282,25 @@ fn points_read_before_a_removal_or_replacement_go_stale() { json!("Stale path point") ] ); + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[1], pt = p.pathPoints[0]; vc.log(pt.typename); pt.remove();\ + try { vc.log(pt.typename); } catch (e) { vc.log(e.message); }", + ); + assert_eq!(out, vec![json!("PathPoint"), json!("Stale path point")]); + // The points of a removed path, and collections kept from an earlier run, throw on typename as on + // their other members. + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0], pp = p.pathPoints; vc.log([pp.typename, app.activeDocument.pathItems.typename]); p.remove();\ + var a = '', b = ''; try { pp.length; } catch (e) { a = e.message; } try { pp.typename; } catch (e) { b = e.message; } vc.log(a !== '' && a === b);", + ); + assert_eq!(out, vec![json!(["PathPoints", "PathItems"]), json!(true)]); + run(&mut s, "#targetengine keep\nvar items = app.activeDocument.pathItems, pts = items[0].pathPoints;").unwrap(); + for (member, message) in [("items.typename", "Stale document"), ("pts.typename", "Stale")] { + let e = failure(&mut s, &format!("#targetengine keep\n{member};")); + assert!(e.contains(message), "{member}: {e}"); + } } #[test] @@ -468,6 +487,14 @@ fn a_color_read_from_a_path_assigns_back_unchanged() { var g = new GrayColor(); g.gray = 25; p.strokeColor = g; vc.log([p.fillColor.red, p.fillColor.green, p.strokeColor.gray]);", ); assert_eq!(out, vec![json!([200, 0.5, 25])], "whole and short values read as they were given"); + // A Gray ink amount too small for its Gray value to name: assigning the color read back changes nothing. + let (mut s, a, _) = doc(); + let k = f32::from_bits(0x1f00_0000); + std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc).node_mut(a).unwrap().appearance.set_fill(Paint::solid(Color::Gray { k })); + let steps = undo_steps(&s); + let r = run(&mut s, "var p = app.activeDocument.pathItems[0]; p.fillColor = p.fillColor;").unwrap(); + assert_eq!(paint_of(&s, a, true), Paint::solid(Color::Gray { k })); + assert_eq!((undo_steps(&s), &r["slowestCommands"]), (steps, &json!([]))); } #[test] @@ -869,16 +896,49 @@ fn area_sign_follows_direction() { fn many_path_edits_are_one_undo_step() { let (mut s, a, b) = doc(); let steps = undo_steps(&s); + let look = |s: &Session| [a, b].map(|id| (node(s, id).appearance, node(s, id).path_data().map(|pd| pd.subpaths.clone()))); + let before = look(&s); log( &mut s, "var p = app.activeDocument.pathItems, c = new RGBColor(); c.green = 200;\ for (var i = 0; i < p.length; i++) { p[i].fillColor = c; p[i].strokeWidth = 3; p[i].pathPoints[0].anchor = [0, 0]; }", ); assert_eq!(undo_steps(&s), steps + 1); + assert_ne!(look(&s), before); s.execute("edit.undo", &json!({})).unwrap(); - for id in [a, b] { - assert!((node(&s, id).appearance.stroke_width() - 1.0).abs() < 1e-9); - } + assert_eq!(look(&s), before, "one Undo puts back the fill, the stroke width and the anchor of both paths"); +} + +#[test] +fn point_indexes_follow_subpaths_through_edits_adds_and_removals() { + let (mut s, a, _) = doc(); + let source = format!( + "function A(x) {{ return {{x: x, y: 5, in: [x, 5], out: [x, 5], smooth: false}}; }}\ + function xs() {{ var out = []; for (var i = 0; i < pp.length; i++) out.push(pp[i].anchor[0]); return out; }}\ + var p = app.activeDocument.pathItems[0], pp = p.pathPoints;\ + vc.run('path.setAnchors', {{id: {id}, subpaths: [{{anchors: [A(0), A(1)], closed: false}}, {{anchors: [A(10), A(11), A(12)], closed: false}},\ + {{anchors: [A(20)], closed: false}}]}});\ + vc.log(xs()); pp[3].anchor = [50, pp[3].anchor[1]]; vc.log([pp[3].anchor[0], pp[4].anchor[0], pp[5].anchor[0]]);\ + pp.add(); vc.log([pp.length, pp[6].anchor[0]]);\ + pp[0].remove(); vc.log(xs()); pp[0].remove(); vc.log(xs()); pp[4].anchor = [70, 0]; vc.log(xs());", + id = a.0 + ); + let out = log(&mut s, &source); + let out: Vec = out.iter().map(rounded).collect(); + assert_eq!( + out, + vec![ + json!([0, 1, 10, 11, 12, 20]), + json!([50, 12, 20]), + json!([7, 20]), + json!([1, 10, 50, 12, 20, 20]), + json!([10, 50, 12, 20, 20]), + json!([10, 50, 12, 20, 70]), + ] + ); + let subs = node(&s, a).path_data().unwrap().subpaths.clone(); + let xs: Vec> = subs.iter().map(|sp| sp.anchors.iter().map(|an| (an.p.x * 1000.0).round() / 1000.0).collect()).collect(); + assert_eq!(xs, vec![vec![10.0, 50.0, 12.0], vec![20.0, 70.0]]); } fn selected_anchors(s: &Session, id: NodeId) -> Option> { diff --git a/docs/mcp.md b/docs/mcp.md index 504525c265..b0e133b490 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9147,8 +9147,9 @@ resets it. `appearance.setNewArtBasic` rejects an `on` value that is not a boolean. Omitting `on` toggles the current preference. `appearance.setNewArt {fill?, stroke?, weight?, cap?, join?, miterLimit?, dash?, dashOffset?, fillOverprint?, strokeOverprint?}` sets new art's fill, stroke and stroke options whatever is selected, and leaves the selection, its -art, the active proxy and Recent Colors as they were. `fill` and `stroke` take a paint as `paint.setFill` does; a -stroke painted on new art without one gets a 1 pt weight unless `weight` is given. Every value is checked before +art, the active proxy and Recent Colors as they were. `fill` and `stroke` take a paint as `paint.setFill` does, and +`tint` only with a global or spot `swatch`. Without `weight` the stored stroke weight stays; a stroke painted on new +art without one gets 1 pt only when that stored weight is 0. Every value is checked before anything changes, and any change while New Art Has Basic Appearance is off and an object is selected is an error. It returns `{changed}`, false when the next object would look the same. @@ -9462,8 +9463,8 @@ runs, as `document.open` reads its file when it runs. A file larger than 64 MiB When the file cannot be read, is too large or is not a native document, or the request's read roots leave out the folder (whether or not the file exists), the document starts with the defaults and `file.new`'s result carries `profileError: {profile, reason}`; the desktop app shows the reason in the status bar, and -a script's `app.documents.addDocument` throws it. A script's file access limits do not apply to reading the profile's -file. The +a script's `app.documents.addDocument` throws it. Reading the profile's file is not limited to the script's folder (the +`File` and `Folder` rule in [Script engines](#script-engines)), but the request's automation read roots still apply. The reason given when the read roots leave out the folder does not name the folder's path. Color profiles the profile's file carries are installed when they are missing, as `document.open` installs them, and each one that can't be used adds a line to `file.new`'s `warnings`. The new document's links find their files through relative paths from the From 7baaac6391a82805e363761c85718024463d424d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 18:24:19 -0800 Subject: [PATCH 031/264] Scripts: read a new path's id from the command's own result pathItems.add() and the shape constructors read the new path's id from the script's copy of the command result, where it is a number. An id above 2^53 was rounded there, so the constructor could return another path, or fail after the path was made. They now read the id as an integer from the command's result. --- crates/engine/src/script/dom/paths.rs | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index d3faca29a3..026d990a5c 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -67,9 +67,9 @@ use vectorcraft_js::{Data, HostClass, HostError, HostItem, HostMember, Realm, Ru use vectorcraft_tools::params::gradient_params; use super::{ - Answer, Coords, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, coordinate, doc_of, edit_item, editable, find_doc, - float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, point, point_get, - point_method, point_property, property, this_doc, whole, with_doc, + Answer, Coords, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, command_value, coordinate, doc_of, edit_item, + editable, find_doc, float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, + point, point_get, point_method, point_property, property, this_doc, whole, with_doc, }; use crate::{DocState, NodeId, NodeKind}; @@ -444,20 +444,17 @@ fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer { Ok(Data::Undefined) } -/// The id in the result of a command that made an object. -fn made_id(r: &Data) -> std::result::Result { - let id = match r { - Data::Object(o) => o.iter().find(|(k, _)| k == "id").and_then(|(_, v)| if let Data::Number(n) = v { whole(*n) } else { None }), - _ => None, - }; - id.map(NodeId).ok_or_else(|| HostError::Error("the path was not made".into())) +/// The id in the result of a command that made an object, read from the command's own result so +/// that an id above 2^53 stays exact. +fn made_id(r: &Value) -> std::result::Result { + r["id"].as_u64().map(NodeId).ok_or_else(|| HostError::Error("the path was not made".into())) } /// Runs the command `id` that makes a path in `doc` on top of the active layer, the selection kept, /// and reverses the new path's direction when `reversed`. → the new path. fn make(h: &super::Host, doc: Doc, id: &str, params: &Value, reversed: bool) -> Answer { let made = on_doc(h, doc.uid, true, |h| { - let id = made_id(&drawing_normally(h, || command(h, id, params))?)?; + let id = made_id(&drawing_normally(h, || command_value(h, id, params))?.1)?; if reversed { command(h, "path.reverse", &json!({"ids": [id.0]}))?; } @@ -616,7 +613,7 @@ fn items_add(h: &super::Host, a: &[Data]) -> Answer { let ap = h.session.borrow().new_art(); ap.fill_paint().is_none() && ap.stroke_paint().is_none() }; - let id = made_id(&drawing_normally(h, || command(h, "path.create", &json!({"d": ""})))?)?; + let id = made_id(&drawing_normally(h, || command_value(h, "path.create", &json!({"d": ""})))?.1)?; if unpainted { keeping_paint(h, || command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]})))?; } @@ -1720,3 +1717,16 @@ pub(super) fn classes(l: &Link) -> Vec { ), ] } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_made_id_above_two_to_the_53_stays_exact() { + assert_eq!(made_id(&json!({"id": 9_007_199_254_740_993_u64})), Ok(NodeId(9_007_199_254_740_993))); + assert_eq!(made_id(&json!({"id": 7})), Ok(NodeId(7))); + assert!(made_id(&json!({"id": 1.5})).is_err()); + assert!(made_id(&json!({})).is_err()); + } +} From e2b33969dc64d57f4edc7c012fe41dba921375dd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 19:48:56 -0800 Subject: [PATCH 032/264] Scripts: the plugin gate test sets held, and catalogs keep main's rows The merge with main added a ScriptGate initializer in the plugin tests that predates the held field. The two script save errors are added in English only; their translations go through craft-i18n. --- crates/engine/src/tests/plugins.rs | 1 + crates/ui-egui/src/i18n/ca.tsv | 2 -- crates/ui-egui/src/i18n/cs.tsv | 2 -- crates/ui-egui/src/i18n/da.tsv | 2 -- crates/ui-egui/src/i18n/de.tsv | 2 -- crates/ui-egui/src/i18n/el.tsv | 2 -- crates/ui-egui/src/i18n/es.tsv | 2 -- crates/ui-egui/src/i18n/fi.tsv | 2 -- crates/ui-egui/src/i18n/fr.tsv | 2 -- crates/ui-egui/src/i18n/hi.tsv | 2 -- crates/ui-egui/src/i18n/hu.tsv | 2 -- crates/ui-egui/src/i18n/id.tsv | 2 -- crates/ui-egui/src/i18n/it.tsv | 2 -- crates/ui-egui/src/i18n/ja.tsv | 2 -- crates/ui-egui/src/i18n/ka.tsv | 2 -- crates/ui-egui/src/i18n/ko.tsv | 2 -- crates/ui-egui/src/i18n/nl.tsv | 2 -- crates/ui-egui/src/i18n/pl.tsv | 2 -- crates/ui-egui/src/i18n/pt-br.tsv | 2 -- crates/ui-egui/src/i18n/ru.tsv | 2 -- crates/ui-egui/src/i18n/sv.tsv | 2 -- crates/ui-egui/src/i18n/tr.tsv | 2 -- crates/ui-egui/src/i18n/uk.tsv | 2 -- crates/ui-egui/src/i18n/vi.tsv | 2 -- crates/ui-egui/src/i18n/zh-hans.tsv | 2 -- crates/ui-egui/src/i18n/zh-hant.tsv | 2 -- 26 files changed, 1 insertion(+), 50 deletions(-) diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index 0a255fb3a3..fc3586756f 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -2202,6 +2202,7 @@ fn a_script_loads_no_plugin_from_outside_its_folder_through_a_name_that_is_not_t read: ScriptScope::of_folder(&inside), write: ScriptScope::default(), documents: vec![], + held: vec![], linked: Default::default(), also: None, }; diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 70b0e70d00..87f76147b6 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6631,8 +6631,6 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file could not be written No s’ha pogut escriure el fitxer de l’script @msg Script file dialogs need a person to answer them Els diàlegs de fitxers de l’script necessiten una persona que els respongui @msg Script file is not open for writing El fitxer de l’script no està obert per escriure-hi -@msg Script file is read-only El fitxer de l’script és només de lectura -@msg Script file is open for writing El fitxer de l’script està obert per escriure-hi @msg Script file name is already in use El nom del fitxer de l’script ja està en ús @msg Script file name must be a name without a folder El nom del fitxer de l’script ha de ser un nom sense carpeta @msg Script file permission can be kept only for a script run from a file El permís de fitxers només es pot conservar per a un script executat des d’un fitxer diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index f67e75d6f1..13129a99a0 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5416,8 +5416,6 @@ liquify-list-end {0}, {1} {0} a {1} @msg Script file could not be written Soubor skriptu nelze zapsat @msg Script file dialogs need a person to answer them Dialogy souborů skriptu potřebují osobu, která na ně odpoví @msg Script file is not open for writing Soubor skriptu není otevřený pro zápis -@msg Script file is read-only Soubor skriptu je jen pro čtení -@msg Script file is open for writing Soubor skriptu je otevřený pro zápis @msg Script file name is already in use Název souboru skriptu se už používá @msg Script file name must be a name without a folder Název souboru skriptu musí být název bez složky @msg Script file permission can be kept only for a script run from a file Oprávnění k souborům lze zachovat jen pro skript spuštěný ze souboru diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 18030993dc..94df1eb83e 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -88,8 +88,6 @@ @msg Script file could not be written Scriptfilen kunne ikke skrives @msg Script file dialogs need a person to answer them Scriptets fildialoger skal besvares af en person @msg Script file is not open for writing Scriptfilen er ikke åben for skrivning -@msg Script file is read-only Scriptfilen er skrivebeskyttet -@msg Script file is open for writing Scriptfilen er åben for skrivning @msg Script file name is already in use Scriptfilens navn er allerede i brug @msg Script file name must be a name without a folder Scriptfilens navn skal være et navn uden en mappe @msg Script file permission can be kept only for a script run from a file Filtilladelsen kan kun beholdes for et script, der køres fra en fil diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 61ccfe0721..0fb57437c4 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4995,8 +4995,6 @@ liquify-list-end {0}, {1} {0} und {1} @msg Script file could not be written Skriptdatei konnte nicht geschrieben werden @msg Script file dialogs need a person to answer them Dateidialoge von Skripten brauchen eine Person, die sie beantwortet @msg Script file is not open for writing Skriptdatei ist nicht zum Schreiben geöffnet -@msg Script file is read-only Skriptdatei ist schreibgeschützt -@msg Script file is open for writing Skriptdatei ist zum Schreiben geöffnet @msg Script file name is already in use Name der Skriptdatei wird bereits verwendet @msg Script file name must be a name without a folder Name der Skriptdatei muss ein Name ohne Ordner sein @msg Script file permission can be kept only for a script run from a file Dateiberechtigung kann nur für ein Skript behalten werden, das aus einer Datei ausgeführt wird diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index dcbd2fd5c3..3bd10eceb1 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2825,8 +2825,6 @@ liquify-list-end {0}, {1} {0} και {1} @msg Script file could not be written Δεν ήταν δυνατή η εγγραφή του αρχείου του σεναρίου @msg Script file dialogs need a person to answer them Τα παράθυρα διαλόγου αρχείων του σεναρίου χρειάζονται ένα άτομο για να απαντήσει @msg Script file is not open for writing Το αρχείο του σεναρίου δεν είναι ανοιχτό για εγγραφή -@msg Script file is read-only Το αρχείο του σεναρίου είναι μόνο για ανάγνωση -@msg Script file is open for writing Το αρχείο του σεναρίου είναι ανοιχτό για εγγραφή @msg Script file name is already in use Το όνομα του αρχείου του σεναρίου χρησιμοποιείται ήδη @msg Script file name must be a name without a folder Το όνομα του αρχείου του σεναρίου πρέπει να είναι όνομα χωρίς φάκελο @msg Script file permission can be kept only for a script run from a file Η άδεια αρχείων μπορεί να διατηρηθεί μόνο για σενάριο που εκτελείται από αρχείο diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 37e1a3bd42..7e71c1c191 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5103,8 +5103,6 @@ liquify-list-end {0}, {1} {0}, {1} @msg Script file could not be written No se pudo escribir el archivo del script @msg Script file dialogs need a person to answer them Los cuadros de diálogo de archivo del script necesitan que una persona los responda @msg Script file is not open for writing El archivo del script no está abierto para escritura -@msg Script file is read-only El archivo del script es de solo lectura -@msg Script file is open for writing El archivo del script está abierto para escritura @msg Script file name is already in use El nombre del archivo del script ya está en uso @msg Script file name must be a name without a folder El nombre del archivo del script debe ser un nombre sin carpeta @msg Script file permission can be kept only for a script run from a file El permiso de archivos solo se puede conservar para un script ejecutado desde un archivo diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 064d7d6da9..cc6e0d2fd2 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5344,8 +5344,6 @@ liquify-list-end {0}, {1} {0} ja {1} @msg Script file could not be written Komentosarjan tiedostoa ei voitu kirjoittaa @msg Script file dialogs need a person to answer them Komentosarjan tiedostovalintaikkunoihin tarvitaan vastaava henkilö @msg Script file is not open for writing Komentosarjan tiedosto ei ole auki kirjoittamista varten -@msg Script file is read-only Komentosarjan tiedosto on vain luku -tilassa -@msg Script file is open for writing Komentosarjan tiedosto on auki kirjoittamista varten @msg Script file name is already in use Komentosarjan tiedoston nimi on jo käytössä @msg Script file name must be a name without a folder Komentosarjan tiedoston nimen on oltava nimi ilman kansiota @msg Script file permission can be kept only for a script run from a file Tiedostolupa voidaan säilyttää vain tiedostosta suoritetulle komentosarjalle diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3afc56aa93..6bcf110355 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5062,8 +5062,6 @@ liquify-list-end {0}, {1} {0} et {1} @msg Script file could not be written Le fichier du script n’a pas pu être écrit @msg Script file dialogs need a person to answer them Les boîtes de dialogue de fichiers du script ont besoin d’une personne pour y répondre @msg Script file is not open for writing Le fichier du script n’est pas ouvert en écriture -@msg Script file is read-only Le fichier du script est en lecture seule -@msg Script file is open for writing Le fichier du script est ouvert en écriture @msg Script file name is already in use Le nom du fichier du script est déjà utilisé @msg Script file name must be a name without a folder Le nom du fichier du script doit être un nom sans dossier @msg Script file permission can be kept only for a script run from a file L’autorisation d’accès aux fichiers ne peut être conservée que pour un script exécuté depuis un fichier diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 567cf5740c..986e007efc 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7793,8 +7793,6 @@ liquify-list-end {0}, {1} {0} और {1} @msg Script file could not be written स्क्रिप्ट फ़ाइल लिखी नहीं जा सकी @msg Script file dialogs need a person to answer them स्क्रिप्ट के फ़ाइल डायलॉग को उत्तर देने के लिए किसी व्यक्ति की ज़रूरत है @msg Script file is not open for writing स्क्रिप्ट फ़ाइल लिखने के लिए खुली नहीं है -@msg Script file is read-only स्क्रिप्ट फ़ाइल केवल पढ़ने के लिए है -@msg Script file is open for writing स्क्रिप्ट फ़ाइल लिखने के लिए खुली है @msg Script file name is already in use स्क्रिप्ट फ़ाइल का नाम पहले से उपयोग में है @msg Script file name must be a name without a folder स्क्रिप्ट फ़ाइल का नाम बिना फ़ोल्डर वाला नाम होना चाहिए @msg Script file permission can be kept only for a script run from a file फ़ाइल अनुमति केवल फ़ाइल से चलाई गई स्क्रिप्ट के लिए रखी जा सकती है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index d7b576514a..ec8a60deaf 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5937,8 +5937,6 @@ liquify-list-end {0}, {1} {0} és {1} @msg Script file could not be written A parancsfájl fájlját nem sikerült írni @msg Script file dialogs need a person to answer them A parancsfájl fájlpárbeszédpaneleire egy személynek kell válaszolnia @msg Script file is not open for writing A parancsfájl fájlja nincs írásra megnyitva -@msg Script file is read-only A parancsfájl fájlja csak olvasható -@msg Script file is open for writing A parancsfájl fájlja írásra meg van nyitva @msg Script file name is already in use A parancsfájl fájljának neve már használatban van @msg Script file name must be a name without a folder A parancsfájl fájljának neve mappa nélküli név kell legyen @msg Script file permission can be kept only for a script run from a file A fájlengedély csak fájlból futtatott parancsfájlnál tartható meg diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 8445293d26..3b3069e023 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -8815,8 +8815,6 @@ breakText Glyphs Glif @msg Script file could not be written File skrip tidak dapat ditulis @msg Script file dialogs need a person to answer them Dialog file skrip memerlukan orang untuk menjawabnya @msg Script file is not open for writing File skrip tidak dibuka untuk ditulis -@msg Script file is read-only File skrip hanya dapat dibaca -@msg Script file is open for writing File skrip sedang dibuka untuk ditulis @msg Script file name is already in use Nama file skrip sudah digunakan @msg Script file name must be a name without a folder Nama file skrip harus berupa nama tanpa folder @msg Script file permission can be kept only for a script run from a file Izin file skrip hanya dapat disimpan untuk skrip yang dijalankan dari file diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 94715f0eff..8e7959999c 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5133,8 +5133,6 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file could not be written Impossibile scrivere il file dello script @msg Script file dialogs need a person to answer them Le finestre di dialogo dei file dello script richiedono una persona che risponda @msg Script file is not open for writing Il file dello script non è aperto in scrittura -@msg Script file is read-only Il file dello script è di sola lettura -@msg Script file is open for writing Il file dello script è aperto in scrittura @msg Script file name is already in use Il nome del file dello script è già in uso @msg Script file name must be a name without a folder Il nome del file dello script deve essere un nome senza cartella @msg Script file permission can be kept only for a script run from a file Il permesso sui file può essere mantenuto solo per uno script eseguito da un file diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index c6e123c242..d14fc0f723 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5968,8 +5968,6 @@ liquify-list-end {0}, {1} {0}、{1} @msg Script file could not be written スクリプトのファイルを書き込めませんでした @msg Script file dialogs need a person to answer them スクリプトのファイルダイアログには応答する人が必要です @msg Script file is not open for writing スクリプトのファイルが書き込み用に開かれていません -@msg Script file is read-only スクリプトのファイルは読み取り専用です -@msg Script file is open for writing スクリプトのファイルが書き込み用に開かれています @msg Script file name is already in use スクリプトのファイル名はすでに使用されています @msg Script file name must be a name without a folder スクリプトのファイル名はフォルダーを含まない名前にしてください @msg Script file permission can be kept only for a script run from a file ファイルの許可を保持できるのは、ファイルから実行したスクリプトだけです diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 47cabd5226..1991d156eb 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -8638,8 +8638,6 @@ liquify-list-end {0}, {1} {0} და {1} @msg Script file could not be written სკრიპტის ფაილის ჩაწერა ვერ მოხერხდა @msg Script file dialogs need a person to answer them სკრიპტის ფაილის დიალოგებს სჭირდება ადამიანი, რომელიც უპასუხებს @msg Script file is not open for writing სკრიპტის ფაილი ჩასაწერად გახსნილი არ არის -@msg Script file is read-only სკრიპტის ფაილი მხოლოდ წასაკითხია -@msg Script file is open for writing სკრიპტის ფაილი ჩასაწერად გახსნილია @msg Script file name is already in use სკრიპტის ფაილის სახელი უკვე გამოიყენება @msg Script file name must be a name without a folder სკრიპტის ფაილის სახელი უნდა იყოს სახელი საქაღალდის გარეშე @msg Script file permission can be kept only for a script run from a file ფაილების ნებართვის შენახვა შესაძლებელია მხოლოდ ფაილიდან გაშვებული სკრიპტისთვის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 0e2f433152..005f8284ea 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5897,8 +5897,6 @@ liquify-list-end {0}, {1} {0} 및 {1} @msg Script file could not be written 스크립트 파일을 쓸 수 없습니다 @msg Script file dialogs need a person to answer them 스크립트 파일 대화 상자에는 응답할 사람이 필요합니다 @msg Script file is not open for writing 스크립트 파일이 쓰기용으로 열려 있지 않습니다 -@msg Script file is read-only 스크립트 파일이 읽기 전용입니다 -@msg Script file is open for writing 스크립트 파일이 쓰기용으로 열려 있습니다 @msg Script file name is already in use 스크립트 파일 이름이 이미 사용 중입니다 @msg Script file name must be a name without a folder 스크립트 파일 이름은 폴더 없는 이름이어야 합니다 @msg Script file permission can be kept only for a script run from a file 파일 권한은 파일에서 실행한 스크립트에만 유지할 수 있습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index e9293a7be3..731173eea6 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -90,8 +90,6 @@ @msg Script file could not be written Het scriptbestand kon niet worden geschreven @msg Script file dialogs need a person to answer them Dialoogvensters voor scriptbestanden moeten door een persoon worden beantwoord @msg Script file is not open for writing Het scriptbestand is niet geopend voor schrijven -@msg Script file is read-only Het scriptbestand is alleen-lezen -@msg Script file is open for writing Het scriptbestand is geopend voor schrijven @msg Script file name is already in use De naam van het scriptbestand is al in gebruik @msg Script file name must be a name without a folder De naam van het scriptbestand moet een naam zonder map zijn @msg Script file permission can be kept only for a script run from a file Toestemming voor scriptbestanden kan alleen worden bewaard voor een script dat vanuit een bestand wordt uitgevoerd diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index e97c78e081..9152459071 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5235,8 +5235,6 @@ liquify-list-end {0}, {1} {0} i {1} @msg Script file could not be written Nie można zapisać pliku skryptu @msg Script file dialogs need a person to answer them Okna dialogowe plików skryptu wymagają osoby, która na nie odpowie @msg Script file is not open for writing Plik skryptu nie jest otwarty do zapisu -@msg Script file is read-only Plik skryptu jest tylko do odczytu -@msg Script file is open for writing Plik skryptu jest otwarty do zapisu @msg Script file name is already in use Nazwa pliku skryptu jest już używana @msg Script file name must be a name without a folder Nazwa pliku skryptu musi być nazwą bez folderu @msg Script file permission can be kept only for a script run from a file Uprawnienie do plików można zachować tylko dla skryptu uruchomionego z pliku diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 87f2ac800b..b49b217c8f 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -6280,8 +6280,6 @@ liquify-list-end {0}, {1} {0} e {1} @msg Script file could not be written Não foi possível gravar o arquivo do script @msg Script file dialogs need a person to answer them As caixas de diálogo de arquivo do script precisam de uma pessoa para respondê-las @msg Script file is not open for writing O arquivo do script não está aberto para gravação -@msg Script file is read-only O arquivo do script é somente leitura -@msg Script file is open for writing O arquivo do script está aberto para gravação @msg Script file name is already in use O nome do arquivo do script já está em uso @msg Script file name must be a name without a folder O nome do arquivo do script deve ser um nome sem pasta @msg Script file permission can be kept only for a script run from a file A permissão de arquivos só pode ser mantida para um script executado a partir de um arquivo diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index decd022096..eec9216b69 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5128,8 +5128,6 @@ liquify-list-end {0}, {1} {0} и {1} @msg Script file could not be written Не удалось записать файл скрипта @msg Script file dialogs need a person to answer them Для ответа на файловые диалоги скрипта нужен человек @msg Script file is not open for writing Файл скрипта не открыт для записи -@msg Script file is read-only Файл скрипта доступен только для чтения -@msg Script file is open for writing Файл скрипта открыт для записи @msg Script file name is already in use Имя файла скрипта уже используется @msg Script file name must be a name without a folder Имя файла скрипта должно быть именем без папки @msg Script file permission can be kept only for a script run from a file Разрешение на файлы можно сохранить только для скрипта, запущенного из файла diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index f014e5d79e..a4184199a4 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5001,8 +5001,6 @@ liquify-list-end {0}, {1} {0} och {1} @msg Script file could not be written Skriptets fil kunde inte skrivas @msg Script file dialogs need a person to answer them Skriptets fildialoger behöver en person som svarar på dem @msg Script file is not open for writing Skriptets fil är inte öppen för skrivning -@msg Script file is read-only Skriptets fil är skrivskyddad -@msg Script file is open for writing Skriptets fil är öppen för skrivning @msg Script file name is already in use Namnet på skriptets fil används redan @msg Script file name must be a name without a folder Namnet på skriptets fil måste vara ett namn utan mapp @msg Script file permission can be kept only for a script run from a file Filbehörighet kan bara behållas för ett skript som körs från en fil diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 78997530b9..6f1d616aca 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4831,8 +4831,6 @@ liquify-list-end {0}, {1} {0} ve {1} @msg Script file could not be written Betiğin dosyası yazılamadı @msg Script file dialogs need a person to answer them Betiğin dosya iletişim kutularının yanıtlanması için bir kişi gerekir @msg Script file is not open for writing Betiğin dosyası yazmak için açık değil -@msg Script file is read-only Betiğin dosyası salt okunur -@msg Script file is open for writing Betiğin dosyası yazmak için açık @msg Script file name is already in use Betiğin dosya adı zaten kullanılıyor @msg Script file name must be a name without a folder Betiğin dosya adı klasör içermeyen bir ad olmalıdır @msg Script file permission can be kept only for a script run from a file Dosya izni yalnızca bir dosyadan çalıştırılan betik için saklanabilir diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index f13fd4a094..89c20c44a5 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5117,8 +5117,6 @@ liquify-list-end {0}, {1} {0} і {1} @msg Script file could not be written Не вдалося записати файл скрипту @msg Script file dialogs need a person to answer them Для відповіді на файлові діалоги скрипту потрібна людина @msg Script file is not open for writing Файл скрипту не відкрито для запису -@msg Script file is read-only Файл скрипту доступний лише для читання -@msg Script file is open for writing Файл скрипту відкрито для запису @msg Script file name is already in use Ім’я файлу скрипту вже використовується @msg Script file name must be a name without a folder Ім’я файлу скрипту має бути іменем без папки @msg Script file permission can be kept only for a script run from a file Дозвіл на файли можна зберегти лише для скрипту, запущеного з файлу diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 407e46823f..d358d49544 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5627,8 +5627,6 @@ liquify-list-end {0}, {1} {0} và {1} @msg Script file could not be written Không thể ghi tệp của tập lệnh @msg Script file dialogs need a person to answer them Hộp thoại tệp của tập lệnh cần một người trả lời @msg Script file is not open for writing Tệp của tập lệnh chưa được mở để ghi -@msg Script file is read-only Tệp của tập lệnh ở chế độ chỉ đọc -@msg Script file is open for writing Tệp của tập lệnh đang được mở để ghi @msg Script file name is already in use Tên tệp của tập lệnh đã được sử dụng @msg Script file name must be a name without a folder Tên tệp của tập lệnh phải là một tên không có thư mục @msg Script file permission can be kept only for a script run from a file Chỉ có thể giữ quyền truy cập tệp cho tập lệnh chạy từ một tệp diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 3c2d9eedda..c48a32148a 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5624,8 +5624,6 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file could not be written 无法写入脚本的文件 @msg Script file dialogs need a person to answer them 脚本的文件对话框需要有人回答 @msg Script file is not open for writing 脚本的文件未以写入方式打开 -@msg Script file is read-only 脚本的文件为只读 -@msg Script file is open for writing 脚本的文件已以写入方式打开 @msg Script file name is already in use 脚本的文件名已被使用 @msg Script file name must be a name without a folder 脚本的文件名必须是不含文件夹的名称 @msg Script file permission can be kept only for a script run from a file 只有从文件运行的脚本才能保留文件权限 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index d79d239334..58c451afd6 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2968,8 +2968,6 @@ liquify-list-end {0}, {1} {0}和{1} @msg Script file could not be written 無法寫入指令碼的檔案 @msg Script file dialogs need a person to answer them 指令碼的檔案對話框需要有人回應 @msg Script file is not open for writing 指令碼的檔案未以寫入方式開啟 -@msg Script file is read-only 指令碼的檔案為唯讀 -@msg Script file is open for writing 指令碼的檔案已以寫入方式開啟 @msg Script file name is already in use 指令碼的檔案名稱已在使用中 @msg Script file name must be a name without a folder 指令碼的檔案名稱必須是不含資料夾的名稱 @msg Script file permission can be kept only for a script run from a file 只有從檔案執行的指令碼才能保留檔案權限 From 4021d27d5a9d71269baf7107e4d8e92a8e3015eb Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 11:27:37 -0800 Subject: [PATCH 033/264] Format the native layer appearance regressions --- crates/ui-egui/src/panels/layers/tests.rs | 31 +++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 6ca4cefe9c..29ea72202a 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -797,10 +797,13 @@ fn appearance_diamond(shape: &egui::Shape) -> Option<(egui::Pos2, f32, f32)> { fn target_marks_painted(panel: &mut crate::tests::panel_harness::Panel, name: &str) -> Vec<(f32, bool, f32)> { let center = panel.rect(name).center(); let (shapes, _) = panel.paint_at(1.0); - let ink = shapes.iter().find_map(|shape| match shape { - egui::Shape::Circle(circle) if circle.center.distance(center) < 0.01 && (circle.radius - 5.0).abs() < 1e-4 => Some(circle.stroke.color), - _ => None, - }).expect("the cell's outer target ring"); + let ink = shapes + .iter() + .find_map(|shape| match shape { + egui::Shape::Circle(circle) if circle.center.distance(center) < 0.01 && (circle.radius - 5.0).abs() < 1e-4 => Some(circle.stroke.color), + _ => None, + }) + .expect("the cell's outer target ring"); for shape in &shapes { if appearance_diamond(shape).is_some_and(|(at, _, _)| at.distance(center) < 0.01) && let egui::Shape::Path(path) = shape @@ -809,11 +812,17 @@ fn target_marks_painted(panel: &mut crate::tests::panel_harness::Panel, name: &s assert_eq!(path.stroke.kind, egui::StrokeKind::Middle, "the diamond's stroke is centered on its outline"); } } - let mut marks: Vec<_> = shapes.iter().filter_map(|shape| match shape { - egui::Shape::Circle(circle) if circle.center.distance(center) < 0.01 && circle.radius < 5.0 - && circle.fill == egui::Color32::TRANSPARENT => Some((circle.radius, false, circle.stroke.width)), - shape => appearance_diamond(shape).filter(|(at, _, _)| at.distance(center) < 0.01).map(|(_, r, width)| (r, true, width)), - }).collect(); + let mut marks: Vec<_> = shapes + .iter() + .filter_map(|shape| match shape { + egui::Shape::Circle(circle) + if circle.center.distance(center) < 0.01 && circle.radius < 5.0 && circle.fill == egui::Color32::TRANSPARENT => + { + Some((circle.radius, false, circle.stroke.width)) + } + shape => appearance_diamond(shape).filter(|(at, _, _)| at.distance(center) < 0.01).map(|(_, r, width)| (r, true, width)), + }) + .collect(); marks.sort_by(|a, b| a.0.total_cmp(&b.0)); marks } @@ -845,7 +854,9 @@ fn a_targeted_circle_with_an_appearance_shows_both_ring_and_dot() { assert!((alone.0 - 2.5).abs() < 1e-4); let looks = [&neither, &targeted, &styled, &both]; for (i, x) in looks.iter().enumerate() { - for y in &looks[i + 1..] { assert_ne!(x, y, "all four actual cell looks differ"); } + for y in &looks[i + 1..] { + assert_ne!(x, y, "all four actual cell looks differ"); + } } } From f26086c58b2f0bf08ccfa2fe9cb8acc4c3a861c5 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 12:30:14 -0800 Subject: [PATCH 034/264] Describe the hollow diamond in current Layers feature rows --- docs/roadmap.md | 2 +- docs/target-app-parity.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/roadmap.md b/docs/roadmap.md index f8ada20777..b4f19e07a8 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -188,7 +188,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | # | Milestone | Status | Est. remaining, one agent (h) | |---|---|---|---| | M0 | Skeleton + vertical slice | ✅ done | — | -| M1 | Selection, transform, layers, MCP (common command tools, strict keys, session resources and version-aware result hints) | ✅ mostly done (a targeted Layers item with an appearance of its own shows its inner ring around a smaller appearance dot (#8711); path and compound-path interior selection follows enabled fill rows (#6625); a marquee leaves locked or hidden guide paths out inside groups, as clicks do (#8538); hidden-fill and no-fill stroke cap/join CPU regressions passed; document-tab artwork drag with lossless resource transfer and one target Undo; malformed MCP app replies discard the connection without replay, #1761; bounded control socket waits and connection-slot recovery, #1726; bounded synthetic control input, #1709; no-op anchor Align keeps Undo, Redo and saved state (#1180 follow-up); transform reference point snaps to anchors/centres; rotated objects keep a rotated bounding box and their angle; Free Transform, Scale and Reflect along a rotated box pending; the Transform fields take one Tab each, the W/H link after them); Layers own appearance has a hollow diamond and tooltip distinct from targeting/selection (#8710), retaining Hassan1305's #8757 ring-visibility fix; validation pending | 4–6 | +| M1 | Selection, transform, layers, MCP (common command tools, strict keys, session resources and version-aware result hints) | ✅ mostly done (a targeted Layers item with an appearance of its own shows its inner ring around a smaller hollow diamond (#8711); path and compound-path interior selection follows enabled fill rows (#6625); a marquee leaves locked or hidden guide paths out inside groups, as clicks do (#8538); hidden-fill and no-fill stroke cap/join CPU regressions passed; document-tab artwork drag with lossless resource transfer and one target Undo; malformed MCP app replies discard the connection without replay, #1761; bounded control socket waits and connection-slot recovery, #1726; bounded synthetic control input, #1709; no-op anchor Align keeps Undo, Redo and saved state (#1180 follow-up); transform reference point snaps to anchors/centres; rotated objects keep a rotated bounding box and their angle; Free Transform, Scale and Reflect along a rotated box pending; the Transform fields take one Tab each, the W/H link after them); Layers own appearance has a hollow diamond and tooltip distinct from targeting/selection (#8710), retaining Hassan1305's #8757 ring-visibility fix; validation pending | 4–6 | | M2 | Drawing tools + smart guides | ✅ mostly done (Eraser preserves fill outside fixed and varied tip sweeps and Alt-drag marquees on fill-only open paths and keeps their compound holes; clipping masks retain surviving contours or empty geometry in the same node; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; hidden Rasterize and Along/Across stroke rows do not block visible gradients; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior (#6582); #3380 deletion creates independent selected path pieces and keeps bounds-fitted gradients in place; endpoint highlighting remains open; Polygon/Star exact-size count persistence, with repeated-drag, tool-switch and Cancel regression coverage; Curvature point markers without direction handles (#1236, in part); Direct Selection segment click/Delete preserves neighboring edges, #1278; Flare, Reshape, Live Corners widget dragging and per-corner radii and kinds landed, on any path's corners; Shaper rough-shape recognition and orientation steps, the remaining Pen modifier nuances; Shaper Groups with editable sources and separate fill/stroke edits landed; custom ruler origin with drag preview, active-artboard reset, relative X/Y fields and native round-trip (#1212); construction widget/refinements pending); a shape just drawn moves by its centre point and turns from the zone outside a corner with its tool still active (#5477); Tangent and straight-segment perpendicular snapping use saved Smart Guides Geometric Guides preferences and Control bar quick access (#2537), including the existing Snap to Glyph and Alignment Guides toggles (#6164); no View submenu; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123); Scissors hover and cuts use the Pen's path/align/intersect/anchor snaps, with Alt Add Anchor and cut endpoint selection retained (#6470); Scissors previews the current anchor or curve cut point (#8655) | 12–18 | | M3 | Paint & appearance (swatches, color, gradient, stroke, appearance, transparency, styles) | ✅ done (M3.7–M3.98): swatches, groups, libraries, tints, Lab spots and Registration; Eyedropper copies transformed character dimensions (#6404) and styles highlighted text only (atomic transparency rejection); Eyedropper reads visible locked and outside-isolation sources (#1251); Color Picker, Color panel (its spectrum grows with a resized panel, #8005), Color Guide, Color Themes, Edit Colors and Recolor Artwork (screen-bounded Edit chip list, #3416; native Lab entry and swatch libraries in the picker, Assign-row menus, #8031/#4028; Recolor with Preset asks whether to limit the colors to a swatch library first); gradients that follow every transform, the annotator, linked stops, freeform gradients, focal points, gradients on strokes and Expand; visible strokes when paint is added to inherited None/zero-width art (#1253); stroke geometry, arrowheads, dashes fitted to corners, stroke on type, width profiles and the Width tool (Shift-double-click enables adjoining adjustment in Width Point Edit; finite-arithmetic follow-up regressions and full CI passed ([Validation evidence](target-app-parity.md#evidence-what-ships-today-by-area))), Scale Strokes and preview bounds; Appearance targeting, container appearance, target circles, Expand Appearance; knockout, isolation, blend accuracy, CMYK blending, overprint, Attributes, masks and clipping, Flatten Transparency; graphic styles, links and libraries; CSS library export preserves fractional linear and radial gradient stop positions. Left: freeform gradients in SVG/PDF, mixed spot/process gradients in SVG and PDF gradients mixing a spot color with RGB or Lab stops export as stops or process colors; PDF export writes dithered gradient fills with spot stops, and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, as images in process colors; confirm the Scale Strokes & Effects default; Recolor model selection is available through the engine and MCP only (#2520); the dialog retains its existing controls; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Graphic Styles list fills a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); | 4–8 | | M4 | Files (native, SVG, PDF, raster, Export for Screens, clipboard interop) | `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths (#8128; estimates unchanged); Production Preflight checks fonts, overflow, links and image resolution with clickable findings and automatic rechecking (VectorCraft addition; estimates unchanged); PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked (#8300; estimates unchanged); PDF import: type filled and stroked by one text-showing operator comes in as one filled and stroked type object (#8015; not for type filled and stroked at less than full opacity, which still comes in as a filled object and a stroked one, as the file composites them; estimates unchanged); PDF import: type filled and stroked by a `TJ` whose kerning starts a new line part way through comes in filled and stroked, a type object for each part, also where it draws a glyph again where it drew one, in an `ActualText` span too, where it stays one replacement type object on the first glyph's line and in its style; a `TJ` over more than 65 lines (the 64 its fill pass finished, kept back, and the open one) stays a filled object and a stroked one for each part (#8543; estimates unchanged); PDF import: type filled and stroked after a page of type filled only (more than 64 lines) comes in as one filled and stroked type object again, with or without a path between, and a `TJ` over more lines than are kept with a glyph kept as an outline still stays a filled object and a stroked one for each part (#8549 follow-up; estimates unchanged); PDF import: stroked type keeps the file's line cap, line join and miter limit (#7741; estimates unchanged); Rename artboards in Export for Screens (#7275); Explicit editing-data import keeps oversized capped-page artboards (#6865; estimates unchanged); Save refusal continuation (#6146): ordinary Save offers Save As; unchanged format keeps options, changed format opens its Save options; cancellation/automation isolation; focused UI regressions passed, native acceptance pending; PDF authored ActualText preserved once in editable import (#6165; first-glyph line/style, bounded input; estimates unchanged); PDF export keeps harakat and zero-advance Noto Arabic dot glyphs in one compatible batch per layout line, with per-glyph vertical offsets (#6309). `crates/pdf/src/tests/realtext.rs` (`mark_text_*`) checks decoded cluster mappings, mixed Arabic/Latin/digits, contour placement against outline export, vertical columns, differing path rotations and PDF/X-1a/3/4. Editable-text import preserves authored ActualText separately (#6165), with cross-line/style layout limits; separately styled or differently rotated clusters and external viewer search/copy remain outside this export-only evidence. `.ai`/EPS type from the text document keeps its paragraphs' tab stops (#6147); `.ai`/EPS type from the text document keeps auto leading per line, its hyphenation options, and may show more of the last lines the file sets in an area frame of its own, when growing the frame by its lines' deepest descent plus 0.05 pt shows them (#6137); ✅ done (M4.14–M4.98 on 2026-10-05): Save As/Save a Copy/Revert/templates, Data Recovery and background save, SVG import and export fidelity (units, text, symbols, filters, SVGZ, Preserve Editing, SVG Options), shared guarded PDF writer and windowed reader ([pdf-backend.md](pdf-backend.md)), PDF import (colours, layers, masks, editable text, security) and export (presets, marks, bleed, ICC and output intent, raster effects, subset fonts, PDF/X-1a, X-3 and X-4, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3), Place and Links, Package, EPS and DXF in and out (EPS legacy mesh corners, vector opacity masks and raster page comparison verified; closed SPLINE flags round-trip and circular paths export as native CIRCLE/ARC, #1299), EMF/WMF, TIFF/BMP/Targa/PSD/GIF/PNG-8 export, Print and print presets, slices, Save for Web, TIFF in Export for Screens and Asset Export, clipboard flavours, File Info; AF.1–AF.4 add Affinity import (native layers, artboards, vectors, text and images from Affinity 1–3 files; the embedded preview only as a warned fallback; AF.4 expands current `.af` fixtures and every-board round-trip validation); EPS Save and Save As keep an opened EPS as EPS with its page frame and complete editable VectorCraft document (2026-10-26; G9 import fidelity unchanged). Left: DWG (use DXF), PSD placement as layers, overprint read back from PDF, Affinity export, polish; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; PDF import: glyphs inside a marked-content span with an empty `ActualText` come in as outlines in their fill and stroke, adding no text (#6971; scores and estimates unchanged); | 3–6 (existing scope; Affinity export unestimated) | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e0c7ac9998..c763d8e4b6 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -796,7 +796,7 @@ since 2026-10-01. - **Ctrl/Cmd-click and Shift-click on Layers panel target circles (#8639):** the target circles follow the same modifier rules as the row names, as the help page describes for selecting objects in the Layers panel: Shift for adjacent objects, Ctrl or Command for non-adjacent ones ([Move objects to different layers](https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/move-objects-to-different-layers.html)). Ctrl/Cmd-click adds the item (a layer: its art) to the selection or takes it out, which Shift-click did before (#913); Shift-click selects the art of every row from the last circle clicked (else the targeted row) to this one, and Shift+Ctrl/Cmd-click adds it (`layer.target {range, add?}`). Hidden or locked art and art outside the isolated group in the range is left out, and nothing stays targeted. Regression tests: `clicking_a_target_circle_targets_the_layer` and `shift_clicking_a_target_circle_selects_a_range_of_rows` in `crates/ui-egui/src/panels/layers/tests.rs`. - **Shift-click in the Layers panel's selection column selects the art of a range of rows:** after a selection square is clicked, Shift-clicking another selects the art of every row listed from the last square clicked to this one, down or up and across sublayers and groups, and Shift+Ctrl/Cmd-click adds that art to the selection (`layer.selectAll {range, add?}`). Hidden and locked rows and art outside the isolated group are left out, and a range does not move where the next Shift-click starts. Ctrl/Cmd-click adds one row's art or takes it out, and so does Shift-click before any square was clicked. The panel menu's Select Art of Highlighted Rows (`layer.selectHighlighted`) selects the art of the highlighted rows by the same rules. These are VectorCraft's own rules. Regression tests: `shift_clicking_a_selection_square_selects_the_art_of_a_range_of_rows` and `shift_clicking_the_first_selection_square_adds_or_removes_one_row` in `crates/ui-egui/src/panels/layers/tests.rs`, `the_selection_column_selects_the_art_of_a_range_of_rows` and `select_highlighted_selects_the_art_of_the_highlighted_rows` in `crates/engine/src/tests/layers.rs`. - **Layers added to the selection from their target circles show as targeted (#8646):** with several items picked from their circles (nothing targeted), a layer or sublayer's circle shows its inner ring while all of its visible, unlocked art is selected, as an object's circle does while the object is selected. A layer is never selected itself, only its art, so its circle used to keep a single ring. Regression test: `a_layer_added_from_its_target_circle_shows_as_targeted` in `crates/ui-egui/src/panels/layers/tests.rs`. -- **A targeted item with an appearance of its own shows both marks (#8711):** its target circle keeps the inner ring of a targeted item, with the appearance dot drawn smaller inside it and a gap between them, so not targeted, targeted, with an appearance and both look different, as the target icons in [Appearance attributes](https://helpx.adobe.com/illustrator/using/appearance-attributes.html) do. The dot used to cover the ring. Regression test: `a_targeted_circle_with_an_appearance_shows_both_ring_and_dot` in `crates/ui-egui/src/panels/layers/tests.rs`. +- **A targeted item with an appearance of its own shows both marks (#8711):** its target circle keeps the inner ring of a targeted item, with the hollow diamond drawn smaller inside it and a gap between them, so not targeted, targeted, with an appearance and both look different, as the target icons in [Appearance attributes](https://helpx.adobe.com/illustrator/using/appearance-attributes.html) do. The dot used to cover the ring. Regression test: `a_targeted_circle_with_an_appearance_shows_both_ring_and_dot` in `crates/ui-egui/src/panels/layers/tests.rs`. - **Selection passes through raster effects:** clicks with the Selection, Direct Selection and Group Selection tools (Group Selection's repeated click included), the Selection tool's pointer and marquee, Direct Selection's marquee, pointer and anchor highlight, and Group Selection's marquee (E for enclosed objects included) leave out the area that a drop shadow, a glow, a blur or another raster effect paints beyond an object. A click on a shadow selects the object under it, or nothing over an empty canvas, a repeated Group Selection click there adds the groups of the object under it, and a press on the shadow of a selected object does not move it ([the help page](https://helpx.adobe.com/illustrator/using/selecting-objects.html)). Over a shadow, Direct Selection highlights only the anchors of the object under it, and Group Selection keeps its own pointer and highlights no anchor, as it does everywhere (VectorCraft's own rule). No setting changes this. This covers paths, groups, type, symbol instances and images. Regression tests: `crates/engine/src/tests/select_effects.rs`. - **Symbol instances are selected where their art draws past their box:** a click or a marquee selects a symbol instance where a clipping path in its art, moved or reshaped by its live geometry effects, shows the art past the instance's box, as it selects a group of the same art; a click also selects it where a stroke in its art paints past the box ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/select-objects.html)). The rest is VectorCraft's own rule: inside the box the instance is selected as before; in Outline view and below a layer whose Preview is off only the box counts; hidden art and the area a raster effect paints are left out. This covers instances in groups, nested in other symbols' art, moved and scaled. Regression tests: `a_symbol_instance_is_hit_where_a_moved_clipping_path_in_its_art_shows_the_art` and `a_symbol_instance_is_hit_on_the_stroke_of_its_art_past_its_box` in `crates/doc/src/hit/tests.rs`. - **Selection follows geometry effects:** a click or a marquee with the selection tools selects a path or compound path where its live geometry effects (Transform, Offset Path, Roughen, Zig Zag and the other effects that reshape a path, on the object or on its fills and strokes) draw it, the copies a Transform effect makes included, and not where its own geometry no longer paints. The members of a group or layer whose own geometry effects move or reshape them are selected where they are drawn, at the depth each tool selects, and a locked member there lets the click through to what is below and is listed there in the Unlock submenu. A group's own fills and strokes are clicked where they paint its members, and a clipping path inside such a group is taken on its drawn outline before the art it clips. A compound path keeps its holes, Object Selection by Path Only takes the drawn outline and not its fill, and stacking order is kept. The selection tools select objects by clicking or by a marquee ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/select-objects.html)), and the effects leave the art they reshape editable ([the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/apply-and-modify-effects.html)); where clicks land on the reshaped art is VectorCraft's own rule. In Outline view clicks and marquees use the plain paths, and in a layer with Preview off they take outlines only. The area a raster effect paints is still left out. Regression tests: `a_*_shifted_art_*`, `a_click_hits_a_paths_copy_and_evaluates_its_art_once_until_it_changes`, `a_groups_own_effect_moves_where_its_members_are_hit`, `a_layers_own_effect_moves_where_its_art_is_hit`, `a_preview_off_sublayer_of_an_effected_layer_is_clicked_in_outline`, `a_painted_group_around_an_effected_symbols_instance_is_hit_where_its_art_is_drawn`, `an_intertwine_group_in_a_layers_drawn_art_is_hit_in_its_woven_order`, `a_click_in_a_plain_group_evaluates_only_its_member_with_effects`, `a_clip_groups_own_effect_moves_where_its_mask_outline_is_hit`, `an_isolated_clip_group_with_its_own_effect_is_marqueed_by_its_members_own_geometry` and `a_clip_groups_art_is_hit_when_its_drawn_art_holds_only_the_clipping_path` in `crates/doc/src/hit/tests.rs`, and `a_click_and_a_marquee_select_art_where_its_transform_effect_draws_it`, `a_click_selects_a_group_where_its_own_fill_paints_a_moved_member`, `a_marquee_takes_an_inner_groups_own_fill_inside_a_painted_group` and `a_marquee_takes_a_groups_own_fill_inside_a_painted_layer` in `crates/engine/src/tests/select_effects.rs`. From 07378009102db84ab7221fa2f6742047088675d2 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 12:55:01 -0800 Subject: [PATCH 035/264] test: assert Layers target button pressed state --- crates/ui-egui/src/panels/layers/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 29ea72202a..205a9d0f74 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -882,7 +882,7 @@ fn appearance_marker_names_its_state_and_keeps_targeting_actions() { let active = "Target appearance: targeted, additional appearance or transparency"; assert_eq!(panel.description("Target A").as_deref(), Some(idle)); assert_eq!(panel.description("Target B").as_deref(), Some("Target appearance: not targeted, basic appearance")); - assert!(!panel.selected("Target A")); + assert_eq!(panel.toggled("Target A"), Some(craft::behavior::Mixed::Same(false))); let before = { let app = panel.app(); (app.session.active().unwrap().selection.clone(), undo_len(&app)) @@ -899,11 +899,11 @@ fn appearance_marker_names_its_state_and_keeps_targeting_actions() { panel.click("Target A"); assert_eq!(targeted(&panel.app()), (Some(a), vec![a])); assert_eq!(panel.description("Target A").as_deref(), Some(active)); - assert!(panel.selected("Target A")); + assert_eq!(panel.toggled("Target A"), Some(craft::behavior::Mixed::Same(true))); panel.click("Target B"); assert_eq!(panel.description("Target A").as_deref(), Some(idle)); assert_eq!(panel.description("Target B").as_deref(), Some("Target appearance: targeted, basic appearance")); - assert!(panel.selected("Target B")); + assert_eq!(panel.toggled("Target B"), Some(craft::behavior::Mixed::Same(true))); assert!(target_marks_painted(&mut panel, "Target A").iter().any(|m| m.1), "the appearance stays after targeting other art"); } From d48ea9a3c06ebdf5d2b567cc255483066ece432a Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 13:03:54 -0800 Subject: [PATCH 036/264] Remove the unused test selection helper --- crates/ui-egui/src/tests/panel_harness.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index 7251c04291..b596f3a1c8 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -378,11 +378,6 @@ impl Panel { tree.keys().into_iter().any(|key| tree.value_of(key).is_some_and(&matches)) } - /// Whether the control named `name` reports selected state. - pub(crate) fn selected(&self, name: &str) -> bool { - self.fixture.tree().selected_of(self.look(name).node).unwrap_or(false) - } - /// The toggle state of the control named `name`. // PLAN: assumed the facade re-exports the behavior crate's `Mixed` as `craft::behavior::Mixed`. pub(crate) fn toggled(&self, name: &str) -> Option> { From 53c57248adb0c1c926a3a677978c7eac0b21c5d1 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 15:02:33 -0800 Subject: [PATCH 037/264] Use the current stroke paint API in Properties --- crates/ui-egui/src/panels/properties/appearance_section.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/properties/appearance_section.rs b/crates/ui-egui/src/panels/properties/appearance_section.rs index cd71a0f035..e2ae112143 100644 --- a/crates/ui-egui/src/panels/properties/appearance_section.rs +++ b/crates/ui-egui/src/panels/properties/appearance_section.rs @@ -102,7 +102,7 @@ fn effect_delete(app: &mut VectorcraftApp, ui: &mut Ui, id: NodeId, effects: &[( /// active Appearance row in `PropertiesUi::edited_profiled`. False while the Type tool edits text or /// the Live Paint Bucket is active, when the list edits the stroke the panel shows. fn edited_strokes_profiled(app: &mut VectorcraftApp) -> bool { - if panels::character::text_editing(app).is_some() || app.session.bucket_paints() { + if panels::character::text_editing(app).is_some() || app.session.tool_paints(true) { return false; } let Some(st) = app.session.active() else { return false }; From 44afcbfb2aca52f692103c82d7a9dfa2676c16c3 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Fri, 27 Nov 2026 21:19:24 +0530 Subject: [PATCH 038/264] Spell-check other languages from the Craft apps' Language packs Part of #4936. Spelling and hyphenation now read the Language packs installed in the font store the Craft apps share, and proof.packs, proof.installPack and proof.removePack list, install and remove them. Installs need downloading on, which only the person turns on; in the desktop app they run in the background and the documents are laid out again when one ends. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 2 + Cargo.toml | 3 + apps/vectorcraft-cli/src/main.rs | 3 + apps/vectorcraft/src/main.rs | 4 + apps/vectorcraft/src/prefs_dir.rs | 8 + crates/engine/Cargo.toml | 4 + crates/engine/src/cmd.rs | 5 + crates/engine/src/cmd/packs.rs | 101 +++++++ crates/engine/src/cmd/spelling.rs | 7 +- crates/engine/src/lib.rs | 5 + crates/engine/src/packs.rs | 370 +++++++++++++++++++++++++ crates/engine/src/session/documents.rs | 1 + crates/engine/src/store.rs | 24 ++ crates/engine/src/tests.rs | 2 + crates/engine/src/tests/packs.rs | 219 +++++++++++++++ crates/ui-egui/src/app.rs | 5 + docs/gaps.md | 3 +- docs/mcp.md | 33 ++- 18 files changed, 794 insertions(+), 5 deletions(-) create mode 100644 crates/engine/src/cmd/packs.rs create mode 100644 crates/engine/src/packs.rs create mode 100644 crates/engine/src/tests/packs.rs diff --git a/Cargo.lock b/Cargo.lock index 28a8205997..3c9e8caff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8536,6 +8536,8 @@ dependencies = [ "craft-cdr", "craft-codepage", "craft-docpath", + "craft-font-catalog", + "craft-font-store", "craft-image-codecs", "craft-jxl", "craft-proof", diff --git a/Cargo.toml b/Cargo.toml index 51693818bb..4699191ed0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,9 @@ craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0", default-features = false, features = ["interpret", "write"] } craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } +# Language packs: the Craft apps' shared font store installs them (#4936). +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0" } diff --git a/apps/vectorcraft-cli/src/main.rs b/apps/vectorcraft-cli/src/main.rs index 2416b17b89..3064392942 100644 --- a/apps/vectorcraft-cli/src/main.rs +++ b/apps/vectorcraft-cli/src/main.rs @@ -201,6 +201,9 @@ fn main() -> ExitCode { #[cfg(target_os = "macos")] mac_fonts::install(); prefs_dir::install_fonts(); + // The Language packs installed in the shared font store; `proof.installPack` returns once + // installed. + prefs_dir::use_language_packs(); let mut args: Vec = std::env::args().skip(1).collect(); // Before any subcommand attaches the plug-in folder. let safe_mode = args.first().is_some_and(|a| a == "--safe-mode"); diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 8907fe4bd1..92178a9f4a 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -571,6 +571,10 @@ fn main() -> std::process::ExitCode { mac_fonts::install(); // VectorCraft's own Fonts folder, which text.addFontFiles copies fonts into. prefs_dir::install_fonts(); + // Language packs: installs and index fetches run on their own threads, so the window keeps + // working while a pack downloads. + prefs_dir::use_language_packs(); + vectorcraft_engine::packs::run_in_background(true); // The log file lives in the settings directory, next to the preferences; opened after the // arguments, so `--version` leaves no file behind. Records logged until now are written to it // first. Runs without preferences (agents' test runs) log to standard error only, so they diff --git a/apps/vectorcraft/src/prefs_dir.rs b/apps/vectorcraft/src/prefs_dir.rs index 8f1b50dd58..4a14bf6f79 100644 --- a/apps/vectorcraft/src/prefs_dir.rs +++ b/apps/vectorcraft/src/prefs_dir.rs @@ -24,6 +24,14 @@ pub fn install_fonts() { } } +/// Have spelling and hyphenation read the Language packs installed in the Craft apps' shared font +/// store (`proof.installPack`, or another Craft app), and install new ones there (#4936). Like the +/// Fonts folder, whether or not `VECTORCRAFT_NO_PREFS` is set: the packs are the store's, not +/// VectorCraft's preferences. +pub fn use_language_packs() { + vectorcraft_engine::packs::use_font_store(); +} + /// The folder `name` next to the settings, for what the user keeps: none in a run without /// preferences (`VECTORCRAFT_NO_PREFS`), which keeps nothing. fn store_dir(name: &str) -> Option { diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 6732c973f4..bc74ee5503 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -87,6 +87,10 @@ windows-native-keyring-store = "1.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] heic-rs = { version = "=0.1.4", default-features = false, features = ["std", "parallel"], optional = true } rayon = { version = "1.12", optional = true } +# Language packs (packs.rs): the shared font store installs them and finds its folder. Already in +# Cargo.lock (craft-font-manager), so this adds no new crate. +craft-font-store = { workspace = true } +craft-font-catalog = { workspace = true } # The MAC that `grants.json` carries (grant_keys.rs) and the random key it is made with, which the # user's key store keeps: Keychain on macOS, Credential Manager on Windows, the Secret Service on # Linux. All MIT OR Apache-2.0. diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index fbe46f41c8..76c9914a26 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -92,6 +92,8 @@ pub(crate) mod shaper; pub mod shortcutset; pub(crate) mod slices; pub mod spelling; +#[cfg(not(target_arch = "wasm32"))] +pub mod packs; mod stroke; mod style; pub use style::styled_node; @@ -381,6 +383,9 @@ pub fn command_specs() -> &'static [CommandSpec] { v.extend(tags::specs()); v.extend(interactivity::specs()); v.extend(spelling::specs()); + // Language packs need a font store, which the web build has none of. + #[cfg(not(target_arch = "wasm32"))] + v.extend(packs::specs()); v.extend(svgfilter::specs()); v.extend(newart::specs()); v.extend(colortheme::specs()); diff --git a/crates/engine/src/cmd/packs.rs b/crates/engine/src/cmd/packs.rs new file mode 100644 index 0000000000..9941596f59 --- /dev/null +++ b/crates/engine/src/cmd/packs.rs @@ -0,0 +1,101 @@ +//! Language packs as commands (#4936): list, install and remove the packs that spell-check and +//! hyphenate languages other than English ([`crate::packs`]). They open nothing and never turn +//! downloading on: an install needs the Craft apps' shared download setting, which only the person +//! using an app turns on. + +use serde_json::{Value, json}; + +use super::{CommandSpec, EngineError, Result, Session, always, bad, cmd, text_param}; +use crate::packs::{self, Outcome}; + +/// The Language pack commands. +pub fn specs() -> Vec { + vec![ + cmd!( + query "proof.packs", + "Language Packs", + [], + None, + "{refresh?: bool (fetch the pinned pack index again; needs downloading on; in the desktop app it runs in the background: see refreshing)} the Language packs that spell-check and hyphenate languages other than English, shared by the Craft apps → {packs: [{locale, name, size: bytes, licence: SPDX, class, spelling: bool, hyphenation: bool, installed: bool}…] (the index fetched last; empty before the first fetch), installed: [{locale, name, licence}…] (the packs spelling and hyphenation use), installing: [{locale, done, total}…] (bytes), refreshing: bool, errors: {locale: message} (the last failure of each install or removal; \"\": of the index fetch), downloads: bool (the person allowed downloading), indexOverride: string|null (a test index used instead of the pinned one), available: bool (there is a font store folder to install into)}", + always, + list + ), + cmd!( + query "proof.installPack", + "Install Language Pack", + [], + None, + "{locale: language tag (a pack's locale from proof.packs, like nl or pt-br)} downloads the pack, checks its sha256 and installs it; spelling and hyphenation in that language use it at once, in every open document. Needs downloading on, which only the person using a Craft app can turn on. Opens nothing. In the desktop app it runs in the background → {locale, started: true}: follow it with proof.packs (installing, then installed or errors); elsewhere it returns once installed → {locale, installed: true}", + always, + install + ), + cmd!( + query "proof.removePack", + "Remove Language Pack", + [], + None, + "{locale} removes the installed pack (not while it installs); that language is no longer checked with it → {locale, installed: false}", + always, + remove + ), + ] +} + +fn locale_param(p: &Value, command: &str) -> Result { + let raw = text_param(p, "locale", command)?.ok_or_else(|| bad(command, "`locale` (a language tag like nl) is required"))?; + packs::parse_locale(raw).map_err(|e| bad(command, e)) +} + +fn list(s: &mut Session, p: &Value) -> Result { + const C: &str = "proof.packs"; + match p.get("refresh") { + None | Some(Value::Null) | Some(Value::Bool(false)) => {} + Some(Value::Bool(true)) => { + packs::refresh().map_err(EngineError::Other)?; + } + Some(_) => return Err(bad(C, "`refresh` must be true or false")), + } + let installed = craft_proof::packs::installed(); + let backend = packs::backend(); + let rows: Vec = packs::available() + .iter() + .map(|p| { + json!({ + "locale": p.locale, "name": p.name, "size": p.size, "licence": p.licence, "class": p.class, + "spelling": p.spelling, "hyphenation": p.hyphenation, + "installed": installed.iter().any(|i| i.locale == p.locale), + }) + }) + .collect(); + let (installing, refreshing, errors) = packs::status(); + // An install that ended since the last frame shows in every document's layout. + s.poll_language_packs(); + Ok(json!({ + "packs": rows, + "installed": installed.iter().map(|i| json!({"locale": i.locale, "name": i.name, "licence": i.licence})).collect::>(), + "installing": installing.iter().map(|(l, done, total)| json!({"locale": l, "done": done, "total": total})).collect::>(), + "refreshing": refreshing, + "errors": errors, + "downloads": backend.as_ref().is_some_and(|b| b.downloads_on()), + "indexOverride": backend.as_ref().and_then(|b| b.index_override()), + "available": backend.is_some(), + })) +} + +fn install(s: &mut Session, p: &Value) -> Result { + let locale = locale_param(p, "proof.installPack")?; + match packs::install(&locale).map_err(EngineError::Other)? { + Outcome::Started => Ok(json!({"locale": locale, "started": true})), + Outcome::Done => { + s.poll_language_packs(); + Ok(json!({"locale": locale, "installed": true})) + } + } +} + +fn remove(s: &mut Session, p: &Value) -> Result { + let locale = locale_param(p, "proof.removePack")?; + packs::remove(&locale).map_err(EngineError::Other)?; + s.poll_language_packs(); + Ok(json!({"locale": locale, "installed": false})) +} diff --git a/crates/engine/src/cmd/spelling.rs b/crates/engine/src/cmd/spelling.rs index cd8b4890f2..ef238e7b91 100644 --- a/crates/engine/src/cmd/spelling.rs +++ b/crates/engine/src/cmd/spelling.rs @@ -325,10 +325,11 @@ pub fn misspellings_from(t: &TextObject, ignored: &BTreeSet, from: usize /// not, since a save takes in the words another window saved), and a dictionary file attached. static DICTIONARY_GENERATION: AtomicU64 = AtomicU64::new(0); -/// The custom dictionary's generation: what [`misspellings`] found before it last changed may be -/// out of date (Auto Spell Check checks the type again). +/// The dictionaries' generation: what [`misspellings`] found before it last changed may be out of +/// date (Auto Spell Check checks the type again). It moves on with the custom dictionary and with +/// craft-proof's own dictionaries, which change when a Language pack is installed or removed. pub fn dictionary_generation() -> u64 { - DICTIONARY_GENERATION.load(Ordering::Relaxed) + DICTIONARY_GENERATION.load(Ordering::Relaxed).wrapping_add(craft_proof::dictionary_generation()) } fn dictionary_changed() { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 722192a185..6694d6953f 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -12,6 +12,8 @@ pub mod guard; pub mod inspect; pub mod journal; pub mod link_watch; +#[cfg(not(target_arch = "wasm32"))] +pub mod packs; pub mod schemas; pub mod steps; pub mod store; @@ -216,6 +218,9 @@ pub struct Session { /// Whether the loads of the stored plug-ins and of the plug-ins folder go on after the call /// that starts them ([`Session::load_plugins_in_background`]). plugin_loads_in_background: bool, + /// The Language packs' generation the documents were last laid out for + /// ([`Session::poll_language_packs`]). + packs_seen: u64, /// The Scripts folder, whose scripts File › Scripts lists; `None`: no folder /// ([`Session::attach_scripts_dir`]). scripts_dir: Option, diff --git a/crates/engine/src/packs.rs b/crates/engine/src/packs.rs new file mode 100644 index 0000000000..ba1e85c3d0 --- /dev/null +++ b/crates/engine/src/packs.rs @@ -0,0 +1,370 @@ +//! Language packs (#4936, RFC-0011): the spelling dictionary, hyphenation patterns and licence +//! texts of a language other than English, published by storytold/craft-i18n and installed into the +//! Craft apps' shared font store (craft-libs `craft-font-store`, item kind `language-pack`), where +//! craft-proof reads them (`craft_proof::packs`). A pack installed by another Craft app is used +//! here too, since the apps share the store. +//! +//! The store downloads only while its download setting is on, which only the person using an app +//! turns on, with their own click. Nothing here turns it on: [`use_font_store`] opens the store as +//! an agent's, so `proof.installPack` from the CLI, MCP or a script installs only after the person +//! allowed downloads. +//! +//! The packs state is the process's, like craft-proof's: one backend ([`set_backend`]), one list of +//! installs running and one error per locale. In the desktop app installs run on a thread of their +//! own ([`run_in_background`]) and [`crate::Session::poll_language_packs`] lays out the documents +//! again when one ends; elsewhere they return once installed. + +use std::collections::BTreeMap; +use std::path::PathBuf; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard, PoisonError, RwLock}; + +pub use craft_font_store::Cancel; + +/// One pack the pack index lists. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Pack { + /// Lowercase BCP 47 tag (`nl`, `pt-br`), also the installed pack's folder name. + pub locale: String, + /// The language's own name (`Nederlands`). + pub name: String, + /// The download's size in bytes. + pub size: u64, + /// SPDX licence expression of the pack's data. + pub licence: String, + /// The licence class: `Embeddable` or `Download-only`. + pub class: String, + /// Whether it has a spelling dictionary. + pub spelling: bool, + /// Whether it has hyphenation patterns. + pub hyphenation: bool, +} + +/// Where packs come from and go to: the font store ([`use_font_store`]), or a stand-in in tests. +pub trait Backend: Send + Sync { + /// The installed-packs folder craft-proof reads. + fn packs_dir(&self) -> PathBuf; + /// Whether the person allowed downloads. + fn downloads_on(&self) -> bool; + /// The packs of the index fetched last, with no request; empty before the first fetch. + fn cached_index(&self) -> Vec; + /// Fetches the pinned pack index (needs downloads on). + fn fetch_index(&self, cancel: &Cancel) -> Result, String>; + /// Downloads, checks and installs the pack for `locale`, which the index lists (needs downloads + /// on), calling `progress(done, total)` in bytes. + fn install(&self, locale: &str, cancel: &Cancel, progress: &mut dyn FnMut(u64, u64)) -> Result<(), String>; + /// Removes the installed pack for `locale`. + fn remove(&self, locale: &str) -> Result<(), String>; + /// The test index used instead of the pinned one (`CRAFT_LANGUAGE_PACK_INDEX`), if any. + fn index_override(&self) -> Option { + None + } +} + +/// An install running. +struct Job { + done: u64, + total: u64, + cancel: Cancel, +} + +#[derive(Default)] +struct Jobs { + installing: BTreeMap, + /// A fetch of the index running. + refreshing: Option, + /// The last failure of each locale's install or removal, and of the index fetch (key `""`). + errors: BTreeMap, +} + +static BACKEND: RwLock>> = RwLock::new(None); +static JOBS: Mutex = Mutex::new(Jobs { installing: BTreeMap::new(), refreshing: None, errors: BTreeMap::new() }); +static BACKGROUND: AtomicBool = AtomicBool::new(false); +/// Goes up each time the installed packs change. +static GENERATION: AtomicU64 = AtomicU64::new(0); + +fn jobs() -> MutexGuard<'static, Jobs> { + JOBS.lock().unwrap_or_else(PoisonError::into_inner) +} + +/// Use `backend` for packs (`None`: none), and have craft-proof read its installed packs. +pub fn set_backend(backend: Option>) { + let dir = backend.as_ref().map(|b| b.packs_dir()); + *BACKEND.write().unwrap_or_else(PoisonError::into_inner) = backend; + craft_proof::packs::set_packs_dir(dir); + changed(); +} + +/// The backend [`set_backend`] set. +pub fn backend() -> Option> { + BACKEND.read().unwrap_or_else(PoisonError::into_inner).clone() +} + +/// Use the Craft apps' shared font store for packs, as an agent's store (it can't turn downloads +/// on): the desktop app and `vectorcraft-cli` call it at startup. Without a per-user folder there +/// are no packs. +pub fn use_font_store() { + let env = craft_font_catalog::FontEnv::from_process(); + set_backend(craft_font_store::FontStore::for_agent(&env).map(|store| Arc::new(FontStoreBackend::new(store)) as Arc)); +} + +/// Run installs and index fetches on a thread of their own (the desktop app, so its window keeps +/// working) instead of returning once they are done. +pub fn run_in_background(on: bool) { + BACKGROUND.store(on, Ordering::Relaxed); +} + +/// Goes up each time the installed packs change ([`crate::Session::poll_language_packs`]). +pub fn generation() -> u64 { + GENERATION.load(Ordering::Relaxed) +} + +/// Read the packs folder again: spelling and hyphenation in its languages change. +fn changed() { + craft_proof::packs::reload(); + GENERATION.fetch_add(1, Ordering::Relaxed); +} + +/// Whether an install or an index fetch is running. +pub fn busy() -> bool { + let j = jobs(); + !j.installing.is_empty() || j.refreshing.is_some() +} + +/// `raw` as a pack locale: trimmed, lower case, `_` read as `-` (`pt_BR` is `pt-br`); a language +/// tag of letters and digits, at most 35 bytes, in parts of at most 8. +pub fn parse_locale(raw: &str) -> Result { + let l = raw.trim().to_ascii_lowercase().replace('_', "-"); + let ok = !l.is_empty() + && l.len() <= 35 + && l.split('-').all(|p| !p.is_empty() && p.len() <= 8 && p.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit())); + if ok { Ok(l) } else { Err(format!("{:?} is not a language tag like nl or pt-br", raw.chars().take(40).collect::())) } +} + +fn no_backend() -> String { + "Language packs aren't available: there is no font store folder for this user".into() +} + +fn downloads_off() -> String { + "downloading is turned off; only the person using a Craft app can turn it on, by installing a Language pack there".into() +} + +/// The packs the index fetched last lists. +pub fn available() -> Vec { + backend().map(|b| b.cached_index()).unwrap_or_default() +} + +/// What `proof.packs` reports about the jobs: the installs running as (locale, done, total), whether +/// the index is being fetched, and the last error of each locale (`""`: the index). +pub fn status() -> (Vec<(String, u64, u64)>, bool, BTreeMap) { + let j = jobs(); + (j.installing.iter().map(|(l, job)| (l.clone(), job.done, job.total)).collect(), j.refreshing.is_some(), j.errors.clone()) +} + +/// What an install or a fetch did. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Outcome { + /// Done. + Done, + /// Running in the background ([`run_in_background`]). + Started, +} + +/// Runs `f` on a thread of its own in the background, else here. +fn run(f: impl FnOnce() + Send + 'static) -> Result { + if !BACKGROUND.load(Ordering::Relaxed) { + f(); + return Ok(Outcome::Done); + } + std::thread::Builder::new().name("language-pack".into()).spawn(f).map(|_| Outcome::Started).map_err(|e| format!("couldn't start the download: {e}")) +} + +/// Fetches the pinned pack index again. Needs downloads on. +pub fn refresh() -> Result { + let b = backend().ok_or_else(no_backend)?; + if !b.downloads_on() { + return Err(downloads_off()); + } + let cancel = { + let mut j = jobs(); + if j.refreshing.is_some() { + return Ok(Outcome::Started); + } + let cancel = Cancel::new(); + j.refreshing = Some(cancel.clone()); + j.errors.remove(""); + cancel + }; + let outcome = run(move || { + let r = b.fetch_index(&cancel); + let mut j = jobs(); + j.refreshing = None; + if let Err(e) = r { + j.errors.insert(String::new(), e); + } + }); + if outcome.is_err() { + jobs().refreshing = None; + } + let outcome = outcome?; + match jobs().errors.get("") { + Some(e) if outcome == Outcome::Done => Err(e.clone()), + _ => Ok(outcome), + } +} + +/// Installs the pack for `locale` (fetching the index first when it doesn't list it). Needs +/// downloads on. Spelling and hyphenation in that language use it once it is installed. +pub fn install(locale: &str) -> Result { + let b = backend().ok_or_else(no_backend)?; + if !b.downloads_on() { + return Err(downloads_off()); + } + let locale = locale.to_string(); + let cancel = { + let mut j = jobs(); + if j.installing.contains_key(&locale) { + return Ok(Outcome::Started); + } + let cancel = Cancel::new(); + j.installing.insert(locale.clone(), Job { done: 0, total: 0, cancel: cancel.clone() }); + j.errors.remove(&locale); + cancel + }; + let l = locale.clone(); + let outcome = run(move || { + let r = install_now(&*b, &l, &cancel); + if r.is_ok() { + changed(); + } + let mut j = jobs(); + j.installing.remove(&l); + if let Err(e) = r { + j.errors.insert(l, e); + } + }); + if outcome.is_err() { + jobs().installing.remove(&locale); + } + let outcome = outcome?; + match jobs().errors.get(&locale) { + Some(e) if outcome == Outcome::Done => Err(e.clone()), + _ => Ok(outcome), + } +} + +fn install_now(b: &dyn Backend, locale: &str, cancel: &Cancel) -> Result<(), String> { + let listed = |packs: &[Pack]| packs.iter().any(|p| p.locale == locale); + if !listed(&b.cached_index()) && !listed(&b.fetch_index(cancel)?) { + return Err(format!("there is no Language pack for {locale}")); + } + b.install(locale, cancel, &mut |done, total| { + if let Some(job) = jobs().installing.get_mut(locale) { + (job.done, job.total) = (done, total); + } + }) +} + +/// Stops the install of `locale` (or the index fetch, for `""`) if one is running. +pub fn cancel(locale: &str) { + let j = jobs(); + let c = if locale.is_empty() { j.refreshing.as_ref() } else { j.installing.get(locale).map(|job| &job.cancel) }; + if let Some(c) = c { + c.cancel(); + } +} + +/// Removes the installed pack for `locale`; not while it is installing. +pub fn remove(locale: &str) -> Result<(), String> { + let b = backend().ok_or_else(no_backend)?; + if jobs().installing.contains_key(locale) { + return Err(format!("the {locale} pack is still installing")); + } + let r = b.remove(locale); + changed(); + let mut j = jobs(); + match &r { + Ok(()) => j.errors.remove(locale), + Err(e) => j.errors.insert(locale.to_string(), e.clone()), + }; + r +} + +/// The pack index this build trusts: craft-i18n's Language pack release `language-packs-2` (75 +/// packs), pinned by the sha256 of its `index.json`. The font store reads +/// `CRAFT_LANGUAGE_PACK_INDEX` itself, to try packs from a test index (testing only). +pub const PACK_INDEX: craft_font_store::PackIndexPin = craft_font_store::PackIndexPin { + url: "https://github.com/storytold/craft-i18n/releases/download/language-packs-2/index.json", + sha256: "b35c7aef0591177f18233b551da16035dcd615549ff874e169ffd19f16fea74b", +}; + +/// The font store as the packs [`Backend`]. +struct FontStoreBackend { + store: craft_font_store::FontStore, + /// The index read or fetched last: an install takes its entry (URL, size, sha256) from it. + index: Mutex>, +} + +impl FontStoreBackend { + fn new(store: craft_font_store::FontStore) -> Self { + Self { store, index: Mutex::new(None) } + } + + fn keep(&self, index: craft_font_store::PackIndex) -> Vec { + let packs = index + .packs + .iter() + .map(|e| Pack { + locale: e.locale.clone(), + name: e.name.clone(), + size: e.size, + licence: e.licence.clone(), + class: e.class.clone(), + spelling: e.spelling, + hyphenation: e.hyphenation, + }) + .collect(); + *self.index.lock().unwrap_or_else(PoisonError::into_inner) = Some(index); + packs + } +} + +impl Backend for FontStoreBackend { + fn packs_dir(&self) -> PathBuf { + self.store.language_packs_dir() + } + + fn downloads_on(&self) -> bool { + self.store.network() == craft_font_store::Network::On + } + + fn cached_index(&self) -> Vec { + self.store.cached_language_pack_index(&PACK_INDEX).map(|i| self.keep(i)).unwrap_or_default() + } + + fn fetch_index(&self, cancel: &Cancel) -> Result, String> { + let index = self.store.fetch_language_pack_index(&PACK_INDEX, cancel).map_err(|e| e.to_string())?; + Ok(self.keep(index)) + } + + fn install(&self, locale: &str, cancel: &Cancel, progress: &mut dyn FnMut(u64, u64)) -> Result<(), String> { + let held = self.index.lock().unwrap_or_else(PoisonError::into_inner).clone(); + let index = held.or_else(|| self.store.cached_language_pack_index(&PACK_INDEX)).ok_or("the list of Language packs hasn't been fetched")?; + let entry = index.pack(locale).ok_or_else(|| format!("there is no Language pack for {locale}"))?.clone(); + self.store.install_language_pack(&index, &entry, cancel, &mut |p| progress(p.done, p.total)).map(|_| ()).map_err(|e| e.to_string()) + } + + fn remove(&self, locale: &str) -> Result<(), String> { + self.store.remove_language_pack(locale).map_err(|e| e.to_string()) + } + + fn index_override(&self) -> Option { + craft_font_store::language_pack_index_overridden() + } +} + +/// The font store backend in `dir`, for tests that need the real store without a request. +#[cfg(test)] +pub(crate) fn font_store_in(dir: PathBuf) -> Arc { + Arc::new(FontStoreBackend::new(craft_font_store::FontStore::new(dir, craft_font_store::Caller::Agent))) +} diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 2890618dd8..2d249a7091 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -110,6 +110,7 @@ impl Session { plugin_dir: None, plugin_loads: Default::default(), plugin_loads_in_background: false, + packs_seen: 0, scripts_dir: None, startup_scripts_dir: None, metadata_templates_dir: None, diff --git a/crates/engine/src/store.rs b/crates/engine/src/store.rs index 29cd6f1bea..eeb730b0ac 100644 --- a/crates/engine/src/store.rs +++ b/crates/engine/src/store.rs @@ -974,6 +974,30 @@ impl Session { self.plugin_loads_in_background = on; } + /// Lays every document out again when the installed Language packs changed since the last + /// call (an install in the background ended, or a pack was removed), since spelling and + /// hyphenation in their languages change → whether an install or index fetch is still running, + /// so the app looks again. The app calls it as its frames go by. + pub fn poll_language_packs(&mut self) -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + let now = crate::packs::generation(); + if now != self.packs_seen { + self.packs_seen = now; + for st in &mut self.docs { + st.revision += 1; + } + } + crate::packs::busy() + } + // The web build has no packs. + #[cfg(target_arch = "wasm32")] + { + let _ = self.packs_seen; + false + } + } + /// Installs what the plug-in loads have loaded so far, in the order the loads started and each /// load's file-name order, up to the first module still loading, without waiting → whether /// some are still loading. A load starts once the loads before it are done. When another diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index f0c8393339..c4fbc09a3b 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -127,6 +127,8 @@ mod outlineobject; pub(super) mod outlinestroke; mod overprint; mod package; +#[cfg(not(target_arch = "wasm32"))] +mod packs; mod paintopacity; mod paintproxy; mod panelcmds; diff --git a/crates/engine/src/tests/packs.rs b/crates/engine/src/tests/packs.rs new file mode 100644 index 0000000000..473640f263 --- /dev/null +++ b/crates/engine/src/tests/packs.rs @@ -0,0 +1,219 @@ +//! Language packs (`proof.packs`, `proof.installPack`, `proof.removePack`, #4936): an installed pack +//! spell-checks its language in the documents, an install needs downloads on, and a pack installed +//! in the background reaches the documents once it ends. + +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard, PoisonError}; + +use serde_json::{Value, json}; + +use crate::packs::{self, Backend, Cancel, Pack}; +use crate::*; + +/// Tests that set the process-wide packs backend take turns. +fn packs_lock() -> MutexGuard<'static, ()> { + static LOCK: Mutex<()> = Mutex::new(()); + LOCK.lock().unwrap_or_else(PoisonError::into_inner) +} + +/// Puts the process back to no packs and no background installs when dropped, also when the test +/// panicked, and deletes the test's folder. +struct Reset(PathBuf); + +impl Drop for Reset { + fn drop(&mut self) { + packs::run_in_background(false); + packs::set_backend(None); + let _ = std::fs::remove_dir_all(&self.0); + } +} + +/// A new folder for one test. +fn folder(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("vc-packs-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + dir +} + +/// Writes a small Dutch pack into `packs/nl`, laid out as the font store unpacks one. +fn write_dutch_pack(packs: &Path) { + let dir = packs.join("nl"); + std::fs::create_dir_all(dir.join("LICENCES")).unwrap(); + std::fs::write(dir.join("pack.toml"), "locale = \"nl\"\nname = \"Nederlands (test)\"\nlicence = \"MIT\"\n").unwrap(); + std::fs::write(dir.join("LICENCES").join("COPYING"), "Test licence text.").unwrap(); + std::fs::write(dir.join("spelling.aff"), "SET UTF-8\nTRY esianrtolducgmphbykfvwjzxq\n").unwrap(); + std::fs::write(dir.join("spelling.dic"), "5\nhet\nhuis\nen\nde\nfiets\n").unwrap(); +} + +/// A session with a new document holding Dutch point type with one misspelt word, `fietz`. +fn dutch_session() -> Session { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let id = s.execute("text.create", &json!({"x": 10, "y": 50, "text": "Het huis en de fietz"})).unwrap()["id"].clone(); + s.execute("text.setFormat", &json!({"ids": [id], "language": "Dutch"})).unwrap(); + s +} + +/// The unknown words a check lists, as (word, lang). +fn unknown(s: &mut Session) -> Vec<(String, String)> { + let r = s.execute("text.spelling.check", &json!({})).unwrap(); + r["words"].as_array().unwrap().iter().map(|w| (w["word"].as_str().unwrap().into(), w["lang"].as_str().unwrap().into())).collect() +} + +fn installed_locales(s: &mut Session) -> Vec { + let r = s.execute("proof.packs", &json!({})).unwrap(); + r["installed"].as_array().unwrap().iter().map(|p| p["locale"].as_str().unwrap().to_string()).collect() +} + +#[test] +fn a_pack_in_the_font_store_checks_its_language_until_it_is_removed() { + let _turn = packs_lock(); + let root = folder("store"); + let _reset = Reset(root.clone()); + let mut s = dutch_session(); + let without = unknown(&mut s); + // A pack another Craft app installed into the shared store. + let store = packs::font_store_in(root.clone()); + write_dutch_pack(&store.packs_dir()); + packs::set_backend(Some(store)); + assert_eq!(unknown(&mut s), [("fietz".to_string(), "nl".to_string())], "checked in Dutch by the pack"); + assert_eq!(installed_locales(&mut s), ["nl"]); + let listed = s.execute("proof.packs", &json!({})).unwrap(); + assert_eq!((listed["available"].clone(), listed["downloads"].clone()), (json!(true), json!(false)), "downloads stay off"); + let before = s.doc().unwrap().revision; + assert_eq!(s.execute("proof.removePack", &json!({"locale": "NL"})).unwrap()["installed"], false); + assert!(s.doc().unwrap().revision > before, "the document is laid out again"); + assert_eq!(unknown(&mut s), without, "checked as before the pack"); + assert!(installed_locales(&mut s).is_empty()); + assert!(s.execute("proof.removePack", &json!({"locale": "nl"})).is_err(), "no longer installed"); +} + +/// A stand-in for the font store: it lists a Dutch pack and installs it by writing its files. +struct Fake { + dir: PathBuf, + downloads: bool, + /// While set, an install waits until it is cleared. + hold: AtomicBool, +} + +impl Backend for Fake { + fn packs_dir(&self) -> PathBuf { + self.dir.clone() + } + + fn downloads_on(&self) -> bool { + self.downloads + } + + fn cached_index(&self) -> Vec { + let nl = Pack { + locale: "nl".into(), + name: "Nederlands".into(), + size: 2, + licence: "MIT".into(), + class: "Embeddable".into(), + spelling: true, + hyphenation: false, + }; + vec![nl] + } + + fn fetch_index(&self, _: &Cancel) -> Result, String> { + Ok(self.cached_index()) + } + + fn install(&self, locale: &str, cancel: &Cancel, progress: &mut dyn FnMut(u64, u64)) -> Result<(), String> { + progress(1, 2); + while self.hold.load(Ordering::Relaxed) { + if cancel.is_cancelled() { + return Err("cancelled".into()); + } + std::thread::yield_now(); + } + // The index lists only Dutch, which `packs::install` checks first. + if locale != "nl" { + return Err(format!("asked to install {locale}")); + } + write_dutch_pack(&self.dir); + Ok(()) + } + + fn remove(&self, locale: &str) -> Result<(), String> { + std::fs::remove_dir_all(self.dir.join(locale)).map_err(|e| e.to_string()) + } +} + +fn error(s: &mut Session, id: &str, p: Value) -> String { + s.execute(id, &p).unwrap_err().to_string() +} + +#[test] +fn an_install_needs_downloads_on_and_a_pack_the_index_lists() { + let _turn = packs_lock(); + let root = folder("fake"); + let _reset = Reset(root.clone()); + let mut s = dutch_session(); + assert!(error(&mut s, "proof.installPack", json!({"locale": "nl"})).contains("aren't available"), "no store, no packs"); + packs::set_backend(Some(Arc::new(Fake { dir: root.clone(), downloads: false, hold: AtomicBool::new(false) }))); + assert!(error(&mut s, "proof.installPack", json!({"locale": "nl"})).contains("downloading is turned off")); + assert!(error(&mut s, "proof.packs", json!({"refresh": true})).contains("downloading is turned off")); + assert!(installed_locales(&mut s).is_empty(), "nothing installed"); + packs::set_backend(Some(Arc::new(Fake { dir: root.clone(), downloads: true, hold: AtomicBool::new(false) }))); + for bad in [json!({}), json!({"locale": ""}), json!({"locale": "../nl"}), json!({"locale": 5})] { + assert!(s.execute("proof.installPack", &bad).is_err(), "{bad} is refused"); + } + assert!(!root.exists(), "a refused locale writes nothing"); + assert!(error(&mut s, "proof.installPack", json!({"locale": "fy"})).contains("no Language pack for fy")); + assert!(s.execute("proof.packs", &json!({})).unwrap()["errors"]["fy"].is_string(), "the failure is reported"); + let before = s.doc().unwrap().revision; + assert!(error(&mut s, "proof.installPack", json!({"locale": "nl_NL"})).contains("no Language pack for nl-nl"), "nl_NL reads as nl-nl"); + assert_eq!(s.execute("proof.installPack", &json!({"locale": "nl"})).unwrap()["installed"], true); + assert!(s.doc().unwrap().revision > before, "the document is laid out again"); + assert_eq!(unknown(&mut s), [("fietz".to_string(), "nl".to_string())]); + let listed = s.execute("proof.packs", &json!({})).unwrap(); + assert_eq!(listed["packs"][0]["installed"], true); +} + +#[test] +fn an_install_in_the_background_reaches_the_documents_when_it_ends() { + let _turn = packs_lock(); + let root = folder("background"); + let _reset = Reset(root.clone()); + let mut s = dutch_session(); + let without = unknown(&mut s); + let fake = Arc::new(Fake { dir: root.clone(), downloads: true, hold: AtomicBool::new(true) }); + packs::set_backend(Some(fake.clone())); + packs::run_in_background(true); + assert_eq!(s.execute("proof.installPack", &json!({"locale": "nl"})).unwrap()["started"], true); + assert_eq!(s.execute("proof.installPack", &json!({"locale": "nl"})).unwrap()["started"], true, "asked again, it is the same install"); + let listed = s.execute("proof.packs", &json!({})).unwrap(); + assert_eq!(listed["installing"][0]["locale"], "nl"); + assert!(error(&mut s, "proof.removePack", json!({"locale": "nl"})).contains("still installing")); + assert_eq!(unknown(&mut s), without, "not used before it is installed"); + let before = s.doc().unwrap().revision; + fake.hold.store(false, Ordering::Relaxed); + while s.poll_language_packs() { + std::thread::yield_now(); + } + s.poll_language_packs(); + assert!(s.doc().unwrap().revision > before, "the document is laid out again"); + assert_eq!(unknown(&mut s), [("fietz".to_string(), "nl".to_string())]); +} + +#[test] +fn a_cancelled_background_install_installs_nothing() { + let _turn = packs_lock(); + let root = folder("cancel"); + let _reset = Reset(root.clone()); + let mut s = dutch_session(); + packs::set_backend(Some(Arc::new(Fake { dir: root.clone(), downloads: true, hold: AtomicBool::new(true) }))); + packs::run_in_background(true); + assert_eq!(s.execute("proof.installPack", &json!({"locale": "nl"})).unwrap()["started"], true); + packs::cancel("nl"); + while packs::busy() { + std::thread::yield_now(); + } + assert!(installed_locales(&mut s).is_empty()); + assert!(s.execute("proof.packs", &json!({})).unwrap()["errors"]["nl"].as_str().unwrap_or_default().contains("cancelled")); +} diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index c5a97a940a..447199bb6f 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -535,6 +535,11 @@ impl VectorcraftApp { // what waits for them. They install after the control requests are drained, so the frame // after the last one opens the files held for them (the desktop app does that before this // pass) before a control request waiting for them runs. + // A Language pack installed or removed lays the documents out again; while one downloads + // the host keeps coming back to look. + if self.session.poll_language_packs() { + ctx.request_repaint_after(std::time::Duration::from_millis(250)); + } if self.session.plugins_loading() { if self.session.poll_plugin_loads() { ctx.request_repaint_after(std::time::Duration::from_millis(50)); diff --git a/docs/gaps.md b/docs/gaps.md index e1f45bff43..766c215388 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -531,7 +531,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done:** COLR and SVG glyphs go with type that geometry effects reshape, into Expand Appearance and EMF/WMF export, where the type's outlines used to leave them out; bitmap glyphs (emoji) too, as images that hold their own pixels until a document takes them in; estimate unchanged. -- **Done:** spell check (#4936): engine (`text.spelling.check` and `text.spelling.suggest` on craft-proof); custom dictionary and Ignore All (`text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary`, `ignoreAll`); Auto Spell Check (`edit.autoSpellCheck`) with red wavy underlines and canvas context menu suggestions, Ignore All and Add to Dictionary; Edit › Edit Custom Dictionary…; and modal Check Spelling dialog (Edit › Spelling › Check Spelling…, and Spelling › Check Spelling… in the canvas context menu of type, `ui.checkSpelling`) with sentence context, suggestions list, "Change to" edit, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done, Cancel, and keyboard navigation. Estimate unchanged. +- **Done:** spell check (#4936): engine (`text.spelling.check` and `text.spelling.suggest` on craft-proof); custom dictionary and Ignore All (`text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary`, `ignoreAll`); Auto Spell Check (`edit.autoSpellCheck`) with red wavy underlines and canvas context menu suggestions, Ignore All and Add to Dictionary; Edit › Edit Custom Dictionary…; and modal Check Spelling dialog (Edit › Spelling › Check Spelling…, and Spelling › Check Spelling… in the canvas context menu of type, `ui.checkSpelling`) with sentence context, suggestions list, "Change to" edit, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done, Cancel, and keyboard navigation; Language packs for languages other than English, read from the Craft apps' shared font store, with `proof.packs`, `proof.installPack` and `proof.removePack` (a Preferences page to install them and the missing-pack bar remain). Estimate unchanged. - **Missing:** CJK vertical composition (custom mojikumi sets and the Mojikumi Settings dialog, kinsoku settings #633, manual tate-chu-yoko), Middle Eastern features beyond bidi, digit types, Character Direction and Kashidas (a split caret; the Middle Eastern & South Asian composers are done, #4935), @@ -1021,6 +1021,7 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv | Date | Change | Summary | |---|---|---| +| 2026-11-27 | minor | G4 type: Language packs (#4936): spelling and hyphenation read the packs installed in the Craft apps' shared font store, and `proof.packs`, `proof.installPack` and `proof.removePack` list, install and remove them (installs need downloading on, which only the person turns on); a Preferences page to install them and the missing-pack bar remain; scores and estimates unchanged. | | 2026-11-24 | minor | G12: History row context menus use shared Craft List and Menu controls after rebasing onto the panel migration. App-specific actions retain the chosen snapshot across pending edits and dismiss on document switches; keyboard context requests and focus restoration use the shared runtime. Regression cases retained (#8845); scores and estimates unchanged. | | 2026-11-23 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale Slider, RGB Sliders, HSB Sliders, CMYK Sliders and Web Color Sliders, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. | | 2026-11-21 | minor | G13: View › Snapping groups five existing toggles and Pixel Snapping Options…; top-level commands and shortcuts remain; headless click/checkmark coverage added; scores and estimates unchanged. | diff --git a/docs/mcp.md b/docs/mcp.md index 808f600e69..e26c2a193c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -12612,7 +12612,7 @@ returns the new value. `text.spelling.check {ids?}` lists the words of the document's type that its dictionaries don't know: every visible, unlocked type object in paint order, or those in `ids` (and in the groups `ids` names). Each run is checked in its Character panel Language (English when it has none) by craft-proof, one paragraph at a time; a language without -a spelling dictionary marks nothing. English words come from the first dictionary craft-proof finds: a Hunspell +a spelling dictionary marks nothing (see [Language packs](#language-packs)). English words come from the first dictionary craft-proof finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary for that English built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into craft-proof. Words in capitals, words with digits and web addresses are taken as correct. The result is `{words: [{id, start, end, word, lang}], more}`: `start` and `end` are byte offsets in the type object's text, the @@ -12663,6 +12663,37 @@ for it (each a `text.editRange {id, start, end, insert}` item labelled with its All (`text.spelling.ignoreAll {word}`) and Add to Dictionary (`text.spelling.addWord {word}`); the context menu's entries list them with their params. A right-click on type also has Spelling › Auto Spell Check (`edit.autoSpellCheck`). +### Language packs + +Languages other than English are spell-checked, and hyphenated, from **Language packs**: one per language, with its +Hunspell dictionary, hyphenation patterns and licence texts, published by storytold/craft-i18n (release +`language-packs-2`, whose `index.json` VectorCraft pins by its sha256). They are installed into the font store folder +the Craft apps share, so a pack installed in another Craft app is used here too. A language's dictionary is looked up +in an installed pack, then in the system's Hunspell dictionaries. The desktop app and `vectorcraft-cli` read the +installed packs; the web app has none, and no `proof.*` commands. + +- `proof.packs {refresh?}` lists the packs of the index fetched last (`packs`, each with `locale`, `name`, `size` in + bytes, `licence`, `class`, `spelling`, `hyphenation` and `installed`), the packs in use (`installed`), the installs + running (`installing`, with bytes `done` of `total`), whether the index is being fetched (`refreshing`), the last + failure of each locale (`errors`; `""` is the index fetch), whether downloading is on (`downloads`), a test index + used instead of the pinned one (`indexOverride`, from `CRAFT_LANGUAGE_PACK_INDEX`) and whether there is a store to + install into (`available`). `refresh: true` fetches the index again. +- `proof.installPack {locale}` downloads a pack, checks its sha256 and installs it (fetching the index first when it + doesn't list the locale). Every open document is laid out and checked again with it. `locale` is the pack's tag, + like `nl` or `pt-br` (`pt_BR` reads as `pt-br`). +- `proof.removePack {locale}` removes an installed pack, not while it installs. + +Installs and index fetches need downloading on. Only the person using a Craft app turns it on, with their own click +(the setting is the font store's, shared by the apps): no command turns it on, and until then an install is an error +that says so. In the desktop app installs and fetches run in the background: `proof.installPack` returns +`{locale, started: true}` and `proof.packs` shows the install in `installing`, then in `installed` or `errors`. In +`vectorcraft-cli` they return once done. + +```json +{"name":"run_command","arguments":{"command":"proof.packs","params":{"refresh":true}}} +{"name":"run_command","arguments":{"command":"proof.installPack","params":{"locale":"nl"}}} +``` + ## Find and Replace `edit.findNext {find, matchCase?, wholeWord?, backwards?, hiddenLayers?, lockedLayers?, from?}` finds the next match From fef393ddc06f4eadaeb916963bc84eed5ce11071 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Fri, 27 Nov 2026 21:56:59 +0530 Subject: [PATCH 039/264] Language packs: fmt, a Status struct for clippy, std Result in the tests Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd.rs | 4 ++-- crates/engine/src/cmd/packs.rs | 2 +- crates/engine/src/packs.rs | 27 ++++++++++++++++++++++----- crates/engine/src/tests/packs.rs | 6 +++--- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 76c9914a26..c8fb66f630 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -65,6 +65,8 @@ pub(crate) mod objects_on_path; mod opacitymask; mod overprint; pub mod package; +#[cfg(not(target_arch = "wasm32"))] +pub mod packs; mod paint; mod panelcmds; pub mod params; @@ -92,8 +94,6 @@ pub(crate) mod shaper; pub mod shortcutset; pub(crate) mod slices; pub mod spelling; -#[cfg(not(target_arch = "wasm32"))] -pub mod packs; mod stroke; mod style; pub use style::styled_node; diff --git a/crates/engine/src/cmd/packs.rs b/crates/engine/src/cmd/packs.rs index 9941596f59..b90cec9c3d 100644 --- a/crates/engine/src/cmd/packs.rs +++ b/crates/engine/src/cmd/packs.rs @@ -67,7 +67,7 @@ fn list(s: &mut Session, p: &Value) -> Result { }) }) .collect(); - let (installing, refreshing, errors) = packs::status(); + let packs::Status { installing, refreshing, errors } = packs::status(); // An install that ended since the last frame shows in every document's layout. s.poll_language_packs(); Ok(json!({ diff --git a/crates/engine/src/packs.rs b/crates/engine/src/packs.rs index ba1e85c3d0..8ab8f2be17 100644 --- a/crates/engine/src/packs.rs +++ b/crates/engine/src/packs.rs @@ -154,11 +154,24 @@ pub fn available() -> Vec { backend().map(|b| b.cached_index()).unwrap_or_default() } -/// What `proof.packs` reports about the jobs: the installs running as (locale, done, total), whether -/// the index is being fetched, and the last error of each locale (`""`: the index). -pub fn status() -> (Vec<(String, u64, u64)>, bool, BTreeMap) { +/// What `proof.packs` reports about the jobs. +pub struct Status { + /// The installs running, as (locale, bytes done, bytes in all). + pub installing: Vec<(String, u64, u64)>, + /// Whether the index is being fetched. + pub refreshing: bool, + /// The last error of each locale (`""`: the index fetch). + pub errors: BTreeMap, +} + +/// The jobs running and the last errors. +pub fn status() -> Status { let j = jobs(); - (j.installing.iter().map(|(l, job)| (l.clone(), job.done, job.total)).collect(), j.refreshing.is_some(), j.errors.clone()) + Status { + installing: j.installing.iter().map(|(l, job)| (l.clone(), job.done, job.total)).collect(), + refreshing: j.refreshing.is_some(), + errors: j.errors.clone(), + } } /// What an install or a fetch did. @@ -176,7 +189,11 @@ fn run(f: impl FnOnce() + Send + 'static) -> Result { f(); return Ok(Outcome::Done); } - std::thread::Builder::new().name("language-pack".into()).spawn(f).map(|_| Outcome::Started).map_err(|e| format!("couldn't start the download: {e}")) + std::thread::Builder::new() + .name("language-pack".into()) + .spawn(f) + .map(|_| Outcome::Started) + .map_err(|e| format!("couldn't start the download: {e}")) } /// Fetches the pinned pack index again. Needs downloads on. diff --git a/crates/engine/src/tests/packs.rs b/crates/engine/src/tests/packs.rs index 473640f263..37825e8cd2 100644 --- a/crates/engine/src/tests/packs.rs +++ b/crates/engine/src/tests/packs.rs @@ -119,11 +119,11 @@ impl Backend for Fake { vec![nl] } - fn fetch_index(&self, _: &Cancel) -> Result, String> { + fn fetch_index(&self, _: &Cancel) -> std::result::Result, String> { Ok(self.cached_index()) } - fn install(&self, locale: &str, cancel: &Cancel, progress: &mut dyn FnMut(u64, u64)) -> Result<(), String> { + fn install(&self, locale: &str, cancel: &Cancel, progress: &mut dyn FnMut(u64, u64)) -> std::result::Result<(), String> { progress(1, 2); while self.hold.load(Ordering::Relaxed) { if cancel.is_cancelled() { @@ -139,7 +139,7 @@ impl Backend for Fake { Ok(()) } - fn remove(&self, locale: &str) -> Result<(), String> { + fn remove(&self, locale: &str) -> std::result::Result<(), String> { std::fs::remove_dir_all(self.dir.join(locale)).map_err(|e| e.to_string()) } } From 22f5ca3cbf45b925fabdaf12f486f6cd0661e4cd Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Fri, 27 Nov 2026 23:55:40 +0530 Subject: [PATCH 040/264] Language packs: review fixes, and plug-ins can't call proof commands - proof.installPack, proof.removePack and proof.packs {refresh} are refused under automation roots: the shared font store is outside them. - Plug-ins may not call proof.* (DENIED_PREFIXES), which plugin_call's every_command_is_reviewed requires of new commands. - A synchronous install or refresh returns its own result, not one read back from the shared errors. - proof.packs reads the jobs before the installed packs, and poll_language_packs reads busy() before the generation, so an install that ends between the reads is never missed. - A pack change measures type with a language of its own again (refresh_document_text_bounds), so selection boxes and hits follow. - The tests' Reset cancels and waits for background jobs. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/packs.rs | 24 +++++-- crates/engine/src/cmd/plugin_call.rs | 2 + crates/engine/src/packs.rs | 90 +++++++++++++------------- crates/engine/src/session/documents.rs | 2 +- crates/engine/src/store.rs | 14 +++- crates/engine/src/tests/packs.rs | 35 +++++++++- docs/mcp.md | 4 +- 7 files changed, 117 insertions(+), 54 deletions(-) diff --git a/crates/engine/src/cmd/packs.rs b/crates/engine/src/cmd/packs.rs index b90cec9c3d..9dd85a79f9 100644 --- a/crates/engine/src/cmd/packs.rs +++ b/crates/engine/src/cmd/packs.rs @@ -16,7 +16,7 @@ pub fn specs() -> Vec { "Language Packs", [], None, - "{refresh?: bool (fetch the pinned pack index again; needs downloading on; in the desktop app it runs in the background: see refreshing)} the Language packs that spell-check and hyphenate languages other than English, shared by the Craft apps → {packs: [{locale, name, size: bytes, licence: SPDX, class, spelling: bool, hyphenation: bool, installed: bool}…] (the index fetched last; empty before the first fetch), installed: [{locale, name, licence}…] (the packs spelling and hyphenation use), installing: [{locale, done, total}…] (bytes), refreshing: bool, errors: {locale: message} (the last failure of each install or removal; \"\": of the index fetch), downloads: bool (the person allowed downloading), indexOverride: string|null (a test index used instead of the pinned one), available: bool (there is a font store folder to install into)}", + "{refresh?: bool (fetch the pinned pack index again; needs downloading on; refused under automation roots; in the desktop app it runs in the background: see refreshing)} the Language packs that spell-check and hyphenate languages other than English, shared by the Craft apps → {packs: [{locale, name, size: bytes, licence: SPDX, class, spelling: bool, hyphenation: bool, installed: bool}…] (the index fetched last; empty before the first fetch), installed: [{locale, name, licence}…] (the packs spelling and hyphenation use), installing: [{locale, done, total}…] (bytes), refreshing: bool, errors: {locale: message} (the last failure of each install or removal; \"\": of the index fetch), downloads: bool (the person allowed downloading), indexOverride: string|null (a test index used instead of the pinned one), available: bool (there is a font store folder to install into)}", always, list ), @@ -25,7 +25,7 @@ pub fn specs() -> Vec { "Install Language Pack", [], None, - "{locale: language tag (a pack's locale from proof.packs, like nl or pt-br)} downloads the pack, checks its sha256 and installs it; spelling and hyphenation in that language use it at once, in every open document. Needs downloading on, which only the person using a Craft app can turn on. Opens nothing. In the desktop app it runs in the background → {locale, started: true}: follow it with proof.packs (installing, then installed or errors); elsewhere it returns once installed → {locale, installed: true}", + "{locale: language tag (a pack's locale from proof.packs, like nl or pt-br)} downloads the pack, checks its sha256 and installs it; spelling and hyphenation in that language use it at once, in every open document. Needs downloading on, which only the person using a Craft app can turn on. Refused under automation roots (the store is outside them). Opens nothing. In the desktop app it runs in the background → {locale, started: true}: follow it with proof.packs (installing, then installed or errors); elsewhere it returns once installed → {locale, installed: true}", always, install ), @@ -34,7 +34,7 @@ pub fn specs() -> Vec { "Remove Language Pack", [], None, - "{locale} removes the installed pack (not while it installs); that language is no longer checked with it → {locale, installed: false}", + "{locale} removes the installed pack (not while it installs; refused under automation roots); that language is no longer checked with it → {locale, installed: false}", always, remove ), @@ -51,10 +51,14 @@ fn list(s: &mut Session, p: &Value) -> Result { match p.get("refresh") { None | Some(Value::Null) | Some(Value::Bool(false)) => {} Some(Value::Bool(true)) => { + not_confined(C)?; packs::refresh().map_err(EngineError::Other)?; } Some(_) => return Err(bad(C, "`refresh` must be true or false")), } + // The jobs before the installed packs: an install makes craft-proof read its pack before it + // leaves the jobs, so one that ends between the two reads is in one list or the other. + let packs::Status { installing, refreshing, errors } = packs::status(); let installed = craft_proof::packs::installed(); let backend = packs::backend(); let rows: Vec = packs::available() @@ -67,7 +71,6 @@ fn list(s: &mut Session, p: &Value) -> Result { }) }) .collect(); - let packs::Status { installing, refreshing, errors } = packs::status(); // An install that ended since the last frame shows in every document's layout. s.poll_language_packs(); Ok(json!({ @@ -82,8 +85,20 @@ fn list(s: &mut Session, p: &Value) -> Result { })) } +/// Refuses `command` for a caller confined to automation roots: the packs are written into the font +/// store the Craft apps share, which is outside them. +fn not_confined(command: &str) -> Result<()> { + if crate::file_access::current().is_some() { + return Err(EngineError::Other(format!( + "automation path rejected: {command} writes the Language packs into the font store the Craft apps share, outside the automation roots" + ))); + } + Ok(()) +} + fn install(s: &mut Session, p: &Value) -> Result { let locale = locale_param(p, "proof.installPack")?; + not_confined("proof.installPack")?; match packs::install(&locale).map_err(EngineError::Other)? { Outcome::Started => Ok(json!({"locale": locale, "started": true})), Outcome::Done => { @@ -95,6 +110,7 @@ fn install(s: &mut Session, p: &Value) -> Result { fn remove(s: &mut Session, p: &Value) -> Result { let locale = locale_param(p, "proof.removePack")?; + not_confined("proof.removePack")?; packs::remove(&locale).map_err(EngineError::Other)?; s.poll_language_packs(); Ok(json!({"locale": locale, "installed": false})) diff --git a/crates/engine/src/cmd/plugin_call.rs b/crates/engine/src/cmd/plugin_call.rs index 867c1f2ff0..fc69773561 100644 --- a/crates/engine/src/cmd/plugin_call.rs +++ b/crates/engine/src/cmd/plugin_call.rs @@ -70,6 +70,8 @@ const DENIED_PREFIXES: &[&str] = &[ "text.rescanFonts", "text.fontList", "text.spelling.", + // Language packs: downloads into, and removals from, the font store the Craft apps share. + "proof.", "colorTheme.", "magicWand.", "eyedropper.", diff --git a/crates/engine/src/packs.rs b/crates/engine/src/packs.rs index 8ab8f2be17..fec380c1c2 100644 --- a/crates/engine/src/packs.rs +++ b/crates/engine/src/packs.rs @@ -183,17 +183,23 @@ pub enum Outcome { Started, } -/// Runs `f` on a thread of its own in the background, else here. -fn run(f: impl FnOnce() + Send + 'static) -> Result { +/// Runs `job` on a thread of its own in the background, else here and gives its own result (never +/// another call's, which the shared errors also hold). `undo` takes the job's entry back when its +/// thread can't start. +fn run(job: impl FnOnce() -> Result<(), String> + Send + 'static, undo: impl FnOnce()) -> Result { if !BACKGROUND.load(Ordering::Relaxed) { - f(); - return Ok(Outcome::Done); + return job().map(|()| Outcome::Done); + } + match std::thread::Builder::new().name("language-pack".into()).spawn(move || { + // The result is kept in the shared errors for `proof.packs`. + let _ = job(); + }) { + Ok(_) => Ok(Outcome::Started), + Err(e) => { + undo(); + Err(format!("couldn't start the download: {e}")) + } } - std::thread::Builder::new() - .name("language-pack".into()) - .spawn(f) - .map(|_| Outcome::Started) - .map_err(|e| format!("couldn't start the download: {e}")) } /// Fetches the pinned pack index again. Needs downloads on. @@ -212,22 +218,18 @@ pub fn refresh() -> Result { j.errors.remove(""); cancel }; - let outcome = run(move || { - let r = b.fetch_index(&cancel); - let mut j = jobs(); - j.refreshing = None; - if let Err(e) = r { - j.errors.insert(String::new(), e); - } - }); - if outcome.is_err() { - jobs().refreshing = None; - } - let outcome = outcome?; - match jobs().errors.get("") { - Some(e) if outcome == Outcome::Done => Err(e.clone()), - _ => Ok(outcome), - } + run( + move || { + let r = b.fetch_index(&cancel).map(|_| ()); + let mut j = jobs(); + j.refreshing = None; + if let Err(e) = &r { + j.errors.insert(String::new(), e.clone()); + } + r + }, + || jobs().refreshing = None, + ) } /// Installs the pack for `locale` (fetching the index first when it doesn't list it). Needs @@ -249,25 +251,25 @@ pub fn install(locale: &str) -> Result { cancel }; let l = locale.clone(); - let outcome = run(move || { - let r = install_now(&*b, &l, &cancel); - if r.is_ok() { - changed(); - } - let mut j = jobs(); - j.installing.remove(&l); - if let Err(e) = r { - j.errors.insert(l, e); - } - }); - if outcome.is_err() { - jobs().installing.remove(&locale); - } - let outcome = outcome?; - match jobs().errors.get(&locale) { - Some(e) if outcome == Outcome::Done => Err(e.clone()), - _ => Ok(outcome), - } + run( + move || { + let r = install_now(&*b, &l, &cancel); + // craft-proof reads the new pack before the job ends, so a caller that sees no + // install running sees the pack installed (`proof.packs`, `busy`). + if r.is_ok() { + changed(); + } + let mut j = jobs(); + j.installing.remove(&l); + if let Err(e) = &r { + j.errors.insert(l, e.clone()); + } + r + }, + || { + jobs().installing.remove(&locale); + }, + ) } fn install_now(b: &dyn Backend, locale: &str, cancel: &Cancel) -> Result<(), String> { diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 2d249a7091..2ed3cd6a34 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -335,7 +335,7 @@ impl Session { /// [`Session::refresh_text_bounds`] walks them), as a change that is not an edit: a saved /// document stays saved, and its undo history keeps its documents as they are. The document is /// left as it is when `stale` picks nothing. - fn refresh_document_text_bounds(&mut self, index: usize, mut stale: impl FnMut(&TextObject) -> bool) { + pub(crate) fn refresh_document_text_bounds(&mut self, index: usize, mut stale: impl FnMut(&TextObject) -> bool) { let Some(st) = self.docs.get_mut(index) else { return }; if !text_trees(&st.doc).any(|n| has_text_where(n, &mut stale)) { return; diff --git a/crates/engine/src/store.rs b/crates/engine/src/store.rs index eeb730b0ac..428b88d51c 100644 --- a/crates/engine/src/store.rs +++ b/crates/engine/src/store.rs @@ -981,14 +981,22 @@ impl Session { pub fn poll_language_packs(&mut self) -> bool { #[cfg(not(target_arch = "wasm32"))] { + // Busy first: an install moves the generation on before it ends, so when none is + // running any more its change is read below. + let busy = crate::packs::busy(); let now = crate::packs::generation(); if now != self.packs_seen { self.packs_seen = now; - for st in &mut self.docs { - st.revision += 1; + for index in 0..self.docs.len() { + // Type in a language of its own may break its lines elsewhere now: it is + // measured again (not an edit), so its selection box and hits follow. + self.refresh_document_text_bounds(index, |t| t.runs.iter().any(|r| r.style.language.is_some())); + if let Some(st) = self.docs.get_mut(index) { + st.revision += 1; + } } } - crate::packs::busy() + busy } // The web build has no packs. #[cfg(target_arch = "wasm32")] diff --git a/crates/engine/src/tests/packs.rs b/crates/engine/src/tests/packs.rs index 37825e8cd2..0218a9d39d 100644 --- a/crates/engine/src/tests/packs.rs +++ b/crates/engine/src/tests/packs.rs @@ -18,11 +18,19 @@ fn packs_lock() -> MutexGuard<'static, ()> { } /// Puts the process back to no packs and no background installs when dropped, also when the test -/// panicked, and deletes the test's folder. +/// panicked: the jobs still running are cancelled and waited for, so none outlives its test. Then +/// it deletes the test's folder. struct Reset(PathBuf); impl Drop for Reset { fn drop(&mut self) { + while packs::busy() { + for (locale, _, _) in packs::status().installing { + packs::cancel(&locale); + } + packs::cancel(""); + std::thread::yield_now(); + } packs::run_in_background(false); packs::set_backend(None); let _ = std::fs::remove_dir_all(&self.0); @@ -217,3 +225,28 @@ fn a_cancelled_background_install_installs_nothing() { assert!(installed_locales(&mut s).is_empty()); assert!(s.execute("proof.packs", &json!({})).unwrap()["errors"]["nl"].as_str().unwrap_or_default().contains("cancelled")); } + +/// A caller confined to automation roots lists the packs but can't fetch, install or remove them: +/// the store they are written into is outside its roots. +#[test] +fn a_confined_caller_lists_packs_but_cannot_change_them() { + let _turn = packs_lock(); + let root = folder("confined"); + let _reset = Reset(root.clone()); + let roots_dir = folder("confined-roots"); + std::fs::create_dir_all(&roots_dir).unwrap(); + let mut s = dutch_session(); + write_dutch_pack(&root); + packs::set_backend(Some(Arc::new(Fake { dir: root.clone(), downloads: true, hold: AtomicBool::new(false) }))); + let roots = crate::file_access::AutomationRoots::new(&[roots_dir.as_path()], &[roots_dir.as_path()]).unwrap(); + let mut confined = |cmd: &str, p: Value| crate::file_access::confine(roots.as_ref(), || s.execute(cmd, &p)).map_err(|e| e.to_string()); + for (cmd, p) in + [("proof.installPack", json!({"locale": "nl"})), ("proof.removePack", json!({"locale": "nl"})), ("proof.packs", json!({"refresh": true}))] + { + let e = confined(cmd, p).unwrap_err(); + assert!(e.contains("automation path rejected"), "{cmd}: {e}"); + } + assert_eq!(confined("proof.packs", json!({})).unwrap()["installed"][0]["locale"], "nl", "listing is allowed"); + assert!(root.join("nl").join("pack.toml").exists(), "the pack is still there"); + let _ = std::fs::remove_dir_all(&roots_dir); +} diff --git a/docs/mcp.md b/docs/mcp.md index e26c2a193c..5b083aa51e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -12685,7 +12685,9 @@ installed packs; the web app has none, and no `proof.*` commands. Installs and index fetches need downloading on. Only the person using a Craft app turns it on, with their own click (the setting is the font store's, shared by the apps): no command turns it on, and until then an install is an error -that says so. In the desktop app installs and fetches run in the background: `proof.installPack` returns +that says so. A caller with automation roots (`--automation-read-root`, `--automation-write-root`) can list packs +but not fetch, install or remove them, since the store is outside its roots. In the desktop app installs and fetches +run in the background: `proof.installPack` returns `{locale, started: true}` and `proof.packs` shows the install in `installing`, then in `installed` or `errors`. In `vectorcraft-cli` they return once done. From 979ae2dc1bd848dbfe63e84228ca75f0eb5a0ae2 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Sat, 28 Nov 2026 00:19:55 +0530 Subject: [PATCH 041/264] Language packs: measure back documents in their own composite fonts When the packs change, poll_language_packs measures the type of every open document again. A document in the back now has its own composite fonts lent while it is measured, as measure_back_document does, so type set in a composite font of the same name as one of the front document's is not measured in the front document's definition. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/store.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/engine/src/store.rs b/crates/engine/src/store.rs index 428b88d51c..4a547d6513 100644 --- a/crates/engine/src/store.rs +++ b/crates/engine/src/store.rs @@ -988,9 +988,15 @@ impl Session { if now != self.packs_seen { self.packs_seen = now; for index in 0..self.docs.len() { + // A document in the back is measured in its own composite fonts, lent for the + // measuring, as `measure_back_document` does: the front document's are the + // ones registered, and one of the same name may differ. + let back_fonts = (self.active != Some(index)).then(|| self.docs.get(index).map(|st| st.doc.composite_fonts.clone())).flatten(); + let lent = back_fonts.as_ref().map(|fonts| vectorcraft_text::FontDb::global().lend_document_composite_fonts(fonts)); // Type in a language of its own may break its lines elsewhere now: it is // measured again (not an edit), so its selection box and hits follow. self.refresh_document_text_bounds(index, |t| t.runs.iter().any(|r| r.style.language.is_some())); + drop(lent); if let Some(st) = self.docs.get_mut(index) { st.revision += 1; } From 1b18ab3a3763215bff9ab116de2763167d4b0c23 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Sat, 28 Nov 2026 11:06:36 +0530 Subject: [PATCH 042/264] Language packs: a script cannot run the proof commands A script's rollback cannot put back what proof.installPack, proof.removePack and proof.packs {refresh: true} write to or delete from the font store the Craft apps share, and in the desktop app an install keeps running after the run ends. refused_to_scripts now refuses the proof. prefix, as plugin_call does. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/script/mod.rs | 1 + crates/engine/src/tests/packs.rs | 15 +++++++++++++++ docs/mcp.md | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/script/mod.rs b/crates/engine/src/script/mod.rs index c5fffb6574..49853c8609 100644 --- a/crates/engine/src/script/mod.rs +++ b/crates/engine/src/script/mod.rs @@ -159,6 +159,7 @@ pub fn refused_to_scripts(id: &str) -> bool { "edit.undoGroup.", "file.recovery.", "stroke.widthProfile.", + "proof.", ]; const IDS: &[&str] = &[ "text.addFontFiles", diff --git a/crates/engine/src/tests/packs.rs b/crates/engine/src/tests/packs.rs index 0218a9d39d..0c09a5e259 100644 --- a/crates/engine/src/tests/packs.rs +++ b/crates/engine/src/tests/packs.rs @@ -250,3 +250,18 @@ fn a_confined_caller_lists_packs_but_cannot_change_them() { assert!(root.join("nl").join("pack.toml").exists(), "the pack is still there"); let _ = std::fs::remove_dir_all(&roots_dir); } + +/// A script's rollback cannot put back what an install writes into the shared font store, so a +/// script cannot run the pack commands. +#[test] +fn a_script_cannot_install_a_pack() { + let _turn = packs_lock(); + let root = folder("script"); + let _reset = Reset(root.clone()); + let mut s = dutch_session(); + packs::set_backend(Some(Arc::new(Fake { dir: root.clone(), downloads: true, hold: AtomicBool::new(false) }))); + let e = error(&mut s, "script.run", json!({"source": "vc.run('proof.installPack', {locale: 'nl'});", "name": "t.js"})); + assert!(e.contains("a script cannot run `proof.installPack`"), "{e}"); + assert!(installed_locales(&mut s).is_empty(), "nothing installed"); + assert_eq!(s.execute("proof.installPack", &json!({"locale": "nl"})).unwrap()["installed"], true, "outside a script it installs"); +} diff --git a/docs/mcp.md b/docs/mcp.md index 5b083aa51e..a7bf2d3168 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3080,7 +3080,7 @@ returns `{stopped}`. `notifications/cancelled` stops a run only while the `tools for it, as in a headless server; use `script.stop` for a run the app started. A script cannot run commands that change anything outside the documents: `script.*` except `script.check`, `plugin.*`, `prefs.*`, `actionSet.*`, `shortcutSet.*`, `help.*`, `print.*`, `library.*`, `importMatches.*`, `edit.undoGroup.*`, `file.recovery.*`, -`stroke.widthProfile.*`, saving, importing or deleting a preset, `text.addFontFiles`, `text.findFontFiles`, +`stroke.widthProfile.*`, `proof.*` (Language packs), saving, importing or deleting a preset, `text.addFontFiles`, `text.findFontFiles`, `text.rescanFonts`, `links.findFiles`, `file.place.queue`, `color.loadProfile`, `color.removeProfile`, `file.print`, `view.proofSetup`, `view.proofSetup.save`, `view.proofSetup.load`, `view.proofColors`, `view.overprintPreview` and `view.separationsPreview`. It also cannot run @@ -12686,7 +12686,8 @@ installed packs; the web app has none, and no `proof.*` commands. Installs and index fetches need downloading on. Only the person using a Craft app turns it on, with their own click (the setting is the font store's, shared by the apps): no command turns it on, and until then an install is an error that says so. A caller with automation roots (`--automation-read-root`, `--automation-write-root`) can list packs -but not fetch, install or remove them, since the store is outside its roots. In the desktop app installs and fetches +but not fetch, install or remove them, since the store is outside its roots. A script cannot run the `proof.*` +commands at all, since a run's rollback cannot put the store back. In the desktop app installs and fetches run in the background: `proof.installPack` returns `{locale, started: true}` and `proof.packs` shows the install in `installing`, then in `installed` or `errors`. In `vectorcraft-cli` they return once done. From 39c5e98a3ef9eeb0174af54c19ca11d068438bc1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 03:15:09 -0800 Subject: [PATCH 043/264] Scripts: refuse unsafe close saves and refused multi-file writes up front - A save of several files whose file access refuses one of them returns the refusal before any file goes to the writer, so a writer that does not check the file access writes nothing. - close(SaveOptions.SAVECHANGES) throws before writing, and leaves the document open, when the document's last save named some of its artboards, since saving with those options again could leave changes out of the file. - The script check no longer treats an object literal's saveAs or exportFile as the script's own when a function body assigns the variable without declaring it, or when the script assigns it as a property of this (the global object in global code and in a function called without a receiver). - The close-with-SAVECHANGES format test reads the saved PDF and checks that it holds the change made after the first save. - docs/mcp.md limits the "none of them is written" sentence for SVG linked images to refusals found before the first write, and documents the new close refusal. --- crates/engine/src/cmd/fileio/save.rs | 11 +++--- crates/engine/src/script/dom/save_open.rs | 26 +++++++++++-- crates/engine/src/tests/script_save_open.rs | 43 ++++++++++++++++++++- crates/scriptcheck/src/analyze.rs | 39 +++++++++++++++++++ crates/scriptcheck/src/analyze/features.rs | 17 +++++++- crates/scriptcheck/src/tests.rs | 40 +++++++++++++++++++ docs/mcp.md | 6 ++- 7 files changed, 168 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index cf00d4194a..7c185352a0 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -1071,15 +1071,14 @@ impl SaveJob { return Ok(stopped); } // Every path is checked against the file access in force before the first file is - // written. A refused file goes to `write` first, which refuses it with the error the - // caller gives (naming the path as the caller does), so none of the files is written. + // written. A refused file is not handed to `write`, so a writer that does not check the + // file access writes none of the files; the error is the file access's own refusal, as + // the writers that check it give. #[cfg(not(target_arch = "wasm32"))] if files.len() > 1 - && let Some((p, bytes)) = files.iter().find(|(p, _)| super::may_write(p).is_err()) + && let Some(refused) = files.iter().find_map(|(p, _)| super::may_write(p).err()) { - write(p, bytes)?; - // A writer that does not check the file access writes none of the others. - return Err(super::may_write(p).err().unwrap_or_else(|| crate::EngineError::Other(format!("file access denied: {p}")))); + return Err(refused); } for (i, (p, bytes)) in files.iter().enumerate() { if i == 0 { diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index 6400b32f73..8d282ce7bb 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -896,12 +896,29 @@ const UNSAVED_CHANGES: &str = const NO_FILE_TO_SAVE: &str = "the document has unsaved changes and no file to save them to: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; +/// The error `close(SaveOptions.SAVECHANGES)` gives for a document with unsaved changes whose +/// last save named some of its artboards: saving with those options again could leave changes out. +const SAVES_SOME_ARTBOARDS: &str = + "the document was last saved with some of its artboards named: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; + +/// Whether the options `st` was last saved with name artboards (`artboard`, `artboards`, or a +/// `range` other than all of them), so that a save with them may write only some of the artboards. +fn picks_artboards(st: &crate::doc_state::DocState) -> bool { + let options = crate::cmd::fileio::remembered_save_options(st); + crate::cmd::fileio::ARTBOARD_PARAMS.iter().any(|k| match options.get(*k) { + None | Some(Value::Null) => false, + Some(Value::String(r)) if *k == "range" => !(r.trim().is_empty() || r.trim().eq_ignore_ascii_case("all")), + Some(_) => true, + }) +} + /// `document.close(saveOptions?)`: `file.close` of the document. A document without unsaved /// changes closes with any `SaveOptions`. With unsaved changes, `SaveOptions.DONOTSAVECHANGES` /// closes it without them; `SaveOptions.SAVECHANGES` saves them to the document's file with /// `file.saveAs` in the format the document was last saved in, after the write-access check `saveAs` makes of /// the path, and then closes it, and throws [`NO_FILE_TO_SAVE`] -/// for a document that has no file, a converted or recovered one included; and +/// for a document that has no file, a converted or recovered one included, and +/// [`SAVES_SOME_ARTBOARDS`] before writing when the document's last save named some of its artboards; and /// `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws [`UNSAVED_CHANGES`], since a script /// cannot show the prompt. fn doc_close(h: &Host, a: &[Data]) -> Answer { @@ -910,13 +927,16 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { Some(d) => member(d, "SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"], "saveOptions")?, None => "PROMPTTOSAVECHANGES", }; - let (dirty, file, format) = - super::with_doc(h, doc, |_, st| (st.is_dirty(), st.path.clone().filter(|_| !st.converted && !st.recovered), st.format)); + let (dirty, file, format, picked) = + super::with_doc(h, doc, |_, st| (st.is_dirty(), st.path.clone().filter(|_| !st.converted && !st.recovered), st.format, picks_artboards(st))); if dirty { match how { "DONOTSAVECHANGES" => {} "SAVECHANGES" => { let path = file.ok_or_else(|| HostError::Error(NO_FILE_TO_SAVE.into()))?; + if picked { + return Err(HostError::Error(SAVES_SOME_ARTBOARDS.into())); + } // A refusal names the document, as `fullName` does when the read roots hide its file. let name = super::with_doc(h, doc, |_, st| st.title()); let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?; diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index a3f937a244..9ce5c2f820 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -208,7 +208,7 @@ fn a_save_writes_nothing_when_one_of_its_files_is_refused() { } /// When the writer a save is given does not check the file access itself, a save of several files -/// still writes none of them after the refused one. +/// whose file access refuses one of them hands none of them to the writer. #[test] fn a_refused_file_stops_a_save_whose_writer_does_not_check() { use crate::cmd::fileio::{SaveMode, save_job, save_plan}; @@ -247,7 +247,7 @@ fn a_refused_file_stops_a_save_whose_writer_does_not_check() { }); assert!(r.is_err(), "{r:?}"); let refused = refused.unwrap(); - assert_eq!(written, std::slice::from_ref(&refused), "only the refused file went to the writer"); + assert_eq!(written, Vec::::new(), "no file went to the writer, the refused one ({refused}) included"); let mut perms = std::fs::metadata(&refused).unwrap().permissions(); #[allow(clippy::permissions_set_readonly_false)] perms.set_readonly(false); @@ -722,10 +722,49 @@ fn closing_with_save_changes_keeps_the_documents_format() { ); let bytes = std::fs::read(dir.join("p.svg")).unwrap_or_default(); assert!(bytes.starts_with(b"%PDF"), "the save on close keeps the PDF format"); + let pdf = vectorcraft_pdf::import(&bytes).unwrap(); + let mut sizes = vec![]; + for l in &pdf.layers { + l.walk(&mut |n| sizes.extend(n.geometric_bounds().map(|b| (b.width(), b.height())))); + } + let near = |(w, h): (f64, f64), (x, y): (f64, f64)| (w - x).abs() < 0.01 && (h - y).abs() < 0.01; + assert!(sizes.iter().any(|&s| near(s, (5.0, 5.0))), "the file holds the rectangle drawn after the first save: {sizes:?}"); + assert!(sizes.iter().any(|&s| near(s, (50.0, 20.0))), "and the first one: {sizes:?}"); assert!(s.documents().is_empty()); let _ = std::fs::remove_dir_all(base); } +/// `close(SaveOptions.SAVECHANGES)` on a document whose last save named some of its artboards +/// throws before writing and leaves the document open, so no change is left out of its file. +#[test] +fn closing_with_save_changes_refuses_a_save_of_some_artboards() { + let base = folder("closerange"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('artboard.new', {{x: 300, y: 0, width: 60, height: 80}});\n\ + var o = new PDFSaveOptions(); o.artboardRange = '2'; d.saveAs(new File({d} + '/r.pdf'), o);\n\ + vc.run('shape.rectangle', {{x: 20, y: 20, width: 5, height: 5}});\n\ + var e = ''; try {{ d.close(SaveOptions.SAVECHANGES); }} catch (x) {{ e = String(x); }} vc.log([e, app.documents.length]);" + ), + ); + assert!(out[0][0].as_str().unwrap().contains("some of its artboards"), "{}", out[0]); + assert_eq!(out[0][1], json!(1), "the document stays open"); + let pdf = vectorcraft_pdf::import(&std::fs::read(dir.join("r.pdf")).unwrap()).unwrap(); + let mut drawn = 0; + for l in &pdf.layers { + l.walk(&mut |n| drawn += usize::from(n.geometric_bounds().is_some_and(|b| (b.width() - 5.0).abs() < 0.01))); + } + assert_eq!(drawn, 0, "the file is left as the first save wrote it"); + assert!(s.active().unwrap().is_dirty(), "the change is still unsaved"); + let _ = std::fs::remove_dir_all(base); +} + /// Setting `Document.saved` records the document's saved state without saving it: `true` lets /// `close()` close a document with edits, and `false` makes an untouched one ask. #[test] diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 8765501507..7a596f5633 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -647,6 +647,12 @@ struct Analyzer<'s, 'a, 'l> { /// What the receiver before the last `[` read defines in [`Analyzer::writers`], 0 for a receiver /// that is not such a variable. index_receiver: u8, + /// The variables that may get another value when code read elsewhere runs: assigned inside a + /// function body that does not declare them, or as a property of `this` ([`Analyzer::reassigned_later`]). + /// None of them joins [`Analyzer::writers`]. + later: HashSet, + /// `later` ran out of room: no variable joins [`Analyzer::writers`]. + later_full: bool, /// This file or what the scan started with gives names values the analysis doesn't read /// ([`Declared::unsure`]): no object counts as a Folder object whatever the path names. unsure: bool, @@ -727,6 +733,8 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { objects: vec![], closed: None, index_receiver: 0, + later: HashSet::new(), + later_full: false, unsure: known.unsure || declared.unsure, own_names: HashSet::new(), scopes: vec![], @@ -1417,9 +1425,18 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { // A name after `.`, `..`, `.@`, `::` or `@` is a property's or an attribute's; any other // name before `=` is a variable, at the start of a statement or inside an expression. if !member_mark(h1) && !is(h1, "@") { + if !self.scopes.is_empty() && !self.declared_in_body(name.text) { + self.reassigned_later(name.text); + } self.assign = Some(Assign { name: name.text.to_string(), after_new: false }); } } + if let Some((name, _)) = self.updated(t) + && !self.scopes.is_empty() + && !self.declared_in_body(name) + { + self.reassigned_later(name); + } match self.updated(t) { // The value on the right is read at this depth, and the name holds nothing the check // follows once that value ends ([`Analyzer::settle_groups`]). @@ -1435,12 +1452,34 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { fn settle_literal(&mut self, t: &Sig<'s>) { if let Some((name, bits)) = self.closed.take() && (t.is(";") || t.is(",") || (t.nl && !goes_on_with(t))) + && !self.later_full + && !self.later.contains(&name) && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) { self.writers.insert(name, bits); } } + /// `name` may get another value when code read elsewhere runs: a function body assigns it without + /// declaring it, and the function may be called before or after any line, or it is assigned as a + /// property of `this`. Its object literal's methods are no longer known, now or later. + fn reassigned_later(&mut self, name: &str) { + self.writers.remove(name); + if !self.later.contains(name) { + if self.acc.room(self.later.len()) { + self.later.insert(name.to_string()); + } else { + self.later_full = true; + } + } + } + + /// Whether `name` is declared in a function body this token is inside (`var name`, `function + /// name`, a parameter). + fn declared_in_body(&self, name: &str) -> bool { + self.scopes.iter().any(|s| s.saved.get(name).is_some_and(|v| v.local)) + } + /// `t` in an object literal assigned to a variable, `before` the bracket depth before `t`: a single /// function expression directly inside its braces as the whole value of a key that names a /// document method writing a file (`{saveAs: function … {…}, …}`, `{'exportFile': function … {…}}`) diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 48303c173e..9a99338da4 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -376,9 +376,24 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// `local[k] = w`, `delete local.saveAs`). fn writer_use(&mut self, t: &Sig<'s>) { let [h0, h1, h2, h3] = self.h; - let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before) != 0).map(|s| s.text); let changes = t.kind == T::Punct && (t.text == "=" || COMPOUND.contains(&t.text) || matches!(t.text, "++" | "--")); let key = t.is(":") && (is(h1, "{") || is(h1, ",")); + // `this.local = …` or `this['local'] = …`: `this` is the global object in the global code and in a + // function called without a receiver (ECMA-262 3rd edition, sections 10.2.1 and 10.2.3), so the + // global variable of that name may get another value. + if changes { + let global = if is(h1, ".") && word(h2, "this") { + h0.filter(|s| s.kind == T::Ident).map(|s| s.text.to_string()) + } else if is(h0, "]") && is(h2, "[") && word(h3, "this") { + h1.filter(|s| s.kind == T::Str).map(|s| unquote(s.text, 64)) + } else { + None + }; + if let Some(name) = global { + self.reassigned_later(&name); + } + } + let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before) != 0).map(|s| s.text); let escaped = if word(h0, "delete") { // `delete local…` writer(Some(*t), h0) diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 1524d4d7ae..422679f803 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -664,6 +664,46 @@ fn only_a_whole_var_value_makes_save_as_the_scripts_own() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7, 9, 11, 13, 14, 17][..])); } +/// A function body read before the literal that assigns its variable without declaring it may run +/// after the literal, so the literal's `saveAs` keeps reporting the write; a body that declares the +/// name assigns its own variable. +#[test] +fn a_function_read_earlier_that_assigns_the_variable_keeps_save_as_writing() { + let r = report(concat!( + "var f = new File(p);\n", + "function choose() { d = app.activeDocument; }\n", + "var d = {saveAs: function () {}};\n", + "choose(); d.saveAs(f);\n", + "function bump() { e++; }\n", + "var e = {saveAs: function () {}};\n", + "e.saveAs(f);\n", + "function own() { var g; g = app.activeDocument; }\n", + "var g = {saveAs: function () {}};\n", + "g.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7][..])); +} + +/// Assigning a property of `this`, the global object in the global code and in a function called +/// without a receiver, may give the global variable of that name another value, before or after +/// its literal. +#[test] +fn assigning_a_property_of_this_keeps_save_as_writing() { + let r = report(concat!( + "var f = new File(p);\n", + "var d = {saveAs: function () {}};\n", + "this.d = app.activeDocument;\n", + "d.saveAs(f);\n", + "function swap() { this['e'] = app.activeDocument; }\n", + "var e = {saveAs: function () {}};\n", + "swap(); e.saveAs(f);\n", + "var g = {saveAs: function () {}};\n", + "this.other = 1;\n", + "g.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7][..])); +} + /// A `saveAs` key's value is a method of the script's own only when the whole value is one function /// expression: a value that goes on after the function's body, and a literal inside another, leave /// `saveAs` writing the file. A literal given to a function body's own variable at the end of the body diff --git a/docs/mcp.md b/docs/mcp.md index 5c2c05d8fe..c3794b55b4 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2935,7 +2935,8 @@ other files through `$`: format's extension unless the name already ends with it (`.jpg` or `.jpeg`, `.tif` or `.tiff`, `.svgz` with `compressed`), and writes one file: the active artboard with `artBoardClipping`, otherwise the bounds of the visible art. An SVG with `embedRasterImages` false also writes the document's embedded images beside it, and - when one of those files may not be written, none of them is. A listed option that is not mapped is accepted at its help page's default, and any other value throws + when the script's folders refuse one of those files, none of them is written; a write that fails once the + first file is in place leaves the files written before it. A listed option that is not mapped is accepted at its help page's default, and any other value throws an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`. A property the help pages do not list throws an error that names it (`PDFFileOptions` also accepts its read-only `typename` and `parent`), and an `undefined` one is left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default @@ -2956,7 +2957,8 @@ other files through `$`: undo step. With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`; `SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format the document was last saved in and after the same write-access check of the path as `saveAs`, and throws an error - and leaves the document open when the document has no file (a converted or recovered document included); and + and leaves the document open when the document has no file (a converted or recovered document included) or when + its last save named some of its artboards, without writing anything; and `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot show the prompt. A bad value throws an error before anything is written. - `PageItem.tags` and `Document.tags` are `Tags` collections (https://ai-scripting.docsforadobe.dev/jsobjref/Tags/) From 9ed5e06ff3ec424b727068875cd77d9a3e15f86a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 17:12:28 -0800 Subject: [PATCH 044/264] Dependencies: craft-libs f762f98a, with the status-bar zoom look and the compass clear of the scroll bars - Every craft-libs crate moves from 610c86792a to f762f98a (craft-libs main), which adds the fixed corner-widget inset, the ruler corner's plus, popover padding, and a native window's move recorded once. - The status bar's Zoom field uses ZoomField::status_bar, so it draws without an outline in the status bar's look. - The Rotate View compass is placed in CanvasScrollbars::clear_of instead of a copy of the scroll bars' sizes. - The tools' corner-widget inset is public, and a test holds it equal to CornerWidgets::INSET, the inset the canvas draws the widgets at. --- Cargo.lock | 170 ++++++++++----------- Cargo.toml | 70 ++++----- apps/vectorcraft-web/Cargo.toml | 2 +- crates/tools/src/corners.rs | 5 +- crates/ui-egui/src/canvas.rs | 7 +- crates/ui-egui/src/canvas/widgets/tests.rs | 6 + crates/ui-egui/src/chrome/status_bar.rs | 23 ++- xtask/src/pdf_deps.rs | 2 +- 8 files changed, 155 insertions(+), 130 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 520647b95d..c36c00d090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853" +source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index a0fb986dcc..4551280d71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index e8b56c29a9..305ed6a65e 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/tools/src/corners.rs b/crates/tools/src/corners.rs index 3d02e37aa0..a958422e6d 100644 --- a/crates/tools/src/corners.rs +++ b/crates/tools/src/corners.rs @@ -21,8 +21,9 @@ use crate::{Action, Overlay, PointerEvent, ToolContext}; pub const DIALOG: &str = "corners"; /// Widgets sit at least this far inside their corner along each side of a right angle (screen px; -/// √2 times it along the bisector, at any angle), further in once the radius is. -const MIN_INSET_PX: f64 = 10.0; +/// √2 times it along the bisector, at any angle), further in once the radius is. The canvas draws the +/// widgets at the framework's `CornerWidgets::INSET`, which the UI's tests hold equal to this value. +pub const MIN_INSET_PX: f64 = 10.0; /// Corners with a side shorter than this on screen (px) hide their widgets. const MIN_SIDE_PX: f64 = 3.0 * MIN_INSET_PX; diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 9a7734e494..ab89a47115 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -404,15 +404,12 @@ fn compass(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option egui::Rect { if app.ui.screen_mode >= 2 { return rect; } - let env = Env::of(ui); - let strip = env.tokens.size.icon.md + env.tokens.space.gap.tight; - egui::Rect::from_min_max(rect.min, egui::pos2((rect.right() - strip).max(rect.left()), rect.bottom())) + CanvasScrollbars::clear_of(ui, rect, false, false) } /// The scroll bars along the right and bottom edges (Normal and Full Screen with Menu Bar): the view diff --git a/crates/ui-egui/src/canvas/widgets/tests.rs b/crates/ui-egui/src/canvas/widgets/tests.rs index 68e70867bd..63721050d6 100644 --- a/crates/ui-egui/src/canvas/widgets/tests.rs +++ b/crates/ui-egui/src/canvas/widgets/tests.rs @@ -101,6 +101,12 @@ fn corner_widgets_hide_above_the_preference_angle() { assert!(corners(&app, app.session.tool_id(), app.view_info().zoom).is_none()); } +/// The tools hit-test corner widgets at the inset the canvas draws them at. +#[test] +fn corner_widgets_are_hit_tested_at_the_inset_they_are_drawn_at() { + assert_eq!(vectorcraft_tools::corners::MIN_INSET_PX, f64::from(CornerWidgets::INSET)); +} + /// #1232: the pointer within 5 screen points of a corner widget gives the cut of the corner it controls, in the /// layer colour, with Direct Selection, the Selection tool and the Rectangle tool. It gives none with a mouse button /// down (a press on the widget or a pan), during a drag from the widget, off the canvas, away from the widgets, or diff --git a/crates/ui-egui/src/chrome/status_bar.rs b/crates/ui-egui/src/chrome/status_bar.rs index 51834cb232..1a3df7737b 100644 --- a/crates/ui-egui/src/chrome/status_bar.rs +++ b/crates/ui-egui/src/chrome/status_bar.rs @@ -241,7 +241,7 @@ fn show_navigation(p: &mut Navigation<'_>, ui: &mut Ui) { let (view, document) = (p.view, p.document); let zoom = Field::new(tl!("Zoom")) .side(SideLabel::new().kind(LabelKind::Hidden)) - .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).show(ui)); + .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui)); // The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom. if let Some(zoom) = zoom.inner { if let Some(view) = zoom.view.committed() { @@ -500,6 +500,27 @@ mod tests { } } + /// The Zoom field draws in the status bar's look: no outline while it does not have the focus. + #[test] + fn the_zoom_field_draws_in_the_status_bars_look() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0)); + let mut panel = Panel::new(app, status_bar); + panel.room(egui::vec2(1200.0, 300.0)); + panel.frame(); + let field = panel.rect("Zoom"); + let (shapes, _) = panel.paint_at(1.0); + let outlines = shapes + .iter() + .filter(|shape| match shape { + egui::Shape::Rect(rect) => rect.stroke.width > 0.0 && rect.stroke.color.a() > 0 && rect.rect.intersects(field), + _ => false, + }) + .count(); + assert_eq!(outlines, 0, "the status bar's Zoom field draws no outline"); + } + #[test] fn with_no_document_the_artboard_navigator_shows_a_dash() { let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 1b04ed6518..cbe18b7dcf 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "610c86792a02aa3d416926ee44e3ec3788dea853"; +const REV: &str = "f762f98a988b8a94a0031f428d4256eb38c87adb"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 19fecfb74964916a8189830473948a8d49315119 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 18:09:21 -0800 Subject: [PATCH 045/264] Dependencies: craft-libs 81bca5c8e2 Every craft-libs crate moves from f762f98a to 81bca5c8e2 (craft-libs main). The new rev adds the title bar's item gap, docking of part of a collapsed column, the tool rail's footer rule, disabled accessibility nodes that ignore actions, and built-in themes that load without a cycle search. VectorCraft builds on it without other changes. --- Cargo.lock | 170 ++++++++++++++++---------------- Cargo.toml | 70 ++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 122 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c36c00d090..f742ccdb7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=f762f98a988b8a94a0031f428d4256eb38c87adb#f762f98a988b8a94a0031f428d4256eb38c87adb" +source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 4551280d71..21419659e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 305ed6a65e..45f012ea3e 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "f762f98a988b8a94a0031f428d4256eb38c87adb", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index cbe18b7dcf..752b3dfcb7 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "f762f98a988b8a94a0031f428d4256eb38c87adb"; +const REV: &str = "81bca5c8e27893341003716a1a740ef05ae88dd8"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 0d5850f616e46c7258df6cd5c6ed9b702823313d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 18:41:43 -0800 Subject: [PATCH 046/264] Scripts: build on main's optional item bounds and painting-tool check main's item_rect now gives no bounds for an empty object, and the Live Paint Bucket check became tool_paints for the fill and the stroke. rotate and resize leave a path without bounds unchanged, and appearance.setNewArt uses the same inheritance test as paint.rs. --- crates/engine/src/cmd/newart.rs | 6 +++++- crates/engine/src/script/dom.rs | 4 +--- crates/engine/src/script/dom/defaults.rs | 12 ++---------- crates/engine/src/script/dom/paths.rs | 23 +++++++++++++++-------- crates/engine/src/tests/script_dom.rs | 8 +++++--- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index 2637927046..f9563ee886 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -172,7 +172,11 @@ fn set_new_art(s: &mut Session, p: &Value) -> Result { return Err(bad(C, "dashOffset needs a dash pattern")); } let nothing = fill.is_none() && stroke.is_none() && change.is_empty() && fill_overprint.is_none() && stroke_overprint.is_none(); - if !nothing && !s.prefs.new_art_basic && !s.bucket_paints() && s.active().is_some_and(|st| !st.selection.subjects().is_empty()) { + if !nothing + && !s.prefs.new_art_basic + && !(s.tool_paints(false) && s.tool_paints(true)) + && s.active().is_some_and(|st| !st.selection.subjects().is_empty()) + { return Err(bad( C, "with New Art Has Basic Appearance off, new art takes the selected object's appearance: deselect it or turn the option on", diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index 39c22665fd..b02050c5c5 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -2868,9 +2868,7 @@ fn classes(link: &Link) -> Vec { ]); document.extend(defaults::document_members(l)); document.extend( - ["layers", "artboards", "groupItems", "swatches", "symbols", "activeLayer", "saveAs", "close"] - .into_iter() - .map(|m| later(l, "Document", m)), + ["layers", "artboards", "groupItems", "swatches", "symbols", "activeLayer", "saveAs", "close"].into_iter().map(|m| later(l, "Document", m)), ); document.extend(variables::document_members(l)); document.push(("tags".into(), get(l, tags::doc_tags), MemberInfo { collection: true, ..typed("Tags") })); diff --git a/crates/engine/src/script/dom/defaults.rs b/crates/engine/src/script/dom/defaults.rs index 4b8e24cbb3..9080d30dd7 100644 --- a/crates/engine/src/script/dom/defaults.rs +++ b/crates/engine/src/script/dom/defaults.rs @@ -192,18 +192,10 @@ pub(super) fn document_members(l: &Link) -> Vec { named(vec![ ("defaultFillColor", property(l, |h, a| default_color(h, a, true), |h, a| set_default_color(h, a, true)), typed("Color")), ("defaultFilled", property(l, |h, a| default_painted(h, a, true), |h, a| set_default_painted(h, a, true)), typed("boolean")), - ( - "defaultFillOverprint", - property(l, |h, a| default_overprint(h, a, true), |h, a| set_default_overprint(h, a, true)), - typed("boolean"), - ), + ("defaultFillOverprint", property(l, |h, a| default_overprint(h, a, true), |h, a| set_default_overprint(h, a, true)), typed("boolean")), ("defaultStrokeColor", property(l, |h, a| default_color(h, a, false), |h, a| set_default_color(h, a, false)), typed("Color")), ("defaultStroked", property(l, |h, a| default_painted(h, a, false), |h, a| set_default_painted(h, a, false)), typed("boolean")), - ( - "defaultStrokeOverprint", - property(l, |h, a| default_overprint(h, a, false), |h, a| set_default_overprint(h, a, false)), - typed("boolean"), - ), + ("defaultStrokeOverprint", property(l, |h, a| default_overprint(h, a, false), |h, a| set_default_overprint(h, a, false)), typed("boolean")), ( "defaultStrokeWidth", property(l, default_stroke_width, set_default_stroke_width), diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 503e5c3ffe..356afe8b99 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -67,9 +67,9 @@ use vectorcraft_js::{Data, HostClass, HostError, HostItem, HostMember, MemberInf use vectorcraft_tools::params::gradient_params; use super::{ - Answer, Coords, Described, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, command_value, coordinate, doc_of, edit_item, - editable, find_doc, float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, on_doc, pair, - point, point_get, point_method, point_property, property, returns, this_doc, typed, whole, with_doc, + Answer, Coords, Described, Doc, Item, Link, NOT_FOUND, STALE_ITEM, arg, boolean, class, colors, command, command_value, coordinate, doc_of, + edit_item, editable, find_doc, float, frame, get, given, handle_of, id_of, id_parts, item_of, item_rect, later, method, named, num, number, + on_doc, pair, point, point_get, point_method, point_property, property, returns, this_doc, typed, whole, with_doc, }; use crate::{DocState, NodeId, NodeKind}; @@ -1155,8 +1155,9 @@ fn path_rotate(h: &super::Host, a: &[Data]) -> Answer { let place = about_name(arg(a, 6))?; let mut params = json!({"angle": angle}); transform_options(a, 2, &mut params)?; - if angle.rem_euclid(360.0) != 0.0 { - let (r, _) = item_rect(h, item, false)?; + if angle.rem_euclid(360.0) != 0.0 + && let (Some(r), _) = item_rect(h, item, false)? + { let origin = about(h, item, place, r)?; params["origin"] = json!([origin.x, origin.y]); edit_path(h, item, "object.rotate", params)?; @@ -1185,8 +1186,9 @@ fn path_resize(h: &super::Host, a: &[Data]) -> Answer { if new_width.is_some_and(|w| w > MAX_STROKE_WIDTH) { return Err(HostError::Range("changeLineWidths would make the stroke weight more than 1000 points".into())); } - if sx != 100.0 || sy != 100.0 { - let (r, _) = item_rect(h, item, false)?; + if (sx != 100.0 || sy != 100.0) + && let (Some(r), _) = item_rect(h, item, false)? + { let origin = about(h, item, place, r)?; params["origin"] = json!([origin.x, origin.y]); edit_path(h, item, "object.scale", params)?; @@ -1637,7 +1639,12 @@ fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { pub(super) fn path_item_members(l: &Link) -> Vec { let transform = |first: &[(&'static str, &'static str)]| { let mut args: Vec<(&str, &str)> = first.to_vec(); - args.extend([("changePositions", "boolean"), ("changeFillPatterns", "boolean"), ("changeFillGradients", "boolean"), ("changeStrokePattern", "boolean")]); + args.extend([ + ("changePositions", "boolean"), + ("changeFillPatterns", "boolean"), + ("changeFillGradients", "boolean"), + ("changeStrokePattern", "boolean"), + ]); args }; let mut resize = transform(&[("scaleX", "number"), ("scaleY", "number")]); diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 35d5c8e6a9..cf96155be9 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1243,9 +1243,11 @@ fn a_startup_preset_alone_gives_its_first_size() { #[test] fn page_item_members_not_built_yet_throw_on_read_and_assignment() { let (mut s, _, _) = doc(); - for source in - ["app.activeDocument.pageItems[0].isIsolated;", "app.activeDocument.pageItems[0].uuid = 'x';", "app.activeDocument.pageItems[0].transform(5);"] - { + for source in [ + "app.activeDocument.pageItems[0].isIsolated;", + "app.activeDocument.pageItems[0].uuid = 'x';", + "app.activeDocument.pageItems[0].transform(5);", + ] { assert!(failure(&mut s, source).contains("is not available yet"), "{source}"); } assert!(failure(&mut s, "app.activeDocument.layers = 1;").contains("Document.layers is not available yet")); From eb1407217f2e3c72fe66587ba21bbc1f0a019505 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:05:55 +0000 Subject: [PATCH 047/264] feat: Object > Step and Repeat for print-and-cut sheets Grid or fill-sheet layout with per-axis gaps measured on a chosen cut path, optional 180-degree alternation of columns or rows, scriptable as object.stepAndRepeat. --- crates/engine/src/cmd.rs | 2 + crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/src/cmd/stepandrepeat.rs | 214 ++++++++++++++++++ crates/engine/src/cmd/stepandrepeat/tests.rs | 132 +++++++++++ crates/ui-egui/src/dialogs.rs | 1 + crates/ui-egui/src/dialogs/object_dialogs.rs | 6 +- .../src/dialogs/rearrange_artboards.rs | 2 +- crates/ui-egui/src/dialogs/step_repeat.rs | 147 ++++++++++++ crates/ui-egui/src/menus/tree.rs | 1 + 9 files changed, 504 insertions(+), 2 deletions(-) create mode 100644 crates/engine/src/cmd/stepandrepeat.rs create mode 100644 crates/engine/src/cmd/stepandrepeat/tests.rs create mode 100644 crates/ui-egui/src/dialogs/step_repeat.rs diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 009fc4efd8..17132f9b5a 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -109,6 +109,7 @@ mod textedit; pub use textedit::effective_kerning; mod retype; +mod stepandrepeat; pub mod textstyles; pub(crate) mod textwrap; pub(crate) mod threads; @@ -325,6 +326,7 @@ pub fn command_specs() -> &'static [CommandSpec] { v.extend(layerpanel::specs()); v.extend(draw2::specs()); v.extend(xform::specs()); + v.extend(stepandrepeat::specs()); v.extend(effectcmd::specs()); v.extend(bevels::specs()); v.extend(wireframe::specs()); diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 612cf436b7..b4ffedbd77 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -415,6 +415,7 @@ pub(super) const ALLOWED: &[&str] = &[ "object.textWrap.release", "object.transform", "object.transformAgain", + "object.stepAndRepeat", "object.transformEach", "object.ungroup", "object.unlockAll", diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs new file mode 100644 index 0000000000..cc66e04a69 --- /dev/null +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -0,0 +1,214 @@ +//! Object › Step and Repeat: lays out copies of the selection on a grid or fills a sheet, for +//! print-and-cut work (stickers, labels). + +use serde_json::{Value, json}; +use vectorcraft_geom::{Rect, Vec2, rotate_deg}; + +use super::edit::{copy_above, selected_roots}; +use super::object::group_nodes; +use super::{Affine, CommandSpec, NodeId, Result, Session, bad, check_numbers, check_switches, cmd, has_selection, switch_or}; +use crate::EngineError; +use vectorcraft_doc::Scaling; + +const CMD: &str = "object.stepAndRepeat"; +const MAX_CELLS: usize = 10_000; +const EPS: f64 = 1e-9; + +pub fn specs() -> Vec { + vec![cmd!( + "object.stepAndRepeat", + "Step and Repeat…", + ["Object", "Transform"], + None, + "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutPath`, else of the selection, not between centers), cutPath?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", + has_selection, + step_and_repeat + )] +} + +/// Which cells of the grid are turned by 180°. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Alternate { + None, + Columns, + Rows, +} + +/// One cell of a layout: its place in the grid, the offset of its top-left corner from the first +/// cell's, and whether its copy is turned by 180° about the cell's center. +#[derive(Clone, Copy, PartialEq, Debug)] +pub struct Cell { + pub row: usize, + pub col: usize, + pub dx: f64, + pub dy: f64, + pub turned: bool, +} + +/// How many items of `size` with `gap` between them fit in `room` (all at least 0). +pub fn fit_count(room: f64, size: f64, gap: f64) -> usize { + if !(room.is_finite() && size.is_finite() && gap.is_finite()) || size <= 0.0 || room < size - EPS { + return 0; + } + (((room + gap) / (size + gap)) + EPS).floor().max(0.0) as usize +} + +/// The `(rows, columns)` of items `w` × `h` with gaps `gx`, `gy` that fit a sheet `sw` × `sh` +/// inside `margin` on every side. +pub fn fill_counts(sw: f64, sh: f64, margin: f64, w: f64, h: f64, gx: f64, gy: f64) -> (usize, usize) { + let m = margin.max(0.0); + (fit_count(sh - 2.0 * m, h, gy), fit_count(sw - 2.0 * m, w, gx)) +} + +/// The cells of a `rows` × `cols` grid of items `w` × `h` with gaps `gx` between columns and `gy` +/// between rows, in reading order. +pub fn layout(w: f64, h: f64, gx: f64, gy: f64, rows: usize, cols: usize, alt: Alternate) -> Vec { + (0..rows) + .flat_map(|row| (0..cols).map(move |col| (row, col))) + .map(|(row, col)| Cell { + row, + col, + dx: col as f64 * (w + gx), + dy: row as f64 * (h + gy), + turned: match alt { + Alternate::None => false, + Alternate::Columns => col % 2 == 1, + Alternate::Rows => row % 2 == 1, + }, + }) + .collect() +} + +fn count_param(p: &Value, key: &str) -> Result { + match p.get(key).filter(|v| !v.is_null()) { + None => Ok(1), + Some(v) => v + .as_u64() + .filter(|n| (1..=MAX_CELLS as u64).contains(n)) + .map(|n| n as usize) + .ok_or_else(|| bad(CMD, format!("`{key}` must be a whole number from 1 to {MAX_CELLS}"))), + } +} + +fn sheet_param(p: &Value) -> Result> { + let Some(v) = p.get("sheet").filter(|v| !v.is_null()) else { return Ok(None) }; + let n = |k: &str| v.get(k).and_then(Value::as_f64).filter(|x| x.is_finite()).ok_or_else(|| bad(CMD, format!("`sheet.{k}` must be a number"))); + let (x, y, w, h) = (n("x")?, n("y")?, n("width")?, n("height")?); + if w <= 0.0 || h <= 0.0 { + return Err(bad(CMD, "`sheet` needs a positive width and height")); + } + Ok(Some(Rect::new(x, y, x + w, y + h))) +} + +fn step_and_repeat(s: &mut Session, p: &Value) -> Result { + check_numbers(p, &["gap", "gapX", "gapY", "margin"], CMD)?; + check_switches(p, &["patterns"], CMD)?; + let fill = switch_or(p, "fill", false, CMD)?; + let alt = match p.get("rotate").filter(|v| !v.is_null()) { + None => Alternate::None, + Some(v) => match v.as_str() { + Some("none") => Alternate::None, + Some("columns") => Alternate::Columns, + Some("rows") => Alternate::Rows, + _ => return Err(bad(CMD, "`rotate` must be \"none\", \"columns\" or \"rows\"")), + }, + }; + let gap = super::f64_or(p, "gap", 0.0); + let (gx, gy) = (super::f64_or(p, "gapX", gap), super::f64_or(p, "gapY", gap)); + let margin = super::f64_or(p, "margin", 0.0); + if !(gx.is_finite() && gy.is_finite() && margin.is_finite()) { + return Err(bad(CMD, "gaps and margin must be finite")); + } + let (rows, cols) = (count_param(p, "rows")?, count_param(p, "columns")?); + let sheet = sheet_param(p)?; + let mut roots = selected_roots(s)?; + if roots.is_empty() { + return Err(EngineError::Other("nothing selected".into())); + } + let d = &s.doc()?.doc; + let cut = match p.get("cutPath").filter(|v| !v.is_null()) { + None => None, + Some(v) => { + let id = NodeId(v.as_u64().ok_or_else(|| bad(CMD, "`cutPath` must be an object id"))?); + let held = roots.iter().filter_map(|r| d.node(*r)).any(|n| { + let mut found = false; + n.walk(&mut |c| found |= c.id == id); + found + }); + if !held { + return Err(bad(CMD, "`cutPath` must be part of the selection")); + } + Some(id) + } + }; + let measured = cut.map_or_else(|| roots.clone(), |id| vec![id]); + let b = d.bounds_of(&measured, false); + let b = b.ok_or_else(|| EngineError::Other("the selection has no bounds".into()))?; + let (w, h) = (b.width(), b.height()); + if !(w.is_finite() && h.is_finite()) || w <= 0.0 || h <= 0.0 { + return Err(EngineError::Other("the selection has no area to repeat".into())); + } + let anchor = if fill { + let sheet = sheet.or_else(|| { + let c = b.center(); + d.artboards.iter().find(|a| a.rect.contains(c)).or_else(|| d.artboards.first()).map(|a| a.rect) + }); + let sheet = sheet.ok_or_else(|| EngineError::Other("no sheet to fill".into()))?; + Some((sheet, margin.max(0.0))) + } else { + None + }; + let (rows, cols) = match anchor { + Some((sh, m)) => fill_counts(sh.width(), sh.height(), m, w, h, gx, gy), + None => (rows, cols), + }; + if rows == 0 || cols == 0 { + return Err(EngineError::Other("the selection does not fit the sheet".into())); + } + if rows.saturating_mul(cols) > MAX_CELLS { + return Err(bad(CMD, format!("more than {MAX_CELLS} copies"))); + } + let origin = anchor.map_or(Vec2::ZERO, |(sh, m)| Vec2::new(sh.x0 + m - b.x0, sh.y0 + m - b.y0)); + let cells = layout(w, h, gx, gy, rows, cols, alt); + let center = b.center().to_vec2(); + let place = |c: &Cell| -> Affine { + let t = Affine::translate(origin + Vec2::new(c.dx, c.dy)); + if c.turned { t * Affine::translate(center) * rotate_deg(180.0) * Affine::translate(-center) } else { t } + }; + let sc = Scaling { patterns: super::object::transform_patterns(s, p, &roots)?, ..Scaling::default() }; + let ids = s.edit("Step and Repeat", |d, sel| { + if roots.len() > 1 { + roots = vec![group_nodes(d, &roots)?]; + } + let mut copied: Vec = vec![]; + let mut first = Affine::IDENTITY; + for c in &cells { + let m = place(c); + if c.row == 0 && c.col == 0 { + first = m; + continue; + } + let copies = copy_above(d, &roots, |_, _, n| { + n.transform(m, sc); + super::object::keep_pixel_aligned(n, sc); + })?; + copied.extend(copies); + } + if first != Affine::IDENTITY { + for id in &roots { + if let Some(n) = d.node_mut(*id) { + n.transform(first, sc); + super::object::keep_pixel_aligned(n, sc); + } + } + } + let mut out: Vec = roots.clone(); + out.extend(copied); + sel.set(out.iter().copied()); + Ok(out) + })?; + Ok(json!({ "ids": ids.iter().map(|i| i.0).collect::>(), "rows": rows, "columns": cols, "count": ids.len() })) +} + +#[cfg(test)] +mod tests; diff --git a/crates/engine/src/cmd/stepandrepeat/tests.rs b/crates/engine/src/cmd/stepandrepeat/tests.rs new file mode 100644 index 0000000000..e2addab74b --- /dev/null +++ b/crates/engine/src/cmd/stepandrepeat/tests.rs @@ -0,0 +1,132 @@ +use serde_json::json; + +use super::*; + +const A4: (f64, f64) = (210.0, 297.0); + +#[test] +fn fills_a4_with_50_by_30_items_and_3_gap() { + assert_eq!(fill_counts(A4.0, A4.1, 0.0, 50.0, 30.0, 3.0, 3.0), (9, 4)); + assert_eq!(fill_counts(A4.0, A4.1, 5.0, 50.0, 30.0, 3.0, 3.0), (8, 3)); + assert_eq!(fill_counts(40.0, 297.0, 0.0, 50.0, 30.0, 3.0, 3.0), (9, 0)); +} + +#[test] +fn layout_places_cells_at_the_pitch_and_alternates_rotation() { + let c = layout(50.0, 30.0, 3.0, 3.0, 9, 4, Alternate::Columns); + assert_eq!(c.len(), 36); + let at = |r: usize, k: usize| c[r * 4 + k]; + assert_eq!((at(0, 0).dx, at(0, 0).dy), (0.0, 0.0)); + assert_eq!((at(2, 3).dx, at(2, 3).dy), (159.0, 66.0)); + assert_eq!(c.iter().filter(|c| c.turned).count(), 18); + assert!(at(4, 1).turned && at(4, 3).turned && !at(4, 0).turned && !at(4, 2).turned); + let rows = layout(50.0, 30.0, 3.0, 3.0, 3, 2, Alternate::Rows); + assert_eq!(rows.iter().map(|c| c.turned).collect::>(), [false, false, true, true, false, false]); + assert!(layout(50.0, 30.0, 3.0, 3.0, 3, 2, Alternate::None).iter().all(|c| !c.turned)); +} + +fn setup() -> (Session, u64) { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 210, "height": 297})).unwrap(); + let id = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 30})).unwrap()["id"].as_u64().unwrap(); + (s, id) +} + +fn bounds(s: &Session, id: u64) -> (f64, f64, f64, f64) { + let b = s.doc().unwrap().doc.node(NodeId(id)).unwrap().geometric_bounds().unwrap(); + (b.x0, b.y0, b.x1, b.y1) +} + +fn undo_steps(s: &Session) -> usize { + s.doc().unwrap().history.undo.len() +} + +#[test] +fn creates_the_grid_in_one_undo_step_and_undoes_cleanly() { + let (mut s, _) = setup(); + let (before, steps) = (s.doc().unwrap().doc.clone(), undo_steps(&s)); + let r = s.execute(CMD, &json!({"rows": 2, "columns": 3, "gap": 3})).unwrap(); + assert_eq!((r["count"].clone(), r["rows"].clone(), r["columns"].clone()), (json!(6), json!(2), json!(3))); + assert_eq!(undo_steps(&s), steps + 1); + let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); + assert_eq!(bounds(&s, ids[0]), (0.0, 0.0, 50.0, 30.0)); + assert_eq!(bounds(&s, ids[4]), (53.0, 33.0, 103.0, 63.0)); + assert_eq!(bounds(&s, ids[5]), (106.0, 33.0, 156.0, 63.0)); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(undo_steps(&s), steps); + let d = &s.doc().unwrap().doc; + assert_eq!(d.artboards.len(), before.artboards.len()); + assert!(d.node(NodeId(ids[0])).is_some()); + assert!(ids[1..].iter().all(|i| d.node(NodeId(*i)).is_none())); +} + +#[test] +fn fill_sheet_with_margin_moves_the_first_copy_to_the_corner() { + let (mut s, _) = setup(); + let r = s.execute(CMD, &json!({"fill": true, "gap": 3, "margin": 0})).unwrap(); + assert_eq!((r["rows"].clone(), r["columns"].clone(), r["count"].clone()), (json!(9), json!(4), json!(36))); + let (mut s, _) = setup(); + let r = s.execute(CMD, &json!({"fill": true, "gap": 3, "margin": 5})).unwrap(); + assert_eq!(r["count"], json!(24)); + let first = r["ids"][0].as_u64().unwrap(); + assert_eq!(bounds(&s, first), (5.0, 5.0, 55.0, 35.0)); +} + +#[test] +fn fill_places_every_cell_from_the_original_when_it_starts_away_from_the_margin() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 210, "height": 297})).unwrap(); + s.execute("shape.rectangle", &json!({"x": 20, "y": 40, "width": 50, "height": 30})).unwrap(); + let r = s.execute(CMD, &json!({"fill": true, "gap": 3, "margin": 5, "rotate": "columns"})).unwrap(); + let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); + assert_eq!((r["rows"].clone(), r["columns"].clone()), (json!(8), json!(3))); + assert_eq!(bounds(&s, ids[0]), (5.0, 5.0, 55.0, 35.0)); + assert_eq!(bounds(&s, ids[1]), (58.0, 5.0, 108.0, 35.0)); + assert_eq!(bounds(&s, ids[2]), (111.0, 5.0, 161.0, 35.0)); + assert_eq!(bounds(&s, ids[3]), (5.0, 38.0, 55.0, 68.0)); +} + +#[test] +fn alternate_columns_turn_by_180_degrees_about_the_cell_center() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 210, "height": 297})).unwrap(); + let id = s.execute("shape.polygon", &json!({"cx": 25, "cy": 15, "radius": 10, "sides": 3})).unwrap()["id"].as_u64().unwrap(); + let b0 = bounds(&s, id); + let r = s.execute(CMD, &json!({"rows": 1, "columns": 2, "gap": 4, "rotate": "columns"})).unwrap(); + let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); + let (w, b1) = (b0.2 - b0.0, bounds(&s, ids[1])); + assert!((b1.0 - (b0.0 + w + 4.0)).abs() < 1e-6 && ((b1.2 - b1.0) - w).abs() < 1e-6); + assert!((b1.1 - b0.1).abs() < 1e-6 && (b1.3 - b0.3).abs() < 1e-6); + let tri = |s: &Session, id: u64| format!("{:?}", s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind); + assert_ne!(tri(&s, ids[0]), tri(&s, ids[1])); +} + +#[test] +fn a_cut_contour_stays_grouped_with_its_artwork_in_every_copy() { + let (mut s, art) = setup(); + let cut = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 30})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [art, cut]})).unwrap(); + let r = s.execute(CMD, &json!({"rows": 1, "columns": 3, "gap": 2, "cutPath": cut})).unwrap(); + assert_eq!(r["count"], json!(3)); + let d = &s.doc().unwrap().doc; + for id in r["ids"].as_array().unwrap() { + let n = d.node(NodeId(id.as_u64().unwrap())).unwrap(); + assert!(matches!(n.kind, vectorcraft_doc::NodeKind::Group { .. })); + let mut paths = 0; + n.walk(&mut |c| paths += usize::from(matches!(c.kind, vectorcraft_doc::NodeKind::Path { .. }))); + assert_eq!(paths, 2); + } +} + +#[test] +fn rejects_bad_params_and_a_selection_that_does_not_fit() { + let (mut s, _) = setup(); + assert!(s.execute(CMD, &json!({"rows": 0})).is_err()); + assert!(s.execute(CMD, &json!({"rows": 1000, "columns": 1000})).is_err()); + assert!(s.execute(CMD, &json!({"rotate": "diagonal"})).is_err()); + assert!(s.execute(CMD, &json!({"cutPath": 999999})).is_err()); + assert!(s.execute(CMD, &json!({"fill": true, "sheet": {"x": 0, "y": 0, "width": 40, "height": 40}})).is_err()); + let mut e = Session::new(); + e.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + assert!(e.execute(CMD, &json!({})).is_err()); +} diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 0e5e2100ba..8046049528 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -146,6 +146,7 @@ pub mod shortcut_import; pub(crate) mod simplify_slider; pub mod slices; pub mod smart_punctuation; +pub mod step_repeat; pub(crate) mod smooth_slider; pub mod spot_colors; pub mod svg_filter; diff --git a/crates/ui-egui/src/dialogs/object_dialogs.rs b/crates/ui-egui/src/dialogs/object_dialogs.rs index df0c1be3ed..ee26844185 100644 --- a/crates/ui-egui/src/dialogs/object_dialogs.rs +++ b/crates/ui-egui/src/dialogs/object_dialogs.rs @@ -4,7 +4,7 @@ use super::path_ops::PathOp; use super::simplify_slider::StripKind; use super::{ blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form, - path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, transform, transform_each, + path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, step_repeat, transform, transform_each, width_point, }; use crate::VectorcraftApp; @@ -16,6 +16,8 @@ pub(crate) struct ObjectDialogs { pub transform: Option, /// The open Transform Each dialog's preview record. pub each: Option, + /// The open Step and Repeat dialog's preview record. + pub step: Option, /// The open Average, Average & Join, Offset Path and Simplify dialogs' preview records. pub path: Vec, /// The open Split Into Grid dialog's record. @@ -47,6 +49,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { sync(app); transform::pump(app, ctx); transform_each::pump(app, ctx); + step_repeat::pump(app, ctx); path_ops::pump(app, ctx); shapes::pump(app, ctx); flare_options::pump(app, ctx); @@ -75,6 +78,7 @@ pub(crate) fn open_from_menu(app: &mut VectorcraftApp, id: &str) -> bool { } match id { "object.transformEach" => transform_each::open(app), + step_repeat::CMD => step_repeat::open(app), "path.average" => path_ops::open(app, PathOp::Average), "path.averageJoin" => path_ops::open(app, PathOp::AverageJoin), "object.path.offsetPath" => path_ops::open(app, PathOp::OffsetPath), diff --git a/crates/ui-egui/src/dialogs/rearrange_artboards.rs b/crates/ui-egui/src/dialogs/rearrange_artboards.rs index 3926501a05..d567dd3363 100644 --- a/crates/ui-egui/src/dialogs/rearrange_artboards.rs +++ b/crates/ui-egui/src/dialogs/rearrange_artboards.rs @@ -110,7 +110,7 @@ impl RearrangeValues { } /// The length unit a document unit shows as. -fn length_kind(unit: Unit) -> UnitKind { +pub(super) fn length_kind(unit: Unit) -> UnitKind { match unit { Unit::Picas => UnitKind::Picas, Unit::Inches => UnitKind::Inches, diff --git a/crates/ui-egui/src/dialogs/step_repeat.rs b/crates/ui-egui/src/dialogs/step_repeat.rs new file mode 100644 index 0000000000..442c25da18 --- /dev/null +++ b/crates/ui-egui/src/dialogs/step_repeat.rs @@ -0,0 +1,147 @@ +//! Object → Step and Repeat: copies of the selection on a grid or filling a sheet, with the gaps +//! between the cut paths, every other column or row turned by 180° (`object.stepAndRepeat`), +//! previewed live on the canvas. +//! +//! Fields: `rows`, `columns`, `gapX`, `gapY` (pt), `margin` (pt), `fill` (as many as fit the +//! artboard), `rotate` (`none`, `columns` or `rows`), `cutPath` (an object of the selection, or +//! empty for the selection itself). + +use craft::ui::contract::Bind; +use craft::ui::dialog::DialogId; +use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind, ParamResult}; +use craft::ui::runtime::env::{Label, LengthUnits, UnitKind}; +use serde_json::{Map, Value, json}; + +use super::host::{HeldOptions, open_held_with}; +use super::preview::LivePreview; +use crate::VectorcraftApp; + +pub(crate) const CMD: &str = "object.stepAndRepeat"; + +pub(crate) struct Open { + pub id: DialogId, + pub preview: LivePreview, +} + +fn cut_options(app: &VectorcraftApp) -> Vec<(String, Label)> { + let mut out = vec![(String::new(), Label::from(tl!("Selection")))]; + let Some(st) = app.session.active() else { return out }; + let single = st.selection.objects.len() == 1; + for id in &st.selection.objects { + let Some(n) = st.doc.node(*id) else { continue }; + out.push((id.0.to_string(), Label::from(n.display_name()))); + if single { + for c in &n.children { + out.push((c.id.0.to_string(), Label::from(c.display_name()))); + } + } + } + out +} + +fn rows(lengths: LengthUnits, cuts: Vec<(String, Label)>) -> Vec { + let len = |key: &str, label: &'static str| Param::number(key, label, 0.0, 1.0, 2).length(lengths.clone()); + vec![ + Param::new("rows", tl!("Rows"), ParamKind::int(Some(1), Some(500), 2)).enabled_when("fill", false), + Param::new("columns", tl!("Columns"), ParamKind::int(Some(1), Some(500), 2)).enabled_when("fill", false), + len("gapX", tl!("Horizontal Gap")), + len("gapY", tl!("Vertical Gap")), + Param::new("cutPath", tl!("Cut Path"), ParamKind::choice(cuts, Some(String::new()))), + Param::new("fill", tl!("Fill the Artboard"), ParamKind::bool(false)), + len("margin", tl!("Margin")).enabled_when("fill", true), + Param::new( + "rotate", + tl!("Rotate 180°"), + ParamKind::choice( + vec![ + ("none".into(), Label::from(tl!("None"))), + ("columns".into(), Label::from(tl!("Every Other Column"))), + ("rows".into(), Label::from(tl!("Every Other Row"))), + ], + Some("none".into()), + ), + ), + ] +} + +pub fn fields() -> DialogFields { + DialogFields::from_pairs([ + ("rows", FieldValue::Int(2)), + ("columns", FieldValue::Int(2)), + ("gapX", FieldValue::Number(12.0)), + ("gapY", FieldValue::Number(12.0)), + ("margin", FieldValue::Number(0.0)), + ("fill", FieldValue::Bool(false)), + ("cutPath", FieldValue::Text(String::new())), + ("rotate", FieldValue::Text("none".into())), + ]) +} + +fn count(f: &DialogFields, key: &str) -> u64 { + f.int(key).or_else(|| f.number(key).map(|n| n as i64)).unwrap_or(1).max(1) as u64 +} + +fn params(f: &DialogFields) -> Value { + let mut p = Map::new(); + p.insert("rows".into(), json!(count(f, "rows"))); + p.insert("columns".into(), json!(count(f, "columns"))); + for k in ["gapX", "gapY", "margin"] { + p.insert(k.into(), json!(f.number(k).unwrap_or(0.0))); + } + p.insert("fill".into(), json!(f.bool("fill").unwrap_or(false))); + p.insert("rotate".into(), json!(f.text("rotate").unwrap_or("none"))); + if let Some(id) = f.text("cutPath").and_then(|t| t.parse::().ok()) { + p.insert("cutPath".into(), json!(id)); + } + Value::Object(p) +} + +pub(crate) fn open(app: &mut VectorcraftApp) -> Result { + let ctx = app.ui_ctx.clone().ok_or("no window")?; + let lengths = LengthUnits::new(UnitKind::Points, super::rearrange_artboards::length_kind(app.session.general_unit()), 72.0); + let lengths = crate::fields::bare_points(lengths, app.session.prefs.numbers_without_units_are_points); + let cuts = cut_options(app); + let dialog = HostedParamDialog::command(&ctx, CMD, fields(), move |fields| { + ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths.clone(), cuts.clone())).previews(true).values(Bind::bound(fields)) + }); + let ok = |app: &mut VectorcraftApp, result: &ParamResult| { + let mut open = app.object_dialogs.step.take().ok_or("the dialog is closed")?; + let done = std::mem::take(&mut open.preview).commit(app, CMD, params(&result.fields)); + if done.is_err() { + app.object_dialogs.step = Some(open); + } + done.map(|_| ()) + }; + let cancel: Box = Box::new(|app| { + if let Some(open) = app.object_dialogs.step.take() { + open.preview.cancel(app); + } + }); + let id = open_held_with(app, dialog, ok, HeldOptions { cancel: Some(cancel), ..Default::default() }).ok_or("no window")?; + app.object_dialogs.step = Some(Open { id, preview: LivePreview::default() }); + Ok(Value::Null) +} + +pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { + let Some(mut open) = app.object_dialogs.step.take() else { return }; + let shown = app.dialogs().and_then(|host| { + host.with(|h| h.get_by_id::(open.id).map(|d| (d.is_previewing(), params(d.fields())))) + }); + if let Some((on, p)) = shown { + let _ = open.preview.run(app, on, "Step and Repeat", CMD, &p); + } + app.object_dialogs.step = Some(open); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn cut_path_is_sent_only_when_one_is_chosen() { + let mut f = fields(); + assert!(params(&f).get("cutPath").is_none()); + f.set("cutPath", FieldValue::Text("42".into())); + assert_eq!(params(&f)["cutPath"], json!(42)); + } +} diff --git a/crates/ui-egui/src/menus/tree.rs b/crates/ui-egui/src/menus/tree.rs index b2757b3cbd..c8f67c81d7 100644 --- a/crates/ui-egui/src/menus/tree.rs +++ b/crates/ui-egui/src/menus/tree.rs @@ -847,6 +847,7 @@ pub(super) fn transform_items() -> Vec { c("Shear…", "object.shear"), Sep, c("Transform Each…", "object.transformEach"), + c("Step and Repeat…", "object.stepAndRepeat"), Sep, c("Reset Bounding Box", "object.resetBoundingBox"), cp("Rotate Bounding Box…", "object.rotateBoundingBox", json!({"angle": 0})), From 9ddc0aef3aa42c553a61c57755ee2c5cbcb6dc79 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:36:42 +0000 Subject: [PATCH 048/264] fix: step and repeat dialog on the hosted form, cut path choice, sorted review list --- crates/engine/src/cmd/plugin_call/reviewed.rs | 2 +- crates/ui-egui/src/dialogs.rs | 2 +- crates/ui-egui/src/dialogs/object_dialogs.rs | 4 ++-- crates/ui-egui/src/dialogs/step_repeat.rs | 17 ++++++++++------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index b4ffedbd77..cd7d1db8ae 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -405,6 +405,7 @@ pub(super) const ALLOWED: &[&str] = &[ "object.slice.release", "object.slice.select", "object.slice.setRect", + "object.stepAndRepeat", "object.tag.add", "object.tag.remove", "object.tag.removeAll", @@ -415,7 +416,6 @@ pub(super) const ALLOWED: &[&str] = &[ "object.textWrap.release", "object.transform", "object.transformAgain", - "object.stepAndRepeat", "object.transformEach", "object.ungroup", "object.unlockAll", diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 8046049528..eee24e9a47 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -146,9 +146,9 @@ pub mod shortcut_import; pub(crate) mod simplify_slider; pub mod slices; pub mod smart_punctuation; -pub mod step_repeat; pub(crate) mod smooth_slider; pub mod spot_colors; +pub mod step_repeat; pub mod svg_filter; pub(crate) mod svg_options; pub mod swatch_conflict; diff --git a/crates/ui-egui/src/dialogs/object_dialogs.rs b/crates/ui-egui/src/dialogs/object_dialogs.rs index ee26844185..4ef12e9828 100644 --- a/crates/ui-egui/src/dialogs/object_dialogs.rs +++ b/crates/ui-egui/src/dialogs/object_dialogs.rs @@ -4,8 +4,8 @@ use super::path_ops::PathOp; use super::simplify_slider::StripKind; use super::{ blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form, - path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, step_repeat, transform, transform_each, - width_point, + path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, step_repeat, transform, + transform_each, width_point, }; use crate::VectorcraftApp; diff --git a/crates/ui-egui/src/dialogs/step_repeat.rs b/crates/ui-egui/src/dialogs/step_repeat.rs index 442c25da18..8828f2e172 100644 --- a/crates/ui-egui/src/dialogs/step_repeat.rs +++ b/crates/ui-egui/src/dialogs/step_repeat.rs @@ -31,7 +31,7 @@ fn cut_options(app: &VectorcraftApp) -> Vec<(String, Label)> { let Some(n) = st.doc.node(*id) else { continue }; out.push((id.0.to_string(), Label::from(n.display_name()))); if single { - for c in &n.children { + for c in n.children().into_iter().flatten() { out.push((c.id.0.to_string(), Label::from(c.display_name()))); } } @@ -40,7 +40,7 @@ fn cut_options(app: &VectorcraftApp) -> Vec<(String, Label)> { } fn rows(lengths: LengthUnits, cuts: Vec<(String, Label)>) -> Vec { - let len = |key: &str, label: &'static str| Param::number(key, label, 0.0, 1.0, 2).length(lengths.clone()); + let len = |key: &str, label: &'static str| Param::number(key, label, 0.0, 1.0, 2).length(lengths); vec![ Param::new("rows", tl!("Rows"), ParamKind::int(Some(1), Some(500), 2)).enabled_when("fill", false), Param::new("columns", tl!("Columns"), ParamKind::int(Some(1), Some(500), 2)).enabled_when("fill", false), @@ -96,13 +96,17 @@ fn params(f: &DialogFields) -> Value { Value::Object(p) } -pub(crate) fn open(app: &mut VectorcraftApp) -> Result { +pub(crate) fn open(app: &mut VectorcraftApp) { + let _ = try_open(app); +} + +fn try_open(app: &mut VectorcraftApp) -> Result { let ctx = app.ui_ctx.clone().ok_or("no window")?; let lengths = LengthUnits::new(UnitKind::Points, super::rearrange_artboards::length_kind(app.session.general_unit()), 72.0); let lengths = crate::fields::bare_points(lengths, app.session.prefs.numbers_without_units_are_points); let cuts = cut_options(app); let dialog = HostedParamDialog::command(&ctx, CMD, fields(), move |fields| { - ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths.clone(), cuts.clone())).previews(true).values(Bind::bound(fields)) + ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths, cuts.clone())).previews(true).values(Bind::bound(fields)) }); let ok = |app: &mut VectorcraftApp, result: &ParamResult| { let mut open = app.object_dialogs.step.take().ok_or("the dialog is closed")?; @@ -124,9 +128,8 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result { pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { let Some(mut open) = app.object_dialogs.step.take() else { return }; - let shown = app.dialogs().and_then(|host| { - host.with(|h| h.get_by_id::(open.id).map(|d| (d.is_previewing(), params(d.fields())))) - }); + let shown = + app.dialogs().and_then(|host| host.with(|h| h.get_by_id::(open.id).map(|d| (d.is_previewing(), params(d.fields()))))); if let Some((on, p)) = shown { let _ = open.preview.run(app, on, "Step and Repeat", CMD, &p); } From 8074d6fbc0cad89db688107aaebb94ea42cde631 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 25 Nov 2026 06:31:58 +0000 Subject: [PATCH 049/264] fix: say which way Step and Repeat rotate turns --- crates/engine/src/cmd/stepandrepeat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs index cc66e04a69..7109d6a766 100644 --- a/crates/engine/src/cmd/stepandrepeat.rs +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -20,7 +20,7 @@ pub fn specs() -> Vec { "Step and Repeat…", ["Object", "Transform"], None, - "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutPath`, else of the selection, not between centers), cutPath?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", + "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutPath`, else of the selection, not between centers), cutPath?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", has_selection, step_and_repeat )] From e5cb0d8dcaec63230fe2d50e528e8600612eea97 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 25 Nov 2026 19:09:38 +0000 Subject: [PATCH 050/264] fix: name the Step and Repeat cut object param cutId --- crates/engine/src/cmd/stepandrepeat.rs | 8 ++++---- crates/engine/src/cmd/stepandrepeat/tests.rs | 4 ++-- crates/ui-egui/src/dialogs/step_repeat.rs | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs index 7109d6a766..b83ebbb28a 100644 --- a/crates/engine/src/cmd/stepandrepeat.rs +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -20,7 +20,7 @@ pub fn specs() -> Vec { "Step and Repeat…", ["Object", "Transform"], None, - "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutPath`, else of the selection, not between centers), cutPath?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", + "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", has_selection, step_and_repeat )] @@ -126,17 +126,17 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { return Err(EngineError::Other("nothing selected".into())); } let d = &s.doc()?.doc; - let cut = match p.get("cutPath").filter(|v| !v.is_null()) { + let cut = match p.get("cutId").filter(|v| !v.is_null()) { None => None, Some(v) => { - let id = NodeId(v.as_u64().ok_or_else(|| bad(CMD, "`cutPath` must be an object id"))?); + let id = NodeId(v.as_u64().ok_or_else(|| bad(CMD, "`cutId` must be an object id"))?); let held = roots.iter().filter_map(|r| d.node(*r)).any(|n| { let mut found = false; n.walk(&mut |c| found |= c.id == id); found }); if !held { - return Err(bad(CMD, "`cutPath` must be part of the selection")); + return Err(bad(CMD, "`cutId` must be part of the selection")); } Some(id) } diff --git a/crates/engine/src/cmd/stepandrepeat/tests.rs b/crates/engine/src/cmd/stepandrepeat/tests.rs index e2addab74b..73948bd664 100644 --- a/crates/engine/src/cmd/stepandrepeat/tests.rs +++ b/crates/engine/src/cmd/stepandrepeat/tests.rs @@ -106,7 +106,7 @@ fn a_cut_contour_stays_grouped_with_its_artwork_in_every_copy() { let (mut s, art) = setup(); let cut = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 30})).unwrap()["id"].as_u64().unwrap(); s.execute("select.set", &json!({"ids": [art, cut]})).unwrap(); - let r = s.execute(CMD, &json!({"rows": 1, "columns": 3, "gap": 2, "cutPath": cut})).unwrap(); + let r = s.execute(CMD, &json!({"rows": 1, "columns": 3, "gap": 2, "cutId": cut})).unwrap(); assert_eq!(r["count"], json!(3)); let d = &s.doc().unwrap().doc; for id in r["ids"].as_array().unwrap() { @@ -124,7 +124,7 @@ fn rejects_bad_params_and_a_selection_that_does_not_fit() { assert!(s.execute(CMD, &json!({"rows": 0})).is_err()); assert!(s.execute(CMD, &json!({"rows": 1000, "columns": 1000})).is_err()); assert!(s.execute(CMD, &json!({"rotate": "diagonal"})).is_err()); - assert!(s.execute(CMD, &json!({"cutPath": 999999})).is_err()); + assert!(s.execute(CMD, &json!({"cutId": 999999})).is_err()); assert!(s.execute(CMD, &json!({"fill": true, "sheet": {"x": 0, "y": 0, "width": 40, "height": 40}})).is_err()); let mut e = Session::new(); e.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); diff --git a/crates/ui-egui/src/dialogs/step_repeat.rs b/crates/ui-egui/src/dialogs/step_repeat.rs index 8828f2e172..b057d1b320 100644 --- a/crates/ui-egui/src/dialogs/step_repeat.rs +++ b/crates/ui-egui/src/dialogs/step_repeat.rs @@ -3,7 +3,7 @@ //! previewed live on the canvas. //! //! Fields: `rows`, `columns`, `gapX`, `gapY` (pt), `margin` (pt), `fill` (as many as fit the -//! artboard), `rotate` (`none`, `columns` or `rows`), `cutPath` (an object of the selection, or +//! artboard), `rotate` (`none`, `columns` or `rows`), `cutId` (an object of the selection, or //! empty for the selection itself). use craft::ui::contract::Bind; @@ -46,7 +46,7 @@ fn rows(lengths: LengthUnits, cuts: Vec<(String, Label)>) -> Vec { Param::new("columns", tl!("Columns"), ParamKind::int(Some(1), Some(500), 2)).enabled_when("fill", false), len("gapX", tl!("Horizontal Gap")), len("gapY", tl!("Vertical Gap")), - Param::new("cutPath", tl!("Cut Path"), ParamKind::choice(cuts, Some(String::new()))), + Param::new("cutId", tl!("Cut Path"), ParamKind::choice(cuts, Some(String::new()))), Param::new("fill", tl!("Fill the Artboard"), ParamKind::bool(false)), len("margin", tl!("Margin")).enabled_when("fill", true), Param::new( @@ -72,7 +72,7 @@ pub fn fields() -> DialogFields { ("gapY", FieldValue::Number(12.0)), ("margin", FieldValue::Number(0.0)), ("fill", FieldValue::Bool(false)), - ("cutPath", FieldValue::Text(String::new())), + ("cutId", FieldValue::Text(String::new())), ("rotate", FieldValue::Text("none".into())), ]) } @@ -90,8 +90,8 @@ fn params(f: &DialogFields) -> Value { } p.insert("fill".into(), json!(f.bool("fill").unwrap_or(false))); p.insert("rotate".into(), json!(f.text("rotate").unwrap_or("none"))); - if let Some(id) = f.text("cutPath").and_then(|t| t.parse::().ok()) { - p.insert("cutPath".into(), json!(id)); + if let Some(id) = f.text("cutId").and_then(|t| t.parse::().ok()) { + p.insert("cutId".into(), json!(id)); } Value::Object(p) } @@ -143,8 +143,8 @@ mod tests { #[test] fn cut_path_is_sent_only_when_one_is_chosen() { let mut f = fields(); - assert!(params(&f).get("cutPath").is_none()); - f.set("cutPath", FieldValue::Text("42".into())); - assert_eq!(params(&f)["cutPath"], json!(42)); + assert!(params(&f).get("cutId").is_none()); + f.set("cutId", FieldValue::Text("42".into())); + assert_eq!(params(&f)["cutId"], json!(42)); } } From 7583602d8fae63e99e714ceb256ba6c25267d106 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 29 Nov 2026 03:12:39 +0000 Subject: [PATCH 051/264] fix: step and repeat ignores counts when filling, keeps exact spacing, lists nested cut objects --- crates/engine/src/cmd/stepandrepeat.rs | 6 ++-- crates/engine/src/cmd/stepandrepeat/tests.rs | 18 ++++++++++ crates/ui-egui/src/dialogs/step_repeat.rs | 38 ++++++++++++++------ 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs index b83ebbb28a..27ee3504c9 100644 --- a/crates/engine/src/cmd/stepandrepeat.rs +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -20,7 +20,7 @@ pub fn specs() -> Vec { "Step and Repeat…", ["Object", "Transform"], None, - "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", + "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); spacing is exact: copies are not snapped to the pixel grid; a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", has_selection, step_and_repeat )] @@ -119,7 +119,7 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { if !(gx.is_finite() && gy.is_finite() && margin.is_finite()) { return Err(bad(CMD, "gaps and margin must be finite")); } - let (rows, cols) = (count_param(p, "rows")?, count_param(p, "columns")?); + let (rows, cols) = if fill { (1, 1) } else { (count_param(p, "rows")?, count_param(p, "columns")?) }; let sheet = sheet_param(p)?; let mut roots = selected_roots(s)?; if roots.is_empty() { @@ -190,7 +190,6 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { } let copies = copy_above(d, &roots, |_, _, n| { n.transform(m, sc); - super::object::keep_pixel_aligned(n, sc); })?; copied.extend(copies); } @@ -198,7 +197,6 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { for id in &roots { if let Some(n) = d.node_mut(*id) { n.transform(first, sc); - super::object::keep_pixel_aligned(n, sc); } } } diff --git a/crates/engine/src/cmd/stepandrepeat/tests.rs b/crates/engine/src/cmd/stepandrepeat/tests.rs index 73948bd664..dcf5009ca5 100644 --- a/crates/engine/src/cmd/stepandrepeat/tests.rs +++ b/crates/engine/src/cmd/stepandrepeat/tests.rs @@ -130,3 +130,21 @@ fn rejects_bad_params_and_a_selection_that_does_not_fit() { e.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); assert!(e.execute(CMD, &json!({})).is_err()); } + +#[test] +fn fill_ignores_explicit_counts() { + let (mut s, _) = setup(); + let r = s.execute(CMD, &json!({"fill": true, "rows": 0, "columns": 0, "gap": 3})).unwrap(); + assert_eq!((r["rows"].clone(), r["columns"].clone()), (json!(9), json!(4))); + assert!(s.execute(CMD, &json!({"rows": 0})).is_err()); +} + +#[test] +fn a_pixel_aligned_copy_keeps_the_requested_fractional_gap() { + let (mut s, id) = setup(); + s.execute("object.setPixelAligned", &json!({"ids": [id], "on": true})).unwrap(); + let r = s.execute(CMD, &json!({"rows": 1, "columns": 3, "gapX": 0.5})).unwrap(); + let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); + assert_eq!(bounds(&s, ids[1]).0, 50.5); + assert_eq!(bounds(&s, ids[2]).0, 101.0); +} diff --git a/crates/ui-egui/src/dialogs/step_repeat.rs b/crates/ui-egui/src/dialogs/step_repeat.rs index b057d1b320..927b344d8d 100644 --- a/crates/ui-egui/src/dialogs/step_repeat.rs +++ b/crates/ui-egui/src/dialogs/step_repeat.rs @@ -23,18 +23,20 @@ pub(crate) struct Open { pub preview: LivePreview, } +fn cut_ids(doc: &vectorcraft_doc::Document, selected: &[vectorcraft_doc::NodeId]) -> Vec<(u64, String)> { + let mut out = vec![]; + for id in selected { + if let Some(n) = doc.node(*id) { + n.walk(&mut |c| out.push((c.id.0, c.display_name()))); + } + } + out +} + fn cut_options(app: &VectorcraftApp) -> Vec<(String, Label)> { let mut out = vec![(String::new(), Label::from(tl!("Selection")))]; - let Some(st) = app.session.active() else { return out }; - let single = st.selection.objects.len() == 1; - for id in &st.selection.objects { - let Some(n) = st.doc.node(*id) else { continue }; - out.push((id.0.to_string(), Label::from(n.display_name()))); - if single { - for c in n.children().into_iter().flatten() { - out.push((c.id.0.to_string(), Label::from(c.display_name()))); - } - } + if let Some(st) = app.session.active() { + out.extend(cut_ids(&st.doc, &st.selection.objects).into_iter().map(|(id, name)| (id.to_string(), Label::from(name)))); } out } @@ -147,4 +149,20 @@ mod tests { f.set("cutId", FieldValue::Text("42".into())); assert_eq!(params(&f)["cutId"], json!(42)); } + + #[test] + fn cut_choices_reach_objects_nested_in_groups() { + let mut s = vectorcraft_engine::Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let a = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + let b = s.execute("shape.rectangle", &json!({"x": 20, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [a, b]})).unwrap(); + let inner = s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap(); + let c = s.execute("shape.rectangle", &json!({"x": 40, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [inner, c]})).unwrap(); + let outer = s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap(); + let doc = &s.doc().unwrap().doc; + let ids: Vec = cut_ids(doc, &[vectorcraft_doc::NodeId(outer)]).into_iter().map(|(i, _)| i).collect(); + assert!([outer, inner, a, b, c].iter().all(|i| ids.contains(i))); + } } From 3496bbc6a272c113f0c15ac5d7d3dc4deb0a3fb7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 19:36:20 -0800 Subject: [PATCH 052/264] Dependencies: craft-libs 07a8c471ed --- Cargo.lock | 170 ++++++++++++++++---------------- Cargo.toml | 70 ++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 122 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f742ccdb7a..8b0e5c3750 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=81bca5c8e27893341003716a1a740ef05ae88dd8#81bca5c8e27893341003716a1a740ef05ae88dd8" +source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 21419659e6..bc004dc7fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 45f012ea3e..2b3b0cb826 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "81bca5c8e27893341003716a1a740ef05ae88dd8", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 752b3dfcb7..0d0e715893 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "81bca5c8e27893341003716a1a740ef05ae88dd8"; +const REV: &str = "07a8c471ed71791b35fb4baf736248d022abead8"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From cc7d17d70c69aacebbd9a6300b3a0aaaefc49bdd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 20:49:41 -0800 Subject: [PATCH 053/264] Dependencies: craft-libs 8bea6009f9 Moves every craft-libs crate from 07a8c471ed to craft-libs main at 8bea6009f9. --- Cargo.lock | 170 ++++++++++++++++---------------- Cargo.toml | 70 ++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 122 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b0e5c3750..0ecda8546c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=07a8c471ed71791b35fb4baf736248d022abead8#07a8c471ed71791b35fb4baf736248d022abead8" +source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index bc004dc7fe..8aa545a1bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 2b3b0cb826..c59556472e 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "07a8c471ed71791b35fb4baf736248d022abead8", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 0d0e715893..f238101022 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "07a8c471ed71791b35fb4baf736248d022abead8"; +const REV: &str = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 043650d79453475332245a48cc49ff5055e5a583 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 21:21:56 -0800 Subject: [PATCH 054/264] Scripts: tighten save, open and close edge cases - saveAs picks the encoder from the requested name, so a link to a file of another format writes the format the name asks for. - fullName, path and close(SaveOptions.SAVECHANGES) resolve a relative saved path against the working directory. - close(SAVECHANGES) accepts an artboard range that covers every artboard and keeps the document open when the save would drop artboards. - app.open keeps the requested file name, rejects a file over 128 MiB before reading it, applies the requested color space to plug-in imports, and rejects PDF options for files that are not PDF content; null PDF options keep their defaults. - Explicit null options throw; assigning the current Document.saved value runs no command; Document.path reflects as Folder or string. - An implicit multi-file save names no refused path in its error. - The script checker counts SAVECHANGES only on SaveOptions and keeps write warnings for receivers that evaluated code can rebind. --- crates/engine/src/cmd/fileio.rs | 3 + crates/engine/src/cmd/fileio/access.rs | 31 +- crates/engine/src/cmd/fileio/load.rs | 8 +- crates/engine/src/cmd/fileio/save.rs | 10 +- crates/engine/src/cmd/fileio/svg.rs | 2 +- crates/engine/src/script/dom.rs | 4 +- crates/engine/src/script/dom/save_open.rs | 80 +++-- crates/engine/src/tests/script_save_open.rs | 351 ++++++++++++++++++++ crates/engine/tests/plugin_import.rs | 33 ++ crates/scriptcheck/src/analyze.rs | 4 +- crates/scriptcheck/src/analyze/features.rs | 17 +- crates/scriptcheck/src/tests.rs | 52 +++ docs/mcp.md | 15 +- 13 files changed, 563 insertions(+), 47 deletions(-) diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 5f66067142..51d7590f35 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -125,6 +125,7 @@ pub use screens::{ builtin_presets as screen_export_builtin_presets, first_file as screen_first_file, preset_list as screen_export_preset_list, preset_rows as screen_preset_rows, }; +pub(crate) use svg::lost_artboards_warning as svg_lost_artboards_warning; pub use svg::options_map as svg_options; /// Atomic file writes (a temporary file renamed over the target: a failed write never damages the /// file it replaces), for the apps' own writers too. @@ -141,6 +142,8 @@ mod formats; #[cfg(not(target_arch = "wasm32"))] pub(crate) use access::list_dir; +#[cfg(all(test, not(target_arch = "wasm32")))] +pub(crate) use access::{SCRIPT_OPEN_MAX_BYTES, SCRIPT_OPEN_TOO_LARGE}; pub(crate) use access::{check_images_in, check_scripts_of, with_readable_settings_folder}; pub use access::{check_linked_images, check_linked_scripts, write_file_with, write_save_file, write_save_file_with}; diff --git a/crates/engine/src/cmd/fileio/access.rs b/crates/engine/src/cmd/fileio/access.rs index 8ca1fedcd7..84b8bc1a4f 100644 --- a/crates/engine/src/cmd/fileio/access.rs +++ b/crates/engine/src/cmd/fileio/access.rs @@ -267,14 +267,43 @@ pub(crate) fn may_write(path: &str) -> Result<()> { crate::file_access::check_write(path).map_err(EngineError::Other) } +/// The most a file read during a script command holds, the limit an importer reads. +#[cfg(not(target_arch = "wasm32"))] +pub(crate) const SCRIPT_OPEN_MAX_BYTES: usize = vectorcraft_plugins::import::MAX_INPUT_BYTES; +/// The error of a file past [`SCRIPT_OPEN_MAX_BYTES`]. +#[cfg(not(target_arch = "wasm32"))] +pub(crate) const SCRIPT_OPEN_TOO_LARGE: &str = "file exceeds 128 MiB"; + #[cfg(not(target_arch = "wasm32"))] pub(crate) fn read_file(path: &str) -> Result> { + use std::io::Read; may_read(path)?; // A device or pipe may never end: only a regular file is read to its end. if !std::fs::metadata(path).map_err(|e| EngineError::Other(format!("{path}: {e}")))?.is_file() { return Err(EngineError::Other(format!("{path}: not a file"))); } - std::fs::read(path).map_err(|e| EngineError::Other(format!("{path}: {e}"))) + if crate::file_access::in_script_command() { + let max = SCRIPT_OPEN_MAX_BYTES; + let read = || -> std::io::Result> { + let file = std::fs::File::open(path)?; + let meta = file.metadata()?; + if !meta.is_file() { + return Err(std::io::Error::other("not a file")); + } + if meta.len() > max as u64 { + return Err(std::io::Error::other(SCRIPT_OPEN_TOO_LARGE)); + } + let mut bytes = Vec::new(); + file.take(max as u64 + 1).read_to_end(&mut bytes)?; + if bytes.len() > max { + return Err(std::io::Error::other(SCRIPT_OPEN_TOO_LARGE)); + } + Ok(bytes) + }; + read().map_err(|e| EngineError::Other(format!("{path}: {e}"))) + } else { + std::fs::read(path).map_err(|e| EngineError::Other(format!("{path}: {e}"))) + } } /// The first `max` bytes of the file at `path` (all of it when it is shorter). Anything but a diff --git a/crates/engine/src/cmd/fileio/load.rs b/crates/engine/src/cmd/fileio/load.rs index 4f11935db0..e426bd5a23 100644 --- a/crates/engine/src/cmd/fileio/load.rs +++ b/crates/engine/src/cmd/fileio/load.rs @@ -818,7 +818,7 @@ pub fn read_for_open_asking( (linked_pages(name, bytes, path.as_deref(), &opts)?, None) } else { match super::importer::pick(name, bytes, p)? { - Some(plugin) => (super::importer::load(name, bytes, &plugin, p)?, None), + Some(plugin) => (super::importer::load(name, bytes, &plugin, p)?, opts.color_mode), // The color mode `p` asks for converts the colors after the policies did, through the // profiles the document keeps. None => (load_with(name, bytes, &LoadOptions { color_mode: None, ..opts.clone() })?, opts.color_mode), @@ -1096,6 +1096,12 @@ pub(super) fn open(s: &mut Session, p: &Value) -> Result { source(p, "document.open")? } }; + if crate::file_access::in_script_command() && ["page", "cropTo"].iter().any(|k| p.get(*k).is_some_and(|v| !v.is_null())) { + let pdf = detect(src.name, &src.bytes).is_some_and(|f| matches!(f.id, "pdf" | "ai" | "ait")) && !vectorcraft_pdf::is_postscript(&src.bytes); + if !pdf { + return Err(bad("document.open", "PDF open options require a PDF file")); + } + } // A relative path is the file in the working directory: its folder is where relative links // are found (a bare file name has no folder of its own). let path = src.path.map(super::absolute_path); diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index 7c185352a0..af84199414 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -602,6 +602,7 @@ pub struct SaveJob { stamped: Option, /// The artboards also saved to files of their own (`separateArtboards`). boards: Vec, + redact_paths: bool, } /// Writes the file at a path with what the filler it is given writes into it @@ -963,7 +964,7 @@ fn job_for_stamped(s: &Session, st: &DocState, plan: SavePlan, stamped: Option 1 - && let Some(refused) = files.iter().find_map(|(p, _)| super::may_write(p).err()) + && let Some(refused) = files + .iter() + .find_map(|(p, _)| super::may_write(p).err().map(|e| if self.redact_paths { super::access::naming_in_error(e, p) } else { e })) { return Err(refused); } @@ -1240,9 +1243,10 @@ pub fn save_with(s: &mut Session, plan: SavePlan, write: impl FnMut(&str, &[u8]) /// A save command: plan, then write with the file system (a native file as it is encoded). pub(crate) fn save(s: &mut Session, mode: SaveMode, p: &Value) -> Result { let plan = save_plan(s, mode, p)?; - let job = save_job(s, plan)?; + let mut job = save_job(s, plan)?; let uid = s.doc()?.uid; let given = str_param(p, "path").is_some_and(|g| !g.is_empty()); + job.redact_paths = !given; // Without a path, the files written are the document's own file and those beside it. let mut write = |path: &str, fill: &mut dyn FnMut(&mut dyn std::io::Write) -> std::io::Result<()>| { super::write_save_file_with(path, fill).map_err(|e| if given { e } else { super::access::naming_in_error(e, path) }) diff --git a/crates/engine/src/cmd/fileio/svg.rs b/crates/engine/src/cmd/fileio/svg.rs index 066c6fc63f..e5ecc858dc 100644 --- a/crates/engine/src/cmd/fileio/svg.rs +++ b/crates/engine/src/cmd/fileio/svg.rs @@ -172,7 +172,7 @@ pub(super) fn drawn<'a>(doc: &'a Document, p: &Value) -> Option Option { +pub(crate) fn lost_artboards_warning(doc: &Document, p: &Value, label: &str) -> Option { let n = doc.artboards.len(); let preserved = plan(doc, p).is_ok_and(|(opts, ..)| opts.preserve_editing); (n > 1 && !preserved).then(|| { diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index f50dbad41d..6cbf460954 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -2751,9 +2751,7 @@ fn classes(link: &Link) -> Vec { ("toString", method(l, doc_to_string), returns("string", &[])), ]); document.extend( - ["layers", "artboards", "pathItems", "groupItems", "swatches", "symbols", "activeLayer"] - .into_iter() - .map(|m| later(l, "Document", m)), + ["layers", "artboards", "pathItems", "groupItems", "swatches", "symbols", "activeLayer"].into_iter().map(|m| later(l, "Document", m)), ); document.extend(save_open::document_members(l)); document.extend(variables::document_members(l)); diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index 8654d46d7e..bf49aae883 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -43,7 +43,8 @@ //! - `Document.path` is a `Folder` for the folder of the document's file. A document that has no //! file has a `fullName` of a `File` for its name in `Folder.current` and a `path` of `""`. //! `fullName` and `path` of a document whose file the automation read roots do not allow throw -//! `Script file access denied`. Setting `Document.saved` runs `document.setSaved`. +//! `Script file access denied`. Changing `Document.saved` runs `document.setSaved`. +//! Assigning its current value runs no command. //! - `Document.close` with unsaved changes closes without them with //! `SaveOptions.DONOTSAVECHANGES`, and saves them to the document's file first with //! `SaveOptions.SAVECHANGES`, which throws for a document that has no file (a converted or @@ -52,6 +53,9 @@ //! - `app.open(file, documentColorSpace?, options?)` takes `options` as a `PDFFileOptions` record: //! an object with `pageToOpen` and `pDFCropToBox`, used for that call only. Any other property //! but `typename` and `parent` throws the same error, unless it is `undefined`. +//! Page and crop options require PDF content, including PDF-compatible `.ai` and `.ait` files. +//! Built-in file reads by script commands reject files over 8 MiB and cap the read at 8 MiB plus one byte. +//! - Optional arguments use defaults when omitted or `undefined`; explicit `null` throws a type error. //! - `app.userInteractionLevel` starts at `UserInteractionLevel.DISPLAYALERTS` in each run. The //! commands a script runs never show a dialog, so the level does not change what they do, and it //! never allows a file the script's grants do not. @@ -696,7 +700,7 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer { let doc = this_doc(h, a)?; let path = file_path(arg(a, 1), "saveAs")?; let mut p = Map::new(); - let given_options = given(arg(a, 2)).filter(|d| !matches!(d, Data::Null)); + let given_options = given(arg(a, 2)); // Without options, a path ending in `.ai`, `.eps` or `.pdf` takes the defaults a new options // object of that format's class holds. let extension = path.rsplit(['/', '\\']).next().and_then(|n| n.rsplit_once('.')).map(|(_, e)| e.to_ascii_lowercase()); @@ -718,6 +722,9 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer { } else if !q.is_empty() { p.insert("options".into(), Value::Object(q)); } + } else { + let format = crate::cmd::fileio::format_for_name(path).map_or_else(|| super::with_doc(h, doc, |_, st| st.format), |f| f.id); + p.insert("format".into(), json!(format)); } let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?; p.insert("path".into(), json!(plain(real))); @@ -742,7 +749,7 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer { let path = file_path(arg(a, 1), "exportFile")?; let kind = export_kind(arg(a, 2))?; // Without options, an export takes the defaults a new options object of its class holds. - let mut p = match given(arg(a, 3)).filter(|d| !matches!(d, Data::Null)) { + let mut p = match given(arg(a, 3)) { None => match kind.options { Some(class) => options_params(class, &fresh(class))?, None => Map::new(), @@ -784,11 +791,11 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer { fn app_open(h: &Host, a: &[Data]) -> Answer { let path = file_path(arg(a, 1), "open")?; let mut p = Map::new(); - if let Some(d) = given(arg(a, 2)).filter(|d| !matches!(d, Data::Null)) { + if let Some(d) = given(arg(a, 2)) { let mode = if member(d, "DocumentColorSpace", &["CMYK", "RGB"], "documentColorSpace")? == "RGB" { "rgb" } else { "cmyk" }; p.insert("colorMode".into(), json!(mode)); } - if let Some(o) = given(arg(a, 3)).filter(|d| !matches!(d, Data::Null)) { + if let Some(o) = given(arg(a, 3)) { let Data::Object(items) = o else { return Err(HostError::Type("open's options must be a PDFFileOptions record".into())) }; if typename(o).is_some_and(|t| t != "PDFFileOptions") { return Err(HostError::Type("open's options must be a PDFFileOptions record".into())); @@ -819,8 +826,11 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { } } } - let real = h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; - p.insert("path".into(), json!(plain(real))); + if p.contains_key("cropTo") { + p.insert("editingData".into(), json!(false)); + } + h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; + p.insert("path".into(), json!(plain(std::path::PathBuf::from(path)))); let r = exactly(h, || command(h, "document.open", &Value::Object(p)))?; let index = match &r { Data::Object(items) => items.iter().find_map(|(k, v)| match (k.as_str(), v) { @@ -837,12 +847,23 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { /// The document's file, `None` for a document that has none, or `Script file access denied` with /// the document's name when the automation read roots do not allow the file to be named /// ([`crate::file_access::check_read`]), as `app.getIsFileOpen` reads them. -fn shown_file(st: &crate::DocState) -> std::result::Result, HostError> { - match st.path.as_deref() { +fn shown_file(st: &crate::DocState) -> std::result::Result, HostError> { + let path = st.path.as_deref().map(absolute_file).transpose()?; + match path.as_deref() { Some(p) if crate::file_access::check_read(p).is_err() => { Err(HostError::Error(format!("{}: {}", super::super::files::ACCESS_DENIED, st.title()))) } - p => Ok(p), + _ => Ok(path), + } +} + +fn absolute_file(path: &str) -> std::result::Result { + let path = std::path::Path::new(path); + if path.is_absolute() { + Ok(path.to_string_lossy().into_owned()) + } else { + let cwd = std::env::current_dir().map_err(|e| HostError::Error(e.to_string()))?; + Ok(cwd.join(path).to_string_lossy().into_owned()) } } @@ -852,7 +873,7 @@ fn doc_full_name(h: &Host, a: &[Data]) -> Answer { let doc = this_doc(h, a)?; super::with_doc(h, doc, |_, st| { Ok(match shown_file(st)? { - Some(p) => vectorcraft_js::file_ref(p), + Some(p) => vectorcraft_js::file_ref(&p), None => vectorcraft_js::file_ref(&st.title()), }) }) @@ -864,7 +885,7 @@ fn doc_path(h: &Host, a: &[Data]) -> Answer { let doc = this_doc(h, a)?; let folder = super::with_doc(h, doc, |_, st| { Ok(shown_file(st)?.and_then(|p| { - let parent = std::path::Path::new(p).parent()?.to_string_lossy().into_owned(); + let parent = std::path::Path::new(&p).parent()?.to_string_lossy().into_owned(); (!parent.is_empty()).then_some(parent) })) })?; @@ -882,6 +903,9 @@ fn doc_saved(h: &Host, a: &[Data]) -> Answer { fn doc_set_saved(h: &Host, a: &[Data]) -> Answer { let doc = this_doc(h, a)?; let saved = boolean(arg(a, 1), "Document.saved")?; + if saved == super::with_doc(h, doc, |_, st| !st.is_dirty()) { + return Ok(Data::Undefined); + } command(h, "document.setSaved", &json!({"index": doc.index, "saved": saved}))?; Ok(Data::Undefined) } @@ -897,19 +921,23 @@ const NO_FILE_TO_SAVE: &str = "the document has unsaved changes and no file to save them to: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; /// The error `close(SaveOptions.SAVECHANGES)` gives for a document with unsaved changes whose -/// last save named some of its artboards: saving with those options again could leave changes out. +/// save would keep only some of its artboards. const SAVES_SOME_ARTBOARDS: &str = - "the document was last saved with some of its artboards named: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; + "the save would keep only some of its artboards: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; -/// Whether the options `st` was last saved with name artboards (`artboard`, `artboards`, or a -/// `range` other than all of them), so that a save with them may write only some of the artboards. +/// Whether saving `st` with its remembered options would omit artboards. fn picks_artboards(st: &crate::doc_state::DocState) -> bool { - let options = crate::cmd::fileio::remembered_save_options(st); - crate::cmd::fileio::ARTBOARD_PARAMS.iter().any(|k| match options.get(*k) { - None | Some(Value::Null) => false, - Some(Value::String(r)) if *k == "range" => !(r.trim().is_empty() || r.trim().eq_ignore_ascii_case("all")), - Some(_) => true, - }) + let options = Value::Object(crate::cmd::fileio::remembered_save_options(st)); + if matches!(st.format, "svg" | "svgz") && crate::cmd::fileio::svg_lost_artboards_warning(&st.doc, &options, st.format).is_some() { + return true; + } + let count = st.doc.artboards.len(); + let pick = serde_json::from_value::(options); + match pick.map_err(|e| e.to_string()).and_then(|p| p.resolve(count)) { + Ok(None) => false, + Ok(Some(indices)) => (0..count).any(|i| !indices.contains(&i)), + Err(_) => true, + } } /// `document.close(saveOptions?)`: `file.close` of the document. A document without unsaved @@ -918,12 +946,12 @@ fn picks_artboards(st: &crate::doc_state::DocState) -> bool { /// `file.saveAs` in the format the document was last saved in, after the write-access check `saveAs` makes of /// the path, and then closes it, and throws [`NO_FILE_TO_SAVE`] /// for a document that has no file, a converted or recovered one included, and -/// [`SAVES_SOME_ARTBOARDS`] before writing when the document's last save named some of its artboards; and +/// [`SAVES_SOME_ARTBOARDS`] before writing when the save would omit artboards; and /// `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws [`UNSAVED_CHANGES`], since a script /// cannot show the prompt. fn doc_close(h: &Host, a: &[Data]) -> Answer { let doc = this_doc(h, a)?; - let how = match given(arg(a, 1)).filter(|d| !matches!(d, Data::Null)) { + let how = match given(arg(a, 1)) { Some(d) => member(d, "SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"], "saveOptions")?, None => "PROMPTTOSAVECHANGES", }; @@ -933,7 +961,7 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { match how { "DONOTSAVECHANGES" => {} "SAVECHANGES" => { - let path = file.ok_or_else(|| HostError::Error(NO_FILE_TO_SAVE.into()))?; + let path = absolute_file(&file.ok_or_else(|| HostError::Error(NO_FILE_TO_SAVE.into()))?)?; if picked { return Err(HostError::Error(SAVES_SOME_ARTBOARDS.into())); } @@ -974,7 +1002,7 @@ pub(super) fn document_members(l: &Link) -> Vec { ("saveAs", method(l, doc_save_as), returns("undefined", &[("saveIn", "File"), ("options", "*")])), ("exportFile", method(l, doc_export_file), returns("undefined", &[("exportFile", "File"), ("exportFormat", "ExportType"), ("options", "*")])), ("fullName", get(l, doc_full_name), typed("File")), - ("path", get(l, doc_path), typed("File")), + ("path", get(l, doc_path), typed("Folder|string")), ("saved", property(l, doc_saved, doc_set_saved), typed("boolean")), ("close", method(l, doc_close), returns("undefined", &[("saveOptions", "SaveOptions")])), ]) diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 9ce5c2f820..8c09da874c 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -93,6 +93,92 @@ fn save_as_export_file_and_open_write_and_read_where_the_script_may() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn relative_saved_paths_use_the_process_working_directory() { + let cwd = crate::cmd::findfiles::plain(std::fs::canonicalize(std::env::current_dir().unwrap()).unwrap()); + let relative_base = PathBuf::from(format!("vc-script-relative-save-{}", std::process::id())); + let base = cwd.join(&relative_base); + std::fs::create_dir_all(base.join("main")).unwrap(); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let file = dir.join("relative.svg"); + let relative = file.strip_prefix(&cwd).unwrap(); + s.execute("file.new", &json!({})).unwrap(); + s.execute("file.saveAs", &json!({"path": relative.to_string_lossy()})).unwrap(); + let before = std::fs::read(&file).unwrap(); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; Folder.current = new Folder({main}); var d = app.activeDocument;\n\ + vc.log([d.fullName.fsName === new File({file}).fsName, d.path.fsName === new Folder({dir}).fsName]);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}});\n\ + d.close(SaveOptions.SAVECHANGES); vc.log(app.documents.length);", + main = quoted(&base.join("main")), + file = quoted(&file), + dir = quoted(&dir), + ), + ); + assert_eq!(out, json!([[true, true], 0])); + assert_ne!(std::fs::read(&file).unwrap(), before); + let _ = std::fs::remove_dir_all(base); +} + +#[cfg(unix)] +#[test] +fn save_as_uses_the_link_name_extension_for_the_encoder() { + let base = folder("linkformat"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let target = dir.join("drawing.vectorcraft"); + std::fs::write(&target, b"").unwrap(); + std::os::unix::fs::symlink(&target, dir.join("drawing.svg")).unwrap(); + s.execute("file.new", &json!({})).unwrap(); + logged(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&dir.join("drawing.svg")))); + assert!(std::fs::read_to_string(&target).unwrap().contains("").unwrap(); + std::os::unix::fs::symlink(&target, &link).unwrap(); + let out = logged(&mut s, &base, &format!("Folder.userData; var d = app.open(new File({})); vc.log([d.name, d.fullName.name]);", quoted(&link))); + assert_eq!(out, json!([["drawing.svg", "drawing.svg"]])); + assert_eq!(s.active().unwrap().format, "svg"); + let _ = std::fs::remove_dir_all(base); +} + /// Without options, a save or export writes what an untouched new options object of its class gives. #[test] fn omitted_options_are_a_new_options_objects_defaults() { @@ -633,6 +719,121 @@ fn open_takes_the_page_and_crop_box_of_its_options() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn crop_only_options_apply_to_an_editable_pdf() { + let base = folder("pdfcroponly"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let pdf = dir.join("editable.pdf"); + s.execute("file.new", &json!({"width": 100, "height": 50})).unwrap(); + s.execute( + "file.saveAs", + &json!({"path": pdf.to_string_lossy(), "preserveEditing": true, + "bleed": {"useDocument": false, "top": 10, "bottom": 10, "left": 10, "right": 10}}), + ) + .unwrap(); + assert!(vectorcraft_pdf::editing(&std::fs::read(&pdf).unwrap()).is_some_and(|e| e.intact)); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&pdf))); + let original = s.active().unwrap().doc.artboards[0].rect; + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}), undefined, {{pDFCropToBox: PDFBoxType.PDFMEDIABOX}});", quoted(&pdf))); + let cropped = s.active().unwrap().doc.artboards[0].rect; + assert!(cropped.width() > original.width() && cropped.height() > original.height()); + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn script_document_open_rejects_files_over_the_read_limit() { + let base = folder("openreadlimit"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let file = dir.join("large.svg"); + std::fs::write(&file, b"").unwrap(); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&file))); + let count = s.documents().len(); + std::fs::OpenOptions::new().write(true).open(&file).unwrap().set_len(crate::cmd::fileio::SCRIPT_OPEN_MAX_BYTES as u64 + 1).unwrap(); + let e = failure(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&file))); + assert!(e.contains(crate::cmd::fileio::SCRIPT_OPEN_TOO_LARGE), "{e}"); + assert_eq!(s.documents().len(), count); + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn pdf_open_options_reject_other_detected_formats() { + let base = folder("pdfoptionsformat"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 50})).unwrap(); + let native = dir.join("native.pdf"); + s.execute("file.saveAs", &json!({"path": native.to_string_lossy(), "format": "vectorcraft"})).unwrap(); + let svg = dir.join("drawing.pdf"); + std::fs::write(&svg, b"").unwrap(); + let count = s.documents().len(); + let uid = s.active().unwrap().uid; + for file in [&native, &svg] { + for options in ["{pageToOpen: 2}", "{pDFCropToBox: PDFBoxType.PDFMEDIABOX}"] { + let script = format!("Folder.userData; app.open(new File({}), undefined, {options});", quoted(file)); + let e = failure(&mut s, &base, &script); + assert!(e.contains("PDF open options require a PDF file"), "{e}"); + assert_eq!(s.documents().len(), count); + assert_eq!(s.active().unwrap().uid, uid); + } + } + let pdf = dir.join("actual.svg"); + s.execute("file.saveCopy", &json!({"path": pdf.to_string_lossy(), "format": "pdf"})).unwrap(); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}), undefined, {{pageToOpen: 1}});", quoted(&pdf))); + assert_eq!(s.documents().len(), count + 1); + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn script_document_open_treats_null_pdf_options_as_omitted() { + let base = folder("nullpdfdefaults"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({})).unwrap(); + for extension in ["svg", "vectorcraft"] { + let file = dir.join(format!("drawing.{extension}")); + s.execute("file.saveAs", &json!({"path": file.to_string_lossy()})).unwrap(); + for options in ["page: null", "cropTo: null", "page: null, cropTo: null"] { + let count = s.documents().len(); + logged(&mut s, &base, &format!("Folder.userData; vc.run('document.open', {{path: {}, {options}}});", quoted(&file))); + assert_eq!(s.documents().len(), count + 1, "{extension}: {options}"); + assert_eq!(s.active().unwrap().doc.artboards.len(), 1); + } + } + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn explicit_null_options_do_not_save_export_open_or_close() { + let base = folder("nulloptions"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 50})).unwrap(); + let file = dir.join("existing.svg"); + let original = b""; + std::fs::write(&file, original).unwrap(); + let f = format!("new File({})", quoted(&file)); + for call in [ + format!("app.activeDocument.saveAs({f}, null);"), + format!("app.activeDocument.exportFile({f}, ExportType.SVG, null);"), + format!("app.open({f}, null);"), + format!("app.open({f}, undefined, null);"), + "app.activeDocument.close(null);".into(), + ] { + let e = failure(&mut s, &base, &format!("Folder.userData; {call}")); + assert!(e.contains("TypeError"), "{call}: {e}"); + assert_eq!(std::fs::read(&file).unwrap(), original, "{call}"); + assert_eq!(s.documents().len(), 1, "{call}"); + assert!(!s.active().unwrap().is_dirty(), "{call}"); + } + logged(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs({f}, undefined);")); + assert_ne!(std::fs::read(&file).unwrap(), original); + logged(&mut s, &base, "Folder.userData; app.activeDocument.close(undefined);"); + assert!(s.documents().is_empty()); + let _ = std::fs::remove_dir_all(base); +} + /// `fullName` and `path` name the document's file and folder once it has one, `saved` follows its /// changes, and `close` with `SaveOptions.DONOTSAVECHANGES` closes it. #[test] @@ -765,6 +966,109 @@ fn closing_with_save_changes_refuses_a_save_of_some_artboards() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn closing_with_save_changes_accepts_a_range_covering_all_current_artboards() { + let base = folder("closefullrange"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + for (name, range, boards) in [("one", "1", 1), ("two", "1-2", 2)] { + let file = dir.join(format!("{name}.pdf")); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": boards})).unwrap(); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.activeDocument, o = new PDFSaveOptions(); o.artboardRange = '{range}';\n\ + d.saveAs(new File({}), o);", + quoted(&file), + ), + ); + let before = std::fs::read(&file).unwrap(); + logged( + &mut s, + &base, + "Folder.userData; vc.run('shape.rectangle', {x: 10, y: 10, width: 5, height: 5}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(s.documents().is_empty()); + assert_ne!(std::fs::read(&file).unwrap(), before); + } + s.execute("file.new", &json!({})).unwrap(); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var o = new PDFSaveOptions(); o.artboardRange = '1'; app.activeDocument.saveAs(new File({}), o);\n\ + vc.run('artboard.new', {{x: 300, y: 0, width: 60, height: 80}});", + quoted(&dir.join("grown.pdf")), + ), + ); + let before = std::fs::read(dir.join("grown.pdf")).unwrap(); + let e = failure(&mut s, &base, "Folder.userData; app.activeDocument.close(SaveOptions.SAVECHANGES);"); + assert!(e.contains("some of its artboards"), "{e}"); + assert_eq!(s.documents().len(), 1); + assert_eq!(std::fs::read(dir.join("grown.pdf")).unwrap(), before); + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn closing_with_save_changes_refuses_svg_artboard_loss_before_writing() { + let base = folder("closesvgboards"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + for extension in ["svg", "svgz"] { + for preserve in [false, true] { + let file = dir.join(format!("drawing-{preserve}.{extension}")); + let path = quoted(&file); + let save = if preserve { + format!("vc.run('file.saveAs', {{path: {path}, preserveEditing: true}});") + } else { + format!("d.saveAs(new File({path}));") + }; + logged(&mut s, &base, &format!("Folder.userData; var d = app.documents.add(DocumentColorSpace.RGB, 100, 50); {save}")); + let before = std::fs::read(&file).unwrap(); + logged(&mut s, &base, "Folder.userData; vc.run('artboard.new', {x: 300, y: 0, width: 60, height: 80});"); + let uid = s.active().unwrap().uid; + if preserve { + logged(&mut s, &base, "Folder.userData; app.activeDocument.close(SaveOptions.SAVECHANGES);"); + assert!(s.documents().is_empty()); + assert_ne!(std::fs::read(&file).unwrap(), before); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}));")); + assert_eq!(s.active().unwrap().doc.artboards.len(), 2); + } else { + let e = failure(&mut s, &base, "Folder.userData; app.activeDocument.close(SaveOptions.SAVECHANGES);"); + assert!(e.contains("some of its artboards"), "{extension}: {e}"); + assert_eq!(s.documents().len(), 1); + assert_eq!(s.active().unwrap().uid, uid); + assert_eq!(s.active().unwrap().doc.artboards.len(), 2); + assert!(s.active().unwrap().is_dirty()); + assert_eq!(std::fs::read(&file).unwrap(), before); + } + logged(&mut s, &base, "Folder.userData; app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);"); + } + } + let _ = std::fs::remove_dir_all(base); +} + +#[test] +fn document_path_reflection_describes_folders_and_unsaved_strings() { + let base = folder("pathreflection"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.documents.add();\n\ + vc.log([d.reflect.find('path').dataType, d.path === '']);\n\ + d.saveAs(new File({})); vc.log([d.reflect.find('path').dataType, d.path instanceof Folder ? 'Folder' : typeof d.path]);\n\ + vc.log([d.path instanceof Folder, d.path.fsName]);", + quoted(&dir.join("saved.svg")), + ), + ); + assert_eq!(out, json!([["Folder|string", true], ["Folder|string", "Folder"], [true, dir.to_string_lossy()]])); + let _ = std::fs::remove_dir_all(base); +} + /// Setting `Document.saved` records the document's saved state without saving it: `true` lets /// `close()` close a document with edits, and `false` makes an untouched one ask. #[test] @@ -794,6 +1098,24 @@ fn setting_saved_records_the_saved_state() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn unchanged_saved_assignments_do_not_record_commands() { + let base = folder("savednoop"); + let mut s = session(&base); + let out = logged( + &mut s, + &base, + "var d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + d.saved = d.saved; d.saved = true; vc.log(d.saved);\n\ + d.saved = false; d.saved = d.saved; d.saved = false; vc.log(d.saved);\n\ + d.saved = true; d.saved = d.saved; vc.log(d.saved);", + ); + assert_eq!(out, json!([true, false, true])); + let changes: Vec<_> = s.journal.iter().filter(|(id, _)| id == "document.setSaved").map(|(_, p)| p["saved"].clone()).collect(); + assert_eq!(changes, [json!(false), json!(true)]); + let _ = std::fs::remove_dir_all(base); +} + /// With automation read roots that leave out the document's file, `fullName` and `path` throw /// instead of naming another file. #[test] @@ -831,6 +1153,35 @@ fn full_name_and_path_leave_out_a_file_outside_the_read_roots() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn implicit_multifile_save_redacts_preflight_refusals_before_writing() { + let base = folder("savepreflight"); + let mut s = session(&base); + let hidden = base.join("private-save-directory"); + std::fs::create_dir_all(&hidden).unwrap(); + let path = hidden.join("drawing.vectorcraft"); + s.execute("file.new", &json!({"artboards": 2})).unwrap(); + let saved = s.execute("document.save", &json!({"path": path.to_string_lossy(), "separateArtboards": true})).unwrap(); + let files: Vec<_> = saved["files"].as_array().unwrap().iter().map(|p| PathBuf::from(p.as_str().unwrap())).collect(); + assert!(files.len() > 1); + let before: Vec<_> = files.iter().map(|p| std::fs::read(p).unwrap()).collect(); + s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 5, "height": 5})).unwrap(); + let main = base.join("main"); + let roots = crate::file_access::AutomationRoots::new(&[&main], &[&main]).unwrap().unwrap(); + let e = crate::file_access::confine(Some(&roots), || s.execute("document.save", &json!({}))).unwrap_err().to_string(); + assert!(e.contains("automation path rejected"), "{e}"); + assert!(!e.contains("private-save-directory"), "{e}"); + assert!(!e.contains(path.to_string_lossy().as_ref()), "{e}"); + assert!(s.active().unwrap().is_dirty()); + for (file, bytes) in files.iter().zip(before) { + assert_eq!(std::fs::read(file).unwrap(), bytes); + } + let explicit = + crate::file_access::confine(Some(&roots), || s.execute("document.save", &json!({"path": path.to_string_lossy()}))).unwrap_err().to_string(); + assert!(explicit.contains(path.to_string_lossy().as_ref()), "{explicit}"); + let _ = std::fs::remove_dir_all(base); +} + /// A `pDFPreset` in square brackets names the built-in preset of the name inside them, and a name /// that is not a preset either way is refused. #[test] diff --git a/crates/engine/tests/plugin_import.rs b/crates/engine/tests/plugin_import.rs index 11a42a6f90..1327e57208 100644 --- a/crates/engine/tests/plugin_import.rs +++ b/crates/engine/tests/plugin_import.rs @@ -88,6 +88,39 @@ fn path_of(p: &std::path::Path) -> String { p.to_string_lossy().into_owned() } +#[test] +fn scripted_open_converts_importer_output_to_the_requested_color_space() { + let mut s = Session::new(); + install(&mut s, &tpl::returning(&tpl::importer("test.scriptcolorspace", r#"["tscmyk"]"#, "{}"), RECT)); + let dir = tmp_dir("scriptcolorspace"); + s.attach_script_data(dir.join("settings/Script Data")); + let file = dir.join("drawing.tscmyk"); + std::fs::write(&file, b"importer input").unwrap(); + let script = dir.join("main.jsx"); + let path = serde_json::to_string(&file.to_string_lossy()).unwrap(); + for (argument, mode) in [ + ("", vectorcraft_doc::ColorMode::Rgb), + (", DocumentColorSpace.CMYK", vectorcraft_doc::ColorMode::Cmyk), + (", DocumentColorSpace.RGB", vectorcraft_doc::ColorMode::Rgb), + ] { + std::fs::write(&script, format!("Folder.userData; var d = app.open(new File({path}){argument}); vc.log(d.documentColorSpace);")).unwrap(); + let count = s.documents().len(); + let out = s.execute("script.run", &json!({"path": script.to_string_lossy()})).unwrap(); + assert_eq!(s.documents().len(), count + 1); + let doc = &s.doc().unwrap().doc; + assert_eq!(doc.color_mode, mode, "{argument}: {out}"); + let color = doc.layers[0].children().unwrap()[0].appearance.fill_paint().color().unwrap(); + if mode == vectorcraft_doc::ColorMode::Cmyk { + assert!(matches!(color, vectorcraft_color::Color::Cmyk { .. }), "{color:?}"); + assert_eq!(out["log"], json!(["DocumentColorSpace.CMYK"])); + } else { + assert!(matches!(color, vectorcraft_color::Color::Rgb { .. }), "{color:?}"); + assert_eq!(out["log"], json!(["DocumentColorSpace.RGB"])); + } + } + let _ = std::fs::remove_dir_all(dir); +} + #[test] fn an_importer_adds_a_read_only_format_while_it_is_installed() { let mut s = Session::new(); diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 7a596f5633..4ad90a30a8 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -1474,10 +1474,10 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } - /// Whether `name` is declared in a function body this token is inside (`var name`, `function + /// Whether `name` is declared in the innermost function body (`var name`, `function /// name`, a parameter). fn declared_in_body(&self, name: &str) -> bool { - self.scopes.iter().any(|s| s.saved.get(name).is_some_and(|v| v.local)) + self.scopes.last().is_some_and(|s| s.saved.get(name).is_some_and(|v| v.local)) } /// `t` in an object literal assigned to a variable, `before` the bracket depth before `t`: a single diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 9a99338da4..bf808469e5 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -208,7 +208,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else if of(catalog::FOLDER) && catalog::FOLDER_PLACES.contains(&n) { self.acc.feature(FeatureId::FilePlaces, line); } - if n == catalog::SAVE_CHANGES { + if n == catalog::SAVE_CHANGES && of(catalog::SAVE_OPTIONS) { self.save_changes(line); } if n == catalog::ON_DRAW { @@ -283,6 +283,13 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { "]" if is(h1, "[") && h0.is_some_and(|s| s.kind == T::Str) => { let name = h0.map(|s| unquote(s.text, 16)).unwrap_or_default(); self.setter(&name, h2, h3, line); + if name == catalog::SAVE_CHANGES + && word(h2, catalog::SAVE_OPTIONS) + && !member_mark(h3) + && !self.own_names.contains(catalog::SAVE_OPTIONS) + { + self.save_changes(line); + } } // `local['saveAs']`: what the object before the bracket defines, for a call that may follow. "[" => self.index_receiver = self.writer_bits(h0, h1), @@ -364,7 +371,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// 0 for anything else. A receiver the check does not follow may be a document. fn writer_bits(&self, receiver: Option>, before: Option>) -> u8 { match receiver { - Some(r) if r.kind == T::Ident && !member_mark(before) => self.writers.get(r.text).copied().unwrap_or(0), + Some(r) if !self.unsure && r.kind == T::Ident && !member_mark(before) => self.writers.get(r.text).copied().unwrap_or(0), _ => 0, } } @@ -447,11 +454,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { if t.text.contains(catalog::ACTION_TEXT) { self.acc.feature(FeatureId::Actions, line); } - // `SaveOptions['SAVECHANGES']`, or the value written as the string `"SaveOptions.SAVECHANGES"`. + // The value written as the string `"SaveOptions.SAVECHANGES"`. let value = unquote(t.text, 32); - if value == catalog::SAVE_CHANGES - || value.strip_prefix(catalog::SAVE_OPTIONS).and_then(|r| r.strip_prefix('.')) == Some(catalog::SAVE_CHANGES) - { + if value.strip_prefix(catalog::SAVE_OPTIONS).and_then(|r| r.strip_prefix('.')) == Some(catalog::SAVE_CHANGES) { self.save_changes(line); } let compares = h0.is_some_and(|s| s.kind == T::Punct && matches!(s.text, "==" | "===" | "!=" | "!==")); diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index b609217756..236bede7ce 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -573,6 +573,19 @@ fn export_variables_in_brackets_writes_a_file() { assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[3, 4][..])]); } +#[test] +fn evaluated_code_keeps_warnings_for_rebound_writer_receivers() { + for call in ["local.exportVariables(f);", "local['exportVariables'](f);", "local.saveAs(f);", "local['exportFile'](f);"] { + let r = report(&format!( + "var local = {{exportVariables: function () {{}}, saveAs: function () {{}}, exportFile: function () {{}}}};\n\ + eval('local = app.activeDocument');\n{call}\n" + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3][..]), "{call}"); + let written = r.outside.iter().find(|o| o.id == "filesWritten"); + assert_eq!(written.map(|o| o.lines.as_slice()), Some(&[3][..]), "{call}"); + } +} + /// `SaveOptions.SAVECHANGES` makes a document's `close` save it to its own file, read directly, in /// brackets, as a string or through a variable; closing without it, and the other save options, /// write nothing. @@ -592,6 +605,24 @@ fn closing_with_save_changes_writes_a_file() { assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[4, 5, 7][..])]); } +#[test] +fn unrelated_save_changes_properties_and_strings_do_not_report_writes() { + let r = report(concat!( + "var a = other.SAVECHANGES;\n", + "var b = other['SAVECHANGES'];\n", + "app.activeDocument.close('SAVECHANGES');\n", + "var c = holder.SaveOptions.SAVECHANGES;\n", + "var d = holder.SaveOptions['SAVECHANGES'];\n", + "var e = 'SAVECHANGES';\n", + "var key = SaveOptions['SAVECHANGES' + suffix];\n", + "var f = SaveOptions.SAVECHANGES;\n", + "var g = SaveOptions['SAVECHANGES'];\n", + "var h = 'SaveOptions.SAVECHANGES';\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[8, 9, 10][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[8, 9, 10][..])]); +} + /// `saveAs` and `exportFile` called with their names as string literals in brackets write the file /// too; reading the method without calling it does not. #[test] @@ -714,6 +745,27 @@ fn a_function_read_earlier_that_assigns_the_variable_keeps_save_as_writing() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7][..])); } +#[test] +fn captured_reassignments_keep_save_as_writing_after_a_later_initializer() { + let r = report(concat!( + "var f = new File(p);\n", + "function outer() {\n", + " function choose() { d = app.activeDocument; }\n", + " var d = {saveAs: function () {}};\n", + " choose(); d.saveAs(f);\n", + " function bump() { e++; }\n", + " var e = {saveAs: function () {}};\n", + " bump(); e.saveAs(f);\n", + " function own() { var g; g = app.activeDocument; }\n", + " var g = {saveAs: function () {}};\n", + " own(); g.saveAs(f);\n", + "}\n", + "outer();\n", + )); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[5, 8][..])]); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[5, 8][..])); +} + /// Assigning a property of `this`, the global object in the global code and in a function called /// without a receiver, may give the global variable of that name another value, before or after /// its literal. diff --git a/docs/mcp.md b/docs/mcp.md index a9542a7435..7e98a72bbd 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3003,6 +3003,8 @@ other files through `$`: those pages list, such as `app.version` and `Document.save()`, and the members of the pages of the page-item kinds themselves, such as a path's fill, are not defined yet and read as `undefined`. - `Document.saveAs(file, options?)` runs `file.saveAs`, and the document then has the new file. + When the format is selected by a `.vctemplate` path, `saveAs` writes a template copy and leaves the document's + file and saved state unchanged. `Document.exportFile(file, exportType, options?)` runs `document.export` and leaves the document's file as it is. `app.open(file, documentColorSpace?, options?)` runs `document.open` and gives the new `Document` (https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/). @@ -3027,7 +3029,10 @@ other files through `$`: `coordinatePrecision` (1 to 7), `embedRasterImages`, `compressed`, `preserveEditability` and `includeVariablesAndDatasets` (SVG); `PNG8`, `GIF` and `TIFF` take no options. `app.open`'s `options` is a `PDFFileOptions` record (https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/) with - `pageToOpen` and `pDFCropToBox`. `app.userInteractionLevel` is `UserInteractionLevel.DISPLAYALERTS` at the start of + `pageToOpen` and `pDFCropToBox`. These options require PDF content, including PDF-compatible `.ai` and `.ait` files. + `app.open` rejects a file over 128 MiB before reading it. + Optional arguments to `saveAs`, `exportFile`, `app.open` and `close` use defaults when omitted or `undefined`; + explicit `null` throws a type error. `app.userInteractionLevel` is `UserInteractionLevel.DISPLAYALERTS` at the start of each run. The enumerations `ExportType`, `Compatibility`, `PDFCompatibility`, `PDFBoxType`, `EPSPreview`, `EPSPostScriptLevelEnum`, `PDFOverprint`, `SaveOptions` and `UserInteractionLevel` hold strings such as `"ExportType.PNG24"`. @@ -3059,13 +3064,15 @@ other files through `$`: artboard numbers (such as `abc` or `0-`) throws. `Document.path` is a `Folder` for the folder of the document's file. A document that has no file has a `fullName` of a `File` for its name in `Folder.current` and a `path` of `""`. `fullName` and `path` of a document whose file the automation read roots do not allow throw - `Script file access denied`. Setting `saved` runs `document.setSaved`: `true` records the document as saved + `Script file access denied`. Changing `saved` runs `document.setSaved`: `true` records the document as saved without saving it, so `close()` then closes it, and `false` records it as having unsaved changes; neither adds an - undo step. With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`; + undo step. Assigning its current value runs no command and adds no journal entry. + With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`; `SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format the document was last saved in and after the same write-access check of the path as `saveAs`, and throws an error and leaves the document open when the document has no file (a converted or recovered document included) or when - its last save named some of its artboards, without writing anything; and + the save would omit artboards. These refusals occur before writing any files. An SVG or SVGZ save of several + artboards requires Preserve Editing Capabilities to close with `SaveOptions.SAVECHANGES`. `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot show the prompt. A bad value throws an error before anything is written. - `Document.textFrames` (https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItems/) lists the document's type From ff47fc8699748d8a5ffb55cb8a58069a4ec8c3f0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 21:58:54 -0800 Subject: [PATCH 055/264] Transparency: transparency.info reports the selected symbol part that transparency.set edits With an object of a dynamic symbol instance selected by Direct Selection, transparency.set without ids changes that object's opacity and blend mode for the instance, and the Transparency panel shows those values. The transparency.info command still reported the instance's own opacity and blend mode. Without ids or id it now returns the panel's values (Session::transparency_info), so it reports the part's opacity and blend mode with the instance's isolate and knockout. With ids or id it still reports those objects. --- crates/engine/src/cmd/opacitymask.rs | 16 +++++++++++----- crates/engine/src/tests/dynamic_symbols.rs | 22 ++++++++++++++++++++++ docs/mcp.md | 4 +++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/opacitymask.rs b/crates/engine/src/cmd/opacitymask.rs index 5fb3df4e32..a64d038d8f 100644 --- a/crates/engine/src/cmd/opacitymask.rs +++ b/crates/engine/src/cmd/opacitymask.rs @@ -105,7 +105,7 @@ pub fn specs() -> Vec { "Transparency Info", [], None, - "{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none); editingMask is the id of the object whose mask is being edited, or null; the page values are the document's", + "{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none). Without ids or id, with an object of a dynamic symbol instance selected by Direct Selection, opacity and blend are that object's for this instance, as transparency.set changes them; editingMask is the id of the object whose mask is being edited, or null; the page values are the document's", has_doc, info ), @@ -489,10 +489,16 @@ impl Session { fn info(s: &mut Session, p: &Value) -> Result { let st = s.doc()?; - let ids = transparency_targets(s, p)?; - // The points `transparency.set` with the same `ids` (or none) fades. - let points = if p.get("ids").is_none() && p.get("id").is_none() { s.mesh_points_picked() } else { super::paint::picked_mesh_points_of(s, &ids) }; - let i = TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points); + // Without `ids` or `id`, the values `transparency.set` without them edits: those of the panel, + // whose picked mesh points and selected dynamic symbol part take the opacity (and the part the + // blend mode). + let i = if p.get("ids").is_none() && p.get("id").is_none() { + s.transparency_info() + } else { + let ids = transparency_targets(s, p)?; + let points = super::paint::picked_mesh_points_of(s, &ids); + TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points) + }; Ok(json!({ "ids": i.ids.iter().map(|id| id.0).collect::>(), "opacity": i.opacity, diff --git a/crates/engine/src/tests/dynamic_symbols.rs b/crates/engine/src/tests/dynamic_symbols.rs index 2f88f5acc9..e406c1b4f2 100644 --- a/crates/engine/src/tests/dynamic_symbols.rs +++ b/crates/engine/src/tests/dynamic_symbols.rs @@ -1184,6 +1184,28 @@ fn opacity_and_blend_on_a_picked_object_go_through_transparency_set() { assert!((node(&t, static_inst).opacity - 0.4).abs() < 1e-6); } +#[test] +fn transparency_info_reports_the_picked_object_that_transparency_set_edits() { + let mut s = session(); + let inst = pair(&mut s, "dynamic"); + s.execute("transparency.set", &json!({"ids": [inst.0], "opacity": 75, "blend": "screen", "isolate": true, "knockout": "on"})).unwrap(); + s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [1]})).unwrap(); + s.execute("transparency.set", &json!({"opacity": 50, "blend": "multiply"})).unwrap(); + let shown = |v: &Value| (v["ids"].clone(), v["opacity"].as_f64(), v["blend"].clone(), v["isolate"].clone(), v["knockout"].clone()); + // Without ids, the picked object's opacity and blend mode, and the instance's isolate and knockout. + let info = s.execute("transparency.info", &json!({})).unwrap(); + assert_eq!(shown(&info), (json!([inst.0]), Some(50.0), json!("Multiply"), json!(true), json!("on"))); + let panel = s.transparency_info(); + assert_eq!((panel.opacity, panel.blend.map(vectorcraft_color::BlendMode::label)), (Some(50.0), Some("Multiply"))); + // The other object of the art draws as the symbol does. + s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [0]})).unwrap(); + let info = s.execute("transparency.info", &json!({})).unwrap(); + assert_eq!(shown(&info), (json!([inst.0]), Some(100.0), json!("Normal"), json!(true), json!("on"))); + // With the instance's id, the instance itself, as transparency.set with that id edits it. + let info = s.execute("transparency.info", &json!({"id": inst.0})).unwrap(); + assert_eq!(shown(&info), (json!([inst.0]), Some(75.0), json!("Screen"), json!(true), json!("on"))); +} + #[test] fn select_part_refuses_hidden_and_locked_objects_of_the_art() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index ad6a5f95be..9b98785ddc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5066,7 +5066,9 @@ already walks Image Trace. Short agent entry points: `paint.setFill` and `paint.setStroke` (solid, none, gradient or pattern) and `paint.invert` and `paint.complement` on a solid color change that object's fill or stroke for this instance only when `ids`, `id` and `item` are omitted. `transparency.set` with opacity and/or blend does the same when `ids`, `id` and `item` are omitted; with `ids` or - `id` it edits those objects, so the instance's id changes the instance. `appearance.copyFrom` takes the source's + `id` it edits those objects, so the instance's id changes the instance. `transparency.info` without `ids` or `id` + reports that object's opacity and blend mode for this instance, with the instance's isolate and knockout values; with + the instance's id it reports the instance. `appearance.copyFrom` takes the source's fill and stroke (including a gradient or pattern) for this instance only when `ids` is omitted and `reverse`, `append` and `defaultsOnly` are false or omitted, and only for each paint the Eyedropper Options pick up and apply; a paint disabled in either tree stays as it was. With `ids`, and `reverse` false or omitted, it copies From 7f821d39de46511df638852f1c089963d8e076eb Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Sun, 29 Nov 2026 06:00:33 +0000 Subject: [PATCH 056/264] test: cover fractional gaps with pixel-aligned objects, document the contract --- crates/engine/src/cmd/stepandrepeat.rs | 4 +++- crates/engine/src/cmd/stepandrepeat/tests.rs | 21 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs index 27ee3504c9..620f64a9a7 100644 --- a/crates/engine/src/cmd/stepandrepeat.rs +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -20,7 +20,7 @@ pub fn specs() -> Vec { "Step and Repeat…", ["Object", "Transform"], None, - "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); spacing is exact: copies are not snapped to the pixel grid; a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", + "{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); copies of pixel-aligned objects stay on the pixel grid, so a fractional gap between them is rounded to it, and gaps of other objects are exact; a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}", has_selection, step_and_repeat )] @@ -190,6 +190,7 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { } let copies = copy_above(d, &roots, |_, _, n| { n.transform(m, sc); + super::object::keep_pixel_aligned(n, sc); })?; copied.extend(copies); } @@ -197,6 +198,7 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { for id in &roots { if let Some(n) = d.node_mut(*id) { n.transform(first, sc); + super::object::keep_pixel_aligned(n, sc); } } } diff --git a/crates/engine/src/cmd/stepandrepeat/tests.rs b/crates/engine/src/cmd/stepandrepeat/tests.rs index dcf5009ca5..c25953d598 100644 --- a/crates/engine/src/cmd/stepandrepeat/tests.rs +++ b/crates/engine/src/cmd/stepandrepeat/tests.rs @@ -140,11 +140,18 @@ fn fill_ignores_explicit_counts() { } #[test] -fn a_pixel_aligned_copy_keeps_the_requested_fractional_gap() { - let (mut s, id) = setup(); - s.execute("object.setPixelAligned", &json!({"ids": [id], "on": true})).unwrap(); - let r = s.execute(CMD, &json!({"rows": 1, "columns": 3, "gapX": 0.5})).unwrap(); - let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); - assert_eq!(bounds(&s, ids[1]).0, 50.5); - assert_eq!(bounds(&s, ids[2]).0, 101.0); +fn fractional_gaps_are_exact_except_for_pixel_aligned_objects_which_stay_on_the_grid() { + let gap = |aligned: bool| { + let (mut s, id) = setup(); + if aligned { + s.execute("object.setPixelAligned", &json!({"ids": [id], "on": true})).unwrap(); + } + let r = s.execute(CMD, &json!({"rows": 1, "columns": 2, "gapX": 0.5})).unwrap(); + let ids: Vec = r["ids"].as_array().unwrap().iter().map(|i| i.as_u64().unwrap()).collect(); + let (a, c) = (bounds(&s, ids[0]), bounds(&s, ids[1])); + (c.0 - a.2, c.0 - a.0) + }; + assert!((gap(false).0 - 0.5).abs() < 1e-9); + let pitch = gap(true).1; + assert!((pitch - pitch.round()).abs() < 1e-9); } From c0704b7bb02d93766e1281dffd77a9e7de37de97 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:31:01 -0800 Subject: [PATCH 057/264] Pathfinder: Shape Modes buttons dim while they are off With nothing selected the four Shape Modes buttons are off, but their icon was drawn through a glyph that paints the icon's own colors and ignores the off color, so they stayed at full strength while the Pathfinders row dimmed. The buttons now show the set icon, and the glyph is used only while members with different modes are selected, where it adds the question mark and the buttons are on. --- crates/ui-egui/src/panels/pathfinder.rs | 5 +++- .../ui-egui/src/panels/tests_icon_buttons.rs | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/pathfinder.rs b/crates/ui-egui/src/panels/pathfinder.rs index d1ee58262d..1855261d6e 100644 --- a/crates/ui-egui/src/panels/pathfinder.rs +++ b/crates/ui-egui/src/panels/pathfinder.rs @@ -136,9 +136,12 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { Row::new().gap(Gap::Item).show(ui, |ui, _| { for ((icon, label, op), mode) in SHAPE_MODES.into_iter().zip(ShapeMode::ALL) { let glyph = ShapeModeGlyph { icon: IconId::new(icon), mixed }; + // The glyph paints the icon in its own inks, so it is used only for the question mark (mixed modes + // keep the buttons on). Otherwise the button paints the set icon, dimmed while it is off. + let spec = if mixed { IconSpec::glyph(&glyph) } else { IconSpec::svg(IconId::new(icon)) }; let value = if mixed { Mixed::Mixed } else { Mixed::Same(shared == Some(mode)) }; let out = ToggleButton::new(tl!(label).to_string(), Bind::given(value)) - .icon(IconSpec::glyph(&glyph)) + .icon(spec) .icon_only() .enabled(count >= 2) .tooltip(tip(label)) diff --git a/crates/ui-egui/src/panels/tests_icon_buttons.rs b/crates/ui-egui/src/panels/tests_icon_buttons.rs index b7a1ee607e..ff498339a4 100644 --- a/crates/ui-egui/src/panels/tests_icon_buttons.rs +++ b/crates/ui-egui/src/panels/tests_icon_buttons.rs @@ -54,6 +54,34 @@ fn the_align_panel_icons_fill_their_square() { assert_full_size(align::show, &names); } +/// The colors the icon meshes inside `rect` are tinted with, sorted and without repeats. +fn icon_tints(shapes: &[Shape], rect: Rect) -> Vec<[u8; 4]> { + let mut tints: Vec<[u8; 4]> = shapes + .iter() + .filter_map(|shape| match shape { + Shape::Mesh(mesh) if mesh.texture_id != TextureId::default() && rect.contains_rect(mesh.calc_bounds()) => Some(mesh), + _ => None, + }) + .flat_map(|mesh| mesh.vertices.iter().map(|v| v.color.to_array())) + .collect(); + tints.sort_unstable(); + tints.dedup(); + tints +} + +#[test] +fn the_shape_modes_dim_with_the_pathfinders_while_they_are_off() { + let mut app = app_with_rect(); + run(&mut app, "select.none", json!({})); + let mut panel = Panel::new(app, pathfinder::show); + let (shapes, _) = panel.paint_at(2.0); + let off = icon_tints(&shapes, panel.rect("Divide")); + assert!(!off.is_empty(), "no icon drawn for Divide"); + for (_, name, _) in pathfinder::SHAPE_MODES { + assert_eq!(icon_tints(&shapes, panel.rect(name)), off, "{name} is off and should be painted as the off Divide button is"); + } +} + #[test] fn the_pathfinder_panel_icons_fill_their_square() { let names: Vec<&str> = pathfinder::SHAPE_MODES.iter().chain(&pathfinder::PATHFINDERS).map(|r| r.1).collect(); From a88b5ebe7e19379fcbcd25aa083dd6880eab7c8d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:31:06 -0800 Subject: [PATCH 058/264] Dependencies: craft-libs 869c9704d9 Moves every craft-libs crate to 869c9704d9. The Image Trace test reads the dimmed Stroke row's slider by role, since the row now holds a slider and a number box under one name. --- Cargo.toml | 70 +++++++++---------- apps/vectorcraft-web/Cargo.toml | 2 +- .../ui-egui/src/panels/image_trace/tests.rs | 3 +- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8aa545a1bf..2396b9cb2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index c59556472e..f8748d719d 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/panels/image_trace/tests.rs b/crates/ui-egui/src/panels/image_trace/tests.rs index 29ed937ca9..1c7a51edc3 100644 --- a/crates/ui-egui/src/panels/image_trace/tests.rs +++ b/crates/ui-egui/src/panels/image_trace/tests.rs @@ -860,7 +860,8 @@ fn create_strokes_traces_again_and_keeps_one_kind_on() { for s in ["Create:", "Fills", "Strokes", "Stroke"] { assert!(panel.shows(s), "{s}"); } - assert_eq!(panel.value("Stroke").as_deref().and_then(number), Some(10.0)); + // The dimmed row holds a slider and a number box under one name: read the slider. + assert_eq!(panel.value_role("Stroke", craft::ui::contract::Role::SLIDER).as_deref().and_then(number), Some(10.0)); // Fills alone can't be turned off. panel.click("Fills"); assert_eq!(create(&panel), (Some(json!(true)), Some(json!(false)))); From 57e0e6297113b699636ea116b7204ed573642efd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:34:52 -0800 Subject: [PATCH 059/264] Links: rows of images on layers show their thumbnails The rows' thumbnail lookup searched only the objects outside the layer tree, so every linked or embedded image on a layer drew an empty box. A row now finds its object by the layer tree's index first, then among the objects outside the tree. --- crates/ui-egui/src/panels/links.rs | 9 +++++++-- crates/ui-egui/src/panels/tests_links.rs | 25 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/links.rs b/crates/ui-egui/src/panels/links.rs index ba3723a24e..5d69953674 100644 --- a/crates/ui-egui/src/panels/links.rs +++ b/crates/ui-egui/src/panels/links.rs @@ -118,6 +118,12 @@ impl Cache { pub(super) fn nested_node(&self, id: u64) -> Option<&Arc> { self.nested.binary_search_by_key(&id, |(n, _)| *n).ok().and_then(|i| self.nested.get(i)).map(|(_, n)| n) } + + /// The object of row `id` of `doc`, for its thumbnail: by the layer tree's index, or, for an + /// object outside the layer tree, as [`cached`] collected it. + pub(super) fn row_node(&self, doc: &vectorcraft_doc::Document, id: NodeId) -> Option> { + super::layers::node_arc(doc, id).or_else(|| self.nested_node(id.0).cloned()) + } } /// What a footer button, a row menu item or a panel menu row does to the selected rows. @@ -762,9 +768,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let rows: &[Value] = cache.list["links"].as_array().map_or(&[], Vec::as_slice); let by_id: HashMap = rows.iter().filter_map(|r| Some((r["id"].as_u64()?, r))).collect(); let row_ids: Vec = rows.iter().filter_map(|r| r["id"].as_u64()).collect(); - // `lookup` gives the objects outside the layer tree. let thumbs = super::layers::link_thumbnails(ui.ctx()); - let nodes = super::layers::NodeThumbs::new(&doc, |id| cache.nested_node(id.0).cloned()); + let nodes = super::layers::NodeThumbs::new(&doc, |id| cache.row_node(&doc, id)); let (thumbs, nodes) = (&thumbs, &nodes); let ppp = ui.ctx().pixels_per_point(); diff --git a/crates/ui-egui/src/panels/tests_links.rs b/crates/ui-egui/src/panels/tests_links.rs index e817ac9f36..af34acbd8e 100644 --- a/crates/ui-egui/src/panels/tests_links.rs +++ b/crates/ui-egui/src/panels/tests_links.rs @@ -405,6 +405,31 @@ fn a_row_in_a_stored_brushs_art_finds_its_object() { assert!(matches!(found[0].1.kind, vectorcraft_doc::NodeKind::Image(_)), "{:?}", found[0].1.kind); } +/// The rows of a linked and an embedded image in the layer tree find their objects, and their +/// thumbnails show the images. +#[test] +fn the_rows_of_images_in_the_layer_tree_have_thumbnails() { + use craft::ui::primitives::textures::{ThumbRender, ThumbRequest, ThumbSource as _}; + let dir = Folder::new("tree-thumbs"); + let (app, linked, embedded) = app(&dir); + let h = rig(app); + let st = h.state().session.active().unwrap(); + let doc = std::sync::Arc::new(st.doc.clone()); + let cache = std::sync::Arc::clone(&h.state().ui.links.cache); + let thumbs = super::layers::NodeThumbs::new(&doc, |id| cache.row_node(&doc, id)); + let request = ThumbRequest::for_cell(24.0, 1.0); + for id in [linked, embedded] { + let node = cache.row_node(&doc, vectorcraft_doc::NodeId(id)).unwrap_or_else(|| panic!("row {id} finds its object")); + assert!(matches!(node.kind, vectorcraft_doc::NodeKind::Image(_)), "{:?}", node.kind); + let key = super::layers::NodeThumb { uid: st.uid, node: vectorcraft_doc::NodeId(id) }; + match thumbs.render(&key, &request) { + ThumbRender::Ready(img) => assert!(img.pixels.iter().any(|p| p.a() > 0), "row {id}'s thumbnail shows the image"), + ThumbRender::Later(_) => {} + _ => panic!("row {id}'s thumbnail is blank"), + } + } +} + #[test] fn edit_original_and_show_in_folder_hand_the_file_to_the_system() { let dir = Folder::new("open"); From fe968bfd338f4481442757cc8e331095212e161c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:43:57 -0800 Subject: [PATCH 060/264] Dependencies: Cargo.lock takes craft-libs 869c9704d9 --- Cargo.lock | 170 ++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ecda8546c..41bd07d3fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=8bea6009f99f1d7ba955a672ebebf38fe4ec2c57#8bea6009f99f1d7ba955a672ebebf38fe4ec2c57" +source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" dependencies = [ "arrayvec", "kurbo 0.13.1", From 0488c58928647b78ee57c5170ba9ac40a7ade6ba Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 07:48:25 +0100 Subject: [PATCH 061/264] Pin VectorCraft to current craft-libs and its matching egui Keep native and web manifests, the lockfile, and the PDF source guard on the same craft-libs revision. Align the egui patch revision with craft-libs to retain one crate source. --- Cargo.lock | 198 ++++++++++++++++---------------- Cargo.toml | 98 ++++++++-------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 150 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41bd07d3fd..6023090b50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2752,7 +2752,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "bytemuck", "emath", @@ -2785,7 +2785,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "ahash", "bytemuck", @@ -2820,7 +2820,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "accesskit", "ahash", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "ahash", "bytemuck", @@ -2858,7 +2858,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "accesskit_winit", "arboard", @@ -2883,7 +2883,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "ahash", "egui", @@ -2897,7 +2897,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "bytemuck", "egui", @@ -2910,7 +2910,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "dify", "eframe", @@ -2936,7 +2936,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "bytemuck", ] @@ -3017,7 +3017,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" dependencies = [ "ahash", "bytemuck", @@ -3043,7 +3043,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" [[package]] name = "equivalent" @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=869c9704d9fdce1c3341fe8e16030e12b85e1d59#869c9704d9fdce1c3341fe8e16030e12b85e1d59" +source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -10762,14 +10762,14 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" +source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" diff --git a/Cargo.toml b/Cargo.toml index 2396b9cb2f..7ffa6409eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,25 +193,25 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +emath = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index f8748d719d..3d626ea472 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "869c9704d9fdce1c3341fe8e16030e12b85e1d59", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index f238101022..2bac79d96d 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "8bea6009f99f1d7ba955a672ebebf38fe4ec2c57"; +const REV: &str = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 5881c0c3f632854f26bdf6ec0a24a8497d00de0c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:53:58 -0800 Subject: [PATCH 062/264] Arrange: tests cover the settings chosen in Replace with Top Object and Sort Objects Replace with Top Object and Sort Objects bind their dialogs' values to the fields the preview and OK read, as Arrange in Grid, Set Size of Each and Randomize Opacity do, but no test covered those two. The new tests pick Bounds and Keep Original in Replace with Top Object and Large to Small in Sort Objects with the dialog's own controls, then check the dialog's values, the preview and the document after OK. Each fails when its dialog's values are not bound. --- crates/ui-egui/src/addons/arrange/tests.rs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/crates/ui-egui/src/addons/arrange/tests.rs b/crates/ui-egui/src/addons/arrange/tests.rs index 420bfdb01d..98eeb7c282 100644 --- a/crates/ui-egui/src/addons/arrange/tests.rs +++ b/crates/ui-egui/src/addons/arrange/tests.rs @@ -1,3 +1,4 @@ +use craft::ui::contract::Role; use serde_json::json; use vectorcraft_doc::NodeId; use vectorcraft_engine::Session; @@ -109,6 +110,58 @@ fn real_opacity_edits_drive_validation_confirmation_and_cancel() { assert!((opacity(&panel, a) - 0.8).abs() < 1e-6 && (opacity(&panel, b) - 0.8).abs() < 1e-6); } +/// The objects of the first layer, from the back. +fn stacking(panel: &Harness) -> Vec { + panel.app().session.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id).collect() +} + +#[test] +fn real_replace_edits_reach_the_preview_and_confirmed_copies() { + let (app, a, b) = app(); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Replace with Top Object…"); + panel.frame(); + panel.click_role("Size", Role::COMBO_BOX); + panel.click("Bounds"); + panel.click_role("Keep Original", Role::CHECK_BOX); + panel.frame(); + let id = host::dialog_id(&panel.app()); + let fields = host::read(&panel.app(), id, |f| (f.text("fit").map(str::to_owned), f.bool("keep"))); + assert_eq!(fields, (Some("bounds".to_owned()), Some(true))); + // The copies of the top object: every object other than the two rectangles, with its bounds. + let copies = |panel: &Harness| { + let ids: Vec = stacking(panel).into_iter().filter(|id| ![a, b].contains(id)).collect(); + let app = panel.app(); + ids.into_iter().map(|id| bounds(&app, id)).collect::>() + }; + let preview = copies(&panel); + assert_eq!(preview, vec![bounds(&panel.app(), a)], "one copy, fitted to the kept original's bounds"); + panel.click("OK"); + panel.frame(); + assert_eq!(copies(&panel), preview); + assert_eq!(stacking(&panel).len(), 3, "Keep Original leaves the original in place"); + assert!(!panel.app().any_dialog_open()); +} + +#[test] +fn real_sort_edits_reach_the_preview_and_confirmed_stacking() { + let (app, a, b) = app(); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Sort Objects…"); + panel.frame(); + assert_eq!(stacking(&panel), vec![a, b], "the smaller area is already at the back"); + panel.click_role("Order", Role::COMBO_BOX); + panel.click("Large to Small"); + panel.frame(); + let id = host::dialog_id(&panel.app()); + assert_eq!(host::read(&panel.app(), id, |f| f.text("order").map(str::to_owned)), Some("descending".to_owned())); + assert_eq!(stacking(&panel), vec![b, a], "the preview puts the larger area at the back"); + panel.click("OK"); + panel.frame(); + assert_eq!(stacking(&panel), vec![b, a]); + assert!(!panel.app().any_dialog_open()); +} + #[test] fn set_size_of_each_sets_the_sides_ticked() { let (mut app, a, b) = app(); From 92b009d819375f5c1ef39e913e99fbf2deb1ec6d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 22:56:23 -0800 Subject: [PATCH 063/264] Panels: menu rows show their names instead of command ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The menus of Swatches, Brushes, Symbols, Graphic Styles, Appearance, Paragraph, OpenType, Align, Glyphs, Pathfinder, Links, Actions, Asset Export, Image Trace, Separations, Tabs, Flattener Preview, Color Themes and CSS Properties showed 137 rows by their command ids, such as "ui.swatches.newSwatch" and "brush.new". A panel menu row takes its label from the command catalog, which lists the keymap's commands and the menu bar's rows only; the panels' own commands, and commands with params, have no entry there. Each panel's menu states now name its rows, as Stroke and Transform already did. Symbols' New Symbol… and Symbol Options… rows share one command and showed one name, and the Links menu's four Select rows all read Select by Link Status; each now shows its own name. The Paragraph menu's East Asian rows are named too. A test opens every panel menu in a frame of the whole app and fails on a row that shows its command id, or on two rows of one menu level that show the same name, with the East Asian and Indic options off and on. --- .../ui-egui/src/addons/select/link_status.rs | 9 ++- crates/ui-egui/src/panels.rs | 12 ++++ crates/ui-egui/src/panels/actions/menu.rs | 8 +-- crates/ui-egui/src/panels/align.rs | 8 +-- crates/ui-egui/src/panels/appearance.rs | 4 +- crates/ui-egui/src/panels/asset_export.rs | 55 ++++++++++----- crates/ui-egui/src/panels/brushes.rs | 19 +++++ crates/ui-egui/src/panels/color_themes.rs | 1 + crates/ui-egui/src/panels/css_properties.rs | 14 ++-- .../ui-egui/src/panels/flattener_preview.rs | 6 +- crates/ui-egui/src/panels/glyphs.rs | 1 + crates/ui-egui/src/panels/graphic_styles.rs | 13 ++++ crates/ui-egui/src/panels/image_trace.rs | 1 + crates/ui-egui/src/panels/links.rs | 47 +++++++------ crates/ui-egui/src/panels/opentype.rs | 2 +- crates/ui-egui/src/panels/paragraph.rs | 38 +++++----- crates/ui-egui/src/panels/pathfinder.rs | 2 +- crates/ui-egui/src/panels/separations.rs | 2 +- crates/ui-egui/src/panels/swatches/actions.rs | 21 ++++++ crates/ui-egui/src/panels/symbols.rs | 40 ++++++----- crates/ui-egui/src/panels/tabs.rs | 4 +- crates/ui-egui/src/panels/tests_menu_names.rs | 69 +++++++++++++++++++ 22 files changed, 275 insertions(+), 101 deletions(-) create mode 100644 crates/ui-egui/src/panels/tests_menu_names.rs diff --git a/crates/ui-egui/src/addons/select/link_status.rs b/crates/ui-egui/src/addons/select/link_status.rs index 8e0d033cb6..fcc3b3a071 100644 --- a/crates/ui-egui/src/addons/select/link_status.rs +++ b/crates/ui-egui/src/addons/select/link_status.rs @@ -80,11 +80,14 @@ pub(crate) fn rows() -> Vec { } /// Dims the Select row of each status no image or placed document has ([`enabled`]), in the states of -/// the commands the Links panel's menu shows. +/// the commands the Links panel's menu shows, and names each row and its Shift alternate for its status: the +/// catalog's label for the command is Select by Link Status's. pub(crate) fn states(app: &VectorcraftApp, states: &mut CommandStates) { - for &(status, ..) in &STATUSES { + for &(status, label, _) in &STATUSES { let params = json!({ "status": status }); - states.set(CommandRef::with_params(COMMAND, params.clone()), CommandState::new().enabled(enabled(app, ¶ms))); + let state = CommandState::new().enabled(enabled(app, ¶ms)).title(crate::i18n::t(label)); + states.set(CommandRef::with_params(COMMAND, with_shift(params.clone())), state.clone()); + states.set(CommandRef::with_params(COMMAND, params), state); } } diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index f41407b29d..2ebca9a8bc 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -614,6 +614,16 @@ pub(crate) fn panel_menu_states(app: &VectorcraftApp, states: &mut CommandStates crate::canvas::task_bar::menu_states(app, states); } +/// Names the panel menu rows `rows` in `states`, each by its English label shown in the UI language: a row the menu bar +/// and the keymap do not list has no catalog label, and shows its command id without one. The state set for a row +/// keeps its enabled and checked flags. +pub(crate) fn name_rows<'a>(states: &mut CommandStates, rows: impl IntoIterator) { + for (command, label) in rows { + let state = states.get(&command).cloned().unwrap_or_default(); + states.set(command, state.title(crate::i18n::t(label))); + } +} + /// Runs panel menu command `id` when a panel runs it itself; `None` otherwise. pub(crate) fn run_menu_command(app: &mut VectorcraftApp, id: &str, params: &Value) -> Option> { if id == "ui.libraryPanel.add" { @@ -1318,6 +1328,8 @@ mod tests_links; #[cfg(test)] mod tests_maskview; #[cfg(test)] +mod tests_menu_names; +#[cfg(test)] mod tests_panel_rows; #[cfg(test)] mod tests_panel_spacing; diff --git a/crates/ui-egui/src/panels/actions/menu.rs b/crates/ui-egui/src/panels/actions/menu.rs index 5d0d26583e..7c6c783c1a 100644 --- a/crates/ui-egui/src/panels/actions/menu.rs +++ b/crates/ui-egui/src/panels/actions/menu.rs @@ -145,17 +145,17 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { set(Row::Panel(C::InsertStop), recording || has); set(Row::Panel(C::InsertMenuItem), recording || has); set(Row::Panel(C::InsertPath), (recording || has) && f.path); - set(Row::SelectObject, recording || has); - set(Row::Options, has); set(Row::Panel(C::PlaybackOptions), true); set(Row::Panel(C::Save), f.current.is_some()); set(Row::Panel(C::Load), can_load(app)); set(Row::Panel(C::Replace), can_load(app) && f.idle); set(Row::Panel(C::ClearAll), f.idle && f.sets > 0); set(Row::Panel(C::Reset), f.idle); - // The framework's labels differ from the panel's own words on these rows. - let titled = |row: Row, title: &str, enabled: bool| (row.command(), CommandState::new().enabled(enabled).title(title.to_string())); + // The framework's labels differ from the panel's own words on these rows, and the panel's own rows have none. + let titled = |row: Row, title: &str, enabled: bool| (row.command(), CommandState::new().enabled(enabled).title(crate::i18n::t(title))); for (command, state) in [ + titled(Row::SelectObject, "Select Object…", recording || has), + titled(Row::Options, "Action Options…", has), titled(Row::Panel(C::Play), "Play Current Selection", has || f.waiting), titled(Row::Panel(C::InsertPath), "Insert Select Path", (recording || has) && f.path), titled(Row::Panel(C::ClearAll), "Clear Actions", f.idle && f.sets > 0), diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index 5a630eaa13..1eeb293edc 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -604,13 +604,13 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let hidden = part_hidden(app, HIDE_OPTIONS); let prefs = &app.session.prefs; states.set(CommandRef::new("ui.align.hideOptions"), CommandState::new().title(if hidden { tl!("Show Options") } else { tl!("Hide Options") })); - states.set(CommandRef::new("ui.align.usePreviewBounds"), CommandState::new().checked(prefs.use_preview_bounds)); - states.set(CommandRef::new("ui.align.cancelKeyObject"), CommandState::new().enabled(align_to(app) == AlignTo::Key)); + states.set(CommandRef::new("ui.align.usePreviewBounds"), CommandState::new().checked(prefs.use_preview_bounds).title(tl!("Use Preview Bounds"))); + states.set(CommandRef::new("ui.align.cancelKeyObject"), CommandState::new().enabled(align_to(app) == AlignTo::Key).title(tl!("Cancel Key Object"))); // The key choice is named for what the key is: Align to Key Anchor while it is an anchor point. let key = CommandState::new().enabled(can_choose(app, AlignTo::Key)).checked(shown_align_to(app) == AlignTo::Key); states.set(CommandRef::new("align.toKeyObject"), key.title(align_to_icon_name(AlignTo::Key, key_is_anchor(app)).1)); - states.set(CommandRef::new("ui.align.glyphBoundsPoint"), CommandState::new().checked(prefs.align_glyph_bounds_point)); - states.set(CommandRef::new("ui.align.glyphBoundsArea"), CommandState::new().checked(prefs.align_glyph_bounds_area)); + states.set(CommandRef::new("ui.align.glyphBoundsPoint"), CommandState::new().checked(prefs.align_glyph_bounds_point).title(tl!("Point Text"))); + states.set(CommandRef::new("ui.align.glyphBoundsArea"), CommandState::new().checked(prefs.align_glyph_bounds_area).title(tl!("Area Text"))); } /// Runs the Align panel menu command `id`; `None` when `id` is not one of them. The glyph-bounds diff --git a/crates/ui-egui/src/panels/appearance.rs b/crates/ui-egui/src/panels/appearance.rs index 7bce287424..c4470a4f92 100644 --- a/crates/ui-egui/src/panels/appearance.rs +++ b/crates/ui-egui/src/panels/appearance.rs @@ -1898,8 +1898,8 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let enabled = |on: bool| CommandState::new().enabled(on); states.set("appearance.addFill", enabled(has)); states.set("appearance.addStroke", enabled(has)); - states.set(DUPLICATE_ITEM, enabled(has && sel.editable())); - states.set(REMOVE_ITEM, enabled(has && sel.deletable())); + states.set(DUPLICATE_ITEM, enabled(has && sel.editable()).title(tl!("Duplicate Item"))); + states.set(REMOVE_ITEM, enabled(has && sel.deletable()).title(tl!("Remove Item"))); states.set("appearance.clear", enabled(has)); states.set("appearance.reduceToBasic", enabled(any_subject_needs_reduction(app))); states.set(new_art_basic(app), enabled(true).checked(app.session.prefs.new_art_basic)); diff --git a/crates/ui-egui/src/panels/asset_export.rs b/crates/ui-egui/src/panels/asset_export.rs index 043918e3b5..048d8dcfb0 100644 --- a/crates/ui-egui/src/panels/asset_export.rs +++ b/crates/ui-egui/src/panels/asset_export.rs @@ -824,25 +824,46 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let facts = Facts::of(app); for panel_row in menu_rows(app) { let PanelRow::Command(command) = panel_row else { continue }; - let Some(f) = &facts else { - states.set(command, CommandState::new().enabled(false)); - continue; + let row = command.id.strip_prefix(PREFIX).unwrap_or_default(); + let state = match (&facts, row) { + (None, _) => CommandState::new().enabled(false), + (Some(f), "add" | "add3D") => CommandState::new().enabled(f.has_art), + (Some(f), "selectAll") => CommandState::new().enabled(!f.all.is_empty()), + (Some(f), "remove") => CommandState::new().enabled(!f.sel.is_empty()), + (Some(f), "subfolders") => CommandState::new().checked(f.subfolders), + (Some(f), "openLocation") => CommandState::new().checked(f.open_location), + (Some(f), "applyPreset") => CommandState::new().checked(f.applied == command.params["name"].as_str().unwrap_or_default()), + (Some(f), "saveChanges" | "deletePreset") => CommandState::new().enabled(f.saved), + (Some(f), "exportPreset") => CommandState::new().enabled(f.known), + _ => CommandState::new(), }; - let state = match command.id.strip_prefix(PREFIX).unwrap_or_default() { - "add" | "add3D" => CommandState::new().enabled(f.has_art), - "selectAll" => CommandState::new().enabled(!f.all.is_empty()), - "remove" => CommandState::new().enabled(!f.sel.is_empty()), - "subfolders" => CommandState::new().checked(f.subfolders), - "openLocation" => CommandState::new().checked(f.open_location), - "applyPreset" => { - let name = command.params["name"].as_str().unwrap_or_default().to_string(); - CommandState::new().checked(f.applied == name).title(name) - } - "saveChanges" | "deletePreset" => CommandState::new().enabled(f.saved), - "exportPreset" => CommandState::new().enabled(f.known), - _ => continue, + let title = match row { + "applyPreset" => command.params["name"].as_str().unwrap_or_default().to_string(), + "add" if command.params["multiple"] == true => tl!("Add Selected Artwork as Multiple Assets").to_string(), + row => tl!(menu_label(row)).to_string(), }; - states.set(command, state); + states.set(command, state.title(title)); + } +} + +/// The English label of the panel menu's row `row` (`ui.assetExport.`); Add Selected Artwork as Multiple Assets +/// and the presets' rows are named by [`menu_states`]. +fn menu_label(row: &str) -> &'static str { + match row { + "add" => "Add Selected Artwork as One Asset", + "add3D" => "Export 3D Object", + "selectAll" => "Select All Assets", + "remove" => "Remove Selected Assets", + "exportForScreens" => "Export for Screens…", + "formatSettings" => "Format Settings…", + "subfolders" => "Create Sub-folders", + "openLocation" => "Open Location after Export", + "savePresetAs" => "Save As Preset…", + "saveChanges" => "Save Changes", + "deletePreset" => "Delete Preset", + "importPreset" => "Import Preset…", + "exportPreset" => "Export Preset…", + _ => "", } } diff --git a/crates/ui-egui/src/panels/brushes.rs b/crates/ui-egui/src/panels/brushes.rs index 7c1d4cfa96..d8075d4c66 100644 --- a/crates/ui-egui/src/panels/brushes.rs +++ b/crates/ui-egui/src/panels/brushes.rs @@ -767,6 +767,25 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { states.set(CommandRef::new(THUMBNAIL_VIEW), on(true).checked(!view.list)); states.set(CommandRef::new(LIST_VIEW), on(true).checked(view.list)); states.set(CommandRef::new(SAVE_LIBRARY), on(!list.is_empty())); + let names = [ + (new_brush("calligraphic"), "New Calligraphic Brush"), + (new_brush("bristle"), "New Bristle Brush"), + (new_brush("art"), "New Art Brush from Selection"), + (new_brush("scatter"), "New Scatter Brush from Selection"), + (new_brush("pattern"), "New Pattern Brush from Selection"), + (CommandRef::new(DUPLICATE), "Duplicate Brush"), + (CommandRef::new(DELETE_BRUSH), "Delete Brush"), + (CommandRef::new(SELECT_UNUSED), "Select All Unused"), + (CommandRef::new(THUMBNAIL_VIEW), "Thumbnail View"), + (CommandRef::new(LIST_VIEW), "List View"), + (CommandRef::new(SAVE_LIBRARY), "Save Brush Library…"), + ]; + super::name_rows(states, names); + for (ty, label) in KINDS { + let title = crate::i18n::fmt(tl!("Show {kind} Brushes"), &[("kind", tl!(label))]); + let state = states.get(&show_kind(ty)).cloned().unwrap_or_default(); + states.set(show_kind(ty), state.title(title)); + } } /// Runs the panel menu's own row `id`; `None` for an id that is not one of them. diff --git a/crates/ui-egui/src/panels/color_themes.rs b/crates/ui-egui/src/panels/color_themes.rs index 6399ec1372..3d1b32f037 100644 --- a/crates/ui-egui/src/panels/color_themes.rs +++ b/crates/ui-egui/src/panels/color_themes.rs @@ -412,6 +412,7 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { for id in [SAVE, ADD_TO_SWATCHES, EDIT, DELETE] { states.set(CommandRef::new(id), CommandState::new().enabled(enabled(app, id))); } + super::name_rows(states, [(CommandRef::new(SAVE), "Save Theme"), (CommandRef::new(ADD_TO_SWATCHES), "Add to Swatches")]); states.set(CommandRef::new(SHOW_FIND), CommandState::new().checked(app.ui.color_themes_panel.show_find)); } diff --git a/crates/ui-egui/src/panels/css_properties.rs b/crates/ui-egui/src/panels/css_properties.rs index 91683cc016..d076d8a515 100644 --- a/crates/ui-egui/src/panels/css_properties.rs +++ b/crates/ui-egui/src/panels/css_properties.rs @@ -285,17 +285,17 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let panel = &app.ui.css_properties_panel; let selection = app.session.active().map(|st| !st.selection.is_empty()); let (has_doc, selected) = (selection.is_some(), selection == Some(true)); - states.set(CommandRef::new(COPY_SELECTED), CommandState::new().enabled(selected)); - states.set(CommandRef::new(EXPORT_SELECTED), CommandState::new().enabled(selected)); - states.set(CommandRef::new(EXPORT_ALL), CommandState::new().enabled(has_doc)); - states.set(CommandRef::new(GENERATE), CommandState::new().enabled(has_doc).checked(panel.all)); + states.set(CommandRef::new(COPY_SELECTED), CommandState::new().enabled(selected).title(tl!("Copy Selected Style"))); + states.set(CommandRef::new(EXPORT_SELECTED), CommandState::new().enabled(selected).title(tl!("Export Selected CSS…"))); + states.set(CommandRef::new(EXPORT_ALL), CommandState::new().enabled(has_doc).title(tl!("Export All…"))); + states.set(CommandRef::new(GENERATE), CommandState::new().enabled(has_doc).checked(panel.all).title(tl!("Generate CSS"))); for units in CssUnits::ALL { - states.set(units_ref(units), CommandState::new().checked(panel.options.units == units)); + states.set(units_ref(units), CommandState::new().checked(panel.options.units == units).title(units.name())); } let mut options = panel.options.clone(); - for name in FLAGS { + for (name, label) in FLAGS.into_iter().zip([tl!("Absolute Position"), tl!("Width and Height"), tl!("Unnamed Objects"), tl!("Rasterize Unsupported Art")]) { let on = flag_mut(&mut options, name).is_some_and(|on| *on); - states.set(option_ref(name), CommandState::new().checked(on)); + states.set(option_ref(name), CommandState::new().checked(on).title(label)); } } diff --git a/crates/ui-egui/src/panels/flattener_preview.rs b/crates/ui-egui/src/panels/flattener_preview.rs index 82703526b1..6b37957e6f 100644 --- a/crates/ui-egui/src/panels/flattener_preview.rs +++ b/crates/ui-egui/src/panels/flattener_preview.rs @@ -397,8 +397,10 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// The states of the menu's rows: Refresh needs a document, Show Options is checked while the options show. pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { - states.set(CommandRef::new(REFRESH), CommandState::new().enabled(app.session.active().is_some())); - states.set(CommandRef::new(SHOW_OPTIONS), CommandState::new().checked(app.ui.flattener_preview.show_options)); + states.set(CommandRef::new(REFRESH), CommandState::new().enabled(app.session.active().is_some()).title(tl!("Refresh"))); + states.set(CommandRef::new(SHOW_OPTIONS), CommandState::new().checked(app.ui.flattener_preview.show_options).title(tl!("Show Options"))); + states.set(CommandRef::new(FIT_IN_WINDOW), CommandState::new().title(tl!("Fit in Window"))); + states.set(CommandRef::new(SAVE_PRESET), CommandState::new().title(tl!("Save Transparency Flattener Preset…"))); } /// Runs a menu row; `None` for an id that is not this panel's. diff --git a/crates/ui-egui/src/panels/glyphs.rs b/crates/ui-egui/src/panels/glyphs.rs index e595eb55fa..e639ae3ea4 100644 --- a/crates/ui-egui/src/panels/glyphs.rs +++ b/crates/ui-egui/src/panels/glyphs.rs @@ -1395,6 +1395,7 @@ pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec { /// The row titles of a category, which are the panel's words, with the check on the shown one. A /// form no face of the selection has a feature for is disabled ([`form_faces`]). pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { + states.set(CommandRef::new("ui.glyphs.useTextFont"), CommandState::new().title(tl!("Use the Selected Text's Font"))); let (_, _, face) = browsed_face(app); let cats = categories(face.as_deref()); let current = current_category(app, &cats); diff --git a/crates/ui-egui/src/panels/graphic_styles.rs b/crates/ui-egui/src/panels/graphic_styles.rs index c102a1ecdc..d9250ad7ee 100644 --- a/crates/ui-egui/src/panels/graphic_styles.rs +++ b/crates/ui-egui/src/panels/graphic_styles.rs @@ -872,6 +872,19 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { for (v, _) in View::ALL { states.set(view_ref(v), CommandState::new().checked(app.ui.graphic_styles_view == v)); } + let names = [ + ("new", "New Graphic Style…"), + ("duplicate", "Duplicate Graphic Style"), + ("merge", "Merge Graphic Styles"), + ("delete", "Delete Graphic Style"), + ("selectUnused", "Select All Unused"), + ("square", "Use Square for Previews"), + ("text", "Use Text for Previews"), + ("options", "Graphic Style Options…"), + ]; + let rows = names.into_iter().map(|(row, label)| (CommandRef::new(id(row)), label)); + let views = View::ALL.into_iter().map(|(v, label)| (view_ref(v), label)); + crate::panels::name_rows(states, rows.chain(views).chain([(override_ref(app), "Override Character Color")])); } /// Run the panel-menu row `id` (an id under `ui.graphicStyles`). diff --git a/crates/ui-egui/src/panels/image_trace.rs b/crates/ui-egui/src/panels/image_trace.rs index 08dcd9f42e..372d3117aa 100644 --- a/crates/ui-egui/src/panels/image_trace.rs +++ b/crates/ui-egui/src/panels/image_trace.rs @@ -1086,6 +1086,7 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let state = states.get(&command).cloned().unwrap_or_else(CommandState::new).enabled(enabled); states.set(command, state); } + states.set(CommandRef::new("ui.imageTrace.reset"), CommandState::new().title(tl!("Reset to Default"))); } /// The panel's own menu commands. diff --git a/crates/ui-egui/src/panels/links.rs b/crates/ui-egui/src/panels/links.rs index ba3723a24e..8078af2984 100644 --- a/crates/ui-egui/src/panels/links.rs +++ b/crates/ui-egui/src/panels/links.rs @@ -1049,14 +1049,14 @@ fn link_info(ui: &mut Ui, app: &VectorcraftApp, info: Option<(u64, &Value)>, uni reveal } -/// A command row with the state its panel-menu row shows. -fn entry(app: &VectorcraftApp, f: &Facts, id: &str, params: Value, a: Act) -> (CommandRef, CommandState) { - (CommandRef::with_params(id, params), CommandState::new().enabled(can(app, a, f, None))) +/// A command row named `label` with the state its panel-menu row shows. +fn entry(app: &VectorcraftApp, f: &Facts, id: &str, params: Value, a: Act, label: &str) -> (CommandRef, CommandState) { + (CommandRef::with_params(id, params), CommandState::new().enabled(can(app, a, f, None)).title(tl!(label))) } -/// A command row that is always enabled and checked or not. -fn option_entry(id: &str, params: Value, checked: bool) -> (CommandRef, CommandState) { - (CommandRef::with_params(id, params), CommandState::new().enabled(true).checked(checked)) +/// A command row named `label` that is always enabled and checked or not. +fn option_entry(id: &str, params: Value, checked: bool, label: &str) -> (CommandRef, CommandState) { + (CommandRef::with_params(id, params), CommandState::new().enabled(true).checked(checked).title(tl!(label))) } /// The panel menu's command rows with their states, in the groups the menu separates: the link @@ -1067,29 +1067,32 @@ fn groups(app: &VectorcraftApp) -> [Vec<(CommandRef, CommandState)>; 6] { let selected = selected_links(app); let f = Facts::of(&cache.list, &selected); let o = &app.ui.links.options; - let e = |id: &str, params: Value, a: Act| entry(app, &f, id, params, a); + let e = |id: &str, params: Value, a: Act, label: &str| entry(app, &f, id, params, a, label); [ vec![ - e("ui.relinkDialog", json!({ "ids": f.all() }), Act::Relink), - e("ui.links.relinkToFolder", Value::Null, Act::RelinkToFolder), - e("ui.findLinksInFolder", json!({ "ids": f.linked() }), Act::FindInFolder), - e("ui.links.goTo", Value::Null, Act::GoTo), - e("ui.links.update", Value::Null, Act::Update), - e("links.editOriginal", f.file_row(), Act::Edit), + e("ui.relinkDialog", json!({ "ids": f.all() }), Act::Relink, "Relink…"), + e("ui.links.relinkToFolder", Value::Null, Act::RelinkToFolder, "Relink to Folder…"), + e("ui.findLinksInFolder", json!({ "ids": f.linked() }), Act::FindInFolder, "Find in Folder…"), + e("ui.links.goTo", Value::Null, Act::GoTo, "Go To Link"), + e("ui.links.update", Value::Null, Act::Update, "Update Link"), + e("links.editOriginal", f.file_row(), Act::Edit, "Edit Original"), ], vec![ - e("ui.links.embed", Value::Null, Act::Embed), - e("ui.links.unembed", Value::Null, Act::Unembed), - e("ui.placementOptionsDialog", json!({ "ids": f.all() }), Act::Placement), - e("links.reveal", f.file_row(), Act::Reveal), + e("ui.links.embed", Value::Null, Act::Embed, "Embed Image(s)"), + e("ui.links.unembed", Value::Null, Act::Unembed, "Unembed…"), + e("ui.placementOptionsDialog", json!({ "ids": f.all() }), Act::Placement, "Placement Options…"), + e("links.reveal", f.file_row(), Act::Reveal, "Show in Folder"), ], - SHOW.iter().map(|(k, _)| option_entry("ui.links.show", json!({ "show": k }), o.show == *k)).collect(), - SORT.iter().map(|(k, _)| option_entry("ui.links.sort", json!({ "sort": k }), o.sort == Some(*k))).collect(), - vec![e("links.copyInfo", json!({ "ids": f.all() }), Act::CopyInfo)], + SHOW.iter().map(|(k, label)| option_entry("ui.links.show", json!({ "show": k }), o.show == *k, label)).collect(), + SORT.iter().map(|(k, label)| option_entry("ui.links.sort", json!({ "sort": k }), o.sort == Some(*k), label)).collect(), + vec![e("links.copyInfo", json!({ "ids": f.all() }), Act::CopyInfo, "Copy Info")], THUMBS .iter() - .map(|(k, size, _)| option_entry("ui.links.thumbnails", json!({ "size": k }), o.thumb == *size)) - .chain([option_entry("ui.links.linkInfo", Value::Null, o.info), option_entry("ui.links.dcs", Value::Null, o.dcs)]) + .map(|(k, size, label)| option_entry("ui.links.thumbnails", json!({ "size": k }), o.thumb == *size, label)) + .chain([ + option_entry("ui.links.linkInfo", Value::Null, o.info, "Show Link Info"), + option_entry("ui.links.dcs", Value::Null, o.dcs, "Show DCS Transparency Interactions"), + ]) .collect(), ] } diff --git a/crates/ui-egui/src/panels/opentype.rs b/crates/ui-egui/src/panels/opentype.rs index b0025b5f82..41788bfded 100644 --- a/crates/ui-egui/src/panels/opentype.rs +++ b/crates/ui-egui/src/panels/opentype.rs @@ -447,7 +447,7 @@ pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec { pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let style = text_style(app); let has = style.is_some(); - states.set(CommandRef::new(RESET), CommandState::new().enabled(has)); + states.set(CommandRef::new(RESET), CommandState::new().enabled(has).title(tl!("Reset OpenType Features"))); let sets = style.map(|(st, _)| set_entries(app, &st)).unwrap_or_default(); for (set, flag, on) in &sets { if let Some(tag) = flag.tag() { diff --git a/crates/ui-egui/src/panels/paragraph.rs b/crates/ui-egui/src/panels/paragraph.rs index b987c8af99..8bc176f74d 100644 --- a/crates/ui-egui/src/panels/paragraph.rs +++ b/crates/ui-egui/src/panels/paragraph.rs @@ -923,7 +923,7 @@ fn composers() -> [(&'static str, Composer); 4] { ] } -/// The Paragraph panel menu's rows; the labels and chords come from the commands' catalogue entries. +/// The Paragraph panel menu's rows; [`menu_states`] names them, and the chords come from the commands' catalogue entries. pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec { let cmd = |r: CommandRef| PanelRow::Command(r); let mut rows = vec![ @@ -965,34 +965,38 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let has = style.is_some(); let title = if app.ui.paragraph_hide_options { tl!("Show Options") } else { tl!("Hide Options") }; states.set(show_ref(), CommandState::new().title(title)); - let mut put = |r: CommandRef, enabled: bool, checked: Option| states.set(r, state(enabled, checked)); + // Each row is named here: the rows take params the catalog's rows do not list. `title` is shown as given. + let mut put = |r: CommandRef, enabled: bool, checked: Option, title: &str| states.set(r, state(enabled, checked).title(title)); // Quotation marks, hyphens, full stops and commas at a line's ends hang outside the margin. - put(toggle_ref("romanHangingPunctuation"), has, Some(style.as_ref().is_some_and(|(_, p)| p.roman_hanging))); - put(CommandRef::new("ui.justification"), has, None); - put(CommandRef::new("ui.hyphenation"), has, None); + let hanging = Some(style.as_ref().is_some_and(|(_, p)| p.roman_hanging)); + put(toggle_ref("romanHangingPunctuation"), has, hanging, tl!("Roman Hanging Punctuation")); + put(CommandRef::new("ui.justification"), has, None, tl!("Justification…")); + put(CommandRef::new("ui.hyphenation"), has, None, tl!("Hyphenation…")); if app.session.prefs.show_east_asian_options { let top_to_top = style.as_ref().is_some_and(|(_, p)| p.leading_model == LeadingModel::EmBoxTop); - put(set_ref("leadingModel", "emBoxTop"), has, Some(top_to_top)); - put(set_ref("leadingModel", "romanBaseline"), has, Some(has && !top_to_top)); + put(set_ref("leadingModel", "emBoxTop"), has, Some(top_to_top), tl!("Top-to-Top Leading")); + put(set_ref("leadingModel", "romanBaseline"), has, Some(has && !top_to_top), tl!("Bottom-to-Bottom Leading")); let hang = style.as_ref().map(|(_, p)| p.burasagari); - for (_, b, key) in burasagari_rows() { - put(set_ref("burasagari", key), has, Some(hang == Some(b))); + for (label, b, key) in burasagari_rows() { + put(set_ref("burasagari", key), has, Some(hang == Some(b)), label); } - put(toggle_ref("kurikaeshiMojiShori"), has, Some(shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true))); + let repeat = Some(shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true)); + put(toggle_ref("kurikaeshiMojiShori"), has, repeat, tl!("Kurikaeshi Moji Shori")); let kinsoku_type = shared_para(app, |p| p.kinsoku_type); - for (_, t, key) in kinsoku_types() { - put(set_ref("kinsokuType", key), has, Some(kinsoku_type == Some(t))); + for (label, t, key) in kinsoku_types() { + put(set_ref("kinsokuType", key), has, Some(kinsoku_type == Some(t)), label); } // Inseparable pairs stay on one line; only with a kinsoku set. let (kinsoku_on, bunri) = bunri_kinshi_item(app); - put(toggle_ref("bunriKinshi"), has && kinsoku_on, Some(bunri)); - put(toggle_ref("koreanLineBreakAnywhere"), has, Some(shared_para(app, |p| p.korean_line_break_anywhere) == Some(true))); + put(toggle_ref("bunriKinshi"), has && kinsoku_on, Some(bunri), tl!("Bunri-Kinshi")); + let anywhere = Some(shared_para(app, |p| p.korean_line_break_anywhere) == Some(true)); + put(toggle_ref("koreanLineBreakAnywhere"), has, anywhere, tl!("Korean Line Break Anywhere")); } let composer = shared_composer(app); - for (_, c) in composers() { - put(set_ref("composer", composer_id(c)), has, Some(composer == Some(c))); + for (label, c) in composers() { + put(set_ref("composer", composer_id(c)), has, Some(composer == Some(c)), label); } - put(reset_ref(), has, None); + put(reset_ref(), has, None, tl!("Reset Panel")); } /// Runs a `ui.paragraph.*` command; `None` for any other id. diff --git a/crates/ui-egui/src/panels/pathfinder.rs b/crates/ui-egui/src/panels/pathfinder.rs index d1ee58262d..f7ca2a08e4 100644 --- a/crates/ui-egui/src/panels/pathfinder.rs +++ b/crates/ui-egui/src/panels/pathfinder.rs @@ -187,7 +187,7 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// The states of the panel's own menu commands; the others read the commands' own rules. pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { - states.set(CommandRef::new("ui.pathfinder.trap"), CommandState::new().enabled(operands(app) >= 2)); + states.set(CommandRef::new("ui.pathfinder.trap"), CommandState::new().enabled(operands(app) >= 2).title(tl!("Trap…"))); } /// Runs the panel's own menu commands; `None` for any other id. diff --git a/crates/ui-egui/src/panels/separations.rs b/crates/ui-egui/src/panels/separations.rs index 691bd720fc..845552dd76 100644 --- a/crates/ui-egui/src/panels/separations.rs +++ b/crates/ui-egui/src/panels/separations.rs @@ -446,7 +446,7 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// Show All Plates is available while the separations preview is on. pub(crate) fn menu_states(_app: &VectorcraftApp, states: &mut CommandStates) { - states.set(SHOW_ALL_PLATES, CommandState::new().enabled(proof::view().separations.is_some())); + states.set(SHOW_ALL_PLATES, CommandState::new().enabled(proof::view().separations.is_some()).title(tl!("Show All Plates"))); } /// Runs the panel's own menu command `id`; `None` for any other id. Show All Plates turns the diff --git a/crates/ui-egui/src/panels/swatches/actions.rs b/crates/ui-egui/src/panels/swatches/actions.rs index 13d912b40c..7fd324a517 100644 --- a/crates/ui-egui/src/panels/swatches/actions.rs +++ b/crates/ui-egui/src/panels/swatches/actions.rs @@ -197,6 +197,27 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { for (v, _) in View::ALL { states.set(view_ref(v), CommandState::new().checked(v == app.ui.swatches_view)); } + let names = [ + ("newSwatch", "New Swatch…"), + ("newColorGroup", "New Color Group…"), + ("duplicate", "Duplicate Swatch"), + ("merge", "Merge Swatches"), + ("delete", "Delete Swatch"), + ("editGroup", "Edit or Apply Color Group…"), + ("ungroup", "Ungroup Color Group"), + ("groupOptions", "Color Group Options…"), + ("selectUnused", "Select All Unused"), + ("addUsedColors", "Add Used Colors"), + ("addSelectedColors", "Add Selected Colors"), + ("sortByName", "Sort by Name"), + ("sortByKind", "Sort by Kind"), + ("showFind", "Show Find Field"), + ("showRecent", "Show Recent Colors"), + ("options", "Swatch Options…"), + ("spotColors", "Spot Colors…"), + ]; + let views = View::ALL.into_iter().map(|(v, label)| (view_ref(v), label)); + crate::panels::name_rows(states, names.into_iter().map(|(row, label)| (CommandRef::new(id(row)), label)).chain(views)); } /// Runs panel menu row `id` (`ui.swatches.`); `None` for another panel's id. diff --git a/crates/ui-egui/src/panels/symbols.rs b/crates/ui-egui/src/panels/symbols.rs index c257f30d0a..e8dbf1a468 100644 --- a/crates/ui-egui/src/panels/symbols.rs +++ b/crates/ui-egui/src/panels/symbols.rs @@ -774,39 +774,43 @@ fn menu_lines(app: &VectorcraftApp) -> Vec { let picked = !marked(app).is_empty(); let inst = instance_flags(app); let name = json!({ "name": sel }); - let row = |id: &str, params: Value, enabled: bool| MenuLine::Command(CommandRef::with_params(id, params), CommandState::new().enabled(enabled)); + // Each row is named here: several share a command (New Symbol… and Symbol Options…), and most take params that + // the catalog's rows do not list. + let row = |id: &str, params: Value, enabled: bool, label: &str| { + MenuLine::Command(CommandRef::with_params(id, params), CommandState::new().enabled(enabled).title(tl!(label))) + }; let view = app.ui.symbols_view; - let views = View::ALL.iter().map(|&(v, _)| { + let views = View::ALL.iter().map(|&(v, label)| { let params = json!({ "panel": "symbols", "view": v }); - MenuLine::Command(CommandRef::with_params("ui.panelView", params), CommandState::new().checked(view == v)) + MenuLine::Command(CommandRef::with_params("ui.panelView", params), CommandState::new().checked(view == v).title(tl!(label))) }); let mut lines = vec![ // Shift on New Symbol… and Redefine Symbol keeps the selected art as ordinary art // ([`fired_params`]). - row("ui.symbolOptions", json!({}), has_sel), - row("symbol.update", name.clone(), has_sel && sel.is_some()), - row("symbol.duplicate", name.clone(), sel.is_some()), + row("ui.symbolOptions", json!({}), has_sel, "New Symbol…"), + row("symbol.update", name.clone(), has_sel && sel.is_some(), "Redefine Symbol"), + row("symbol.duplicate", name.clone(), sel.is_some(), "Duplicate Symbol"), // Asks first, as the panel's button does; the menu row has no Alt shortcut. - row(ROW_DELETE, Value::Null, sel.is_some() || picked), - row("ui.symbolOptions", json!({ "edit": true, "name": sel }), sel.is_some()), + row(ROW_DELETE, Value::Null, sel.is_some() || picked, "Delete Symbol"), + row("ui.symbolOptions", json!({ "edit": true, "name": sel }), sel.is_some(), "Symbol Options…"), // The selected instance's symbol, else the symbol selected in the panel. - row("symbol.edit", if inst.any { json!({}) } else { name.clone() }, inst.any || sel.is_some()), - row("symbol.place", name.clone(), sel.is_some()), - row("symbol.replace", name.clone(), inst.any && sel.is_some()), - row("symbol.breakLink", json!({}), inst.any), - row("symbol.instance.reset", json!({}), inst.changed), - row("symbol.instance.resetTransform", json!({}), inst.transformed), - row("symbol.selectInstances", name, sel.is_some()), + row("symbol.edit", if inst.any { json!({}) } else { name.clone() }, inst.any || sel.is_some(), "Edit Symbol"), + row("symbol.place", name.clone(), sel.is_some(), "Place Symbol Instance"), + row("symbol.replace", name.clone(), inst.any && sel.is_some(), "Replace Symbol"), + row("symbol.breakLink", json!({}), inst.any, "Break Link to Symbol"), + row("symbol.instance.reset", json!({}), inst.changed, "Reset Symbol Instance"), + row("symbol.instance.resetTransform", json!({}), inst.transformed, "Reset Transformation"), + row("symbol.selectInstances", name, sel.is_some(), "Select All Instances"), MenuLine::Separator, // Select All Unused (#4918): the symbols nothing places show selected, and Delete Symbol // deletes them all. - row(ROW_SELECT_UNUSED, Value::Null, symbols > 0), + row(ROW_SELECT_UNUSED, Value::Null, symbols > 0, "Select All Unused"), // The document's symbols in name order, as one undo step. - row("symbol.sortByName", json!({}), symbols > 1), + row("symbol.sortByName", json!({}), symbols > 1, "Sort by Name"), MenuLine::Separator, ]; lines.extend(views); - lines.extend([MenuLine::Separator, MenuLine::Libraries, row(ROW_SAVE_LIBRARY, Value::Null, symbols > 0)]); + lines.extend([MenuLine::Separator, MenuLine::Libraries, row(ROW_SAVE_LIBRARY, Value::Null, symbols > 0, "Save Symbol Library…")]); lines } diff --git a/crates/ui-egui/src/panels/tabs.rs b/crates/ui-egui/src/panels/tabs.rs index 47a0508f5d..fbea360c43 100644 --- a/crates/ui-egui/src/panels/tabs.rs +++ b/crates/ui-egui/src/panels/tabs.rs @@ -840,8 +840,8 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// Enable or disable the panel menu's commands as [`can`] says. pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { - for id in COMMANDS { - states.set(CommandRef::new(id), CommandState::new().enabled(can(app, id))); + for (id, label) in COMMANDS.into_iter().zip([tl!("Clear All Tabs"), tl!("Delete Tab"), tl!("Repeat Tab")]) { + states.set(CommandRef::new(id), CommandState::new().enabled(can(app, id)).title(label)); } } diff --git a/crates/ui-egui/src/panels/tests_menu_names.rs b/crates/ui-egui/src/panels/tests_menu_names.rs new file mode 100644 index 0000000000..7e3e10550e --- /dev/null +++ b/crates/ui-egui/src/panels/tests_menu_names.rs @@ -0,0 +1,69 @@ +//! Panel menus: every command row shows a name of its own, never its command id. + +use craft::ui::runtime::commands; + +use super::tests_appearance::app_with_rect; +use super::*; + +/// The command rows of `rows`, each with the level it is on (0 for the menu, then one number per submenu), submenus' +/// rows included. A row with a Shift alternate brings the alternate's command too. +fn command_rows(rows: &[PanelRow], level: usize, next: &mut usize, out: &mut Vec<(usize, CommandRef)>) { + for row in rows { + match row { + PanelRow::Command(command) => out.push((level, command.clone())), + PanelRow::Alternated(command, alternate) => { + out.push((level, command.clone())); + *next += 1; + out.push((*next, alternate.command.clone())); + } + PanelRow::Submenu(_, rows) => { + *next += 1; + command_rows(rows, *next, next, out); + } + _ => {} + } + } +} + +/// What is wrong with the rows of every panel menu in a frame of the whole app: a row whose label is empty or is its +/// command id, and two rows of one menu that show the same label. +fn unnamed_rows(app: &mut VectorcraftApp) -> Vec { + let ctx = app.ui_ctx.clone().expect("the app has a window"); + let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0))); + for k in 0..2 { + crate::testing::app_frame(app, &ctx, egui::RawInput { time: Some(f64::from(k)), screen_rect, ..Default::default() }); + } + let mut wrong = Vec::new(); + for menu in PANEL_MENUS { + let mut rows = Vec::new(); + command_rows(&(menu.rows)(app), 0, &mut 0, &mut rows); + let mut seen: Vec<(usize, String, String)> = Vec::new(); + for (level, command) in rows { + let label = commands::resolve(&ctx, command.clone()).label.to_string(); + if label.trim().is_empty() || label == command.id { + wrong.push(format!("{}: {} shows its id", menu.id, command.key())); + } else if let Some((_, other, _)) = seen.iter().find(|(at, key, shown)| *at == level && *shown == label && *key != command.key()) { + wrong.push(format!("{}: {} and {other} both show {label:?}", menu.id, command.key())); + } + seen.push((level, command.key(), label)); + } + } + wrong +} + +#[test] +fn panel_menu_rows_show_names_not_command_ids() { + let mut app = app_with_rect(); + let wrong = unnamed_rows(&mut app); + assert!(wrong.is_empty(), "{} rows:\n{}", wrong.len(), wrong.join("\n")); +} + +/// The rows the East Asian and Indic options add to the Paragraph, OpenType and Glyphs menus are named too. +#[test] +fn panel_menu_rows_with_the_east_asian_options_show_names() { + let mut app = app_with_rect(); + app.session.prefs.show_east_asian_options = true; + app.session.prefs.show_indic_options = true; + let wrong = unnamed_rows(&mut app); + assert!(wrong.is_empty(), "{} rows:\n{}", wrong.len(), wrong.join("\n")); +} From 148541971f35062d8803791b5007db41566cd7a6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 21:58:32 -0800 Subject: [PATCH 064/264] UI: Fidelity applies only once committed in freehand Tool Options and the Contextual Task Bar The Contextual Task Bar ran tool.setOption for the Smooth tool's Fidelity on every typed proposal, so a value typed and then canceled with Escape stayed set on the tool. The bar now sets the option only when the field commits the value. In the freehand Tool Options dialog, Escape during a Fidelity slider drag left the dragged value in the dialog. The draft now follows the drag unrounded, takes the rounded value when the drag ends, and gets the value from before the drag back on Escape, including a value above the slider's end that the field allows. The dialog's Fidelity field reads its edit events with landed(), as the variation fields do. Follow-up to #9753. --- crates/ui-egui/src/canvas/task_bar.rs | 6 +- crates/ui-egui/src/dialogs/freehand.rs | 22 ++++-- crates/ui-egui/src/dialogs/freehand/tests.rs | 73 ++++++++++++++++++++ crates/ui-egui/src/tests/taskbar.rs | 26 +++++++ 4 files changed, 118 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index a1613565bb..56657ef670 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -464,10 +464,12 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpac .show(ui, space.view.rect, |ui, _| { for (label, icon, cmd, params) in &offer.actions { if *cmd == TASK_BAR_FIDELITY { - // The Smooth tool's Fidelity, labeled, sets the tool's option as it is typed or stepped. + // The Smooth tool's Fidelity, labeled, sets the tool's option once a typed or stepped value is + // committed; Escape leaves the option as it was. if let Some(v) = offer.fidelity { Text::new(*label).show(ui); - if let Some(x) = crate::dialogs::freehand::fidelity_field(ui, "task-bar-fidelity", v, "smooth").filter(|x| *x != v) { + let events = crate::dialogs::freehand::fidelity_field(ui, "task-bar-fidelity", v, "smooth"); + if let Some(x) = events.committed().and_then(|typed| typed.to_owned()).filter(|x| *x != v) { run = Some(("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": x}}))); } } diff --git a/crates/ui-egui/src/dialogs/freehand.rs b/crates/ui-egui/src/dialogs/freehand.rs index 34d4e39fe5..7de36ba00e 100644 --- a/crates/ui-egui/src/dialogs/freehand.rs +++ b/crates/ui-egui/src/dialogs/freehand.rs @@ -19,6 +19,7 @@ // PLAN: the imports below assume `craft_ui` paths as the framework's own code uses them; `ui::brush_settings` // of the draw crate is where `TipEllipse` and `TipAngle` live. +use craft::behavior::EditEvents; use craft::draw::ui::brush_settings::{TipAngle, TipEllipse}; use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _}; use craft::ui::display::{Picture, PictureSize}; @@ -116,9 +117,10 @@ fn fidelity_round(v: f64) -> f64 { } /// The Fidelity field of tool `tool`, showing `v` to two decimals from the tool's lowest Fidelity to -/// 100 and stepping by [`fidelity_step`], named by the label drawn just before it. Returns the value -/// typed or stepped to. The Contextual Task Bar shows the Smooth tool's. -pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> Option { +/// 100 and stepping by [`fidelity_step`], named by the label drawn just before it. Returns the field's +/// edit events: the value typed or stepped to as a proposal, then its commit, or the cancel that +/// restores `v`. The Contextual Task Bar shows the Smooth tool's. +pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> EditEvents> { let min = vectorcraft_tools::draw2::min_fidelity(tool); NumberField::new(tl!("Fidelity"), Bind::given(Some(v))) .id_salt(id.to_owned()) @@ -128,8 +130,7 @@ pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> Optio .stepper(|v, dir, scale| fidelity_step(v, f64::from(dir) * scale)) .show(ui) .edit - .value() - .and_then(|typed| typed.to_owned()) + .events } /// The Fidelity row: a logarithmic slider from the tool's lowest Fidelity to [`FIDELITY_MAX`] with the field at its @@ -145,10 +146,17 @@ fn fidelity_row(ui: &mut Ui, fields: &mut DialogFields, tool: &str) -> Response .label(tl!("Fidelity")) .id_salt("fidelity-slider") .show(ui); - if let Some(x) = slid.value() { + // The draft follows a drag unrounded, as a rounded value would end the slider's gesture, and takes the rounded + // value once the drag ends. Escape puts back the value from before the drag or the typing, which the field + // allows above the slider's end. + if let Some(x) = slid.events.committed() { set = Some(fidelity_round(*x).clamp(min, FIDELITY_MAX)); + } else if let Some(x) = slid.events.value() { + set = Some(x.clamp(min, FIDELITY_MAX)); + } else if let Some(x) = slid.events.landed() { + set = Some(*x); } - if let Some(x) = fidelity_field(ui, "fidelity-field", v, tool) { + if let Some(x) = fidelity_field(ui, "fidelity-field", v, tool).landed().and_then(|typed| typed.to_owned()) { set = Some(x); } }); diff --git a/crates/ui-egui/src/dialogs/freehand/tests.rs b/crates/ui-egui/src/dialogs/freehand/tests.rs index d9e4e32dfe..790d5742e1 100644 --- a/crates/ui-egui/src/dialogs/freehand/tests.rs +++ b/crates/ui-egui/src/dialogs/freehand/tests.rs @@ -416,3 +416,76 @@ fn the_blob_brush_size_offers_the_stylus_wheel() { let text = shown_text(&mut app); assert!(text.contains("Stylus Wheel"), "it shows again on the next open: {text}"); } + +/// The Fidelity the open Tool Options dialog holds, `None` once it is closed. +fn draft_fidelity(panel: &crate::tests::panel_harness::Panel) -> Option { + panel.app().dialogs().and_then(|d| d.with(|host| host.get::().and_then(|dialog| dialog.fields().number("fidelity")))) +} + +/// The Smooth tool's Fidelity slider and field: a drag or a typed value that Escape cancels leaves the dialog's Fidelity +/// and the tool's as they were; a finished drag or a typed value left with Tab sets the dialog's, and OK sets the tool's. +#[test] +fn a_canceled_fidelity_drag_or_typed_value_leaves_the_dialog_and_the_tool() { + use craft::ui::contract::Role; + use egui::{Key, Modifiers, vec2}; + let mut app = app(); + app.run("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": 2.5}})).unwrap(); + let original = app.session.tool_options_of("smooth"); + let document = app.session.active().unwrap().doc.clone(); + let mut panel = crate::tests::panel_harness::Panel::new(app, crate::tests::picks::dialogs); + panel.room(vec2(1000.0, 1200.0)); + crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap(); + panel.frame(); + assert_eq!(draft_fidelity(&panel), Some(2.5)); + + // On the track, above the Accurate and Smooth marks. + let track = |panel: &crate::tests::panel_harness::Panel| { + let r = panel.rect_role("Fidelity", Role::SLIDER); + egui::pos2(r.center().x, r.top() + 5.0) + }; + let from = track(&panel); + panel.drag_hold_between(from, from + vec2(60.0, 0.0)); + assert_ne!(draft_fidelity(&panel), Some(2.5), "the dialog's Fidelity follows the drag"); + panel.key(Key::Escape, Modifiers::NONE); + panel.release(); + assert_eq!(draft_fidelity(&panel), Some(2.5), "Escape puts back the Fidelity from before the drag"); + + panel.click_role("Fidelity", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("7"); + panel.key(Key::Escape, Modifiers::NONE); + assert_eq!(panel.app().session.tool_options_of("smooth"), original, "the canceled typed value leaves the tool"); + if draft_fidelity(&panel).is_none() { + crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap(); + panel.frame(); + } + assert_eq!(draft_fidelity(&panel), Some(2.5), "the dialog shows the Fidelity from before the typing"); + + let from = track(&panel); + panel.drag_hold_between(from, from + vec2(60.0, 0.0)); + panel.release(); + let dragged = draft_fidelity(&panel).unwrap(); + assert!(dragged > 2.5, "a finished drag sets the dialog's Fidelity: {dragged}"); + assert_eq!(dragged, fidelity_round(dragged), "to the slider's step"); + panel.click_role("Fidelity", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("7"); + panel.key(Key::Tab, Modifiers::NONE); + assert_eq!(draft_fidelity(&panel), Some(7.0), "a typed value left with Tab sets the dialog's Fidelity"); + assert_eq!(panel.app().session.tool_options_of("smooth"), original, "the tool keeps its Fidelity until OK"); + panel.click("OK"); + panel.frame(); + assert_eq!(draft_fidelity(&panel), None, "OK closes the dialog"); + assert_eq!(panel.app().session.tool_options_of("smooth")["fidelity"].as_f64(), Some(7.0)); + assert_eq!(panel.app().session.active().unwrap().doc, document); + + panel.app().run("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": 50}})).unwrap(); + crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap(); + panel.frame(); + let from = track(&panel); + panel.drag_hold_between(from, from - vec2(60.0, 0.0)); + assert!(draft_fidelity(&panel).is_some_and(|x| x <= FIDELITY_MAX), "the drag runs along the slider"); + panel.key(Key::Escape, Modifiers::NONE); + panel.release(); + assert_eq!(draft_fidelity(&panel), Some(50.0), "Escape puts back a Fidelity above the slider's end"); +} diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index 3a56b8dad8..1995432740 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -1584,6 +1584,32 @@ fn the_smooth_tool_shows_fidelity_and_tool_options_for_a_path() { }); } +/// The Smooth tool's Fidelity field sets the tool's Fidelity only once a typed value is committed: while it is typed +/// and after Escape the tool keeps its Fidelity, and Enter sets it without an undo step. +#[test] +fn the_smooth_tools_fidelity_is_set_only_when_the_typed_value_is_committed() { + let mut app = app(); + let path = id(app.run("shape.ellipse", json!({"x": 60, "y": 60, "width": 120, "height": 80})).unwrap()); + select(&mut app, &[path]); + app.run("tool.select", json!({"tool": "smooth"})).unwrap(); + app.run("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": 2.5}})).unwrap(); + let undo = app.session.active().unwrap().history.undo.len(); + on_canvas(&mut app, |rig| { + let field = rig.field_after("Fidelity:"); + rig.fx.click_at(field); + rig.fx.key(Key::A, Modifiers::COMMAND); + rig.fx.type_text("7"); + rig.settle(); + assert_eq!(rig.app().session.tool_options()["fidelity"].as_f64(), Some(2.5), "a value being typed leaves the tool"); + rig.fx.key(Key::Escape, Modifiers::NONE); + rig.settle(); + assert_eq!(rig.app().session.tool_options()["fidelity"].as_f64(), Some(2.5), "Escape leaves the tool's Fidelity"); + rig.enter_value(field, "7"); + }); + assert_eq!(app.session.tool_options()["fidelity"].as_f64(), Some(7.0), "Enter sets it"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); +} + /// The Smooth tool's "Fidelity:" label is a framework text in the bar: a label node in the access tree, drawn on one /// line with its baseline on the Fidelity field's. #[test] From dc6ba53e6e8ffb50719c60035f450ac7d8fd0133 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 23:06:27 -0800 Subject: [PATCH 065/264] Tool options: tests cover a canceled field edit that keeps the dialog open The Live Paint Bucket Width test and the nullable length test pressed Escape, which closes the modal, and then reopened it, so they passed with the number and length rows still reading only proposals. Each test now also types a value, adds text that does not parse, and leaves the field with Tab. The dialog stays open, and the row must hold the opening value again (4 px, and null). --- crates/ui-egui/src/dialogs/option_form.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/option_form.rs b/crates/ui-egui/src/dialogs/option_form.rs index 7b127c08ef..fde3f40932 100644 --- a/crates/ui-egui/src/dialogs/option_form.rs +++ b/crates/ui-egui/src/dialogs/option_form.rs @@ -507,6 +507,15 @@ pub(super) mod tests { crate::toolbar::open_options(&mut panel.app(), "livePaintBucket").unwrap(); panel.frame(); assert_eq!(fields(&panel.app()), before); + panel.click_role("Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9"); + assert_eq!(fields(&panel.app())["width"], 9.0, "typing proposes the width"); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app()), before, "leaving the field on text that is not a number restores the opening width"); if commit { panel.click_role("Width", Role::SPIN_BUTTON); panel.key(Key::A, Modifiers::COMMAND); @@ -530,7 +539,7 @@ pub(super) mod tests { /// Normal Gap Options supplies numeric points. This hosted row fixture separately checks /// the nullable length helper's contract, including restoring an empty opening value. #[test] - fn a_nullable_length_row_restores_null_on_escape() { + fn a_nullable_length_row_restores_null_when_its_typing_is_canceled() { static NULL_LENGTH: OptionSpec = OptionSpec { key: "nullableLengthTest", title: || "Nullable Length".into(), @@ -555,6 +564,15 @@ pub(super) mod tests { open(&mut panel.app(), &NULL_LENGTH, Map::from_iter([("length".into(), Value::Null)]), Value::Null).unwrap(); panel.frame(); assert_eq!(fields(&panel.app())["length"], Value::Null); + panel.click_role("Length", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9 pt"); + assert_eq!(fields(&panel.app())["length"], 9.0); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app())["length"], Value::Null, "leaving the field on text that is not a length restores null"); } /// Whether `a` and `b` are the same value, numbers by their value. From 7b7ad0bd0e2bbb0f6725291a82ea7f907fedf2b8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 23:07:01 -0800 Subject: [PATCH 066/264] Brush Options: test that a canceled Bristle slider drag leaves the brush as it was For each of the five Bristle sliders, a held drag ended with Escape restores the open dialog's field, and OK then keeps the brush and the undo history unchanged. A released drag is kept by OK in one undo step. --- .../src/dialogs/brush_options/tests.rs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/crates/ui-egui/src/dialogs/brush_options/tests.rs b/crates/ui-egui/src/dialogs/brush_options/tests.rs index 7e6fdf0952..a63d0cef53 100644 --- a/crates/ui-egui/src/dialogs/brush_options/tests.rs +++ b/crates/ui-egui/src/dialogs/brush_options/tests.rs @@ -362,6 +362,52 @@ fn canceled_pattern_scale_edits_do_not_reach_the_brush() { assert_eq!(panel.app().run("brush.get", json!({"name": "Diamonds"})).unwrap(), original); } +/// Bristle Brush Options' sliders: a held drag ended with Escape leaves the open dialog's field as it +/// opened, and OK then leaves the brush as it was; a released drag is kept by OK. +#[test] +fn canceled_bristle_slider_drags_do_not_reach_the_brush() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + + for (key, label, _) in BRISTLE { + let mut app = app(); + let params = json!({"length": 150.0, "density": 50.0, "thickness": 50.0, "opacity": 50.0, "stiffness": 50.0}); + app.run("brush.options", json!({"name": "Bristle Round", "params": params})).unwrap(); + let original = app.run("brush.get", json!({"name": "Bristle Round"})).unwrap(); + let undo = app.session.active().unwrap().history.undo.len(); + let mut panel = Panel::new(app, draw_hosted_options); + panel.room(egui::vec2(1000.0, 1000.0)); + open(&mut panel.app(), "Bristle Round"); + panel.frame(); + let initial = fields_of(&panel.app()).number(key).unwrap(); + panel.drag_hold_role(label, Role::SLIDER, egui::vec2(40.0, 0.0)); + assert_ne!(fields_of(&panel.app()).number(key), Some(initial), "the held drag previews another {key}"); + panel.key(Key::Escape, Modifiers::NONE); + panel.release(); + assert!(is_open(&panel.app())); + assert_eq!(fields_of(&panel.app()).number(key), Some(initial), "the canceled drag restores the opening {key}"); + panel.click("OK"); + panel.frame(); + assert!(!is_open(&panel.app())); + assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap(), original, "OK after a canceled {key} drag"); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo); + + open(&mut panel.app(), "Bristle Round"); + panel.frame(); + panel.drag_hold_role(label, Role::SLIDER, egui::vec2(40.0, 0.0)); + panel.release(); + let accepted = fields_of(&panel.app()).number(key).unwrap(); + assert_ne!(accepted, initial); + panel.click("OK"); + panel.frame(); + assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap()[key], accepted); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + 1); + panel.app().run("edit.undo", json!({})).unwrap(); + assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap(), original); + } +} + /// What a step of the table expects at a JSON pointer of the saved brush. enum Expect { Is(Value), From 8254c2f6d4522a5d3781f89a9cd9db91226fa688 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 23:10:00 -0800 Subject: [PATCH 067/264] Slices: a refused OK keeps Slice Options and Divide Slices open with what was typed Both dialogs closed on OK before the app checked the document and slices they opened with, so a refusal (the selection changed, the document was reverted, or the command failed) went to the status line and the typed values were lost. They now open through the held-OK host: the check and the command run while the dialog waits, a refusal shows its reason under the rows with the values kept, and OK applies once the opening slices are selected again. --- crates/ui-egui/src/app.rs | 1 - crates/ui-egui/src/dialogs/host.rs | 1 - crates/ui-egui/src/dialogs/object_dialogs.rs | 4 +- crates/ui-egui/src/dialogs/slices.rs | 119 +++++++++++-------- crates/ui-egui/src/lib.rs | 2 - 5 files changed, 69 insertions(+), 58 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 283c1bd6a8..97fca4f235 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -246,7 +246,6 @@ impl VectorcraftApp { three_d_dialog: None, three_d: Default::default(), export_dialogs: Default::default(), - slice_dialogs: Default::default(), package_document: None, web_export: Default::default(), flattener_preview: Default::default(), diff --git a/crates/ui-egui/src/dialogs/host.rs b/crates/ui-egui/src/dialogs/host.rs index 67c6683f73..38c572c1c9 100644 --- a/crates/ui-egui/src/dialogs/host.rs +++ b/crates/ui-egui/src/dialogs/host.rs @@ -207,7 +207,6 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { super::graph_design::pump, super::perspective_grid::pump, super::perspective_presets::pump, - super::slices::pump, super::blend_options::pump, super::saved_names::pump, super::object_mosaic::pump, diff --git a/crates/ui-egui/src/dialogs/object_dialogs.rs b/crates/ui-egui/src/dialogs/object_dialogs.rs index df0c1be3ed..465fdcb850 100644 --- a/crates/ui-egui/src/dialogs/object_dialogs.rs +++ b/crates/ui-egui/src/dialogs/object_dialogs.rs @@ -4,8 +4,7 @@ use super::path_ops::PathOp; use super::simplify_slider::StripKind; use super::{ blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form, - path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, transform, transform_each, - width_point, + path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, transform, transform_each, width_point, }; use crate::VectorcraftApp; @@ -58,7 +57,6 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { graph_design::pump(app, ctx); perspective_grid::pump(app, ctx); perspective_presets::pump(app, ctx); - slices::pump(app, ctx); blend_options::pump(app, ctx); saved_names::pump(app, ctx); object_mosaic::pump(app, ctx); diff --git a/crates/ui-egui/src/dialogs/slices.rs b/crates/ui-egui/src/dialogs/slices.rs index ae99272163..8695ac0574 100644 --- a/crates/ui-egui/src/dialogs/slices.rs +++ b/crates/ui-egui/src/dialogs/slices.rs @@ -24,12 +24,6 @@ pub const OPTIONS: &str = "sliceOptions"; /// The dialog kind of Divide Slices. pub const DIVIDE: &str = "divideSlices"; -#[derive(Default)] -pub(crate) struct SliceDialogs { - options: Option, - divide: Option, -} - /// The document, its revert count and the effective slice selection used when opening either dialog. #[derive(PartialEq)] struct Target { @@ -134,12 +128,8 @@ pub fn open_options(app: &mut VectorcraftApp) -> Result { kinds.push(SliceKind::HtmlText); } let dialog = SliceOptionsDialog::new(options_of(&map)).kinds(&kinds); - app.dialogs().ok_or("no window")?.with(|host| { - host.open(dialog); - // Replacing a still-open dialog leaves its Cancel behind. - let _ = host.take::(); - }); - app.slice_dialogs.options = Some(source); + crate::dialogs::host::open_held(app, dialog, move |app, o: &SliceOptions| apply(app, &source, "object.slice.options", options_json(o))) + .ok_or("no window")?; Ok(Value::Null) } @@ -152,44 +142,27 @@ pub fn open_divide(app: &mut VectorcraftApp) -> Result { let source = Target::new(st.uid, st.reverts, selected); let (w, h) = first.map_or((50.0, 50.0), |r| (r.width() / 2.0, r.height() / 2.0)); let dialog = DivideSlicesDialog::new(DivideSlices::new(Some(DivideBy::Count(2)), Some(DivideBy::Count(2)))).lengths(lengths).start_sizes(h, w); - app.dialogs().ok_or("no window")?.with(|host| { - host.open(dialog); - let _ = host.take::(); - }); - app.slice_dialogs.divide = Some(source); + crate::dialogs::host::open_held(app, dialog, move |app, d: &DivideSlices| apply(app, &source, "object.slice.divide", divide_json(d))) + .ok_or("no window")?; Ok(Value::Null) } -/// Run the answer of whichever slice dialog closed with OK. The framework dialogs hold no answer, so a -/// refusal goes to the status line and the dialog is already closed. -pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { - let Some(host) = app.dialogs() else { return }; - let (options, divide) = host.with(|h| (h.take::(), h.take::())); - let answers = [ - options.and_then(|r| { - let source = app.slice_dialogs.options.take(); - r.ok().map(|o| (source, "object.slice.options", options_json(&o))) - }), - divide.and_then(|r| { - let source = app.slice_dialogs.divide.take(); - r.ok().map(|d| (source, "object.slice.divide", divide_json(&d))) - }), - ]; - for (source, cmd, params) in answers.into_iter().flatten() { - if source.as_ref().is_some_and(|source| source.reverted(app)) { - app.status(tl!("The document was reverted. Reopen this dialog to continue.")); - } else if !source.is_some_and(|source| Some(source) == Target::current(app)) { - app.status(tl!("The slice selection changed while the dialog was open.")); - } else if let Err(e) = app.run(cmd, params) { - app.status(e); - } +/// Runs a slice dialog's OK on the document and slices it opened with. A refusal keeps the dialog open with +/// what was typed and the reason under its rows. +fn apply(app: &mut VectorcraftApp, source: &Target, cmd: &str, params: Value) -> Result<(), String> { + if source.reverted(app) { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").to_owned()); } + if Target::current(app).as_ref() != Some(source) { + return Err(tl!("The slice selection changed while the dialog was open.").to_owned()); + } + app.run(cmd, params).map(|_| ()) } #[cfg(test)] mod tests { use super::*; - use craft::ui::dialog::{DialogHost, DialogId}; + use craft::ui::dialog::{DialogHost, DialogId, HeldOk}; use vectorcraft_doc::NodeId; use vectorcraft_engine::Session; @@ -217,12 +190,20 @@ mod tests { host(app, |h| h.set_json_field(&ctx, id, field, value)).unwrap(); } - /// OK on the open dialog, then the frame's pump runs its answer; whether OK was enabled. + /// OK on the open dialog, then the frame's pump runs its held answer, and an accepted answer closes the + /// dialog; whether OK was enabled. fn ok(app: &mut VectorcraftApp) -> bool { let (ctx, (id, _)) = (app.ui_ctx.clone().unwrap(), the_dialog(app)); - let enabled = host(app, |h| h.confirm_by_id(&ctx, id)); + let closed = host(app, |h| h.confirm_by_id(&ctx, id)); + if !closed && host(app, |h| h.held_state(id)) != Some(HeldOk::Waiting) { + return false; + } crate::dialogs::host::pump(app, &ctx); - enabled + if host(app, |h| h.held_state(id)) == Some(HeldOk::Accepted) { + host(app, |h| h.confirm_by_id(&ctx, id)); + crate::dialogs::host::pump(app, &ctx); + } + true } fn add_slice(app: &mut VectorcraftApp, x: f64) -> NodeId { @@ -235,15 +216,33 @@ mod tests { app.run("object.slice.select", json!({"slices": [id.0]})).unwrap(); } + /// The reason the open dialog shows for its refused OK, if it has one. + fn refusal(app: &VectorcraftApp) -> Option { + let (id, _) = the_dialog(app); + match host(app, |h| h.held_state(id)) { + Some(HeldOk::Refused(reason)) => Some(reason.as_str().to_string()), + _ => None, + } + } + + /// Whether either slice dialog is open. + fn slice_dialog_open(app: &VectorcraftApp) -> bool { + host(app, |h| h.is_open::() || h.is_open::()) + } + + /// The field each dialog's test types into, and the value typed. + fn draft(divide: bool) -> (&'static str, Value) { + if divide { ("columns", json!(3)) } else { ("name", json!("Original")) } + } + fn check_changed_selection(dialog: &str, divide: bool) { let mut app = app(); let source = app.session.active().unwrap().doc.slice_ids()[0]; let destination = add_slice(&mut app, 80.0); select_slice(&mut app, source); app.run(dialog, json!({})).unwrap(); - if !divide { - set(&app, "name", json!("Original")); - } + let (field, typed) = draft(divide); + set(&app, field, typed.clone()); select_slice(&mut app, destination); let st = app.session.active().unwrap(); let undo = st.history.undo.len(); @@ -253,7 +252,22 @@ mod tests { let st = app.session.active().unwrap(); assert_eq!(*st.doc, *document, "the changed selection is untouched"); assert_eq!(st.history.undo.len(), undo); - assert_eq!(app.ui.status, "The slice selection changed while the dialog was open."); + assert!(slice_dialog_open(&app), "the refused dialog stays open"); + assert_eq!(refusal(&app).as_deref(), Some("The slice selection changed while the dialog was open.")); + assert_eq!(the_dialog(&app).1[field], typed, "the refused dialog keeps what was typed"); + + // With the opening slice selected again, the same draft applies. + select_slice(&mut app, source); + assert!(ok(&mut app)); + assert!(!slice_dialog_open(&app), "the accepted dialog closes"); + let st = app.session.active().unwrap(); + assert_eq!(st.history.undo.len(), undo + 1, "the accepted OK is one undo step"); + if divide { + assert_eq!(st.doc.slices.len(), document.slices.len() + 6, "the opening slice is divided into six cells"); + } else { + assert_eq!(st.doc.slice_options(source).unwrap().name, "Original"); + assert_eq!(st.doc.slice_options(destination).unwrap().name, "", "the other slice keeps its options"); + } } #[test] @@ -267,7 +281,7 @@ mod tests { } /// Opens `dialog` on the saved document's slice, edits the document, reverts it and reselects the same slice id; - /// OK then leaves the restored document as it is and reports the revert. Returns the app and the slice. + /// OK then leaves the restored document as it is and the dialog open with the reason. Returns the app and the slice. fn check_refused_after_file_revert(dialog: &str, divide: bool, tag: &str) -> (VectorcraftApp, NodeId) { let mut app = app(); let slice = app.session.active().unwrap().doc.slice_ids()[0]; @@ -292,7 +306,8 @@ mod tests { let st = app.session.active().unwrap(); assert_eq!(*st.doc, *restored, "OK leaves the restored document's slices unchanged"); assert_eq!(st.history.undo.len(), undo); - assert_eq!(app.ui.status, "The document was reverted. Reopen this dialog to continue."); + assert!(slice_dialog_open(&app), "the refused dialog stays open"); + assert_eq!(refusal(&app).as_deref(), Some("The document was reverted. Reopen this dialog to continue.")); (app, slice) } @@ -332,6 +347,8 @@ mod tests { let st = app.session.active().unwrap(); assert_eq!(st.doc.slice_options(to).unwrap().name, ""); assert_eq!(st.history.undo.len(), undo); + assert_eq!(refusal(&app).as_deref(), Some("The slice selection changed while the dialog was open."), "the refused dialog stays open"); + assert_eq!(the_dialog(&app).1["name"], "Source", "the refused dialog keeps what was typed"); } #[test] @@ -342,7 +359,7 @@ mod tests { select_slice(&mut app, other); app.run("object.slice.options", json!({})).unwrap(); let ctx = app.ui_ctx.clone().unwrap(); - pump(&mut app, &ctx); + crate::dialogs::host::pump(&mut app, &ctx); set(&app, "name", json!("Replacement")); assert!(ok(&mut app)); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4062cc4302..3cd948fce0 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -288,8 +288,6 @@ pub struct VectorcraftApp { pub(crate) three_d: panels::three_d::Model, /// The open export option dialogs and what runs after each. pub(crate) export_dialogs: dialogs::export_host::ExportDialogs, - /// The document and selection used by each open slice dialog. - pub(crate) slice_dialogs: dialogs::slices::SliceDialogs, /// The drawing and loaded contents the open Package dialog saves and collects. pub(crate) package_document: Option<(u64, u64)>, /// Save for Web's renders and colour table. From 6f3703bbab1fdb2ed28256206695f5f6b2dcb5fc Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 08:38:26 +0100 Subject: [PATCH 068/264] Advance shared PDF pin and honor Standard-mode Tab hiding Keep the native and web craft-libs pins, Cargo.lock and PDF source checks on 57c8c8d4. Preserve the matching egui pin. Consult the shared Standard-mode chrome state for visibility and for show-panel requests; the dock already honors that state when drawing. --- Cargo.lock | 170 ++++++++++++++-------------- Cargo.toml | 70 ++++++------ apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/panel_docking.rs | 9 +- xtask/src/pdf_deps.rs | 2 +- 5 files changed, 128 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6023090b50..4910ae4bb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=db0b5931e2855ef86b4ab0a4de77fb4f82ee810e#db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" +source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 7ffa6409eb..c00cdc10bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } emath = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } epaint = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 3d626ea472..6947954a79 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 451bb131cc..74a5586b04 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -226,20 +226,23 @@ fn settle(app: &mut VectorcraftApp) { /// last pass left it, and Presentation Mode is off? With no window yet nothing hides them. pub(crate) fn panels_shown(app: &VectorcraftApp) -> bool { let chrome = app.ui_ctx.as_ref().map(|ctx| chrome_state(ctx, egui::ViewportId::ROOT)).unwrap_or_default(); - !chrome.hidden && !chrome.panels_hidden && app.ui.screen_mode < 3 + !chrome.hidden && !chrome.chrome_hidden && !chrome.panels_hidden && app.ui.screen_mode < 3 } /// Whether Tab hides the main window's panels, toolbars and Control bar (Shift+Tab leaves the /// toolbars). pub(crate) fn tab_hidden(app: &VectorcraftApp) -> bool { - app.ui_ctx.as_ref().is_some_and(|ctx| chrome_state(ctx, egui::ViewportId::ROOT).hidden) + app.ui_ctx.as_ref().is_some_and(|ctx| { + let chrome = chrome_state(ctx, egui::ViewportId::ROOT); + chrome.hidden || chrome.chrome_hidden + }) } /// Ends Tab and Shift+Tab hiding the panels in the main window; nothing while they show. pub(crate) fn show_panels(app: &VectorcraftApp) { let Some(ctx) = &app.ui_ctx else { return }; let chrome = chrome_state(ctx, egui::ViewportId::ROOT); - if chrome.hidden || chrome.panels_hidden { + if chrome.hidden || chrome.chrome_hidden || chrome.panels_hidden { request_chrome_toggle(ctx, egui::ViewportId::ROOT, ChromeToggle::ShowPanels); } } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 2bac79d96d..29758d7de0 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "db0b5931e2855ef86b4ab0a4de77fb4f82ee810e"; +const REV: &str = "57c8c8d48819e98d483e65a623c1a1b77a7091d3"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From de7f1fc144f5015dfd2d4caf8b2de3bc79e006b1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:07:51 -0800 Subject: [PATCH 069/264] New Document: a test checks that a typed Artboards count keeps the preset until committed Artboards is the one numeric field in Preset Details without a cancel test. The new test types a count over the preset's 5, checks that the dialog still shows the preset and its settings, presses Escape, and creates the document with the preset's settings. --- crates/ui-egui/src/dialogs/new_document.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/ui-egui/src/dialogs/new_document.rs b/crates/ui-egui/src/dialogs/new_document.rs index 8e770d3da7..0723f554c0 100644 --- a/crates/ui-egui/src/dialogs/new_document.rs +++ b/crates/ui-egui/src/dialogs/new_document.rs @@ -980,6 +980,10 @@ mod tests { canceled_detail_number("Height", "150"); } #[test] + fn canceled_new_document_artboards_preserve_preset() { + canceled_detail_number("Artboards", "3"); + } + #[test] fn canceled_new_document_bleed_preserves_preset() { canceled_detail_number("Top", "3"); } From 452bf2013d796b6245a6799a00e7833b59c2f76d Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 09:34:32 +0100 Subject: [PATCH 070/264] Constrain the paragraph Tabs action row to the form width Wrap the action buttons against the offered form width. Keep the accessibility lookup and pointer-click regression at both viewport sizes, and assert that the click target is inside the viewport. --- crates/ui-egui/src/dialogs/para_style_options.rs | 4 +++- crates/ui-egui/src/dialogs/para_style_options/tests.rs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/para_style_options.rs b/crates/ui-egui/src/dialogs/para_style_options.rs index 8522ee741c..609fca1dce 100644 --- a/crates/ui-egui/src/dialogs/para_style_options.rs +++ b/crates/ui-egui/src/dialogs/para_style_options.rs @@ -609,7 +609,9 @@ fn tabs_buttons(unit: Unit) -> Param { let (rows, _, _) = tab_rows(fields); let can_add = new_tab_position(&rows, unit).is_some(); let (mut add, mut delete, mut clear) = (false, false, false); - let line = Row::new().wrap(true).show(ui, |ui, _| { + // Wrap against the form's offered width rather than measuring an intrinsic-width + // strip that may be clipped by the property group on small screens. + let line = Row::new().fill_width().wrap(true).show(ui, |ui, _| { add = clicked(&Button::new(tl!("Add")).enabled(can_add).show(ui)); delete = clicked(&Button::new(tl!("Delete Tab")).enabled(!rows.is_empty()).show(ui)); clear = clicked(&Button::new(tl!("Clear All Tabs")).enabled(!rows.is_empty()).show(ui)); diff --git a/crates/ui-egui/src/dialogs/para_style_options/tests.rs b/crates/ui-egui/src/dialogs/para_style_options/tests.rs index 22802313ce..39d26bfb1a 100644 --- a/crates/ui-egui/src/dialogs/para_style_options/tests.rs +++ b/crates/ui-egui/src/dialogs/para_style_options/tests.rs @@ -576,9 +576,13 @@ fn clear_all_tabs_can_be_clicked_in_a_narrow_viewport() { } let out = frame(&mut app, vec![]); let nodes = out.platform_output.accesskit_update.unwrap().nodes; - let clear = nodes.iter().find(|(_, node)| node.role() == Role::Button && node.label() == Some("Clear All Tabs")).unwrap(); + let clear = nodes + .iter() + .find(|(_, node)| node.role() == Role::Button && node.label() == Some("Clear All Tabs")) + .unwrap_or_else(|| panic!("Clear All Tabs is missing at {width} points")); let bounds = clear.1.bounds().unwrap(); let at = pos2(((bounds.x0 + bounds.x1) * 0.5) as f32, ((bounds.y0 + bounds.y1) * 0.5) as f32); + assert!(screen.contains(at), "Clear All Tabs at {bounds:?} is outside the {width}-point viewport"); assert_eq!(tab_rows(&app).len(), 2); frame(&mut app, vec![Event::PointerMoved(at)]); From b0f821f2db7378632b03b785ce1f3807d29ce4cb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:39:56 -0800 Subject: [PATCH 071/264] Graph Type: test that typed numbers and text reach the draft only on commit The Column Width and Prefix rows write the draft only when their edit is committed. The existing dialog test still passed with either row reading every proposal while typing, so a new test types into each row, checks that the draft keeps its value, then presses Tab and checks that the typed value is in the draft. --- crates/ui-egui/src/dialogs/graph_type.rs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/ui-egui/src/dialogs/graph_type.rs b/crates/ui-egui/src/dialogs/graph_type.rs index 962b569dd7..1d75fd7b97 100644 --- a/crates/ui-egui/src/dialogs/graph_type.rs +++ b/crates/ui-egui/src/dialogs/graph_type.rs @@ -1219,6 +1219,40 @@ mod tests { } } + /// A number or text row leaves the draft alone while its text is still being typed, and writes + /// the typed value once Tab commits it. + #[test] + fn typed_number_and_text_rows_reach_the_draft_only_when_committed() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + + let mut app = app_with_graph("column"); + app.run(COMMAND, json!({"columnWidth": 80, "prefix": "USD"})).unwrap(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(egui::vec2(900.0, 900.0)); + open(&mut panel.app()).unwrap(); + panel.frame(); + panel.click_role("Column Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("140"); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(80.0), "a number being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(140.0), "Tab commits the typed number"); + set(&panel.app(), PAGE, json!("valueAxis")).unwrap(); + panel.frame(); + panel.click_role("Prefix", Role::TEXT_INPUT); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("EUR"); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("USD"), "text being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("EUR"), "Tab commits the typed text"); + } + /// Object › Graph › Type… opens the dialog on the selected graph's options, on its Graph /// Options page; each page the type has can be shown, and Override Calculated Values of the /// right axis takes input only while that axis has a scale of its own. From 4b7ac6969205008150daad4751e8f5ba39cf9d53 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:42:20 -0800 Subject: [PATCH 072/264] Scripts: fix path handles after main's revert count and review findings on path edits PathItem handles carry the document's revert count, as page item handles on main do, so path members find their path again. setEntirePath and the path point setters throw a RangeError for a point off the canvas. Opening a path whose closing segment is selected keeps the edit. pathItems.add() leaves new art's paint as it was with New Art Has Basic Appearance off. addDocument reports settings the built-in preset refuses. appearance.setNewArt refuses a swatch that is not a name. Writing one path's points looks only at that path afterwards. --- crates/engine/src/cmd/newart.rs | 3 + crates/engine/src/script/dom.rs | 32 +++++-- crates/engine/src/script/dom/paths.rs | 93 ++++++++++++++------- crates/engine/src/tests/newart.rs | 10 +++ crates/engine/src/tests/script_dom.rs | 5 ++ crates/engine/src/tests/script_dom_paths.rs | 60 +++++++++++++ 6 files changed, 164 insertions(+), 39 deletions(-) diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index f9563ee886..c7398db1da 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -116,6 +116,9 @@ fn set_new_art(s: &mut Session, p: &Value) -> Result { if !v.is_object() { return Err(bad(C, format!("{key} must be a paint object (color, none, swatch or gradient), got {v}"))); } + if v.get("swatch").is_some_and(|w| !w.is_string()) { + return Err(bad(C, format!("{key}: `swatch` must be a swatch name"))); + } let pattern_only = |name: &str| s.doc().is_ok_and(|st| st.doc.swatch(name).is_none() && st.doc.pattern(name).is_some()); if v.get("tint").is_some() && v.get("swatch").and_then(Value::as_str).is_none_or(pattern_only) { return Err(bad(C, format!("{key}: `tint` goes with a global or spot `swatch`"))); diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index db83366b2c..facf010415 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -115,6 +115,9 @@ mod colors; mod defaults; mod paths; +#[cfg(test)] +pub(crate) use paths::POINT_LOOKS; + /// The error for a member read or called with no document open. pub const NO_ACTIVE_DOCUMENT: &str = "No active document"; /// The error for an object that was deleted, or that came from an earlier run. @@ -185,9 +188,12 @@ pub(super) struct State { /// How many times the points the run read of each path went stale, by document uid and path id /// ([`paths`]). point_cuts: RefCell>, - /// Each path whose points the run read, as the run last saw it, by document uid and path id - /// ([`paths`]). - point_nodes: RefCell>>, + /// Each path whose points the run read, as the run last saw it, by document uid and then path + /// id ([`paths`]). + point_nodes: RefCell>>>, + /// The path whose points the object model is writing with `path.setAnchors`, the only path + /// that command changes ([`paths`]). + one_path: Cell>, /// Each document, by uid, as it was when the run last looked at all the paths in it whose /// points it read ([`paths`]). point_docs: RefCell>>, @@ -741,6 +747,12 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) - return Ok(()); } let partial = |id: &NodeId| before.anchors.contains_key(id) || before.segments.contains_key(id); + // Anchors and segments the change removed (a path opened or given fewer points) are left out. + let left = |id: &NodeId, p: usize, test: &dyn Fn(&vectorcraft_geom::path::SubPath) -> bool| { + doc.node(*id).and_then(|n| n.path_data()).is_some_and(|pd| pd.subpaths.get(p).is_some_and(test)) + }; + let anchor_left = |id: &NodeId, p: usize, k: usize| left(id, p, &|sp| k < sp.anchors.len()); + let segment_left = |id: &NodeId, p: usize, k: usize| left(id, p, &|sp| sp.has_segment(k, true)); let kept: Vec = before.objects.iter().copied().filter(keep).collect(); if kept.is_empty() { command(h, "select.none", &json!({}))?; @@ -753,7 +765,7 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) - .iter() .map(|i| { let anchors: Vec<[usize; 2]> = match before.anchors.get(i) { - Some(a) => a.iter().map(|(p, k)| [*p, *k]).collect(), + Some(a) => a.iter().filter(|(p, k)| anchor_left(i, *p, *k)).map(|(p, k)| [*p, *k]).collect(), // A path with only segments selected gets them back below, with no anchors. None if before.segments.contains_key(i) => Vec::new(), None => doc.node(*i).and_then(|n| n.path_data()).map(|p| p.anchors().map(|(s, k, _)| [s, k]).collect()).unwrap_or_default(), @@ -764,7 +776,10 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) - command(h, "select.anchorsMany", &json!({"items": items, "mode": "set"}))?; } for (i, segments) in before.segments.iter().filter(|(i, _)| keep(i)) { - let segments: Vec<[usize; 2]> = segments.iter().map(|(p, k)| [*p, *k]).collect(); + let segments: Vec<[usize; 2]> = segments.iter().filter(|(p, k)| segment_left(i, *p, *k)).map(|(p, k)| [*p, *k]).collect(); + if segments.is_empty() { + continue; + } command(h, "select.segments", &json!({"id": i.0, "segments": segments, "mode": "add"}))?; } let guides: Vec = doc.ruler_guides().into_iter().filter_map(|g| g.id).collect(); @@ -1366,13 +1381,12 @@ fn docs_add_document(h: &Host, a: &[Data]) -> Answer { } // The document starts from the first built-in preset of the profile's category (Print: // Letter) with `presetSettings` over it, given in full so that a saved preset of the same name - // does not stand in for it. Settings `file.new` refuses are left for it to report. + // does not stand in for it. Settings the built-in preset refuses are an error. let first = profile.and_then(|n| crate::cmd::newdoc::category(&h.session.borrow(), n)?.into_iter().next()); if let Some(first) = first { p.insert("preset".into(), json!(first.name)); - if let Ok(full) = first.with_params(&Value::Object(p.clone()), "file.new") - && let Value::Object(settings) = full.to_json() - { + let full = first.with_params(&Value::Object(p.clone()), "file.new").map_err(|e| HostError::Error(e.to_string()))?; + if let Value::Object(settings) = full.to_json() { for key in BUILT_IN_SETTINGS { if let Some(v) = settings.get(*key) { p.insert((*key).into(), v.clone()); diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 356afe8b99..e9510871c4 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -136,8 +136,11 @@ fn read_path(h: &super::Host, item: Item, f: impl FnOnce(&DocState, &crate::d } fn path_ref(h: &super::Host, item: Item) -> Data { - let [high, low] = id_parts(item.id); - host_ref("PathItem", &[float(h.run), float(item.doc.uid), high, low]) + let s = h.session.borrow(); + match s.documents().iter().find(|d| d.uid == item.doc.uid) { + Some(st) => host_ref("PathItem", &super::node_handle(h, st, item.id)), + None => Data::Null, + } } /// The index of the first point of each subpath of `subs`, followed by the number of points. @@ -309,7 +312,12 @@ pub(super) fn flush(h: &super::Host) -> std::result::Result<(), HostError> { } let subpaths: Vec = subs.iter().map(|sp| json!({"anchors": sp.anchors.iter().map(anchor_json).collect::>(), "closed": sp.closed})).collect(); - edit_item(h, item, "path.setAnchors", &json!({"id": item.id.0, "subpaths": subpaths}))?; + // Changes made before this one are looked at in full first. + see_all_points(h); + let kept = h.dom.one_path.replace(Some(item)); + let r = edit_item(h, item, "path.setAnchors", &json!({"id": item.id.0, "subpaths": subpaths})); + h.dom.one_path.set(kept); + r?; Ok(()) } @@ -605,20 +613,25 @@ fn items_star(h: &super::Host, a: &[Data]) -> Answer { /// `pathItems.add()`: a path with no points on top of the active layer, from `path.create` with /// empty path data, painted as new art. When new art has no fill and no stroke, the black stroke `path.create` gives an open -/// path is set back to none in the same step. +/// path is set back to none in the same step, and new art keeps the paint it had before. fn items_add(h: &super::Host, a: &[Data]) -> Answer { let doc = items_doc(h, a)?; - let made = on_doc(h, doc.uid, true, |h| { - let unpainted = { - let ap = h.session.borrow().new_art(); - ap.fill_paint().is_none() && ap.stroke_paint().is_none() - }; - let id = made_id(&drawing_normally(h, || command_value(h, "path.create", &json!({"d": ""})))?.1)?; - if unpainted { - keeping_paint(h, || command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]})))?; - } - Ok(id) - })?; + let add = |h: &super::Host, unpainted: bool| { + on_doc(h, doc.uid, true, |h| { + let id = made_id(&drawing_normally(h, || command_value(h, "path.create", &json!({"d": ""})))?.1)?; + if unpainted { + command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]}))?; + } + Ok(id) + }) + }; + let unpainted = { + let ap = h.session.borrow().new_art(); + ap.fill_paint().is_none() && ap.stroke_paint().is_none() + }; + // Selecting the new path loads its temporary stroke into new art, and putting the selection + // back does not undo that, so new art's paint from before the path is put back. + let made = if unpainted { keeping_paint(h, || add(h, true))? } else { add(h, false)? }; let s = h.session.borrow(); let st = s.documents().iter().find(|d| d.uid == doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; Ok(super::item_ref(h, st, made)) @@ -746,7 +759,8 @@ fn path_set_entire(h: &super::Host, a: &[Data]) -> Answer { let f = with_doc(h, item.doc, |_, st| frame(st))?; let closed = read_points(h, item, |subs| !subs.is_empty() && subs.iter().all(|sp| sp.closed))?; let c = h.dom.coords.get(); - let anchors: Vec = script.iter().map(|p| Anchor::corner(f.to_document(c, *p))).collect(); + let anchors: Vec = + script.iter().map(|p| on_canvas(f.to_document(c, *p), "each point").map(Anchor::corner)).collect::>()?; let subs = if anchors.is_empty() { Vec::new() } else { vec![SubPath::new(anchors, closed)] }; write_path(h, item, subs)?; cut_points(h, item); @@ -1251,6 +1265,12 @@ fn cut_key(h: &super::Host, key: (u64, u64)) { *n = n.saturating_add(1); } +#[cfg(test)] +thread_local! { + /// How many times this thread looked at a path's points ([`see_points`]), for the tests. + pub(crate) static POINT_LOOKS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + /// The node of `id` in `d`, as the document holds it. fn node_arc(d: &crate::Document, id: NodeId) -> Option<&Arc> { let at = d.index_path(id)?; @@ -1269,6 +1289,8 @@ fn node_arc(d: &crate::Document, id: NodeId) -> Option<&Arc> { /// the document, so a node whose pointer is unchanged has unchanged points, and any change to it /// makes a new node. fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { + #[cfg(test)] + POINT_LOOKS.with(|n| n.set(n.get() + 1)); let node = { let s = h.session.borrow(); s.documents().iter().find(|d| d.uid == key.0).and_then(|st| node_arc(&st.doc, NodeId(key.1)).cloned()) @@ -1276,12 +1298,12 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { // A path that is gone makes its points stale, so that an undo that brings it back leaves them // stale. let Some(node) = node else { - if h.dom.point_nodes.borrow_mut().remove(&key).is_some() { + if h.dom.point_nodes.borrow_mut().get_mut(&key.0).and_then(|paths| paths.remove(&key.1)).is_some() { cut_key(h, key); } return; }; - let changed = match h.dom.point_nodes.borrow_mut().insert(key, node.clone()) { + let changed = match h.dom.point_nodes.borrow_mut().entry(key.0).or_default().insert(key.1, node.clone()) { Some(old) => !Arc::ptr_eq(&old, &node) && old.path_data().map(|pd| &pd.subpaths) != node.path_data().map(|pd| &pd.subpaths), None => false, }; @@ -1294,34 +1316,35 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { /// change that a later command reverses still makes the points stale. Paths under the object that /// the object model is changing ([`super::State`]), or that object itself, take the change as the /// object model's own, and their points stay valid. A document that is the one the run last looked -/// at is skipped, as are its paths. +/// at is skipped, as are its paths. While the object model writes one path's points +/// ([`super::State`]'s `one_path`), only that path is looked at in its document. pub(super) fn see_all_points(h: &super::Host) { let keys: Vec<(u64, u64)> = { let seen = h.dom.point_nodes.borrow(); - if seen.is_empty() { + if seen.values().all(|paths| paths.is_empty()) { return; } let s = h.session.borrow(); let mut docs = h.dom.point_docs.borrow_mut(); + let one = h.dom.one_path.get(); + let mut keys = Vec::new(); // The documents that changed since the last look, kept as they are now. - let mut changed = std::collections::HashSet::new(); - for (uid, _) in seen.keys() { - if changed.contains(uid) { - continue; - } + for (uid, paths) in seen.iter().filter(|(_, paths)| !paths.is_empty()) { match s.documents().iter().find(|d| d.uid == *uid) { - Some(st) if docs.get(uid).is_some_and(|d| Arc::ptr_eq(d, &st.doc)) => {} + Some(st) if docs.get(uid).is_some_and(|d| Arc::ptr_eq(d, &st.doc)) => continue, Some(st) => { docs.insert(*uid, st.doc.clone()); - changed.insert(*uid); } None => { docs.remove(uid); - changed.insert(*uid); } } + match one { + Some(item) if item.doc.uid == *uid => keys.extend(paths.contains_key(&item.id.0).then_some((*uid, item.id.0))), + _ => keys.extend(paths.keys().map(|id| (*uid, *id))), + } } - seen.keys().copied().filter(|(uid, _)| changed.contains(uid)).collect() + keys }; let editing = h.dom.editing.get(); for (uid, id) in keys { @@ -1439,7 +1462,17 @@ fn assigned_point(h: &super::Host, a: &[Data], what: &str) -> std::result::Resul let p = point(arg(a, 1), what)?; let (item, _) = this_point(h, a)?; let fr = with_doc(h, item.doc, |_, st| frame(st))?; - Ok(fr.to_document(h.dom.coords.get(), p)) + on_canvas(fr.to_document(h.dom.coords.get(), p), what) +} + +/// `p`, a point a script gave in document coordinates, when it is on the canvas (within +/// [`crate::MAX_COORD`] of the origin); a `RangeError` otherwise. +fn on_canvas(p: Point, what: &str) -> std::result::Result { + if p.x.is_finite() && p.y.is_finite() && p.x.abs() <= crate::MAX_COORD && p.y.abs() <= crate::MAX_COORD { + Ok(p) + } else { + Err(HostError::Range(format!("{what} is outside the canvas"))) + } } fn pt_anchor(h: &super::Host, a: &[Data]) -> Answer { diff --git a/crates/engine/src/tests/newart.rs b/crates/engine/src/tests/newart.rs index e92ac41e19..a19f5ff6ab 100644 --- a/crates/engine/src/tests/newart.rs +++ b/crates/engine/src/tests/newart.rs @@ -448,6 +448,16 @@ fn set_new_art_refuses_a_tint_on_a_pattern_without_a_swatch_entry() { assert_eq!(run(&mut s, "appearance.setNewArt", json!({"fill": {"swatch": name}})), json!({"changed": true})); } +#[test] +fn set_new_art_refuses_a_swatch_that_is_not_a_name() { + let mut s = session(); + let before = s.paint.clone(); + for p in [json!({"fill": {"swatch": 7, "color": "#ff0000"}}), json!({"stroke": {"swatch": null, "color": "#ff0000"}})] { + assert!(s.execute("appearance.setNewArt", &p).is_err(), "accepted {p}"); + assert_eq!(s.paint, before, "{p} changed new art"); + } +} + #[test] fn set_new_art_refuses_while_new_art_takes_the_selected_look() { let mut s = session(); diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 05a7e8cf10..15a1ee1320 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1504,6 +1504,11 @@ fn document_preset_applies_only_its_given_fields() { assert!(e.contains(part), "{source}: {e}"); } assert_eq!(s.documents().len(), 2, "a refused preset makes no document"); + // A saved preset with the built-in preset's name does not make the refused settings fit. + s.execute("file.newPresets.save", &json!({"name": "Letter", "artboardLayout": "column"})).unwrap(); + let e = failure(&mut s, "var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5; app.documents.addDocument('Print', p);"); + assert!(e.contains("don't fit"), "{e}"); + assert_eq!(s.documents().len(), 2, "settings the built-in preset refuses make no document"); } #[test] diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index ce088ea01c..fe02779654 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -194,6 +194,21 @@ fn hostile_set_entire_path_input_is_bounded() { assert_eq!(art(&s), before); } +#[test] +fn points_off_the_canvas_throw_where_they_are_given() { + let (mut s, _, _) = doc(); + let before = art(&s); + for source in [ + "app.activeDocument.pathItems[0].setEntirePath([[0, 0], [7000000, 1]]);", + "app.activeDocument.pathItems[0].pathPoints[0].anchor = [7000000, 1];", + "app.activeDocument.pathItems[0].pathPoints[0].leftDirection = [1, -7000000];", + ] { + let out = log(&mut s, &format!("try {{ {source} vc.log('kept'); }} catch (e) {{ vc.log(e.name); }}")); + assert_eq!(out, vec![json!("RangeError")], "{source}"); + assert_eq!(art(&s), before, "{source}"); + } +} + #[test] fn path_point_setters_edit_one_anchor() { let (mut s, a, _) = doc(); @@ -524,6 +539,24 @@ fn many_point_edits_run_one_command() { assert_eq!(undo_steps(&s), steps + 1); } +#[test] +fn editing_one_point_on_each_of_many_paths_looks_at_each_path_a_few_times() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + for i in 0..300 { + rect(&mut s, f64::from(i % 30) * 10.0, f64::from(i / 30) * 10.0, 5.0, 5.0); + } + s.execute("select.none", &json!({})).unwrap(); + let start = crate::script::dom::POINT_LOOKS.with(|n| n.get()); + log( + &mut s, + "var ps = app.activeDocument.pathItems;\ + for (var i = 0; i < ps.length; i++) { var q = ps[i].pathPoints[0]; var a = q.anchor; q.anchor = [a[0] + 1, a[1]]; }", + ); + let looks = crate::script::dom::POINT_LOOKS.with(|n| n.get()) - start; + assert!(looks < 3000, "{looks} looks at paths for 300 one-point edits"); +} + #[test] fn point_edits_are_written_before_the_next_other_member_reads() { let (mut s, a, _) = doc(); @@ -706,6 +739,19 @@ fn an_added_path_takes_new_art_without_a_fill_or_stroke() { assert_eq!(out, [json!(false), json!(true), json!(255)], "a new-art stroke stays"); } +#[test] +fn an_added_path_leaves_new_art_unpainted_with_basic_appearance_off() { + let (mut s, _, _) = doc(); + s.execute("paint.setFill", &json!({"none": true})).unwrap(); + s.execute("paint.setStroke", &json!({"none": true})).unwrap(); + s.prefs.new_art_basic = false; + let paint = s.paint.clone(); + let out = log(&mut s, "var n = app.activeDocument.pathItems.add(); vc.log(n.stroked);"); + assert_eq!(out, [json!(false)]); + assert!(s.active().unwrap().selection.is_empty()); + assert_eq!(s.paint, paint, "new art keeps no fill and no stroke"); +} + /// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke. fn doc_with_paints() -> (Session, NodeId) { let (mut s, a, _) = doc(); @@ -1093,6 +1139,20 @@ fn path_point_selected_refuses_handles_bad_values_and_locked_paths() { assert!(s.active().unwrap().selection.is_empty()); } +#[test] +fn opening_a_path_with_its_closing_segment_selected_keeps_the_edit() { + let (mut s, a, b) = doc(); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 3]], "mode": "set"})).unwrap(); + s.execute("select.segments", &json!({"id": b.0, "segments": [[0, 0], [0, 3]], "mode": "add"})).unwrap(); + log(&mut s, "var p = app.activeDocument.pathItems; p[0].closed = false; p[1].closed = false;"); + for id in [a, b] { + assert!(!node(&s, id).path_data().unwrap().subpaths[0].closed, "{id:?} stayed closed"); + } + let sel = &s.active().unwrap().selection; + assert_eq!(sel.segments.get(&b).map(|g| g.iter().copied().collect::>()), Some(vec![(0, 0)])); + assert!(sel.segments.get(&a).is_none_or(|g| g.is_empty()), "{:?}", sel.segments); +} + /// The ways an editable path cannot be selected: on a locked artboard, and outside the isolated /// object. const UNSELECTABLE: [&str; 2] = ["locked artboard", "isolation"]; From b0b10c610963f9b6cd44fb1df5b4a94840a38bf2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:46:50 -0800 Subject: [PATCH 073/264] Panels: tests compare the menu rows' flags now that rows are named Four tests compared a panel menu row's whole state with one that had no name, and failed once the rows were named: the Symbols view rows, the Paragraph composer rows, the Links panel's Select rows and OpenType's Reset row. They now compare the enabled and checked flags, or the state with its name. The Links test also checks each Select row's Shift alternate. Two lines in Align and CSS Properties are split to fit the 150-column width. --- .../src/addons/select/link_status/tests.rs | 22 ++++++++++++------- crates/ui-egui/src/panels/align.rs | 3 ++- crates/ui-egui/src/panels/css_properties.rs | 3 ++- crates/ui-egui/src/panels/opentype.rs | 2 +- crates/ui-egui/src/panels/paragraph/tests.rs | 6 +++-- crates/ui-egui/src/panels/symbols/tests.rs | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/addons/select/link_status/tests.rs b/crates/ui-egui/src/addons/select/link_status/tests.rs index 1dfbc67c40..dd1c374021 100644 --- a/crates/ui-egui/src/addons/select/link_status/tests.rs +++ b/crates/ui-egui/src/addons/select/link_status/tests.rs @@ -178,14 +178,20 @@ fn menu_items_are_on_for_the_statuses_present_and_shift_adds() { { assert_eq!(item(label).enabled, on, "{label}"); } - // The Links panel's rows follow the statuses present, per status. - let enabled_of = |app: &VectorcraftApp| { + // The Links panel's rows follow the statuses present, per status, and each row and its Shift alternate is named + // for its status. + let enabled_of = |app: &VectorcraftApp, shift: bool| { let mut all = CommandStates::new(); states(app, &mut all); - STATUSES.map(|(status, ..)| all.get(&CommandRef::with_params(COMMAND, json!({ "status": status }))).cloned()) + STATUSES.map(|(status, ..)| { + let p = json!({ "status": status }); + all.get(&CommandRef::with_params(COMMAND, if shift { with_shift(p) } else { p })).cloned() + }) }; - let on = Some(CommandState::new().enabled(true)); - assert_eq!(enabled_of(&app), [on.clone(), on.clone(), on.clone(), Some(CommandState::new().enabled(false))]); + let named = |on: bool, label: &str| Some(CommandState::new().enabled(on).title(label)); + let want = [named(true, "Select Linked"), named(true, "Select Embedded"), named(true, "Select Missing"), named(false, "Select Modified")]; + assert_eq!(enabled_of(&app, false), want); + assert_eq!(enabled_of(&app, true), want, "the Shift alternates"); // The item's params run as the menu runs them: Shift's alternate is `with_shift` of them. let run = |app: &mut VectorcraftApp, status: &str, shift: bool| { let p = json!({ "status": status }); @@ -207,9 +213,9 @@ fn menu_items_are_on_for_the_statuses_present_and_shift_adds() { app.run("select.set", json!({"ids": [harbour]})).unwrap(); app.run("edit.clear", json!({})).unwrap(); refresh(&mut app, 1.0); - let after = enabled_of(&app); - assert_eq!(after[2], Some(CommandState::new().enabled(false)), "no missing image is left"); - assert_eq!(after[1], on, "the embedded one stays"); + let after = enabled_of(&app, false); + assert_eq!(after[2], named(false, "Select Missing"), "no missing image is left"); + assert_eq!(after[1], named(true, "Select Embedded"), "the embedded one stays"); } /// A missing link kept only in a symbol's art can't be selected: Select Missing stays off and diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index 1eeb293edc..65d777899d 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -605,7 +605,8 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let prefs = &app.session.prefs; states.set(CommandRef::new("ui.align.hideOptions"), CommandState::new().title(if hidden { tl!("Show Options") } else { tl!("Hide Options") })); states.set(CommandRef::new("ui.align.usePreviewBounds"), CommandState::new().checked(prefs.use_preview_bounds).title(tl!("Use Preview Bounds"))); - states.set(CommandRef::new("ui.align.cancelKeyObject"), CommandState::new().enabled(align_to(app) == AlignTo::Key).title(tl!("Cancel Key Object"))); + let cancel = CommandState::new().enabled(align_to(app) == AlignTo::Key).title(tl!("Cancel Key Object")); + states.set(CommandRef::new("ui.align.cancelKeyObject"), cancel); // The key choice is named for what the key is: Align to Key Anchor while it is an anchor point. let key = CommandState::new().enabled(can_choose(app, AlignTo::Key)).checked(shown_align_to(app) == AlignTo::Key); states.set(CommandRef::new("align.toKeyObject"), key.title(align_to_icon_name(AlignTo::Key, key_is_anchor(app)).1)); diff --git a/crates/ui-egui/src/panels/css_properties.rs b/crates/ui-egui/src/panels/css_properties.rs index d076d8a515..13743fb641 100644 --- a/crates/ui-egui/src/panels/css_properties.rs +++ b/crates/ui-egui/src/panels/css_properties.rs @@ -293,7 +293,8 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { states.set(units_ref(units), CommandState::new().checked(panel.options.units == units).title(units.name())); } let mut options = panel.options.clone(); - for (name, label) in FLAGS.into_iter().zip([tl!("Absolute Position"), tl!("Width and Height"), tl!("Unnamed Objects"), tl!("Rasterize Unsupported Art")]) { + let labels = [tl!("Absolute Position"), tl!("Width and Height"), tl!("Unnamed Objects"), tl!("Rasterize Unsupported Art")]; + for (name, label) in FLAGS.into_iter().zip(labels) { let on = flag_mut(&mut options, name).is_some_and(|on| *on); states.set(option_ref(name), CommandState::new().checked(on).title(label)); } diff --git a/crates/ui-egui/src/panels/opentype.rs b/crates/ui-egui/src/panels/opentype.rs index 41788bfded..8715d02401 100644 --- a/crates/ui-egui/src/panels/opentype.rs +++ b/crates/ui-egui/src/panels/opentype.rs @@ -872,7 +872,7 @@ mod tests { assert_eq!(text_style(&app).unwrap().0.features, ["smcp"]); app.session.execute("select.set", &json!({"ids": []})).unwrap(); assert!(!menu_rows(&app).iter().any(|row| matches!(row, PanelRow::Submenu(..))), "the submenu is left out with no text selected"); - assert_eq!(state_of(&app, &CommandRef::new(RESET)), Some(CommandState::new().enabled(false))); + assert_eq!(state_of(&app, &CommandRef::new(RESET)), Some(CommandState::new().enabled(false).title("Reset OpenType Features"))); assert_eq!(run(&mut app, "ui.openType.nothing", &json!({})), None); } diff --git a/crates/ui-egui/src/panels/paragraph/tests.rs b/crates/ui-egui/src/panels/paragraph/tests.rs index 5a589acd8e..75310b3f35 100644 --- a/crates/ui-egui/src/panels/paragraph/tests.rs +++ b/crates/ui-egui/src/panels/paragraph/tests.rs @@ -10,9 +10,11 @@ fn selected(app: &VectorcraftApp) -> Vec { row.map(|r| r.0).into_iter().collect() } -/// Whether `states` holds `r` with exactly the state `state(enabled, checked)` makes. +/// Whether `states` holds `r` with the enabled and checked flags `state(enabled, checked)` makes. The row's name is +/// checked in `tests_menu_names`. fn has_state(states: &CommandStates, r: &CommandRef, enabled: bool, checked: Option) -> bool { - format!("{:?}", states.get(r)) == format!("{:?}", Some(&state(enabled, checked))) + let want = state(enabled, checked); + states.get(r).is_some_and(|s| s.is_enabled() == want.is_enabled() && s.is_checked() == want.is_checked()) } fn editing_text(text: &str) -> (VectorcraftApp, Value) { diff --git a/crates/ui-egui/src/panels/symbols/tests.rs b/crates/ui-egui/src/panels/symbols/tests.rs index baf277937a..262f1d7cdb 100644 --- a/crates/ui-egui/src/panels/symbols/tests.rs +++ b/crates/ui-egui/src/panels/symbols/tests.rs @@ -253,7 +253,7 @@ fn checked_view(app: &VectorcraftApp) -> Vec<&'static str> { menu_states(app, &mut states); let checked = |view: &str| { let row = CommandRef::with_params("ui.panelView", json!({"panel": "symbols", "view": view})); - states.get(&row) == Some(&CommandState::new().checked(true)) + states.get(&row).is_some_and(|s| s.is_enabled() && s.is_checked() == Some(true)) }; ["thumbnail", "smallList", "largeList"].into_iter().filter(|&view| checked(view)).collect() } From 4ce921dd1b3778e7dd3f12f7516ffd25911aa10b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 00:59:38 -0800 Subject: [PATCH 074/264] Export for Screens: the items sit in a framed view, and checked items show selected The Artboards and Assets panes drew their list and grid with no frame and only as tall as their items, so with one artboard the view buttons, Clear Selection and Prefix sat right under the thumbnail with empty space below. The views were also shown without a selection, and the grid draws a tile's check from the tile's selection, so a checked artboard had no outline and its check box drew empty. - The list and the grid sit on a sunken surface with control padding, and keep their height (9 rows, 4 tiles) when fewer items are shown. - The checked items are bound as the view's selection, so they draw the selection outline and a checked box. The lead and anchor are kept per tab from pass to pass; the checks still decide which items are exported. --- .../ui-egui/src/dialogs/export_for_screens.rs | 46 +++++++++---- crates/ui-egui/src/dialogs/tests_screens.rs | 64 +++++++++++++++++++ 2 files changed, 98 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/dialogs/export_for_screens.rs b/crates/ui-egui/src/dialogs/export_for_screens.rs index bef9fda0f9..bfedfd4d7d 100644 --- a/crates/ui-egui/src/dialogs/export_for_screens.rs +++ b/crates/ui-egui/src/dialogs/export_for_screens.rs @@ -30,13 +30,13 @@ use std::borrow::Cow; use std::sync::Arc; -use craft::behavior::{ColumnKey, ColumnWidth, DisplayOrder, GesturePhase, IconId, ItemSource, SelectionChange}; +use craft::behavior::{ColumnKey, ColumnWidth, DisplayOrder, GesturePhase, IconId, ItemSource, Selection, SelectionChange}; use craft::host::PickRequest; use craft::ui::buttons::Button; use craft::ui::choice::{Checkbox, Radio, RadioGroup, Segmented}; use craft::ui::contract::{ - Bind, CollectionEvent, ColumnSpec, Entry, Props as _, Show as _, ShowCollection as _, ShowContainer as _, SpaceAction, SweepApply, SweepStep, - ToggleColumn, + Bind, CollectionEvent, ColumnSpec, Entry, Pad, Props as _, Show as _, ShowCollection as _, ShowContainer as _, SpaceAction, SweepApply, + SweepStep, ToggleColumn, }; use craft::ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, HeldAnswer, HeldOk, StackDialog, dialog_id}; use craft::ui::display::{Shade, Text}; @@ -46,6 +46,7 @@ use craft::ui::patterns::form_dialogs::{FormDialog, PathRow}; use craft::ui::primitives::{ContentPainterCx, fit_rect}; use craft::ui::runtime::env::Label; use craft::ui::runtime::focus::Initial; +use craft::ui::style::SurfaceKind; use craft::ui::tabs::{Tab, TabKind, TabStrip}; use craft::ui::text::TextField; use craft::ui::tile_grid::{Tile, TileGrid, TilePartEvent}; @@ -93,10 +94,11 @@ const SETTABLE: [&str; 20] = [ /// The check column of the list view and its name column. const CHECK: ColumnKey = ColumnKey::new("check"); const NAME: ColumnKey = ColumnKey::new("name"); -/// Rows of the list view and of the grid view the items pane shows before it scrolls, a pane as tall as the options -/// column's first sections. +/// How many items the list view and the grid view hold before they scroll, and how tall they are with fewer: a +/// missing item counts a control row, so the pane stays about as tall as the options column's first sections with +/// one artboard. The framework counts a grid's items, not its rows of tiles. const LIST_ROWS: u16 = 9; -const GRID_ROWS: u16 = 3; +const GRID_ITEMS: u16 = 4; /// The longest side of an artboard thumbnail, in pixels. const THUMB_PX: u32 = 92; @@ -219,6 +221,7 @@ pub fn open(app: &mut VectorcraftApp) { pending: None, renaming_in: None, rename: None, + leads: Default::default(), held: HeldAnswer::new(), }; if let Some(dialogs) = app.dialogs() { @@ -541,6 +544,8 @@ pub(crate) struct ExportForScreensDialog { renaming_in: Option<(u64, u64)>, /// A committed artboard name: ((document uid, reverts), artboard id, name), for the pump to run. rename: Option<((u64, u64), u32, String)>, + /// The lead and anchor of the Artboards and the Assets view, by tab. + leads: [Selection; 2], held: HeldAnswer>, } @@ -616,7 +621,7 @@ impl ExportForScreensDialog { let checked = |at: usize| on.get(at).copied().unwrap_or(false); let shelf = Shelf { items: &items, enabled: text(fields, "select") != "full", reveal: None, caption: &caption, checked: &checked, paint: &paint }; - let picks = shelf.show(ui, text(fields, "view") == "list"); + let picks = shelf.show(ui, text(fields, "view") == "list", &mut self.leads[0]); for key in picks.toggled { if let Some(b) = items.index_of(&key).and_then(|at| on.get_mut(at)) { *b ^= true; @@ -654,7 +659,7 @@ impl ExportForScreensDialog { let checked = |at: usize| items.0.get(at).is_some_and(|(id, _)| on.contains(id)); let reveal = fields.get("__scrollTo").and_then(Value::as_u64).filter(|id| items.index_of(id).is_some()); let shelf = Shelf { items: &items, enabled: true, reveal, caption: &caption, checked: &checked, paint: &paint }; - let picks = shelf.show(ui, text(fields, "view") == "list"); + let picks = shelf.show(ui, text(fields, "view") == "list", &mut self.leads[1]); for id in picks.toggled { if on.contains(&id) { on.retain(|a| *a != id); @@ -724,23 +729,30 @@ struct Shelf<'a> { } impl Shelf<'_> { - /// Shows the items as a list of rows (`list`) or a grid of tiles → what the user did to them. - fn show(self, ui: &mut Ui, list: bool) -> Picks { + /// Shows the items as a list of rows (`list`) or a grid of tiles in a sunken frame, with the checked items + /// selected → what the user did to them. `lead` holds the selection's lead and anchor from pass to pass; its + /// items are the checked ones. + fn show(self, ui: &mut Ui, list: bool, lead: &mut Selection) -> Picks { let Shelf { items, enabled, reveal, caption, checked, paint } = self; let mut picks = Picks::default(); let rename = reveal.is_none(); let at = |key: &u64| items.index_of(key).unwrap_or(usize::MAX); let state = |at: usize| if checked(at) { ToggleState::On } else { ToggleState::Off }; + let mut selection = Selection::new((0..items.len()).filter(|at| checked(*at)).map(|at| items.key(at)).collect(), lead.lead, lead.anchor); if list { let columns = vec![ColumnSpec::toggle(CHECK, Label::Empty, ToggleColumn::default()), ColumnSpec::new(NAME, Label::Empty, ColumnWidth::fill(1.0))]; let mut view = List::::new(tl!("Export for Screens")) + .surface(SurfaceKind::Sunken) + .pad(Pad::Control) .header(false) .space(SpaceAction::ToggleCell) .columns(columns) .rename(rename) .enabled(enabled) - .max_rows(LIST_ROWS); + .min_rows(LIST_ROWS) + .max_rows(LIST_ROWS) + .selection(Bind::bound(&mut selection)); if rename { view = view.rename_column(NAME); } @@ -763,7 +775,15 @@ impl Shelf<'_> { } } } else { - let mut grid = TileGrid::::new(tl!("Export for Screens")).checks(true).rename(rename).enabled(enabled).max_rows(GRID_ROWS); + let mut grid = TileGrid::::new(tl!("Export for Screens")) + .surface(SurfaceKind::Sunken) + .pad(Pad::Control) + .checks(true) + .rename(rename) + .enabled(enabled) + .min_rows(GRID_ITEMS) + .max_rows(GRID_ITEMS) + .selection(Bind::bound(&mut selection)); if let Some(key) = reveal { grid = grid.reveal(key); } @@ -778,6 +798,8 @@ impl Shelf<'_> { } } } + // A click picks the item it lands on as the lead; the checks alone say which items are selected. + (lead.lead, lead.anchor) = (selection.lead, selection.anchor); picks } } diff --git a/crates/ui-egui/src/dialogs/tests_screens.rs b/crates/ui-egui/src/dialogs/tests_screens.rs index b4ae88d15a..8e6c139a68 100644 --- a/crates/ui-egui/src/dialogs/tests_screens.rs +++ b/crates/ui-egui/src/dialogs/tests_screens.rs @@ -1670,3 +1670,67 @@ fn the_format_rows_fit_the_right_column_at_the_default_and_least_window_sizes() } } } + +/// The items pane, in the grid and in the list, with one artboard and with many: the artboards sit in a sunken frame +/// at least one and a half tiles or five rows tall, the view buttons and the prefix sit under the frame, and the checked +/// artboards are the selected ones. +#[test] +fn the_artboards_sit_in_a_framed_view_as_tall_as_the_pane_and_the_checked_ones_are_selected() { + for (boards, view) in [(1, "grid"), (1, "list"), (12, "grid"), (12, "list")] { + let (mut app, _) = app(boards, false); + let mut w = Window::default(); + w.run(&mut app, vec![]); + open(&mut app); + set(&mut app, "view", json!(view)); + let shown = |w: &mut Window, app: &mut VectorcraftApp| { + w.run(app, vec![]); + let out = w.run(app, vec![]); + let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default(); + (out.shapes, nodes) + }; + let rect = |n: &egui::accesskit::Node| { + n.bounds().map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32))) + }; + let (shapes, nodes) = shown(&mut w, &mut app); + let find = |label: &str, role: Role| { + nodes + .iter() + .find(|(_, n)| n.label() == Some(label) && n.role() == role) + .and_then(|(_, n)| rect(n)) + .unwrap_or_else(|| panic!("{view}: no {role:?} {label:?}")) + }; + let pane = nodes + .iter() + .find(|(_, n)| n.label() == Some("Export for Screens") && matches!(n.role(), Role::ListBox | Role::List)) + .and_then(|(_, n)| rect(n)) + .unwrap_or_else(|| panic!("{boards} {view}: no items view")); + let clear = find("Clear Selection", Role::Button); + let tile = find("1 Artboard 1", Role::ListItem); + // The frame: a filled or outlined rectangle that holds the items view. + fn rects(shape: &egui::Shape, out: &mut Vec) { + match shape { + egui::Shape::Rect(r) => out.push(r.clone()), + egui::Shape::Vec(v) => v.iter().for_each(|s| rects(s, out)), + _ => {} + } + } + let mut painted = Vec::new(); + shapes.iter().for_each(|c| rects(&c.shape, &mut painted)); + let near: Vec<_> = painted.iter().filter(|r| r.rect.expand(4.0).contains_rect(pane) && pane.expand(4.0).contains_rect(r.rect)).collect(); + let framed = near.iter().any(|r| r.stroke.width > 0.0 || r.fill.a() > 0); + assert!(framed, "{boards} {view}: the items view at {pane:?} has a frame: {near:?}"); + assert!(clear.top() >= pane.bottom(), "{boards} {view}: Clear Selection {clear:?} is under the items {pane:?}"); + // One and a half tiles tall in the grid, five rows in the list, whatever the count of artboards. + let least = if view == "grid" { 1.5 } else { 5.0 } * tile.height(); + assert!(pane.height() >= least, "{boards} {view}: the items view {pane:?} is at least {least} tall (an item is {tile:?})"); + let selected = |nodes: &[(egui::accesskit::NodeId, egui::accesskit::Node)]| { + nodes.iter().find(|(_, n)| n.label() == Some("1 Artboard 1") && n.role() == Role::ListItem).and_then(|(_, n)| n.is_selected()) + }; + assert_eq!(selected(&nodes), Some(true), "{boards} {view}: the checked artboard is selected"); + let mut off = vec![true; boards]; + off[0] = false; + set(&mut app, "boards", json!(off)); + let (_, nodes) = shown(&mut w, &mut app); + assert_ne!(selected(&nodes), Some(true), "{boards} {view}: an artboard that is not checked is not selected"); + } +} From c1bc3a2d502117a09d43b76a0e1effb350fc584b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 01:02:30 -0800 Subject: [PATCH 075/264] Appearance: a narrow group shows the Stroke and Fill labels whole In a 220 pt floating group the paint rows' links were cut to "S" and "F": each row gives its trailing parts their full width first, and the stroke weight was the Stroke panel's regular-size field with its presets list. A paint row's weight is now a small field without the presets list; its arrows, the arrow keys and the wheel still step it, stopping at each preset. Fill rows reserve the same room, so the swatches stay in one column. --- crates/ui-egui/src/panels/appearance.rs | 15 ++++++---- crates/ui-egui/src/panels/appearance/tests.rs | 28 +++++++++++++++++++ crates/ui-egui/src/panels/stroke.rs | 21 ++++++++++++-- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/panels/appearance.rs b/crates/ui-egui/src/panels/appearance.rs index 7bce287424..bdb561f5f6 100644 --- a/crates/ui-egui/src/panels/appearance.rs +++ b/crates/ui-egui/src/panels/appearance.rs @@ -44,7 +44,7 @@ use craft::ui::primitives::IconSpec; use craft::ui::runtime::commands::{CommandRef, CommandState, CommandStates}; use craft::ui::runtime::env::Label; use craft::ui::sections::{FooterAction, FooterBar}; -use craft::ui::text::NumberOutput; +use craft::ui::text::{NumberField, NumberOutput}; use egui::{Rect, Ui, vec2}; use serde_json::{Value, json}; use vectorcraft_color::{BlendMode, Paint}; @@ -860,11 +860,9 @@ fn item_row<'r>(cx: &'r RowCx<'_>, key: RowKey, i: usize) -> ListRow<'r> { if let Some(st) = stroke_layer { let target = if new_art { WeightTarget::Shown } else { WeightTarget::Item(i) }; let pass = cx.pass; - row = row.trailing_field(stroke::weight_number(cx.app, Some(st.width)), move |out| { - pass.borrow_mut().acts.push(Act::Weight(target, Box::new(out))) - }); + row = row.trailing_field(row_weight(cx.app, Some(st.width)), move |out| pass.borrow_mut().acts.push(Act::Weight(target, Box::new(out)))); } else { - row = row.trailing_space(stroke::weight_number(cx.app, None)); + row = row.trailing_space(row_weight(cx.app, None)); } let painted = if new_art { Painted::NewArt { fill } } else { Painted::Item(i) }; let pass = cx.pass; @@ -892,6 +890,13 @@ fn paint_swatch(fill: bool, paint: &Paint) -> Swatch { .tooltip(tl!("Click to choose a swatch, Shift-click to mix a colour")) } +/// The weight field of a stroke row, or the room it takes in a fill row: the Stroke panel's field as a small control, +/// as the row's swatch is, without the presets list (a step still stops at each preset), so the row's label shows +/// whole in the narrowest group. +fn row_weight(app: &VectorcraftApp, weight: Option) -> NumberField<'static> { + stroke::steps_weight(app, weight).size(ControlSize::Sm) +} + /// A stroke row's notes after the weight: its brush and "Dashed". fn stroke_notes(st: &vectorcraft_doc::StrokeLayer) -> Option { let dashed = st.dash.as_ref().is_some_and(|d| d.is_dashed()).then_some(tl!("Dashed")); diff --git a/crates/ui-egui/src/panels/appearance/tests.rs b/crates/ui-egui/src/panels/appearance/tests.rs index 97a76b420f..5e5a4fc5b4 100644 --- a/crates/ui-egui/src/panels/appearance/tests.rs +++ b/crates/ui-egui/src/panels/appearance/tests.rs @@ -677,6 +677,34 @@ fn an_appearance_row_held_across_file_revert_is_not_dropped_on_the_footer() { assert_eq!(items(&panel), before + 1, "a drag started after the revert still duplicates the row"); } +/// A floating group at the narrowest panel width shows the "Stroke:" and "Fill:" links whole, as wide as a wide group +/// shows them: the stroke weight beside them is a small field inside the panel, and the stroke and fill swatches still +/// stand in one column. +#[test] +fn the_narrowest_group_shows_the_stroke_and_fill_labels_whole() { + use crate::panel_docking::PANEL_MIN_WIDTH; + use crate::tests::panel_harness::{Place, floated}; + let one = |shown: &crate::tests::panel_harness::Shown, name: &str, width: f32| { + let rects = shown.rects(name); + assert_eq!(rects.len(), 1, "one {name:?} at {width} pt: {rects:?}"); + rects[0] + }; + let links = |width: f32| { + let shown = floated(app_with_a_selected_rectangle(), "appearance", "en", Place::Floating(width), &["Stroke:", "Fill:"]); + let [stroke, fill] = ["Stroke:", "Fill:"].map(|name| one(&shown, name, width).width()); + let [stroke_well, fill_well] = ["Stroke swatch", "Fill swatch"].map(|name| one(&shown, name, width).left()); + assert!((stroke_well - fill_well).abs() < 0.5, "the swatches stand at {stroke_well} and {fill_well} pt at {width} pt"); + let weight = one(&shown, "Weight", width); + assert!(shown.body.contains_rect(weight), "the weight field {weight:?} stands inside the panel {:?} at {width} pt", shown.body); + ([stroke, fill], format!("stroke swatch at {stroke_well} pt, weight {weight:?}")) + }; + let (wide, _) = links(400.0); + let (narrow, row) = links(PANEL_MIN_WIDTH); + for (at, name) in ["Stroke:", "Fill:"].iter().enumerate() { + assert!(narrow[at] >= wide[at] - 0.5, "{name:?} is {} pt wide at {PANEL_MIN_WIDTH} pt and {} pt at 400 pt ({row})", narrow[at], wide[at]); + } +} + /// The panel's subject is the `Arc` the document holds for the selected object, a targeted group /// or a targeted layer, not a copy of it; nothing with nothing selected. #[test] diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 15b3e438cc..7ea1db6e49 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -301,10 +301,19 @@ static BLANK_WEIGHT_STOPS: [f64; 2] = [0.25, 0.5]; /// 0 pt); Shift or Page steps the grid by ten. // PLAN: the sheet names `NumberField<'static, f64>`; `NumberField::length` takes `Option`. pub(crate) fn weight_number(app: &VectorcraftApp, weight: Option) -> NumberField<'static> { + let field = steps_weight(app, weight); + match weight_ladder(app) { + Some(l) => field.presets(&l.rows), + None => field, + } +} + +/// [`weight_number`] without the presets list: a plain step still stops at each preset. +pub(crate) fn steps_weight(app: &VectorcraftApp, weight: Option) -> NumberField<'static> { let unit = app.session.stroke_unit(); let lengths = crate::fields::bare_points(LengthUnits::new(UnitKind::Points, shown_kind(unit), 72.0), app.session.prefs.numbers_without_units_are_points); - let ladder = LADDERS.iter().find(|(u, _)| *u == unit).or_else(|| LADDERS.iter().find(|(u, _)| *u == Unit::Points)).map(|(_, l)| l); + let ladder = weight_ladder(app); let field = NumberField::length(tl!("Weight"), Bind::given(weight), lengths).range(0.0..=1000.0).step_arrows(StepArrows::Leading).scrub_by_label(); // The stepper steps the number the field shows; the ladders are in points. @@ -315,12 +324,18 @@ pub(crate) fn weight_number(app: &VectorcraftApp, weight: Option) -> Number match ladder { // A blank weight (the selected objects differ) steps in points from 0.25 pt, whatever the unit's ladder: up // gives 0.5 pt, down 0 pt (#5349). - Some(l) if weight.is_none() => field.presets(&l.rows).stepper(in_points(&BLANK_WEIGHT_STOPS, true)), - Some(l) => field.presets(&l.rows).stepper(in_points(&l.stops, false)), + Some(_) if weight.is_none() => field.stepper(in_points(&BLANK_WEIGHT_STOPS, true)), + Some(l) => field.stepper(in_points(&l.stops, false)), None => field, } } +/// The ladder of the stroke unit the session shows, or of points. +fn weight_ladder(app: &VectorcraftApp) -> Option<&'static Ladder> { + let unit = app.session.stroke_unit(); + LADDERS.iter().find(|(u, _)| *u == unit).or_else(|| LADDERS.iter().find(|(u, _)| *u == Unit::Points)).map(|(_, l)| l) +} + /// Sends a weight edit of `out` to `target`: a scrub or slider drag is one undo step, a typed, stepped or picked /// value commits at once, and while the Type tool edits text the weight goes to the selected characters. pub(crate) fn apply_weight(app: &mut VectorcraftApp, out: &NumberOutput, target: WeightTarget) { From 31c0f6466a31a0aa50f18fd338fb01f5321fa1d1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 01:18:05 -0800 Subject: [PATCH 076/264] Import PDF: a page number the Page field refuses goes back to the shown page The Page field in Import PDF and Place PDF read the typed number with `value()`, so a number typed before text the field then refused on Tab stayed as the chosen page while the field showed the page from before the edit, and OK placed that page. The field now reads `landed()`, as the DXF import options' Scale field does since #9747. DXF import options gains a test for its Scale field that refuses text on Tab and checks the import uses the restored scale; the Escape test from #9747 passed with `value()` as well. --- crates/ui-egui/src/dialogs/dxf_import.rs | 14 ++++++++++ crates/ui-egui/src/dialogs/import_pdf.rs | 2 +- .../ui-egui/src/dialogs/tests_import_pdf.rs | 26 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/dxf_import.rs b/crates/ui-egui/src/dialogs/dxf_import.rs index 55e39a119a..59d5dddca0 100644 --- a/crates/ui-egui/src/dialogs/dxf_import.rs +++ b/crates/ui-egui/src/dialogs/dxf_import.rs @@ -537,6 +537,20 @@ mod tests { assert_eq!(host::fields(&panel.app(), KIND)["scale"], 1.0); } + #[test] + fn a_scale_the_field_refuses_on_tab_imports_the_scale_it_restores() { + let mut panel = actual_dialog(); + panel.click("Scale"); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("2"); + assert_eq!(host::fields(&panel.app(), KIND)["scale"], 2.0); + panel.type_text("*"); + panel.key(Key::Tab, Modifiers::NONE); + assert!(host::is_open(&panel.app(), KIND)); + assert_eq!(host::fields(&panel.app(), KIND)["scale"], 1.0, "the refused text restores the scale from before the edit"); + accept_and_check_width(&mut panel, Unit::Millimeters, 100.0 * Unit::Millimeters.points()); + } + #[test] fn actual_layout_and_unit_enter_and_scale_blur_import_the_accepted_choices() { let mut panel = actual_dialog(); diff --git a/crates/ui-egui/src/dialogs/import_pdf.rs b/crates/ui-egui/src/dialogs/import_pdf.rs index df899ee1c3..f539897c25 100644 --- a/crates/ui-egui/src/dialogs/import_pdf.rs +++ b/crates/ui-egui/src/dialogs/import_pdf.rs @@ -441,7 +441,7 @@ fn pages_body(ui: &mut egui::Ui, s: &mut State, preview: Option<&(Revision, Arc< Text::new(crate::i18n::fmt(tl!("of {count}"), &[("count", &count.to_string())])).shade(Shade::Muted).show(ui); let next = nav(ui, "chevron-right", tl!("Next Page"), (current + 1).min(count), current < count); let last = nav(ui, "chevrons-right", tl!("Last Page"), count, current < count); - to = first.or(previous).or(next).or(last).or(typed.value().copied().flatten().map(|v| v as usize)); + to = first.or(previous).or(next).or(last).or(typed.edit.events.landed().copied().flatten().map(|v| v as usize)); }); if let Some(page) = to { s.page = page.clamp(1, count.max(1)); diff --git a/crates/ui-egui/src/dialogs/tests_import_pdf.rs b/crates/ui-egui/src/dialogs/tests_import_pdf.rs index 622756a1bd..3b96687a49 100644 --- a/crates/ui-egui/src/dialogs/tests_import_pdf.rs +++ b/crates/ui-egui/src/dialogs/tests_import_pdf.rs @@ -678,3 +678,29 @@ fn an_empty_password_still_asks_for_the_password() { assert!(!import_pdf::offer_place_password(&mut app, &p), "a given password is placed with"); assert!(!is_open(&app)); } + +/// A page number the Page field refuses when Tab leaves it goes back to the page shown before the edit, and OK places +/// that page. +#[test] +fn a_page_the_field_refuses_on_tab_places_the_page_it_restores() { + use crate::tests::panel_harness::Panel; + use egui::{Key, Modifiers}; + + let mut panel = Panel::new(app(), crate::tests::picks::dialogs); + panel.room(egui::vec2(1000.0, 800.0)); + place(&mut panel.app(), &three_pages(), json!({"at": [100, 120], "link": false})).unwrap(); + panel.frame(); + panel.click("Page"); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("2"); + assert_eq!(field(&panel.app(), "page"), 2); + panel.type_text("*"); + panel.key(Key::Tab, Modifiers::NONE); + assert!(is_open(&panel.app())); + assert_eq!(field(&panel.app(), "page"), 1, "the refused text restores the page from before the edit"); + panel.click("OK"); + panel.frame(); + assert!(!is_open(&panel.app())); + let (_, bounds) = placed(&panel.app()); + assert_eq!((bounds.width(), bounds.height()), (100.0, 100.0), "the first page is placed"); +} From c77fd87964946795ae9c20f3a7711a3eca7006ef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 01:29:38 -0800 Subject: [PATCH 077/264] Brushes: Brush Options and Apply Brush that change nothing add no undo step brush.options with params and a newName that leave the brush as it is stored the library again, raised the document revision and added an Undo step; only the Brush Options dialog skipped an unchanged OK. save_library now returns without an edit when the library it is given equals the document's and nothing is renamed, as brush.move already does. brush.apply of the brush the strokes and the current brush already have runs through edit_if_changed and records nothing. --- crates/engine/src/cmd/brushsym.rs | 4 +- crates/engine/src/cmd/brushsym/brushes.rs | 10 +++- crates/engine/src/tests/brushsym.rs | 56 +++++++++++++++++++++++ docs/mcp.md | 4 +- 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/brushsym.rs b/crates/engine/src/cmd/brushsym.rs index 3828d67d0c..2de3ddfcfe 100644 --- a/crates/engine/src/cmd/brushsym.rs +++ b/crates/engine/src/cmd/brushsym.rs @@ -98,7 +98,7 @@ pub fn specs() -> Vec { "Apply Brush", [], None, - "{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current → {ids}", + "{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current; when the strokes already have it and it is already current, nothing changes and no undo step is recorded → {ids}", has_doc, brush_apply ), @@ -170,7 +170,7 @@ pub fn specs() -> Vec { "Brush Options…", [], None, - "{name, params?: {…fields to change (brush.get shows them; values outside their ranges are clamped). calligraphic: angle −180..180° (counter-clockwise from level), roundness 0..100%, size 0..1296 pt, variation: [angle°, roundness%, size pt], modes: [fixed|random|pressure|tilt|bearing|rotation|stylusWheel for angle, roundness, size] (pressure goes from value − variation at the lightest pen pressure to value + variation at the heaviest; tilt from value − variation with the pen lying flat to value + variation with it upright; bearing and rotation add variation × the pen's bearing (which way it leans, counter-clockwise from leaning right) or its barrel's counter-clockwise rotation over 180°; stylusWheel from value − variation at one end of an airbrush pen's finger wheel to value + variation at the other; the angle turns on past ±180°). scatter: size [a, b] 1..10000%, spacing [a, b] 1..10000%, scatter [a, b] −1000..1000%, rotation [a, b] −180..180° (counter-clockwise), modes: [fixed|random|pressure|tilt|bearing|rotation|stylusWheel for size, spacing, scatter, rotation] (fixed: a; random: between a and b; pressure: a at the lightest pen pressure to b at the heaviest; tilt: a with the pen lying flat to b upright; bearing and rotation: a at −180° to b at 180°; stylusWheel: a at one end of an airbrush pen's finger wheel to b at the other), rotation_relative_to_path, hue_jitter 0..180° (each copy turns the hue of its solid colors, after the colorization, by its own amount up to this far either way, the same on every redraw; colors without a hue stay; 0: off), saturation_jitter 0..100% (each copy moves the saturation of its solid colors, after the colorization and the hue jitter, by its own amount up to this many points either way, keeping their hue and brightness, the same on every redraw; colors without a hue stay; 0: off), brightness_jitter 0..100% (each copy moves the brightness of its solid colors, after the colorization and the hue and saturation jitter, by its own amount up to this many points either way, keeping their hue and saturation, the same on every redraw; white, black and grays move too; 0: off). art: width 1..1000%, width_mode: null (fixed)|pressure|tilt|bearing|rotation|stylusWheel, width_max 1..1000% (pressure: width at the lightest pen pressure to width_max at the heaviest; tilt: width with the pen lying flat to width_max upright; bearing and rotation: width at −180° to width_max at 180°; stylusWheel: width at one end of the finger wheel to width_max at the other; half way on a stroke drawn without that input), scale: {mode: proportional|stretch|betweenGuides, start, end: 0..1 of the art length}, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flip_along, flip_across, overlap. pattern: scale 1..10000%, scale_mode: null (fixed)|pressure|tilt|bearing|rotation|stylusWheel, scale_max 1..10000% (the tiles go from scale to scale_max over the same pen ranges as an art brush's width; half way on a stroke drawn without that input; each tile's height follows the stroke, its length and the gap after it take the scale at its middle, and a corner tile takes the scale at its corner), spacing 0..10000%, fit: stretch|addSpace|approximate, flip_along, flip_across, outer_corner and inner_corner: corner tile art (drawn as the corner that joins a side tile on its right to one below it) or null, outer_source and inner_source: what that kind of corner draws without its art: none|autoCentered|autoBetween|autoSliced|autoOverlap (a tile made from the side tile), or null (the other kind of corner's art); side_tile, outer_corner_tile, inner_corner_tile, start_tile, end_tile: a document pattern name, original, or none (side refuses none); corner tiles also take autoCentered|autoBetween|autoSliced|autoOverlap. Each tile also accepts {pattern: name} to select a swatch whose name is a reserved choice. scatter, art and pattern: colorization: {method: none|tints|tintsAndShades|hueShift, key: colour (hueShift: the art colour that becomes the stroke colour; without a key: the solid color the art's fills and strokes use most, black when they use none)}; colorization and the art brush's scale change only the fields given}, newName? (trimmed; blank: the name is kept; a new bristle brush name has at most 31 characters, and a longer name the brush has is kept)} edit a brush definition (strokes using it update) → {name}", + "{name, params?: {…fields to change (brush.get shows them; values outside their ranges are clamped). calligraphic: angle −180..180° (counter-clockwise from level), roundness 0..100%, size 0..1296 pt, variation: [angle°, roundness%, size pt], modes: [fixed|random|pressure|tilt|bearing|rotation|stylusWheel for angle, roundness, size] (pressure goes from value − variation at the lightest pen pressure to value + variation at the heaviest; tilt from value − variation with the pen lying flat to value + variation with it upright; bearing and rotation add variation × the pen's bearing (which way it leans, counter-clockwise from leaning right) or its barrel's counter-clockwise rotation over 180°; stylusWheel from value − variation at one end of an airbrush pen's finger wheel to value + variation at the other; the angle turns on past ±180°). scatter: size [a, b] 1..10000%, spacing [a, b] 1..10000%, scatter [a, b] −1000..1000%, rotation [a, b] −180..180° (counter-clockwise), modes: [fixed|random|pressure|tilt|bearing|rotation|stylusWheel for size, spacing, scatter, rotation] (fixed: a; random: between a and b; pressure: a at the lightest pen pressure to b at the heaviest; tilt: a with the pen lying flat to b upright; bearing and rotation: a at −180° to b at 180°; stylusWheel: a at one end of an airbrush pen's finger wheel to b at the other), rotation_relative_to_path, hue_jitter 0..180° (each copy turns the hue of its solid colors, after the colorization, by its own amount up to this far either way, the same on every redraw; colors without a hue stay; 0: off), saturation_jitter 0..100% (each copy moves the saturation of its solid colors, after the colorization and the hue jitter, by its own amount up to this many points either way, keeping their hue and brightness, the same on every redraw; colors without a hue stay; 0: off), brightness_jitter 0..100% (each copy moves the brightness of its solid colors, after the colorization and the hue and saturation jitter, by its own amount up to this many points either way, keeping their hue and saturation, the same on every redraw; white, black and grays move too; 0: off). art: width 1..1000%, width_mode: null (fixed)|pressure|tilt|bearing|rotation|stylusWheel, width_max 1..1000% (pressure: width at the lightest pen pressure to width_max at the heaviest; tilt: width with the pen lying flat to width_max upright; bearing and rotation: width at −180° to width_max at 180°; stylusWheel: width at one end of the finger wheel to width_max at the other; half way on a stroke drawn without that input), scale: {mode: proportional|stretch|betweenGuides, start, end: 0..1 of the art length}, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flip_along, flip_across, overlap. pattern: scale 1..10000%, scale_mode: null (fixed)|pressure|tilt|bearing|rotation|stylusWheel, scale_max 1..10000% (the tiles go from scale to scale_max over the same pen ranges as an art brush's width; half way on a stroke drawn without that input; each tile's height follows the stroke, its length and the gap after it take the scale at its middle, and a corner tile takes the scale at its corner), spacing 0..10000%, fit: stretch|addSpace|approximate, flip_along, flip_across, outer_corner and inner_corner: corner tile art (drawn as the corner that joins a side tile on its right to one below it) or null, outer_source and inner_source: what that kind of corner draws without its art: none|autoCentered|autoBetween|autoSliced|autoOverlap (a tile made from the side tile), or null (the other kind of corner's art); side_tile, outer_corner_tile, inner_corner_tile, start_tile, end_tile: a document pattern name, original, or none (side refuses none); corner tiles also take autoCentered|autoBetween|autoSliced|autoOverlap. Each tile also accepts {pattern: name} to select a swatch whose name is a reserved choice. scatter, art and pattern: colorization: {method: none|tints|tintsAndShades|hueShift, key: colour (hueShift: the art colour that becomes the stroke colour; without a key: the solid color the art's fills and strokes use most, black when they use none)}; colorization and the art brush's scale change only the fields given}, newName? (trimmed; blank: the name is kept; a new bristle brush name has at most 31 characters, and a longer name the brush has is kept)} edit a brush definition (strokes using it update); params and a newName that leave the brush as it is change nothing and record no undo step → {name}", has_doc, brush_options ), diff --git a/crates/engine/src/cmd/brushsym/brushes.rs b/crates/engine/src/cmd/brushsym/brushes.rs index af71b2dae9..18eb440f3a 100644 --- a/crates/engine/src/cmd/brushsym/brushes.rs +++ b/crates/engine/src/cmd/brushsym/brushes.rs @@ -80,10 +80,11 @@ pub(super) fn brush_apply(s: &mut Session, p: &Value) -> Result { } let ids = brush_targets(&s.doc()?.doc, &roots(s, p)?); let stroke = stroke_paint(s); - s.edit("Apply Brush", |d, _| { + crate::cmd::colorcmds::edit_if_changed(s, "Apply Brush", |before, d| { d.unknown.insert(brush::CURRENT_KEY.into(), json!(name)); apply_brush(d, &ids, &name, &stroke); - Ok(()) + let changed = brush::current(before).as_deref() != Some(name.as_str()) || ids.iter().any(|id| before.node(*id) != d.node(*id)); + Ok(((), changed)) })?; Ok(json!({ "ids": ids_json(&ids) })) } @@ -213,7 +214,12 @@ fn rename_brush_strokes(d: &mut Document, lib: &mut [Brush], from: &str, to: Opt } } +/// Stores `lib` and applies `renames` as one undo step named `label`. A `lib` equal to the +/// document's library, with no renames, leaves the document and its undo history as they are. fn save_library(s: &mut Session, label: &str, mut lib: Vec, renames: &[(String, Option)]) -> Result<()> { + if renames.is_empty() && lib == brush::library(&s.doc()?.doc) { + return Ok(()); + } s.edit(label, |d, _| { for (from, to) in renames { rename_brush_strokes(d, &mut lib, from, to.as_deref()); diff --git a/crates/engine/src/tests/brushsym.rs b/crates/engine/src/tests/brushsym.rs index 032e3ddb8c..86074c2a6b 100644 --- a/crates/engine/src/tests/brushsym.rs +++ b/crates/engine/src/tests/brushsym.rs @@ -913,6 +913,62 @@ fn brush_options_rename_duplicate_and_delete_update_strokes() { assert!(s.execute("brush.delete", &json!({"name": "5 pt. Round"})).is_err()); } +/// `brush.options` that leaves the brush as it is changes neither the document nor its revision, +/// and records no undo step, whether the library is stored or still the defaults. +#[test] +fn brush_options_that_change_nothing_record_no_undo_step() { + let mut s = session(); + let state = |s: &Session| { + let st = s.doc().unwrap(); + (st.doc.clone(), st.revision, st.history.undo.len()) + }; + let before = state(&s); + s.execute("brush.options", &json!({"name": "Arrow", "params": {}})).unwrap(); + assert_eq!(state(&s), before, "unchanged options of a default library change nothing"); + s.execute("brush.options", &json!({"name": "Arrow", "params": {"width": 110.25}})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1, "a changed option is one undo step"); + let before = state(&s); + for p in [ + json!({"name": "Arrow"}), + json!({"name": "Arrow", "params": {}}), + json!({"name": "Arrow", "params": {"width": 110.25}}), + json!({"name": "Arrow", "newName": " Arrow "}), + json!({"name": "Arrow", "newName": ""}), + ] { + assert_eq!(s.execute("brush.options", &p).unwrap()["name"], "Arrow"); + assert_eq!(state(&s), before, "{p} changes nothing"); + } + s.execute("brush.options", &json!({"name": "Arrow", "newName": "Arrow 2"})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1, "a rename is one undo step"); +} + +/// `brush.apply` of the brush that the strokes and the current brush already have changes neither +/// the document nor its revision, and records no undo step. +#[test] +fn brush_apply_that_changes_nothing_records_no_undo_step() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0, 50.0, 50.0); + let state = |s: &Session| { + let st = s.doc().unwrap(); + (st.doc.clone(), st.revision, st.history.undo.len()) + }; + let before = state(&s); + s.execute("brush.apply", &json!({"name": "Charcoal", "ids": [a.0]})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1); + let before = state(&s); + s.execute("brush.apply", &json!({"name": "Charcoal", "ids": [a.0]})).unwrap(); + assert_eq!(state(&s), before, "applying the brush again changes nothing"); + s.execute("brush.setCurrent", &json!({"name": "Arrow"})).unwrap(); + s.execute("brush.apply", &json!({"name": "Charcoal", "ids": [a.0]})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1, "making the brush current again is one undo step"); + assert_eq!(s.execute("brush.list", &json!({})).unwrap()["current"], "Charcoal"); + let b = rect(&mut s, 80.0, 10.0, 50.0, 50.0); + let steps = undo_steps(&s); + s.execute("brush.apply", &json!({"name": "Charcoal", "ids": [a.0, b.0]})).unwrap(); + assert_eq!((brush_of(&s, a).as_deref(), brush_of(&s, b).as_deref()), (Some("Charcoal"), Some("Charcoal"))); + assert_eq!(undo_steps(&s), steps + 1, "a new stroke to paint is one undo step"); +} + /// A document whose brushes repeat a name opens with the later brush numbered: strokes of the name /// keep the first brush, and renaming or deleting one brush leaves the other and its strokes alone. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..b22bc55ef5 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5179,7 +5179,9 @@ already walks Image Trace. Short agent entry points: `brush.new` or `brush.options` without a `key` takes the color that the art's fills and strokes use most (on a tie, the one found first), or black when they use no solid color. `brush.options` changes only the fields of `colorization` and of an art brush's `scale` that `params` gives, so `{colorization: {method: "hueShift"}}` keeps a - Hue Shift brush's key. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the + Hue Shift brush's key. A `brush.options` whose `params` and `newName` leave the brush as it is, and a + `brush.apply` whose strokes already have the brush while it is already current, do not change the document or + its revision and record no undo step. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the default, leaves every copy's colors as the colorization gives them) turns the hue of each copy's solid fills and strokes, its type's characters included, by that copy's own amount between minus and plus that many degrees. The turn comes after the colorization: with None it turns the art's own colors, with Tints and Tints and Shades the From 988edeabc6be352a9b057215b3e74f0f8d520bef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 01:47:52 -0800 Subject: [PATCH 078/264] Export for Screens: Space flips only the item it is pressed on The items pane selects every checked item. Space on a selected item flips that item and then the other selected items to its new value, so Space on one checked artboard unchecked every checked artboard. The pane now keeps only the flips of the first item a pass reports, which is the lead item for Space. A test moves to a checked artboard with the arrow keys, runs a frame and presses Space in the grid and the list. --- .../ui-egui/src/dialogs/export_for_screens.rs | 5 +++++ crates/ui-egui/src/dialogs/tests_screens.rs | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/ui-egui/src/dialogs/export_for_screens.rs b/crates/ui-egui/src/dialogs/export_for_screens.rs index bfedfd4d7d..decb345a71 100644 --- a/crates/ui-egui/src/dialogs/export_for_screens.rs +++ b/crates/ui-egui/src/dialogs/export_for_screens.rs @@ -800,6 +800,11 @@ impl Shelf<'_> { } // A click picks the item it lands on as the lead; the checks alone say which items are selected. (lead.lead, lead.anchor) = (selection.lead, selection.anchor); + // Space on a selected item flips that item first and then the other selected items to the same value. The + // selection here is every checked item, so only the first item's flips are kept. + if let Some(&first) = picks.toggled.first() { + picks.toggled.retain(|key| *key == first); + } picks } } diff --git a/crates/ui-egui/src/dialogs/tests_screens.rs b/crates/ui-egui/src/dialogs/tests_screens.rs index 8e6c139a68..48a6c0255f 100644 --- a/crates/ui-egui/src/dialogs/tests_screens.rs +++ b/crates/ui-egui/src/dialogs/tests_screens.rs @@ -1734,3 +1734,23 @@ fn the_artboards_sit_in_a_framed_view_as_tall_as_the_pane_and_the_checked_ones_a assert_ne!(selected(&nodes), Some(true), "{boards} {view}: an artboard that is not checked is not selected"); } } + +/// With two artboards checked, the arrow keys move to a checked one and, a frame later, Space unchecks only that one, +/// in the grid and in the list. +#[test] +fn space_on_a_checked_artboard_flips_only_its_own_check() { + for (view, back) in [("grid", egui::Key::ArrowLeft), ("list", egui::Key::ArrowUp)] { + let (mut app, _) = app(3, false); + let mut w = Window::default(); + w.names(&mut app); + open(&mut app); + set(&mut app, "view", json!(view)); + set(&mut app, "boards", json!([true, true, false])); + w.press(&mut app, "3 Artboard 3", Role::ListItem); + assert_eq!(field(&app, "boards"), json!([true, true, false]), "{view}: a click on the third artboard leaves the checks"); + w.key(&mut app, back); + w.run(&mut app, vec![]); + w.key(&mut app, egui::Key::Space); + assert_eq!(field(&app, "boards"), json!([true, false, false]), "{view}: Space unchecks only the second artboard"); + } +} From cfa2bbb878e0fe1c6017fdbdbf8f53ff7ba8df02 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 02:37:49 -0800 Subject: [PATCH 079/264] Dialogs: a style options dialog keeps its tab through its first measuring run With the current craft-libs, the first show of a properties dialog is a measuring run that can end before the dialog's body runs, and it then sets the first tab as the shown one. A tab picked before the first frame (Tabs in Paragraph Style Options) was lost, so the Tabs pane and its Clear All Tabs button were not shown. The style options dialogs now keep the tab that was shown before a measuring run. --- crates/ui-egui/src/dialogs/char_style_options.rs | 10 +++++++++- crates/ui-egui/src/dialogs/para_style_options/tests.rs | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/char_style_options.rs b/crates/ui-egui/src/dialogs/char_style_options.rs index 584964e0c4..3e8a78a618 100644 --- a/crates/ui-egui/src/dialogs/char_style_options.rs +++ b/crates/ui-egui/src/dialogs/char_style_options.rs @@ -1126,7 +1126,15 @@ macro_rules! style_dialog { } fn show(&mut self, ui: &mut egui::Ui, stack: &craft::ui::dialog::DialogStack) -> Option> { - craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack) + // A measuring run can end without running the dialog's body and then sets the first tab as the + // shown one. The dialog keeps the tab that was shown before that run. + let measuring = craft::ui::runtime::measure::active(ui.ctx()); + let tab = self.inner.tab(); + let shown = craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack); + if measuring && self.inner.tab() != tab { + let _ = craft::ui::dialog::StackDialog::set_json_field(&mut self.inner, ui.ctx(), "tab", serde_json::json!(tab)); + } + shown } fn key(&self) -> Option<&str> { diff --git a/crates/ui-egui/src/dialogs/para_style_options/tests.rs b/crates/ui-egui/src/dialogs/para_style_options/tests.rs index 39d26bfb1a..d9ed8b9ed7 100644 --- a/crates/ui-egui/src/dialogs/para_style_options/tests.rs +++ b/crates/ui-egui/src/dialogs/para_style_options/tests.rs @@ -574,6 +574,8 @@ fn clear_all_tabs_can_be_clicked_in_a_narrow_viewport() { for _ in 0..5 { frame(&mut app, vec![]); } + // The dialog's first frames measure it before its body runs; the Tabs pane picked before them stays shown. + assert_eq!(fields(&app)["tab"], json!("tabs"), "the dialog left Tabs in its first frames at {width} points"); let out = frame(&mut app, vec![]); let nodes = out.platform_output.accesskit_update.unwrap().nodes; let clear = nodes From 7d9cd73f5fff98a907fdf51c2e9d2d32b01b4e2d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 02:37:49 -0800 Subject: [PATCH 080/264] Toolbars: Rename Button works on a button whose command is dimmed A context menu owned by a disabled button takes no clicks with the current craft-libs, so Rename Button... on a dimmed button opened no dialog. The row around the button now owns the menu, and a right click on the button opens it. --- crates/ui-egui/src/custom_toolbars.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/custom_toolbars.rs b/crates/ui-egui/src/custom_toolbars.rs index 9622364483..e9e58f7e6b 100644 --- a/crates/ui-egui/src/custom_toolbars.rs +++ b/crates/ui-egui/src/custom_toolbars.rs @@ -32,6 +32,7 @@ use craft::ui::buttons::{Button, IconButton}; use craft::ui::contract::{Bind, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger}; use craft::ui::dialog::DialogResult; use craft::ui::display::{Divider, Shade, Text}; +use craft::ui::layout_components::Row; use craft::ui::menu::{Menu, MenuItem}; use craft::ui::patterns::form_dialogs::{ DialogFields, FieldValue, HostedListManager, HostedParamDialog, ListManagerAction, ListManagerChoice, ListManagerEntry, ListManagerWords, Param, @@ -895,21 +896,29 @@ fn command_button(app: &VectorcraftApp, ui: &mut egui::Ui, bar: &str, look: &Com (Some(t), Some(keys)) => format!("{} {keys}", t.name), (Some(t), None) => t.name.clone(), }; - let button = match &look.text { - Some(t) => Button::command(t.command.clone()).label(look.said()), - None => Button::new(look.said()).enabled(false), - }; - // The face paints the label; the accessible name stays `said`. - let button = if look.own.is_some() { button.painted(look.label().to_string()) } else { button }; - let response = button.tooltip(tip).show(ui).response; + let mut response = None; + // A menu owned by a dimmed button takes no clicks, so the row around the button owns the menu and a right + // click on the button opens it: Rename Button… and the rest work while the command is dimmed. + let row = Row::new() + .show(ui, |ui, _| { + let button = match &look.text { + Some(t) => Button::command(t.command.clone()).label(look.said()), + None => Button::new(look.said()).enabled(false), + }; + // The face paints the label; the accessible name stays `said`. + let button = if look.own.is_some() { button.painted(look.label().to_string()) } else { button }; + response = Some(button.tooltip(tip.clone()).show(ui).response); + }) + .output; if measuring { return; } + let Some(response) = response else { return }; let (i, n) = place; let moved = |at: usize| CommandRef::with_params("toolbar.addCommand", json!({ "command": look.id, "toolbar": bar, "at": at })); let removed = CommandRef::with_params("toolbar.removeCommand", json!({ "command": look.id, "toolbar": bar })); let renamed = CommandRef::with_params("toolbar.renameCommand", json!({ "command": look.id, "toolbar": bar })); - Menu::context(look.name().to_string(), &response).show(ui, |ui, _| { + Menu::context(look.name().to_string(), &row).opened_by(&response, Trigger::Context).show(ui, |ui, _| { MenuItem::command(moved(i.saturating_sub(1))).label(tl!("Move Up")).enabled(i > 0).show(ui); MenuItem::command(moved(i + 1)).label(tl!("Move Down")).enabled(i + 1 < n).show(ui); MenuItem::command(renamed.clone()).label(tl!("Rename Button…")).show(ui); From 85d7248548e51a90697d3f468e8927ba52c0af9a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 02:37:49 -0800 Subject: [PATCH 081/264] Window: Tab reads Standard Screen Mode's hidden chrome In Standard Screen Mode the shell records Tab's hide as the chrome hidden, not as everything hidden. The Tab command and the tool lookup read only the second, so a second Tab hid again instead of showing the panels. Both now use panel_docking::tab_hidden. --- crates/ui-egui/src/menus/run.rs | 2 +- crates/ui-egui/src/menus/tests.rs | 17 ++++++++++++++++- crates/ui-egui/src/palette.rs | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index d0020042ba..11975b7c24 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -738,7 +738,7 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option { - let hidden = craft::ui::shell::chrome_state(&ctx, egui::ViewportId::ROOT).hidden; + let hidden = crate::panel_docking::tab_hidden(app); request_chrome_toggle(&ctx, egui::ViewportId::ROOT, if hidden { ChromeToggle::ShowPanels } else { ChromeToggle::Panels }); Ok(json!(hidden)) } diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index adaa0b488c..120c80aadd 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -262,6 +262,21 @@ fn help_f1_opens_discover_without_a_document() { assert!(crate::panel_docking::showing(&app.ui, "discover")); } +/// In Standard Screen Mode Tab hides the panels, the toolbars and the Control bar, and the next Tab +/// shows them again. +#[test] +fn a_second_tab_shows_what_the_first_hid() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let ctx = crate::testing::ui_context(); + app.ui_ctx = Some(ctx.clone()); + assert_eq!(app.run("window.dock", json!({})).unwrap(), json!(false)); + app_frame(&mut app, &ctx, vec![]); + assert!(crate::panel_docking::tab_hidden(&app)); + assert_eq!(app.run("window.dock", json!({})).unwrap(), json!(true), "the second Tab shows what the first hid"); + app_frame(&mut app, &ctx, vec![]); + assert!(!crate::panel_docking::tab_hidden(&app)); +} + /// With the toolbars hidden by Tab, choosing a tool in Help, or a tool's link in a tutorial Help /// shows, marks nothing and the status bar says why. #[test] @@ -314,7 +329,7 @@ fn discover_says_why_a_tool_cannot_be_marked() { // Tab hides the toolbars in the shell's next pass. app.run("window.dock", json!({})).unwrap(); app_frame(&mut app, &ctx, vec![]); - assert!(craft::ui::shell::chrome_state(&ctx, egui::ViewportId::ROOT).hidden); + assert!(crate::panel_docking::tab_hidden(&app)); let reason = app.run("learn.locateTool", json!({"tool": "rectangle"})).unwrap()["reason"].as_str().unwrap().to_string(); let found = app.run("help.discover.search", json!({"query": "rectangle"})).unwrap(); diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 9079b40a5d..6deacc0c01 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -534,7 +534,7 @@ fn tool_home(app: &VectorcraftApp, tool: &str) -> String { None => name.to_string(), }; // Tab hides every toolbar with the panels, as the main window's shell left it. - let tab_hidden = app.ui_ctx.as_ref().is_some_and(|ctx| craft::ui::shell::chrome_state(ctx, egui::ViewportId::ROOT).hidden); + let tab_hidden = crate::panel_docking::tab_hidden(app); let toolbars_shown = app.ui.screen_mode < 3 && !tab_hidden; let main = crate::toolbar::slots(app).into_iter().map(|(_, s)| s).find(|s| s.contains(&tool)); // A group torn off into a strip shows each of its tools on its own button. From 5ce0ab2e0df833442d40c88ce9426a333e116f57 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 02:37:49 -0800 Subject: [PATCH 082/264] Tests: Save Options radio test measures the check box with its label The check box and the text of its label are two accessibility nodes with the same name. The test now takes the bounds of every node so named on the same line, so it measures the gap from the check box row and not from its label text. --- crates/ui-egui/src/dialogs/save_options/tests.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/save_options/tests.rs b/crates/ui-egui/src/dialogs/save_options/tests.rs index 8656fe3bf0..750e5b1130 100644 --- a/crates/ui-egui/src/dialogs/save_options/tests.rs +++ b/crates/ui-egui/src/dialogs/save_options/tests.rs @@ -532,14 +532,15 @@ fn labelled_controls(app: &mut VectorcraftApp) -> Vec<(String, egui::Rect)> { .collect() } -/// The bounds of the control labelled `label` in `controls`, with or without a final colon. +/// The bounds of the control labelled `label` in `controls`, with or without a final colon. A check box and the text of +/// its label are two nodes with the same name side by side, so the bounds take in every node so named on the first +/// one's line. fn control(controls: &[(String, egui::Rect)], label: &str) -> egui::Rect { let bare = |l: &str| l.trim_end_matches(':').to_string(); - controls - .iter() - .find(|(l, _)| bare(l) == bare(label)) - .map(|(_, r)| *r) - .unwrap_or_else(|| panic!("no control labelled {label:?} in {:?}", controls.iter().map(|(l, _)| l).collect::>())) + let named: Vec = controls.iter().filter(|(l, _)| bare(l) == bare(label)).map(|(_, r)| *r).collect(); + let first = + *named.first().unwrap_or_else(|| panic!("no control labelled {label:?} in {:?}", controls.iter().map(|(l, _)| l).collect::>())); + named.iter().filter(|r| r.top() < first.bottom() && first.top() < r.bottom()).fold(first, |all, r| all.union(*r)) } /// The All and Range radios stand right under the artboard check box, and EPS's Transparent and Opaque radios right From 951e552a76601257d9f457f893a1bcdea95d5d1f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 02:43:57 -0800 Subject: [PATCH 083/264] Symbols: Symbol Options and Replace Symbol that change nothing add no undo step symbol.options recorded an undo step and moved the revision whenever any option was passed, unless only alignToPixelGrid was given with the value the symbol already had. A newName equal to the current name, or a registration, export type, 9-slice, type or pixel grid value the symbol already has, now leaves the document and its undo history as they are. symbol.replace with the symbol the instances already show recorded an undo step too. It now records one only when an instance changes. Both run through colorcmds::edit_if_changed, as the Symbol Shifter and the other symbolism tools do. --- crates/engine/src/cmd/brushsym.rs | 4 +- crates/engine/src/cmd/brushsym/symbols.rs | 19 ++++---- crates/engine/src/tests/brushsym.rs | 55 +++++++++++++++++++++++ docs/mcp.md | 7 +-- 4 files changed, 69 insertions(+), 16 deletions(-) diff --git a/crates/engine/src/cmd/brushsym.rs b/crates/engine/src/cmd/brushsym.rs index 3828d67d0c..bd6cb220e5 100644 --- a/crates/engine/src/cmd/brushsym.rs +++ b/crates/engine/src/cmd/brushsym.rs @@ -225,7 +225,7 @@ pub fn specs() -> Vec { "Symbol Options…", [], None, - "{name?, newName?, registration?: 0..8, exportType?: movieClip|graphic, nineSlice?: bool, nineSliceGuides?: array, type?: static|dynamic, alignToPixelGrid?: bool} rename a symbol (its instances and the graphics and Map Art maps on 3D objects follow the new name) and/or set Symbol Options › Registration, Export Type, 9-slice guides (nineSliceGuides [left, top, right, bottom] fractions in from each edge, each -16..16, with left + right < 1 and top + bottom < 1), Symbol Type (a dynamic symbol's instances may change the appearance of objects in its art and stay linked; making it static drops those changes) and Align to Pixel Grid (on: the horizontal and vertical straight segments of the paths in the symbol's art snap to whole points, or half points for an odd centered stroke, at the symbol's natural size, its stroke weights become whole points, and every instance placed at that size, reflected across one axis or not, moves to whole points and goes back to them after each move; a scaled, rotated (a half turn included) or sheared instance, and an instance in another symbol's art, is left where it is; the art snaps again after it is edited); alignToPixelGrid alone with the value the symbol already has changes nothing and adds no undo step; default name: current → {name, registration, exportType, nineSlice, type, alignToPixelGrid}", + "{name?, newName?, registration?: 0..8, exportType?: movieClip|graphic, nineSlice?: bool, nineSliceGuides?: array, type?: static|dynamic, alignToPixelGrid?: bool} rename a symbol (its instances and the graphics and Map Art maps on 3D objects follow the new name) and/or set Symbol Options › Registration, Export Type, 9-slice guides (nineSliceGuides [left, top, right, bottom] fractions in from each edge, each -16..16, with left + right < 1 and top + bottom < 1), Symbol Type (a dynamic symbol's instances may change the appearance of objects in its art and stay linked; making it static drops those changes) and Align to Pixel Grid (on: the horizontal and vertical straight segments of the paths in the symbol's art snap to whole points, or half points for an odd centered stroke, at the symbol's natural size, its stroke weights become whole points, and every instance placed at that size, reflected across one axis or not, moves to whole points and goes back to them after each move; a scaled, rotated (a half turn included) or sheared instance, and an instance in another symbol's art, is left where it is; the art snaps again after it is edited); values the symbol already has, newName included, change nothing and add no undo step; default name: current → {name, registration, exportType, nineSlice, type, alignToPixelGrid}", has_doc, symbol_options ), @@ -289,7 +289,7 @@ pub fn specs() -> Vec { "Replace Symbol", [], None, - "{name, ids?|id?} swap the symbol of the selected instances (an instance given a different symbol drops its appearance changes; one given its own symbol keeps them) → {ids}", + "{name, ids?|id?} swap the symbol of the selected instances (an instance given a different symbol drops its appearance changes; one given its own symbol keeps them; when every instance already shows the symbol, nothing changes and no undo step is recorded) → {ids}", has_selection, symbol_replace ), diff --git a/crates/engine/src/cmd/brushsym/symbols.rs b/crates/engine/src/cmd/brushsym/symbols.rs index ac85e71de4..9e39d49d9e 100644 --- a/crates/engine/src/cmd/brushsym/symbols.rs +++ b/crates/engine/src/cmd/brushsym/symbols.rs @@ -347,13 +347,8 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result { let dynamic = type_param(p, C)?; let pixel = pixel_grid_param(p, C)?; let new_name = str_param(p, "newName").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string); - if new_name.is_none() && export.is_none() && reg.is_none() && nine.is_none() && dynamic.is_none() { - match pixel { - None => return Err(bad(C, "pass newName, registration, exportType, nineSlice, type and/or alignToPixelGrid")), - // Align to Pixel Grid alone, already as asked: nothing changes and no undo step is added. - Some(on) if on == s.doc()?.doc.symbol_pixel_aligned(&name) => return Ok(options_json(&s.doc()?.doc, &name)), - Some(_) => {} - } + if new_name.is_none() && export.is_none() && reg.is_none() && nine.is_none() && dynamic.is_none() && pixel.is_none() { + return Err(bad(C, "pass newName, registration, exportType, nineSlice, type and/or alignToPixelGrid")); } if let Some(ref n) = new_name && n != &name @@ -362,7 +357,8 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result { return Err(bad(C, format!("a symbol named `{n}` already exists"))); } let final_name = new_name.clone().unwrap_or_else(|| name.clone()); - s.edit("Symbol Options", |d, _| { + // Values the symbol already has leave the document as it is, and no undo step is added. + crate::cmd::colorcmds::edit_if_changed(s, "Symbol Options", |before, d| { if let Some(ref n) = new_name && n != &name { @@ -439,7 +435,7 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result { if let Some(on) = pixel { d.set_symbol_pixel_aligned(&final_name, on); } - Ok(()) + Ok(((), before != &*d)) })?; Ok(options_json(&s.doc()?.doc, &final_name)) } @@ -859,7 +855,8 @@ pub(super) fn symbol_replace(s: &mut Session, p: &Value) -> Result { if ids.is_empty() { return Err(EngineError::Other("no symbol instances selected".into())); } - s.edit("Replace Symbol", |d, _| { + // Instances that already show the symbol leave the document as it is, and no undo step is added. + crate::cmd::colorcmds::edit_if_changed(s, "Replace Symbol", |before, d| { let new = natural_size(d, &name); for id in &ids { let (old, other) = match d.node(*id).map(|n| &n.kind) { @@ -877,7 +874,7 @@ pub(super) fn symbol_replace(s: &mut Session, p: &Value) -> Result { } } fit_overrides(d, &ids); - Ok(()) + Ok(((), ids.iter().any(|id| before.node(*id) != d.node(*id)))) })?; Ok(json!({ "ids": ids_json(&ids) })) } diff --git a/crates/engine/src/tests/brushsym.rs b/crates/engine/src/tests/brushsym.rs index 032e3ddb8c..03eb4ec5e8 100644 --- a/crates/engine/src/tests/brushsym.rs +++ b/crates/engine/src/tests/brushsym.rs @@ -3048,6 +3048,61 @@ fn symbol_export_type_defaults_to_movie_clip_and_round_trips() { assert!(s.execute("symbol.options", &json!({"name": "Renamed"})).is_err()); } +/// `symbol.options` whose values are the ones the symbol already has changes neither the document +/// nor its revision, and records no undo step. +#[test] +fn symbol_options_that_change_nothing_record_no_undo_step() { + let mut s = session(); + make_symbol(&mut s); + let state = |s: &Session| { + let st = s.doc().unwrap(); + (st.doc.clone(), st.revision, st.history.undo.len()) + }; + let unchanged = [ + json!({"name": "Box", "newName": "Box"}), + json!({"name": "Box", "newName": " Box "}), + json!({"name": "Box", "registration": 4}), + json!({"name": "Box", "exportType": "movieClip"}), + json!({"name": "Box", "nineSlice": false}), + json!({"name": "Box", "type": "static"}), + json!({"name": "Box", "alignToPixelGrid": false}), + json!({"name": "Box", "newName": "Box", "registration": 4, "exportType": "movieClip", "type": "static", "alignToPixelGrid": false}), + ]; + let before = state(&s); + for p in &unchanged { + assert_eq!(s.execute("symbol.options", p).unwrap()["name"], "Box"); + assert_eq!(state(&s), before, "{p} changes nothing"); + } + s.execute("symbol.options", &json!({"name": "Box", "registration": 0, "exportType": "graphic", "type": "dynamic"})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1, "changed options are one undo step"); + let before = state(&s); + let r = s.execute("symbol.options", &json!({"name": "Box", "registration": 0, "exportType": "graphic", "type": "dynamic"})).unwrap(); + assert_eq!((r["registration"].clone(), r["exportType"].clone(), r["type"].clone()), (json!(0), json!("graphic"), json!("dynamic"))); + assert_eq!(state(&s), before, "setting the options again changes nothing"); + s.execute("symbol.options", &json!({"name": "Box", "newName": "Logo"})).unwrap(); + assert_eq!(undo_steps(&s), before.2 + 1, "a rename is one undo step"); +} + +/// `symbol.replace` with the symbol the instances already show changes neither the document nor +/// its revision, and records no undo step. +#[test] +fn symbol_replace_with_the_same_symbol_records_no_undo_step() { + let mut s = session(); + let (inst, _, _) = make_symbol(&mut s); + rect(&mut s, 0.0, 0.0, 20.0, 20.0); + s.execute("symbol.new", &json!({"name": "Small"})).unwrap(); + let state = |s: &Session| { + let st = s.doc().unwrap(); + (st.doc.clone(), st.revision, st.history.undo.len()) + }; + let before = state(&s); + assert_eq!(s.execute("symbol.replace", &json!({"name": "Box", "ids": [inst.0]})).unwrap()["ids"], json!([inst.0])); + assert_eq!(state(&s), before, "replacing an instance with its own symbol changes nothing"); + s.execute("symbol.replace", &json!({"name": "Small", "ids": [inst.0]})).unwrap(); + assert!(matches!(&node(&s, inst).kind, NodeKind::SymbolInstance { symbol, .. } if symbol == "Small")); + assert_eq!(undo_steps(&s), before.2 + 1, "replacing it with another symbol is one undo step"); +} + #[test] fn sprayer_command_creates_a_symbol_set_and_alt_removes() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..4e8d51da8b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4968,8 +4968,8 @@ already walks Image Trace. Short agent entry points: placed at that size, reflected across one axis or not, moves to whole points and goes back to them after every move; VectorCraft leaves a scaled, rotated (a half turn included) or sheared instance, and an instance in another symbol's art, where it is, snaps the art again after it is edited, and does not count - instances in `select.object.notAlignedToPixelGrid`; `alignToPixelGrid` alone with the value the symbol already has - adds no undo step), + instances in `select.object.notAlignedToPixelGrid`; values the symbol already has, `newName` included, do not change + the document or its revision and add no undo step), `symbol.place {name?, x?, y?}` (on top of the current layer; in Draw Behind directly below the bottommost selected object, beside the compound path that holds it, or at the bottom of the current layer with nothing selected, above a clipping path; `symbol.placeFromDocument` and `symbol.addFromLibrary` with `place` stack the instance the same @@ -4979,7 +4979,8 @@ already walks Image Trace. Short agent entry points: undo step, and a symbol with the same name but other art or Symbol Options is added under a free name; an error when that document is no longer open; plug-ins cannot call it), `symbol.breakLink {ids?}` (the art keeps the instance's opacity mask and its bounding box, square after `object.resetBoundingBox`; a hidden or locked instance's - art stays hidden or locked and is not selected), `symbol.replace`, + art stays hidden or locked and is not selected), `symbol.replace` (instances that already show the symbol do not + change the document or its revision, and add no undo step), `symbol.update {name, ids?|id?, keepArt?: false}` (Redefine Symbol: the selection, or `ids`, becomes the symbol's art and an instance of it in one undo step; with `keepArt: true` the art stays ordinary art in its place, with its ids, and stays selected unless it is hidden or locked, and the result's `id` is null; a `keepArt` other than true or false is an error; art that holds an instance of the symbol (opacity masks included), directly or through the art From 4f2bb0d1778bfd22746a5055d95252cba27c11c7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 03:09:24 -0800 Subject: [PATCH 084/264] Arrange Tools: Match Objects gives the others the key object's size, angle and stacking place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Object › Plug-ins › Arrange Tools › Match Objects… (addon.arrange.match) makes the other selected objects match one source object: the key object, or the top or the bottom selected object. Each can take the source's width (height in proportion), height (width in proportion) or both, its bounding-box angle, and its stacking place directly above it in its layer or group, about a reference point, as one undo step. No step is recorded when nothing changes, and invalid params are refused. The dialog previews on the canvas; OK stays off while nothing is chosen or the source is a missing key object. Docs: docs/mcp.md, docs/target-app-parity.md, docs/ui-parity.md, ROADMAP. --- ROADMAP.md | 1 + crates/engine/src/cmd/addons/arrange.rs | 112 ++++++++++- crates/engine/src/cmd/addons/arrange/tests.rs | 181 ++++++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/tests/command_sweep.rs | 4 + crates/ui-egui/src/addons/arrange.rs | 43 ++++- crates/ui-egui/src/addons/arrange/tests.rs | 53 +++++ docs/mcp.md | 5 + docs/target-app-parity.md | 4 + docs/ui-parity.md | 1 + 10 files changed, 402 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index d40c33e9e1..fbd5c54036 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -163,6 +163,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-01: Expand Dashes into Paths joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): each selected path's dashed stroke becomes separate open paths, one per dash, laid out exactly as the stroke draws them (pattern, offset, Align Dashes to Corners and Path Ends), each keeping the stroke with the dashes off, so the gaps are real gaps for cutters and plotters, as one undo step (`addon.pathtools.expandDashes`, #4922). - 2026-11-01: Randomize Opacity joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): each selected object gets its own opacity at random between a minimum and a maximum percent, with a seed that repeats the result, as one undo step (`addon.arrange.randomizeOpacity`, #4925). - 2026-11-01: Sort Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are sorted by width, height, area, position, opacity or stacking order (small to large, large to small or at random) and take another of those in that order, trading their values or stepping them evenly, as one undo step (`addon.arrange.sort`, #4917). +- 2026-11-29: Match Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the other selected objects take the width, the height or both, the bounding-box angle and the stacking place of the key object, or of the top or the bottom selected object, about a reference point, with Preview, as one undo step (`addon.arrange.match`). A VectorCraft addition: headline numbers unchanged. - 2026-11-15: Tangent Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the circles that touch two selected paths or compound paths at a set radius, or three of them (up to eight for three circles), touching each outline without crossing it; circles, rotated ellipses and other paths alike. A dialog that previews every circle or one picked by number, the current paint, one undo step (`addon.pathtools.tangentCircle`). A VectorCraft addition: headline numbers unchanged. - 2026-11-17: Add Bounding Rectangle and Add Bounding Circle join the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): a live rectangle on the selection's geometric bounding box, or the smallest live circle that holds its outlines, around the whole selection or around each object, with the current paint and one undo step; the menu items open a dialog with Offset, One per Object and Preview (`addon.pathtools.boundingRectangle`, `addon.pathtools.boundingCircle`, #6966). A VectorCraft addition: headline numbers unchanged. - 2026-11-22: Add Inscribed Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the largest live circle inside each selected closed path or compound path, in the area it fills under its fill rule, with the current paint and one undo step (`addon.pathtools.inscribedCircle`, #6966). A VectorCraft addition: headline numbers unchanged. diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index f81d7a599a..1588ec1162 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -2,7 +2,8 @@ //! out in rows and columns, a row or a column; Swap Objects swaps the places (and sizes) of two; //! Replace with Top Object puts a copy of the topmost selected object in place of each of the //! others; and Set Size of Each gives every selected object an exact width and height. Places and -//! sizes are measured and set as `object.setBounds` does. Group Overlapping Objects groups the +//! sizes are measured and set as `object.setBounds` does. Match Objects gives the other selected +//! objects the size, bounding-box angle and stacking place of one of them. Group Overlapping Objects groups the //! objects whose visual bounds overlap, Randomize Opacity gives each selected object a random //! opacity, and Sort Objects sorts the selected objects by one attribute and gives them another in //! that order. Its submenu (Object › Plug-ins › Arrange Tools), its dialogs and Zoom to Selection @@ -79,6 +80,15 @@ pub fn specs() -> Vec { has_selection, size ), + cmd!( + "addon.arrange.match", + "Match Objects", + ["Object", "Plug-ins", "Arrange Tools"], + None, + "{source?: \"key\" (the key object, select.key) | \"top\" (the frontmost selected object) | \"bottom\" (the backmost) (default: the key object when the selection has one, else \"top\"), size?: \"none\" | \"width\" (each target takes the source's width, its height following in proportion) | \"height\" (the source's height, the width following in proportion) | \"both\" (the source's width and height, each on its own) (\"none\"), rotate?: false (true: each target takes the source's bounding-box angle), stacking?: false (true: the targets go directly above the source in the stacking order, in its layer or group, in the order they had), reference?: 0..8 (the 9-point grid row by row from the top-left; 4, the center: the point of each target that stays put as it is sized and turned), scaleStrokes?: the Scale Strokes & Effects preference, patterns?: the Transform Pattern Tiles preference (at least one of size, rotate and stacking)} make the other selected objects (the top-level ones, at most 20000) match the source, which stays as it is, as one undo step (none when nothing changes). Sizes are measured and set as object.setBounds measures them (Use Preview Bounds), each in the object's own bounding-box frame; to match places, use object.align {to: \"key\"} → {source, count}", + has_multi, + match_objects + ), cmd!( "addon.arrange.groupOverlapping", "Group Overlapping Objects", @@ -313,6 +323,106 @@ fn size(s: &mut Session, p: &Value) -> Result { Ok(json!({ "count": xfs.len() })) } +/// The source Match Objects matches `roots` (the selected roots, in stacking order) to, from its +/// `source` param: the selected root that is the key object or holds it, the frontmost or the backmost. +fn match_source(s: &Session, p: &Value, roots: &[NodeId], cmd: &str) -> Result { + let st = s.doc()?; + let key = st.selection.key.and_then(|k| st.doc.ancestry(k)).and_then(|up| roots.iter().copied().find(|id| up.contains(id))); + let picked = match choice(p, cmd, "source", &["key", "top", "bottom"])? { + Some("key") => Some(key.ok_or_else(|| bad(cmd, "no key object: set one with select.key"))?), + Some("bottom") => roots.first().copied(), + Some(_) => roots.last().copied(), + None => key.or_else(|| roots.last().copied()), + }; + picked.ok_or_else(|| bad(cmd, "select at least two objects")) +} + +/// Whether `targets` (in stacking order) are directly above `source` in its layer or group, in that order. +fn stacked_above(d: &vectorcraft_doc::Document, source: NodeId, targets: &[NodeId]) -> bool { + let paths = d.index_paths(targets.iter().copied().chain([source])); + let Some((&at, up)) = paths.get(&source).and_then(|p| p.split_last()) else { return false }; + targets.iter().enumerate().all(|(i, id)| paths.get(id).and_then(|p| p.split_last()) == Some((&(at + 1 + i), up))) +} + +fn match_objects(s: &mut Session, p: &Value) -> Result { + const C: &str = "addon.arrange.match"; + let size = choice(p, C, "size", &["none", "width", "height", "both"])?.unwrap_or("none"); + let rotate = switch_or(p, "rotate", false, C)?; + let stacking = switch_or(p, "stacking", false, C)?; + let reference = whole_in(p, "reference", (0, 8), C)?.unwrap_or(4); + let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let patterns = switch_or(p, "patterns", s.prefs.transform_pattern_tiles, C)?; + if size == "none" && !rotate && !stacking { + return Err(bad(C, "give `size`, `rotate` or `stacking`")); + } + let roots = selected_roots(s)?; + if roots.len() > MAX_OBJECTS { + return Err(bad(C, "too many objects selected (at most 20000)")); + } + let source = match_source(s, p, &roots, C)?; + let targets: Vec = roots.iter().copied().filter(|id| *id != source).collect(); + if targets.is_empty() { + return Err(bad(C, "select at least two objects")); + } + let sb = box_of(s, source)?; + let (w, h) = (sb.rect.width(), sb.rect.height()); + let wanted = match size { + "width" if w < LEAST => return Err(bad(C, "the source object has no width")), + "height" if h < LEAST => return Err(bad(C, "the source object has no height")), + "both" if w < LEAST || h < LEAST => return Err(bad(C, "the source object has no width or no height")), + "width" => Some(json!({ "width": w, "proportional": true })), + "height" => Some(json!({ "height": h, "proportional": true })), + "both" => Some(json!({ "width": w, "height": h })), + _ => None, + }; + let angle = s.doc()?.doc.bbox_angle(&[source]); + let mut xfs = Vec::with_capacity(targets.len()); + for &id in &targets { + let Some(b) = s.transform_box(&[id]) else { continue }; + let mut xf = Affine::IDENTITY; + if let Some(q) = &wanted { + let mut q = q.clone(); + q["reference"] = json!(reference); + q["strokes"] = json!(strokes); + xf = object_bounds_transform(s, &q, id)?; + } + if rotate { + // Turned about the reference point, which the sizing keeps in place; angles are + // counter-clockwise and y is down. + let turn = vectorcraft_geom::normalize_deg(angle - s.doc()?.doc.bbox_angle(&[id])); + if turn.abs() > 1e-9 { + let at = b.to_doc() * vectorcraft_geom::reference_point(b.rect, reference as usize); + xf = Affine::rotate_about(-turn.to_radians(), at) * xf; + } + } + xfs.push((id, xf)); + } + let still = |xf: &Affine| xf.as_coeffs().iter().zip(Affine::IDENTITY.as_coeffs()).all(|(a, b)| (a - b).abs() <= 1e-9); + xfs.retain(|(_, xf)| !still(xf)); + let restack = stacking && !stacked_above(&s.doc()?.doc, source, &targets); + let count = json!({ "source": source.0, "count": targets.len() }); + if xfs.is_empty() && !restack { + return Ok(count); + } + let q = json!({ "strokes": strokes, "patterns": patterns }); + let ids: Vec = xfs.iter().map(|(id, _)| *id).collect(); + let mut sc = scaling(s, &q); + sc.patterns = transform_patterns(s, &q, &ids)?; + s.edit("Match Objects", |d, _| { + for (id, xf) in &xfs { + if let Some(n) = d.node_mut(*id) { + transform_node(n, *xf, sc, true); + } + } + if restack { + let moved = d.remove_many(&targets)?; + d.insert_beside(vec![(source, moved.into_iter().map(Arc::unwrap_or_clone).collect())], false)?; + } + Ok(()) + })?; + Ok(count) +} + /// The sets of two or more of `items` (each in the order given) whose rects overlap or touch, /// chains included, among items of the same key (parent). A sweep along x: only the rects still /// open where each one starts are compared with it. diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 759f6f321e..7cf91abfb7 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -215,6 +215,186 @@ fn size_gives_each_object_a_width_and_height() { assert!(near(bounds(&s, a), (30.0, 8.0, 10.0, 12.0)), "both given: both set, {:?}", bounds(&s, a)); } +/// Three rectangles from the back, all selected: `a` 20 × 10 at the origin, `b` 40 × 40 at +/// (100, 100) and `c` 10 × 30 at (200, 0). +fn three(s: &mut Session) -> (NodeId, NodeId, NodeId) { + let a = rect(s, 0.0, 0.0, 20.0, 10.0); + let b = rect(s, 100.0, 100.0, 40.0, 40.0); + let c = rect(s, 200.0, 0.0, 10.0, 30.0); + select(s, &[a, b, c]); + (a, b, c) +} + +#[test] +fn match_gives_the_others_the_key_objects_size() { + let mut s = session(); + let (a, b, c) = three(&mut s); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + let n = steps(&s); + let r = s.execute("addon.arrange.match", &json!({"size": "both"})).unwrap(); + assert_eq!(r, json!({"source": b.0, "count": 2})); + assert_eq!(steps(&s), n + 1, "one undo step"); + // About each center; the key object stays. + assert!(near(bounds(&s, a), (-10.0, -15.0, 40.0, 40.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, c), (185.0, -5.0, 40.0, 40.0)), "{:?}", bounds(&s, c)); + assert!(near(bounds(&s, b), (100.0, 100.0, 40.0, 40.0)), "{:?}", bounds(&s, b)); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(near(bounds(&s, a), (0.0, 0.0, 20.0, 10.0))); + // The width, with the height in proportion, about the top-left corner. + s.execute("addon.arrange.match", &json!({"size": "width", "reference": 0})).unwrap(); + assert!(near(bounds(&s, a), (0.0, 0.0, 40.0, 20.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, c), (200.0, 0.0, 40.0, 120.0)), "{:?}", bounds(&s, c)); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("addon.arrange.match", &json!({"size": "height", "reference": 8})).unwrap(); + assert!(near(bounds(&s, a), (-60.0, -30.0, 80.0, 40.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, c), (196.6666666666667, -10.0, 13.333333333333334, 40.0)), "{:?}", bounds(&s, c)); +} + +#[test] +fn match_takes_the_top_or_the_bottom_object_without_a_key() { + let mut s = session(); + let (a, b, c) = three(&mut s); + // No key object: the frontmost, c. + let r = s.execute("addon.arrange.match", &json!({"size": "both"})).unwrap(); + assert_eq!(r["source"], json!(c.0)); + assert!(near(bounds(&s, a), (5.0, -10.0, 10.0, 30.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, b), (115.0, 105.0, 10.0, 30.0)), "{:?}", bounds(&s, b)); + s.execute("edit.undo", &json!({})).unwrap(); + let r = s.execute("addon.arrange.match", &json!({"source": "bottom", "size": "both"})).unwrap(); + assert_eq!(r["source"], json!(a.0)); + assert!(near(bounds(&s, b), (110.0, 115.0, 20.0, 10.0)), "{:?}", bounds(&s, b)); + assert!(near(bounds(&s, c), (195.0, 10.0, 20.0, 10.0)), "{:?}", bounds(&s, c)); + s.execute("edit.undo", &json!({})).unwrap(); + // "top" names the frontmost even while a key object is set. + s.execute("select.key", &json!({"id": a.0})).unwrap(); + let r = s.execute("addon.arrange.match", &json!({"source": "top", "size": "both"})).unwrap(); + assert_eq!(r["source"], json!(c.0)); +} + +#[test] +fn match_turns_the_others_to_the_sources_angle() { + let mut s = session(); + let (a, b, c) = three(&mut s); + select(&mut s, &[b]); + s.execute("object.rotate", &json!({"angle": 30})).unwrap(); + select(&mut s, &[a, b, c]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + let n = steps(&s); + s.execute("addon.arrange.match", &json!({"rotate": true, "size": "both"})).unwrap(); + assert_eq!(steps(&s), n + 1, "one undo step"); + for (id, center) in [(a, (10.0, 5.0)), (c, (205.0, 15.0))] { + let o = s.transform_box(&[id]).unwrap(); + assert!((o.angle - 30.0).abs() < 1e-6, "{id:?} turned to {}", o.angle); + assert!((o.rect.width() - 40.0).abs() < 1e-6 && (o.rect.height() - 40.0).abs() < 1e-6, "{id:?} sized {:?}", o.rect); + let at = o.center(); + assert!((at.x - center.0).abs() < 1e-6 && (at.y - center.1).abs() < 1e-6, "{id:?} turned about its center: {at:?}"); + } + // Turned back to the angle of an unturned source. + let d = rect(&mut s, 300.0, 0.0, 10.0, 10.0); + select(&mut s, &[a, d]); + s.execute("addon.arrange.match", &json!({"rotate": true, "source": "top"})).unwrap(); + assert!(s.transform_box(&[a]).unwrap().angle.abs() < 1e-6); +} + +#[test] +fn match_puts_the_others_directly_above_the_source() { + let mut s = session(); + let (a, b, c) = three(&mut s); + let d = rect(&mut s, 300.0, 0.0, 10.0, 10.0); + select(&mut s, &[d, a, c]); + s.execute("select.key", &json!({"id": a.0})).unwrap(); + let n = steps(&s); + s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap(); + assert_eq!(steps(&s), n + 1, "one undo step"); + assert_eq!(layer_order(&s), [a, c, d, b], "in the order they had, above the key object"); + assert!(near(bounds(&s, c), (200.0, 0.0, 10.0, 30.0)), "nothing else changes"); + s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap(); + assert_eq!(steps(&s), n + 1, "already above it: no step"); + // An object in another layer goes into the source's. + s.execute("layer.new", &json!({})).unwrap(); + let e = rect(&mut s, 0.0, 200.0, 10.0, 10.0); + select(&mut s, &[b, e]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap(); + assert_eq!(layer_order(&s), [a, c, d, b, e]); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(layer_order(&s), [a, c, d, b]); +} + +#[test] +fn match_makes_no_step_when_everything_matches() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 10.0); + let b = rect(&mut s, 100.0, 100.0, 20.0, 10.0); + select(&mut s, &[a, b]); + let n = steps(&s); + let r = s.execute("addon.arrange.match", &json!({"size": "both", "rotate": true})).unwrap(); + assert_eq!(r["count"], json!(1)); + assert_eq!(steps(&s), n, "the same size and angle: no step"); +} + +#[test] +fn match_turns_the_others_about_their_reference_point() { + let mut s = session(); + let (a, b, c) = three(&mut s); + select(&mut s, &[b]); + s.execute("object.rotate", &json!({"angle": 30})).unwrap(); + select(&mut s, &[a, b, c]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + s.execute("addon.arrange.match", &json!({"rotate": true, "reference": 0})).unwrap(); + // Each top-left corner stays where it was. + for (id, corner) in [(a, (0.0, 0.0)), (c, (200.0, 0.0))] { + let o = s.transform_box(&[id]).unwrap(); + assert!((o.angle - 30.0).abs() < 1e-6, "{id:?} turned to {}", o.angle); + let at = o.to_doc() * vectorcraft_geom::reference_point(o.rect, 0); + assert!((at.x - corner.0).abs() < 1e-6 && (at.y - corner.1).abs() < 1e-6, "{id:?} turned about its top-left corner: {at:?}"); + } +} + +#[test] +fn match_scales_strokes_as_asked() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let b = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap(); + s.execute("stroke.set", &json!({"weight": 2})).unwrap(); + let weight = |s: &Session, id| s.doc().unwrap().doc.node(id).unwrap().appearance.stroke_width(); + s.execute("addon.arrange.match", &json!({"size": "both"})).unwrap(); + assert_eq!(weight(&s, a), 2.0, "off by default (the preference)"); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("addon.arrange.match", &json!({"size": "both", "scaleStrokes": true})).unwrap(); + assert!((weight(&s, a) - 4.0).abs() < 1e-9, "{}", weight(&s, a)); + assert!(near(bounds(&s, a), (-5.0, -5.0, 20.0, 20.0)), "{:?}", bounds(&s, a)); +} + +#[test] +fn match_refuses_bad_params() { + let mut s = session(); + let (a, _, _) = three(&mut s); + refuses( + &mut s, + "addon.arrange.match", + &[ + json!({}), + json!({"size": "none"}), + json!({"size": "area"}), + json!({"size": 1}), + json!({"rotate": 1}), + json!({"stacking": "yes"}), + json!({"size": "both", "reference": 9}), + json!({"size": "both", "reference": 1.5}), + json!({"size": "both", "source": "left"}), + json!({"size": "both", "scaleStrokes": "no"}), + json!({"size": "both", "patterns": 0}), + ], + ); + let e = s.execute("addon.arrange.match", &json!({"source": "key", "rotate": true})).unwrap_err().to_string(); + assert!(e.contains("no key object"), "{e}"); + select(&mut s, &[a]); + assert!(!enabled(&s, "addon.arrange.match"), "one object selected"); +} + #[test] fn bad_params_are_refused() { let mut s = session(); @@ -261,6 +441,7 @@ fn off_without_a_selection() { "addon.arrange.swap", "addon.arrange.replace", "addon.arrange.size", + "addon.arrange.match", "addon.arrange.groupOverlapping", "addon.arrange.randomizeOpacity", "addon.arrange.sort", diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index c2699f219c..4cf43ae92c 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -6,6 +6,7 @@ pub(super) const ALLOWED: &[&str] = &[ "addon.arrange.grid", "addon.arrange.groupOverlapping", + "addon.arrange.match", "addon.arrange.randomizeOpacity", "addon.arrange.replace", "addon.arrange.size", diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 462641b953..93a444a1d9 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -1000,6 +1000,10 @@ fn structured_junk() { ("addon.arrange.replace", json!({"fit": "bounds", "scaleStrokes": true})), ("addon.arrange.size", json!({"width": 1e6, "height": 0.001, "reference": 8, "scaleStrokes": true})), ("addon.arrange.size", json!({"width": 0.001, "proportional": true, "reference": u64::MAX})), + ("addon.arrange.match", json!({"size": "both", "rotate": true, "stacking": true, "reference": 8, "scaleStrokes": true})), + ("addon.arrange.match", json!({"source": "bottom", "size": "width", "patterns": true})), + ("addon.arrange.match", json!({"source": "key", "rotate": true})), + ("addon.arrange.match", json!({"source": "nope", "size": 3, "rotate": "x", "reference": u64::MAX})), ("addon.arrange.groupOverlapping", json!({"ids": "x", "junk": f64::MAX})), ("addon.arrange.randomizeOpacity", json!({"min": 0, "max": 100, "seed": u64::MAX})), ("addon.arrange.randomizeOpacity", json!({"min": f64::MAX, "max": -1e308, "seed": -1, "ids": [u64::MAX]})), diff --git a/crates/ui-egui/src/addons/arrange.rs b/crates/ui-egui/src/addons/arrange.rs index a26f5f7a28..6ef3c8e3c1 100644 --- a/crates/ui-egui/src/addons/arrange.rs +++ b/crates/ui-egui/src/addons/arrange.rs @@ -1,5 +1,5 @@ //! Arrange Tools in the interface: its submenu (Object › Plug-ins › Arrange Tools); the dialogs of -//! Arrange in Grid, Replace with Top Object, Set Size of Each, Randomize Opacity and Sort Objects, +//! Arrange in Grid, Replace with Top Object, Set Size of Each, Match Objects, Randomize Opacity and Sort Objects, //! which preview on the canvas and run their `addon.arrange.*` command on OK; Group Overlapping //! Objects; and Zoom to Selection ([`ZOOM`]), which fits the active view to the selection. @@ -24,13 +24,15 @@ pub const ZOOM: &str = "addon.arrange.zoomSelection"; const GRID: &str = "addon.arrange.grid"; const REPLACE: &str = "addon.arrange.replace"; const SIZE: &str = "addon.arrange.size"; +const MATCH: &str = "addon.arrange.match"; const OPACITY: &str = "addon.arrange.randomizeOpacity"; const SORT: &str = "addon.arrange.sort"; /// Each dialog's command and heading. -const DIALOGS: [(&str, &str); 5] = [ +const DIALOGS: [(&str, &str); 6] = [ (GRID, "Arrange in Grid"), (REPLACE, "Replace with Top Object"), (SIZE, "Set Size of Each"), + (MATCH, "Match Objects"), (OPACITY, "Randomize Opacity"), (SORT, "Sort Objects"), ]; @@ -60,6 +62,7 @@ pub fn menu() -> Vec { cp("Swap Objects and Sizes", "addon.arrange.swap", json!({ "size": true })), c("Replace with Top Object…", REPLACE), c("Set Size of Each…", SIZE), + c("Match Objects…", MATCH), cp("Group Overlapping Objects", "addon.arrange.groupOverlapping", json!({})), c("Randomize Opacity…", OPACITY), c("Sort Objects…", SORT), @@ -71,6 +74,7 @@ pub fn menu() -> Vec { static GRID_SPEC: Spec = Spec { command: GRID, params: grid_params, found: None }; static REPLACE_SPEC: Spec = Spec { command: REPLACE, params: replace_params, found: None }; static SIZE_SPEC: Spec = Spec { command: SIZE, params: size_params, found: None }; +static MATCH_SPEC: Spec = Spec { command: MATCH, params: match_params, found: None }; static OPACITY_SPEC: Spec = Spec { command: OPACITY, params: opacity_params, found: None }; static SORT_SPEC: Spec = Spec { command: SORT, params: sort_params, found: None }; @@ -134,6 +138,20 @@ fn size_rows(lengths: LengthUnits) -> Vec { ] } +fn match_rows() -> Vec { + let sources = [("key", "Key Object"), ("top", "Top Object"), ("bottom", "Bottom Object")]; + let sizes = [("none", "None"), ("width", "Width"), ("height", "Height"), ("both", "Width and Height")]; + vec![ + choice("source", "Match To:", &sources, "key"), + choice("size", "Size:", &sizes, "both"), + check("rotate", "Rotation", false), + check("stacking", "Stacking Order", false), + reference_param("reference", tl!("Reference Point")), + scale_strokes().enabled_when_in("size", ["width", "height", "both"]), + check("patterns", "Transform Patterns", false), + ] +} + fn opacity_rows() -> Vec { vec![percent("min", "Minimum:", 30.0), percent("max", "Maximum:", 100.0), seed()] } @@ -173,6 +191,10 @@ fn size_params(fields: &DialogFields) -> Value { Value::Object(params) } +fn match_params(fields: &DialogFields) -> Value { + Value::Object(form::json_of(&match_rows(), fields)) +} + fn opacity_params(fields: &DialogFields) -> Value { Value::Object(form::json_of(&opacity_rows(), fields)) } @@ -186,6 +208,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option Option (replace_rows(), json!({ "fit": "keep", "keep": false, "scaleStrokes": strokes })), + // The key object while the selection has one, else the top object. + MATCH => ( + match_rows(), + json!({ + "source": if key { "key" } else { "top" }, "size": "both", "rotate": false, "stacking": false, + "reference": 4, "scaleStrokes": strokes, "patterns": app.session.prefs.transform_pattern_tiles, + }), + ), // A new seed each time the document has changed, so running it again varies the result. OPACITY => (opacity_rows(), json!({ "min": 30, "max": 100, "seed": st.revision % SEEDS })), // The random order's seed (not shown): new whenever the document has changed, so each run @@ -224,6 +255,14 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option super::dialogs::open(app, &GRID_SPEC, fields, move |fields| dialog(GRID, grid_rows(lengths)).values(Bind::bound(fields))), REPLACE => super::dialogs::open(app, &REPLACE_SPEC, fields, |fields| dialog(REPLACE, replace_rows()).values(Bind::bound(fields))), + MATCH => super::dialogs::open(app, &MATCH_SPEC, fields, move |fields| { + let chosen = fields.text("size").is_some_and(|size| size != "none") + || fields.bool("rotate") == Some(true) + || fields.bool("stacking") == Some(true); + let source = key || fields.text("source") != Some("key"); + let reason = if source { tl!("Choose Size, Rotation or Stacking Order.") } else { tl!("The selection has no key object.") }; + dialog(MATCH, match_rows()).ok_enabled(chosen && source).ok_reason(reason.into()).values(Bind::bound(fields)) + }), OPACITY => super::dialogs::open(app, &OPACITY_SPEC, fields, |fields| { let (min, max) = (fields.number("min").unwrap_or(0.0), fields.number("max").unwrap_or(100.0)); dialog(OPACITY, opacity_rows()).ok_enabled(min <= max).values(Bind::bound(fields)) diff --git a/crates/ui-egui/src/addons/arrange/tests.rs b/crates/ui-egui/src/addons/arrange/tests.rs index 420bfdb01d..da066784f1 100644 --- a/crates/ui-egui/src/addons/arrange/tests.rs +++ b/crates/ui-egui/src/addons/arrange/tests.rs @@ -124,6 +124,59 @@ fn set_size_of_each_sets_the_sides_ticked() { assert_eq!((bounds(&app, b).width(), bounds(&app, b).height()), (30.0, 40.0)); } +fn layer_order(app: &VectorcraftApp) -> Vec { + app.session.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id).collect() +} + +#[test] +fn real_match_keyboard_edits_preview_confirm_and_cancel() { + let (app, a, b) = app(); + let steps = |app: &VectorcraftApp| app.session.doc().unwrap().history.undo.len(); + let before = steps(&app); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Match Objects…"); + panel.frame(); + let id = host::dialog_id(&panel.app()); + // No key object: it opens on the top object, b, and previews its size on a. + assert_eq!( + host::read(&panel.app(), id, |f| (f.text("source").map(str::to_owned), f.text("size").map(str::to_owned))), + (Some("top".into()), Some("both".into())) + ); + assert_eq!(bounds(&panel.app(), a), vectorcraft_geom::Rect::new(-10.0, -15.0, 30.0, 25.0)); + panel.focus("Stacking Order"); + panel.key(egui::Key::Space, egui::Modifiers::NONE); + panel.frame(); + assert_eq!(host::read(&panel.app(), id, |f| f.bool("stacking")), Some(true)); + assert_eq!(layer_order(&panel.app()), [b, a], "the preview puts a above b"); + panel.click("Cancel"); + panel.frame(); + { + let app = panel.app(); + assert_eq!((bounds(&app, a), layer_order(&app), steps(&app)), (vectorcraft_geom::Rect::new(0.0, 0.0, 20.0, 10.0), vec![a, b], before)); + } + click(&mut panel.app(), "Match Objects…"); + panel.frame(); + let id = host::dialog_id(&panel.app()); + host::set(&panel.app(), id, "size", json!("none")); + panel.frame(); + assert!(!panel.enabled("OK"), "nothing to match"); + host::set(&panel.app(), id, "size", json!("width")); + host::set(&panel.app(), id, "source", json!("key")); + panel.frame(); + assert!(!panel.enabled("OK"), "the selection has no key object"); + host::set(&panel.app(), id, "source", json!("bottom")); + panel.frame(); + assert!(panel.enabled("OK")); + panel.click("OK"); + panel.frame(); + let app = panel.app(); + assert!(!app.any_dialog_open()); + // b takes a's width, its height in proportion, as one undo step. + assert_eq!(bounds(&app, b), vectorcraft_geom::Rect::new(110.0, 110.0, 130.0, 130.0)); + assert_eq!(bounds(&app, a), vectorcraft_geom::Rect::new(0.0, 0.0, 20.0, 10.0)); + assert_eq!(steps(&app), before + 1); +} + #[test] fn replace_opens_with_the_scale_strokes_preference_and_swap_runs_directly() { let (mut app, a, b) = app(); diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..ae4203a3ce 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17438,6 +17438,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.swap` | `size` (false); `scaleStrokes` (the Scale Strokes & Effects preference) | Swaps the bounds centres of exactly two selected objects (off otherwise); with `size`, each also takes the other's width and height. | | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | +| `addon.arrange.match` | `source`: `key` (the key object, `select.key`), `top` (the frontmost selected object), `bottom` (the backmost) (the key object when the selection has one, else `top`); `size`: `none`, `width` (the height follows in proportion), `height` (the width follows in proportion), `both` (`none`); `rotate` (false); `stacking` (false); `reference` 0…8 (4, the center); `scaleStrokes`; `patterns` (the Transform Pattern Tiles preference); at least one of `size`, `rotate` and `stacking` | Makes the other selected objects (at most 20000) match the source, which stays as it is. `size` gives each one the source's width, height or both, measured in each object's own bounding-box frame; `rotate` turns each one to the source's bounding-box angle; both keep each object's reference point in place. `stacking` puts the others directly above the source, in its layer or group, in the order they had. `source: "key"` without a key object, and a `size` that takes a width or a height the source does not have, are refused. To match places, use `object.align {to: "key"}`. → `{source, count}` | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | @@ -17447,11 +17448,15 @@ active view so the selection's visual bounds fill the window with a margin, as ` and fails with nothing selected. Arrange in Grid…, Replace with Top Object…, Set Size of Each…, Randomize Opacity… and Sort Objects… open dialogs (`ui.menuDialog {command}`, dialog kinds `arrangeGrid`, `arrangeReplace`, `arrangeSize`, `arrangeOpacity` and `arrangeSort`) whose fields are the command's parameters, with Preview (Randomize Opacity's seed, and Sort Objects' `seed`, which is not shown, start new whenever the document has changed); Set Size of Each's `__width` and `__height` say which sizes OK applies. +Match Objects… opens a dialog of its own in the same way, keyed by its command, whose fields are the command's +parameters, with Preview; it opens on the key object when the selection has one, else on the top object, and OK is +off while nothing is chosen to match or the source is the key object and there is none. ```json {"name":"run_command","arguments":{"command":"addon.arrange.grid","params":{"columns":4,"gapX":12,"gapY":12}}} {"name":"run_command","arguments":{"command":"addon.arrange.replace","params":{"fit":"proportional"}}} {"name":"run_command","arguments":{"command":"addon.arrange.size","params":{"width":72,"proportional":true}}} +{"name":"run_command","arguments":{"command":"addon.arrange.match","params":{"source":"key","size":"both","rotate":true}}} ``` ## Document Tools add-on diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 032041c2a1..445a68aeeb 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3144,6 +3144,10 @@ scaling, replace with each fit and kept originals in stacking order, size with p undo step, off states, bad params refused), `addons::arrange::tests` in `vectorcraft-ui-egui` (the submenu, the dialogs, Preview and Cancel, Zoom to Selection) and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. +## Arrange Tools add-on: Match Objects (2026-11-29) + +A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Arrange Tools › Match Objects… makes the other top-level selected objects (at most 20000) match one of them, the source: the key object, or the top or the bottom selected object. Each can take the source's width (the height following in proportion), its height (the width following), or both, measured as `object.setBounds` measures them (Use Preview Bounds) in each object's own bounding-box frame; its bounding-box angle; and its stacking place, directly above the source in its layer or group, in the order they had. Sizing and turning keep each object's reference point in place, and strokes, effects and pattern tiles follow Scale Strokes & Effects and Transform Pattern Tiles. The source stays as it is, the dialog previews on the canvas, and OK is one undo step; no step when nothing changes. Places are matched with Align to Key Object (`object.align {to: "key"}`). Tests: `match_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (each size, the key, top and bottom sources, angles about the center, stacking within and across layers, no step when matched, bad params), `real_match_keyboard_edits_preview_confirm_and_cancel` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. + ## Arrange Tools add-on: Group Overlapping Objects (2026-11-01) A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Arrange Tools › Group Overlapping Objects groups the top-level selected objects wherever their visual bounds overlap or touch, chains included (A overlapping B and B overlapping C makes one group of three), only among objects of the same layer or group; objects that overlap nothing stay as they are, each new group takes its frontmost member's place in the stacking order, and the groups and the loose objects stay selected. One undo step; at most 20000 objects, compared by a sweep along x with union-find. Tests: `group_overlapping_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (chains, loners, stacking order, layers kept apart, visual bounds, no step when nothing overlaps, many objects), `group_overlapping_objects_runs_directly` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 453bda832d..0e7750475b 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -564,6 +564,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Outline view: a click selects by the outlines drawn, so it reaches a path behind an image (picked on its frame, unless Show Images in Outline Mode draws its pixels) or a gradient mesh (picked on its mesh lines) | done | #6437; in Outline mode the path is selected directly ([Object selection methods and preferences](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/object-selection-methods-and-preferences.html), Object Selection by Path Only). Type, symbol instances, blends, envelopes and placed documents are still picked within their bounds. Tests `outline_mode_picks_paths_through_images_and_meshes`, `outline_view_click_through_an_image_selects_the_path_behind` | | Outline view draws a linked image or placed document as its box with an X inside, unless Show Images in Outline Mode is on | done | A linked file draws in Outline mode as a box with an X in it, and its contents show only after the Document Setup option Show Images in Outline Mode is turned on ([View artwork](https://helpx.adobe.com/illustrator/using/viewing-artwork.html)). The rest are VectorCraft's own rules. A linked image's frame is crossed from corner to corner, following the corners of a turned or distorted image. An embedded image, and each piece that an envelope cuts an image into, shows its frame alone. A click selects a linked image on its frame, as before, and not on the lines. A placed document shows its box crossed and none of its art, also with raster effects such as a drop shadow and with color adjustments. Effects that change geometry, its own or its group's, reshape the crossed box instead of the file's art, and an envelope holding a placed document distorts its crossed box. Each step of a blend of placed documents is crossed too. With the option on, images show their pixels in gray and placed documents show their art in outline, uncrossed, and the art inside a placed document follows the option of the document it is placed in. Output draws them as before, and so does Preview mode, except in a layer that is not a template and whose Preview is off, which draws them by these rules. In Outline mode, a template layer draws them as Preview mode does. Tests `outline_mode_crosses_a_linked_images_frame_unless_the_setup_shows_images`, `outline_mode_crosses_a_linked_image_with_a_color_mask`, `outline_mode_does_not_cross_the_pieces_of_an_enveloped_linked_image`, `outline_mode_crosses_a_linked_image_moved_into_a_warp_piece`, `outline_mode_crosses_a_turned_or_distorted_linked_image_through_its_corners`, `outline_mode_draws_a_placed_document_as_its_box_crossed_unless_the_setup_shows_images`, `outline_mode_reshapes_the_crossed_box_of_a_placed_document_by_its_groups_effects`, `outline_mode_draws_the_crossed_box_its_effects_move_into_view_after_a_preview_frame`, `outline_mode_warps_an_enveloped_placed_documents_crossed_box`, `outline_mode_draws_each_step_of_a_blend_of_placed_documents_crossed` | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools runs Arrange in Grid… (grid by row, one row or one column; columns, H and V spacing, Center on Artboard; Preview), Swap Objects, Swap Objects and Sizes, Replace with Top Object… (Actual Size, Bounds or Bounds (Fit Proportionally); Keep Original; Scale Strokes & Effects; Preview), Set Size of Each… (Width and Height each ticked on or off, Constrain Width and Height Proportions with one side, the reference point, Scale Strokes & Effects; Preview) and Zoom to Selection, each one undo step | done | `addon.arrange.*`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | +| Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Match Objects… gives the other selected objects the size (Width, Height or Width and Height), the bounding-box angle (Rotation) and the stacking place (Stacking Order) of the source, chosen in Match To (Key Object, Top Object, Bottom Object); the reference point, Scale Strokes & Effects, Transform Patterns; Preview; one undo step | done | `addon.arrange.match`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Group Overlapping Objects groups the selected objects whose visual bounds overlap or touch (chains included, within one layer or group), each group at its frontmost member's stacking place, one undo step | done | #4928; `addon.arrange.groupOverlapping`, `crates/engine/src/cmd/addons/arrange.rs` and its tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Randomize Opacity… gives each selected object its own opacity at random between Minimum and Maximum (%), with a Seed that repeats it and Preview, one undo step | done | #4925; `addon.arrange.randomizeOpacity`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Sort Objects… sorts the selected objects by Sort By (width, height, area, X or Y position, opacity, stacking order) in an Order (Small to Large, Large to Small, Random) and gives them Apply To in that order, trading the values or with Distribute Evenly; Scale Strokes & Effects; Preview; one undo step | done | #4917; `addon.arrange.sort`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | From 2b61bdc7520f75987de5b6a025598b5f21ead919 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 03:38:29 -0800 Subject: [PATCH 085/264] Arrange Tools: Offset Objects chains the selection in a row or a column with a set gap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Object › Plug-ins › Arrange Tools › Offset Objects… (addon.arrange.offset) puts the selected objects one after another in a row (left to right) or a column (top to bottom), each a gap past the one before it; a negative gap overlaps them. The order is the stacking order from the back or the position (left or top edges), and Reverse Order runs it the other way. The first object stays where it is, and the others move only along the row or column, keeping their place across it. Objects are measured by their visual bounds, a clipping group by its mask. One undo step, none when nothing moves; bad params are refused. The dialog has Direction, Gap, Order and Reverse Order with Preview. Docs: docs/mcp.md, docs/ui-parity.md, docs/target-app-parity.md, ROADMAP. --- ROADMAP.md | 1 + crates/engine/src/cmd/addons/arrange.rs | 50 ++++++- crates/engine/src/cmd/addons/arrange/tests.rs | 128 ++++++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/tests/command_sweep.rs | 2 + crates/ui-egui/src/addons/arrange.rs | 27 +++- crates/ui-egui/src/addons/arrange/tests.rs | 54 ++++++++ docs/mcp.md | 6 +- docs/target-app-parity.md | 4 + docs/ui-parity.md | 1 + 10 files changed, 268 insertions(+), 6 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index d40c33e9e1..c743448b07 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -163,6 +163,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-01: Expand Dashes into Paths joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): each selected path's dashed stroke becomes separate open paths, one per dash, laid out exactly as the stroke draws them (pattern, offset, Align Dashes to Corners and Path Ends), each keeping the stroke with the dashes off, so the gaps are real gaps for cutters and plotters, as one undo step (`addon.pathtools.expandDashes`, #4922). - 2026-11-01: Randomize Opacity joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): each selected object gets its own opacity at random between a minimum and a maximum percent, with a seed that repeats the result, as one undo step (`addon.arrange.randomizeOpacity`, #4925). - 2026-11-01: Sort Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are sorted by width, height, area, position, opacity or stacking order (small to large, large to small or at random) and take another of those in that order, trading their values or stepping them evenly, as one undo step (`addon.arrange.sort`, #4917). +- 2026-11-29: Offset Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are chained one after another in a row or a column with a set gap (negative to overlap them), in stacking order or by position, either way; the first stays in place and the others move only along the row or column, as one undo step (`addon.arrange.offset`). A VectorCraft addition: headline numbers unchanged. - 2026-11-15: Tangent Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the circles that touch two selected paths or compound paths at a set radius, or three of them (up to eight for three circles), touching each outline without crossing it; circles, rotated ellipses and other paths alike. A dialog that previews every circle or one picked by number, the current paint, one undo step (`addon.pathtools.tangentCircle`). A VectorCraft addition: headline numbers unchanged. - 2026-11-17: Add Bounding Rectangle and Add Bounding Circle join the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): a live rectangle on the selection's geometric bounding box, or the smallest live circle that holds its outlines, around the whole selection or around each object, with the current paint and one undo step; the menu items open a dialog with Offset, One per Object and Preview (`addon.pathtools.boundingRectangle`, `addon.pathtools.boundingCircle`, #6966). A VectorCraft addition: headline numbers unchanged. - 2026-11-22: Add Inscribed Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the largest live circle inside each selected closed path or compound path, in the area it fills under its fill rule, with the current paint and one undo step (`addon.pathtools.inscribedCircle`, #6966). A VectorCraft addition: headline numbers unchanged. diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index f81d7a599a..a25f341d1c 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -1,5 +1,6 @@ //! Arrange Tools (`addon.arrange.*`), a built-in add-on: Arrange in Grid lays the selected objects -//! out in rows and columns, a row or a column; Swap Objects swaps the places (and sizes) of two; +//! out in rows and columns, a row or a column; Offset Objects chains them one after another in a +//! row or a column with a set gap, the first staying in place; Swap Objects swaps the places (and sizes) of two; //! Replace with Top Object puts a copy of the topmost selected object in place of each of the //! others; and Set Size of Each gives every selected object an exact width and height. Places and //! sizes are measured and set as `object.setBounds` does. Group Overlapping Objects groups the @@ -17,7 +18,7 @@ use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_color::recolor::Rng; use vectorcraft_doc::{Node, NodeId, OrientedBox}; -use vectorcraft_geom::{Affine, Point, Rect}; +use vectorcraft_geom::{Affine, Point, Rect, Vec2}; use vectorcraft_render::effects; use super::super::appearance::series_children_in_paint_order; @@ -52,6 +53,15 @@ pub fn specs() -> Vec { has_selection, grid ), + cmd!( + "addon.arrange.offset", + "Offset Objects", + ["Object", "Plug-ins", "Arrange Tools"], + None, + "{direction?: \"row\" (left to right) | \"column\" (top to bottom) (\"row\"), gap?: pt −1000000..1000000 (10; negative: the objects overlap), order?: \"stacking\" (stacking order, from the back) | \"position\" (by left edge in a row, by top edge in a column; equal edges keep their stacking order) (\"stacking\"), reverse?: false (true: the order runs the other way)} chain the selected objects (the top-level ones) one after another in that order, as one undo step: the first stays where it is, and each later one moves only along the direction, so that its left (top) edge is `gap` past the right (bottom) edge of the one before it; its place across the direction stays. Everything is measured by visual bounds (strokes and effects as drawn; a clipping group by its mask). A run that moves nothing makes no step → {count}", + has_multi, + offset + ), cmd!( "addon.arrange.swap", "Swap Objects", @@ -228,6 +238,42 @@ fn grid(s: &mut Session, p: &Value) -> Result { Ok(json!({ "count": n })) } +fn offset(s: &mut Session, p: &Value) -> Result { + const C: &str = "addon.arrange.offset"; + let row = choice(p, C, "direction", &["row", "column"])?.unwrap_or("row") == "row"; + let gap = number_in(p, "gap", 10.0, (-LIMIT, LIMIT), C)?; + let by_position = choice(p, C, "order", &["stacking", "position"])?.unwrap_or("stacking") == "position"; + let reverse = switch_or(p, "reverse", false, C)?; + let roots = selected_roots(s)?; + let d = &s.doc()?.doc; + // The objects in stacking order from the back, each with its leading and trailing edge along the direction. + let mut items: Vec<(NodeId, f64, f64)> = roots + .iter() + .filter_map(|id| { + let b = effects::preview::bounds_of(d, &[*id], true)?; + Some(if row { (*id, b.x0, b.x1) } else { (*id, b.y0, b.y1) }) + }) + .collect(); + if by_position { + items.sort_by(|a, b| a.1.total_cmp(&b.1)); + } + if reverse { + items.reverse(); + } + // The first stays; each later one starts `gap` past where the one before it now ends. + let mut end: Option = None; + let xfs: Vec<(NodeId, Affine)> = items + .iter() + .map(|&(id, start, finish)| { + let shift = end.map_or(0.0, |e| e + gap - start); + end = Some(finish + shift); + (id, Affine::translate(if row { Vec2::new(shift, 0.0) } else { Vec2::new(0.0, shift) })) + }) + .collect(); + transform_each(s, "Offset Objects", false, &xfs)?; + Ok(json!({ "count": items.len() })) +} + fn swap(s: &mut Session, p: &Value) -> Result { const C: &str = "addon.arrange.swap"; let size = switch_or(p, "size", false, C)?; diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 759f6f321e..498a927898 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -106,6 +106,134 @@ fn grid_measures_visual_bounds() { assert!(near(bounds(&s, b), (24.0, 0.0, 20.0, 20.0)), "{:?}", bounds(&s, b)); } +#[test] +fn offset_chains_a_row_in_stacking_order_from_the_first_in_place() { + let mut s = session(); + let a = rect(&mut s, 100.0, 50.0, 20.0, 10.0); + let b = rect(&mut s, 0.0, 200.0, 40.0, 30.0); + let c = rect(&mut s, 300.0, 0.0, 10.0, 10.0); + select(&mut s, &[c, a, b]); + let n = steps(&s); + let r = s.execute("addon.arrange.offset", &json!({"gap": 5})).unwrap(); + assert_eq!(r["count"], json!(3)); + assert_eq!(steps(&s), n + 1, "one undo step"); + // From the back: a stays, b starts 5 past a's right edge, c 5 past b's; each keeps its y. + assert!(near(bounds(&s, a), (100.0, 50.0, 20.0, 10.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, b), (125.0, 200.0, 40.0, 30.0)), "{:?}", bounds(&s, b)); + assert!(near(bounds(&s, c), (170.0, 0.0, 10.0, 10.0)), "{:?}", bounds(&s, c)); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(near(bounds(&s, b), (0.0, 200.0, 40.0, 30.0))); + assert!(near(bounds(&s, c), (300.0, 0.0, 10.0, 10.0))); + // Reversed: c stays, then b, then a. The gap defaults to 10. + s.execute("addon.arrange.offset", &json!({"reverse": true})).unwrap(); + assert!(near(bounds(&s, c), (300.0, 0.0, 10.0, 10.0)), "{:?}", bounds(&s, c)); + assert!(near(bounds(&s, b), (320.0, 200.0, 40.0, 30.0)), "{:?}", bounds(&s, b)); + assert!(near(bounds(&s, a), (370.0, 50.0, 20.0, 10.0)), "{:?}", bounds(&s, a)); +} + +#[test] +fn offset_chains_a_column_by_position_either_way_and_overlaps_with_a_negative_gap() { + let mut s = session(); + let a = rect(&mut s, 0.0, 100.0, 10.0, 20.0); + let b = rect(&mut s, 50.0, 0.0, 10.0, 10.0); + let c = rect(&mut s, 100.0, 40.0, 10.0, 30.0); + select(&mut s, &[a, b, c]); + // Top to bottom: b, c, a; each 5 into the one before it, keeping its x. + s.execute("addon.arrange.offset", &json!({"direction": "column", "order": "position", "gap": -5})).unwrap(); + assert!(near(bounds(&s, b), (50.0, 0.0, 10.0, 10.0)), "{:?}", bounds(&s, b)); + assert!(near(bounds(&s, c), (100.0, 5.0, 10.0, 30.0)), "{:?}", bounds(&s, c)); + assert!(near(bounds(&s, a), (0.0, 30.0, 10.0, 20.0)), "{:?}", bounds(&s, a)); + s.execute("edit.undo", &json!({})).unwrap(); + // Bottom to top: a stays, then c, then b. + s.execute("addon.arrange.offset", &json!({"direction": "column", "order": "position", "reverse": true, "gap": 0})).unwrap(); + assert!(near(bounds(&s, a), (0.0, 100.0, 10.0, 20.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, c), (100.0, 120.0, 10.0, 30.0)), "{:?}", bounds(&s, c)); + assert!(near(bounds(&s, b), (50.0, 150.0, 10.0, 10.0)), "{:?}", bounds(&s, b)); + s.execute("edit.undo", &json!({})).unwrap(); + // Left to right in a row: a, b, c. + s.execute("addon.arrange.offset", &json!({"order": "position", "gap": 1})).unwrap(); + assert!(near(bounds(&s, a), (0.0, 100.0, 10.0, 20.0)), "{:?}", bounds(&s, a)); + assert!(near(bounds(&s, b), (11.0, 0.0, 10.0, 10.0)), "{:?}", bounds(&s, b)); + assert!(near(bounds(&s, c), (22.0, 40.0, 10.0, 30.0)), "{:?}", bounds(&s, c)); +} + +#[test] +fn offset_measures_visual_bounds_and_clipping_groups_by_their_mask() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let b = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap(); + s.execute("stroke.set", &json!({"weight": 4})).unwrap(); + s.execute("addon.arrange.offset", &json!({"gap": 0})).unwrap(); + // Visual boxes 24 wide, touching. + assert!(near(bounds(&s, b), (24.0, 0.0, 20.0, 20.0)), "{:?}", bounds(&s, b)); + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + // A 200 wide object clipped to a 30 wide mask at x 100. + let clipped = rect(&mut s, 50.0, 50.0, 200.0, 10.0); + let mask = rect(&mut s, 100.0, 40.0, 30.0, 30.0); + select(&mut s, &[clipped, mask]); + s.execute("object.clippingMask.make", &json!({})).unwrap(); + let group = s.doc().unwrap().selection.objects[0]; + let c = rect(&mut s, 300.0, 0.0, 10.0, 10.0); + select(&mut s, &[a, group, c]); + s.execute("addon.arrange.offset", &json!({"gap": 0})).unwrap(); + // The mask starts at a's right edge, and c at the mask's. + assert!(near(bounds(&s, mask), (20.0, 40.0, 30.0, 30.0)), "{:?}", bounds(&s, mask)); + assert!(near(bounds(&s, clipped), (-30.0, 50.0, 200.0, 10.0)), "{:?}", bounds(&s, clipped)); + assert!(near(bounds(&s, c), (50.0, 0.0, 10.0, 10.0)), "{:?}", bounds(&s, c)); +} + +#[test] +fn offset_makes_no_step_when_nothing_moves_and_skips_locked_objects() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0); + let b = rect(&mut s, 30.0, 50.0, 20.0, 20.0); + select(&mut s, &[a]); + assert!(!enabled(&s, "addon.arrange.offset"), "off with one object"); + select(&mut s, &[a, b]); + assert!(enabled(&s, "addon.arrange.offset")); + // Already 10 apart in a row. + let n = steps(&s); + s.execute("addon.arrange.offset", &json!({})).unwrap(); + assert_eq!(steps(&s), n, "no step when nothing moves"); + // Two objects in one group are one object: nothing to chain. + s.execute("object.group", &json!({})).unwrap(); + s.execute("select.all", &json!({})).unwrap(); + assert!(!enabled(&s, "addon.arrange.offset"), "off with one group"); + refuses(&mut s, "addon.arrange.offset", &[json!({"gap": 50})]); + s.execute("edit.undo", &json!({})).unwrap(); + let c = rect(&mut s, 200.0, 200.0, 10.0, 10.0); + select(&mut s, &[b]); + s.execute("object.lock", &json!({})).unwrap(); + s.execute("select.all", &json!({})).unwrap(); + s.execute("addon.arrange.offset", &json!({"gap": 0})).unwrap(); + assert!(near(bounds(&s, b), (30.0, 50.0, 20.0, 20.0)), "the locked object stays, {:?}", bounds(&s, b)); + assert!(near(bounds(&s, c), (20.0, 200.0, 10.0, 10.0)), "{:?}", bounds(&s, c)); +} + +#[test] +fn offset_refuses_bad_params() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 20.0, 10.0); + let b = rect(&mut s, 100.0, 100.0, 40.0, 40.0); + select(&mut s, &[a, b]); + refuses( + &mut s, + "addon.arrange.offset", + &[ + json!({"direction": "diagonal"}), + json!({"direction": 1}), + json!({"gap": 1e7}), + json!({"gap": -1e7}), + json!({"gap": "10"}), + json!({"order": "size"}), + json!({"reverse": "yes"}), + ], + ); +} + #[test] fn swap_trades_places_and_optionally_sizes() { let mut s = session(); diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index c2699f219c..9849a22077 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -6,6 +6,7 @@ pub(super) const ALLOWED: &[&str] = &[ "addon.arrange.grid", "addon.arrange.groupOverlapping", + "addon.arrange.offset", "addon.arrange.randomizeOpacity", "addon.arrange.replace", "addon.arrange.size", diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 462641b953..c98cd9278e 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -995,6 +995,8 @@ fn structured_junk() { ("addon.arrange.grid", json!({"columns": u64::MAX, "gapX": 1e6, "gapY": -1e6, "centerOnArtboard": true})), ("addon.arrange.grid", json!({"layout": "row", "gapX": f64::MAX, "columns": -1})), ("addon.arrange.grid", json!({"layout": "column", "gapX": -1e6})), + ("addon.arrange.offset", json!({"direction": "column", "gap": -1e6, "order": "position", "reverse": true})), + ("addon.arrange.offset", json!({"direction": "diagonal", "gap": f64::MAX, "order": 3, "reverse": "x"})), ("addon.arrange.swap", json!({"size": true, "scaleStrokes": true})), ("addon.arrange.replace", json!({"fit": "proportional", "keep": true})), ("addon.arrange.replace", json!({"fit": "bounds", "scaleStrokes": true})), diff --git a/crates/ui-egui/src/addons/arrange.rs b/crates/ui-egui/src/addons/arrange.rs index a26f5f7a28..ccd32bd7aa 100644 --- a/crates/ui-egui/src/addons/arrange.rs +++ b/crates/ui-egui/src/addons/arrange.rs @@ -1,5 +1,5 @@ //! Arrange Tools in the interface: its submenu (Object › Plug-ins › Arrange Tools); the dialogs of -//! Arrange in Grid, Replace with Top Object, Set Size of Each, Randomize Opacity and Sort Objects, +//! Arrange in Grid, Offset Objects, Replace with Top Object, Set Size of Each, Randomize Opacity and Sort Objects, //! which preview on the canvas and run their `addon.arrange.*` command on OK; Group Overlapping //! Objects; and Zoom to Selection ([`ZOOM`]), which fits the active view to the selection. @@ -22,19 +22,21 @@ use crate::menus::{Sep, c, cp}; /// Zoom to Selection: a view command, since the view is the interface's. pub const ZOOM: &str = "addon.arrange.zoomSelection"; const GRID: &str = "addon.arrange.grid"; +const OFFSET: &str = "addon.arrange.offset"; const REPLACE: &str = "addon.arrange.replace"; const SIZE: &str = "addon.arrange.size"; const OPACITY: &str = "addon.arrange.randomizeOpacity"; const SORT: &str = "addon.arrange.sort"; /// Each dialog's command and heading. -const DIALOGS: [(&str, &str); 5] = [ +const DIALOGS: [(&str, &str); 6] = [ (GRID, "Arrange in Grid"), + (OFFSET, "Offset Objects"), (REPLACE, "Replace with Top Object"), (SIZE, "Set Size of Each"), (OPACITY, "Randomize Opacity"), (SORT, "Sort Objects"), ]; -/// The widths and heights Set Size of Each takes (pt), and the gaps Arrange in Grid takes. +/// The widths and heights Set Size of Each takes (pt), and the gaps Arrange in Grid and Offset Objects take. const SIZES: std::ops::RangeInclusive = 0.001..=1e6; const GAPS: std::ops::RangeInclusive = -1e6..=1e6; /// The seeds the Randomize Opacity dialog offers. @@ -56,6 +58,7 @@ const ATTRIBUTES: [(&str, &str); 7] = [ pub fn menu() -> Vec { vec![ c("Arrange in Grid…", GRID), + c("Offset Objects…", OFFSET), cp("Swap Objects", "addon.arrange.swap", json!({})), cp("Swap Objects and Sizes", "addon.arrange.swap", json!({ "size": true })), c("Replace with Top Object…", REPLACE), @@ -69,6 +72,7 @@ pub fn menu() -> Vec { } static GRID_SPEC: Spec = Spec { command: GRID, params: grid_params, found: None }; +static OFFSET_SPEC: Spec = Spec { command: OFFSET, params: offset_params, found: None }; static REPLACE_SPEC: Spec = Spec { command: REPLACE, params: replace_params, found: None }; static SIZE_SPEC: Spec = Spec { command: SIZE, params: size_params, found: None }; static OPACITY_SPEC: Spec = Spec { command: OPACITY, params: opacity_params, found: None }; @@ -116,6 +120,17 @@ fn grid_rows(lengths: LengthUnits) -> Vec { ] } +fn offset_rows(lengths: LengthUnits) -> Vec { + let directions = [("row", "Row (Left to Right)"), ("column", "Column (Top to Bottom)")]; + let orders = [("stacking", "Stacking Order"), ("position", "Position")]; + vec![ + choice("direction", "Direction:", &directions, "row"), + length("gap", "Gap:", 10.0, GAPS, lengths), + choice("order", "Order:", &orders, "stacking"), + check("reverse", "Reverse Order", false), + ] +} + fn replace_rows() -> Vec { let fits = [("keep", "Actual Size"), ("bounds", "Bounds"), ("proportional", "Bounds (Fit Proportionally)")]; vec![choice("fit", "Size:", &fits, "keep"), check("keep", "Keep Original", false), scale_strokes()] @@ -156,6 +171,10 @@ fn grid_params(fields: &DialogFields) -> Value { Value::Object(form::json_of(&grid_rows(POINTS), fields)) } +fn offset_params(fields: &DialogFields) -> Value { + Value::Object(form::json_of(&offset_rows(POINTS), fields)) +} + fn replace_params(fields: &DialogFields) -> Value { Value::Object(form::json_of(&replace_rows(), fields)) } @@ -196,6 +215,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option (offset_rows(lengths), json!({ "direction": "row", "gap": 10, "order": "stacking", "reverse": false })), REPLACE => (replace_rows(), json!({ "fit": "keep", "keep": false, "scaleStrokes": strokes })), // A new seed each time the document has changed, so running it again varies the result. OPACITY => (opacity_rows(), json!({ "min": 30, "max": 100, "seed": st.revision % SEEDS })), @@ -223,6 +243,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, id: &str) -> Option super::dialogs::open(app, &GRID_SPEC, fields, move |fields| dialog(GRID, grid_rows(lengths)).values(Bind::bound(fields))), + OFFSET => super::dialogs::open(app, &OFFSET_SPEC, fields, move |fields| dialog(OFFSET, offset_rows(lengths)).values(Bind::bound(fields))), REPLACE => super::dialogs::open(app, &REPLACE_SPEC, fields, |fields| dialog(REPLACE, replace_rows()).values(Bind::bound(fields))), OPACITY => super::dialogs::open(app, &OPACITY_SPEC, fields, |fields| { let (min, max) = (fields.number("min").unwrap_or(0.0), fields.number("max").unwrap_or(100.0)); diff --git a/crates/ui-egui/src/addons/arrange/tests.rs b/crates/ui-egui/src/addons/arrange/tests.rs index 420bfdb01d..e0c0e693d3 100644 --- a/crates/ui-egui/src/addons/arrange/tests.rs +++ b/crates/ui-egui/src/addons/arrange/tests.rs @@ -61,6 +61,60 @@ fn real_grid_edits_reach_the_preview_and_confirmed_geometry() { assert!(!app.any_dialog_open()); } +fn steps(app: &VectorcraftApp) -> usize { + app.session.doc().unwrap().history.undo.len() +} + +#[test] +fn real_offset_edits_reach_the_preview_and_ok_applies_them_as_one_step() { + let (app, a, b) = app(); + let n = steps(&app); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Offset Objects…"); + type_number(&mut panel, "Gap", "3"); + let id = host::dialog_id(&panel.app()); + assert_eq!(host::read(&panel.app(), id, |f| f.number("gap")), Some(3.0)); + { + // From the back: a stays and b starts 3 past its right edge, keeping its y. + let app = panel.app(); + assert_eq!((bounds(&app, a).x0, bounds(&app, a).y0), (0.0, 0.0)); + assert_eq!((bounds(&app, b).x0, bounds(&app, b).y0), (23.0, 100.0)); + } + panel.focus("Reverse Order"); + panel.key(egui::Key::Space, egui::Modifiers::NONE); + panel.frame(); + let preview = { + // Reversed: b stays and a starts 3 past b's right edge, keeping its y. + let app = panel.app(); + assert_eq!((bounds(&app, b).x0, bounds(&app, b).y0), (100.0, 100.0)); + assert_eq!((bounds(&app, a).x0, bounds(&app, a).y0), (143.0, 0.0)); + (bounds(&app, a), bounds(&app, b)) + }; + panel.click("OK"); + panel.frame(); + let app = panel.app(); + assert_eq!((bounds(&app, a), bounds(&app, b)), preview); + assert_eq!(steps(&app), n + 1, "one undo step"); + assert!(!app.any_dialog_open()); +} + +#[test] +fn real_offset_cancel_puts_the_objects_back() { + let (app, a, b) = app(); + let n = steps(&app); + let before = (bounds(&app, a), bounds(&app, b)); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + click(&mut panel.app(), "Offset Objects…"); + type_number(&mut panel, "Gap", "50"); + assert_eq!(bounds(&panel.app(), b).x0, 70.0, "the preview moves b"); + panel.click("Cancel"); + panel.frame(); + let app = panel.app(); + assert_eq!((bounds(&app, a), bounds(&app, b)), before); + assert_eq!(steps(&app), n); + assert!(!app.any_dialog_open()); +} + #[test] fn real_size_keyboard_edits_keep_unticked_sides_unchanged() { let (app, a, b) = app(); diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..fbd68a9bca 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17430,11 +17430,12 @@ images and patterns keep their colours. → `{changed, swatches: [the document s Arrange Tools is a built-in add-on that lays out, swaps, replaces and sizes selected objects: its commands are `addon.arrange.*`, and in the desktop app it lives in Object › Plug-ins › Arrange Tools. Each command acts on the top-level selected objects and is one undo step; a run that moves nothing makes no step. Places and sizes are measured -as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid, which uses visual bounds. +as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid and Offset Objects, which use visual bounds. | Command | Parameters (default) | Does | |---|---|---| | `addon.arrange.grid` | `layout`: `grid`, `row`, `column` (`grid`); `columns`: 1…10000 (⌈√count⌉, never more than the count); `gapX` pt (10), `gapY` pt (`gapX`), each −1000000…1000000; `centerOnArtboard` (false) | Lays the objects out in their stacking order from the back, left to right and top to bottom. Each cell is as wide as the widest object in its column and as tall as the tallest in its row, and each object is centred in its cell. The grid starts at the selection's top-left, or is centred on the artboard under the selection's centre (the first artboard when none is there). → `{count}` | +| `addon.arrange.offset` | `direction`: `row` (left to right), `column` (top to bottom) (`row`); `gap` pt, −1000000…1000000 (10; negative overlaps the objects); `order`: `stacking` (stacking order from the back), `position` (by left edge in a row, by top edge in a column; equal edges keep their stacking order) (`stacking`); `reverse` (false) | Chains the objects one after another in that order: the first stays where it is, and each later one moves only along the direction so that its left (top) edge is `gap` past the right (bottom) edge of the one before it; its place across the direction stays. Measured by visual bounds, a clipping group by its mask. Needs two objects or more. → `{count}` | | `addon.arrange.swap` | `size` (false); `scaleStrokes` (the Scale Strokes & Effects preference) | Swaps the bounds centres of exactly two selected objects (off otherwise); with `size`, each also takes the other's width and height. | | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | @@ -17447,9 +17448,12 @@ active view so the selection's visual bounds fill the window with a margin, as ` and fails with nothing selected. Arrange in Grid…, Replace with Top Object…, Set Size of Each…, Randomize Opacity… and Sort Objects… open dialogs (`ui.menuDialog {command}`, dialog kinds `arrangeGrid`, `arrangeReplace`, `arrangeSize`, `arrangeOpacity` and `arrangeSort`) whose fields are the command's parameters, with Preview (Randomize Opacity's seed, and Sort Objects' `seed`, which is not shown, start new whenever the document has changed); Set Size of Each's `__width` and `__height` say which sizes OK applies. +Offset Objects… opens one the same way (`ui.menuDialog {command: "addon.arrange.offset"}`), with Direction, Gap, Order +and Reverse Order. ```json {"name":"run_command","arguments":{"command":"addon.arrange.grid","params":{"columns":4,"gapX":12,"gapY":12}}} +{"name":"run_command","arguments":{"command":"addon.arrange.offset","params":{"direction":"column","gap":6,"order":"position"}}} {"name":"run_command","arguments":{"command":"addon.arrange.replace","params":{"fit":"proportional"}}} {"name":"run_command","arguments":{"command":"addon.arrange.size","params":{"width":72,"proportional":true}}} ``` diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 032041c2a1..001f3a2ecb 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3156,6 +3156,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Arrange Tools › Sort Objects… sorts the top-level selected objects (or `ids`, at most 20000) by one attribute (width, height, area, x or y position, opacity or stacking order; small to large, large to small, or a random order from a seed) and gives them another in that order, the first the smallest value: the objects trade the values they have, or with Distribute Evenly the values step evenly from the smallest to the largest. Lining objects up left to right by size, restacking them so the largest is at the back, or giving them heights that step with their x position are each one run. Sizes and places are measured and set as `object.setBounds` measures them (Use Preview Bounds); a width, height or area changes about each object's centre (an area in proportion), and stacking order trades places only among objects of the same layer or group. One undo step; no step when nothing changes. Tests: `sort_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (each attribute sorted by and applied, both directions, distribute, layers kept apart, the seeded random order, `ids`, no step when in order, bad params), `sort_objects_opens_its_dialog_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. +## Arrange Tools add-on: Offset Objects (2026-11-29) + +A VectorCraft addition, so no area score moves. Object › Plug-ins › Arrange Tools › Offset Objects… chains the top-level selected objects one after another in a row (left to right) or a column (top to bottom) with a gap of −1000000 to 1000000 pt (10 by default; a negative gap overlaps them). The order is the stacking order from the back, or the position (left edges in a row, top edges in a column), and Reverse Order runs it the other way. The first object stays where it is; each later one moves only along the row or column so that it starts the gap past the end of the one before it, and keeps its place across it. Objects are measured by their visual bounds, a clipping group by its mask. One undo step; no step when nothing moves. Tests: `offset_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (row and column, both orders and reversed, a negative gap, strokes and clipping groups, no step, locked objects left out, bad params), `real_offset_*` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. + ## Type Tools add-on: Text Tweaker (2026-11-03) A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Type Tools › Text Tweaker… gives one character attribute (size, baseline shift, character rotation, horizontal or vertical scale, tracking, leading or stroke weight) to the selected characters letter by letter, from a start value to an end value along a straight ramp, an ease in and out, a bow, a spike or at random with a seed, while the text stays live and editable (#4924). With Block enabled, a leading ramp sets Line Gap from the first changed character instead of varying leading across the text. Values are set as the Character panel sets them, in its units and ranges, so scaled type takes the sizes shown; spaces and line breaks are skipped unless asked for, each type object gets its own ramp, the range is the Type tool's selection or all the text of the selected type objects, and the run is one undo step from a dialog with Preview. Tests: `cmd::addons::typetools::tests` in `vectorcraft-engine` (each shape, each attribute, skipped spaces, ranges, one ramp per object, seeded random values, scaled type, one undo step, bad params refused), `addons::typetools::tests` in `vectorcraft-ui-egui` (the submenu, the dialog, Preview and Cancel, OK) and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 453bda832d..ac20453f86 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -567,6 +567,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Group Overlapping Objects groups the selected objects whose visual bounds overlap or touch (chains included, within one layer or group), each group at its frontmost member's stacking place, one undo step | done | #4928; `addon.arrange.groupOverlapping`, `crates/engine/src/cmd/addons/arrange.rs` and its tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Randomize Opacity… gives each selected object its own opacity at random between Minimum and Maximum (%), with a Seed that repeats it and Preview, one undo step | done | #4925; `addon.arrange.randomizeOpacity`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | | Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Sort Objects… sorts the selected objects by Sort By (width, height, area, X or Y position, opacity, stacking order) in an Order (Small to Large, Large to Small, Random) and gives them Apply To in that order, trading the values or with Distribute Evenly; Scale Strokes & Effects; Preview; one undo step | done | #4917; `addon.arrange.sort`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; not a feature of the reference app, so it is not scored | +| Arrange Tools add-on (VectorCraft addition): Object › Plug-ins › Arrange Tools › Offset Objects… chains the selected objects one after another in a Direction (Row (Left to Right) or Column (Top to Bottom)) with a Gap (negative overlaps), in an Order (Stacking Order or Position) with Reverse Order; the first stays in place and the others move only along the row or column; Preview; one undo step | done | `addon.arrange.offset`, `crates/engine/src/cmd/addons/arrange.rs`, `crates/ui-egui/src/addons/arrange.rs` and their tests; a VectorCraft addition, so it is not scored | | Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › Save a Timestamped Copy writes `_YYYY-MM-DD_HH-MM.` next to the document (a folder picked for one never saved), which keeps its path, title and modified state; off on the web | done | #4926; `addon.document.saveTimestampedCopy`, `crates/engine/src/cmd/addons/document.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app, so it is not scored | | Document Tools add-on (VectorCraft addition): Export All Open Documents as PDF / as SVG (#4920) | done | asks for a folder, writes a copy of every open document named after it (taken names numbered, nothing replaced), documents and active tab unchanged; failures named in the status bar | | Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › Batch Trace Folder asks for a folder of images, then a destination folder, traces each image with a preset (optionally expanded) and saves it there as `.vectorcraft`, `.svg`, `.pdf`, `.ai` or `.eps` under its own name (taken names numbered, nothing replaced), closing each image again; the status bar counts the images traced and those that couldn't be; off on the web | done | #4921; `addon.document.batchTraceFolder`, `crates/engine/src/cmd/addons/document/batch_trace.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app | From 36ec203ef5a058bc22823ff8835eb402c8a5cc55 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 12:44:11 +0100 Subject: [PATCH 086/264] Pin current craft-libs and its matching egui revision --- Cargo.lock | 198 ++++++++++++++++---------------- Cargo.toml | 98 ++++++++-------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 150 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4910ae4bb8..c4f93bacb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2752,7 +2752,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", "emath", @@ -2785,7 +2785,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -2820,7 +2820,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "accesskit", "ahash", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -2858,7 +2858,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "accesskit_winit", "arboard", @@ -2883,7 +2883,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "egui", @@ -2897,7 +2897,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", "egui", @@ -2910,7 +2910,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "dify", "eframe", @@ -2936,7 +2936,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", ] @@ -3017,7 +3017,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -3043,7 +3043,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[package]] name = "equivalent" @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=57c8c8d48819e98d483e65a623c1a1b77a7091d3#57c8c8d48819e98d483e65a623c1a1b77a7091d3" +source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -10762,14 +10762,14 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=5dded1756441dfcc6d84ab43be370df2d89843b7#5dded1756441dfcc6d84ab43be370df2d89843b7" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" diff --git a/Cargo.toml b/Cargo.toml index c00cdc10bf..1dfeb423a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,25 +193,25 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -emath = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "5dded1756441dfcc6d84ab43be370df2d89843b7" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 6947954a79..7f84c95338 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "57c8c8d48819e98d483e65a623c1a1b77a7091d3", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 29758d7de0..6dafe7147a 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "57c8c8d48819e98d483e65a623c1a1b77a7091d3"; +const REV: &str = "27c2cbf821ccf3842f789484f0234460cfcd07a6"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 267b55bfa52697d6437c9a908053d1c390304c2c Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 13:40:19 +0100 Subject: [PATCH 087/264] Read retained paint chunks in UI label tests Collect painted swatch labels from retained paint chunks as well as flat shapes. Keep the localized-label and physical pointer assertions unchanged in scope. --- crates/ui-egui/src/panels/library_panel/tests.rs | 14 ++++++-------- crates/ui-egui/src/tests/labels.rs | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/panels/library_panel/tests.rs b/crates/ui-egui/src/panels/library_panel/tests.rs index 272ffc1df8..a08ea664f8 100644 --- a/crates/ui-egui/src/panels/library_panel/tests.rs +++ b/crates/ui-egui/src/panels/library_panel/tests.rs @@ -767,14 +767,12 @@ fn built_in_library_swatches_are_listed_in_the_ui_language() { let panel = shown(&app); app.run("ui.libraryPanel", json!({"panel": panel, "view": "smallList"})).unwrap(); let draw = |app: &mut VectorcraftApp, ui: &mut Ui| show(app, ui, &panel); - let mut texts = vec![]; - for _ in 0..2 { - let out = draw_frame(&mut app, &ctx, &draw, vec![]); - texts = - out.shapes.iter().filter_map(|c| if let egui::Shape::Text(t) = &c.shape { Some(t.galley.text().to_string()) } else { None }).collect(); - } - assert!(texts.iter().any(|t| t == "Argile") && texts.iter().any(|t| t == "Argile 1"), "{texts:?}"); - assert!(!texts.iter().any(|t| t == "Clay" || t == "Clay 1"), "{texts:?}"); + draw_frame(&mut app, &ctx, &draw, vec![]); + let out = draw_frame(&mut app, &ctx, &draw, vec![]); + let painted = crate::tests_labels::shapes_text(&out); + let texts: Vec<_> = painted.lines().collect(); + assert!(texts.contains(&"Argile") && texts.contains(&"Argile 1"), "{texts:?}"); + assert!(!texts.contains(&"Clay") && !texts.contains(&"Clay 1"), "{texts:?}"); let lib = SwatchLibraries::get(&app, "earth-tones").unwrap().1; // The browser's Find matches the shown name and the stored one. let rows = SwatchLibraries::rows(&lib, "earth-tones"); diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index 70cd282490..7213bc8b4a 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -34,6 +34,7 @@ pub(crate) fn shapes_text(out: &egui::FullOutput) -> String { out.push('\n'); } Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), + Shape::PaintChunk(shapes) => shapes.iter().for_each(|clipped| collect(&clipped.shape, out)), _ => {} } } From dd93247cbf4a8773ab0f3cad35f4fb2236a9aa38 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 04:41:14 -0800 Subject: [PATCH 088/264] Scripts: tests index page items topmost first and check the preset fallback Cause of the script_dom and script_dom_paths failures: main's 9872e6b6795 ("page items report their own members, and lists start with the topmost object") made pageItems, pathItems and the selection list art topmost first. The branch's tests still indexed the objects bottom first, so pageItems[1] and pathItems[0] named the other object. The tests now make the objects in the order the lists read them, and index them topmost first. The own-members test asked about rotate, which this branch makes available, so it now asks about transform, which is not available yet. The fallback test for addDocument relied on five 1,000,000 pt artboards not fitting, but a new DocumentPreset puts them in one column. It now unsets the layout so the built-in preset puts them in one row, and the test fails when addDocument falls back to the saved preset of the same name. --- crates/engine/src/tests/script_dom.rs | 15 +++++++++++---- crates/engine/src/tests/script_dom_paths.rs | 8 +++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 15a1ee1320..5d6b14da3b 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1081,10 +1081,11 @@ fn selecting_an_item_keeps_the_direct_selected_anchors_of_others() { s.execute("select.add", &json!({"ids": [b.0]})).unwrap(); let anchors = s.active().unwrap().selection.anchors.clone(); assert!(anchors.contains_key(&a)); - log(&mut s, "app.activeDocument.pageItems[1].selected = false;"); + // Lists start with the topmost object, so `b` is `pageItems[0]`. + log(&mut s, "app.activeDocument.pageItems[0].selected = false;"); let sel = &s.active().unwrap().selection; assert_eq!((sel.objects.clone(), sel.anchors.clone()), (vec![a], anchors.clone())); - log(&mut s, "app.activeDocument.pageItems[1].selected = true;"); + log(&mut s, "app.activeDocument.pageItems[0].selected = true;"); let sel = &s.active().unwrap().selection; assert_eq!((sel.objects.clone(), sel.anchors.get(&a)), (vec![a, b], anchors.get(&a))); } @@ -1506,7 +1507,13 @@ fn document_preset_applies_only_its_given_fields() { assert_eq!(s.documents().len(), 2, "a refused preset makes no document"); // A saved preset with the built-in preset's name does not make the refused settings fit. s.execute("file.newPresets.save", &json!({"name": "Letter", "artboardLayout": "column"})).unwrap(); - let e = failure(&mut s, "var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5; app.documents.addDocument('Print', p);"); + // With the layout unset, the built-in preset puts the five 1,000,000 pt artboards in one row, + // which does not fit, while the saved preset would put them in one column. + let e = failure( + &mut s, + "var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5;\ + p.artboardLayout = undefined; p.artboardRowsOrCols = undefined; app.documents.addDocument('Print', p);", + ); assert!(e.contains("don't fit"), "{e}"); assert_eq!(s.documents().len(), 2, "settings the built-in preset refuses make no document"); } @@ -2181,7 +2188,7 @@ fn page_items_report_their_available_members_as_their_own() { vc.log([p.hasOwnProperty('opacity'), p.hasOwnProperty('typename'), p.hasOwnProperty('duplicate'),\ Object.prototype.hasOwnProperty.call(p, 'name'), p.propertyIsEnumerable('opacity'), d.hasOwnProperty('selection'),\ app.hasOwnProperty('activeDocument')]);\ - vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('rotate'), d.hasOwnProperty('layers'),\ + vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('transform'), d.hasOwnProperty('layers'),\ p.hasOwnProperty('nosuch'), p.hasOwnProperty('hasOwnProperty'), p.hasOwnProperty('constructor')]);\ vc.log([keys.indexOf('opacity') >= 0, keys.indexOf('typename') >= 0, keys.indexOf('duplicate'), keys.indexOf('isIsolated')]);", ); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index fe02779654..ddf2b6188f 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -26,12 +26,13 @@ fn rect(s: &mut Session, x: f64, y: f64, w: f64, h: f64) -> NodeId { NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": y, "width": w, "height": h})).unwrap()["id"].as_u64().unwrap()) } -/// A 400 × 300 pt document with two rectangles. +/// A 400 × 300 pt document with two rectangles, `a` above `b`. Lists start with the topmost +/// object, so `a` is `pathItems[0]` and `b` is `pathItems[1]`. fn doc() -> (Session, NodeId, NodeId) { let mut s = Session::new(); s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); - let a = rect(&mut s, 10.0, 20.0, 30.0, 40.0); let b = rect(&mut s, 100.0, 100.0, 50.0, 50.0); + let a = rect(&mut s, 10.0, 20.0, 30.0, 40.0); s.execute("select.none", &json!({})).unwrap(); (s, a, b) } @@ -880,7 +881,8 @@ fn locked_paths_and_wrong_objects_are_refused() { } assert_eq!(art(&s), before); s.execute("text.create", &json!({"x": 10, "y": 250, "text": "hi"})).unwrap(); - let e = failure(&mut s, "var t = app.activeDocument.pageItems[2]; Object.getOwnPropertyDescriptor(PathItem.prototype, 'closed').get.call(t);"); + // The text is the topmost object, and lists start with the topmost object. + let e = failure(&mut s, "var t = app.activeDocument.pageItems[0]; Object.getOwnPropertyDescriptor(PathItem.prototype, 'closed').get.call(t);"); assert!(e.contains("not a PathItem"), "{e}"); let e = failure(&mut s, "Object.getOwnPropertyDescriptor(PathPoint.prototype, 'anchor').get.call({});"); assert!(e.contains("not a PathPoint"), "{e}"); From 98a8cda0273b79dbd66fda2846c733b943b88a16 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 14:25:08 +0100 Subject: [PATCH 089/264] Track retained paint in VectorCraft menu and readout tests Keep the existing pointer and text expectations on composed paint output. Preserve paint order and apply the retained transforms and clipping when finding drawn controls. --- crates/ui-egui/src/tests/labels.rs | 35 ++++++---- crates/ui-egui/src/tests/selectall.rs | 21 +++--- crates/ui-egui/src/tests/slices.rs | 8 +-- crates/ui-egui/src/tests/trace_runs.rs | 9 +-- .../tests/image_trace_ignore_sampler.rs | 1 + crates/ui-egui/tests/panel_readout_copy.rs | 64 ++++++++++--------- 6 files changed, 69 insertions(+), 69 deletions(-) diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index 7213bc8b4a..ea2a08be62 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -25,22 +25,33 @@ pub(crate) fn painted_text(app: &mut VectorcraftApp, mut f: impl FnMut(&mut Vect shapes_text(&out) } -/// Every string a frame painted, one per line. -pub(crate) fn shapes_text(out: &egui::FullOutput) -> String { - fn collect(s: &Shape, out: &mut String) { - match s { - Shape::Text(t) => { - out.push_str(t.galley.text()); - out.push('\n'); - } - Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), - Shape::PaintChunk(shapes) => shapes.iter().for_each(|clipped| collect(&clipped.shape, out)), +/// Text shapes in paint order, with their composed window transform. +pub(crate) fn text_shapes(out: &egui::FullOutput) -> Vec<(&egui::epaint::TextShape, egui::emath::TSTransform)> { + use egui::emath::TSTransform; + + fn collect<'a>(shape: &'a Shape, transform: TSTransform, out: &mut Vec<(&'a egui::epaint::TextShape, TSTransform)>) { + match shape { + Shape::Text(text) => out.push((text, transform)), + Shape::Vec(shapes) => shapes.iter().for_each(|shape| collect(shape, transform, out)), + Shape::PaintChunk(shapes) => shapes.iter().for_each(|clipped| { + collect(&clipped.shape, transform * clipped.transform_after_tessellation, out); + }), _ => {} } } + let mut text = Vec::new(); + for clipped in &out.shapes { + collect(&clipped.shape, clipped.transform_after_tessellation, &mut text); + } + text +} + +/// Every string a frame painted, one per line. +pub(crate) fn shapes_text(out: &egui::FullOutput) -> String { let mut text = String::new(); - for c in &out.shapes { - collect(&c.shape, &mut text); + for (shape, _) in text_shapes(out) { + text.push_str(shape.galley.text()); + text.push('\n'); } text } diff --git a/crates/ui-egui/src/tests/selectall.rs b/crates/ui-egui/src/tests/selectall.rs index ed97ffcdb7..d7ae5f9b04 100644 --- a/crates/ui-egui/src/tests/selectall.rs +++ b/crates/ui-egui/src/tests/selectall.rs @@ -297,13 +297,11 @@ fn the_clipboard_keys_in_a_focused_field_edit_its_text() { /// The rectangle of the text `text` painted last in a frame's output. fn text_rect(out: &egui::FullOutput, text: &str) -> Rect { - out.shapes - .iter() + crate::tests_labels::text_shapes(out) + .into_iter() .rev() - .find_map(|s| match &s.shape { - egui::Shape::Text(t) if t.galley.text() == text => Some(t.galley.rect.translate(t.pos.to_vec2())), - _ => None, - }) + .find(|(shape, ..)| shape.galley.text() == text) + .map(|(shape, transform)| transform * shape.galley.rect.translate(shape.pos.to_vec2())) .unwrap_or_else(|| panic!("no {text:?} painted")) } @@ -567,12 +565,11 @@ fn panel_text_copied_before_the_art_formats_are_written_stays_on_the_clipboard() /// The centre of the text `label` painted last (in the topmost layer) in a frame's output; with /// `title`, the first one painted (the menu bar's). fn text_at(out: &egui::FullOutput, label: &str, title: bool) -> Pos2 { - let mut shapes: Box> = if title { Box::new(out.shapes.iter()) } else { Box::new(out.shapes.iter().rev()) }; - shapes - .find_map(|s| match &s.shape { - egui::Shape::Text(t) if t.galley.text().trim() == label => Some(Rect::from_min_size(t.pos, t.galley.size()).center()), - _ => None, - }) + let shapes = crate::tests_labels::text_shapes(out); + let label_matches = |(shape, _): &(&egui::epaint::TextShape, egui::emath::TSTransform)| shape.galley.text().trim() == label; + let found = if title { shapes.into_iter().find(label_matches) } else { shapes.into_iter().rev().find(label_matches) }; + found + .map(|(shape, transform)| transform * Rect::from_min_size(shape.pos, shape.galley.size()).center()) .unwrap_or_else(|| panic!("no {label:?} painted")) } diff --git a/crates/ui-egui/src/tests/slices.rs b/crates/ui-egui/src/tests/slices.rs index c1c8244084..fe0999262d 100644 --- a/crates/ui-egui/src/tests/slices.rs +++ b/crates/ui-egui/src/tests/slices.rs @@ -18,13 +18,7 @@ fn frame_texts(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec { let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| crate::canvas::show(app, ui)); out.textures_delta.clear(); - out.shapes - .iter() - .filter_map(|c| match &c.shape { - egui::Shape::Text(t) => Some(t.galley.text().to_string()), - _ => None, - }) - .collect() + crate::tests_labels::text_shapes(&out).into_iter().map(|(shape, _)| shape.galley.text().to_string()).collect() } #[test] diff --git a/crates/ui-egui/src/tests/trace_runs.rs b/crates/ui-egui/src/tests/trace_runs.rs index 17a92f9785..48da48aad2 100644 --- a/crates/ui-egui/src/tests/trace_runs.rs +++ b/crates/ui-egui/src/tests/trace_runs.rs @@ -77,14 +77,7 @@ fn undos(app: &VectorcraftApp) -> usize { fn progress(app: &mut VectorcraftApp, ctx: &egui::Context, time: f64) -> String { let mut out = ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| export_progress::show(app, ui)); out.textures_delta.clear(); - let mut texts = String::new(); - for shape in out.shapes { - if let egui::epaint::Shape::Text(t) = shape.shape { - texts.push_str(t.galley.text()); - texts.push('\n'); - } - } - texts + crate::tests_labels::shapes_text(&out) } /// Object › Image Trace › Make traces in the background, the status bar saying so, and its result is diff --git a/crates/ui-egui/tests/image_trace_ignore_sampler.rs b/crates/ui-egui/tests/image_trace_ignore_sampler.rs index 2433e8d0b3..f9e6bff2ed 100644 --- a/crates/ui-egui/tests/image_trace_ignore_sampler.rs +++ b/crates/ui-egui/tests/image_trace_ignore_sampler.rs @@ -999,6 +999,7 @@ fn review_preset_assert_shown(app: &mut VectorcraftApp, ctx: &egui::Context, pre match shape { egui::Shape::Text(drawn) => out.push(drawn.galley.text().to_string()), egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| texts(shape, out)), + egui::Shape::PaintChunk(shapes) => shapes.iter().for_each(|clipped| texts(&clipped.shape, out)), _ => {} } } diff --git a/crates/ui-egui/tests/panel_readout_copy.rs b/crates/ui-egui/tests/panel_readout_copy.rs index e3145401ae..7c65f085e6 100644 --- a/crates/ui-egui/tests/panel_readout_copy.rs +++ b/crates/ui-egui/tests/panel_readout_copy.rs @@ -175,35 +175,44 @@ fn copies(out: &egui::FullOutput) -> Vec { out.platform_output.commands.iter().filter_map(|c| if let egui::OutputCommand::CopyText(s) = c { Some(s.clone()) } else { None }).collect() } -fn text_shape<'a>(shape: &'a Shape, text: &str) -> Option<&'a egui::epaint::TextShape> { - match shape { - Shape::Text(t) if t.galley.text() == text => Some(t), - Shape::Vec(v) => v.iter().rev().find_map(|s| text_shape(s, text)), - _ => None, +fn visible_paint(out: &egui::FullOutput) -> Vec<(&egui::epaint::TextShape, Rect, Pos2)> { + use egui::emath::TSTransform; + + fn collect<'a>(shape: &'a Shape, transform: TSTransform, clip: Rect, text: &mut Vec<(&'a egui::epaint::TextShape, Rect, Pos2)>) { + match shape { + Shape::Text(t) => { + let drawn = transform * t.galley.rect.translate(t.pos.to_vec2()); + let bounds = drawn.intersect(clip); + if bounds.is_positive() { + text.push((t, bounds, drawn.center())); + } + } + Shape::Vec(v) => v.iter().for_each(|s| collect(s, transform, clip, text)), + Shape::PaintChunk(v) => v.iter().for_each(|s| { + collect(&s.shape, transform * s.transform_after_tessellation, clip.intersect(transform * s.clip_rect), text); + }), + _ => {} + } } + + let mut text = Vec::new(); + for s in &out.shapes { + collect(&s.shape, s.transform_after_tessellation, s.clip_rect, &mut text); + } + text } fn painted(out: &egui::FullOutput, text: &str) -> (Rect, bool) { - out.shapes - .iter() + visible_paint(out) + .into_iter() .rev() - .find_map(|s| { - let t = text_shape(&s.shape, text)?; - let r = t.galley.rect.translate(t.pos.to_vec2()); - s.clip_rect.intersects(r).then_some((r.intersect(s.clip_rect), t.galley.elided)) - }) + .find(|(shape, ..)| shape.galley.text() == text) + .map(|(shape, bounds, _)| (bounds, shape.galley.elided)) .unwrap_or_else(|| panic!("fixture: no visible actual readout {text:?}")) } fn visible_text_count(out: &egui::FullOutput, text: &str) -> usize { - fn count(shape: &Shape, clip: Rect, text: &str) -> usize { - match shape { - Shape::Text(t) if t.galley.text() == text => usize::from(t.galley.rect.translate(t.pos.to_vec2()).intersect(clip).is_positive()), - Shape::Vec(v) => v.iter().map(|s| count(s, clip, text)).sum(), - _ => 0, - } - } - out.shapes.iter().map(|s| count(&s.shape, s.clip_rect, text)).sum() + visible_paint(out).into_iter().filter(|(shape, ..)| shape.galley.text() == text).count() } fn copy_at(a: &mut App, at: Pos2, value: &str) -> egui::FullOutput { @@ -626,15 +635,10 @@ fn location_node_rect(node: &egui::accesskit::Node) -> Rect { Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32)) } -fn shortened_location(shape: &Shape, rect: Rect, full: &str) -> bool { - match shape { - Shape::Text(t) => { - let painted = t.galley.rect.translate(t.pos.to_vec2()); - rect.contains(painted.center()) && t.galley.text().contains('…') && t.galley.text() != full - } - Shape::Vec(shapes) => shapes.iter().any(|s| shortened_location(s, rect, full)), - _ => false, - } +fn shortened_location(out: &egui::FullOutput, rect: Rect, full: &str) -> bool { + visible_paint(out) + .into_iter() + .any(|(shape, bounds, center)| rect.contains(center) && bounds.contains(center) && shape.galley.text().contains('…') && shape.galley.text() != full) } #[test] @@ -722,7 +726,7 @@ fn panel_readout_long_location_fits_and_copies_by_pointer_accessibility_and_keyb let location_rect = location_node_rect(node); assert!(body.contains_rect(location_rect), "{locale}: the fitted Location remains inside the panel"); assert!( - out.shapes.iter().any(|s| shortened_location(&s.shape, location_rect, location)), + shortened_location(&out, location_rect, location), "{locale}: the long path must actually be shortened on screen" ); let buttons: Vec<_> = From 7a71837deac9f323eeb80fcf8b10ea481e2a7a43 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 05:51:46 -0800 Subject: [PATCH 090/264] Scripts: keep new-art defaults and direct selections through path edits - PathPoint.remove() renumbers the direct-selected anchors and segments after the removed point, and drops the removed anchor and the selected segments it ended, through selection commands after the points are written. A removed anchor no longer stays selected, and the same index no longer selects a different point. - pathItems.add() reads new art's paint after the target document is active, so a path added to a document in the back keeps the stroke that document's selection gives new art. - Paths a script draws put new art's paint back afterwards, so a defaultStrokeWidth the script set applies to every path it draws, not only the first. - appearance.setNewArt refuses a fill or stroke paint with a setting a paint does not take, such as opacity, instead of applying the rest. --- crates/engine/src/cmd/newart.rs | 5 + crates/engine/src/script/dom/paths.rs | 117 ++++++++++++++++---- crates/engine/src/tests/newart.rs | 3 + crates/engine/src/tests/script_dom_paths.rs | 56 ++++++++++ 4 files changed, 157 insertions(+), 24 deletions(-) diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index c7398db1da..f420054d11 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -72,6 +72,8 @@ pub fn specs() -> Vec { /// The most dash and gap lengths `appearance.setNewArt` takes. const MAX_DASHES: usize = 64; +/// The settings a `fill` or `stroke` paint of `appearance.setNewArt` takes. +const PAINT_KEYS: [&str; 6] = ["color", "none", "swatch", "tint", "gradient", "keepModel"]; /// The largest dash, gap or dash offset `appearance.setNewArt` takes, in points. const MAX_DASH_LENGTH: f64 = 1_000_000.0; @@ -116,6 +118,9 @@ fn set_new_art(s: &mut Session, p: &Value) -> Result { if !v.is_object() { return Err(bad(C, format!("{key} must be a paint object (color, none, swatch or gradient), got {v}"))); } + if let Some(k) = v.as_object().and_then(|o| o.keys().find(|k| !PAINT_KEYS.contains(&k.as_str()))) { + return Err(bad(C, format!("{key}: unknown setting `{k}` (a paint takes {})", PAINT_KEYS.join(", ")))); + } if v.get("swatch").is_some_and(|w| !w.is_string()) { return Err(bad(C, format!("{key}: `swatch` must be a swatch name"))); } diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index e9510871c4..27b449a5b9 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -459,14 +459,18 @@ fn made_id(r: &Value) -> std::result::Result { } /// Runs the command `id` that makes a path in `doc` on top of the active layer, the selection kept, -/// and reverses the new path's direction when `reversed`. → the new path. +/// and reverses the new path's direction when `reversed`. → the new path. Selecting the new path +/// and putting the selection back load the selected objects' paint and stroke width into new art, +/// so new art's paint from before, the defaults a script set included, is put back. fn make(h: &super::Host, doc: Doc, id: &str, params: &Value, reversed: bool) -> Answer { - let made = on_doc(h, doc.uid, true, |h| { - let id = made_id(&drawing_normally(h, || command_value(h, id, params))?.1)?; - if reversed { - command(h, "path.reverse", &json!({"ids": [id.0]}))?; - } - Ok(id) + let made = keeping_paint(h, || { + on_doc(h, doc.uid, true, |h| { + let id = made_id(&drawing_normally(h, || command_value(h, id, params))?.1)?; + if reversed { + command(h, "path.reverse", &json!({"ids": [id.0]}))?; + } + Ok(id) + }) })?; let s = h.session.borrow(); let st = s.documents().iter().find(|d| d.uid == doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; @@ -616,22 +620,23 @@ fn items_star(h: &super::Host, a: &[Data]) -> Answer { /// path is set back to none in the same step, and new art keeps the paint it had before. fn items_add(h: &super::Host, a: &[Data]) -> Answer { let doc = items_doc(h, a)?; - let add = |h: &super::Host, unpainted: bool| { + // New art's paint is read with the document active, since activating a document can load its + // selection's appearance into new art. Selecting the new path loads its temporary stroke into + // new art, and putting the selection back does not undo that, so new art's paint from before + // the path is put back. + let made = keeping_paint(h, || { on_doc(h, doc.uid, true, |h| { + let unpainted = { + let ap = h.session.borrow().new_art(); + ap.fill_paint().is_none() && ap.stroke_paint().is_none() + }; let id = made_id(&drawing_normally(h, || command_value(h, "path.create", &json!({"d": ""})))?.1)?; if unpainted { command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0]}))?; } Ok(id) }) - }; - let unpainted = { - let ap = h.session.borrow().new_art(); - ap.fill_paint().is_none() && ap.stroke_paint().is_none() - }; - // Selecting the new path loads its temporary stroke into new art, and putting the selection - // back does not undo that, so new art's paint from before the path is put back. - let made = if unpainted { keeping_paint(h, || add(h, true))? } else { add(h, false)? }; + })?; let s = h.session.borrow(); let st = s.documents().iter().find(|d| d.uid == doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; Ok(super::item_ref(h, st, made)) @@ -1652,20 +1657,84 @@ fn path_selected_points(h: &super::Host, a: &[Data]) -> Answer { /// `remove()`: deletes the point; a subpath left with no points goes too. fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { let (item, i) = this_point(h, a)?; - edit_points(h, item, |subs| { - if let Some((s, j)) = locate(subs, i) - && let Some(sp) = subs.get_mut(s) - { - sp.anchors.remove(j); - if sp.anchors.is_empty() { - subs.remove(s); - } + // A direct selection of the path's points is renumbered after the removal. + let selected = { + let s = h.session.borrow(); + let st = s.documents().iter().find(|d| d.uid == item.doc.uid).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + let sel = &st.selection; + (sel.anchors.contains_key(&item.id) || sel.segments.contains_key(&item.id)).then(|| sel.clone()) + }; + let removed = edit_points(h, item, |subs| { + let (s, j) = locate(subs, i)?; + let sp = subs.get_mut(s)?; + // The segment that closes a closed subpath ends at its first anchor. + let closing = (sp.closed && j == 0).then(|| sp.anchors.len() - 1); + sp.anchors.remove(j); + let gone = sp.anchors.is_empty(); + if gone { + subs.remove(s); } + Some((s, j, gone, closing)) })?; + if let (Some((s, j, gone, closing)), Some(mut sel)) = (removed, selected) { + // The points are written first, and the selection is then set with selection commands, + // which the journal records with the edit. + flush(h)?; + renumber_selected(&mut sel, item.id, s, j, gone, closing); + on_doc(h, item.doc.uid, false, |h| { + let doc = h.session.borrow().active().map(|st| st.doc.clone()).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + super::restore_selection(h, &doc, &sel) + })?; + } cut_points(h, item); Ok(Data::Undefined) } +/// Updates the direct selection `sel` of the path `id` after the anchor `j` of its subpath `s` was +/// removed, and the subpath with it when `gone`: the anchor, the segments it ended and their other +/// ends leave the selection, unless a segment still selected ends there, and the anchors, segments +/// and subpaths after it keep the points they selected. `closing` is the segment that closed the +/// subpath at the removed anchor, when it did. +fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: usize, gone: bool, closing: Option) { + // An anchor (or a segment, by its first anchor) after the removed one moves down one place. + let shift = |(p, k): (usize, usize), segment: bool| -> Option<(usize, usize)> { + match p.cmp(&s) { + std::cmp::Ordering::Less => Some((p, k)), + std::cmp::Ordering::Greater => Some((if gone { p - 1 } else { p }, k)), + std::cmp::Ordering::Equal if gone => None, + std::cmp::Ordering::Equal if k == j || (segment && (k + 1 == j || closing == Some(k))) => None, + std::cmp::Ordering::Equal => Some((p, if k > j { k - 1 } else { k })), + } + }; + // The other ends of the selected segments that the removal joins, in the new numbering: the + // anchor before the removed one and the one after it. + let mut ends: Vec<(usize, usize)> = Vec::new(); + if let Some(segments) = sel.segments.get_mut(&id) { + let cut: Vec<(usize, usize)> = segments.iter().copied().filter(|g| shift(*g, true).is_none() && g.0 == s && !gone).collect(); + for (p, k) in cut { + // Segment k runs from anchor k to anchor k + 1; one of the two is the removed one. + let other = if k == j { k + 1 } else { k }; + // The closing segment's other end is its first anchor, the old last one. + let other = if closing == Some(k) { k } else { other }; + ends.extend(shift((p, other), false)); + } + *segments = segments.iter().filter_map(|g| shift(*g, true)).collect(); + if segments.is_empty() { + sel.segments.remove(&id); + } + } + let kept_ends: Vec<(usize, usize)> = + sel.segments.get(&id).map(|g| g.iter().flat_map(|(p, k)| [(*p, *k), (*p, k + 1)]).collect()).unwrap_or_default(); + if let Some(anchors) = sel.anchors.get_mut(&id) { + *anchors = anchors.iter().filter_map(|a| shift(*a, false)).filter(|a| !ends.contains(a) || kept_ends.contains(a)).collect(); + } + if let Some((key, a)) = sel.key_anchor + && key == id + { + sel.key_anchor = shift(a, false).filter(|a| sel.anchors.get(&id).is_some_and(|set| set.contains(a))).map(|a| (key, a)); + } +} + // ---- Registration ---- /// The members `PathItem` adds to `PageItem`'s. diff --git a/crates/engine/src/tests/newart.rs b/crates/engine/src/tests/newart.rs index a19f5ff6ab..6737666046 100644 --- a/crates/engine/src/tests/newart.rs +++ b/crates/engine/src/tests/newart.rs @@ -429,6 +429,9 @@ fn set_new_art_refuses_bad_values_with_nothing_changed() { json!({"stroke": {"tint": 50, "color": "#000000"}}), json!({"fillOverprint": "yes"}), json!({"widht": 3}), + // A setting a paint does not take, here or nested in it, is refused too. + json!({"fill": {"color": "#ff0000", "opacity": 25}}), + json!({"stroke": {"none": true, "weight": 2}}), ] { assert!(s.execute("appearance.setNewArt", ¶ms).is_err(), "accepted {params}"); assert_eq!(s.paint, before, "changed new art for {params}"); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index ddf2b6188f..d33246aba7 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -753,6 +753,62 @@ fn an_added_path_leaves_new_art_unpainted_with_basic_appearance_off() { assert_eq!(s.paint, paint, "new art keeps no fill and no stroke"); } +/// With Basic Appearance off, a path added to a document in the back takes the appearance of that +/// document's selection, which its activation loads into new art, even when new art in the +/// document in front has no paint. +#[test] +fn a_path_added_to_a_document_in_the_back_keeps_that_documents_stroke() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.prefs.new_art_basic = false; + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + s.prefs.new_art_basic = true; + s.execute("paint.setFill", &json!({"none": true})).unwrap(); + s.execute("paint.setStroke", &json!({"none": true})).unwrap(); + s.prefs.new_art_basic = false; + assert!(s.new_art().stroke_paint().is_none()); + let out = log(&mut s, "var d = app.documents[1]; var n = d.pathItems.add(); vc.log(n.stroked); vc.log(app.activeDocument == d);"); + assert_eq!(out, [json!(true), json!(false)]); +} + +/// Drawing a path and putting the selection back keep the defaults a script set, so a second +/// path gets them too. +#[test] +fn every_path_a_script_draws_gets_its_default_stroke_width() { + let (mut s, a, _) = doc(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + let out = log( + &mut s, + "var d = app.activeDocument; d.defaultStrokeWidth = 7;\ + var r1 = d.pathItems.rectangle(10, 10, 5, 5), r2 = d.pathItems.rectangle(20, 20, 5, 5);\ + vc.log([r1.strokeWidth, r2.strokeWidth, d.defaultStrokeWidth]);", + ); + assert_eq!(out, [json!([7, 7, 7])]); +} + +/// Removing a point renumbers the direct-selected anchors after it, and a removed selected anchor +/// leaves the selection. +#[test] +fn removing_a_point_keeps_the_direct_selection_on_the_same_anchors() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 3]]}], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[3].remove();"); + // A path left with no selected anchor leaves the selection, as `select.anchorsMany` leaves it. + assert_eq!(selected_anchors(&s, a), None, "the removed anchor is not selected"); + assert!(!s.active().unwrap().selection.objects.contains(&a)); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 2]]}], "mode": "set"})).unwrap(); + let at = node(&s, a).path_data().unwrap().subpaths[0].anchors[2].p; + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[0].remove();"); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1)]), "the selected anchor moved down one place"); + assert_eq!(node(&s, a).path_data().unwrap().subpaths[0].anchors[1].p, at); + // A selected segment that the removal joins leaves the selection with its other end. + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 0]], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[1].remove();"); + assert_eq!(selected_anchors(&s, a), None, "the segment's other end is not selected"); + assert!(!s.active().unwrap().selection.objects.contains(&a)); +} + /// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke. fn doc_with_paints() -> (Session, NodeId) { let (mut s, a, _) = doc(); From fa1c0a8dc4d84ffa1050996e54cf88589f96ce29 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:01:24 -0800 Subject: [PATCH 091/264] Tests: read retained paint chunks in every ui-egui shape walk The pinned egui replays a region that did not change as one Shape::PaintChunk of clipped shapes. Test helpers that walked out.shapes by hand stopped at the chunk, so text, meshes, rects and lines painted inside it were missed. - Add painted_shapes and flat_painted_shapes next to text_shapes in tests/labels.rs. They open Shape::Vec and Shape::PaintChunk in paint order and compose each shape's transform and clip the same way. - Route every remaining hand-written text and shape walk in the ui-egui tests through text_shapes or these helpers, keeping each test's assertions and its first-painted or last-painted order. - panel_readout_copy: the Link Info Name check called the removed text_shape helper and did not compile; it now reads visible_paint. Format the file. --- crates/ui-egui/src/canvas/panes/tests.rs | 28 +++++----------- crates/ui-egui/src/canvas/tests.rs | 13 ++------ crates/ui-egui/src/chrome/tests.rs | 12 +------ crates/ui-egui/src/dialogs/new_document.rs | 13 +++----- crates/ui-egui/src/dialogs/tests_screens.rs | 30 +++++++---------- .../src/dialogs/tracing_presets/tests.rs | 19 ++++------- crates/ui-egui/src/doc_windows/tests.rs | 12 ++----- crates/ui-egui/src/export_progress.rs | 8 ++--- crates/ui-egui/src/menus/tests.rs | 16 +++------ crates/ui-egui/src/opening/tests.rs | 8 ++--- .../ui-egui/src/panel_docking/native_tests.rs | 13 +++----- crates/ui-egui/src/panel_docking/tests.rs | 9 +++-- crates/ui-egui/src/panels/tests_appearance.rs | 16 +++------ .../src/panels/tests_brush_libraries.rs | 11 +------ .../src/panels/tests_style_libraries.rs | 11 +------ .../src/panels/tests_symbol_libraries.rs | 11 +------ crates/ui-egui/src/placing/tests.rs | 8 ++--- crates/ui-egui/src/prefs_dialog/tests.rs | 2 +- crates/ui-egui/src/tests/background.rs | 11 +------ crates/ui-egui/src/tests/dialog_layout.rs | 14 +++----- crates/ui-egui/src/tests/document_drag.rs | 13 +++----- crates/ui-egui/src/tests/labels.rs | 33 +++++++++++++++++++ crates/ui-egui/src/tests/panel_harness.rs | 10 ++---- crates/ui-egui/src/tests/picks.rs | 14 +++----- crates/ui-egui/src/tests/removeanchors.rs | 6 ++-- crates/ui-egui/src/tests/retype_runs.rs | 8 ++--- crates/ui-egui/src/tests/ruler_origin.rs | 14 +++----- crates/ui-egui/src/tests/script_run.rs | 12 ++----- crates/ui-egui/src/tests/scrub.rs | 12 +++---- crates/ui-egui/src/toolbar/tests.rs | 28 +++++----------- crates/ui-egui/tests/panel_readout_copy.rs | 22 +++++-------- 31 files changed, 147 insertions(+), 290 deletions(-) diff --git a/crates/ui-egui/src/canvas/panes/tests.rs b/crates/ui-egui/src/canvas/panes/tests.rs index 4464e67326..d5c13920ef 100644 --- a/crates/ui-egui/src/canvas/panes/tests.rs +++ b/crates/ui-egui/src/canvas/panes/tests.rs @@ -38,20 +38,12 @@ fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec /// [`frame`] on a window `size` points large. fn frame_in(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec, size: egui::Vec2) -> Vec { - fn flat(s: Shape, out: &mut Vec) { - match s { - Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)), - s => out.push(s), - } - } let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, size)), max_texture_side: Some(8192), events, ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| app.canvas_area(ui)); // A pane's picture is uploaded once, maybe in this frame: [`wait_ready`] finds it later. note_uploads(&mut out.textures_delta); - let mut shapes = vec![]; - out.shapes.into_iter().for_each(|c| flat(c.shape, &mut shapes)); - shapes + crate::tests_labels::flat_painted_shapes(&out.shapes) } /// A texture's picture: its pixels and size. @@ -627,15 +619,10 @@ fn art_carried_through_a_tab_drops_into_a_third_documents_pane() { // A tab's title starts with its document's name (an inactive tab shows the name alone). let names: Vec = app.session.documents().iter().map(|d| d.title()).collect(); let titles = |out: egui::FullOutput| -> Vec { - let mut t: Vec<_> = out - .shapes - .iter() - .filter_map(|s| match &s.shape { - Shape::Text(t) if names.iter().any(|n| t.galley.text().starts_with(n.as_str())) => { - Some(egui::Rect::from_min_size(t.pos, t.galley.size())) - } - _ => None, - }) + let mut t: Vec<_> = crate::tests_labels::text_shapes(&out) + .into_iter() + .filter(|(t, _)| names.iter().any(|n| t.galley.text().starts_with(n.as_str()))) + .map(|(t, transform)| transform * egui::Rect::from_min_size(t.pos, t.galley.size())) .collect(); t.sort_by(|a, b| a.left().total_cmp(&b.left())); t @@ -1002,14 +989,15 @@ fn other_panes_draw_through_their_documents_profiles() { let fills = |out: &egui::FullOutput, rgb: [u8; 3]| { fn any(s: &Shape, f: &dyn Fn(Color32) -> bool) -> bool { match s { - Shape::Vec(v) => v.iter().any(|s| any(s, f)), Shape::Path(p) => f(p.fill), Shape::Rect(r) => f(r.fill), Shape::Mesh(m) if m.texture_id == egui::TextureId::default() => m.vertices.iter().any(|v| f(v.color)), _ => false, } } - out.shapes.iter().any(|c| any(&c.shape, &|c: Color32| c.a() == 255 && near([c.r(), c.g(), c.b()], rgb))) + crate::tests_labels::painted_shapes(&out.shapes) + .into_iter() + .any(|(s, ..)| any(s, &|c: Color32| c.a() == 255 && near([c.r(), c.g(), c.b()], rgb))) }; let ctx = crate::testing::ui_context(); let raw = || egui::RawInput { diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 8b7cabc0cb..ae6956a288 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -956,17 +956,10 @@ fn shapes(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec { shapes } -/// The shapes of a frame's output, `Shape::Vec`s flattened: the canvas's picture slot holds the art's. +/// The shapes of a frame's output, `Shape::Vec`s and retained paint chunks flattened: the canvas's +/// picture slot holds the art's. fn flat_shapes(clipped: Vec) -> Vec { - fn flat(s: Shape, out: &mut Vec) { - match s { - Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)), - s => out.push(s), - } - } - let mut v = vec![]; - clipped.into_iter().for_each(|c| flat(c.shape, &mut v)); - v + crate::tests_labels::flat_painted_shapes(&clipped) } /// One headless canvas frame → the shapes drawn ([`flat_shapes`]) and the textures uploaded by it diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 8fe7f3e43f..67cc29b63f 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -3292,13 +3292,6 @@ struct StyleFace { /// The Style field of the settled bar. `textures` holds the textures the frames uploaded since the fixture began /// recording; the uploads of these frames are applied to it. fn style_face(bar: &mut Shown, textures: &mut std::collections::HashMap) -> StyleFace { - fn flat(shape: egui::Shape, out: &mut Vec) { - if let egui::Shape::Vec(shapes) = shape { - shapes.into_iter().for_each(|s| flat(s, out)); - } else { - out.push(shape); - } - } let field = bar.settle().named("Graphic Styles").rect; let mut paint = bar.fixture.take_paint().expect("the fixture records what it paints"); for (id, delta) in paint.textures_delta.set.iter().flat_map(|(id, deltas)| deltas.iter().map(move |delta| (id, delta))) { @@ -3320,10 +3313,7 @@ fn style_face(bar: &mut Shown, textures: &mut std::collections::HashMap) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect().center())), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let mut app = app(); open(&mut app); let out = laid_out(&mut app); + let drawn: Vec<(String, egui::Pos2)> = crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), (transform * t.visual_bounding_rect()).center())) + .collect(); let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default(); let bounds = |label: &str, role: egui::accesskit::Role| { let (_, n) = nodes.iter().find(|(_, n)| n.label() == Some(label) && n.role() == role).unwrap_or_else(|| panic!("no {role:?} {label}")); @@ -1104,8 +1101,6 @@ mod tests { // Artboards follows Landscape on its line, or wraps below it when the column has no room for it. assert!(landscape.x1 <= artboards.x0 || landscape.y1 <= artboards.y0, "Landscape {landscape:?} stays clear of Artboards {artboards:?}"); let group = bounds("Orientation", egui::accesskit::Role::RadioGroup); - let mut drawn = Vec::new(); - out.shapes.iter().for_each(|s| texts(&s.shape, &mut drawn)); let inside: Vec<_> = drawn .iter() .filter(|(_, at)| (group.x0..=group.x1).contains(&f64::from(at.x)) && (group.y0..=group.y1).contains(&f64::from(at.y))) diff --git a/crates/ui-egui/src/dialogs/tests_screens.rs b/crates/ui-egui/src/dialogs/tests_screens.rs index b4ae88d15a..8d5ebb9789 100644 --- a/crates/ui-egui/src/dialogs/tests_screens.rs +++ b/crates/ui-egui/src/dialogs/tests_screens.rs @@ -295,18 +295,15 @@ fn checked_artboards_read_as_a_range() { /// The rect the frame `shapes` paint `texture` over; `None` when none paints it. fn painted(shapes: &[egui::epaint::ClippedShape], texture: egui::TextureId) -> Option { - fn walk(shape: &egui::Shape, texture: egui::TextureId, out: &mut Option) { - match shape { - egui::Shape::Vec(all) => all.iter().for_each(|s| walk(s, texture, out)), - egui::Shape::Mesh(mesh) if mesh.texture_id == texture => { - let at = mesh.calc_bounds(); - *out = Some(out.map_or(at, |r| r.union(at))); - } - _ => {} + let mut out: Option = None; + for (shape, transform, _) in crate::tests_labels::painted_shapes(shapes) { + if let egui::Shape::Mesh(mesh) = shape + && mesh.texture_id == texture + { + let at = transform * mesh.calc_bounds(); + out = Some(out.map_or(at, |r| r.union(at))); } } - let mut out = None; - shapes.iter().for_each(|clipped| walk(&clipped.shape, texture, &mut out)); out } @@ -943,14 +940,11 @@ fn a_preset_export_reopens_on_its_rows() { } fn screen_text_at(out: &egui::FullOutput, label: &str) -> egui::Pos2 { - fn find(shape: &egui::Shape, label: &str) -> Option { - match shape { - egui::Shape::Text(t) if t.galley.text().trim() == label => Some(t.visual_bounding_rect().center()), - egui::Shape::Vec(v) => v.iter().find_map(|s| find(s, label)), - _ => None, - } - } - out.shapes.iter().find_map(|s| find(&s.shape, label)).unwrap_or_else(|| panic!("missing {label}: {}", crate::tests_labels::shapes_text(out))) + crate::tests_labels::text_shapes(out) + .into_iter() + .find(|(t, _)| t.galley.text().trim() == label) + .map(|(t, transform)| (transform * t.visual_bounding_rect()).center()) + .unwrap_or_else(|| panic!("missing {label}: {}", crate::tests_labels::shapes_text(out))) } /// First-directory entries of the big-endian TIFF chosen below: tag, type, count, inline value. diff --git a/crates/ui-egui/src/dialogs/tracing_presets/tests.rs b/crates/ui-egui/src/dialogs/tracing_presets/tests.rs index bfb3edf947..2cecc9332e 100644 --- a/crates/ui-egui/src/dialogs/tracing_presets/tests.rs +++ b/crates/ui-egui/src/dialogs/tracing_presets/tests.rs @@ -72,16 +72,6 @@ fn frame_texts(app: &VectorcraftApp, ctx: &egui::Context) -> Vec { /// The texts the dialogs paint with where each is drawn and its font, once they have faded in. fn frame_runs(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<(String, egui::Rect, Option)> { - fn walk(s: &egui::Shape, out: &mut Vec<(String, egui::Rect, Option)>) { - match s { - egui::Shape::Text(t) => { - let font = t.galley.job.sections.first().map(|section| section.format.font_id.clone()); - out.push((t.galley.text().to_string(), t.galley.rect.translate(t.pos.to_vec2()), font)); - } - egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)), - _ => {} - } - } let dialogs = app.dialogs().expect("a window"); let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 1200.0)); let mut texts = vec![]; @@ -89,8 +79,13 @@ fn frame_runs(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<(String, egui::R let raw = egui::RawInput { screen_rect: Some(screen), time: Some(f64::from(k) * 0.25), ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| dialogs.with(|host| host.run(ui))); out.textures_delta.clear(); - texts.clear(); - out.shapes.iter().for_each(|c| walk(&c.shape, &mut texts)); + texts = crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| { + let font = t.galley.job.sections.first().map(|section| section.format.font_id.clone()); + (t.galley.text().to_string(), transform * t.galley.rect.translate(t.pos.to_vec2()), font) + }) + .collect(); } texts } diff --git a/crates/ui-egui/src/doc_windows/tests.rs b/crates/ui-egui/src/doc_windows/tests.rs index 5033868701..4e7905cb9f 100644 --- a/crates/ui-egui/src/doc_windows/tests.rs +++ b/crates/ui-egui/src/doc_windows/tests.rs @@ -15,18 +15,10 @@ fn app_with(n: usize) -> VectorcraftApp { /// One headless frame of the canvas panel's body (the tabs and the canvas or panes) on a /// 1200 × 800 window, then the floating document windows, which egui draws inside the window, run -/// as the hosts run a frame → the shapes it drew, `Shape::Vec`s flattened. +/// as the hosts run a frame → the shapes it drew, `Shape::Vec`s and retained paint chunks flattened. fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) -> Vec { - fn flat(s: Shape, out: &mut Vec) { - match s { - Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)), - s => out.push(s), - } - } let out = run_frame(app, ctx, events); - let mut shapes = vec![]; - out.shapes.into_iter().for_each(|c| flat(c.shape, &mut shapes)); - shapes + crate::tests_labels::flat_painted_shapes(&out.shapes) } /// One headless frame of the canvas panel's body and the floating document windows on a 1200 × diff --git a/crates/ui-egui/src/export_progress.rs b/crates/ui-egui/src/export_progress.rs index 8ec6e39b37..81bf88811c 100644 --- a/crates/ui-egui/src/export_progress.rs +++ b/crates/ui-egui/src/export_progress.rs @@ -132,11 +132,9 @@ mod tests { let mut out = ctx.run_ui(egui::RawInput::default(), |ui| super::show(app, ui)); out.textures_delta.clear(); let mut texts = String::new(); - for shape in out.shapes { - if let egui::epaint::Shape::Text(t) = shape.shape { - texts.push_str(t.galley.text()); - texts.push('\n'); - } + for (t, _) in crate::tests_labels::text_shapes(&out) { + texts.push_str(t.galley.text()); + texts.push('\n'); } texts } diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 120c80aadd..b21b2e8ccf 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -288,18 +288,10 @@ fn discover_says_why_a_tool_cannot_be_marked() { } fn texts(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec) -> Vec<(String, egui::Rect)> { let out = pass(ctx, app, events); - fn collect(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())), - egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), - _ => {} - } - } - let mut texts = vec![]; - for c in &out.shapes { - collect(&c.shape, &mut texts); - } - texts + crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect())) + .collect() } fn click(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str) { texts(ctx, app, vec![]); diff --git a/crates/ui-egui/src/opening/tests.rs b/crates/ui-egui/src/opening/tests.rs index 68386b4c5d..cdb55375db 100644 --- a/crates/ui-egui/src/opening/tests.rs +++ b/crates/ui-egui/src/opening/tests.rs @@ -522,11 +522,9 @@ fn progress(app: &mut VectorcraftApp, ctx: &egui::Context) -> String { let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::export_progress::show(app, ui)); out.textures_delta.clear(); let mut texts = String::new(); - for shape in out.shapes { - if let egui::epaint::Shape::Text(t) = shape.shape { - texts.push_str(t.galley.text()); - texts.push('\n'); - } + for (t, _) in crate::tests_labels::text_shapes(&out) { + texts.push_str(t.galley.text()); + texts.push('\n'); } texts } diff --git a/crates/ui-egui/src/panel_docking/native_tests.rs b/crates/ui-egui/src/panel_docking/native_tests.rs index eebf3d6a77..3ceb28ad9f 100644 --- a/crates/ui-egui/src/panel_docking/native_tests.rs +++ b/crates/ui-egui/src/panel_docking/native_tests.rs @@ -113,15 +113,10 @@ impl Host { }; let mut full = ctx.run_ui(input, |ui| (viewport.viewport_ui_cb)(ui)); full.textures_delta.clear(); - fn texts(s: &egui::Shape, out: &mut Vec<(String, Rect)>) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } - let mut shown = Vec::new(); - full.shapes.iter().for_each(|c| texts(&c.shape, &mut shown)); + let shown: Vec<(String, Rect)> = crate::tests_labels::text_shapes(&full) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect())) + .collect(); let nodes = full.platform_output.accesskit_update.as_ref().map_or_else(Vec::new, |update| { let rect = |b: egui::accesskit::Rect| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32)); update.nodes.iter().filter_map(|(_, node)| Some((node.label()?.to_string(), rect(node.bounds()?)))).collect() diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index f132c35145..3476f5c2b0 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -1080,11 +1080,10 @@ fn footer_strip_shows_no_rows(h: &mut Harness, case: &str) { egui::Shape::Mesh(m) => m.vertices.iter().all(|v| v.color.a() == 0), _ => false, }; - let showing: Vec = h - .shapes - .iter() - .filter(|c| !transparent(&c.shape)) - .map(|c| (c.shape.visual_bounding_rect(), c.clip_rect)) + let showing: Vec = crate::tests_labels::painted_shapes(&h.shapes) + .into_iter() + .filter(|(shape, ..)| !transparent(shape)) + .map(|(shape, transform, clip)| (transform * shape.visual_bounding_rect(), clip)) .filter(|(bounds, clip)| { let seen = clip.intersect(*bounds).intersect(strip); bounds.height() < 60.0 && bounds.top() < footer.top() && seen.is_positive() && seen.height() > 0.5 diff --git a/crates/ui-egui/src/panels/tests_appearance.rs b/crates/ui-egui/src/panels/tests_appearance.rs index a98ddb02d3..66ca13b1ee 100644 --- a/crates/ui-egui/src/panels/tests_appearance.rs +++ b/crates/ui-egui/src/panels/tests_appearance.rs @@ -43,18 +43,10 @@ pub(super) fn frame_raw( ) -> Vec<(String, egui::Rect)> { let mut out = ctx.run_ui(raw, |ui| f(app, ui)); out.textures_delta.clear(); - fn collect(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())), - egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), - _ => {} - } - } - let mut texts = vec![]; - for c in &out.shapes { - collect(&c.shape, &mut texts); - } - texts + crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect())) + .collect() } /// Click at `pos` over three frames of `f` (hover, press, release). diff --git a/crates/ui-egui/src/panels/tests_brush_libraries.rs b/crates/ui-egui/src/panels/tests_brush_libraries.rs index de00122189..06458f8e4a 100644 --- a/crates/ui-egui/src/panels/tests_brush_libraries.rs +++ b/crates/ui-egui/src/panels/tests_brush_libraries.rs @@ -20,20 +20,11 @@ fn app() -> VectorcraftApp { /// One frame of `draw` with `events`; the texts it painted. fn frame(ctx: &egui::Context, events: Vec, time: f64, mut draw: impl FnMut(&mut egui::Ui)) -> Vec { - fn texts(s: &egui::Shape, out: &mut Vec) { - match s { - egui::Shape::Text(t) => out.push(t.galley.text().to_string()), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))); let input = egui::RawInput { events, time: Some(time), screen_rect, ..Default::default() }; let mut out = ctx.run_ui(input, &mut draw); out.textures_delta.clear(); - let mut v = vec![]; - out.shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect() } fn undo_len(app: &VectorcraftApp) -> usize { diff --git a/crates/ui-egui/src/panels/tests_style_libraries.rs b/crates/ui-egui/src/panels/tests_style_libraries.rs index 5f7eea0e7b..e3eee634d5 100644 --- a/crates/ui-egui/src/panels/tests_style_libraries.rs +++ b/crates/ui-egui/src/panels/tests_style_libraries.rs @@ -25,21 +25,12 @@ fn app() -> VectorcraftApp { /// One frame of `draw` with `events` and `modifiers` held; the texts it painted. fn frame(ctx: &egui::Context, events: Vec, modifiers: Modifiers, time: f64, mut draw: impl FnMut(&mut egui::Ui)) -> Vec { - fn texts(s: &egui::Shape, out: &mut Vec) { - match s { - egui::Shape::Text(t) => out.push(t.galley.text().to_string()), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))); let events = std::iter::once(Event::ModifiersChanged(modifiers)).chain(events).collect(); let input = egui::RawInput { events, time: Some(time), screen_rect, ..Default::default() }; let mut out = ctx.run_ui(input, &mut draw); out.textures_delta.clear(); - let mut v = vec![]; - out.shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect() } fn undo_len(app: &VectorcraftApp) -> usize { diff --git a/crates/ui-egui/src/panels/tests_symbol_libraries.rs b/crates/ui-egui/src/panels/tests_symbol_libraries.rs index c5ca39e7ec..a0f42855b1 100644 --- a/crates/ui-egui/src/panels/tests_symbol_libraries.rs +++ b/crates/ui-egui/src/panels/tests_symbol_libraries.rs @@ -21,20 +21,11 @@ fn app() -> VectorcraftApp { /// One frame of `draw` with `events`; the texts it painted. fn frame(ctx: &egui::Context, events: Vec, time: f64, mut draw: impl FnMut(&mut egui::Ui)) -> Vec { - fn texts(s: &egui::Shape, out: &mut Vec) { - match s { - egui::Shape::Text(t) => out.push(t.galley.text().to_string()), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))); let input = egui::RawInput { events, time: Some(time), screen_rect, ..Default::default() }; let mut out = ctx.run_ui(input, &mut draw); out.textures_delta.clear(); - let mut v = vec![]; - out.shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect() } fn undo_len(app: &VectorcraftApp) -> usize { diff --git a/crates/ui-egui/src/placing/tests.rs b/crates/ui-egui/src/placing/tests.rs index 385b1b3803..fb75d86663 100644 --- a/crates/ui-egui/src/placing/tests.rs +++ b/crates/ui-egui/src/placing/tests.rs @@ -1951,11 +1951,9 @@ fn progress(app: &mut VectorcraftApp, ctx: &egui::Context) -> String { let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::export_progress::show(app, ui)); out.textures_delta.clear(); let mut texts = String::new(); - for shape in out.shapes { - if let egui::epaint::Shape::Text(t) = shape.shape { - texts.push_str(t.galley.text()); - texts.push('\n'); - } + for (t, _) in crate::tests_labels::text_shapes(&out) { + texts.push_str(t.galley.text()); + texts.push('\n'); } texts } diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 25c2d367f1..fc61192b84 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -1265,7 +1265,7 @@ fn access_frame(a: &mut VectorcraftApp, events: Vec) -> (Vec<(Strin script_access::show(a, &mut w.script_access, ui); a.prefs = Some(w); }); - (crate::tests_removeanchors::shapes_text(&out.shapes.iter().map(|c| c.shape.clone()).collect::>()), out) + (crate::tests_removeanchors::shapes_text(&crate::tests_labels::flat_painted_shapes(&out.shapes)), out) } /// The texts of General › Script File Access after the frames it lays itself out in. diff --git a/crates/ui-egui/src/tests/background.rs b/crates/ui-egui/src/tests/background.rs index a314413f8b..fe90152db4 100644 --- a/crates/ui-egui/src/tests/background.rs +++ b/crates/ui-egui/src/tests/background.rs @@ -362,19 +362,10 @@ fn quitting_waits_for_background_saves() { /// The status bar's texts in one headless frame. pub(super) fn status_bar_texts(app: &mut VectorcraftApp) -> Vec { - fn texts(s: &egui::Shape, out: &mut Vec) { - match s { - egui::Shape::Text(t) => out.push(t.galley.text().to_string()), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let ctx = crate::testing::ui_context(); let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::chrome::status_bar(app, ui)); out.textures_delta.clear(); - let mut v = vec![]; - out.shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect() } #[test] diff --git a/crates/ui-egui/src/tests/dialog_layout.rs b/crates/ui-egui/src/tests/dialog_layout.rs index 0caa8e7007..121e9a0350 100644 --- a/crates/ui-egui/src/tests/dialog_layout.rs +++ b/crates/ui-egui/src/tests/dialog_layout.rs @@ -48,21 +48,15 @@ fn step(h: &mut Window) { /// The texts the window paints with `command` run, each with where it was drawn, a field label's colon left off. fn texts(command: &str, params: Value) -> Vec<(String, Rect)> { - fn collect(s: &egui::Shape, out: &mut Vec<(String, Rect)>) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().trim().trim_end_matches(':').to_owned(), t.visual_bounding_rect())), - egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), - _ => {} - } - } let mut h = window(); crate::menus::invoke(h.state_mut(), command, params); for _ in 0..6 { step(&mut h); } - let mut out = vec![]; - h.output().shapes.iter().for_each(|c| collect(&c.shape, &mut out)); - out + crate::tests_labels::text_shapes(h.output()) + .into_iter() + .map(|(t, transform)| (t.galley.text().trim().trim_end_matches(':').to_owned(), transform * t.visual_bounding_rect())) + .collect() } /// Where each painted `label` was drawn, top to bottom. diff --git a/crates/ui-egui/src/tests/document_drag.rs b/crates/ui-egui/src/tests/document_drag.rs index a18cb222a5..08744212f1 100644 --- a/crates/ui-egui/src/tests/document_drag.rs +++ b/crates/ui-egui/src/tests/document_drag.rs @@ -37,15 +37,10 @@ fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, time: f64, events: Vec = app.session.documents().iter().map(|d| d.title()).collect(); - let mut titles: Vec<_> = out - .shapes - .iter() - .filter_map(|s| match &s.shape { - egui::Shape::Text(t) if names.iter().any(|n| t.galley.text().starts_with(n.as_str())) => { - Some(egui::Rect::from_min_size(t.pos, t.galley.size())) - } - _ => None, - }) + let mut titles: Vec<_> = crate::tests_labels::text_shapes(&out) + .into_iter() + .filter(|(t, _)| names.iter().any(|n| t.galley.text().starts_with(n.as_str()))) + .map(|(t, transform)| transform * egui::Rect::from_min_size(t.pos, t.galley.size())) .collect(); titles.sort_by(|a, b| a.left().total_cmp(&b.left())); titles diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index ea2a08be62..e9c07abee0 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -46,6 +46,39 @@ pub(crate) fn text_shapes(out: &egui::FullOutput) -> Vec<(&egui::epaint::TextSha text } +/// Every painted shape other than `Shape::Vec` and `Shape::PaintChunk` (whose members it lists +/// instead), in paint order, with its composed window transform and the clip rectangle it is drawn in. +pub(crate) fn painted_shapes(clipped: &[egui::epaint::ClippedShape]) -> Vec<(&Shape, egui::emath::TSTransform, egui::Rect)> { + use egui::emath::TSTransform; + + fn collect<'a>(shape: &'a Shape, transform: TSTransform, clip: egui::Rect, out: &mut Vec<(&'a Shape, TSTransform, egui::Rect)>) { + match shape { + Shape::Vec(shapes) => shapes.iter().for_each(|shape| collect(shape, transform, clip, out)), + Shape::PaintChunk(shapes) => shapes.iter().for_each(|clipped| { + collect(&clipped.shape, transform * clipped.transform_after_tessellation, clip.intersect(transform * clipped.clip_rect), out); + }), + shape => out.push((shape, transform, clip)), + } + } + let mut shapes = Vec::new(); + for clipped in clipped { + collect(&clipped.shape, clipped.transform_after_tessellation, clipped.clip_rect, &mut shapes); + } + shapes +} + +/// [`painted_shapes`] as owned shapes, each moved by its transform. +pub(crate) fn flat_painted_shapes(clipped: &[egui::epaint::ClippedShape]) -> Vec { + painted_shapes(clipped) + .into_iter() + .map(|(shape, transform, _)| { + let mut shape = shape.clone(); + shape.transform(transform); + shape + }) + .collect() +} + /// Every string a frame painted, one per line. pub(crate) fn shapes_text(out: &egui::FullOutput) -> String { let mut text = String::new(); diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index 9252b1cec6..0c7d427a68 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -397,14 +397,8 @@ impl Panel { let images = paint.textures_delta.set.iter().flat_map(|(id, deltas)| deltas.iter().map(move |delta| (*id, delta.image.clone()))).collect(); // The test reads the images; no renderer applies them. paint.textures_delta.clear(); - let mut shapes = Vec::new(); - let mut open: Vec = paint.shapes.into_iter().map(|clipped| clipped.shape).collect(); - while let Some(shape) = open.pop() { - match shape { - egui::Shape::Vec(nested) => open.extend(nested), - shape => shapes.push(shape), - } - } + // Last painted first. + let shapes = crate::tests_labels::flat_painted_shapes(&paint.shapes).into_iter().rev().collect(); (shapes, images) } diff --git a/crates/ui-egui/src/tests/picks.rs b/crates/ui-egui/src/tests/picks.rs index 755aefbc45..851d438904 100644 --- a/crates/ui-egui/src/tests/picks.rs +++ b/crates/ui-egui/src/tests/picks.rs @@ -261,19 +261,13 @@ fn frame( events: Vec, draw: &impl Fn(&mut VectorcraftApp, &mut egui::Ui), ) -> Vec<(String, Rect)> { - fn texts(s: &egui::Shape, out: &mut Vec<(String, Rect)>) { - match s { - egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(SCREEN.0, SCREEN.1))), events, ..Default::default() }; // With the app's frame input, as the window's frames have it: its host carries the file service a dialog picks with. let out = crate::testing::part_frame(app, ctx, raw, |app, ui| draw(app, ui)); - let mut v = vec![]; - out.shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect())) + .collect() } /// Where text `label` was drawn (menu items pad theirs). diff --git a/crates/ui-egui/src/tests/removeanchors.rs b/crates/ui-egui/src/tests/removeanchors.rs index 90c977f58f..64f6fc4eea 100644 --- a/crates/ui-egui/src/tests/removeanchors.rs +++ b/crates/ui-egui/src/tests/removeanchors.rs @@ -59,7 +59,7 @@ pub(crate) const CONTROL_ROOM: egui::Vec2 = vec2(2200.0, 900.0); pub(crate) fn control_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) -> Vec<(String, Rect)> { let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, CONTROL_ROOM)), events, ..Default::default() }; let out = crate::testing::part_frame(app, ctx, raw, chrome::control_bar); - shapes_text(&out.shapes.iter().map(|c| c.shape.clone()).collect::>()) + shapes_text(&crate::tests_labels::flat_painted_shapes(&out.shapes)) } pub(crate) fn click_control(app: &mut VectorcraftApp, ctx: &egui::Context, at: Pos2) { @@ -74,7 +74,7 @@ fn canvas_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec>()) + shapes_text(&crate::tests_labels::flat_painted_shapes(&out.shapes)) } fn click_canvas(app: &mut VectorcraftApp, ctx: &egui::Context, at: Pos2, button: PointerButton) -> Vec<(String, Rect)> { @@ -92,7 +92,7 @@ pub(crate) fn properties_frame(app: &mut VectorcraftApp, width: f32) -> Vec<(Str crate::panels::properties::show(app, ui); }); out.textures_delta.clear(); - shapes_text(&out.shapes.iter().map(|c| c.shape.clone()).collect::>()) + shapes_text(&crate::tests_labels::flat_painted_shapes(&out.shapes)) } pub(crate) fn has(texts: &[(String, Rect)], label: &str) -> bool { diff --git a/crates/ui-egui/src/tests/retype_runs.rs b/crates/ui-egui/src/tests/retype_runs.rs index 8f27f1c572..aa10397dbd 100644 --- a/crates/ui-egui/src/tests/retype_runs.rs +++ b/crates/ui-egui/src/tests/retype_runs.rs @@ -39,11 +39,9 @@ fn has_type(app: &VectorcraftApp) -> bool { fn progress(app: &mut VectorcraftApp, ctx: &egui::Context, time: f64) -> String { let out = crate::testing::part_frame(app, ctx, egui::RawInput { time: Some(time), ..Default::default() }, export_progress::show); let mut texts = String::new(); - for shape in out.shapes { - if let egui::epaint::Shape::Text(t) = shape.shape { - texts.push_str(t.galley.text()); - texts.push('\n'); - } + for (t, _) in crate::tests_labels::text_shapes(&out) { + texts.push_str(t.galley.text()); + texts.push('\n'); } texts } diff --git a/crates/ui-egui/src/tests/ruler_origin.rs b/crates/ui-egui/src/tests/ruler_origin.rs index d731d7db76..d016e09d26 100644 --- a/crates/ui-egui/src/tests/ruler_origin.rs +++ b/crates/ui-egui/src/tests/ruler_origin.rs @@ -30,16 +30,10 @@ fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec, draw ..Default::default() }; let out = crate::testing::part_frame(app, ctx, raw, draw); - fn walk(s: &egui::Shape, v: &mut Vec<(String, Rect)>) { - match s { - egui::Shape::Text(t) => v.push((t.galley.text().to_string(), Rect::from_min_size(t.pos, t.galley.size()))), - egui::Shape::Vec(s) => s.iter().for_each(|s| walk(s, v)), - _ => {} - } - } - let mut texts = vec![]; - out.shapes.iter().for_each(|c| walk(&c.shape, &mut texts)); - texts + crate::tests_labels::text_shapes(&out) + .into_iter() + .map(|(t, transform)| (t.galley.text().to_string(), transform * Rect::from_min_size(t.pos, t.galley.size()))) + .collect() } /// How many fields show `v` points: painted as one run, or as its number with the unit as the next run on its row. diff --git a/crates/ui-egui/src/tests/script_run.rs b/crates/ui-egui/src/tests/script_run.rs index 9cb5757c6b..106bd96575 100644 --- a/crates/ui-egui/src/tests/script_run.rs +++ b/crates/ui-egui/src/tests/script_run.rs @@ -626,13 +626,6 @@ fn a_scripts_file_dialog_keeps_at_most_2048_picked_files() { /// The texts the open warning draws, after a few frames of the whole app. fn dialog_texts(app: &mut VectorcraftApp) -> Vec { - fn texts(s: &egui::Shape, out: &mut Vec) { - match s { - egui::Shape::Text(t) => out.push(t.galley.text().to_string()), - egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)), - _ => {} - } - } let ctx = app.ui_ctx.clone().unwrap(); let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 4000.0)); let mut out = None; @@ -640,9 +633,8 @@ fn dialog_texts(app: &mut VectorcraftApp) -> Vec { let raw = egui::RawInput { time: Some(0.1 * f64::from(i)), screen_rect: Some(screen), ..Default::default() }; out = Some(crate::testing::app_frame(app, &ctx, raw)); } - let mut v = vec![]; - out.unwrap().shapes.iter().for_each(|c| texts(&c.shape, &mut v)); - v + let out = out.unwrap(); + crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect() } /// The warning before a run lists the files the script writes, read without running it. diff --git a/crates/ui-egui/src/tests/scrub.rs b/crates/ui-egui/src/tests/scrub.rs index 39142a71e5..78cc74f86f 100644 --- a/crates/ui-egui/src/tests/scrub.rs +++ b/crates/ui-egui/src/tests/scrub.rs @@ -18,14 +18,10 @@ pub(super) fn window(app: &mut VectorcraftApp, ui: &mut egui::Ui) { fn app_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec, text: &str) -> Option { let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 900.0))); let out = crate::testing::app_frame(app, ctx, egui::RawInput { events, screen_rect, ..Default::default() }); - fn find(shape: &egui::Shape, text: &str) -> Option { - match shape { - egui::Shape::Text(t) if t.galley.text() == text => Some(t.galley.rect.translate(t.pos.to_vec2())), - egui::Shape::Vec(v) => v.iter().find_map(|s| find(s, text)), - _ => None, - } - } - out.shapes.iter().find_map(|s| find(&s.shape, text)) + crate::tests_labels::text_shapes(&out) + .into_iter() + .find(|(t, _)| t.galley.text() == text) + .map(|(t, transform)| transform * t.galley.rect.translate(t.pos.to_vec2())) } fn app_with_rect() -> (VectorcraftApp, egui::Context) { diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 2495ec4d03..9ce6cca2e6 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -321,14 +321,7 @@ fn the_controls_under_the_tools_share_a_line_under_a_rule() { let proxy = named_rect(&nodes, "Fill and Stroke"); let screen_rect = Some(egui::Rect::from_min_size(Pos2::ZERO, egui::vec2(1200.0, 2000.0))); let out = crate::testing::app_frame(&mut app, &ctx, egui::RawInput { time: Some(1.0), screen_rect, ..Default::default() }); - let mut flat = Vec::new(); - let mut stack: Vec = out.shapes.into_iter().map(|clipped| clipped.shape).collect(); - while let Some(shape) = stack.pop() { - match shape { - egui::Shape::Vec(inner) => stack.extend(inner), - shape => flat.push(shape), - } - } + let flat = crate::tests_labels::flat_painted_shapes(&out.shapes); // A rule is a thin horizontal line or bar across most of the rail's width, between the tools and the controls. let between = |y: f32| y > last.bottom() && y < proxy.top(); let across = |left: f32, right: f32| right - left >= last.width() * 0.75 && left < last.right() && right > last.left(); @@ -595,20 +588,15 @@ fn a_short_tools_rail_shows_its_scroll_bar_at_rest() { let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); let screen_rect = Some(egui::Rect::from_min_size(Pos2::ZERO, egui::vec2(1200.0, height))); let out = crate::testing::app_frame(app, &ctx, egui::RawInput { time: Some(t0 + 0.2), screen_rect, ..Default::default() }); - let mut stack: Vec = out.shapes.into_iter().map(|clipped| clipped.shape).collect(); let mut found = 0; - while let Some(shape) = stack.pop() { - match shape { - egui::Shape::Vec(inner) => stack.extend(inner), - egui::Shape::Rect(r) => { - let b = r.rect; - let narrow = b.width() > 0.0 && b.width() <= rail.width() * 0.25 && b.height() >= b.width() * 3.0; - let at_end = rail.expand(0.5).contains_rect(b) && b.center().x > rail.center().x; - if narrow && at_end { - found += 1; - } + for shape in crate::tests_labels::flat_painted_shapes(&out.shapes) { + if let egui::Shape::Rect(r) = shape { + let b = r.rect; + let narrow = b.width() > 0.0 && b.width() <= rail.width() * 0.25 && b.height() >= b.width() * 3.0; + let at_end = rail.expand(0.5).contains_rect(b) && b.center().x > rail.center().x; + if narrow && at_end { + found += 1; } - _ => {} } } found diff --git a/crates/ui-egui/tests/panel_readout_copy.rs b/crates/ui-egui/tests/panel_readout_copy.rs index 7c65f085e6..47c72fcb30 100644 --- a/crates/ui-egui/tests/panel_readout_copy.rs +++ b/crates/ui-egui/tests/panel_readout_copy.rs @@ -353,12 +353,11 @@ fn copy_long_link_value(a: &mut App) { assert_eq!(names.len(), 1, "one actual full-name copy readout"); assert_eq!(names[0].1.description(), Some("Copy")); let area = location_node_rect(&names[0].1); - let (value, clipped) = out - .shapes - .iter() - .find_map(|s| { - let t = text_shape(&s.shape, &name)?; - let r = t.galley.rect.translate(t.pos.to_vec2()).intersect(s.clip_rect).intersect(area); + let (value, clipped) = visible_paint(&out) + .into_iter() + .filter(|(t, ..)| t.galley.text() == name) + .find_map(|(t, bounds, _)| { + let r = bounds.intersect(area); r.is_positive().then_some((r, t.galley.elided || r.width() < t.galley.rect.width())) }) .expect("the actual selected image's Link Info Name value"); @@ -636,9 +635,9 @@ fn location_node_rect(node: &egui::accesskit::Node) -> Rect { } fn shortened_location(out: &egui::FullOutput, rect: Rect, full: &str) -> bool { - visible_paint(out) - .into_iter() - .any(|(shape, bounds, center)| rect.contains(center) && bounds.contains(center) && shape.galley.text().contains('…') && shape.galley.text() != full) + visible_paint(out).into_iter().any(|(shape, bounds, center)| { + rect.contains(center) && bounds.contains(center) && shape.galley.text().contains('…') && shape.galley.text() != full + }) } #[test] @@ -725,10 +724,7 @@ fn panel_readout_long_location_fits_and_copies_by_pointer_accessibility_and_keyb let (location_id, node) = locations[0]; let location_rect = location_node_rect(node); assert!(body.contains_rect(location_rect), "{locale}: the fitted Location remains inside the panel"); - assert!( - shortened_location(&out, location_rect, location), - "{locale}: the long path must actually be shortened on screen" - ); + assert!(shortened_location(&out, location_rect, location), "{locale}: the long path must actually be shortened on screen"); let buttons: Vec<_> = nodes.iter().filter(|(_, n)| n.role() == Role::Button && n.label() == Some(vectorcraft_ui_egui::i18n::t("Copy Location"))).collect(); assert_eq!(buttons.len(), 1, "{locale}: one named native Copy Location button"); From 69e325e462c5f58e79e0e5248ae0322b815ac263 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 29 Nov 2026 15:09:23 +0100 Subject: [PATCH 092/264] Pin craft-libs 186a229c for the VectorCraft release Carry the upstream properties-dialog tab retention and layout fixes into the tested release pin. Retain the same egui revision and dependency graph. --- Cargo.lock | 170 ++++++++++++++++---------------- Cargo.toml | 70 ++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 122 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4f93bacb0..4da7886c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,7 +1239,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "crc32fast", "flate2", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1302,7 +1302,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1335,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1353,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1380,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "egui", ] @@ -1388,7 +1388,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "md-5", "rayon", @@ -1397,12 +1397,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "rayon", ] @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1477,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "serde", ] @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1520,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1532,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "serde", "serde_json", @@ -1542,12 +1542,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1562,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1581,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1590,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1613,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "gif", ] @@ -1626,7 +1626,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "flate2", ] @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "chrono", "fixed_decimal", @@ -1675,7 +1675,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1728,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1768,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1809,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "flate2", "serde", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "async-channel", "async-io", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2018,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2140,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "flate2", "serde", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2367,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "winsafe", ] @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "brotli", "hayro-postscript", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3789,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3807,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=27c2cbf821ccf3842f789484f0234460cfcd07a6#27c2cbf821ccf3842f789484f0234460cfcd07a6" +source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 1dfeb423a9..d3057fb0af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,46 +11,46 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -193,13 +193,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 7f84c95338..c220474112 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -27,7 +27,7 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "27c2cbf821ccf3842f789484f0234460cfcd07a6", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 6dafe7147a..f4f02f8627 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "27c2cbf821ccf3842f789484f0234460cfcd07a6"; +const REV: &str = "186a229c8da8db5916f8a863dfd894f1879af735"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 2fa64c33a2bc5f4207c5a015f797af6ec0903db7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:17:06 -0800 Subject: [PATCH 093/264] Tests: the six slowest interface tests run in a fraction of the time - Menu entries and Help search look up every shortcut in one keymap read. While a shortcut change waits for the next frame, each lookup cloned the whole keymap, so a Help search after shortcuts.set took about 4 s in a debug build. - The Insert Menu Item test and the Alt chord test make a new app for each item in one shared window. The Alt chord test releases each chord after its checks. - The palette test picks into one app per case while a pick changes nothing, and compares the tool's state as well. - The 3D row test reopens the dialog in one window for each row. --- crates/ui-egui/src/dialogs/revolve/tests.rs | 22 ++++++++--- crates/ui-egui/src/menus/entries.rs | 28 +++++++++---- crates/ui-egui/src/menus/tests.rs | 2 +- crates/ui-egui/src/palette.rs | 35 ++++++++++++----- .../ui-egui/src/panels/actions/tests_edits.rs | 4 +- .../src/panels/actions/tests_support.rs | 17 ++++++-- crates/ui-egui/src/panels/discover.rs | 10 ++++- crates/ui-egui/src/shortcuts/tests.rs | 39 +++++++++++++++---- crates/ui-egui/src/testing.rs | 15 ++++++- 9 files changed, 132 insertions(+), 40 deletions(-) diff --git a/crates/ui-egui/src/dialogs/revolve/tests.rs b/crates/ui-egui/src/dialogs/revolve/tests.rs index ceb96018f7..f48f65b38d 100644 --- a/crates/ui-egui/src/dialogs/revolve/tests.rs +++ b/crates/ui-egui/src/dialogs/revolve/tests.rs @@ -114,22 +114,32 @@ fn rows() -> Vec<(&'static str, &'static str, &'static str, Value)> { #[test] fn a_3d_row_sets_its_param_previews_and_applies_in_one_step() { + // One window serves every row: Cancel, and OK followed by Undo, leave the drawing as the dialog found it, and each + // row opens the dialog again over it. + let mut shown: Option = None; for (effect, page, key, value) in rows() { let name = format!("{effect}.{key}"); for confirm in [false, true] { - let mut h = drawn(SQUARE, effect); - let before = source(&h); + let p = json!({"effect": effect, "item": null}); + let h = match shown.as_mut() { + Some(h) => { + reopen(h, p); + h + } + None => shown.insert(opened(app_with(SQUARE), p)), + }; + let before = source(h); h.set("__page", json!(page)); h.set(key, value.clone()); - assert!(same(&stored(&h, effect)[key], &value), "{name}: the preview follows the row"); + assert!(same(&stored(h, effect)[key], &value), "{name}: the preview follows the row"); if confirm { h.ok(); - assert!(same(&stored(&h, effect)[key], &value), "{name}: OK keeps it"); - undo(&h); + assert!(same(&stored(h, effect)[key], &value), "{name}: OK keeps it"); + undo(h); } else { h.cancel(); } - assert_eq!(doc(&h), before, "{name}: {}", if confirm { "one undo step" } else { "Cancel restores" }); + assert_eq!(doc(h), before, "{name}: {}", if confirm { "one undo step" } else { "Cancel restores" }); } } } diff --git a/crates/ui-egui/src/menus/entries.rs b/crates/ui-egui/src/menus/entries.rs index 69722bd1ae..66353c55be 100644 --- a/crates/ui-egui/src/menus/entries.rs +++ b/crates/ui-egui/src/menus/entries.rs @@ -1,7 +1,9 @@ +use craft::keymap::{Chord, CommandRef}; + use super::context::context_items; -use super::labels::{display_label, dynamic_label, effect_item_label, item_shortcut, spelling_item_label, unlock_item_label}; +use super::labels::{display_label, dynamic_label, effect_item_label, item_shortcut_in, spelling_item_label, unlock_item_label}; use super::slots::{recent_readable, recent_slot}; -use super::state::{shortcut_of, shown_state}; +use super::state::{command_shortcuts, shown_state}; use super::tree::{Listed, menu_tree_named}; use super::{Node, Serialize, Value, VectorcraftApp, unbound}; @@ -32,8 +34,9 @@ pub struct MenuEntry { /// Flattened menu for `ui.menu.list`. pub fn menu_entries(app: &VectorcraftApp) -> Vec { let mut out = vec![]; + let chord = command_shortcuts(app); for (title, items) in menu_tree_named(app.session.prefs.font_names_in_english, &Listed::of(app)) { - flatten(app, vec![title.to_string()], vec![crate::i18n::t(title).to_string()], &items, &mut out); + flatten(app, &chord, vec![title.to_string()], vec![crate::i18n::t(title).to_string()], &items, &mut out); } out } @@ -41,7 +44,7 @@ pub fn menu_entries(app: &VectorcraftApp) -> Vec { /// Flattened canvas context menu for `ui.contextMenu.list` (paths are its submenus). pub fn context_entries(app: &VectorcraftApp) -> Vec { let mut out = vec![]; - flatten(app, vec![], vec![], &context_items(app), &mut out); + flatten(app, &command_shortcuts(app), vec![], vec![], &context_items(app), &mut out); out } @@ -166,7 +169,15 @@ pub fn insertable_items(english_names: bool, listed: &Listed) -> Vec, shown: Vec, nodes: &[Node], out: &mut Vec) { +/// `nodes` flattened into `out`, each item's shortcut looked up in `chord` ([`command_shortcuts`]). +pub(super) fn flatten( + app: &VectorcraftApp, + chord: &dyn Fn(&CommandRef) -> Option, + path: Vec, + shown: Vec, + nodes: &[Node], + out: &mut Vec, +) { for node in nodes { match node { Node::Item(it) if unbound(&it.command.id) => out.push(MenuEntry { @@ -197,7 +208,10 @@ pub(super) fn flatten(app: &VectorcraftApp, path: Vec, shown: Vec, shown: Vec {} } diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index adaa0b488c..4ecd9e690c 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -394,7 +394,7 @@ fn menu_entry_shown_paths_keep_script_folder_names() { let items = vec![sub("Scripts", vec![sub("File", folder), cp("Other Script…", "ui.runScript", Value::Null)])]; let mut out = vec![]; crate::i18n::set_current(de); - flatten(&app, vec!["File".into()], vec![crate::i18n::t("File").into()], &items, &mut out); + flatten(&app, &super::command_shortcuts(&app), vec!["File".into()], vec![crate::i18n::t("File").into()], &items, &mut out); crate::i18n::set_current(crate::i18n::Lang::EN); let script = out.iter().find(|e| e.command.as_deref() == Some(crate::scripts_menu::COMMAND)).unwrap(); assert_eq!(script.path, ["File", "Scripts", "File"]); diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 9079b40a5d..f4ea2715bb 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -1753,8 +1753,8 @@ mod tests { /// the menu bar, and commands that need a value no menu item gives, with a menu path of their own /// or without one. A pick of each one it leaves /// out (with no document, one object selected or several) changes neither the document, its - /// selection, history and layer state, nor the interface. Every [`PICK_RUNS`] query is still - /// listed. + /// selection, history and layer state, the tool's state, nor the interface. Every [`PICK_RUNS`] + /// query is still listed. #[test] fn the_palette_leaves_out_the_commands_a_pick_cannot_run() { let ui_ids: std::collections::HashSet<&str> = menus::UI_COMMANDS.iter().map(|c| c.0).collect(); @@ -1785,16 +1785,33 @@ mod tests { (st.doc.clone(), format!("{:?}", st.selection), st.history.undo.len(), st.revision, st.active_layer, st.layer_rows.clone()) }); // A modeless dialog (Find and Replace) blocks nothing, so `any_dialog_open` leaves it out: the host lists it. - (doc, app.session.script_console().lines().len(), (app.any_dialog_open(), crate::tests::picks::open_dialogs(app).len()), ui) + // The tool's own state: the tool, a gesture or an input method's text in progress, and an interaction the + // session holds open. + let tool = (app.session.tool_id().to_owned(), app.session.tool_composing(), app.session.pointer_held(), app.session.in_interaction()); + (doc, app.session.script_console().lines().len(), (app.any_dialog_open(), crate::tests::picks::open_dialogs(app).len()), ui, tool) }; - let acts = |id: &str| { - [Session::new(), Fixture::Single.session(), Fixture::Multi.session()].into_iter().any(|session| { - let mut app = app_on(session); - let before = look(&app); - pick(&mut app, id); - look(&app) != before + // One app for each of the three cases, picked in one after another while a pick changes nothing that `look` + // sees; a pick that changes something is recorded, and its case starts again from a new app. + let fresh = |case: usize| { + app_on(match case { + 0 => Session::new(), + 1 => Fixture::Single.session(), + _ => Fixture::Multi.session(), }) }; + let mut apps: Vec = (0..3).map(fresh).collect(); + let mut acts = |id: &str| { + let mut changed = false; + for (case, app) in apps.iter_mut().enumerate() { + let before = look(app); + pick(app, id); + if look(app) != before { + changed = true; + *app = fresh(case); + } + } + changed + }; let changed: Vec<&str> = ids.iter().copied().filter(|id| acts(id)).collect(); assert!(changed.is_empty(), "a pick of these does something: {changed:?}"); for c in &dropped { diff --git a/crates/ui-egui/src/panels/actions/tests_edits.rs b/crates/ui-egui/src/panels/actions/tests_edits.rs index 1fe2f13711..208c293b70 100644 --- a/crates/ui-egui/src/panels/actions/tests_edits.rs +++ b/crates/ui-egui/src/panels/actions/tests_edits.rs @@ -927,8 +927,10 @@ fn insert_menu_item_refuses_what_no_menu_item_runs_and_changes_nothing() { fn every_listed_menu_item_runs_from_the_menu_what_its_step_holds() { // The View menu's proof items change the whole process's proof view. let _view = crate::testing::DefaultProofView::new(); + // A new app for each item, all in one window. + let window = crate::testing::window_context(); for item in crate::menus::insertable_items(false, &crate::menus::Listed::default()) { - let (mut app, _) = app_with_three_moves(); + let (mut app, _) = three_moves_in(new_app_in(&window)); app.run(INSERT_MENU_ITEM, json!({"set": 0, "action": 0, "command": item.command, "params": item.params})).unwrap(); let held = steps(&app, 0, 0)[3].1.clone(); let start = app.session.journal.len(); diff --git a/crates/ui-egui/src/panels/actions/tests_support.rs b/crates/ui-egui/src/panels/actions/tests_support.rs index 610e180bf0..3f763ad877 100644 --- a/crates/ui-egui/src/panels/actions/tests_support.rs +++ b/crates/ui-egui/src/panels/actions/tests_support.rs @@ -20,9 +20,14 @@ use crate::VectorcraftApp; /// An app with the built-in set, in a window whose dialog host the tests drive and which has drawn its first frame, so /// the window's keymap holds the app's commands. pub(crate) fn new_app() -> VectorcraftApp { - let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); - let ctx = app.ui_ctx.clone().expect("a window"); - crate::testing::app_frame(&mut app, &ctx, Default::default()); + new_app_in(&crate::testing::window_context()) +} + +/// [`new_app`] in the window of `ctx` ([`crate::testing::window_context`]), which a test can reuse for a new app at +/// each step. +pub(crate) fn new_app_in(ctx: &egui::Context) -> VectorcraftApp { + let mut app = crate::testing::windowed_in(VectorcraftApp::new(Session::new(), Default::default()), ctx); + crate::testing::app_frame(&mut app, ctx, Default::default()); app } @@ -251,7 +256,11 @@ pub(crate) fn cancel_dialog(app: &mut VectorcraftApp) { /// A document with one rectangle selected and the set "Moves" with one action that moves it /// right three times, by 1, 2 and 4 pt → (the app, the rectangle's left edge as it moves). pub(crate) fn app_with_three_moves() -> (VectorcraftApp, impl Fn(&VectorcraftApp) -> f64) { - let mut app = new_app(); + three_moves_in(new_app()) +} + +/// [`app_with_three_moves`] made from `app`, a new app such as [`new_app_in`] gives. +pub(crate) fn three_moves_in(mut app: VectorcraftApp) -> (VectorcraftApp, impl Fn(&VectorcraftApp) -> f64) { app.run("file.new", json!({"width": 200, "height": 100})).unwrap(); let id = vectorcraft_doc::NodeId(app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index 649727d609..58c9bb5c12 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -52,7 +52,12 @@ pub struct View { /// The text of a tool's shortcut in the window's keymap, empty when it has none. fn tool_shortcut(app: &VectorcraftApp, id: &str) -> String { - menus::shortcut_of(app, &format!("tool:{id}")).map_or_else(String::new, |chord| chord.display(crate::keymap::platform())) + tool_shortcut_in(&menus::command_shortcuts(app), id) +} + +/// [`tool_shortcut`] looked up in `chord` ([`menus::command_shortcuts`]). +fn tool_shortcut_in(chord: &dyn Fn(&craft::keymap::CommandRef) -> Option, id: &str) -> String { + chord(&crate::keymap::command_of(&format!("tool:{id}"))).map_or_else(String::new, |chord| chord.display(crate::keymap::platform())) } /// Updates the retained results' labels, menu paths and shortcuts after the menu state changes (a @@ -109,6 +114,7 @@ fn refresh(app: &mut VectorcraftApp) { /// The tools, each with the entry the search ranks it by. fn tool_hits(app: &VectorcraftApp) -> Vec<(HelpEntry, Hit)> { let lang = crate::i18n::current(); + let chord = menus::command_shortcuts(app); vectorcraft_tools::catalog::all_tools() .map(|tool| { let label: String = crate::i18n::tr(lang, tool.label).into(); @@ -120,7 +126,7 @@ fn tool_hits(app: &VectorcraftApp) -> Vec<(HelpEntry, Hit)> { id: tool.id.into(), label, path: vec![], - shortcut: tool_shortcut(app, tool.id), + shortcut: tool_shortcut_in(&chord, tool.id), english_label: tool.label.into(), english_path: vec![], params: Value::Null, diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index f5cd51ebb5..f33216e978 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -210,6 +210,18 @@ fn editing_hi() -> (VectorcraftApp, u64) { (app, id) } +/// [`editing_hi`] in the window of `ctx`, which a test can reuse for a new app at each step, after the frames +/// [`typing_ready`] runs. +fn editing_hi_in(ctx: &egui::Context) -> (VectorcraftApp, u64) { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 200})).unwrap(); + key_frame(&mut app, ctx, vec![]); + let id = app.session.execute("text.create", &json!({"x": 20, "y": 50, "text": "Hi"})).unwrap()["id"].as_u64().unwrap(); + edit(&mut app, 2, 2); + idle(&mut app, ctx, 2); + (app, id) +} + /// Starts editing the selected type object with the Type tool and selects `start..end`. fn edit(app: &mut VectorcraftApp, start: u64, end: u64) { app.select_tool("type"); @@ -901,22 +913,33 @@ fn alt_chords_type_special_characters_while_editing_text() { return; } let mut wrong = vec![]; + // A new app for each chord, all in one window. + let ctx = crate::testing::ui_context(); for (key, shift, own, character) in ALT_CHARACTER_CHORDS { for typed in [None, Some(own), Some(own.to_uppercase().as_str())] { - let (mut app, id) = editing_hi(); - let ctx = typing_ready(&mut app); + let (mut app, id) = editing_hi_in(&ctx); key_frame(&mut app, &ctx, alt_press(key, shift, typed)); let case = format!("{key:?} shift={shift} text={typed:?}"); let text = text_and_layers(&mut app, id).0; if text != format!("Hi{character}") { wrong.push(format!("{case}: text = {text:?}")); - continue; - } - app.session.execute("edit.undo", &json!({})).unwrap(); - let undone = text_and_layers(&mut app, id).0; - if undone != "Hi" { - wrong.push(format!("{case}: after Undo = {undone:?}")); + } else { + app.session.execute("edit.undo", &json!({})).unwrap(); + let undone = text_and_layers(&mut app, id).0; + if undone != "Hi" { + wrong.push(format!("{case}: after Undo = {undone:?}")); + } } + // The window keeps a key held from one app to the next: the release makes the next chord a new press. + let m = if shift { Modifiers::ALT | Modifiers::SHIFT } else { Modifiers::ALT }; + key_frame( + &mut app, + &ctx, + vec![ + egui::Event::Key { key, physical_key: Some(key), pressed: false, repeat: false, modifiers: m }, + egui::Event::ModifiersChanged(Modifiers::NONE), + ], + ); } } assert!(wrong.is_empty(), "{wrong:#?}"); diff --git a/crates/ui-egui/src/testing.rs b/crates/ui-egui/src/testing.rs index 6098a8467a..89a74801bc 100644 --- a/crates/ui-egui/src/testing.rs +++ b/crates/ui-egui/src/testing.rs @@ -22,10 +22,21 @@ pub(crate) fn install(ctx: &egui::Context) { /// `app` shown in a window of its own: its context is the one every frame of the test runs on, so its dialogs open on /// the window's host, focus and drags last from frame to frame, and the access tree is on for the tests that find a /// control by its role. -pub(crate) fn windowed(mut app: crate::VectorcraftApp) -> crate::VectorcraftApp { +pub(crate) fn windowed(app: crate::VectorcraftApp) -> crate::VectorcraftApp { + windowed_in(app, &window_context()) +} + +/// The context of a window [`windowed`] shows an app in, with the access tree on. A test that makes a new app for each +/// item can show each one in the same window with [`windowed_in`]. +pub(crate) fn window_context() -> egui::Context { let ctx = ui_context(); ctx.enable_accesskit(); - app.ui_ctx = Some(ctx); + ctx +} + +/// `app` shown in the window of `ctx`, as [`windowed`] shows it in a window of its own. +pub(crate) fn windowed_in(mut app: crate::VectorcraftApp, ctx: &egui::Context) -> crate::VectorcraftApp { + app.ui_ctx = Some(ctx.clone()); app } From 6a6fa5056cdb4c8bf6d6f7594f28dd5fafe25a65 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:20:45 -0800 Subject: [PATCH 094/264] CI: the two ui-egui shards take about the same time Each ui-egui part ran its pinned tests with --test-threads 3 beside its counted share with --test-threads 1. On the 4-CPU runners the pinned tests finished in about 40 s, and the counted share of about 2,640 tests then ran on one thread for 9 to 12 minutes (run 46267439238). A part now runs its counted share and then its pinned tests, one after the other, each with nextest's default thread count. The help F1 test moves to part 1's pinned list, which leaves the two parts with closer test totals. --- xtask/src/main.rs | 34 ++++++++-------------------------- xtask/src/shards.rs | 14 +++++--------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ba0ed79acf..7c2e587a7d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -269,6 +269,8 @@ fn cmd_test() -> Result<(), String> { /// [`cmd_test`] for the packages `select` picks (`--workspace` or `-p` ids), shown as `shown`; /// with `part`, only that part's share of their tests (xtask/src/shards.rs), which needs nextest. +/// A part runs its counted share, then its pinned tests, each with nextest's default thread count. +/// Every run finishes before the first error is returned. fn test_packages(select: &[String], shown: &str, part: Option) -> Result<(), String> { const TARGETS: [&str; 3] = ["--lib", "--bins", "--tests"]; if let Some(part) = part { @@ -294,32 +296,12 @@ fn test_packages(select: &[String], shown: &str, part: Option) -> let quoted = args.iter().map(|a| if a.contains(' ') { format!("'{a}'") } else { a.clone() }).collect::>().join(" "); (c, format!("cargo nextest run {shown} --lib --bins --tests {quoted}")) }; - let cpus = std::thread::available_parallelism().map_or(1, usize::from); - let pinned_threads = part.pins().max(1).min(cpus.saturating_sub(1).max(1)); - let counted_threads = if part.pins() == 0 { cpus } else { cpus.saturating_sub(pinned_threads).max(1) }; - let mut runs = part.runs().into_iter(); - let mut counted = runs.next().ok_or_else(|| format!("cargo nextest run {shown}: no counted run"))?; - counted.extend(["--test-threads".to_owned(), counted_threads.to_string()]); - let pinned = runs - .next() - .map(|mut args| { - args.extend(["--test-threads".to_owned(), pinned_threads.to_string()]); - let (mut c, what) = command(args); - eprintln!("$ {what}"); - c.spawn().map(|child| (child, what.clone())).map_err(|e| format!("{what}: failed to spawn: {e}")) - }) - .transpose()?; - let (c, what) = command(counted); - let counted_result = run(c, &what); - let pinned_result = match pinned { - None => Ok(()), - Some((mut child, what)) => match child.wait() { - Ok(status) if status.success() => Ok(()), - Ok(status) => Err(format!("{what}: exited with {status}")), - Err(e) => Err(format!("{what}: failed to wait: {e}")), - }, - }; - return counted_result.and(pinned_result); + let mut result = Ok(()); + for args in part.runs() { + let (c, what) = command(args); + result = result.and(run(c, &what)); + } + return result; } let mut c = cargo(); if has_nextest() { diff --git a/xtask/src/shards.rs b/xtask/src/shards.rs index 1baede03bd..29f5281a84 100644 --- a/xtask/src/shards.rs +++ b/xtask/src/shards.rs @@ -15,7 +15,8 @@ //! part builds the same tests and runs its share of them: the tests its `pinned` list names, and //! every other test of the crates by nextest's counted partition (`--partition count:/` //! with the pinned tests filtered out, so each of them runs once). The doctests and the i18n -//! report run on part 1. +//! report run on part 1. A part runs its counted share and then its pinned tests, each with +//! nextest's default thread count, and runs both even when the first fails. use std::collections::{BTreeMap, BTreeSet}; @@ -51,8 +52,8 @@ impl Split { } } -/// vectorcraft-ui-egui's tests, on two shards. The pinned tests took 23 to 74 s each in CI -/// (run 46256086023), and each part's pinned tests add up to about 120 to 130 s. +/// vectorcraft-ui-egui's tests, on two shards. The pinned tests took 18 to 44 s each in CI +/// run 46267439238. pub static UI_EGUI: Split = Split { crates: &["vectorcraft-ui-egui"], pinned: &[ @@ -60,11 +61,11 @@ pub static UI_EGUI: Split = Split { "panels::actions::tests_edits::every_listed_menu_item_runs_from_the_menu_what_its_step_holds", "dialogs::revolve::tests::a_3d_row_sets_its_param_previews_and_applies_in_one_step", "shortcuts::tests::alt_chords_type_special_characters_while_editing_text", + "menus::tests::help_f1_opens_discover_without_a_document", ], &[ "palette::tests::the_palette_leaves_out_the_commands_a_pick_cannot_run", "chrome::tests::the_control_bar_leaves_members_out_in_its_priority_order", - "menus::tests::help_f1_opens_discover_without_a_document", ], ], }; @@ -104,11 +105,6 @@ pub struct Part { } impl Part { - /// The number of tests this part pins. - pub fn pins(&self) -> usize { - self.split.pinned[self.index - 1].len() - } - /// The arguments `cargo nextest run` takes after the package and target selection, once for /// each run this part makes: the counted share (`--partition count:/`, with every /// pinned test filtered out when the split pins any), then the tests this part pins. From 6ef6df34072e09bbd15e8ce7c2b889637695f75c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:45:32 -0800 Subject: [PATCH 095/264] Scripts: round artboard rows as main's New Document test expects, and drop pathItems= from the host table Cause of the CI failures on 212090fd7a2: - main's dialogs::new_document test a_presets_rows_reach_the_document_create_makes sets artboardLayout.rows to 3.6 and expects 4, but this branch refused a rows value that was not a whole number. rows now rounds like columns and is still refused outside 1 to 1000. - script_host_vs_scriptcheck listed Document.prototype.pathItems=, the setter of main's placeholder. This branch makes pathItems a read-only collection, like pageItems, so the row goes. --- crates/engine/src/cmd/newdoc.rs | 5 +++-- crates/engine/src/tests/newdoc.rs | 2 +- crates/engine/src/tests/script_dom.rs | 2 +- crates/engine/tests/it/script_host_vs_scriptcheck.rs | 2 +- docs/mcp.md | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index e4355bf934..21f3661c89 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -395,9 +395,10 @@ impl DocSettings { "rows" => { self.rows = v .as_f64() - .filter(|r| r.fract() == 0.0 && (1.0..=MAX_ARTBOARDS as f64).contains(r)) + .map(f64::round) + .filter(|r| (1.0..=MAX_ARTBOARDS as f64).contains(r)) .map(|r| r as u32) - .ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be a whole number from 1 to {MAX_ARTBOARDS}")))? + .ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be from 1 to {MAX_ARTBOARDS}")))? } "spacing" => { self.spacing = v diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index cd8feca36d..ad2711558e 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -161,7 +161,7 @@ fn ppi_overprint_preview_and_bad_params() { json!({"artboardLayout": {"layout": "spiral"}}), json!({"artboardLayout": {"columns": 0}}), json!({"artboardLayout": {"rows": 0}}), - json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1.5}}), + json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0.4}}), json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1001}}), json!({"artboardLayout": {"tiles": 2}}), json!({"units": "furlongs"}), diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 5d6b14da3b..03cab27e93 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1017,7 +1017,7 @@ fn file_new_takes_the_rows_of_a_grid_by_column() { let (plain, spaced) = (plain.with_params(&to_row, "file.new").unwrap(), spaced.with_params(&to_row, "file.new").unwrap()); assert_eq!(plain.grid_columns(), spaced.grid_columns()); let e = s.execute("file.new", &json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0}})).unwrap_err().to_string(); - assert!(e.contains("rows must be a whole number from 1 to 1000"), "{e}"); + assert!(e.contains("rows must be from 1 to 1000"), "{e}"); for layout in ["gridByRow", "row", "column"] { let e = s.execute("file.new", &json!({"artboardLayout": {"layout": layout, "rows": 2}})).unwrap_err().to_string(); assert!(e.contains("rows needs the gridByColumn layout"), "{layout}: {e}"); diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 513f27ccf9..d8b6c989d5 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -113,7 +113,7 @@ const INSIDE: &[(&str, &str)] = &[ defaultStrokeDashOffset= defaultStrokeDashes defaultStrokeDashes= defaultStrokeJoin defaultStrokeJoin= \ defaultStrokeMiterLimit defaultStrokeMiterLimit= defaultStrokeOverprint defaultStrokeOverprint= \ defaultStrokeWidth defaultStrokeWidth= defaultStroked defaultStroked= documentColorSpace groupItems \ - groupItems= height layers layers= name pageItems paragraphStyles parent pathItems pathItems= rulerOrigin \ + groupItems= height layers layers= name pageItems paragraphStyles parent pathItems rulerOrigin \ rulerOrigin= rulerUnits saveAs saveAs= scaleFactor selection selection= stories swatches swatches= \ symbols symbols= tags textFrames toString typename views width", ), diff --git a/docs/mcp.md b/docs/mcp.md index 823adc251f..7ed0eebae6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10497,7 +10497,7 @@ and goes back to Document Setup, whose OK runs `document.setup`; its Cancel goes `file.new` takes everything New Document sets: `preset` (a name from `file.newPresets`), `name`, `width`/`height` (points, or lengths such as `"210 mm"`), `units`, `orientation`, `artboards` with `artboardLayout {layout, columns, -rows, spacing, rightToLeft}` (`rows`, a whole number from 1 to 1000, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is +rows, spacing, rightToLeft}` (`rows`, 1 to 1000 and rounded to a whole number, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is an error with another layout; a preset keeps the rows, and `file.newPresets` lists them as set even when there are fewer artboards, until `columns` without `rows`, or another layout, is given; New Document's Columns shows the columns the rows give the current number of artboards, and New Document drops the rows when Columns or the layout changes), From 8f1edd06449ee3231095bf4e062184478251660f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:33:02 -0800 Subject: [PATCH 096/264] Colors: a color with a component too large to store is refused A color given as {"c": 1e300, ...}, [1e300, 0, 0], {"gray": 1e300}, a Lab color or a color object with a number past f32::MAX was stored with an infinite component. paint.setFill, artboard.setProps, swatch.new, text.create and the other commands that read colors through cmd::color_value took it. - color_value refuses a color whose components are not finite, so the commands that read a color through it answer an error and change nothing. - An effect's color (Drop Shadow, Inner Glow, Outer Glow, Shift to Color) with such a number is refused with "`color` must be a #rrggbb color". - ui.colorWheel's contrastBackground refuses it as well. Docs: docs/mcp.md. --- crates/engine/src/cmd.rs | 18 +++++++- crates/engine/src/cmd/params.rs | 12 ++--- crates/engine/src/tests/panelcmds.rs | 46 +++++++++++++++++++ crates/engine/tests/it/param_keys.rs | 14 +++++- crates/ui-egui/src/panels/color_wheel.rs | 6 ++- .../src/panels/tests_color_wheel_contrast.rs | 2 + docs/mcp.md | 10 ++-- 7 files changed, 93 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 8a4e6ebe6f..cc0abc05a3 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -672,8 +672,24 @@ pub fn matrix_param(p: &Value, key: &str) -> Option { } /// A colour from `"#rrggbb"`, a colour key (`"cmyk 0 100 100 0"`, `"lab 55 60 40"`), `[r,g,b]` (0..1), /// `{"c":..,"m":..,"y":..,"k":..}` (percent when any component is above 1, else 0..1), `{"gray":..}` or `{"l":..,"a":..,"b":..}` (CIE Lab: L 0..100, a and b about -/// −128..127). `None` for a hex color with an alpha part (`#rrggbbaa` or `#rgba`, with or without the `#`). +/// −128..127). `None` for a hex color with an alpha part (`#rrggbbaa` or `#rgba`, with or without the `#`), +/// and for a color with a component too large to store ([`color_is_finite`]). pub fn color_value(v: &Value) -> Option { + given_color(v).filter(color_is_finite) +} + +/// Is every component of `c` finite? A number past `f32::MAX`, such as `{"c": 1e300}`, is stored +/// as an infinity. +pub fn color_is_finite(c: &Color) -> bool { + match *c { + Color::Rgb { r, g, b } | Color::Lab { l: r, a: g, b } => [r, g, b].iter().all(|x| x.is_finite()), + Color::Cmyk { c, m, y, k } => [c, m, y, k].iter().all(|x| x.is_finite()), + Color::Gray { k } => k.is_finite(), + } +} + +/// The color `v` gives, as [`color_value`] reads it, with its components unchecked. +fn given_color(v: &Value) -> Option { match v { Value::String(s) if hex_with_alpha(s) => None, // A hex, or a colour key ("cmyk 0 100 100 0", as Recolor Artwork lists colours). diff --git a/crates/engine/src/cmd/params.rs b/crates/engine/src/cmd/params.rs index dcc3eade04..9b498f1ca8 100644 --- a/crates/engine/src/cmd/params.rs +++ b/crates/engine/src/cmd/params.rs @@ -43,7 +43,7 @@ use std::sync::OnceLock; use serde_json::Value; use vectorcraft_apischema::shown_key; -use super::{bad, command_specs, find_command}; +use super::{bad, color_is_finite, command_specs, find_command}; use crate::Result; /// What a params description says about the keys of the params object. @@ -608,16 +608,16 @@ pub(crate) fn undefaulted_type(effect: &str, key: &str) -> Option { /// Can an effect read `v` as its `color`: a string [`Color::from_hex`] reads (`#rrggbb`, `#rgb`, /// `#rrggbbaa`, black, white, red, green, blue), `[r, g, b]` whose first three entries are numbers -/// (read on a 0..1 scale) or a color object (`{"model": "rgb", "r": …}`)? The effect draws its -/// default color for any other value, except that an array of three or more entries draws an -/// entry that isn't a number as 0. +/// (read on a 0..1 scale) or a color object (`{"model": "rgb", "r": …}`), with no component too +/// large to store ([`color_is_finite`])? The effect draws its default color for any other value, +/// except that an array of three or more entries draws an entry that isn't a number as 0. /// /// [`Color::from_hex`]: vectorcraft_color::Color::from_hex fn is_effect_color(v: &Value) -> bool { match v { Value::String(s) => vectorcraft_color::Color::from_hex(s).is_some(), - Value::Array(a) => a.len() >= 3 && a.iter().take(3).all(Value::is_number), - Value::Object(_) => serde_json::from_value::(v.clone()).is_ok(), + Value::Array(a) => a.len() >= 3 && a.iter().take(3).all(|n| n.as_f64().is_some_and(|n| (n as f32).is_finite())), + Value::Object(_) => serde_json::from_value::(v.clone()).is_ok_and(|c| color_is_finite(&c)), _ => false, } } diff --git a/crates/engine/src/tests/panelcmds.rs b/crates/engine/src/tests/panelcmds.rs index 397c9252b5..c99f58359f 100644 --- a/crates/engine/src/tests/panelcmds.rs +++ b/crates/engine/src/tests/panelcmds.rs @@ -266,6 +266,52 @@ fn a_color_with_an_alpha_part_is_refused() { s.execute("object.rasterize", &json!({"ppi": 72, "background": "#ff0000"})).unwrap(); } +/// A color param with a component too large to store (past `f32::MAX`, which would be stored as an +/// infinity) is refused and changes nothing, in every form a color is given in: CMYK, `[r, g, b]`, +/// Gray, Lab and a color object. The ends of each range still set the color. +#[test] +fn a_color_with_a_component_too_large_to_store_is_refused() { + let mut s = session(); + let id = rect(&mut s); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + let before = s.doc().unwrap().doc.clone(); + let undo = s.doc().unwrap().history.undo.len(); + for bad in [ + json!({"c": f64::MAX, "m": 0, "y": 0, "k": 0}), + json!({"c": 0, "m": 0, "y": 0, "k": 1e308}), + json!([1e300, 0, 0]), + json!([0, 0, -1e300]), + json!({"gray": 1e300}), + json!({"l": 1e300, "a": 0, "b": 0}), + json!({"l": 50, "a": 0, "b": -1e300}), + json!({"model": "rgb", "r": 1e300, "g": 0, "b": 0}), + json!({"model": "cmyk", "c": 0, "m": 1e300, "y": 0, "k": 0}), + ] { + for (cmd, p) in [ + ("artboard.setProps", json!({"index": 0, "color": bad})), + ("artboard.new", json!({"color": bad})), + ("paint.setFill", json!({"ids": [id.0], "color": bad})), + ("paint.setStroke", json!({"ids": [id.0], "color": bad})), + ("swatch.new", json!({"name": "Far", "color": bad})), + ("swatch.new", json!({"colors": ["#00ff00", bad]})), + ("text.create", json!({"x": 10, "y": 10, "text": "a", "color": bad})), + ] { + assert!(s.execute(cmd, &p).is_err(), "{cmd} {p}"); + } + } + assert_eq!(*s.doc().unwrap().doc, *before, "a color too large to store changes nothing"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "and records no undo step"); + let fill = |s: &Session| node(s, id).appearance.fill_paint().color(); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": {"c": 100, "m": 0, "y": 0, "k": 0}})).unwrap(); + assert_eq!(fill(&s), Some(Color::cmyk(1.0, 0.0, 0.0, 0.0))); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": [1, 0, 0]})).unwrap(); + assert_eq!(fill(&s).map(|c| c.to_hex()).as_deref(), Some("#ff0000")); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": {"gray": 100}})).unwrap(); + assert_eq!(fill(&s), Some(Color::gray(1.0))); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": {"l": 100, "a": -128, "b": 127}})).unwrap(); + assert_eq!(fill(&s), Some(Color::lab(100.0, -128.0, 127.0))); +} + /// The native format writes an artboard's background color and reads it back. An artboard without /// one is written as before, with no `color` key. #[test] diff --git a/crates/engine/tests/it/param_keys.rs b/crates/engine/tests/it/param_keys.rs index fb30bf3c5c..7e80c1aedc 100644 --- a/crates/engine/tests/it/param_keys.rs +++ b/crates/engine/tests/it/param_keys.rs @@ -170,7 +170,8 @@ fn effect_params_no_longer_taken_still_replay_and_open() { } /// An effect's `color` that the effect can't read (a string `Color::from_hex` doesn't read, an -/// `[r, g, b]` without three numbers, an object that isn't a color, `null`) is refused by +/// `[r, g, b]` without three numbers, an object that isn't a color, `null`, a color with a component +/// too large to store) is refused by /// `effect.apply`, `appearance.addEffect` and `effect.setParams` themselves, not only by the check, /// and the document and its undo history stay as they were. The forms the effect reads pass. A /// document saved with an unreadable color still opens with it. @@ -186,7 +187,16 @@ fn an_effect_color_it_cannot_draw_is_refused() { }; let before = state(&s); let why = "`color` must be a #rrggbb color"; - for bad in [json!("not-a-color"), json!("#ff00"), json!([1, 0]), json!(["#ff0000", 0, 0]), json!({"gray": 50}), json!(null)] { + for bad in [ + json!("not-a-color"), + json!("#ff00"), + json!([1, 0]), + json!(["#ff0000", 0, 0]), + json!({"gray": 50}), + json!(null), + json!([1e300, 0, 0]), + json!({"model": "rgb", "r": 0, "g": 1e300, "b": 0}), + ] { for (cmd, params) in [ ("effect.setParams", json!({"index": 0, "params": {"color": bad}})), ("effect.apply", json!({"effect": "stylize.outerGlow", "params": {"color": bad}})), diff --git a/crates/ui-egui/src/panels/color_wheel.rs b/crates/ui-egui/src/panels/color_wheel.rs index 3e706b06c1..71aab82559 100644 --- a/crates/ui-egui/src/panels/color_wheel.rs +++ b/crates/ui-egui/src/panels/color_wheel.rs @@ -334,9 +334,11 @@ fn deserialize_category<'de, D: serde::Deserializer<'de>>(d: D) -> Result Option { - serde_json::from_value(v.clone()).ok().or_else(|| vectorcraft_engine::cmd::color_value(v)) + let saved = serde_json::from_value(v.clone()).ok().filter(vectorcraft_engine::cmd::color_is_finite); + saved.or_else(|| vectorcraft_engine::cmd::color_value(v)) } fn deserialize_background<'de, D: serde::Deserializer<'de>>(d: D) -> Result, D::Error> { diff --git a/crates/ui-egui/src/panels/tests_color_wheel_contrast.rs b/crates/ui-egui/src/panels/tests_color_wheel_contrast.rs index 2f938cc8e2..0b825aedc8 100644 --- a/crates/ui-egui/src/panels/tests_color_wheel_contrast.rs +++ b/crates/ui-egui/src/panels/tests_color_wheel_contrast.rs @@ -347,6 +347,8 @@ fn ui_color_wheel_sets_the_keys_given_and_refuses_bad_values() { (json!({"contrastFor": 3}), "`contrastFor` must be one of normalText, largeText, graphics"), (json!({"contrastBackground": "nope"}), "`contrastBackground` must be a color or null"), (json!({"contrast": false, "contrastBackground": 5}), "`contrastBackground` must be a color or null"), + (json!({"contrastBackground": {"model": "rgb", "r": 1e300, "g": 0, "b": 0}}), "`contrastBackground` must be a color or null"), + (json!({"contrastBackground": {"c": 0, "m": 0, "y": 0, "k": 1e300}}), "`contrastBackground` must be a color or null"), ] { assert_eq!(app.run("ui.colorWheel", p.clone()).unwrap_err(), e, "{p}"); } diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..61fa504972 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -642,7 +642,8 @@ Paint values (`fill`, `stroke`) accept `"#rrggbb"`, `"none"`, `[r,g,b]` (0..1), or a full `paint.setFill` params object (`{"gradient": …}`, `{"swatch": "name"}`). A color read this way (a fill or stroke color, a swatch's, an artboard's or new type's color, and the other colors commands read in these forms) that is given as a hex color with an alpha part (`#rrggbbaa` or `#rgba`, with or without -the `#`) is an error and changes nothing, as VectorCraft's own rule. The `color` of Drop Shadow, Inner Glow, Outer Glow +the `#`) is an error and changes nothing, as VectorCraft's own rule. So is a color with a component too large to store +as a 32-bit float, such as `{"c": 1e300, "m": 0, "y": 0, "k": 0}`. The `color` of Drop Shadow, Inner Glow, Outer Glow and Shift to Color is read differently and takes `#rrggbbaa`, as described below. For `draw_shape` and `draw_path`, omitted paint fields inherit the current [new-art appearance](#new-art). Both also style the new object in the same call: `dash` (lengths, or null for solid), `cap` @@ -2231,9 +2232,10 @@ in a replayed journal or action too, and nothing changes. The `color` of Drop Shadow, Inner Glow, Outer Glow and Shift to Color must be one the effect can read: a hex color (`#rrggbb`, `#rgb` or `#rrggbbaa`, with or without the `#`), `black`, `white`, `red`, `green` or `blue`, `[r, g, b]` -(three numbers, each read on a 0 to 1 scale), or a color object (`{"model": "rgb", "r": 1, "g": 0, "b": 0}`). -`effect.apply` and `effect.setParams` refuse any other value themselves (where the parameter check runs first, a number -or a boolean is refused as not a string), so the app's effect dialogs and Appearance panel, a step of +(three numbers, each read on a 0 to 1 scale), or a color object (`{"model": "rgb", "r": 1, "g": 0, "b": 0}`), with no +number too large to store as a 32-bit float (`[1e300, 0, 0]` is refused). `effect.apply` and `effect.setParams` +refuse any other value themselves (where the parameter check runs first, a number or a boolean is refused as not a +string), so the app's effect dialogs and Appearance panel, a step of `command.batch` and a replayed journal get the same error, and the document and its undo history stay as they were: ```json From b5affe3a0b412bb18fba9b9db6ca154f20388d68 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 07:11:52 -0800 Subject: [PATCH 097/264] CI: Desktop printing saves its Windows cache on main and builds the tests once The Windows leg found no cache on every pull request, because only a push or manual run on main saves one and the workflow had no push trigger. A push to main that touches the same paths now saves the entry that pull requests restore. Both test runs now select the app and the UI crate together, so Cargo resolves features once and the printps run reuses the first run's dependencies instead of rebuilding 94 crates. The first run keeps every app test (the binary's unit tests and `tests/it`). --- .github/workflows/print.yml | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/print.yml b/.github/workflows/print.yml index 8cdaf0cb28..ac941b5098 100644 --- a/.github/workflows/print.yml +++ b/.github/workflows/print.yml @@ -7,9 +7,26 @@ on: - "apps/vectorcraft/Cargo.toml" - "apps/vectorcraft/src/printing.rs" - "apps/vectorcraft/src/printing/**" + - "crates/ui-egui/Cargo.toml" - "crates/ui-egui/src/print.rs" - "crates/ui-egui/src/tests/printps.rs" - ".github/workflows/print.yml" + # A push to main saves the Windows cache entry that pull requests restore. + push: + branches: [main] + paths: + - "Cargo.toml" + - "Cargo.lock" + - "apps/vectorcraft/Cargo.toml" + - "apps/vectorcraft/src/printing.rs" + - "apps/vectorcraft/src/printing/**" + - "crates/ui-egui/Cargo.toml" + - "crates/ui-egui/src/print.rs" + - "crates/ui-egui/src/tests/printps.rs" + - ".github/workflows/print.yml" + # A weekly run on main saves a fresh entry after a new stable Rust changes the cache key. + schedule: + - cron: "23 6 * * 1" workflow_dispatch: permissions: contents: read @@ -18,15 +35,14 @@ concurrency: group: print-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - # Desktop printing on Windows, through the suite's shared gate. Pull requests restore the cache - # but never save one; a manual run on main saves the cache they restore. + # Desktop printing on Windows, through the suite's shared gate. Pushes to main, the weekly run and + # manual runs on main save the cache; pull requests restore it and never save one. windows: # Tracks @main so suite-wide CI fixes reach every app without a PR in each repository. uses: storytold/craft-common-actions/.github/workflows/gate.yml@main with: os: '["windows-2022"]' - # A change to Cargo.lock finds no cache (only main saves one) and builds everything cold: - # about 55 minutes for `-p vectorcraft` alone, then the UI crate's tests. + # A run that finds no cache builds everything cold, which took 76 to 126 minutes. timeout-minutes: 150 # As in ci.yml: test binaries without debug info or symbols, and workspace crates without # line tables. A panic still names its file and line. @@ -36,10 +52,14 @@ jobs: craft-fonts-ref: "" tools: "" targets: "" - # A filter that matches nothing still passes, so the printps run fails unless some test ran. + # Both test runs select the same two packages, so Cargo resolves features once and the + # second run reuses the first run's dependencies. The first runs every test of the app + # (`--bin vectorcraft --test it`), the second the UI crate's `tests::printps` tests. A filter + # that matches nothing still passes, so the printps run fails unless some test ran. command: | + set -o pipefail cargo clippy --locked -p vectorcraft --all-targets -- -D warnings - cargo test --locked -p vectorcraft + cargo test --locked -p vectorcraft -p vectorcraft-ui-egui --bin vectorcraft --test it log="$RUNNER_TEMP/printps.log" - cargo test --locked -p vectorcraft-ui-egui --lib -- tests::printps | tee "$log" + cargo test --locked -p vectorcraft -p vectorcraft-ui-egui --lib -- tests::printps | tee "$log" grep -Eq 'test result: ok\. [1-9][0-9]* passed' "$log" || { echo "::error::tests::printps matched no tests"; exit 1; } From 295296947eba240c08058b41fcb14b6d4dc0de8e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 08:09:58 -0800 Subject: [PATCH 098/264] MCP: the Simplify and Smooth sliders show in ui.inspect and answer ui.dialog The params text of ui.simplifyAuto and ui.smoothAuto and docs/mcp.md say Object > Path > Simplify and Smooth open the dialogs simplifySlider and smoothSlider with field `level`, kept by ui.dialog.confirm. The sliders are a strip over the canvas, not hosted dialogs, so ui.inspect listed no dialog while one was open and ui.dialog.set and ui.dialog.confirm had nothing to answer. - ui.inspect lists the open slider as {id, parent, key, fields: {level}}, first in `dialogs`, so "top" still names a hosted dialog open over it. - ui.dialog.set {field: "level", value} moves the slider to a level from 0 to 100 and previews it. A value outside that range, a value that is not a number, another field, or a set while another edit holds the interaction is refused and leaves the level as it was. - ui.dialog.confirm keeps the preview as one undo step, as Enter does, and ui.dialog.cancel puts the paths back, as Escape does. A set with `action` answers in the same request and replies {dialog, result}. --- crates/ui-egui/src/control.rs | 13 +- crates/ui-egui/src/dialogs/simplify_slider.rs | 143 +++++++++++++++++ crates/ui-egui/src/dialogs/tests_modal.rs | 146 ++++++++++++++++++ 3 files changed, 301 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index c0c6bd0bc6..7495e0ed02 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -18,7 +18,8 @@ //! - `ui.find`: the controls of the window's access tree that match a name or role //! - `ui.set {brightness?, panel?, dockTab?, rulers?, outline?, …}` //! - `ui.dialog.set` / `ui.dialog.confirm` / `ui.dialog.cancel`: answered by -//! `craft::automation::dialogs::dialog_method` for the dialog asked for (`dialog`, default `"top"`) +//! `craft::automation::dialogs::dialog_method` for the dialog asked for (`dialog`, default `"top"`), and by +//! `dialogs::simplify_slider::dialog_method` for the Simplify and Smooth sliders //! - `ui.resize {width, height}`, `ui.focus`, `ui.screenshot {path?, focus?}` (without a path the //! PNG comes back in the reply) //! - `ui.render {path?, scale?, artboard?, data?, traceViews?}`: render an artboard headlessly @@ -152,6 +153,10 @@ pub fn inspect(app: &VectorcraftApp, ctx: &egui::Context) -> Value { } let mut dialogs = app.dialogs().map_or_else(|| json!([]), |dialogs| dialogs.with(|host| craft::automation::dialogs::inspect(host))); crate::dialogs::javascript_files::show_selected(app, &mut dialogs); + // The Simplify or Smooth slider over the canvas, listed first: `"top"` names a hosted dialog open with it. + if let (Some(open), Some(strip)) = (dialogs.as_array_mut(), crate::dialogs::simplify_slider::inspected(app)) { + open.insert(0, strip); + } json!({ "scriptRunning": app.session.script_running(), "scriptReport": app.session.shown_script_report(), @@ -1437,6 +1442,12 @@ fn dispatch(app: &mut VectorcraftApp, ctx: &egui::Context, method: &str, p: &Val if crate::prefs_dialog::is_open(app) && (p["dialog"] == "preferences" || (top && dialogs.with(|host| host.stack().is_empty()))) { return wrap(preferences_method(app, method, p)); } + // The Simplify and Smooth sliders are the app's own strip over the canvas, not hosted dialogs: they take a + // request that names them, or the top dialog while no hosted dialog is open. + let hosted_open = dialogs.with(|host| !host.stack().is_empty()); + if let Some(r) = crate::dialogs::simplify_slider::dialog_method(app, method, p, hosted_open) { + return wrap(r); + } // The dialog asked for is `dialog`, the top one when it is missing. let mut params = if p.is_object() { p.clone() } else { json!({}) }; if params.get("dialog").is_none_or(Value::is_null) { diff --git a/crates/ui-egui/src/dialogs/simplify_slider.rs b/crates/ui-egui/src/dialogs/simplify_slider.rs index cb58f856a7..2a4f5b0f9c 100644 --- a/crates/ui-egui/src/dialogs/simplify_slider.rs +++ b/crates/ui-egui/src/dialogs/simplify_slider.rs @@ -13,11 +13,14 @@ // PLAN: the framework paths below (`craft_ui_widgets`, `craft_ui_contract`, `craft_behavior`) and // `LivePreview`'s module are assumed; no app file imports them yet. +use craft::automation::dialogs::MAX_DIALOG_FIELDS; +use craft::automation::protocol::Params; use craft::behavior::overlay::{Align, Side}; use craft::behavior::{CanvasView, IconId}; use craft::ui::buttons::IconButton; use craft::ui::contract::overlay::{Anchor, Dismiss, Outside, Place}; use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _}; +use craft::ui::dialog::dialog_id; use craft::ui::layout_components::Row; use craft::ui::popover::Popover; use craft::ui::primitives::IconSpec; @@ -78,6 +81,20 @@ impl StripKind { StripKind::Smooth => SMOOTH_AUTO_LEVEL, } } + + /// The dialog key `ui.inspect` lists the strip under, which `ui.dialog.set`, `ui.dialog.confirm` and + /// `ui.dialog.cancel` take as `dialog`. + pub(crate) fn key(self) -> &'static str { + match self { + StripKind::Simplify => "simplifySlider", + StripKind::Smooth => "smoothSlider", + } + } + + /// The id `ui.inspect` lists the strip under: the one a hosted dialog with the same key has, as a decimal string. + fn id(self) -> String { + dialog_id(self.key()).value().to_string() + } } /// An open slider strip: the level the canvas previews, the selection's bounds from before any @@ -210,6 +227,132 @@ pub(crate) fn more_options(app: &mut VectorcraftApp) -> Result { Ok(json!({ "tolerance": tolerance })) } +/// The open strip as `ui.inspect` lists a dialog, `{id, parent, key, fields: {level}}`; `None` when no strip shows. +pub(crate) fn inspected(app: &VectorcraftApp) -> Option { + let strip = app.object_dialogs.strip.as_ref().filter(|strip| strip.in_source(app))?; + let kind = strip.kind; + Some(json!({ "id": kind.id(), "parent": null, "key": kind.key(), "fields": { "level": strip.level() } })) +} + +/// The level a `ui.dialog.set` on a strip of `kind` asks for: field `level`, a number from 0 to 100, as `field` and +/// `value` or as the last item of `fields`. `None` when it sets nothing. +fn requested_level(kind: StripKind, params: &Value) -> Result, String> { + let level = |field: &Value, value: &Value| { + let field = field.as_str().ok_or("`field` is not a string")?; + if field != "level" { + return Err(format!("the {} slider has no field `{field}`", kind.label())); + } + match value.as_f64() { + Some(level) if (0.0..=100.0).contains(&level) => Ok(level), + _ => Err("`level` must be a number from 0 to 100".to_string()), + } + }; + let Some(list) = params.get("fields") else { + return match params.get("field") { + Some(field) => level(field, params.get("value").unwrap_or(&Value::Null)).map(Some), + None if params.get("value").is_some() => Err("missing `field`".into()), + None => Ok(None), + }; + }; + if params.get("field").is_some() || params.get("value").is_some() { + return Err("`fields` takes the place of `field` and `value`".into()); + } + let items = list.as_array().ok_or("`fields` is not a list")?; + if items.len() > MAX_DIALOG_FIELDS { + return Err(format!("`fields` holds {} items; at most {MAX_DIALOG_FIELDS}", items.len())); + } + let mut last = None; + for item in items { + last = Some(level(item.get("field").unwrap_or(&Value::Null), item.get("value").unwrap_or(&Value::Null))?); + } + Ok(last) +} + +/// `ui.dialog.set`, `ui.dialog.confirm` and `ui.dialog.cancel` (`method`) when `params.dialog` names the open strip: +/// its key or the id [`inspected`] lists, or `"top"` (or no `dialog`) while `hosted_open` is false. `None` for any +/// other dialog. +/// +/// `ui.dialog.set {field: "level", value}` moves the slider and previews the level, then answers with `action` +/// (`confirm` or `cancel`) when one is given; a set it refuses leaves the slider as it was. `ui.dialog.confirm` keeps +/// the preview as one undo step, as Enter does, and `ui.dialog.cancel` puts the paths back, as Escape does. +pub(crate) fn dialog_method(app: &mut VectorcraftApp, method: &str, params: &Value, hosted_open: bool) -> Option> { + let kind = app.object_dialogs.strip.as_ref().filter(|strip| strip.in_source(app))?.kind; + let ours = match params.get("dialog") { + None | Some(Value::Null) => !hosted_open, + Some(Value::String(named)) if named == "top" => !hosted_open, + Some(Value::String(named)) => named == kind.key() || *named == kind.id(), + Some(named) => named.as_u64().is_some_and(|id| id.to_string() == kind.id()), + }; + if !ours { + return None; + } + let keys: &[&str] = match method { + "ui.dialog.set" => &["dialog", "field", "value", "fields", "action"], + "ui.dialog.confirm" | "ui.dialog.cancel" => &["dialog"], + _ => return None, + }; + if let Err(e) = Params(params).only(None, keys) { + return Some(Err(e)); + } + let answer = match (method, params.get("action")) { + ("ui.dialog.confirm", _) => Some(true), + ("ui.dialog.cancel", _) => Some(false), + (_, None | Some(Value::Null)) => None, + (_, Some(action)) if action == "confirm" => Some(true), + (_, Some(action)) if action == "cancel" => Some(false), + (_, Some(_)) => return Some(Err("`action` must be confirm or cancel".into())), + }; + let level = if method == "ui.dialog.set" { + match requested_level(kind, params) { + Ok(None) if answer.is_none() => return Some(Err("missing `field`".into())), + Ok(level) => level, + Err(e) => return Some(Err(e)), + } + } else { + None + }; + let mut strip = app.object_dialogs.strip.take()?; + if let Some(level) = level { + let before = strip.level; + strip.level = level; + let params = strip.params(); + let ran = strip.preview.run(app, true, kind.label(), kind.cmd(), ¶ms); + // Nothing ran: the canvas already previews this level, or another edit holds the interaction. + let shown = || { + app.session + .active() + .and_then(|doc| doc.interaction.as_ref()?.preview.as_ref()) + .is_some_and(|(cmd, showing)| cmd == kind.cmd() && showing == ¶ms) + }; + let error = match ran { + Some(Err(e)) => Some(e), + None if !shown() => Some(tl!("Finish the active edit first.").to_owned()), + _ => None, + }; + if let Some(e) = error { + strip.level = before; + app.object_dialogs.strip = Some(strip); + return Some(Err(e)); + } + } + app.object_dialogs.strip = Some(strip); + let set = inspected(app).unwrap_or(Value::Null); + let Some(answer) = answer else { return Some(Ok(set)) }; + let strip = app.object_dialogs.strip.take()?; + let result = if answer { + let params = strip.params(); + strip.preview.commit(app, kind.cmd(), params).map(|_| Value::Null) + } else { + strip.cancel(app); + Ok(Value::Null) + }; + // A set with an `action` replies `{dialog, result}`: the slider as the set left it, and the answer's result. + Some(match (method, result) { + ("ui.dialog.set", Ok(result)) => Ok(json!({ "dialog": set, "result": result })), + (_, result) => result, + }) +} + /// Where the strip hangs: a point under the lowest corner on screen of the selection's bounds from /// before the preview, centred on them, kept on the canvas. fn anchor_rect(view: &CanvasView, bounds: Option) -> ScreenRect { diff --git a/crates/ui-egui/src/dialogs/tests_modal.rs b/crates/ui-egui/src/dialogs/tests_modal.rs index e9a2166fa7..f54cd71999 100644 --- a/crates/ui-egui/src/dialogs/tests_modal.rs +++ b/crates/ui-egui/src/dialogs/tests_modal.rs @@ -326,3 +326,149 @@ fn path_sliders_close_when_file_revert_restores_the_artwork() { assert!(app.session.in_interaction()); } } + +/// The two sliders: the dialog key `ui.inspect` lists, the menu command that opens it and its undo step's name. +const PATH_SLIDERS: [(&str, &str, &str); 2] = + [("simplifySlider", "object.path.simplify", "Simplify"), ("smoothSlider", "object.path.smooth", "Smooth")]; + +/// One control channel request, answered at once. +fn control(app: &mut VectorcraftApp, method: &str, params: serde_json::Value) -> serde_json::Value { + let ctx = app.ui_ctx.clone().unwrap(); + let (req, _) = craft::automation::ControlRequest::new(method, params); + let craft::automation::Reply::Done(r) = crate::control::handle(app, &ctx, &req) else { panic!("{method} answered later") }; + r +} + +/// The open dialog `key` in `ui.inspect`'s `dialogs`. +fn inspected_dialog(app: &mut VectorcraftApp, key: &str) -> Option { + let r = control(app, "ui.inspect", json!({})); + r["result"]["dialogs"].as_array()?.iter().find(|d| d["key"] == key).cloned() +} + +/// Both sliders show in `ui.inspect` as the dialog their params text names, with field `level`. `ui.dialog.set` +/// moves the slider and previews the level, and `ui.dialog.confirm` keeps the result as one undo step. +#[test] +fn path_sliders_show_in_ui_inspect_and_ui_dialog_confirm_keeps_the_level() { + for (key, command, label) in PATH_SLIDERS { + let mut app = app_with_dense_path(); + let undo_len = app.session.doc().unwrap().history.undo.len(); + crate::menus::invoke(&mut app, command, json!({})); + settle(&mut app); + let open = inspected_dialog(&mut app, key).unwrap_or_else(|| panic!("{key} in ui.inspect")); + assert!(open["fields"]["level"].is_number(), "{open}"); + + let r = control(&mut app, "ui.dialog.set", json!({"dialog": key, "field": "level", "value": 20})); + assert_eq!(r["ok"], true, "{r}"); + assert_eq!(r["result"]["fields"]["level"], 20.0, "{r}"); + let preview = app.session.doc().unwrap().interaction.as_ref().and_then(|it| it.preview.clone()).map(|p| p.1); + assert_eq!(preview, Some(json!({"level": 20.0})), "{key}"); + settle(&mut app); + assert_eq!(inspected_dialog(&mut app, key).map(|d| d["fields"]["level"].clone()), Some(json!(20.0)), "{key}"); + + let r = control(&mut app, "ui.dialog.confirm", json!({"dialog": key})); + assert_eq!(r["ok"], true, "{r}"); + assert!(inspected_dialog(&mut app, key).is_none(), "{key}"); + assert!(!app.session.in_interaction(), "{key}"); + let history = &app.session.doc().unwrap().history; + assert_eq!(history.undo.len(), undo_len + 1, "{key}"); + assert_eq!(history.undo.last().map(|step| step.label.as_str()), Some(label), "{key}"); + } +} + +/// A repeated level succeeds, but another active edit blocks a set and leaves the slider's level unchanged. +#[test] +fn path_sliders_refuse_a_set_when_another_edit_owns_the_interaction() { + for (key, command, _) in PATH_SLIDERS { + let mut app = app_with_dense_path(); + crate::menus::invoke(&mut app, command, json!({})); + settle(&mut app); + for _ in 0..2 { + let r = control(&mut app, "ui.dialog.set", json!({"dialog": key, "field": "level", "value": 30})); + assert_eq!(r["ok"], true, "{key}: {r}"); + } + let level = inspected_dialog(&mut app, key).unwrap_or_else(|| panic!("{key} in ui.inspect"))["fields"]["level"].clone(); + app.session.cancel_interaction().unwrap(); + app.begin_interaction("Other").unwrap(); + + let r = control(&mut app, "ui.dialog.set", json!({"dialog": key, "field": "level", "value": 20})); + assert_eq!(r["ok"], false, "{key}: {r}"); + assert_eq!(inspected_dialog(&mut app, key).map(|d| d["fields"]["level"].clone()), Some(level.clone()), "{key}"); + settle(&mut app); + assert_eq!(inspected_dialog(&mut app, key).map(|d| d["fields"]["level"].clone()), Some(level), "{key}"); + } +} + +/// `ui.dialog.set` with `action` sets the level and answers in one request, replying `{dialog, result}` with the +/// slider as the set left it: `confirm` keeps the level as one undo step, and `cancel` puts the paths back. +#[test] +fn path_sliders_answer_a_set_with_an_action_in_one_request() { + for (key, command, label) in PATH_SLIDERS { + for action in ["confirm", "cancel"] { + let mut app = app_with_dense_path(); + let before = app.session.active().unwrap().doc.clone(); + let undo_len = app.session.doc().unwrap().history.undo.len(); + crate::menus::invoke(&mut app, command, json!({})); + settle(&mut app); + let r = control(&mut app, "ui.dialog.set", json!({"dialog": key, "fields": [{"field": "level", "value": 30}], "action": action})); + assert_eq!(r["ok"], true, "{key} {action}: {r}"); + assert_eq!(r["result"]["dialog"]["key"], key, "{r}"); + assert_eq!(r["result"]["dialog"]["fields"]["level"], 30.0, "{r}"); + assert!(r["result"].get("result").is_some(), "{r}"); + assert!(inspected_dialog(&mut app, key).is_none(), "{key} {action}"); + assert!(!app.session.in_interaction(), "{key} {action}"); + let history = &app.session.doc().unwrap().history; + if action == "confirm" { + assert_eq!(history.undo.len(), undo_len + 1, "{key}"); + assert_eq!(history.undo.last().map(|step| step.label.as_str()), Some(label), "{key}"); + } else { + assert_eq!(history.undo.len(), undo_len, "{key}"); + assert_eq!(app.session.active().unwrap().doc, before, "{key}"); + } + } + } +} + +/// With a hosted dialog open over a slider, `ui.inspect` lists the slider first, and `"top"` names the hosted dialog. +#[test] +fn path_sliders_list_below_a_hosted_dialog_that_top_names() { + let mut app = app_with_dense_path(); + crate::menus::invoke(&mut app, "object.path.simplify", json!({})); + settle(&mut app); + app.run("ui.javascriptFilesDialog", json!({})).unwrap(); + let r = control(&mut app, "ui.inspect", json!({})); + let open = r["result"]["dialogs"].as_array().cloned().unwrap_or_default(); + assert!(open.len() >= 2 && open[0]["key"] == "simplifySlider", "{open:?}"); + let r = control(&mut app, "ui.dialog.cancel", json!({"dialog": "top"})); + assert_eq!(r["ok"], true, "{r}"); + assert!(inspected_dialog(&mut app, "simplifySlider").is_some(), "the hosted dialog closed, the slider stays"); + let r = control(&mut app, "ui.inspect", json!({})); + assert_eq!(r["result"]["dialogs"].as_array().map(Vec::len), Some(open.len() - 1), "{r}"); +} + +/// `ui.dialog.cancel` on the top dialog puts the paths back, as Escape does. A level outside 0..100, a value that +/// isn't a number and another field are refused, and the slider keeps its level. +#[test] +fn path_sliders_answer_ui_dialog_cancel_and_refuse_bad_fields() { + for (key, command, _) in PATH_SLIDERS { + let mut app = app_with_dense_path(); + let before = app.session.active().unwrap().doc.clone(); + let undo_len = app.session.doc().unwrap().history.undo.len(); + crate::menus::invoke(&mut app, command, json!({})); + settle(&mut app); + let level = inspected_dialog(&mut app, key).unwrap_or_else(|| panic!("{key} in ui.inspect"))["fields"]["level"].clone(); + for bad in [json!({"field": "level", "value": 101}), json!({"field": "level", "value": "20"}), json!({"field": "tolerance", "value": 2})] { + let mut params = bad.clone(); + params["dialog"] = json!(key); + let r = control(&mut app, "ui.dialog.set", params); + assert_eq!(r["ok"], false, "{key} {bad}: {r}"); + assert_eq!(inspected_dialog(&mut app, key).map(|d| d["fields"]["level"].clone()), Some(level.clone()), "{key} {bad}"); + } + + let r = control(&mut app, "ui.dialog.cancel", json!({})); + assert_eq!(r["ok"], true, "{r}"); + assert!(inspected_dialog(&mut app, key).is_none(), "{key}"); + assert!(!app.session.in_interaction(), "{key}"); + assert_eq!(app.session.active().unwrap().doc, before, "{key}"); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo_len, "{key}"); + } +} From 59b4e54710d297ed76e59a4fe39baf48904ef143 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:08:57 -0800 Subject: [PATCH 099/264] Build: the workspace manifest prints no unused-dependency or unused-patch warnings Every cargo command printed seven manifest warnings, and clippy on all targets printed one more. Each entry below had no reader on main. - peniko (workspace dependency): no member crate has ever declared it. It has been in the list since the workspace skeleton (bfee80a22c). crates/render reaches peniko through vello_cpu::peniko. - rfd and webbrowser (workspace dependencies): #8800 moved the app onto the craft UI framework and removed their last declarations in apps/vectorcraft and crates/ui-egui. The folder picker and the browser links now come from craft-libs. The rfd name in xtask's layer check is a crate name to reject, so it does not read this entry. - workspace.package.repository: no member crate sets repository.workspace = true, and no packaging script, xtask command or workflow reads the field. - egui_demo_lib, egui_inspection and egui_system_font_provider ([patch.crates-io]): #8800 copied these from craft-libs' own patch list, and nothing in VectorCraft's graph depends on them. Cargo.lock listed them under [[patch.unused]]. A dependency's [patch] does not apply in this workspace, so removing them does not change how craft-libs builds. The egui crates that are in the graph keep their patches at 932a73b285. - apps/vectorcraft-web declared egui_extras for every target, but only the wasm32 module web.rs calls it. It now sits under the wasm32 target dependencies. Cargo.lock drops the three [[patch.unused]] entries. --- Cargo.lock | 15 --------------- Cargo.toml | 7 ------- apps/vectorcraft-web/Cargo.toml | 3 ++- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 520647b95d..d12ce6efa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10758,18 +10758,3 @@ dependencies = [ "syn 3.0.9", "winnow", ] - -[[patch.unused]] -name = "egui_demo_lib" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" - -[[patch.unused]] -name = "egui_inspection" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" - -[[patch.unused]] -name = "egui_system_font_provider" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" diff --git a/Cargo.toml b/Cargo.toml index a0fb986dcc..f8b43c538d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ version = "0.24.1" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" -repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } @@ -86,7 +85,6 @@ vectorcraft-apischema = { path = "crates/apischema" } # foundation kurbo = { version = "0.13", features = ["serde"] } -peniko = "0.6" thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = { version = "1", features = ["float_roundtrip"] } @@ -156,10 +154,8 @@ egui = "0.37" egui_extras = { version = "0.37", default-features = false, features = ["svg"] } eframe = { version = "0.37", default-features = false } egui_kittest = "0.37" -rfd = "0.17" arboard = { version = "3.6", default-features = false } clipboard-win = "5.4" -webbrowser = "1" [workspace.lints.rust] unsafe_code = "deny" @@ -210,8 +206,5 @@ egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560 egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index e8b56c29a9..d4293d8320 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -20,12 +20,13 @@ vectorcraft-format = { workspace = true } vectorcraft-text = { workspace = true } craft = { workspace = true, features = ["ui", "keymap", "automation", "platform"] } egui = { workspace = true } -egui_extras = { workspace = true } log = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } +# The image loaders `web.rs` installs. +egui_extras = { workspace = true } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", version = "0.1.0" } From 91e4c6fbce8060b4cb35fbc4ec7531410692f092 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:10:42 -0800 Subject: [PATCH 100/264] Engine: end_folder no longer warns about unused s and turn on wasm32 end_folder uses its Session and StoreTurn only in the native arm that finishes loaded modules and saves the disabled list. The wasm32 build has no such arm, so rustc reported both parameters as unused there. The function now marks them used under cfg(target_arch = "wasm32"), as install_folder above it already does. cargo check -p vectorcraft-engine --target wasm32-unknown-unknown: 2 warnings in vectorcraft-engine before, 0 after. The manifest and patch warnings it also prints are unchanged. --- crates/engine/src/cmd/plugin.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/engine/src/cmd/plugin.rs b/crates/engine/src/cmd/plugin.rs index 10899074d9..c8a3c2b46a 100644 --- a/crates/engine/src/cmd/plugin.rs +++ b/crates/engine/src/cmd/plugin.rs @@ -1914,6 +1914,9 @@ pub(crate) fn install_folder(s: &mut Session, load: &mut FolderPending, turn: &S /// the grants of ids whose module lists no permissions are forgotten while no `plugin.install` can /// record one for another module → its report; saves the disabled list when loading changed it. pub(crate) fn end_folder(s: &mut Session, mut load: FolderPending, turn: &StoreTurn) -> Value { + // Only native builds load modules, so only they save the disabled list. + #[cfg(target_arch = "wasm32")] + let _ = (s, turn); let (report, retry) = match load.load.take() { #[cfg(not(target_arch = "wasm32"))] Some(Ok(modules)) => { From b19aac26ec46020afc30997752ad3d699f9155db Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:21:40 -0800 Subject: [PATCH 101/264] Selection Tools: Edit Points Only narrows a Direct Selection to its anchor points addon.select.editPointsOnly {segmentEnds?} turns the current selection into one that holds only anchor points, so a move or transform that follows acts on the points alone. Selected segments leave the selection, and the points at their ends leave it too unless segmentEnds is true. Paths selected whole keep every point. A group or compound path selected whole gives way to the visible, unlocked paths inside it (no Shaper Group originals, and no guide paths while guides are locked). Type, images, symbols and other objects without anchor points leave the selection. Only the selection changes, so there is no undo step. With nothing selected or nothing left to keep it is an error and the selection stays as it was. The command is on the plug-in allowed list. Object > Plug-ins > Selection Tools > Edit Points Only... opens a dialog with Keep Ends of Selected Segments; it previews the narrowed selection on the canvas, OK keeps it and Cancel puts the selection back. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/cmd/addons/select.rs | 122 ++++++++++++- crates/engine/src/cmd/addons/select/tests.rs | 160 ++++++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/engine/tests/command_sweep.rs | 2 + crates/ui-egui/src/addons/dialogs.rs | 1 + crates/ui-egui/src/addons/select.rs | 7 +- .../ui-egui/src/addons/select/points_only.rs | 51 ++++++ .../src/addons/select/points_only/tests.rs | 85 ++++++++++ docs/mcp.md | 21 +++ docs/target-app-parity.md | 1 + 10 files changed, 444 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/addons/select/points_only.rs create mode 100644 crates/ui-egui/src/addons/select/points_only/tests.rs diff --git a/crates/engine/src/cmd/addons/select.rs b/crates/engine/src/cmd/addons/select.rs index c9ae29a303..6c3346ca80 100644 --- a/crates/engine/src/cmd/addons/select.rs +++ b/crates/engine/src/cmd/addons/select.rs @@ -1,17 +1,19 @@ //! Selection Tools (`addon.select.*`), a built-in add-on: Select by Artboards selects the objects //! overlapping, fully inside or fully outside one or more chosen artboards (#5525), and Select by //! Link Status selects the images and placed documents whose file is linked, embedded, missing or -//! modified (#5526), saying which ones it had to leave out and why. Its submenu (Object › Plug-ins -//! › Selection Tools), the Links panel's menu items and the dialogs are the UI's. +//! modified (#5526), saying which ones it had to leave out and why. Edit Points Only narrows the +//! selection to the anchor points selected in it, dropping selected segments and objects without +//! anchor points. Its submenu (Object › Plug-ins › Selection Tools), the Links panel's menu items +//! and the dialogs are the UI's. #[cfg(test)] mod tests; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet, HashSet}; use serde_json::{Value, json}; -use vectorcraft_doc::{LockedArtboards, Node, NodeId, NodeKind}; -use vectorcraft_geom::Point; +use vectorcraft_doc::{AnchorRef, LockedArtboards, Node, NodeId, NodeKind}; +use vectorcraft_geom::{PathData, Point}; use super::super::links::{Status, statuses}; use super::super::panelcmds::listed_artboards; @@ -47,6 +49,15 @@ pub fn specs() -> Vec { has_doc, by_link_status ), + cmd!( + "addon.select.editPointsOnly", + "Edit Points Only", + ["Object", "Plug-ins", "Selection Tools"], + None, + "{segmentEnds?: false (true: the points at the ends of each selected segment stay selected, as anchor points)} narrow the selection to the anchor points selected in it, so that a move or transform that follows acts on those points alone: a path with selected anchor points keeps them; a path with selected segments drops the segments and keeps its other selected anchor points, and the points at the segments' ends leave the selection unless segmentEnds is true; a path selected whole keeps all its points; a group or compound path selected whole gives way to the paths inside it, each selected whole, leaving out hidden and locked ones, a Shaper Group's original shapes and, while guides are locked, paths made into guides; type, images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. With nothing selected, or no anchor point left to keep, it is an error that leaves the selection as it was. Only the selection changes, not the document, so there is nothing to undo → {changed (false when the selection already held only anchor points), count (the paths left selected), points (the anchor points selected on them)}", + has_doc, + edit_points_only + ), ] } @@ -193,3 +204,104 @@ fn by_link_status(s: &mut Session, p: &Value) -> Result { } Ok(out) } + +/// The anchor points of `path` that `refs` names, leaving out references to points it does not have. +fn on_path(path: &PathData, refs: &BTreeSet) -> BTreeSet { + refs.iter().copied().filter(|&(si, ai)| path.subpaths.get(si).is_some_and(|sp| ai < sp.anchors.len())).collect() +} + +/// The points at the ends of the segments `segments` of `path`. +fn segment_ends(path: &PathData, segments: &BTreeSet) -> BTreeSet { + let mut ends = BTreeSet::new(); + for &(si, seg) in segments { + if let Some(sp) = path.subpaths.get(si) { + ends.extend([(si, seg), (si, (seg + 1) % sp.anchors.len().max(1))]); + } + } + ends +} + +/// The paths inside container `n` with at least one anchor point, depth first, through the groups +/// and compound paths in it: hidden and locked objects (and what they hold), a Shaper Group's +/// original shapes, and paths made into guides while `guides_locked`, are left out. +fn paths_inside<'a>(n: &'a Node, guides_locked: bool, out: &mut Vec<&'a Node>) { + let originals = usize::from(n.extras().shaper.is_some()); + for c in n.children().into_iter().flatten().skip(originals) { + if !c.visible || c.locked { + continue; + } + match &c.kind { + NodeKind::Path { guide: true, .. } if guides_locked => {} + NodeKind::Path { path, .. } if path.anchors().next().is_some() => out.push(c), + NodeKind::Group { .. } | NodeKind::Compound { .. } => paths_inside(c, guides_locked, out), + _ => {} + } + } +} + +/// `addon.select.editPointsOnly`: narrow the selection to the anchor points selected in it. +fn edit_points_only(s: &mut Session, p: &Value) -> Result { + const C: &str = "addon.select.editPointsOnly"; + let keep_ends = switch_or(p, "segmentEnds", false, C)?; + let guides_locked = s.menu.guides_locked; + let st = s.doc()?; + let (doc, sel) = (&st.doc, &st.selection); + if sel.objects.is_empty() { + return Err(bad(C, "select anchor points or segments first")); + } + // Each path once, in selection order, with its points kept: `None` for all of them. + let mut seen = HashSet::new(); + let mut kept: Vec<(NodeId, usize, Option>)> = vec![]; + for id in &sel.objects { + let Some(n) = doc.node(*id) else { continue }; + match &n.kind { + NodeKind::Path { path, .. } => { + let Some(refs) = sel.anchors.get(id) else { + let count = path.anchors().count(); + if count > 0 && seen.insert(*id) { + kept.push((*id, count, None)); + } + continue; + }; + let mut picked = on_path(path, refs); + if let Some(segments) = sel.segments.get(id) + && !keep_ends + { + let ends = segment_ends(path, segments); + picked.retain(|r| !ends.contains(r)); + } + if !picked.is_empty() && seen.insert(*id) { + kept.push((*id, picked.len(), Some(picked))); + } + } + NodeKind::Group { .. } | NodeKind::Compound { .. } => { + let mut inside = vec![]; + paths_inside(n, guides_locked, &mut inside); + for c in inside { + if seen.insert(c.id) { + kept.push((c.id, c.path_data().map_or(0, |path| path.anchors().count()), None)); + } + } + } + _ => {} + } + } + let points: usize = kept.iter().map(|(_, n, _)| n).sum(); + let objects: Vec = kept.iter().map(|(id, ..)| *id).collect(); + let anchors: BTreeMap> = kept.into_iter().filter_map(|(id, _, set)| Some((id, set?))).collect(); + if objects.is_empty() { + return Err(bad(C, "no anchor points are selected")); + } + let changed = objects != sel.objects || anchors != sel.anchors || !sel.segments.is_empty() || !sel.guides.is_empty(); + let count = objects.len(); + if changed { + s.select(|_, sel| { + let (key, key_anchor) = (sel.key.filter(|k| objects.contains(k)), sel.key_anchor); + sel.set(objects); + sel.anchors = anchors; + sel.key = key; + sel.key_anchor = key_anchor; + })?; + } + Ok(json!({ "changed": changed, "count": count, "points": points })) +} diff --git a/crates/engine/src/cmd/addons/select/tests.rs b/crates/engine/src/cmd/addons/select/tests.rs index 09106a3652..85844c241d 100644 --- a/crates/engine/src/cmd/addons/select/tests.rs +++ b/crates/engine/src/cmd/addons/select/tests.rs @@ -337,3 +337,163 @@ mod by_link_status { assert!(Session::new().execute(C, &json!({"status": "linked"})).is_err()); } } + +/// Edit Points Only. +mod edit_points_only { + use std::collections::{BTreeMap, BTreeSet}; + + use serde_json::{Value, json}; + use vectorcraft_doc::NodeId; + + use super::rect; + use crate::Session; + + const C: &str = "addon.select.editPointsOnly"; + + /// A document with two rectangles, `a` and `b` (four anchors each, anchor 0 first). + fn two() -> (Session, NodeId, NodeId) { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let a = rect(&mut s, 10.0, 10.0, 50.0, 50.0); + let b = rect(&mut s, 100.0, 10.0, 50.0, 50.0); + (s, a, b) + } + + /// Anchors 0 and 1 of `a`, anchor 3 of `b`, and then segment 1 of `b` (its ends are anchors 1 and 2). + fn mixed(s: &mut Session, a: NodeId, b: NodeId) { + let items = json!([{"id": a.0, "anchors": [[0, 0], [0, 1]]}, {"id": b.0, "anchors": [[0, 3]]}]); + s.execute("select.anchorsMany", &json!({"items": items})).unwrap(); + s.execute("select.segments", &json!({"id": b.0, "segments": [[0, 1]], "mode": "add"})).unwrap(); + } + + fn refs(v: &[(usize, usize)]) -> BTreeSet<(usize, usize)> { + v.iter().copied().collect() + } + + /// Selected objects, with the selected anchors of those selected in part. + type Picked = (Vec, BTreeMap>); + + /// The selected objects and their selected anchors. + fn picked(s: &Session) -> Picked { + let sel = &s.doc().unwrap().selection; + (sel.objects.clone(), sel.anchors.clone()) + } + + #[test] + fn selected_segments_drop_out_and_the_anchor_points_stay() { + let (mut s, a, b) = two(); + mixed(&mut s, a, b); + let before = s.doc().unwrap().selection.clone(); + assert_eq!(before.anchors[&b], refs(&[(0, 1), (0, 2), (0, 3)]), "a segment's ends move with it"); + let undo = s.doc().unwrap().history.undo.len(); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(r, json!({"changed": true, "count": 2, "points": 3})); + let sel = &s.doc().unwrap().selection; + assert_eq!(sel.objects, vec![a, b]); + assert_eq!(sel.anchors[&a], refs(&[(0, 0), (0, 1)])); + assert_eq!(sel.anchors[&b], refs(&[(0, 3)]), "the segment's ends leave the selection"); + assert!(sel.segments.is_empty(), "no segment stays selected"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "only the selection changes"); + } + + #[test] + fn segment_ends_stay_as_anchor_points_when_asked() { + let (mut s, a, b) = two(); + mixed(&mut s, a, b); + let r = s.execute(C, &json!({"segmentEnds": true})).unwrap(); + assert_eq!(r, json!({"changed": true, "count": 2, "points": 5})); + let sel = &s.doc().unwrap().selection; + assert_eq!(sel.anchors[&b], refs(&[(0, 1), (0, 2), (0, 3)])); + assert!(sel.segments.is_empty()); + // With the default, a path holding only a selected segment leaves the selection. + s.execute("select.segments", &json!({"id": b.0, "segments": [[0, 0]]})).unwrap(); + s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 2]], "mode": "add"})).unwrap(); + let r = s.execute(C, &json!({"segmentEnds": false})).unwrap(); + assert_eq!(r, json!({"changed": true, "count": 1, "points": 1})); + assert_eq!(picked(&s), (vec![a], BTreeMap::from([(a, refs(&[(0, 2)]))]))); + } + + #[test] + fn a_selection_of_anchor_points_alone_is_left_as_it_is() { + let (mut s, a, b) = two(); + s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 0], [0, 2]]})).unwrap(); + let before = picked(&s); + assert_eq!(s.execute(C, &json!({})).unwrap(), json!({"changed": false, "count": 1, "points": 2})); + assert_eq!(picked(&s), before); + // Paths selected whole keep all their points. + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + assert_eq!(s.execute(C, &json!({})).unwrap(), json!({"changed": false, "count": 2, "points": 8})); + assert_eq!(picked(&s), (vec![a, b], BTreeMap::new())); + } + + #[test] + fn groups_and_compound_paths_give_way_to_their_paths_and_other_objects_leave() { + let (mut s, a, b) = two(); + let c = rect(&mut s, 200.0, 10.0, 20.0, 20.0); + let hidden = rect(&mut s, 200.0, 100.0, 20.0, 20.0); + let text = NodeId(s.execute("text.create", &json!({"x": 20, "y": 200, "text": "Points"})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [b.0, c.0, hidden.0, text.0]})).unwrap(); + let group = s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [hidden.0]})).unwrap(); + s.execute("object.hide", &json!({})).unwrap(); + let d = rect(&mut s, 20.0, 20.0, 10.0, 10.0); + s.execute("select.set", &json!({"ids": [a.0, d.0]})).unwrap(); + s.execute("object.compoundPath.make", &json!({})).unwrap(); + let compound = s.doc().unwrap().selection.objects.clone(); + assert_eq!(compound.len(), 1); + let members: Vec = s.doc().unwrap().doc.node(compound[0]).unwrap().children().unwrap().iter().map(|m| m.id).collect(); + assert_eq!(members.len(), 2); + s.execute("select.set", &json!({"ids": [compound[0].0, group]})).unwrap(); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(r, json!({"changed": true, "count": 4, "points": 16}), "{r}"); + let mut want = members; + want.extend([b, c]); + assert_eq!(picked(&s), (want, BTreeMap::new()), "the hidden path and the type are left out"); + } + + #[test] + fn guide_paths_in_a_group_are_left_out_while_guides_are_locked() { + let (mut s, a, b) = two(); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + s.execute("view.guides.make", &json!({})).unwrap(); + let text = NodeId(s.execute("text.create", &json!({"x": 20, "y": 200, "text": "Points"})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [b.0, text.0]})).unwrap(); + let group = s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap(); + s.execute("view.guides.lock", &json!({"locked": true})).unwrap(); + s.execute("select.set", &json!({"ids": [group]})).unwrap(); + let before = s.doc().unwrap().selection.clone(); + let e = s.execute(C, &json!({})).unwrap_err().to_string(); + assert!(e.contains("no anchor points are selected"), "{e}"); + assert_eq!(s.doc().unwrap().selection, before); + s.execute("select.set", &json!({"ids": [a.0, group]})).unwrap(); + assert_eq!(s.execute(C, &json!({})).unwrap(), json!({"changed": true, "count": 1, "points": 4})); + assert_eq!(picked(&s), (vec![a], BTreeMap::new())); + // Unlocked, the guide path is a path like any other. + s.execute("view.guides.lock", &json!({"locked": false})).unwrap(); + s.execute("select.set", &json!({"ids": [group]})).unwrap(); + assert_eq!(s.execute(C, &json!({})).unwrap(), json!({"changed": true, "count": 1, "points": 4})); + assert_eq!(picked(&s), (vec![b], BTreeMap::new())); + } + + #[test] + fn nothing_to_keep_is_an_error_that_leaves_the_selection() { + let (mut s, a, b) = two(); + let text = NodeId(s.execute("text.create", &json!({"x": 20, "y": 200, "text": "Points"})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.none", &json!({})).unwrap(); + assert!(s.execute(C, &json!({})).is_err(), "nothing selected"); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 0]]})).unwrap(); + s.execute("select.add", &json!({"ids": [text.0]})).unwrap(); + let before = s.doc().unwrap().selection.clone(); + let e = s.execute(C, &json!({})).unwrap_err().to_string(); + assert!(e.contains("no anchor points are selected"), "{e}"); + assert_eq!(s.doc().unwrap().selection, before); + for p in [json!({"segmentEnds": "yes"}), json!({"segmentEnds": 1}), json!({"segmentEnds": [true]}), json!({"segmentEnd": true})] { + s.execute("select.anchors", &json!({"id": b.0, "anchors": [[0, 0]]})).unwrap(); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 0]], "mode": "add"})).unwrap(); + let before = s.doc().unwrap().selection.clone(); + assert!(s.execute(C, &p).is_err(), "{p}"); + assert_eq!(s.doc().unwrap().selection, before, "{p}"); + } + assert!(Session::new().execute(C, &Value::Null).is_err(), "without a document"); + } +} diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index c2699f219c..6b146b91ec 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -81,6 +81,7 @@ pub(super) const ALLOWED: &[&str] = &[ "addon.pen.segment", "addon.pen.togglePoint", "addon.select.byArtboards", + "addon.select.editPointsOnly", "addon.shapes.box3d", "addon.shapes.configure", "addon.shapes.ellipse", diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 462641b953..44919a7960 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -538,6 +538,8 @@ fn structured_junk() { ("addon.select.byLinkStatus", json!({"status": "embedded", "ids": {"a": 1}, "add": [1], "zoom": "yes"})), ("addon.select.byLinkStatus", json!({"status": ["modified", "embedded"], "ids": [], "add": true, "zoom": true})), ("addon.select.byLinkStatus", json!({"status": [[["linked"]]], "ids": null})), + ("addon.select.editPointsOnly", json!({"segmentEnds": "yes"})), + ("addon.select.editPointsOnly", json!({"segmentEnds": [true], "ids": [2, u64::MAX]})), ("links.relink", json!({"scope": "each", "paths": [{"ids": [2, u64::MAX, -1, "x"], "path": ""}, null, 7, {"path": [1]}]})), ("links.relink", json!({"scope": ["all"], "path": "/no/such/file.png", "ids": {"a": 1}})), ("links.relink", json!({"scope": "missingInFolder", "path": "", "folder": [], "paths": "x"})), diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index e58443e259..3273764d5f 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -108,6 +108,7 @@ pub(crate) fn open_from_menu(app: &mut VectorcraftApp, id: &str) -> Option color::legend::open, color::nearest::COMMAND => color::nearest::open, select::COMMAND => select::open, + select::points_only::COMMAND => select::points_only::open, _ => return super::arrange::open(app, id), }; Some(open(app)) diff --git a/crates/ui-egui/src/addons/select.rs b/crates/ui-egui/src/addons/select.rs index 6ae9a2ae91..22428bef53 100644 --- a/crates/ui-egui/src/addons/select.rs +++ b/crates/ui-egui/src/addons/select.rs @@ -1,8 +1,8 @@ //! Selection Tools in the interface: its submenu (Object › Plug-ins › Selection Tools) and the //! Select by Artboards dialog (#5548), which lists the artboards with their number, name and size, //! filters them by name, picks several, fits one in the window on double-click (#5549), and on OK -//! runs `addon.select.byArtboards` with the relation chosen; and Select by Link Status -//! ([`link_status`], #5526). +//! runs `addon.select.byArtboards` with the relation chosen; Select by Link Status +//! ([`link_status`], #5526); and Edit Points Only ([`points_only`]). use craft::behavior::{Selection, keyed}; use craft::i18n::Folder; @@ -27,6 +27,7 @@ use crate::VectorcraftApp; use crate::menus::{Sep, cp}; pub mod link_status; +pub mod points_only; /// Select by Artboards, and its dialog's kind. pub const COMMAND: &str = "addon.select.byArtboards"; @@ -40,6 +41,8 @@ const LIST_ROWS: u16 = 9; pub fn menu() -> Vec { let mut v = vec![cp("Select by Artboards…", COMMAND, Value::Null), Sep]; v.extend(link_status::menu()); + v.push(Sep); + v.extend(points_only::menu()); v } diff --git a/crates/ui-egui/src/addons/select/points_only.rs b/crates/ui-egui/src/addons/select/points_only.rs new file mode 100644 index 0000000000..f4b0d157d2 --- /dev/null +++ b/crates/ui-egui/src/addons/select/points_only.rs @@ -0,0 +1,51 @@ +//! Edit Points Only in the interface: its item in Object › Plug-ins › Selection Tools and its +//! dialog, which previews the narrowed selection on the canvas and runs +//! `addon.select.editPointsOnly` on OK; Cancel puts the selection back. + +use std::borrow::Cow; + +use craft::menu::Node; +use craft::ui::contract::Bind; +use craft::ui::patterns::form_dialogs::{DialogFields, Param, ParamDialog, ParamKind}; +use serde_json::{Map, Value, json}; + +use crate::VectorcraftApp; +use crate::addons::dialogs::Spec; +use crate::dialogs::form; +use crate::menus::c; + +/// Edit Points Only: the dialog's key and the command its OK runs. +pub const COMMAND: &str = "addon.select.editPointsOnly"; + +static SPEC: Spec = Spec { command: COMMAND, params, found: None }; + +/// The menu item. +pub fn menu() -> Vec { + vec![c("Edit Points Only…", COMMAND)] +} + +/// The dialog's rows. +fn rows() -> Vec { + vec![Param::new("segmentEnds", tl!("Keep Ends of Selected Segments"), ParamKind::bool(false))] +} + +/// The command's params for the dialog's `fields`. +fn params(fields: &DialogFields) -> Value { + Value::Object(form::json_of(&rows(), fields)) +} + +/// Opens the dialog on the active document, with the ends of selected segments left out. +pub(crate) fn open(app: &mut VectorcraftApp) -> Result { + if app.session.active().is_none() { + return Err("no document".into()); + } + let mut opening = Map::new(); + opening.insert("segmentEnds".into(), json!(false)); + let fields = form::fields_of(&rows(), &opening); + crate::addons::dialogs::open(app, &SPEC, fields, |fields| { + ParamDialog::new(COMMAND, tl!("Edit Points Only"), Cow::Owned(rows())).previews(true).values(Bind::bound(fields)) + }) +} + +#[cfg(test)] +mod tests; diff --git a/crates/ui-egui/src/addons/select/points_only/tests.rs b/crates/ui-egui/src/addons/select/points_only/tests.rs new file mode 100644 index 0000000000..21285a1e8e --- /dev/null +++ b/crates/ui-egui/src/addons/select/points_only/tests.rs @@ -0,0 +1,85 @@ +use std::collections::BTreeSet; + +use serde_json::json; +use vectorcraft_doc::NodeId; +use vectorcraft_engine::Session; + +use crate::VectorcraftApp; +use crate::addons::dialogs::tests as host; +use crate::tests::panel_harness::Panel as Harness; + +/// An app with a window and two rectangles: anchors 0 and 1 of the first selected, and segment 1 +/// of the second (whose ends are its anchors 1 and 2) beside its anchor 3. +fn app() -> (VectorcraftApp, NodeId, NodeId) { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let mut rect = |x| NodeId(app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap()); + let (a, b) = (rect(10), rect(100)); + let items = json!([{"id": a.0, "anchors": [[0, 0], [0, 1]]}, {"id": b.0, "anchors": [[0, 3]]}]); + app.run("select.anchorsMany", json!({"items": items})).unwrap(); + app.run("select.segments", json!({"id": b.0, "segments": [[0, 1]], "mode": "add"})).unwrap(); + (app, a, b) +} + +fn refs(v: &[(usize, usize)]) -> BTreeSet<(usize, usize)> { + v.iter().copied().collect() +} + +/// The selected anchors of `id`, and whether any segment is selected. +fn points(app: &VectorcraftApp, id: NodeId) -> (Option>, bool) { + let sel = &app.session.doc().unwrap().selection; + (sel.anchors.get(&id).cloned(), !sel.segments.is_empty()) +} + +#[test] +fn the_dialog_previews_keeps_on_ok_and_takes_the_segment_ends_from_the_keyboard() { + let (app, a, b) = app(); + let undo = app.session.doc().unwrap().history.undo.len(); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + host::open_item(&mut panel.app(), "Selection Tools", "Edit Points Only…"); + panel.frame(); + let id = host::dialog_id(&panel.app()); + assert_eq!(host::read(&panel.app(), id, |f| f.bool("segmentEnds")), Some(false)); + assert_eq!(points(&panel.app(), b), (Some(refs(&[(0, 3)])), false), "the preview drops the segment and its ends"); + assert_eq!(points(&panel.app(), a).0, Some(refs(&[(0, 0), (0, 1)]))); + panel.focus("Keep Ends of Selected Segments"); + panel.key(egui::Key::Space, egui::Modifiers::NONE); + panel.frame(); + assert_eq!(host::read(&panel.app(), id, |f| f.bool("segmentEnds")), Some(true)); + assert_eq!(points(&panel.app(), b), (Some(refs(&[(0, 1), (0, 2), (0, 3)])), false), "the ends are kept as anchor points"); + panel.click("OK"); + panel.frame(); + let app = panel.app(); + assert!(!app.any_dialog_open()); + assert_eq!(points(&app, b), (Some(refs(&[(0, 1), (0, 2), (0, 3)])), false)); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo, "a selection change is not an undo step"); +} + +#[test] +fn cancel_puts_the_selection_back() { + let (app, _, b) = app(); + let before = app.session.doc().unwrap().selection.clone(); + let mut panel = Harness::new(app, crate::tests::picks::dialogs); + host::open_item(&mut panel.app(), "Selection Tools", "Edit Points Only…"); + panel.frame(); + assert_eq!(points(&panel.app(), b), (Some(refs(&[(0, 3)])), false)); + panel.click("Cancel"); + panel.frame(); + let app = panel.app(); + assert!(!app.any_dialog_open()); + assert_eq!(app.session.doc().unwrap().selection, before); +} + +#[test] +fn ok_with_nothing_to_keep_says_why_and_leaves_the_selection() { + let (mut app, a, _) = app(); + app.run("select.segments", json!({"id": a.0, "segments": [[0, 0]]})).unwrap(); + let before = app.session.doc().unwrap().selection.clone(); + host::open_item(&mut app, "Selection Tools", "Edit Points Only…"); + let id = host::dialog_id(&app); + assert!(host::confirm(&app, id)); + host::frame(&mut app); + assert!(!app.any_dialog_open()); + assert_eq!(app.session.doc().unwrap().selection, before); + assert!(app.ui.status.contains("no anchor points are selected"), "{}", app.ui.status); +} diff --git a/docs/mcp.md b/docs/mcp.md index d698534089..1c9c20ff48 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17313,6 +17313,27 @@ locked". Select by Link Status… lists every image and placed document with its name and filters by status (Show), chooses rows with checkboxes (All / None act on the rows shown), and on Select selects the rows chosen, zooming to them when Zoom to Selection is on (the default). +`addon.select.editPointsOnly {segmentEnds?}` (Edit Points Only…) narrows the selection to the anchor points selected in +it, so that a move or transform that follows acts on those points alone. A path with selected anchor points keeps them. +A path with selected segments drops the segments and keeps its other selected anchor points; the points at the ends of +the segments leave the selection unless `segmentEnds` is `true` (default `false`), which keeps them as selected anchor +points. A path selected whole keeps all its points. A group or compound path selected whole is replaced by the paths +inside it, each selected whole, without hidden and locked ones, without a Shaper Group's original shapes and, while +guides are locked, without paths made into guides. Type, +images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. Only the +selection changes, so there is nothing to undo. It returns `{changed, count, points}`: `changed` is `false` when the +selection already held only anchor points, `count` is the number of paths left selected and `points` the number of +anchor points selected on them. Nothing selected, no anchor point left to keep ("no anchor points are selected"), or a +`segmentEnds` that is not `true` or `false` is an error, and the selection is left as it was. + +```json +{"name":"run_command","arguments":{"command":"addon.select.editPointsOnly","params":{"segmentEnds":false}}} +``` + +In the desktop app, Object › Plug-ins › Selection Tools › Edit Points Only… opens a dialog with Keep Ends of Selected +Segments (off). With Preview on, the canvas shows the narrowed selection; OK keeps it and Cancel puts the selection +back. + ### Vector Halftone (live) `addon.color.halftone` (Effect › Color Effects › Vector Halftone…, also in Object › Plug-ins › Color Effects) draws its diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 032041c2a1..ad53f0194a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1529,6 +1529,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Polygonal Lasso selects anchor points (and gradient mesh points) inside a straight-edged loop, with the Lasso's rule for which points are inside, and is listed under Object › Plug-ins. Its tool is also in the Lasso tool's group in both shipped toolbars, after the Enclosing Lasso, and All Tools lists it there, under Select; a toolbar edited before it joined keeps its saved layout until Reset Toolbar (tests `polygonal_lasso_is_in_the_lasso_flyout`, `a_saved_toolbar_without_polygonal_lasso_keeps_its_layout` and `a_torn_off_lasso_group_shows_polygonal_lasso` in `edit_toolbar::tests`, `polygonal_lasso_is_in_the_lasso_group_once` in `addons::tests`, `headless_lists_the_lasso_group` in `vectorcraft-mcp`). It has no default shortcut. Each click sets a vertex. A double-click, Enter or a click on the first vertex closes the loop, Backspace or Delete removes the last vertex, Escape drops the loop, and Shift keeps the next segment to 45° steps. Shift or Alt held at the first click adds to or subtracts from the selection. This is a VectorCraft addition; scores and estimates are unchanged. Select by Artboards (Object › Plug-ins › Selection Tools, a VectorCraft addition: #5525, #5548, #5549) selects the objects overlapping, fully inside or fully outside one or more chosen artboards (`addon.select.byArtboards {artboards, relation}`). Overlapping is All on Active Artboard's test, shared as `select::on_artboard`; Fully inside means within one artboard, edges included; Fully outside means on none. It looks at what Select All takes, so hidden, locked and locked-artboard art stays out. Its dialog lists each artboard's number, name and size in the document's units, filters by name, chooses rows with click, Shift-click and Cmd/Ctrl-click, and fits a row's artboard in the window on double-click (`view.goToArtboard`). Tests: `crates/engine/src/cmd/addons/select/tests.rs`, `crates/ui-egui/src/addons/select/tests.rs`, `crates/engine/tests/command_sweep.rs`. Select by Link Status (Object › Plug-ins › Selection Tools and the Links panel menu, a VectorCraft addition: #5526) selects the image objects and placed documents whose link is linked (its file found unchanged), embedded, missing or modified, as `links.list` reports it (`addon.select.byLinkStatus {status, ids?, add?, zoom?}`); Select Linked, Embedded, Missing and Modified are off when no image has that status and add to the selection with Shift. Objects that are hidden or locked, inside a hidden or locked object or layer, on a template layer, on a locked artboard, or outside the isolated group are left out (the `select::is_selectable` test) and returned with the reason, and the status bar says how many, in plural forms of every catalog. Select by Link Status… lists each image and placed document with its name, status and format, searches by name, filters by status, picks rows with checkboxes and All / None, and zooms to the selection with the existing Zoom to Selection (`addon.arrange.zoomSelection`). Missing-link markers on the canvas are #5547. Tests: `crates/engine/src/cmd/addons/select/tests.rs` (`by_link_status`), `crates/ui-egui/src/addons/select/link_status/tests.rs`, `crates/engine/tests/command_sweep.rs`. + Edit Points Only (Object › Plug-ins › Selection Tools, a VectorCraft addition) narrows a Direct Selection to its selected anchor points (`addon.select.editPointsOnly {segmentEnds?}`): selected segments leave the selection, and the points at their ends leave it too unless Keep Ends of Selected Segments is on; paths selected whole keep every point; a group or compound path selected whole gives way to the visible, unlocked paths inside it; type, images, symbols and other objects without anchor points leave the selection. Only the selection changes, so there is no undo step; with nothing left to keep it is an error and the selection stays as it was. The dialog previews the narrowed selection, and Cancel puts the selection back. Tests: `crates/engine/src/cmd/addons/select/tests.rs` (`edit_points_only`), `crates/ui-egui/src/addons/select/points_only/tests.rs`, `crates/engine/tests/command_sweep.rs`. The Links panel provides an item right-click context menu on link rows offering Relink…, Go To Link, Update Link, Edit Original, Show in Folder, Separator, and Embed Image / Unembed…. Right-clicking an unselected row selects that row first; right-clicking a row that is already part of a multi-selection preserves the multi-selection. Tests: `panels::tests_links::right_click_context_menu_in_links_panel`. The Location row of the Links panel's Link Info has a folder button, Show in Folder, that opens the folder of the file Link Info shows in the system's file manager (`links.reveal {id}` with that image's id); the help page describes a folder icon on this row ([Links information](https://helpx.adobe.com/illustrator/using/links-info.html)). The button's name and its off state while the file is missing or no file manager is available (the web build) are VectorCraft's own. Tests: `panels::tests_links::link_infos_location_row_shows_the_file_in_its_folder`. A marquee selects a clip group, or an object on a layer with a clipping mask, only when it reaches the area inside the clipping path, and it measures the art only within that path's bounds. Within the bounds of a mask that is not a rectangle, it can still select art that the mask hides. Direct Selection's marquee still selects the hidden anchor points inside it (#2345). From c2230ee61e57ff1e3a158ad7382227863a56b455 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:25:58 -0800 Subject: [PATCH 102/264] CI: app manifests and doc tests no longer warn - apps/vectorcraft-web: egui_extras moves to the wasm32 dependencies. Its only use is src/web.rs, which builds only for wasm32, so cargo reported it unused on native builds. - apps/vectorcraft: drop the socket2 dev-dependency. Its loopback tests left control_server in #8800 and nothing uses it now. - xtask: the doc-test steps (`cargo xtask ci shard` and the workspace doctests) leave out packages whose only library target is a cdylib, dylib or staticlib. Cargo printed "doc tests are not supported for crate type(s) `cdylib`" for vectorcraft-thumbnail-handler. Packages without a library stay selected, so the shard keeps its features. Warnings on the build host, before and after (cache warm shard `cargo test -p vectorcraft-mcp -p vectorcraft -p vectorcraft-cli -p vectorcraft-web -p xtask --lib --bins --no-run` on a fresh build, and `cargo test -p vectorcraft-thumbnail-handler --doc`): 4 before, 1 after. The one left is `vectorcraft-testkit` in apps/vectorcraft-cli: only the integration tests use it, and the warm step builds only library and binary tests. --- Cargo.lock | 1 - apps/vectorcraft-web/Cargo.toml | 3 +- apps/vectorcraft/Cargo.toml | 2 -- xtask/src/main.rs | 17 +++++++---- xtask/src/shards.rs | 52 +++++++++++++++++++++++++++++++-- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 520647b95d..4df5d36e3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8538,7 +8538,6 @@ dependencies = [ "raw-window-handle", "rustix 1.1.6", "serde_json", - "socket2", "tempfile", "vectorcraft-engine", "vectorcraft-render", diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index e8b56c29a9..c2b40c7158 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -20,10 +20,11 @@ vectorcraft-format = { workspace = true } vectorcraft-text = { workspace = true } craft = { workspace = true, features = ["ui", "keymap", "automation", "platform"] } egui = { workspace = true } -egui_extras = { workspace = true } log = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] +# Image loaders for `src/web.rs`, which builds only for wasm32. +egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. diff --git a/apps/vectorcraft/Cargo.toml b/apps/vectorcraft/Cargo.toml index 1c3e7f39e7..d17c96eaf7 100644 --- a/apps/vectorcraft/Cargo.toml +++ b/apps/vectorcraft/Cargo.toml @@ -129,5 +129,3 @@ winresource = "0.1" [dev-dependencies] tempfile = "3" -# Bound socket buffers in real loopback transport deadline regressions. -socket2 = { workspace = true } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7c2e587a7d..08a55df09a 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -316,13 +316,18 @@ fn test_packages(select: &[String], shown: &str, part: Option) -> /// The doctests, which nextest doesn't run. fn cmd_doctests() -> Result<(), String> { - doctest_packages(&["--workspace".to_owned()], "--workspace") + doctest_packages(&shards::members(&metadata()?)?) } -/// [`cmd_doctests`] for the packages `select` picks, shown as `shown`. -fn doctest_packages(select: &[String], shown: &str) -> Result<(), String> { +/// [`cmd_doctests`] for the crates of `crates` that have doc tests. +fn doctest_packages(crates: &[shards::Member]) -> Result<(), String> { + let crates = shards::with_doctests(crates); + if crates.is_empty() { + return Ok(()); + } + let shown = crates.iter().map(|m| format!("-p {}", m.name)).collect::>().join(" "); let mut c = cargo(); - c.arg("test").args(select).arg("--doc"); + c.arg("test").args(shards::select(&crates)).arg("--doc"); run(c, &format!("cargo test {shown} --doc")) } @@ -372,9 +377,9 @@ fn cmd_ci_shard() -> Result<(), String> { steps.push(("test", Box::new(move || test_packages(&s, &w, part)))); // The doctests and the i18n report run once, on a split's first part. let first = part.is_none_or(|p| p.is_first()); - let (s, w) = (select.clone(), shown.clone()); if first { - steps.push(("doctests", Box::new(move || doctest_packages(&s, &w)))); + let c = crates.clone(); + steps.push(("doctests", Box::new(move || doctest_packages(&c)))); } if first && crates.iter().any(|m| m.name == "vectorcraft-ui-egui") { steps.push(("i18n-report", Box::new(move || i18n_report_packages(&select, &shown)))); diff --git a/xtask/src/shards.rs b/xtask/src/shards.rs index 29f5281a84..2a4ae4d927 100644 --- a/xtask/src/shards.rs +++ b/xtask/src/shards.rs @@ -88,6 +88,10 @@ pub struct Member { /// against this repo's geom and pathops by git, so the graph holds a second copy of each. pub id: String, pub version: String, + /// Whether `cargo test --doc` can select this package without a warning: it has no library + /// target, or one of `lib`, `rlib` or `proc-macro` kind. Cargo warns for a selected package + /// whose library is only a `cdylib`, `dylib` or `staticlib`. + pub doctests: bool, } /// What one shard runs, with its crates resolved; a shard of a [`Split`] carries its part. @@ -159,7 +163,7 @@ pub fn members(meta: &Value) -> Result, String> { .filter(|p| p["id"].as_str().is_some_and(|id| ids.contains(id))) .map(|p| { let field = |key: &str| p[key].as_str().map(str::to_owned).ok_or_else(|| format!("cargo metadata: a workspace package has no `{key}`")); - Ok(Member { name: field("name")?, id: field("id")?, version: field("version")? }) + Ok(Member { name: field("name")?, id: field("id")?, version: field("version")?, doctests: has_doctests(p) }) }) .collect::>()?; if members.is_empty() { @@ -168,6 +172,24 @@ pub fn members(meta: &Value) -> Result, String> { Ok(members) } +/// [`Member::doctests`] for the `cargo metadata` package `p`. +fn has_doctests(p: &Value) -> bool { + let kinds = |t: &Value| t["kind"].as_array().into_iter().flatten().filter_map(Value::as_str).map(str::to_owned).collect::>(); + let libraries: Vec> = p["targets"] + .as_array() + .into_iter() + .flatten() + .map(kinds) + .filter(|k| k.iter().any(|k| matches!(k.as_str(), "lib" | "rlib" | "dylib" | "cdylib" | "staticlib" | "proc-macro"))) + .collect(); + libraries.is_empty() || libraries.iter().flatten().any(|k| matches!(k.as_str(), "lib" | "rlib" | "proc-macro")) +} + +/// The crates of `crates` that `cargo test --doc` can select (see [`Member::doctests`]). +pub fn with_doctests(crates: &[Member]) -> Vec { + crates.iter().filter(|m| m.doctests).cloned().collect() +} + /// Each group of `groups` with its crates: a named crate must be a workspace member and named /// once, there must be exactly one [`Group::Rest`], and no test shard may be empty. A split's /// parts 1 to n must be consecutive shards, with at least two parts, and no test pinned twice. @@ -347,7 +369,24 @@ mod tests { use super::*; fn m(name: &str) -> Member { - Member { name: name.into(), id: format!("path+file:///w/{name}#0.1.0"), version: "0.1.0".into() } + Member { name: name.into(), id: format!("path+file:///w/{name}#0.1.0"), version: "0.1.0".into(), doctests: true } + } + + #[test] + fn the_doc_tests_leave_out_only_packages_whose_library_cargo_cannot_doc_test() { + let package = |kinds: &[&str]| serde_json::json!({ "targets": [{ "kind": kinds }, { "kind": ["bin"] }] }); + assert!(has_doctests(&package(&["lib"]))); + assert!(has_doctests(&package(&["rlib"]))); + assert!(has_doctests(&package(&["proc-macro"]))); + assert!(has_doctests(&package(&["cdylib", "rlib"]))); + assert!(has_doctests(&package(&["bin"]))); + assert!(has_doctests(&serde_json::json!({ "targets": [] }))); + assert!(!has_doctests(&package(&["cdylib"]))); + assert!(!has_doctests(&package(&["dylib"]))); + assert!(!has_doctests(&package(&["staticlib"]))); + let mut cdylib = m("cdylib"); + cdylib.doctests = false; + assert_eq!(with_doctests(&[m("a"), cdylib, m("b")]).iter().map(|m| m.name.as_str()).collect::>(), ["a", "b"]); } fn crates(shard: &Shard) -> Vec<&str> { @@ -514,6 +553,15 @@ mod tests { assert_eq!(shards.iter().filter(|s| **s == Shard::Checks).count(), 1); } + #[test] + fn the_workspace_doc_tests_skip_the_cdylib_thumbnail_handler() { + let ws = members(&crate::metadata().unwrap()).unwrap(); + let doctests = |name: &str| ws.iter().find(|m| m.name == name).map(|m| m.doctests); + assert_eq!(doctests("vectorcraft-thumbnail-handler"), Some(false)); + assert_eq!(doctests("vectorcraft-geom"), Some(true)); + assert_eq!(doctests("vectorcraft-cli"), Some(true)); + } + #[test] fn a_feature_only_another_shard_turns_on_is_a_difference() { let ws = [m("lib"), m("geom")]; From 6be061e60fce0ceb451b0e17f2292e30454047ec Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:36:32 -0800 Subject: [PATCH 103/264] Docking: drop the icon-column float workaround now that craft-libs expands it The craft-libs pin (186a229c8d) includes storytold/craft-libs#4138: a group or tab dragged out of a dock column collapsed to icons now floats or docks expanded in craft-libs itself, while a whole icon column that floats stays collapsed. The floated_from_icons pass added by #9964 expanded those windows a second time after each dock pass, so it is removed and the dock pass stores the area's workspace as it did before. The test from #9964, a_group_dragged_out_of_the_icon_column_floats_expanded_and_its_tabs_switch, is kept and passes on craft-libs alone. --- crates/ui-egui/src/panel_docking.rs | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 74a5586b04..0fd8936a45 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -521,22 +521,6 @@ fn flyout_tab(layout: &Layout, panel: &str) -> Option { .map(|front| front.to_string()) } -/// The actions that expand each floating window the pass made from part of a column collapsed to -/// icons, so a group or tab dragged out of an icon column floats as an expanded panel with its tabs -/// in the window. A whole icon column floated stays collapsed. -fn floated_from_icons(before: &Layout, after: &Layout) -> Vec> { - after - .floating - .iter() - .filter(|window| window.column.iconic && !before.floating.iter().any(|old| old.id == window.id)) - .filter_map(|window| { - let first = window.panels().next()?; - let (_, column) = column_of(before, first)?; - (column.iconic && column.panels().count() > window.panels().count()).then(|| Action::set_iconic(first.clone(), false)) - }) - .collect() -} - /// Show `panel` as `window.panel` does, but leave it be when it can be seen already ([`visible`]): /// a command that opens a panel to work in (Edit › Color Settings…) never puts it away. A flyout /// keeps the name of the icon that opened it after another of its tabs is clicked, so a panel whose @@ -1393,20 +1377,13 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, keeps_tools: boo app.dock_rt.rails = rails; // A workspace a command switched to or changed in this pass (`Workspace::replace`) stays; the // pass's edits were to the one it replaced. - let mut expand = Vec::new(); if app.ui.dock_workspace.revision() == revision { - let before = std::mem::replace(&mut app.ui.dock_workspace, workspace); - expand = floated_from_icons(before.layout(), layout_of(&app.ui)); + app.ui.dock_workspace = workspace; } // A command of this pass that opened or closed a flyout wins over the area's own change. if app.ui.open_panel == flyout_before { app.ui.open_panel = flyout; } - if !expand.is_empty() - && let Err(error) = apply(app, None, expand) - { - app.status(error); - } if output.error.is_some() { Arc::make_mut(&mut app.ui.dock_workspace).replace(default_workspace(&[])); app.status(tl!("Invalid panel layout; restored the default dock").to_string()); From 13f3227220ed4d7c09065faecbc2f49fda1fb1e1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:39:04 -0800 Subject: [PATCH 104/264] Match Objects: rotate says which way it turns; scaleStrokes is journaled The gate's turn_direction test failed because the `rotate` param of addon.arrange.match did not say which way it turns. Its description now says each target turns clockwise or counter-clockwise to the source's angle. Match, Set Size of Each, Swap, Replace and Sort now record the resolved `scaleStrokes` value in their journal entry, so a replay scales strokes the same way after the preference changes. --- crates/engine/src/cmd/addons/arrange.rs | 20 +++++++--- crates/engine/src/cmd/addons/arrange/tests.rs | 37 +++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index 1588ec1162..bb16af321a 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -85,7 +85,7 @@ pub fn specs() -> Vec { "Match Objects", ["Object", "Plug-ins", "Arrange Tools"], None, - "{source?: \"key\" (the key object, select.key) | \"top\" (the frontmost selected object) | \"bottom\" (the backmost) (default: the key object when the selection has one, else \"top\"), size?: \"none\" | \"width\" (each target takes the source's width, its height following in proportion) | \"height\" (the source's height, the width following in proportion) | \"both\" (the source's width and height, each on its own) (\"none\"), rotate?: false (true: each target takes the source's bounding-box angle), stacking?: false (true: the targets go directly above the source in the stacking order, in its layer or group, in the order they had), reference?: 0..8 (the 9-point grid row by row from the top-left; 4, the center: the point of each target that stays put as it is sized and turned), scaleStrokes?: the Scale Strokes & Effects preference, patterns?: the Transform Pattern Tiles preference (at least one of size, rotate and stacking)} make the other selected objects (the top-level ones, at most 20000) match the source, which stays as it is, as one undo step (none when nothing changes). Sizes are measured and set as object.setBounds measures them (Use Preview Bounds), each in the object's own bounding-box frame; to match places, use object.align {to: \"key\"} → {source, count}", + "{source?: \"key\" (the key object, select.key) | \"top\" (the frontmost selected object) | \"bottom\" (the backmost) (default: the key object when the selection has one, else \"top\"), size?: \"none\" | \"width\" (each target takes the source's width, its height following in proportion) | \"height\" (the source's height, the width following in proportion) | \"both\" (the source's width and height, each on its own) (\"none\"), rotate?: false (true: each target turns, clockwise or counter-clockwise, to the source's bounding-box angle), stacking?: false (true: the targets go directly above the source in the stacking order, in its layer or group, in the order they had), reference?: 0..8 (the 9-point grid row by row from the top-left; 4, the center: the point of each target that stays put as it is sized and turned), scaleStrokes?: the Scale Strokes & Effects preference, patterns?: the Transform Pattern Tiles preference (at least one of size, rotate and stacking)} make the other selected objects (the top-level ones, at most 20000) match the source, which stays as it is, as one undo step (none when nothing changes). Sizes are measured and set as object.setBounds measures them (Use Preview Bounds), each in the object's own bounding-box frame; to match places, use object.align {to: \"key\"} → {source, count}", has_multi, match_objects ), @@ -177,6 +177,14 @@ fn transform_each(s: &mut Session, label: &str, strokes: bool, xfs: &[(NodeId, A }) } +/// The `scaleStrokes` param, else the Scale Strokes & Effects preference. The value joins the +/// command's journal entry, so replaying it scales the same way whatever the preference is then. +fn scale_strokes(s: &mut Session, p: &Value, cmd: &str) -> Result { + let on = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, cmd)?; + s.note_journal("scaleStrokes", json!(on)); + Ok(on) +} + /// The box of object `id` as `object.setBounds` measures it. fn box_of(s: &Session, id: NodeId) -> Result { s.transform_box(&[id]).ok_or_else(|| EngineError::Other("no bounds".into())) @@ -241,7 +249,7 @@ fn grid(s: &mut Session, p: &Value) -> Result { fn swap(s: &mut Session, p: &Value) -> Result { const C: &str = "addon.arrange.swap"; let size = switch_or(p, "size", false, C)?; - let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let strokes = scale_strokes(s, p, C)?; let roots = selected_roots(s)?; let &[a, b] = roots.as_slice() else { return Err(bad(C, "select exactly two objects")) }; let (ba, bb) = (box_of(s, a)?, box_of(s, b)?); @@ -254,7 +262,7 @@ fn swap(s: &mut Session, p: &Value) -> Result { fn replace(s: &mut Session, p: &Value) -> Result { const C: &str = "addon.arrange.replace"; let fit = choice(p, C, "fit", &["keep", "bounds", "proportional"])?.unwrap_or("keep"); - let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let strokes = scale_strokes(s, p, C)?; let keep = switch_or(p, "keep", false, C)?; let roots = selected_roots(s)?; let Some((&top, others)) = roots.split_last().filter(|(_, others)| !others.is_empty()) else { @@ -305,7 +313,7 @@ fn size(s: &mut Session, p: &Value) -> Result { } let proportional = switch_or(p, "proportional", false, C)?; let reference = whole_in(p, "reference", (0, 8), C)?.unwrap_or(4); - let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let strokes = scale_strokes(s, p, C)?; let mut q = json!({ "reference": reference, "strokes": strokes, "proportional": proportional && (width.is_none() || height.is_none()) }); if let Some(w) = width { q["width"] = json!(w); @@ -350,7 +358,7 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { let rotate = switch_or(p, "rotate", false, C)?; let stacking = switch_or(p, "stacking", false, C)?; let reference = whole_in(p, "reference", (0, 8), C)?.unwrap_or(4); - let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let strokes = scale_strokes(s, p, C)?; let patterns = switch_or(p, "patterns", s.prefs.transform_pattern_tiles, C)?; if size == "none" && !rotate && !stacking { return Err(bad(C, "give `size`, `rotate` or `stacking`")); @@ -569,7 +577,7 @@ fn sort(s: &mut Session, p: &Value) -> Result { let order = choice(p, C, "order", &["ascending", "descending", "random"])?.unwrap_or("ascending"); let distribute = switch_or(p, "distribute", false, C)?; let mut rng = Rng::new(whole_or(p, "seed", 0, C)?); - let strokes = switch_or(p, "scaleStrokes", s.prefs.scale_strokes, C)?; + let strokes = scale_strokes(s, p, C)?; let ids = checked_ids_or_selection(s, p, C)?; if ids.len() > MAX_OBJECTS { return Err(bad(C, "too many objects selected (at most 20000)")); diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 7cf91abfb7..8dc7ab5c43 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -368,6 +368,43 @@ fn match_scales_strokes_as_asked() { assert!(near(bounds(&s, a), (-5.0, -5.0, 20.0, 20.0)), "{:?}", bounds(&s, a)); } +/// Running `cmd` with Scale Strokes & Effects on doubles the 2 pt stroke of a 10 pt square, and +/// replaying its journal entry after the preference is turned off scales the stroke the same way. +fn replays_the_stroke_scaling_it_ran_with(cmd: &str, p: Value) { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let b = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + select(&mut s, &[a, b]); + s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap(); + s.execute("stroke.set", &json!({"weight": 2})).unwrap(); + let weight = |s: &Session| s.doc().unwrap().doc.node(a).unwrap().appearance.stroke_width(); + s.execute("prefs.set", &json!({"key": "scaleStrokes", "value": true})).unwrap(); + s.execute(cmd, &p).unwrap(); + assert!((weight(&s) - 4.0).abs() < 1e-9, "{cmd}: {}", weight(&s)); + let (id, q) = s.journal.last().unwrap().clone(); + assert_eq!(id, cmd); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("prefs.set", &json!({"key": "scaleStrokes", "value": false})).unwrap(); + select(&mut s, &[a, b]); + s.execute(&id, &q).unwrap(); + assert!((weight(&s) - 4.0).abs() < 1e-9, "{cmd} replayed: {}", weight(&s)); +} + +#[test] +fn match_replays_with_the_stroke_scaling_it_ran_with() { + replays_the_stroke_scaling_it_ran_with("addon.arrange.match", json!({"size": "both"})); +} + +#[test] +fn set_size_of_each_replays_with_the_stroke_scaling_it_ran_with() { + replays_the_stroke_scaling_it_ran_with("addon.arrange.size", json!({"width": 20, "height": 20})); +} + +#[test] +fn swap_replays_with_the_stroke_scaling_it_ran_with() { + replays_the_stroke_scaling_it_ran_with("addon.arrange.swap", json!({"size": true})); +} + #[test] fn match_refuses_bad_params() { let mut s = session(); From 9aa6f7cdae8beb9e30218c41003948cd237b7188 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:45:21 -0800 Subject: [PATCH 105/264] Selection: a click or hover that hits nothing walks the document once A hit test for the selection tools first walks the document without looking inside unfilled closed paths, and when that finds nothing it walked the whole document again to look inside them. With the pointer resting over empty pasteboard that doubled the hit walks on every frame. The first walk now notes whether an unfilled closed path holds the point, and the second walk runs only when one does. Select Behind (objects_at) and Direct Selection in a dynamic symbol's art (symbol_part_at) skip their second pass the same way. Hit tests that do not look inside unfilled paths measure no interiors. --- crates/doc/src/hit.rs | 87 +++++++++++++++++++++++++++++++++---- crates/doc/src/hit/tests.rs | 82 ++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 8 deletions(-) diff --git a/crates/doc/src/hit.rs b/crates/doc/src/hit.rs index 121f12aaeb..bb4dcbd416 100644 --- a/crates/doc/src/hit.rs +++ b/crates/doc/src/hit.rs @@ -446,6 +446,66 @@ impl Drop for InMask { } } +thread_local! { + /// While an [`InteriorProbe`] lives, whether a leaf tested without + /// [`HitOptions::unfilled_interiors`] would have been hit inside an unfilled closed path with + /// it; `None` outside a probe. + static INTERIOR_SEEN: std::cell::Cell> = const { std::cell::Cell::new(None) }; +} + +/// While a guard lives, the leaves tested without [`HitOptions::unfilled_interiors`] note whether +/// they would be hit inside an unfilled closed path with it ([`unfilled_inside`]). A walk that hits +/// nothing then looks inside the unfilled closed paths with a second walk only when one of them +/// holds the point. +struct InteriorProbe { + was: Option, +} + +impl InteriorProbe { + /// A probe when `wanted`, the walk that follows a miss looking inside unfilled closed paths. + /// Otherwise the guard leaves things as they are, and no leaf measures an interior for it. + fn open(wanted: bool) -> Self { + Self { was: if wanted { INTERIOR_SEEN.replace(Some(false)) } else { INTERIOR_SEEN.get() } } + } + + /// Did a leaf tested since [`Self::open`] have an unfilled closed path holding the point? + fn seen(&self) -> bool { + INTERIOR_SEEN.get() == Some(true) + } +} + +impl Drop for InteriorProbe { + fn drop(&mut self) { + // A probe opened inside another passes what it saw on to it. + let seen = INTERIOR_SEEN.get() == Some(true); + INTERIOR_SEEN.set(self.was.map(|was| was || seen)); + } +} + +/// The hit inside path or compound path `n`'s closed subpaths, which have no visible fill, when +/// `n` takes one there ([`takes_interior`]) and `contains` says they hold the point. Without +/// [`HitOptions::unfilled_interiors`], under an [`InteriorProbe`], notes whether `n` would take +/// one with it, and hits nothing. +fn unfilled_inside(n: &Node, opt: HitOptions, contains: impl FnOnce() -> bool) -> Option { + if takes_interior(n, opt) { + return contains().then_some(HitKind::Fill); + } + if INTERIOR_SEEN.get() == Some(false) && takes_interior(n, HitOptions { unfilled_interiors: true, ..opt }) { + #[cfg(test)] + INTERIORS_PROBED.with(|c| c.set(c.get() + 1)); + if contains() { + INTERIOR_SEEN.set(Some(true)); + } + } + None +} + +#[cfg(test)] +thread_local! { + /// How many interiors [`unfilled_inside`] measured for an [`InteriorProbe`] on this thread. + static INTERIORS_PROBED: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + /// `f()`, with `mask` under a [`DrawnOff`] guard: the clipping path of a clip group or of a /// clipping layer is clicked and touched by its own geometry, whatever its geometry effects do to /// the region it clips to. It is also under an [`InMask`] guard. @@ -667,10 +727,15 @@ pub fn objects_at(doc: &Document, p: Point, opt: HitOptions, scope: Option bool, editable_only: bool) -> Option { + let probe = InteriorProbe::open(opt.unfilled_interiors && !opt.path_only && !opt.outline); let painted = hit_test_walk(doc, p, HitOptions { unfilled_interiors: false, ..opt }, skip, editable_only); - if painted.is_some() || !opt.unfilled_interiors || opt.path_only || opt.outline { + if painted.is_some() || !opt.unfilled_interiors || opt.path_only || opt.outline || !probe.seen() { return painted; } + drop(probe); hit_test_walk(doc, p, opt, skip, editable_only) } @@ -1672,8 +1740,8 @@ fn hit_leaf(n: &Node, p: Point, opt: HitOptions, symbols: &SymbolBoxes) -> Optio match &n.kind { NodeKind::Path { path, rule, .. } => { let has_fill = n.appearance.has_visible_fill(); - let interior = !has_fill && path.subpaths.iter().any(|sp| sp.closed) && takes_interior(n, opt); - let inside = || (interior && fill_contains(&closed_subpaths_at([path], p), *rule, p)).then_some(HitKind::Fill); + let interior = !has_fill && path.subpaths.iter().any(|sp| sp.closed); + let inside = || interior.then(|| unfilled_inside(n, opt, || fill_contains(&closed_subpaths_at([path], p), *rule, p))).flatten(); if opt.outline && let Some((hit, needs_full_check)) = near_path_body(path, p, opt.tol, 0.0) { @@ -1740,7 +1808,7 @@ fn hit_leaf(n: &Node, p: Point, opt: HitOptions, symbols: &SymbolBoxes) -> Optio return (!opt.outline && !opt.path_only && fill_contains(&near, *rule, p)).then_some(HitKind::Fill); } let closed = || closed_subpaths_at(children.iter().filter_map(|m| m.path_data()), p); - (takes_interior(n, opt) && fill_contains(&closed(), *rule, p)).then_some(HitKind::Fill) + unfilled_inside(n, opt, || fill_contains(&closed(), *rule, p)) } // The type path lies within the bounds: they rule out the rest before it is measured. NodeKind::Text(t) if opt.type_path_only => { @@ -2121,11 +2189,14 @@ pub fn symbol_part_at(doc: &Document, inst: &Node, p: Point, opt: HitOptions) -> let find = FindPart { art: &art, p, opt, symbols: &symbols, whole_instance: false, drawn: true }; find.find(&art.art, &mut path, None, outline).map(|_| path) }; - // As [`hit_test`] does: inside an unfilled closed path only where nothing else is hit. + // As [`hit_test`] does: inside an unfilled closed path only where nothing else is hit, and only + // when the first walk passes one holding `p` ([`InteriorProbe`]). + let probe = InteriorProbe::open(opt.unfilled_interiors && !opt.path_only && !outline); pick(HitOptions { unfilled_interiors: false, ..opt }).or_else(|| { - if !opt.unfilled_interiors || opt.path_only || outline { + if !opt.unfilled_interiors || opt.path_only || outline || !probe.seen() { return None; } + drop(probe); walk.restart(); pick(opt) }) diff --git a/crates/doc/src/hit/tests.rs b/crates/doc/src/hit/tests.rs index 7ac945e4ee..312d8efda7 100644 --- a/crates/doc/src/hit/tests.rs +++ b/crates/doc/src/hit/tests.rs @@ -200,6 +200,88 @@ fn symbol_art_parts_are_picked_inside_unfilled_frames_after_what_paints() { assert_eq!(at(220.0), None, "inside the clipping path where no art paints"); } +/// An open path with a black stroke and no fill, from (`o`, 0) to (100, `o`) to (100, 100): its box +/// holds (50, 50), and it is drawn nowhere near that point. +fn open_corner(d: &mut Document, o: f64) -> Node { + let pts = [Point::new(o, 0.0), Point::new(100.0, o), Point::new(100.0, 100.0)]; + let path = vectorcraft_geom::PathData::single(vectorcraft_geom::SubPath::polyline(&pts, false)); + Node::path(d.alloc_id(), path, Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0)) +} + +/// How many leaves [`hit_leaf`] tested while `f` ran, with its result. +fn leaves_tested(f: impl FnOnce() -> R) -> (R, usize) { + LEAVES_TESTED.with(|c| c.set(0)); + let r = f(); + (r, LEAVES_TESTED.with(std::cell::Cell::get)) +} + +/// A selection click that hits nothing, where no unfilled closed path holds the point, walks the +/// document once: looking inside unfilled closed paths tests no more leaves than a click without +/// it. An unfilled closed path that holds the point is still hit inside. +#[test] +fn a_selection_click_that_hits_nothing_walks_the_document_once() { + let mut d = Document::new(200.0, 200.0); + let l = d.layers[0].id; + for i in 0..10 { + let corner = open_corner(&mut d, f64::from(i)); + d.insert(Some(l), 99, corner).unwrap(); + } + let p = Point::new(50.0, 50.0); + let (hit, without) = leaves_tested(|| hit_test(&d, p, SELECTING)); + assert_eq!(hit, None); + assert_eq!(without, 10); + let (hit, with) = leaves_tested(|| hit_test(&d, p, INTERIORS)); + assert_eq!(hit, None); + assert_eq!(with, without, "hit_test"); + let (tops, with) = leaves_tested(|| objects_at(&d, p, INTERIORS, None)); + assert!(tops.is_empty()); + assert_eq!(with, without, "objects_at"); + // An unfilled frame below them that holds the point: the second walk finds it. + let frame = d.alloc_id(); + let look = Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0); + d.insert(Some(l), 0, Node::path(frame, shapes::rectangle(Rect::new(0.0, 0.0, 100.0, 100.0)), look)).unwrap(); + assert_eq!(hit_test(&d, p, INTERIORS).map(|h| h.leaf), Some(frame)); + assert_eq!(objects_at(&d, p, INTERIORS, None), vec![frame]); +} + +/// A hit test that does not look inside unfilled closed paths measures none of their interiors. +#[test] +fn a_hit_test_without_unfilled_interiors_measures_no_interior() { + let mut d = Document::new(200.0, 200.0); + stroked(&mut d, &FRAME, true); + let p = Point::new(50.0, 50.0); + let probed = |f: &dyn Fn()| { + INTERIORS_PROBED.with(|c| c.set(0)); + f(); + INTERIORS_PROBED.with(std::cell::Cell::get) + }; + assert_eq!(probed(&|| assert_eq!(hit_test(&d, p, SELECTING), None)), 0, "hit_test"); + assert_eq!(probed(&|| assert!(objects_at(&d, p, SELECTING, None).is_empty())), 0, "objects_at"); + assert_eq!(probed(&|| assert_eq!(hit_test(&d, p, HitOptions { path_only: true, ..INTERIORS }), None)), 0, "by path only"); + assert_eq!(probed(&|| assert!(hit_test(&d, p, INTERIORS).is_some())), 1, "looking inside"); +} + +/// Direct Selection on a dynamic symbol's instance that picks no part of its art, where no +/// unfilled closed path of the art holds the point, walks the art once. +#[test] +fn a_symbol_part_pick_that_hits_nothing_walks_the_art_once() { + let mut d = Document::new(200.0, 200.0); + let corners: Vec> = (0..10).map(|i| Arc::new(open_corner(&mut d, f64::from(i)))).collect(); + let root = Node::group(d.alloc_id(), corners); + d.symbols.push(crate::Symbol { dynamic: true, name: "Corners".into(), art: Arc::new(root) }); + let l = d.layers[0].id; + let inst = d.alloc_id(); + d.insert(Some(l), 0, Node::new(inst, NodeKind::SymbolInstance { symbol: "Corners".into(), xf: vectorcraft_geom::Affine::IDENTITY })).unwrap(); + let n = d.node(inst).unwrap(); + let p = Point::new(50.0, 50.0); + let (part, without) = leaves_tested(|| symbol_part_at(&d, n, p, SELECTING)); + assert_eq!(part, None); + assert!(without >= 10, "{without} leaves tested"); + let (part, with) = leaves_tested(|| symbol_part_at(&d, n, p, INTERIORS)); + assert_eq!(part, None); + assert_eq!(with, without); +} + #[test] fn long_plain_stroke_hits_its_middle_and_curved_end() { let mut d = Document::new(200.0, 200.0); From 740b04cde0bab8b78449c06d61bc5426fabd65ca Mon Sep 17 00:00:00 2001 From: Fredrik Hallin Date: Sun, 29 Nov 2026 18:54:50 +0100 Subject: [PATCH 106/264] CI: use the standard macOS runner for releases --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 226830fc1b..538d09cc31 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,7 @@ jobs: dry-run: ${{ github.event_name == 'schedule' }} app-name: vectorcraft app-title: VectorCraft + macos-runner: macos-15 craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 web-craft-fonts: true version: ${{ inputs.version }} From 6a48d5af401469f2bff3a8baee68ab2029df6d09 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:55:34 -0800 Subject: [PATCH 107/264] Tools: the rail shows one rule above the controls under the tools The tool rail's footer region draws its own rule and gap since craft-libs#4140, so the divider at the top of bottom_controls drew a second rule. Remove it, and have the rule test count exactly one. --- crates/ui-egui/src/toolbar.rs | 4 ++-- crates/ui-egui/src/toolbar/tests.rs | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6f2f72d06a..973e47ddf1 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -768,11 +768,11 @@ fn quad_bounds(quad: &[Point; 4]) -> vectorcraft_geom::Rect { /// The Fill/Stroke proxy, Color/Gradient/None, the drawing modes and screen mode under the rail's /// tools: in two columns the three drawing modes show, in one only the current one, which cycles /// them. A row the rail is too narrow for goes on in the next line. The All Tools drawer's Show -/// section hides any of them. A rule above them parts them from the tools, which scroll above it in a short rail. +/// section hides any of them. The rail's footer region draws the rule that parts them from the tools, which scroll +/// above it in a short rail. fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { let two = footer.columns > 1; let show = app.ui.toolbar_show; - Divider::horizontal().show(ui); if show.fill_stroke { crate::panels::proxy(app, ui); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 9ce6cca2e6..66688bf9ed 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -306,9 +306,9 @@ fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { assert_eq!(app.session.draw_mode, vectorcraft_engine::DrawMode::Behind); } -/// In one column the Color, Gradient and None chips share one line, and a rule across the rail parts the controls under -/// the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and -/// Stroke. +/// In one column the Color, Gradient and None chips share one line, and one rule across the rail parts the controls +/// under the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and +/// Stroke, and no second rule doubles it. #[test] fn the_controls_under_the_tools_share_a_line_under_a_rule() { let mut app = app_with(200, 200); @@ -325,12 +325,15 @@ fn the_controls_under_the_tools_share_a_line_under_a_rule() { // A rule is a thin horizontal line or bar across most of the rail's width, between the tools and the controls. let between = |y: f32| y > last.bottom() && y < proxy.top(); let across = |left: f32, right: f32| right - left >= last.width() * 0.75 && left < last.right() && right > last.left(); - let ruled = flat.iter().any(|shape| match shape { - egui::Shape::LineSegment { points: [a, b], .. } => (a.y - b.y).abs() < 0.5 && between(a.y) && across(a.x.min(b.x), a.x.max(b.x)), - egui::Shape::Rect(r) => r.rect.height() <= 2.0 && between(r.rect.center().y) && across(r.rect.left(), r.rect.right()), - _ => false, - }); - assert!(ruled, "a rule lies between the last tool {last:?} and Fill and Stroke {proxy:?}"); + let rules = flat + .iter() + .filter(|shape| match shape { + egui::Shape::LineSegment { points: [a, b], .. } => (a.y - b.y).abs() < 0.5 && between(a.y) && across(a.x.min(b.x), a.x.max(b.x)), + egui::Shape::Rect(r) => r.rect.height() <= 2.0 && between(r.rect.center().y) && across(r.rect.left(), r.rect.right()), + _ => false, + }) + .count(); + assert_eq!(rules, 1, "one rule lies between the last tool {last:?} and Fill and Stroke {proxy:?}"); } /// A screen reader reads the drawing-mode buttons' state as the rail shows it, in every mode: in two columns the From a17883546e75e8e63f115b51d8a385597e932e08 Mon Sep 17 00:00:00 2001 From: Fredrik Hallin Date: Sun, 29 Nov 2026 18:58:59 +0100 Subject: [PATCH 108/264] Release: VectorCraft v0.25.0 Ship the drawing, text, import/export and editing fixes merged since 0.24.1. --- Cargo.lock | 120 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4da7886c88..b6394fde6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8515,7 +8515,7 @@ dependencies = [ [[package]] name = "vectorcraft" -version = "0.24.1" +version = "0.25.0" dependencies = [ "arboard", "block2 0.6.2", @@ -8559,7 +8559,7 @@ dependencies = [ [[package]] name = "vectorcraft-affinity" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-affinity", "craft-image-codecs", @@ -8570,26 +8570,26 @@ dependencies = [ [[package]] name = "vectorcraft-apischema" -version = "0.24.1" +version = "0.25.0" dependencies = [ "serde_json", ] [[package]] name = "vectorcraft-brush" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "serde", "serde_json", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", ] [[package]] name = "vectorcraft-cad" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-dxf", "craft-image-codecs", @@ -8601,14 +8601,14 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-text", ] [[package]] name = "vectorcraft-cli" -version = "0.24.1" +version = "0.25.0" dependencies = [ "log", "objc2-core-foundation", @@ -8619,7 +8619,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-mcp", "vectorcraft-render", "vectorcraft-svg", @@ -8631,7 +8631,7 @@ dependencies = [ [[package]] name = "vectorcraft-color" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-cms", "craft-color-ui", @@ -8647,7 +8647,7 @@ dependencies = [ [[package]] name = "vectorcraft-doc" -version = "0.24.1" +version = "0.25.0" dependencies = [ "chrono", "craft-image-codecs", @@ -8663,13 +8663,13 @@ dependencies = [ "thiserror 2.0.21", "tiff", "vectorcraft-color", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "zune-jpeg", ] [[package]] name = "vectorcraft-effects" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-svg", @@ -8679,8 +8679,8 @@ dependencies = [ "svgtypes 0.16.1", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-plugins", "vectorcraft-text", "vectorcraft-three-d", @@ -8690,7 +8690,7 @@ dependencies = [ [[package]] name = "vectorcraft-engine" -version = "0.24.1" +version = "0.25.0" dependencies = [ "apple-native-keyring-store", "cfb", @@ -8737,10 +8737,10 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-js", "vectorcraft-metafile", - "vectorcraft-pathops 0.24.1", + "vectorcraft-pathops 0.25.0", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -8760,7 +8760,7 @@ dependencies = [ [[package]] name = "vectorcraft-eps" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-eps", "craft-image-codecs", @@ -8781,9 +8781,9 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-effects", "vectorcraft-eps", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-metafile", - "vectorcraft-pathops 0.24.1", + "vectorcraft-pathops 0.25.0", "vectorcraft-pdf", "vectorcraft-render", "vectorcraft-testkit", @@ -8792,7 +8792,7 @@ dependencies = [ [[package]] name = "vectorcraft-format" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-gzip", "craft-vectorcraft-format", @@ -8804,7 +8804,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-brush", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-testkit", ] @@ -8820,7 +8820,7 @@ dependencies = [ [[package]] name = "vectorcraft-geom" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "proptest", @@ -8831,7 +8831,7 @@ dependencies = [ [[package]] name = "vectorcraft-js" -version = "0.24.1" +version = "0.25.0" dependencies = [ "chrono", "craft-xml", @@ -8842,7 +8842,7 @@ dependencies = [ [[package]] name = "vectorcraft-mcp" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-image-codecs", @@ -8854,7 +8854,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-render", "vectorcraft-svg", "vectorcraft-testkit", @@ -8863,7 +8863,7 @@ dependencies = [ [[package]] name = "vectorcraft-metafile" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-metafile", @@ -8873,7 +8873,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-text", ] @@ -8890,19 +8890,19 @@ dependencies = [ [[package]] name = "vectorcraft-pathops" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "linesweeper", "proptest", "thiserror 2.0.21", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-testkit", ] [[package]] name = "vectorcraft-pdf" -version = "0.24.1" +version = "0.25.0" dependencies = [ "aes 0.8.4", "chrono", @@ -8931,7 +8931,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-pdf", "vectorcraft-testkit", "vectorcraft-text", @@ -8939,7 +8939,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugin-worker" -version = "0.24.1" +version = "0.25.0" dependencies = [ "js-sys", "vectorcraft-plugins", @@ -8949,7 +8949,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugins" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-vectorcraft-format", @@ -8961,7 +8961,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-js", "vectorcraft-plugins", "wasmi", @@ -8972,7 +8972,7 @@ dependencies = [ [[package]] name = "vectorcraft-render" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-gif", "craft-image-codecs", @@ -8990,7 +8990,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-plugins", "vectorcraft-testkit", "vectorcraft-text", @@ -9003,7 +9003,7 @@ dependencies = [ [[package]] name = "vectorcraft-scriptcheck" -version = "0.24.1" +version = "0.25.0" dependencies = [ "proptest", "unicode-properties", @@ -9011,7 +9011,7 @@ dependencies = [ [[package]] name = "vectorcraft-svg" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-docpath", "craft-image-codecs", @@ -9035,15 +9035,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-testkit", "vectorcraft-text", ] [[package]] name = "vectorcraft-testkit" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "fax", @@ -9054,14 +9054,14 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-render", "vectorcraft-svg", ] [[package]] name = "vectorcraft-text" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-fonts-build", @@ -9079,23 +9079,23 @@ dependencies = [ "unicode-script", "unicode-segmentation", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vello_cpu", "write-fonts", ] [[package]] name = "vectorcraft-three-d" -version = "0.24.1" +version = "0.25.0" dependencies = [ "proptest", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", ] [[package]] name = "vectorcraft-thumbnail-handler" -version = "0.24.1" +version = "0.25.0" dependencies = [ "png 0.18.1", "windows", @@ -9104,7 +9104,7 @@ dependencies = [ [[package]] name = "vectorcraft-tools" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "kurbo 0.13.1", @@ -9114,15 +9114,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-text", "vectorcraft-tools", ] [[package]] name = "vectorcraft-trace" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "image", @@ -9130,12 +9130,12 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.21", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", ] [[package]] name = "vectorcraft-ui-egui" -version = "0.24.1" +version = "0.25.0" dependencies = [ "bytemuck", "chrono", @@ -9159,7 +9159,7 @@ dependencies = [ "vectorcraft-engine", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -9174,7 +9174,7 @@ dependencies = [ [[package]] name = "vectorcraft-web" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-web-api", @@ -10403,7 +10403,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee" [[package]] name = "xtask" -version = "0.24.1" +version = "0.25.0" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index d3057fb0af..1a611b41e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"] default-members = ["crates/*", "apps/vectorcraft", "apps/vectorcraft-cli", "xtask"] [workspace.package] -version = "0.24.1" +version = "0.25.0" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" From bd0d0149ac2c83b3c7a14129a09ebb8f709ac6e2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:00:26 -0800 Subject: [PATCH 109/264] Brushes: Apply Brush text says it clears a stroke's own settings brush.apply clears the brush settings of each path's top stroke, and clearing them is one undo step. The command text and docs/mcp.md now limit the no-op to a current brush whose top strokes already have it, paint, a width above 0 and no settings of their own. A new test applies the current brush to a stroke with its own settings and checks that they are cleared as one undo step. --- crates/engine/src/cmd/brushsym.rs | 2 +- crates/engine/src/tests/brushsym.rs | 15 +++++++++++++++ docs/mcp.md | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/brushsym.rs b/crates/engine/src/cmd/brushsym.rs index 2de3ddfcfe..84f7c5ed3b 100644 --- a/crates/engine/src/cmd/brushsym.rs +++ b/crates/engine/src/cmd/brushsym.rs @@ -98,7 +98,7 @@ pub fn specs() -> Vec { "Apply Brush", [], None, - "{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current; when the strokes already have it and it is already current, nothing changes and no undo step is recorded → {ids}", + "{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current; the brush settings of each path's top stroke (brush.objectOptions) are cleared, and clearing them is one undo step; when the brush is already current and applying it leaves every path as it was (its top stroke already has the brush, paint, a width above 0 and no settings of its own), nothing changes and no undo step is recorded → {ids}", has_doc, brush_apply ), diff --git a/crates/engine/src/tests/brushsym.rs b/crates/engine/src/tests/brushsym.rs index 86074c2a6b..33363119c1 100644 --- a/crates/engine/src/tests/brushsym.rs +++ b/crates/engine/src/tests/brushsym.rs @@ -969,6 +969,21 @@ fn brush_apply_that_changes_nothing_records_no_undo_step() { assert_eq!(undo_steps(&s), steps + 1, "a new stroke to paint is one undo step"); } +/// Applying the current brush again to a stroke with settings of its own clears them as one undo step. +#[test] +fn brush_apply_clears_object_options_as_one_undo_step() { + let mut s = session(); + let a = line(&mut s); + select(&mut s, &[a]); + s.execute("brush.apply", &json!({"name": "Arrow"})).unwrap(); + s.execute("brush.objectOptions", &json!({"params": {"width": 50}})).unwrap(); + assert_eq!(own_options(&s, a), json!({"width": 50.0})); + let steps = undo_steps(&s); + s.execute("brush.apply", &json!({"name": "Arrow"})).unwrap(); + assert_eq!(own_options(&s, a), json!({}), "applying the brush clears the stroke's own settings"); + assert_eq!(undo_steps(&s), steps + 1, "clearing the settings is one undo step"); +} + /// A document whose brushes repeat a name opens with the later brush numbered: strokes of the name /// keep the first brush, and renaming or deleting one brush leaves the other and its strokes alone. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index b22bc55ef5..14e4d45f77 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5180,8 +5180,9 @@ already walks Image Trace. Short agent entry points: the one found first), or black when they use no solid color. `brush.options` changes only the fields of `colorization` and of an art brush's `scale` that `params` gives, so `{colorization: {method: "hueShift"}}` keeps a Hue Shift brush's key. A `brush.options` whose `params` and `newName` leave the brush as it is, and a - `brush.apply` whose strokes already have the brush while it is already current, do not change the document or - its revision and record no undo step. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the + `brush.apply` of the current brush whose paths' top strokes already have the brush, paint, a width above 0 and no + settings of their own, do not change the document or its revision and record no undo step. `brush.apply` clears the own settings + (`brush.objectOptions`) of each path's top stroke, and clearing them is one undo step; lower strokes keep theirs. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the default, leaves every copy's colors as the colorization gives them) turns the hue of each copy's solid fills and strokes, its type's characters included, by that copy's own amount between minus and plus that many degrees. The turn comes after the colorization: with None it turns the art's own colors, with Tints and Tints and Shades the From 6c0ce43b9829b4fdbdcaf964673963b3f1dad8b6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:01:22 -0800 Subject: [PATCH 110/264] Panels: Document Info rows and Image Trace Create use the shared row and check box layouts The craft-libs pin now includes storytold/craft-libs#4147 and #4195. A wrapping SpaceBetween row keeps its children at both edges when they fit on one line, and a check box in a row inside a field shows its own label. - Document Info: a row wraps through the shared row layout instead of measuring its label and value first. A row that fits keeps its value at the end; otherwise the value moves under the label. - Image Trace: the Fills and Strokes check boxes in the Create field show their own labels, without a nested field for each. A new test checks that a Document Info value that does not fit beside its label moves under it. --- crates/ui-egui/src/panels/doc_info.rs | 11 +++-------- crates/ui-egui/src/panels/image_trace/rows.rs | 11 ++--------- crates/ui-egui/src/panels/tests_panel_spacing.rs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index 64d9b2e101..e6f7cb6e86 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -35,14 +35,9 @@ pub struct DocInfoView { /// the second or third click of a double or triple click. pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool { let mut clicked = false; - // A row whose label and value fit on one line keeps the value at its end. A wrapping row places its children as - // `Start` does, so the row wraps only when the two do not fit, as in a narrow panel or a longer translation. - let width = |text: &str| { - let font = egui::TextStyle::Body.resolve(ui.style()); - ui.painter().layout_no_wrap(text.to_string(), font, egui::Color32::WHITE).size().x - }; - let fits = width(label) + width(value) + 2.0 * ui.spacing().item_spacing.x <= ui.available_width(); - Row::new().fill_width().align(RowAlign::SpaceBetween).wrap(!fits).show(ui, |ui, _| { + // A row whose label and value fit on one line keeps the value at its end; otherwise the value wraps under the + // label, as in a narrow panel or a longer translation. + Row::new().fill_width().align(RowAlign::SpaceBetween).wrap(true).show(ui, |ui, _| { Text::new(label.to_string()).shade(Shade::Muted).show(ui); // The value can be selected and copied, and a click copies all of it (#8432). A drag selects // and a Shift-click extends the selection, so neither copies. A value wider than the panel diff --git a/crates/ui-egui/src/panels/image_trace/rows.rs b/crates/ui-egui/src/panels/image_trace/rows.rs index 98551787eb..2c87a42d50 100644 --- a/crates/ui-egui/src/panels/image_trace/rows.rs +++ b/crates/ui-egui/src/panels/image_trace/rows.rs @@ -10,7 +10,7 @@ use craft::color_ui::ui::{ColorPopover, PickedColor}; use craft::theme::Srgba; use craft::ui::buttons::ToggleButton; use craft::ui::choice::{Checkbox, Segmented}; -use craft::ui::contract::{Bind, Entry, FieldLayout, Props as _, Show as _, ShowContainer as _}; +use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; use craft::ui::form::{Field, FieldGroup, SliderField, SliderFieldLayout}; use craft::ui::layout_components::Row; use craft::ui::pickers::Select; @@ -271,14 +271,7 @@ pub(crate) fn advanced_rows(ui: &mut Ui, params: &mut Value, _data: &RowsData, _ Row::new().show(ui, |ui, _| { let mut hit = None; for (key, on, other, label) in [("fills", fills, strokes, tl!("Fills")), ("strokes", strokes, fills, tl!("Strokes"))] { - // Inside the Create field a check box's own label is not drawn, so each box takes a field of - // its own with the label after it. - let enabled = !on || other; - let mut value = on; - Field::new(label).layout(FieldLayout::After).enabled(enabled).show(ui, |ui, _| { - Checkbox::new(Bind::bound(&mut value)).enabled(enabled).show(ui); - }); - if value != on { + if check(ui, label, on, !on || other) { hit = Some(key); } } diff --git a/crates/ui-egui/src/panels/tests_panel_spacing.rs b/crates/ui-egui/src/panels/tests_panel_spacing.rs index 621c92817d..cc9b859468 100644 --- a/crates/ui-egui/src/panels/tests_panel_spacing.rs +++ b/crates/ui-egui/src/panels/tests_panel_spacing.rs @@ -51,6 +51,22 @@ fn a_long_document_info_value_wraps_inside_a_narrow_panel() { } } +#[test] +fn a_document_info_value_that_does_not_fit_beside_its_label_moves_under_it() { + let name = "A document name long enough to run past a narrow panel"; + let mut app = crate::testing::windowed(VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default())); + run(&mut app, "file.new", json!({"width": 200, "height": 200, "name": name})); + let mut panel = Panel::new(app, doc_info::show); + panel.room(egui::vec2(160.0, ROOM.y)); + panel.frame(); + panel.frame(); + let label = one(&panel, "Name"); + let value = run_starting(&panel, "A document"); + assert!(value.top() >= label.bottom() - 0.5, "the value {value:?} stands beside its label {label:?}, not under it"); + // A row that wraps starts each line at the start edge. + assert!((value.left() - label.left()).abs() < 1.0, "the value {value:?} does not start under its label {label:?}"); +} + #[test] fn info_paints_stand_a_section_apart_from_the_numbers() { let mut app = app_with_rect(); From c31cef119901acf0df8201107d1734f5109c9d55 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:12:18 -0800 Subject: [PATCH 111/264] Tools: the controls under the tools scroll with them in a short window In a window too short for every tool, the Tools panel kept its paint chips, drawing modes and the other controls under the tools pinned at the bottom, so fewer tools were in view. The controls now scroll with the tools (ToolRail::footer_scrolls): in a window 560 points tall the rail shows 14 tools instead of 10, and scrolling to the end brings the controls into view under the last tool. Toolbars made with New Toolbar and torn-off strips keep their footer in view. --- crates/ui-egui/src/toolbar.rs | 4 +++ crates/ui-egui/src/toolbar/tests.rs | 49 ++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6f2f72d06a..65c1aadc35 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -456,6 +456,10 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m if app.session.prefs.tool_group_labels { rail = rail.captions(); } + // The Tools panel's controls under the tools scroll with them, so a short window shows more tools. + if tools_panel { + rail = rail.footer_scrolls(); + } if own_bar { rail = rail.tear_off().edit_toolbar(tl!("Edit Toolbar")); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 9ce6cca2e6..75dfeb327c 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -282,17 +282,18 @@ fn polygon_and_star_canvas_counts_persist_without_new_toolbar_dialogs() { /// The paint chips, drawing modes and the rest of the footer lie inside the rail at one and at two columns (one column /// shows the current drawing mode alone), and in two columns the three drawing modes sit side by side, each setting -/// its mode (#1129). +/// its mode (#1129). The window is tall enough for every tool and the controls under them, which scroll with the tools. #[test] fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { let mut app = app_with(200, 200); let ctx = reader(); + let height = 2000.0; let footer = ["Color (, or Shift+,)", "Gradient (. or Shift+.)", "None (/)", "Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"]; let mut nodes = vec![]; for (k, double) in [false, true].into_iter().enumerate() { app.run("window.toolbarColumns", json!({ "double": double })).unwrap(); - nodes = settled(&mut app, &ctx, k as f64 * 10.0, 900.0); + nodes = settled(&mut app, &ctx, k as f64 * 10.0, height); // The rail itself, not its dock grip, which is named for the pane too. let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); for label in &footer[..if double { 6 } else { 4 }] { @@ -302,13 +303,12 @@ fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { } let modes = ["Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"].map(|label| named_rect(&nodes, label)); assert!(modes.iter().all(|r| (r.top() - modes[0].top()).abs() < 0.5), "side by side: {modes:?}"); - click(&mut app, &ctx, 20.0, modes[1].center(), 900.0); + click(&mut app, &ctx, 20.0, modes[1].center(), height); assert_eq!(app.session.draw_mode, vectorcraft_engine::DrawMode::Behind); } /// In one column the Color, Gradient and None chips share one line, and a rule across the rail parts the controls under -/// the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and -/// Stroke. +/// the tools from the tools: it lies between the last tool and Fill and Stroke. #[test] fn the_controls_under_the_tools_share_a_line_under_a_rule() { let mut app = app_with(200, 200); @@ -604,3 +604,42 @@ fn a_short_tools_rail_shows_its_scroll_bar_at_rest() { assert!(bars(&mut app, 0.0, 400.0) > 0, "a short rail shows its scroll bar with the pointer away"); assert_eq!(bars(&mut app, 10.0, 2000.0), 0, "a rail with room for every tool shows no scroll bar"); } + +/// In a window too short for the Tools panel, the controls under the tools scroll with them: the tool buttons fill +/// the rail down to its bottom edge, Fill and Stroke starts out of view under them, and scrolling to the end brings +/// Fill and Stroke into view under the last tool. +#[test] +fn the_tools_panel_controls_scroll_with_the_tools_in_a_short_window() { + let mut app = app_with(200, 200); + let ctx = reader(); + app.run("window.toolbarColumns", json!({ "double": false })).unwrap(); + let height = 560.0; + let nodes = settled(&mut app, &ctx, 0.0, height); + let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); + let tools = cells(&app, &nodes); + let in_view: Vec<&egui::Rect> = tools.iter().filter(|r| r.bottom() <= rail.bottom() + 0.5).collect(); + assert!(in_view.len() < tools.len(), "the window is too short for every tool: {} of {}", in_view.len(), tools.len()); + let pitch = tools[1].top() - tools[0].top(); + let lowest = in_view.iter().map(|r| r.bottom()).fold(f32::MIN, f32::max); + let bottom = rail.bottom(); + assert!(bottom - lowest < pitch, "the tools fill the rail to its bottom: the last in view ends at {lowest}, the rail at {bottom}"); + let proxy = named_rect(&nodes, "Fill and Stroke"); + assert!(proxy.top() >= rail.bottom() - 0.5, "Fill and Stroke starts out of view: {proxy:?} under {rail:?}"); + + let wheel = Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(0.0, -400.0), + modifiers: Default::default(), + phase: egui::TouchPhase::Move, + source: egui::MouseWheelSource::Unknown, + }; + let over = tools[0].center(); + for k in 0..10 { + frame(&mut app, &ctx, 1.0 + f64::from(k) * 0.05, vec![Event::PointerMoved(over), wheel.clone()], height); + } + let nodes = settled(&mut app, &ctx, 2.0, height); + let proxy = named_rect(&nodes, "Fill and Stroke"); + let last = cells(&app, &nodes).into_iter().max_by(|a, b| a.bottom().total_cmp(&b.bottom())).expect("the rail shows tools"); + assert!(proxy.bottom() <= rail.bottom() + 0.5, "Fill and Stroke is in view after scrolling: {proxy:?} in {rail:?}"); + assert!(last.bottom() <= proxy.top(), "the last tool {last:?} stands above Fill and Stroke {proxy:?}"); +} From 599426f0756f018b52f57f92d952c7e5297a2f6b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:14:35 -0800 Subject: [PATCH 112/264] New Document: preset cards rest on a tile The app's root look now sets PresetCardLook::PageTile in place of Page, so each preset card in New Document draws on a light veil of the scrim with its paper on it. A card that is not selected now stands apart from the dialog's surface. The craft-libs pin at 186a229c8d already has the look (storytold/craft-libs#4180). The new test resting_preset_cards_stand_on_a_tile checks that a resting card is covered by a veil of the scrim and holds its white paper; it fails with the old Page look. --- crates/ui-egui/src/app.rs | 4 +-- crates/ui-egui/src/dialogs/new_document.rs | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 97fca4f235..fb3c7fafa4 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -809,8 +809,8 @@ pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32, print root.values.set(TabCloseLook::Glyph); // A collapsed panel column's icon groups stand apart by a hairline, as production drew them. root.values.set(IconGroupSeparator::Rule); - // New Document's preset cards show blank paper on a flat card, as production drew them. - root.values.set(PresetCardLook::Page); + // New Document's preset cards show blank paper on a card that rests on a tile, as production drew them. + root.values.set(PresetCardLook::PageTile); // A bare Tab on the canvas, or with nothing focused, toggles the panels (`window.dock`) instead of moving focus. root.tab_toggles_chrome = true; // Escape in a text field gives up its focus, reverting any typing, so the next keys are the window's. diff --git a/crates/ui-egui/src/dialogs/new_document.rs b/crates/ui-egui/src/dialogs/new_document.rs index efcccd932b..c20582141e 100644 --- a/crates/ui-egui/src/dialogs/new_document.rs +++ b/crates/ui-egui/src/dialogs/new_document.rs @@ -1112,6 +1112,38 @@ mod tests { assert!(inside.is_empty(), "the segments draw icons, not words: {inside:?}"); } + /// Each preset card rests on a tile, a light veil of the scrim over the dialog's surface, with its paper on it, so a + /// card that is not selected still stands apart from the dialog. + #[test] + fn resting_preset_cards_stand_on_a_tile() { + use craft::ui::runtime::env::Env; + use craft::ui::style::rgba_color; + let mut scrim = egui::Color32::TRANSPARENT; + let mut theme = + crate::testing::ui_context().run_ui(Default::default(), |ui| scrim = rgba_color(Env::of(ui).tokens.tokens().color.surface.scrim)); + // The test reads the theme; no renderer applies the frame's textures. + theme.textures_delta.clear(); + let mut app = app(); + open(&mut app); + let out = laid_out(&mut app); + let nodes = out.platform_output.accesskit_update.as_ref().map(|u| u.nodes.clone()).unwrap_or_default(); + let card = nodes + .iter() + .find(|(_, n)| n.role() == egui::accesskit::Role::ListItem && n.label().is_some_and(|l| !l.is_empty()) && n.is_selected() == Some(false)) + .and_then(|(_, n)| n.bounds()) + .map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32))) + .expect("a preset card that is not selected"); + let shapes = crate::tests_labels::flat_painted_shapes(&out.shapes); + let rects: Vec<_> = shapes.iter().filter_map(|shape| if let egui::Shape::Rect(rect) = shape { Some(rect) } else { None }).collect(); + let veil = |fill: egui::Color32| fill.a() > 0 && fill.a() < scrim.a() && fill.to_opaque() == scrim.to_opaque(); + assert!( + rects.iter().any(|rect| veil(rect.fill) && rect.rect.contains_rect(card.shrink(1.0)) && card.expand(1.0).contains_rect(rect.rect)), + "a veil of the scrim {scrim:?} covers the resting card {card:?}: {:?}", + rects.iter().filter(|rect| card.expand(1.0).contains_rect(rect.rect)).map(|rect| (rect.rect, rect.fill)).collect::>() + ); + assert!(rects.iter().any(|rect| rect.fill == egui::Color32::WHITE && card.contains_rect(rect.rect)), "the card's paper is on the tile"); + } + /// Recent shows each entry as it was made: a portrait and a landscape A3 are two documents, and /// the built-in cards turn to the picked orientation (#2860). #[test] From a978fd242a56161482bcc533e5aae8baa97fc426 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:16:00 -0800 Subject: [PATCH 113/264] Type: an edit runs each idle and typing frame once The Type tool's text part was shown in the canvas's flow, in a scope sized to the caret. While the tool edited text, every other frame ran its UI twice: the frame's layout check found the part changed and the frame was run again. The part is now shown at the caret's rect with no allocation, as the canvas's other overlays are, and each idle and typing frame runs once. --- crates/ui-egui/src/tests/lifecycle.rs | 19 +++++++++++++++++++ crates/ui-egui/src/type_editing.rs | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tests/lifecycle.rs b/crates/ui-egui/src/tests/lifecycle.rs index 41ace0ff2d..4080427be8 100644 --- a/crates/ui-egui/src/tests/lifecycle.rs +++ b/crates/ui-egui/src/tests/lifecycle.rs @@ -245,3 +245,22 @@ fn ime_delete_surrounding_then_commit_edit_the_type_tool_once_in_order() { ime_frame(&mut app, &ctx, vec![Event::Ime(egui::ImeEvent::Commit("Q".into()))], |_| {}); assert_eq!(plain(&app, id), "abcQZ"); } + +/// While the Type tool edits text, each idle frame and each typing frame runs its UI once: the text part measures the +/// same in the measuring run and the real run, so no frame is discarded and run again. +#[test] +fn an_edit_runs_each_idle_and_typing_frame_once() { + let (mut app, id) = app_with_text("abc"); + let ctx = crate::testing::ui_context(); + ime_frame(&mut app, &ctx, vec![], |_| {}); + ime_frame(&mut app, &ctx, vec![], |_| {}); + begin_typing(&mut app, &ctx, id); + for _ in 0..3 { + ime_frame(&mut app, &ctx, vec![], |_| {}); + } + let idle: Vec = (0..6).map(|_| run_frame(&mut app, &ctx, vec![], |_| {}, false).0).collect(); + assert_eq!(idle, [1; 6], "each idle frame of the edit runs one pass"); + let typing: Vec = (0..6).map(|_| run_frame(&mut app, &ctx, vec![Event::Text("x".into())], |_| {}, false).0).collect(); + assert_eq!(typing, [1; 6], "each typing frame runs one pass"); + assert!(plain(&app, id).contains("xxxxxx"), "every frame's typing reached the text"); +} diff --git a/crates/ui-egui/src/type_editing.rs b/crates/ui-egui/src/type_editing.rs index 8ee26749a2..878d1d757e 100644 --- a/crates/ui-egui/src/type_editing.rs +++ b/crates/ui-egui/src/type_editing.rs @@ -486,7 +486,8 @@ impl Component for TypeEditor<'_> { } /// Shows the editor part over the Type tool's caret while the tool edits text, before the tool host; returns the part's -/// id. A new edit target is a new IME owner, so a reloaded document interrupts its composition. +/// id. A new edit target is a new IME owner, so a reloaded document interrupts its composition. The part is shown at +/// the caret's rect and takes no room in the canvas's flow, as the canvas's other overlays are. pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> Option { if !app.session.tool_wants_text() || app.viewport_hidden(ui.ctx()) { return None; @@ -496,8 +497,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> Option Date: Sun, 29 Nov 2026 10:17:57 -0800 Subject: [PATCH 114/264] Stroke: Cap, Corner, Align Stroke and Miter Limit line up with the panel rows The Stroke panel showed the stroke editor's rows with a label column of their own, so the Alignment, Caps and Corners buttons and the Miter Limit and Dash offset fields started left of the Weight, Arrowheads and Profile controls. The panel now turns on StrokeEditor::host_labels (craft-libs#4227, in the pinned craft-libs), and the editor's rows read the label column of the panel's Stroke Options group. the_panel_rows_start_their_controls_at_one_x now also checks the Alignment, Caps, Corners, Miter limit and Dash offset controls. --- crates/ui-egui/src/panels/stroke.rs | 5 +++-- crates/ui-egui/src/panels/tests_stroke.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 7ea1db6e49..7f71d73da4 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -377,7 +377,7 @@ pub(crate) fn link_field(app: &mut VectorcraftApp, ui: &mut Ui, label: &'static } /// The Stroke panel: the weight, the stroke editor (cap, corner, align, dashes), arrowheads, scale, align and the -/// width profile. The panel's own rows share one label column, so their controls start at one x. +/// width profile. The panel's rows and the editor's rows share one label column, so their controls start at one x. pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; @@ -411,7 +411,8 @@ fn rows(app: &mut VectorcraftApp, ui: &mut Ui) { let editor = StrokeEditor::new(tl!("Stroke"), Bind::given(style.clone())) .sections(StrokeSections::PANEL | StrokeSections::DASH_ALIGN) .closed(mixed.can_align) - .mixed(&mixed_of(&mixed)); + .mixed(&mixed_of(&mixed)) + .host_labels(true); let output = editor.show(ui); if let (Some(new), Some(field)) = (output.events.landed(), output.field) { apply_style(app, &style, new.clone(), field); diff --git a/crates/ui-egui/src/panels/tests_stroke.rs b/crates/ui-egui/src/panels/tests_stroke.rs index 8aca326b47..66cf954339 100644 --- a/crates/ui-egui/src/panels/tests_stroke.rs +++ b/crates/ui-egui/src/panels/tests_stroke.rs @@ -28,9 +28,16 @@ fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_ #[test] fn the_panel_rows_start_their_controls_at_one_x() { let mut panel = Panel::new(app_with_rect(), stroke::show); + // Dashes show the Dash offset row. + run(&mut panel.app(), "stroke.set", json!({"dash": [4, 2]})); panel.frame(); panel.frame(); - let starts: Vec<(&str, f32)> = ["Weight", "Start arrowhead", "Profile"].into_iter().map(|name| (name, panel.rect(name).min.x)).collect(); + let names = ["Weight", "Miter limit", "Dash offset", "Start arrowhead", "Profile"]; + let mut starts: Vec<(&str, f32)> = names.into_iter().map(|name| (name, panel.rect(name).min.x)).collect(); + // The label text of the editor's button rows has the same names as their button groups. + for name in ["Alignment", "Caps", "Corners"] { + starts.push((name, panel.rect_role(name, craft::ui::contract::Role::RADIO_GROUP).min.x)); + } let first = starts[0].1; assert!(starts.iter().all(|(_, x)| (x - first).abs() < 0.5), "controls start at {starts:?}"); } From c10d62d0271ed5e0bdf84ebba5a56c98fc34241c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:19:29 -0800 Subject: [PATCH 115/264] Performance: paths keep their control-point box, so a hover reads no anchors Hit walks measure every path's culling box with PathData::control_bounds, which read every anchor of the path on every call. Since anchors are kept in shared chunks, that read follows two more pointers per path and goes through the chunked iterator, so each node of a hover or cursor walk cost about twice what it did before the chunks. Each subpath's anchor list now keeps the box round its points and handles once it is measured (Anchors::control_bounds), and every change to the list clears it. A copy of the list keeps the box too. control_bounds unions the subpaths' boxes, with the same result as before. - anchors.rs: control_bounds reads the anchors once until they change, counted by measured_control_anchors; each change to the list clears it. - Tests count the anchors read: a list reads them once across calls and copies, again after each kind of change, and a hover past 100 squares reads none after the first. --- crates/doc/src/hit/tests.rs | 23 ++++++++ crates/geom/src/anchors.rs | 111 +++++++++++++++++++++++++++++++++++- crates/geom/src/path.rs | 7 +-- 3 files changed, 134 insertions(+), 7 deletions(-) diff --git a/crates/doc/src/hit/tests.rs b/crates/doc/src/hit/tests.rs index 7ac945e4ee..ff31058da6 100644 --- a/crates/doc/src/hit/tests.rs +++ b/crates/doc/src/hit/tests.rs @@ -3569,3 +3569,26 @@ fn a_shaper_groups_original_shapes_in_symbol_art_are_not_picked() { assert_eq!(symbol_part_at(&d, n, Point::new(130.0, 50.0), opt), None, "over the erased original shape"); assert_eq!(symbol_part_at(&d, n, Point::new(50.0, 50.0), opt), Some(vec![0, 1]), "over the shown face"); } + +/// The pointer resting over empty canvas past many paths reads their anchors for their culling +/// boxes on the first hover only: the next hovers use the boxes the paths keep. +#[test] +fn hovers_past_many_paths_read_their_anchors_once() { + use vectorcraft_geom::anchors::measured_control_anchors; + let mut d = Document::new(1000.0, 1000.0); + let l = d.layers[0].id; + for i in 0..100 { + let n = square(&mut d, (i % 10) as f64 * 60.0, (i / 10) as f64 * 60.0); + d.insert(Some(l), 0, n).unwrap(); + } + let empty = Point::new(900.0, 900.0); + let before = measured_control_anchors(); + assert!(hit_test(&d, empty, HitOptions::default()).is_none()); + let first = measured_control_anchors() - before; + assert!(first >= 400, "the first hover reads every square's anchors: {first}"); + for _ in 0..3 { + assert!(hit_test(&d, empty, HitOptions::default()).is_none()); + } + assert_eq!(measured_control_anchors() - before, first, "later hovers read no anchor"); + assert!(hit_at(&d, 25.0, 25.0, HitOptions::default()).is_some(), "a square is still hit"); +} diff --git a/crates/geom/src/anchors.rs b/crates/geom/src/anchors.rs index 57b8081686..3b9f4aa9bd 100644 --- a/crates/geom/src/anchors.rs +++ b/crates/geom/src/anchors.rs @@ -8,12 +8,16 @@ //! in and rebuilds the table, which has one entry per chunk. //! //! The list reads and writes as one flat sequence of anchors, as a `Vec` does. +//! +//! The list also keeps the box round its anchors' points and handles ([`Anchors::control_bounds`]) +//! once it has been measured, until the list changes. use std::borrow::Cow; use std::fmt; use std::ops::{Index, IndexMut, RangeBounds}; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; +use kurbo::Rect; use serde::{Deserialize, Serialize}; use crate::path::Anchor; @@ -40,12 +44,49 @@ pub struct Anchors { ends: Vec, /// The number of anchors. len: usize, + /// The box round every anchor's point and handles, once measured; emptied by every change. + control: OnceLock, +} + +thread_local! { + /// [`measured_control_anchors`] of this thread. + static MEASURED_CONTROL_ANCHORS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// How many anchors [`Anchors::control_bounds`] has read on this thread. +pub fn measured_control_anchors() -> u64 { + MEASURED_CONTROL_ANCHORS.get() } impl Anchors { /// An empty list. pub const fn new() -> Self { - Self { chunks: Vec::new(), ends: Vec::new(), len: 0 } + Self { chunks: Vec::new(), ends: Vec::new(), len: 0, control: OnceLock::new() } + } + + /// The box round every anchor's point and handles, or `None` when the list is empty. The list + /// reads its anchors for it once, and again only after it has changed. + pub fn control_bounds(&self) -> Option { + if self.len == 0 { + return None; + } + Some(*self.control.get_or_init(|| { + MEASURED_CONTROL_ANCHORS.set(MEASURED_CONTROL_ANCHORS.get().saturating_add(self.len as u64)); + let mut r: Option = None; + for c in &self.chunks { + for a in c.iter() { + for p in [a.p, a.h_in, a.h_out] { + r = Some(r.map_or(Rect::from_points(p, p), |r| r.union_pt(p))); + } + } + } + r.unwrap_or_default() + })) + } + + /// Forget the measured [`Self::control_bounds`]: every change calls it. + fn changed(&mut self) { + self.control.take(); } /// The number of anchors. @@ -85,6 +126,7 @@ impl Anchors { if i >= self.len { return None; } + self.changed(); let (c, o) = self.locate(i); Arc::make_mut(self.chunks.get_mut(c)?).get_mut(o) } @@ -101,11 +143,13 @@ impl Anchors { /// The first anchor to change. pub fn first_mut(&mut self) -> Option<&mut Anchor> { + self.changed(); Arc::make_mut(self.chunks.first_mut()?).first_mut() } /// The last anchor to change. pub fn last_mut(&mut self) -> Option<&mut Anchor> { + self.changed(); Arc::make_mut(self.chunks.last_mut()?).last_mut() } @@ -118,6 +162,7 @@ impl Anchors { /// The anchors in order, to change. Each chunk is copied, when another list shares it, as the /// iterator reaches it. pub fn iter_mut(&mut self) -> IterMut<'_> { + self.changed(); let chunk: fn(&mut Arc>) -> std::slice::IterMut<'_, Anchor> = |c| Arc::make_mut(c).iter_mut(); self.chunks.iter_mut().flat_map(chunk) } @@ -177,6 +222,7 @@ impl Anchors { /// Rebuild `ends` and `len` after the chunks changed, dropping empty chunks. fn reindex(&mut self) { + self.changed(); self.chunks.retain(|c| !c.is_empty()); self.len = self.chunks.iter().map(|c| c.len()).sum(); let n = self.chunks.len(); @@ -193,6 +239,7 @@ impl Anchors { /// Add `a` at the end. pub fn push(&mut self, a: Anchor) { + self.changed(); match self.chunks.last_mut() { Some(last) if last.len() < CHUNK => Arc::make_mut(last).push(a), _ => { @@ -210,6 +257,7 @@ impl Anchors { /// Remove the last anchor. pub fn pop(&mut self) -> Option { + self.changed(); let last = self.chunks.last_mut()?; let a = Arc::make_mut(last).pop(); if last.is_empty() { @@ -489,6 +537,7 @@ impl Index for Anchors { impl IndexMut for Anchors { /// Anchor `i` to change ([`Anchors::get_mut`]). Panics past the end, as indexing a slice does. fn index_mut(&mut self, i: usize) -> &mut Anchor { + self.changed(); let (c, o) = self.locate(i); &mut Arc::make_mut(&mut self.chunks[c])[o] } @@ -501,7 +550,7 @@ impl From> for Anchors { } let len = v.len(); let chunks = if len <= CHUNK { vec![Arc::new(v)] } else { v.chunks(CHUNK).map(|c| Arc::new(c.to_vec())).collect() }; - Self { chunks, ends: Vec::new(), len } + Self { chunks, ends: Vec::new(), len, control: OnceLock::new() } } } @@ -725,6 +774,8 @@ mod tests { } } assert_eq!(a.len(), v.len(), "step {step}"); + // The box kept from the step before is measured again after the edit. + assert_eq!(a.control_bounds(), Anchors::from(v.clone()).control_bounds(), "step {step}"); if step % 50 == 0 { assert_eq!(a, v, "step {step}"); for i in 0..v.len() { @@ -737,6 +788,60 @@ mod tests { assert_eq!(a.get(v.len()), None); } + /// The box of every anchor of `v` with its handles, measured anchor by anchor. + fn box_of(v: &[Anchor]) -> Option { + let mut it = v.iter().flat_map(|a| [a.p, a.h_in, a.h_out]); + let first = it.next()?; + Some(it.fold(Rect::from_points(first, first), |r, p| r.union_pt(p))) + } + + #[test] + fn control_bounds_read_the_anchors_once_until_they_change() { + let n = 1000; + let mut a = Anchors::from(line(n)); + let read = measured_control_anchors; + let before = read(); + assert_eq!(a.control_bounds(), box_of(&line(n))); + assert_eq!(read() - before, n as u64, "the first call reads every anchor"); + let copy = a.clone(); + for _ in 0..5 { + assert_eq!(a.control_bounds(), box_of(&line(n))); + assert_eq!(copy.control_bounds(), box_of(&line(n))); + } + assert_eq!(read() - before, n as u64, "later calls, and a copy's, read no anchor"); + // Every change measures again, and only the list that changed. + let far = Point::new(-50.0, 900.0); + type Edit = fn(&mut Anchors, Point); + let edits: [(&str, Edit); 11] = [ + ("get_mut", |a, p| a.get_mut(3).into_iter().for_each(|x| x.h_out = p)), + ("index_mut", |a, p| a[4].h_in = p), + ("first_mut", |a, p| a.first_mut().into_iter().for_each(|x| x.p = p)), + ("last_mut", |a, p| a.last_mut().into_iter().for_each(|x| x.p = p)), + ("iter_mut", |a, p| a.iter_mut().take(1).for_each(|x| x.p = p)), + ("push", |a, p| a.push(Anchor::corner(p))), + ("insert", |a, p| a.insert(1, Anchor::corner(p))), + ("pop", |a, _| { + let _ = a.pop(); + }), + ("remove", |a, _| { + let _ = a.try_remove(0); + }), + ("truncate", |a, _| a.truncate(10)), + ("reverse", |a, _| a.reverse()), + ]; + for (k, (what, edit)) in edits.iter().enumerate() { + let p = Point::new(far.x - k as f64, far.y + k as f64); + assert!(a.control_bounds().is_some()); + edit(&mut a, p); + let r = read(); + assert_eq!(a.control_bounds(), box_of(&a.to_vec()), "after {what}"); + assert_eq!(read() - r, a.len() as u64, "after {what}: measured again"); + } + assert_eq!(copy.control_bounds(), box_of(&line(n)), "the copy keeps its box"); + a.clear(); + assert_eq!(a.control_bounds(), None); + } + #[test] fn iterators_skip_and_count_as_a_slice_does() { let v = line(1000); diff --git a/crates/geom/src/path.rs b/crates/geom/src/path.rs index 5264414cb3..c5e857f017 100644 --- a/crates/geom/src/path.rs +++ b/crates/geom/src/path.rs @@ -745,11 +745,10 @@ impl PathData { } bbox } - /// Bounds including control handles (used for quick culling). + /// Bounds including control handles (used for quick culling). Each subpath keeps its own box + /// ([`Anchors::control_bounds`]) until its anchors change. pub fn control_bounds(&self) -> Option { - let mut it = self.subpaths.iter().flat_map(|s| s.anchors.iter()).flat_map(|a| [a.p, a.h_in, a.h_out]); - let first = it.next()?; - Some(it.fold(Rect::from_points(first, first), |r, p| r.union_pt(p))) + self.subpaths.iter().filter_map(|s| s.anchors.control_bounds()).reduce(|a, b| a.union(b)) } pub fn transform(&mut self, a: Affine) { for sp in &mut self.subpaths { From 87b5aef6394417e788092b49ba1cd54a7001f46d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:13:51 -0800 Subject: [PATCH 116/264] Scripts: point removals keep the selection, defaults and batching right Follow-up to #9288. - Removing the last anchor of a closed path with its closing segment selected also deselects the first anchor, the segment's other end. - Removing a point puts back new art's paint, so a default stroke width a script set still applies to the next path it draws. - A removal that leaves the direct selection as it was waits with the other point changes, unless every remaining anchor is now selected, the selection refers to points that are gone, or the path is in an Objects on Path group. - Reading the points of a path first writes the waiting point changes of another path in the same Objects on Path group. - Writing a path in an Objects on Path group checks the other tracked paths in the outermost such group, so their PathPoint handles go stale when the group moves them, even after an undo. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/script/dom/paths.rs | 119 +++++++++-- crates/engine/src/tests/script_dom_paths.rs | 215 ++++++++++++++++++++ docs/mcp.md | 10 +- docs/target-app-parity.md | 2 +- 4 files changed, 321 insertions(+), 25 deletions(-) diff --git a/crates/engine/src/script/dom/paths.rs b/crates/engine/src/script/dom/paths.rs index 27b449a5b9..e4f6bb203e 100644 --- a/crates/engine/src/script/dom/paths.rs +++ b/crates/engine/src/script/dom/paths.rs @@ -1225,7 +1225,26 @@ fn path_resize(h: &super::Host, a: &[Data]) -> Answer { fn points_path(h: &super::Host, a: &[Data]) -> std::result::Result { let Some(handle) = handle_of(arg(a, 0), "PathPoints") else { return Err(HostError::Type("this is not a PathPoints".into())) }; let [run, uid, high, low] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoints".into())) }; - path_at(h, *run, *uid, *high, *low) + let item = path_at(h, *run, *uid, *high, *low)?; + flush_other(h, item)?; + Ok(item) +} + +/// Writes the waiting point changes of another path in the same Objects on Path group as `item`. +fn flush_other(h: &super::Host, item: Item) -> std::result::Result<(), HostError> { + let waiting = h.dom.pending.borrow().as_ref().map(|(w, _)| *w); + let other = waiting.is_some_and(|w| { + w.doc.uid == item.doc.uid + && w.id != item.id + && with_doc(h, item.doc, |_, st| { + let d = &st.doc; + let read = d.ancestry(item.id).unwrap_or_default(); + d.ancestry(w.id).is_some_and(|a| { + a.iter().any(|g| read.contains(g) && d.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)) + }) + }) + }); + if other { flush(h) } else { Ok(()) } } /// `typename` of the points of a path that is still in its document. @@ -1322,7 +1341,8 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) { /// the object model is changing ([`super::State`]), or that object itself, take the change as the /// object model's own, and their points stay valid. A document that is the one the run last looked /// at is skipped, as are its paths. While the object model writes one path's points -/// ([`super::State`]'s `one_path`), only that path is looked at in its document. +/// ([`super::State`]'s `one_path`), only that path and tracked paths in its outermost enclosing +/// Objects on Path group are looked at in its document. pub(super) fn see_all_points(h: &super::Host) { let keys: Vec<(u64, u64)> = { let seen = h.dom.point_nodes.borrow(); @@ -1335,9 +1355,24 @@ pub(super) fn see_all_points(h: &super::Host) { let mut keys = Vec::new(); // The documents that changed since the last look, kept as they are now. for (uid, paths) in seen.iter().filter(|(_, paths)| !paths.is_empty()) { + // Editing a path in an Objects on Path group can move other paths in the group. + let mut moved = Vec::new(); match s.documents().iter().find(|d| d.uid == *uid) { Some(st) if docs.get(uid).is_some_and(|d| Arc::ptr_eq(d, &st.doc)) => continue, Some(st) => { + if let Some(item) = one.filter(|i| i.doc.uid == *uid) { + let d = &st.doc; + let group = d.ancestry(item.id).and_then(|a| { + a.into_iter().filter_map(|id| d.node(id)).find(|g| vectorcraft_doc::objects_on_path::is_objects_on_path(g)) + }); + if let Some(g) = group { + g.walk(&mut |n: &crate::doc::Node| { + if n.id != item.id && paths.contains_key(&n.id.0) { + moved.push((*uid, n.id.0)); + } + }); + } + } docs.insert(*uid, st.doc.clone()); } None => { @@ -1345,7 +1380,10 @@ pub(super) fn see_all_points(h: &super::Host) { } } match one { - Some(item) if item.doc.uid == *uid => keys.extend(paths.contains_key(&item.id.0).then_some((*uid, item.id.0))), + Some(item) if item.doc.uid == *uid => { + keys.extend(paths.contains_key(&item.id.0).then_some((*uid, item.id.0))); + keys.append(&mut moved); + } _ => keys.extend(paths.keys().map(|id| (*uid, *id))), } } @@ -1432,6 +1470,7 @@ pub(super) fn this_point(h: &super::Host, a: &[Data]) -> std::result::Result<(It let Some(handle) = handle_of(arg(a, 0), "PathPoint") else { return Err(HostError::Type("this is not a PathPoint".into())) }; let [run, uid, high, low, i, cuts] = handle.as_slice() else { return Err(HostError::Type("this is not a PathPoint".into())) }; let item = path_at(h, *run, *uid, *high, *low)?; + flush_other(h, item)?; if whole(*cuts) != Some(point_cuts(h, item)) { return Err(HostError::Error(STALE_POINT.into())); } @@ -1664,38 +1703,69 @@ fn pt_remove(h: &super::Host, a: &[Data]) -> Answer { let sel = &st.selection; (sel.anchors.contains_key(&item.id) || sel.segments.contains_key(&item.id)).then(|| sel.clone()) }; + // Writing the points can prune the selection, and selecting loads the selected paths' paint + // into new art, so new art's paint, the defaults a script set included, is put back. + keeping_paint(h, || remove_point(h, item, i, selected))?; + cut_points(h, item); + Ok(Data::Undefined) +} + +/// Removes point `i` of the path of `item` for [`pt_remove`], and renumbers `selected`, the +/// direct selection of the path's points before the removal. +fn remove_point(h: &super::Host, item: Item, i: usize, selected: Option) -> std::result::Result<(), HostError> { let removed = edit_points(h, item, |subs| { let (s, j) = locate(subs, i)?; let sp = subs.get_mut(s)?; - // The segment that closes a closed subpath ends at its first anchor. - let closing = (sp.closed && j == 0).then(|| sp.anchors.len() - 1); + // The segment that closes a closed subpath runs from its last anchor to its first. + let last = sp.closed.then(|| sp.anchors.len() - 1); sp.anchors.remove(j); let gone = sp.anchors.is_empty(); if gone { subs.remove(s); } - Some((s, j, gone, closing)) + Some((s, j, gone, last)) })?; - if let (Some((s, j, gone, closing)), Some(mut sel)) = (removed, selected) { - // The points are written first, and the selection is then set with selection commands, - // which the journal records with the edit. - flush(h)?; - renumber_selected(&mut sel, item.id, s, j, gone, closing); - on_doc(h, item.doc.uid, false, |h| { - let doc = h.session.borrow().active().map(|st| st.doc.clone()).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; - super::restore_selection(h, &doc, &sel) - })?; + if let (Some((s, j, gone, last)), Some(before)) = (removed, selected) { + let mut sel = before.clone(); + renumber_selected(&mut sel, item.id, s, j, gone, last); + // A selection the removal leaves as it was waits with the points, so that removals in a + // row are written together, unless its anchors are now all of the path's, which selects + // the path whole, or the path is in an Objects on Path group, which places it again. + let wait = sel == before && { + let valid = read_points(h, item, |subs| { + sel.anchors.get(&item.id).is_none_or(|a| a.iter().all(|(p, k)| subs.get(*p).is_some_and(|sp| *k < sp.anchors.len()))) + && sel.segments.get(&item.id).is_none_or(|a| a.iter().all(|(p, k)| subs.get(*p).is_some_and(|sp| sp.has_segment(*k, true)))) + })?; + let total = points_of(h, item)?; + let all = sel.anchors.get(&item.id).is_some_and(|a| a.len() >= total) && !sel.segments.contains_key(&item.id); + let on_path = with_doc(h, item.doc, |_, st| { + let d = &st.doc; + d.ancestry(item.id).is_some_and(|a| a.iter().any(|g| d.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path))) + }); + valid && !all && !on_path + }; + if !wait { + // The points are written first, and the selection is then set with selection + // commands, which the journal records with the edit. + flush(h)?; + on_doc(h, item.doc.uid, false, |h| { + let doc = h.session.borrow().active().map(|st| st.doc.clone()).ok_or_else(|| HostError::Error(super::STALE_DOCUMENT.into()))?; + super::restore_selection(h, &doc, &sel) + })?; + } } - cut_points(h, item); - Ok(Data::Undefined) + Ok(()) } /// Updates the direct selection `sel` of the path `id` after the anchor `j` of its subpath `s` was /// removed, and the subpath with it when `gone`: the anchor, the segments it ended and their other /// ends leave the selection, unless a segment still selected ends there, and the anchors, segments -/// and subpaths after it keep the points they selected. `closing` is the segment that closed the -/// subpath at the removed anchor, when it did. -fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: usize, gone: bool, closing: Option) { +/// and subpaths after it keep the points they selected. `last` is the index of the subpath's last +/// anchor before the removal when the subpath is closed: its closing segment runs from that anchor +/// to anchor 0. +fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: usize, gone: bool, last: Option) { + // The closing segment ends at the removed anchor when the removed anchor is the first one. + let closing = last.filter(|_| j == 0); // An anchor (or a segment, by its first anchor) after the removed one moves down one place. let shift = |(p, k): (usize, usize), segment: bool| -> Option<(usize, usize)> { match p.cmp(&s) { @@ -1713,7 +1783,14 @@ fn renumber_selected(sel: &mut crate::doc::Selection, id: NodeId, s: usize, j: u let cut: Vec<(usize, usize)> = segments.iter().copied().filter(|g| shift(*g, true).is_none() && g.0 == s && !gone).collect(); for (p, k) in cut { // Segment k runs from anchor k to anchor k + 1; one of the two is the removed one. - let other = if k == j { k + 1 } else { k }; + // The closing segment of a closed subpath ends at anchor 0. + let other = if k != j { + k + } else if last == Some(k) { + 0 + } else { + k + 1 + }; // The closing segment's other end is its first anchor, the old last one. let other = if closing == Some(k) { k } else { other }; ends.extend(shift((p, other), false)); diff --git a/crates/engine/src/tests/script_dom_paths.rs b/crates/engine/src/tests/script_dom_paths.rs index d33246aba7..87f1c4f9ab 100644 --- a/crates/engine/src/tests/script_dom_paths.rs +++ b/crates/engine/src/tests/script_dom_paths.rs @@ -809,6 +809,221 @@ fn removing_a_point_keeps_the_direct_selection_on_the_same_anchors() { assert!(!s.active().unwrap().selection.objects.contains(&a)); } +/// Removing the last anchor of a closed path with only its closing segment selected takes the +/// segment's other end, the first anchor, out of the selection too. +#[test] +fn removing_the_last_point_deselects_the_closing_segment_and_its_first_anchor() { + let (mut s, a, _) = doc(); + s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 3]], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[3].remove();"); + assert_eq!(selected_anchors(&s, a), None, "the first anchor is not selected"); + assert!(!s.active().unwrap().selection.objects.contains(&a)); +} + +/// Removing a point that renumbers the selected anchors keeps the new-art stroke width a script +/// set, so the next path it draws gets it. +#[test] +fn removing_a_point_keeps_the_default_stroke_width_a_script_set() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 2]]}], "mode": "set"})).unwrap(); + let out = log( + &mut s, + "var d = app.activeDocument; d.defaultStrokeWidth = 7; d.pathItems[0].pathPoints[0].remove();\ + vc.log(d.pathItems.rectangle(10, 10, 5, 5).strokeWidth);", + ); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 1)])); + assert_eq!(out, [json!(7)]); +} + +/// Removals that leave the direct selection as it was are written together, with one +/// `path.setAnchors`. +#[test] +fn removals_that_keep_the_selection_are_written_together() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 0]]}], "mode": "set"})).unwrap(); + let start = s.journal.len(); + log(&mut s, "var q = app.activeDocument.pathItems[0].pathPoints; q[3].remove(); q[2].remove();"); + let writes = s.journal.iter().skip(start).filter(|(id, _)| id == "path.setAnchors").count(); + assert_eq!(writes, 1); + assert_eq!(node(&s, a).path_data().unwrap().subpaths[0].anchors.len(), 2); + assert_eq!(selected_anchors(&s, a), Some(vec![(0, 0)])); +} + +#[test] +fn removing_a_replacement_point_clears_selection_of_a_missing_subpath() { + for segments in [false, true] { + let (mut s, a, _) = doc(); + let anchors: Vec = (0..3).map(|x| json!({"x": x, "y": 0, "in": [x, 0], "out": [x, 0], "smooth": false})).collect(); + s.execute("path.setAnchors", &json!({"id": a.0, "subpaths": [{"anchors": anchors, "closed": false}, {"anchors": anchors, "closed": false}]})) + .unwrap(); + if segments { + s.execute("select.segments", &json!({"id": a.0, "segments": [[1, 0]], "mode": "set"})).unwrap(); + } else { + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[1, 0]]}], "mode": "set"})).unwrap(); + } + let out = log( + &mut s, + "var p = app.activeDocument.pathItems[0]; p.setEntirePath([[0, 0], [10, 0], [20, 0], [30, 0]]);\ + p.pathPoints[3].remove(); vc.log(p.selected); vc.log(p.selectedPathPoints.length);", + ); + assert_eq!(out, [json!(false), json!(0)], "segments: {segments}"); + let path = node(&s, a); + let subs = &path.path_data().unwrap().subpaths; + assert_eq!(subs.len(), 1); + assert_eq!(subs[0].anchors.len(), 3); + assert_eq!(selected_anchors(&s, a), None); + let sel = &s.active().unwrap().selection; + assert!(!sel.segments.contains_key(&a)); + assert!(!sel.objects.contains(&a)); + } +} + +#[test] +fn reading_an_unrelated_path_keeps_point_edits_written_together() { + let (mut s, a, b) = doc(); + let before = node(&s, b); + let start = s.journal.len(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, p = P[0].pathPoints, q = P[1].pathPoints;\ + p[0].anchor = [20, 30]; vc.log(q.length); vc.log(q[0].anchor); p[1].anchor = [50, 30];", + ); + let writes = s.journal.iter().skip(start).filter(|(id, _)| id == "path.setAnchors").count(); + assert_eq!(writes, 1); + assert_eq!(out, [json!(4), json!([100, 200])]); + assert_eq!(node(&s, b), before); + let edited = node(&s, a); + let anchors = &edited.path_data().unwrap().subpaths[0].anchors; + assert_eq!(anchors[0].p, vectorcraft_geom::Point::new(20.0, 270.0)); + assert_eq!(anchors[1].p, vectorcraft_geom::Point::new(50.0, 270.0)); +} + +/// Removing the one point that was not direct-selected leaves every point selected, which +/// selects the path whole. +#[test] +fn removing_the_only_unselected_point_selects_the_path_whole() { + let (mut s, a, _) = doc(); + s.execute("select.anchorsMany", &json!({"items": [{"id": a.0, "anchors": [[0, 0], [0, 1], [0, 2]]}], "mode": "set"})).unwrap(); + log(&mut s, "app.activeDocument.pathItems[0].pathPoints[3].remove();"); + assert_eq!(selected_anchors(&s, a), None); + assert!(s.active().unwrap().selection.objects.contains(&a)); +} + +/// Removing a point of a direct-selected member of an Objects on Path group writes it at once, so +/// its points read where the group places it. +#[test] +fn removing_a_point_of_a_selected_member_reads_where_the_group_places_it() { + let (mut s, b) = doc_on_path(); + s.execute("select.anchorsMany", &json!({"items": [{"id": b.0, "anchors": [[0, 0]]}], "mode": "set"})).unwrap(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, m = P.getByName('m');\ + m.pathPoints[3].remove(); m.pathPoints[2].remove(); vc.log(m.pathPoints[0].anchor);\ + P.rectangle(0, 0, 1, 1); vc.log(P.getByName('m').pathPoints[0].anchor);", + ); + assert_eq!(out[0], out[1], "the member read where it is after the run"); +} + +/// [`doc`] with path `drive`, the path of an Objects on Path group that holds `b`, named `m`. +fn doc_on_path() -> (Session, NodeId) { + let (mut s, _, b) = doc(); + let c = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + log(&mut s, "var p = app.activeDocument.pathItems; p[0].name = 'drive'; p[2].name = 'm';"); + s.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + s.execute("object.objectsOnPath.attach", &json!({"path": c.0, "ids": [b.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + (s, b) +} + +/// Reading the points of a path writes the waiting point changes of another path first, so a +/// member of an Objects on Path group reads where the group's edited path moved it. +#[test] +fn reading_a_member_point_after_editing_its_group_path_reads_where_it_moved() { + let (mut s, _) = doc_on_path(); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, g = P.getByName('drive'), m = P.getByName('m');\ + var x = m.pathPoints[0].anchor[0];\ + for (var i = 0; i < g.pathPoints.length; i++) { var q = g.pathPoints[i]; q.anchor = [q.anchor[0] + 50, q.anchor[1]]; }\ + vc.log(m.pathPoints[0].anchor[0] - x);\ + P.rectangle(0, 0, 1, 1); vc.log(P.getByName('m').pathPoints[0].anchor[0] - x);", + ); + assert_ne!(out[1], json!(0), "the member moved"); + assert_eq!(out[0], out[1], "the member read where it is after the run"); +} + +/// A member point read before the group's path is edited is stale afterwards, as the engine moved +/// the member, even when an undo puts the member back. +#[test] +fn a_member_point_read_before_its_group_path_changes_is_stale() { + let (mut s, _) = doc_on_path(); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, g = P.getByName('drive'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = g.pathPoints[0]; q.anchor = [q.anchor[0] + 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); +} + +#[test] +fn a_point_in_a_nested_member_is_stale_after_another_path_changes_and_undoes() { + let (mut s, a, b) = doc(); + log(&mut s, "var P = app.activeDocument.pathItems; P[0].name = 'edit'; P[1].name = 'm';"); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let group = s.active().unwrap().doc.parent_of(a).unwrap(); + let drive = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + s.execute("object.objectsOnPath.attach", &json!({"path": drive.0, "ids": [group.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('edit'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); + assert_eq!(art(&s), before); +} + +#[test] +fn a_point_outside_an_inner_objects_on_path_group_is_stale_after_its_path_changes_and_undoes() { + let (mut s, a, b) = doc(); + log(&mut s, "app.activeDocument.pathItems[0].name = 'drive';"); + s.execute("object.objectsOnPath.attach", &json!({"path": a.0, "ids": [b.0]})).unwrap(); + let inner = s.active().unwrap().doc.parent_of(a).unwrap(); + let sibling = rect(&mut s, 100.0, 200.0, 50.0, 50.0); + s.execute("object.setProps", &json!({"ids": [sibling.0], "name": "m"})).unwrap(); + s.execute("select.set", &json!({"ids": [inner.0, sibling.0]})).unwrap(); + s.execute("object.group", &json!({})).unwrap(); + let group = s.active().unwrap().doc.parent_of(inner).unwrap(); + let outer_drive = rect(&mut s, 200.0, 50.0, 100.0, 100.0); + s.execute("object.objectsOnPath.attach", &json!({"path": outer_drive.0, "ids": [group.0]})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let before = art(&s); + let out = log( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('drive'), m = P.getByName('m');\ + vc.log(m.pathPoints[0].anchor);\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]];\ + vc.log(m.pathPoints[0].anchor); app.undo();", + ); + assert_ne!(out[0], out[1], "the sibling outside the inner group moved"); + assert_eq!(art(&s), before); + let e = failure( + &mut s, + "var P = app.activeDocument.pathItems, p = P.getByName('drive'), m = P.getByName('m');\ + var mp = m.pathPoints[0]; mp.anchor;\ + var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 50, q.anchor[1]]; app.undo();\ + mp.anchor;", + ); + assert!(e.contains("Stale path point"), "{e}"); + assert_eq!(art(&s), before); +} + /// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke. fn doc_with_paints() -> (Session, NodeId) { let (mut s, a, _) = doc(); diff --git a/docs/mcp.md b/docs/mcp.md index 7ed0eebae6..12696f04f0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3116,8 +3116,9 @@ through `$`: stroke options through `stroke.set`, the fill rule through `path.setFillRule`, overprint through `object.setOverprint` and the transforms through `object.move`, `object.rotate` and `object.scale`. Changes to the points of a path (`closed`, `setEntirePath`, `pathPoints` and each `PathPoint`) are written together with one - `path.setAnchors` before the script uses any other member or command, or the points of another path, and when the - script ends; a path aligned to the pixel grid, or in an object that is, is written at each change, so its points + `path.setAnchors` before the script uses any other member or command, edits the points of another path, or reads + the points of another path in the same Objects on Path group, and when the script ends; + a path aligned to the pixel grid, or in an object that is, is written at each change, so its points read as the grid snaps them. `pathPoints` (https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/) has `length`, `[i]`, `index(i)`, `add()` and @@ -3142,7 +3143,10 @@ through `$`: a point of its path (`remove()`, `removeAll()`) or replaced its points (`setEntirePath`), or before anything other than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`, `object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an - object that holds it, such as `translate()`. Every point of a path selected as a whole is a selected anchor point, + object that holds it, such as `translate()`. An exception applies when editing another path in an Objects on + Path group moves a path inside that group. Its existing `PathPoint` handles throw `Stale path point`. + Read those points again from `pathPoints`. Reading a path's points first writes any waiting point changes of + another path in the same Objects on Path group. Every point of a path selected as a whole is a selected anchor point, and the endpoints of selected segments are not; a path in a selected group or compound path is selected as a whole. Direction handles are not selected on their own, so assigning `LEFTDIRECTION`, `RIGHTDIRECTION` or `LEFTRIGHTPOINT` to `selected` throws an error that says it is not available yet, and so does assigning `NOSELECTION` to a point of a diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f2d93a4568..3d7064e18b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1120,7 +1120,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Synthetic input validates complete gestures before queue mutation: at most 256 drag steps, 16 clicks and 1,024 pending events; up to 64 control requests per frame, with later requests retained for the next frame (#1709). - The control server writes each reply through a 64 KiB buffer. On Windows 11 it sends the 17 MB `document.inspect` reply of a document with 50,000 objects on one layer to a client over loopback in 0.09 s instead of 34 s. - Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`. - - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops are not there yet. `crates/engine/src/tests/script_dom_paths.rs`. + - Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). The transforms move gradients with the art: `changeFillGradients` false throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values, and `transform` is not there yet (`docs/mcp.md` lists these limits). Gradient stops are not there yet. A `PathPoint` of a path in an Objects on Path group goes stale when an edit of another path in the group moves it. `crates/engine/src/tests/script_dom_paths.rs`. - Scripts: a document's `default*` members (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) read and set the fill, stroke and stroke options of the next object drawn through `appearance.setNewArt`, leaving the selection and its art as they were, and `scaleFactor` reads 1 (`docs/mcp.md`). `crates/engine/src/tests/script_dom_defaults.rs`. - Scripts: `app.undo()` and `app.redo()` undo and redo the edits the run made, and each document open before and after the run that it changed gets one undo step. `crates/engine/src/tests/script_dom.rs`. - Scripts: `document.textFrames` makes point type, area type and type on a path, and each text frame gives its kind, its contents, its text as text ranges with their characters, words and paragraphs (which can add text), their character attributes (size, leading, tracking, baseline shift, scales, rotation, underline, strikethrough, font) and paragraph attributes (alignment, indents, space before and after), outlines and point and area conversion; `app.textFonts` lists the fonts, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItems/, https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ and https://ai-scripting.docsforadobe.dev/jsobjref/TextFonts/ describe them (`docs/mcp.md`). Offsets count UTF-16 units, VectorCraft's own rule. Lines, tab stops and colors are not there yet. `crates/engine/src/tests/script_text.rs`. From 92a2056a8bcf7b86bc38ab5bac935e3262843e08 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:26:04 -0800 Subject: [PATCH 117/264] Scripts: page-item setters report a stale item before a bad value The name, note, hidden, locked, opacity, blendingMode, position, left, top, width and height setters checked the assigned value before the item, so a bad value on a removed item reported the value error instead of "Stale page item". Each setter now looks up its item first. --- crates/engine/src/script/dom.rs | 18 ++++++++++++------ crates/engine/src/tests/script_dom.rs | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/script/dom.rs b/crates/engine/src/script/dom.rs index facf010415..25269a62e5 100644 --- a/crates/engine/src/script/dom.rs +++ b/crates/engine/src/script/dom.rs @@ -2140,6 +2140,7 @@ fn text_arg(v: &Data, what: &str) -> std::result::Result { /// `name = value`: a number or a Boolean becomes the text `String(value)` gives. fn item_set_name(h: &Host, a: &[Data]) -> Answer { + this_item(h, a)?; let name = &text_arg(arg(a, 1), "name")?; if name.len() > MAX_TEXT_BYTES { return Err(HostError::Range("the name is too long".into())); @@ -2158,11 +2159,11 @@ fn item_note(h: &Host, a: &[Data]) -> Answer { /// `note = text`: the Attributes panel's note, set with `attributes.set`, which trims it. A number /// or a Boolean becomes the text `String(value)` gives. fn item_set_note(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; let note = &text_arg(arg(a, 1), "note")?; if note.len() > MAX_TEXT_BYTES { return Err(HostError::Range("the note is too long".into())); } - let item = this_item(h, a)?; let same = with_doc(h, item.doc, |_, st| st.doc.node(item.id).is_some_and(|n| note_of(n) == note.trim())); if !same { edit_item(h, item, "attributes.set", &json!({"ids": [item.id.0], "note": note}))?; @@ -2196,8 +2197,9 @@ fn item_hidden(h: &Host, a: &[Data]) -> Answer { } fn item_set_hidden(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; let hidden = boolean(arg(a, 1), "hidden")?; - refuse_protected_edit(h, this_item(h, a)?)?; + refuse_protected_edit(h, item)?; set_props(h, a, |n| n.visible != hidden, json!({"visible": !hidden})) } @@ -2206,8 +2208,9 @@ fn item_locked(h: &Host, a: &[Data]) -> Answer { } fn item_set_locked(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; let locked = boolean(arg(a, 1), "locked")?; - refuse_protected_edit(h, this_item(h, a)?)?; + refuse_protected_edit(h, item)?; set_props(h, a, |n| n.locked == locked, json!({"locked": locked})) } @@ -2216,6 +2219,7 @@ fn item_opacity(h: &Host, a: &[Data]) -> Answer { } fn item_set_opacity(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; let v = number(arg(a, 1), "opacity")?; if !(0.0..=100.0).contains(&v) { return Err(HostError::Range("opacity must be from 0 to 100".into())); @@ -2225,7 +2229,6 @@ fn item_set_opacity(h: &Host, a: &[Data]) -> Answer { // replaces the one the graph keeps for its series or kind. // The opacity the item already has may be assigned while its layer is hidden or locked, unless // it would still replace the opacity a graph keeps for the item's series or kind. - let item = this_item(h, a)?; let (now, keeps_other) = with_doc(h, item.doc, |_, st| { let d = &st.doc; // Only the exact number the getter reports counts as the same opacity. @@ -2271,12 +2274,12 @@ fn item_blending_mode(h: &Host, a: &[Data]) -> Answer { /// The mode the object already has may be assigned while its layer is hidden or locked, unless it /// would still replace the blend mode a graph keeps for the item's series or kind. fn item_set_blending_mode(h: &Host, a: &[Data]) -> Answer { + let item = this_item(h, a)?; let mode = match arg(a, 1) { Data::String(s) => s.strip_prefix("BlendModes.").and_then(|m| BLEND_MODES.iter().find(|(name, _)| *name == m)).map(|(_, mode)| *mode), _ => None, }; let mode = mode.ok_or_else(|| HostError::Type("blendingMode needs a BlendModes value".into()))?; - let item = this_item(h, a)?; let (same, keeps_other) = with_doc(h, item.doc, |_, st| { let d = &st.doc; let same = d.node(item.id).is_some_and(|n| n.blend == mode); @@ -2403,16 +2406,19 @@ fn move_to(h: &Host, a: &[Data], x: Option, y: Option) -> Answer { } fn item_set_position(h: &Host, a: &[Data]) -> Answer { + this_item(h, a)?; let p = point(arg(a, 1), "position")?; move_to(h, a, Some(p[0]), Some(p[1])) } fn item_set_left(h: &Host, a: &[Data]) -> Answer { + this_item(h, a)?; let x = coordinate(arg(a, 1), "left")?; move_to(h, a, Some(x), None) } fn item_set_top(h: &Host, a: &[Data]) -> Answer { + this_item(h, a)?; let y = coordinate(arg(a, 1), "top")?; move_to(h, a, None, Some(y)) } @@ -2421,12 +2427,12 @@ fn item_set_top(h: &Host, a: &[Data]) -> Answer { /// or tall, so the page-aligned bounds that `width` and `height` read have that size, rotated /// objects included. fn resize(h: &Host, a: &[Data], width: bool) -> Answer { + let item = this_item(h, a)?; let what = if width { "width" } else { "height" }; let size = number(arg(a, 1), what)?; if size <= 0.0 || size > MAX_SIZE { return Err(HostError::Range(format!("{what} must be more than 0 and at most 3999856 points"))); } - let item = this_item(h, a)?; refuse_protected_edit(h, item)?; selection_ids(h, item.doc, arg(a, 0))?; let (Some(r), _) = item_rect(h, item, false)? else { return Ok(Data::Undefined) }; diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 03cab27e93..bb333e91d8 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1702,6 +1702,29 @@ fn wrappers_go_stale_after_delete_and_undo() { assert!(e.contains("Stale page item"), "{e}"); } +/// A setter on a removed item reports the stale item before it checks the value it was given. +#[test] +fn setters_on_a_stale_item_report_it_before_a_bad_value() { + let (mut s, _, _) = doc(); + for set in [ + "name = {}", + "note = {}", + "hidden = 'x'", + "locked = 'x'", + "opacity = 500", + "blendingMode = 'x'", + "selected = 'x'", + "position = 'x'", + "left = 'x'", + "top = 'x'", + "width = -1", + "height = -1", + ] { + let e = failure(&mut s, &format!("var i = app.activeDocument.pageItems[0].duplicate(); i.remove(); i.{set};")); + assert!(e.contains("Stale page item"), "{set}: {e}"); + } +} + /// File › Revert loads objects with the ids they were saved with: an object or a layer read before /// the revert does not name the loaded one. #[test] From cddc75cf5c06e310c71473477a8b672958ccd492 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:27:30 -0800 Subject: [PATCH 118/264] Brushes: only Brush Options skips an unchanged library save The equality check that skips the undo step now sits in brush.options, which compares the edited brush with the stored one. New, Delete, Move, Duplicate and Replace Brush Art save the library as they do on main, without decoding it a second time. docs/target-app-parity.md lists the no-op rules for Brush Options and Apply Brush with their tests. --- crates/engine/src/cmd/brushsym/brushes.rs | 15 ++++++++------- docs/target-app-parity.md | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/brushsym/brushes.rs b/crates/engine/src/cmd/brushsym/brushes.rs index 18eb440f3a..eaebecf11e 100644 --- a/crates/engine/src/cmd/brushsym/brushes.rs +++ b/crates/engine/src/cmd/brushsym/brushes.rs @@ -214,12 +214,8 @@ fn rename_brush_strokes(d: &mut Document, lib: &mut [Brush], from: &str, to: Opt } } -/// Stores `lib` and applies `renames` as one undo step named `label`. A `lib` equal to the -/// document's library, with no renames, leaves the document and its undo history as they are. +/// Stores `lib` and applies `renames` as one undo step named `label`. fn save_library(s: &mut Session, label: &str, mut lib: Vec, renames: &[(String, Option)]) -> Result<()> { - if renames.is_empty() && lib == brush::library(&s.doc()?.doc) { - return Ok(()); - } s.edit(label, |d, _| { for (from, to) in renames { rename_brush_strokes(d, &mut lib, from, to.as_deref()); @@ -509,8 +505,13 @@ pub(super) fn brush_options(s: &mut Session, p: &Value) -> Result { v["name"] = json!(name); } v["type"] = json!(lib[i].kind.type_id()); - lib[i] = parse_brush(C, v)?; - let out = lib[i].name.clone(); + let edited = parse_brush(C, v)?; + let out = edited.name.clone(); + // Options that leave the brush as it is change nothing and add no undo step. + if new_name.is_none() && edited == lib[i] { + return Ok(json!({ "name": out })); + } + lib[i] = edited; let rename = new_name.map(|nn| (name, Some(nn))); save_library(s, "Brush Options", lib, rename.as_slice())?; Ok(json!({ "name": out })) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 032041c2a1..c06f4e5922 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2243,6 +2243,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Pattern Brush Options' Scale has a menu of Fixed, Pressure, Tilt, Bearing, Rotation and Stylus Wheel with a second scale beside it, in the library brush's dialog and in Options of Selected Object, from the pen tablet options the Pattern brush options section of the help page (, archived copy) lists for Scale (`brush.options` and `brush.objectOptions` `scale_mode` and `scale_max`). The tiles go from Scale where the pen reads 0 to the second scale where it reads 1, over the same ranges as Art Brush Options' Width, and half way on a stroke without that input. Each side, start and end tile is as tall as the scale at each point of the stroke, and the tile is as long as the scale at its middle; a corner tile takes the scale at its corner. Stretch to Fit stretches the tiles and gaps of each run to fill it, Add Space to Fit shares out what is left between the tiles, and Approximate Path centers them on the run. The help page does not say how the pen maps to the scale or how the tiles are measured along the stroke, so those rules are VectorCraft's own. A brush with a fixed scale draws as before. `.ai` files do not read or write the pattern scale's mode, and the Width tool does not turn the pen's data into width points. Evidence: `tests::pattern_brush_scale_follows_the_pressure`, `tests::pattern_brush_scale_follows_tilt_bearing_rotation_and_the_wheel`, `tests::pattern_brush_scale_from_the_pen_places_start_end_and_corner_tiles` (vectorcraft-brush), `tests::brushsym::options_of_selected_object_keep_each_paths_second_scale_when_the_scale_changes`, `tests::brushsym::pattern_brush_scale_mode_goes_through_the_brush_commands` (vectorcraft-engine), `dialogs::brush_options::tests::pattern_options_scale_follows_the_pen`, `dialogs::brush_options::tests::options_of_selected_object_set_one_paths_pattern_scale_mode` (vectorcraft-ui-egui). - **Airbrush stylus wheel:** Calligraphic and Scatter Brush Options offer Stylus Wheel for Size, and Art Brush Options for Width, as the help page lists it (). The Paintbrush records where an airbrush pen's finger wheel is set along each stroke (kept with the path, saved, joined when a stroke continues a path, and interpolated by blends). A Calligraphic Size goes from size − variation at one end of the wheel's travel to size + variation at the other, a Scatter Size from its first value to its second, and an Art Width from Width to the second width; a stroke without a wheel draws the value half way. The direction of travel and the half-way value for a stroke without a wheel are VectorCraft's own rules. On Linux under X11 and XWayland the app reads the wheel from XInput2's `Abs Wheel` valuator, on macOS from AppKit's `tangentialPressure`, and in the web build from Pointer Events' `tangentialPressure` (), for each move of a pen including the positions a fast stroke's events coalesce. Windows pointer messages have no field for it, so on Windows the app reads it from the tablet driver's Wintab interface, as the tangential pressure (`pkTangentPressure`) of a cursor the driver reports as an airbrush, placed within its device's `DVC_TPRESSURE` range (, ). `Wintab32.dll` is loaded from the system directory only; without it, or when a call fails, Windows pens read no wheel and draw as before. The library is loaded and the context opened only while the active tool uses the wheel (the Paintbrush with a brush on Stylus Wheel, or the Blob Brush or the Eraser with a value on it), and the context closes when it stops; this is VectorCraft's own rule. A pen first reads the wheel from an airbrush packet that came within 200 ms of one of its pointer messages, and from none when packets of two tablets' cursors both did or neither did. That pen then holds the readings: its later messages take that airbrush's last wheel, even when the pen has been held still, no packet has come for longer, or another tablet's cursor has been read since, and other pens read no wheel until the readings start afresh (the pen leaves or turns to its other end, or a cursor comes near, leaves or changes). 0 counts as no wheel until the pen has reported another value since it came near, as on macOS and in the web build; the web build reads the wheel afresh for another pen, the other end, a canceled press and a pen that left the hover range. These are VectorCraft's own rules. `path.freehand` points take it seventh and `pointer_gesture` events take `wheel`, and `.ai` brush definitions read and write it as variation code 3. Evidence: `tests::the_stylus_wheel_varies_sizes_and_widths` (vectorcraft-brush), `tests_brushsym::freehand_points_record_the_stylus_wheel` (vectorcraft-engine), `more_brush_settings_are_read_back` and `a_calligraphic_brushs_pen_channels_come_in_by_their_codes` (vectorcraft-eps), `tablet::tests::an_airbrush_wheel_goes_into_the_feed`, `mac_tablet::tests::an_airbrush_wheel_goes_into_the_feed`, `windows_stylus::tests::an_airbrush_wheel_goes_into_the_sample`, `windows_wintab::tests::a_pen_message_takes_the_wheel_of_the_recent_airbrush` and `windows_wintab::tests::the_driver_is_left_alone_until_the_wheel_is_used` (vectorcraft), `pencil::tests::an_airbrush_wheel_goes_into_the_feed`, `pencil::tests::coalesced_moves_keep_their_wheel` and `pencil::tests::the_wheel_is_read_afresh_for_each_pen_and_end` (vectorcraft-web), `symbolism::tests::the_paintbrush_reads_the_wheel_only_with_a_stylus_wheel_brush` (vectorcraft-tools) and `stylus::tests::the_host_is_told_when_the_tool_starts_and_stops_reading_the_wheel` (vectorcraft-ui-egui). - **Blob Brush Size on the stylus wheel:** Blob Brush Tool Options' Size menu offers Stylus Wheel beside Fixed and Pressure. The Blob Brush paints with the Calligraphic brush options ([help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=273)), whose Size an airbrush pen's wheel can vary ([help page](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html)), and the Eraser's Size menu offers the same wheel choice ([help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/erase-paths-using-eraser-tool.html)). With Stylus Wheel a stroke is Size − Variation wide at one end of the wheel's travel, but at least 0.1 pt, and Size + Variation at the other; a point without a wheel counts as half way, and a mouse stroke keeps the Size. A stroke whose points all lie at one place paints one dab sized from its first reading, on Pressure too. While the Blob Brush paints, the tip outline at the pointer takes the size the pen gives, on Pressure too, and keeps the Size when the menu changes to Stylus Wheel during the drag, or to Pressure during a drag that started on Fixed, as the release paints. A drag that started on Stylus Wheel records the pen pressure, so a change to Pressure follows that pressure from the start of the drag when the pen pressed less than fully anywhere. The direction of travel and the half-way value are VectorCraft's own rules. `path.blob` takes `sizeMode: "stylusWheel"` with the wheel seventh in each point. Evidence: `tests::draw2::blob_brush_size_follows_the_stylus_wheel` (vectorcraft-engine), `draw2::gesture::tests::the_blob_brush_size_follows_the_stylus_wheel` (vectorcraft-tools), `dialogs::freehand::tests::the_blob_brush_size_offers_the_stylus_wheel` (vectorcraft-ui-egui). + - **Brush edits that change nothing add no undo step:** Brush Options that leave a brush as it is, and Apply Brush of the current brush to paths whose top strokes already have it, paint, a width above 0 and no settings of their own, leave the document and its undo history as they are. Apply Brush clears the settings of the top stroke (Options of Selected Object), and clearing them is one undo step. Evidence: `tests::brushsym::brush_apply_that_changes_nothing_records_no_undo_step` and `tests::brushsym::brush_apply_clears_object_options_as_one_undo_step` (vectorcraft-engine). Scatter, Art and Pattern Brush Options have the Tips button for Colorization that the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy) describes, beside Method. It opens Colorization Tips, which shows each method's name and what it does beside a sample of the brush, as OK would make it, painted with that method on a blue stroke; Hue Shift's sample uses the dialog's Key Color. `ui.dialog.set {field: "tips", value: true}` opens it. Screen readers name the button, the popover and each sample. Hue Shift set by `brush.new` or `brush.options` without a key color takes the color the art's fills and strokes use most, as Brush Options already offers it, following the Brushes page, where the key color defaults to the color that stands out most in the art (). The page does not state how prominence is measured. Counting the fills and strokes that use each solid color, with the first one found winning a tie and black for art with no solid color, is VectorCraft's own rule. A `brush.options` edit that gives only the method keeps the brush's key color, and one that gives only an art brush's start guide keeps its end guide. Evidence: `tests_brushsym::hue_shift_without_a_key_takes_the_most_used_art_color`, `tests_brushsym::art_brush_options_keep_the_scale_fields_an_edit_leaves_out`. Bristle Brush Options and `brush.new` take a bristle brush name of at most 31 characters, as the Brushes page states for the Bristle Brush Options. The Name field stops taking characters at 31, and `brush.new` and `brush.options` refuse a longer new name with an error that names the limit. The page does not say how the limit counts characters or what happens to longer names already saved; counting characters and the number added to a taken name, keeping longer saved names, and leaving `brush.duplicate` unlimited are VectorCraft's own rules. A bristle brush that a document or a saved file already holds under a longer name keeps it, and the other brush types take a name of any length. Test: `bristle_brush_names_have_at_most_31_characters` in `tests/brushsym.rs`. Public reference: [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) (archived copy). From 8cde91c41897647adda9ee94e7c06cc4b8994371 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:54:58 -0800 Subject: [PATCH 119/264] Tests: Save options radios start in the control column The craft-libs pin on main includes craft-libs#4231, which starts a radio row's options past the form's label column. A new test checks that in the EPS and .ai save options dialogs the All and Range radios start where the artboard check box starts, and that Transparent and Opaque start where the Preview menu starts. With the craft-libs rev pinned before #4231 it fails: All starts at x 526 and the check box at x 619. --- .../ui-egui/src/dialogs/save_options/tests.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/ui-egui/src/dialogs/save_options/tests.rs b/crates/ui-egui/src/dialogs/save_options/tests.rs index 750e5b1130..666f094e60 100644 --- a/crates/ui-egui/src/dialogs/save_options/tests.rs +++ b/crates/ui-egui/src/dialogs/save_options/tests.rs @@ -568,6 +568,31 @@ fn save_options_radios_have_no_empty_caption_over_them() { } } +/// The All and Range radios start where the artboard check box above them starts, in the control column past the +/// captions, and EPS's Transparent and Opaque radios start where the Preview menu starts. +#[test] +fn save_options_radios_start_in_the_control_column() { + for (picked, check) in [("art.eps", "Use Artboards"), ("art.ai", "Save each artboard to a separate file")] { + let (mut app, _, _) = desktop(picked); + save_as(&mut app, "file.saveAs"); + let controls = labelled_controls(&mut app); + let (check, all, range) = (control(&controls, check), control(&controls, "All"), control(&controls, "Range:")); + assert!((all.left() - check.left()).abs() < 1.0, "{picked}: All at {all:?}, the check box at {check:?}"); + assert!((range.left() - check.left()).abs() < 1.0, "{picked}: Range at {range:?}, the check box at {check:?}"); + if picked == "art.eps" { + let (transparent, opaque) = (control(&controls, "Transparent"), control(&controls, "Opaque")); + let preview = controls + .iter() + .filter(|(l, r)| l.trim_end_matches(':') == "Preview" && r.bottom() <= transparent.top()) + .map(|(_, r)| *r) + .max_by(|a, b| a.bottom().total_cmp(&b.bottom())) + .expect("the Preview menu above Transparent"); + assert!((transparent.left() - preview.left()).abs() < 1.0, "Transparent at {transparent:?}, Preview at {preview:?}"); + assert!((opaque.left() - preview.left()).abs() < 1.0, "Opaque at {opaque:?}, Preview at {preview:?}"); + } + } +} + #[test] fn a_native_save_options_draft_cannot_redirect_its_path_to_another_drawing() { let (mut app, written, _) = desktop("original.vectorcraft"); From 65ebc72ec4e2fa9cb7de72ca96220ea04792689c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:22:27 -0800 Subject: [PATCH 120/264] Performance: a hover reads each plain path's effects once The culling box of every path a click or hover passes asked whether the path draws geometry effects by reading its effects twice: once on the path itself, and again in the walk of the path and what it holds, which starts at the path. The walk alone now answers, so a hover over many plain paths reads half as much. The walk also stops at the first object with an effect, for drawn art and for a clipping path's region, instead of visiting every member of a large compound path or group after the answer is known. --- crates/doc/src/hit.rs | 26 +++++++++++++---------- crates/doc/src/hit/tests.rs | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/crates/doc/src/hit.rs b/crates/doc/src/hit.rs index 121f12aaeb..18be31051f 100644 --- a/crates/doc/src/hit.rs +++ b/crates/doc/src/hit.rs @@ -2,6 +2,7 @@ use std::cell::RefCell; use std::collections::{HashMap, HashSet}; +use std::ops::ControlFlow; use std::rc::Rc; use std::sync::{Arc, OnceLock}; @@ -403,6 +404,8 @@ thread_local! { thread_local! { /// How many objects' drawn art [`drawn`] evaluated on this thread. static DRAWN_EVALUATED: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// How many times [`has_own_effects`] read an object's effects on this thread. + static OWN_EFFECTS_READ: std::cell::Cell = const { std::cell::Cell::new(0) }; } /// While a guard lives, [`drawn`] gives no art: the art it gave already has every geometry effect @@ -467,7 +470,7 @@ fn plain(mask: bool, f: impl FnOnce() -> T) -> T { /// kept alone. fn drawn(symbols: &SymbolBoxes, n: &Node) -> Option<(Rc>, Option)> { let f = DRAWN_ART.get()?; - if DRAWN_OFF.get() || !evaluates(n) || !(has_own_effects(n) || draws_effects(symbols, n)) { + if DRAWN_OFF.get() || !evaluates(n) || !draws_effects(symbols, n) { return None; } let doc = symbols.document(); @@ -508,7 +511,7 @@ fn evaluates(n: &Node) -> bool { match &n.kind { NodeKind::Path { guide, .. } => !guide, NodeKind::Compound { .. } => true, - NodeKind::Group { .. } | NodeKind::Layer { .. } => has_own_effects(n) || !n.appearance.items.is_empty(), + NodeKind::Group { .. } | NodeKind::Layer { .. } => !n.appearance.items.is_empty() || has_own_effects(n), _ => false, } } @@ -1120,23 +1123,24 @@ pub(crate) fn clip_region_inputs() -> (u64, bool) { /// Does `clip`, or anything it holds, have a visible effect of its own or on a fill or stroke? Only /// then can the registered [`ClipRegion`] find a geometry effect in it. fn has_effects(clip: &Node) -> bool { - let mut found = false; - clip.walk(&mut |n| found |= has_own_effects(n)); - found + clip.try_walk(&mut |n| if has_own_effects(n) { ControlFlow::Break(()) } else { ControlFlow::Continue(()) }).is_break() } /// Does `n`, anything it holds, or the art of a symbol an instance in it shows have a visible -/// effect? Only then can the registered [`DrawnArt`] find a geometry effect in it. +/// effect? Only then can the registered [`DrawnArt`] find a geometry effect in it. The walk starts +/// at `n`, so its own effects are read once, here, and it ends at the first object with an effect. fn draws_effects(symbols: &SymbolBoxes, n: &Node) -> bool { - let mut found = false; - n.walk(&mut |c| { - found = found || has_own_effects(c) || matches!(&c.kind, NodeKind::SymbolInstance { symbol, .. } if symbols.has_effects(symbol)); - }); - found + n.try_walk(&mut |c| { + let has = has_own_effects(c) || matches!(&c.kind, NodeKind::SymbolInstance { symbol, .. } if symbols.has_effects(symbol)); + if has { ControlFlow::Break(()) } else { ControlFlow::Continue(()) } + }) + .is_break() } /// Does `n` itself have a visible effect, of its own or on one of its own fills or strokes? fn has_own_effects(n: &Node) -> bool { + #[cfg(test)] + OWN_EFFECTS_READ.with(|c| c.set(c.get() + 1)); let visible = |e: &crate::Effect| e.visible; n.appearance.effects.iter().any(visible) || n.appearance.items.iter().any(|i| i.effects().iter().any(visible)) } diff --git a/crates/doc/src/hit/tests.rs b/crates/doc/src/hit/tests.rs index 7ac945e4ee..23ba46415c 100644 --- a/crates/doc/src/hit/tests.rs +++ b/crates/doc/src/hit/tests.rs @@ -3569,3 +3569,45 @@ fn a_shaper_groups_original_shapes_in_symbol_art_are_not_picked() { assert_eq!(symbol_part_at(&d, n, Point::new(130.0, 50.0), opt), None, "over the erased original shape"); assert_eq!(symbol_part_at(&d, n, Point::new(50.0, 50.0), opt), Some(vec![0, 1]), "over the shown face"); } + +/// A hover over empty canvas past many plain paths reads each path's effects once, and the layer's +/// once. +#[test] +fn hovers_past_plain_paths_read_each_paths_effects_once() { + set_drawn_art(shifted_art); + let mut d = Document::new(1000.0, 1000.0); + let l = d.layers[0].id; + let paths = 100; + for i in 0..paths { + let n = square(&mut d, (i % 10) as f64 * 60.0, (i / 10) as f64 * 60.0); + d.insert(Some(l), 0, n).unwrap(); + } + let reads = || OWN_EFFECTS_READ.with(std::cell::Cell::get); + let before = reads(); + assert!(hit_test(&d, Point::new(900.0, 900.0), HitOptions::default()).is_none()); + let read = reads() - before; + assert_eq!(read, paths + 1, "each path's effects and the layer's are read once"); + assert!(hit_at(&d, 25.0, 25.0, HitOptions::default()).is_some(), "a square is still hit"); +} + +/// Whether a compound clipping path, or a compound path, has a live effect is settled by the first +/// object found with one: the members after it are not read. +#[test] +fn an_effect_on_a_compound_path_is_found_without_reading_its_members() { + set_clip_region(moved_clip_region); + set_drawn_art(shifted_art); + let mut d = Document::new(1000.0, 1000.0); + let members: Vec<_> = (0..100) + .map(|i| Arc::new(Node::path(d.alloc_id(), shapes::rectangle(Rect::new(i as f64, 0.0, i as f64 + 5.0, 5.0)), Default::default()))) + .collect(); + let mut mask = Node::new(d.alloc_id(), NodeKind::Compound { children: members, rule: FillRule::NonZero }); + mask.appearance.effects.push(test_move()); + let reads = || OWN_EFFECTS_READ.with(std::cell::Cell::get); + let before = reads(); + assert!(has_effects(&mask)); + assert_eq!(reads() - before, 1, "the clipping path's own effect ends the search"); + let symbols = d.symbol_boxes(); + let before = reads(); + assert!(draws_effects(&symbols, &mask)); + assert_eq!(reads() - before, 1, "the compound path's own effect ends the search"); +} From 9f7501a8f6bf523351ef7b6232994da64ea1a31a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:24:48 -0800 Subject: [PATCH 121/264] Status bar: scrolling the view no longer lays out the zoom and artboard controls again The status bar's Zoom field, Zoom Presets menu, Rotation menu and artboard navigator were one memoized view keyed on the whole canvas view, so every frame of a wheel pan changed the key and ran all four again. The Zoom field reads only the view's zoom, and the status bar reads only the zoom of the view the field commits. - The Zoom field and Zoom Presets menu are their own memoized view, keyed on the zoom instead of the canvas view, so a pan replays them. - The Rotation menu and the artboard navigator are a second memoized view, so a zoom change runs only the zoom controls. The new test counts the runs of each view over ten pan frames and four zoom changes; before the change the pan ran the navigation controls ten times. --- crates/ui-egui/src/chrome/status_bar.rs | 130 +++++++++++++++--------- 1 file changed, 84 insertions(+), 46 deletions(-) diff --git a/crates/ui-egui/src/chrome/status_bar.rs b/crates/ui-egui/src/chrome/status_bar.rs index 1a3df7737b..b7446defb4 100644 --- a/crates/ui-egui/src/chrome/status_bar.rs +++ b/crates/ui-egui/src/chrome/status_bar.rs @@ -1,5 +1,5 @@ use super::{ROTATE_VIEW_ANGLES, Ui, VectorcraftApp, json}; -use craft::behavior::kurbo::Size; +use craft::behavior::kurbo::{Point, Size}; use craft::behavior::{CanvasView, IconId}; use craft::ui::bars::{Bar, BarKind, StatusMessage, StatusProgress}; use craft::ui::buttons::{Button, IconButton}; @@ -31,7 +31,7 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { let view = app.view(); let rotation = view.map_or(0.0, |v| v.rotation); let lang = crate::i18n::current(); - let canvas_view = app.canvas_view(); + let canvas_zoom = app.canvas_view().map(|v| v.zoom); // PLAN: assumed Artboard::rect has `width()` and `height()`. let document = st.and_then(|d| d.doc.artboards.get(cur)).map_or(Size::new(1.0, 1.0), |a| Size::new(a.rect.width(), a.rect.height())); let scaling = app.ui_scaling(); @@ -92,21 +92,10 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { }; // PLAN: assumed VectorcraftApp::canvas_view() -> Option (cv.S4) and the label msgid "Status Bar". Bar::new(tl!("Status Bar"), BarKind::Status).trailing(readouts).show(ui, |ui, _| { - let navigation = Navigation { - view: canvas_view, - document, - scaling, - print, - shown_zoom, - has_view: view.is_some(), - turned, - degrees, - cur, - revision, - artboards, - lang, - picked: Outbox::new(&mut picks), - }; + let zoom = + ZoomControls { zoom: canvas_zoom, document, scaling, print, shown_zoom, has_view: view.is_some(), lang, picked: Outbox::new(&mut picks) }; + let _ = MemoView::new("status-bar-zoom", zoom, show_zoom).show(ui); + let navigation = Navigation { has_view: view.is_some(), turned, degrees, cur, revision, artboards, lang, picked: Outbox::new(&mut picks) }; let _ = MemoView::new("status-bar-navigation", navigation, show_navigation).show(ui); Divider::vertical().show(ui); // An empty readout shows a dash. @@ -187,13 +176,12 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { } } -/// What the status bar's navigation controls read: the Zoom field, the Rotation menu and the artboard navigator. The -/// bar replays them while these hold still and nothing reaches them (`MemoView`), as most frames only move the -/// readouts. +/// What the status bar's Zoom field and Zoom Presets menu read. The bar replays them while these hold still and +/// nothing reaches them (`MemoView`). The canvas view's center is not among them, so a pan replays them. #[derive(MemoProps)] -struct Navigation<'a> { - /// The canvas view the Zoom field shows and edits. - view: Option, +struct ZoomControls<'a> { + /// The canvas view's zoom (`CanvasView::zoom`), which the Zoom field shows and edits. + zoom: Option, /// The size of the artboard the navigator shows, which the Zoom field fits. document: Size, /// UI Scaling, which divides the canvas view's zoom. @@ -202,6 +190,45 @@ struct Navigation<'a> { print: Option, /// The view's zoom percentage, which the Zoom Presets menu checks. shown_zoom: Option, + /// Whether the active document has a view to zoom. + has_view: bool, + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, + /// What the controls chose in the pass. + picked: Outbox<'a, NavigationPick>, +} + +/// The Zoom field and the Zoom Presets menu of the status bar, from [`ZoomControls`]. +fn show_zoom(p: &mut ZoomControls<'_>, ui: &mut Ui) { + #[cfg(test)] + tests::ZOOM_RUNS.with(|n| n.set(n.get() + 1)); + // The field reads only the view's zoom, and the bar reads only the zoom of the view it commits. + let view = p.zoom.map(|zoom| CanvasView::new(egui::Rect::ZERO, Point::ZERO, zoom)); + let document = p.document; + let zoom = Field::new(tl!("Zoom")) + .side(SideLabel::new().kind(LabelKind::Hidden)) + .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui)); + // The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom. + if let Some(zoom) = zoom.inner { + if let Some(view) = zoom.view.committed() { + let percent = crate::state::zoom_display_percent(crate::state::View::zoom_of_canvas(view, p.scaling), p.print); + p.picked.send(NavigationPick::Zoom(percent)); + } + if let Some(invalid) = zoom.invalid_zoom { + p.picked.send(NavigationPick::InvalidZoom(invalid.message(&Env::of(ui)))); + } + } + let presets = zoom_presets(p.shown_zoom, p.print); + let open_presets = IconButton::new(IconId::new("chevron_down")).label(tl!("Zoom Presets")).enabled(p.has_view).show(ui); + if let Some(preset) = Menu::new(tl!("Zoom Presets")).values().opened_by(open_presets.response(), Trigger::Press).pick(ui, &presets).picked { + p.picked.send(NavigationPick::Preset(preset)); + } +} + +/// What the status bar's Rotation menu and artboard navigator read. The bar replays them while these hold still and +/// nothing reaches them (`MemoView`), as most frames only move the readouts, and a pan or a zoom leaves them alone. +#[derive(MemoProps)] +struct Navigation<'a> { /// Whether the active document has a view to turn. has_view: bool, /// The Rotate View preset the view is turned to, else `usize::MAX`. @@ -234,29 +261,10 @@ enum NavigationPick { Artboard(serde_json::Value), } -/// The Zoom field, the Rotation menu and the artboard navigator of the status bar, from [`Navigation`]. +/// The Rotation menu and the artboard navigator of the status bar, from [`Navigation`]. fn show_navigation(p: &mut Navigation<'_>, ui: &mut Ui) { #[cfg(test)] tests::NAVIGATION_RUNS.with(|n| n.set(n.get() + 1)); - let (view, document) = (p.view, p.document); - let zoom = Field::new(tl!("Zoom")) - .side(SideLabel::new().kind(LabelKind::Hidden)) - .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui)); - // The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom. - if let Some(zoom) = zoom.inner { - if let Some(view) = zoom.view.committed() { - let percent = crate::state::zoom_display_percent(crate::state::View::zoom_of_canvas(view, p.scaling), p.print); - p.picked.send(NavigationPick::Zoom(percent)); - } - if let Some(invalid) = zoom.invalid_zoom { - p.picked.send(NavigationPick::InvalidZoom(invalid.message(&Env::of(ui)))); - } - } - let presets = zoom_presets(p.shown_zoom, p.print); - let open_presets = IconButton::new(IconId::new("chevron_down")).label(tl!("Zoom Presets")).enabled(p.has_view).show(ui); - if let Some(preset) = Menu::new(tl!("Zoom Presets")).values().opened_by(open_presets.response(), Trigger::Press).pick(ui, &presets).picked { - p.picked.send(NavigationPick::Preset(preset)); - } let angles: Vec> = ROTATE_VIEW_ANGLES.iter().enumerate().map(|(i, (label, _))| Entry::new(i, *label)).collect(); let (turned, angle, has_view) = (p.turned, format!("{}°", p.degrees), p.has_view); let mut rotate_to = None; @@ -388,13 +396,15 @@ mod tests { thread_local! { /// How many times this thread ran the status bar's navigation controls ([`show_navigation`]). pub(super) static NAVIGATION_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// How many times this thread ran the status bar's Zoom field and Zoom Presets menu ([`show_zoom`]). + pub(super) static ZOOM_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; } - /// Frames that change nothing the navigation controls show replay them instead of laying them out again; a new - /// zoom or a new artboard runs them once, and they show it. + /// Frames that change nothing the zoom and navigation controls show replay them instead of laying them out again; + /// a new zoom or a new artboard runs them once, and they show it. #[test] fn idle_frames_replay_the_navigation_controls() { - let runs = || NAVIGATION_RUNS.with(std::cell::Cell::get); + let runs = || ZOOM_RUNS.with(std::cell::Cell::get) + NAVIGATION_RUNS.with(std::cell::Cell::get); let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0)); @@ -423,6 +433,34 @@ mod tests { assert!(panel.enabled("Next Artboard") || panel.enabled("Previous Artboard"), "the navigator counts the new artboard"); } + /// Scrolling the view moves its center and nothing the navigation controls show, so frames of a wheel pan replay + /// them; a new zoom runs only the Zoom field and its presets, not the Rotation menu and the artboard navigator. + #[test] + fn wheel_frames_run_only_the_controls_that_show_what_changed() { + let runs = || (ZOOM_RUNS.with(std::cell::Cell::get), NAVIGATION_RUNS.with(std::cell::Cell::get)); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0)); + let mut panel = Panel::new(app, status_bar); + panel.room(egui::vec2(1200.0, 300.0)); + panel.frame(); + panel.frame(); + let before = runs(); + for i in 0..10 { + panel.app().view_mut().unwrap().center.y += if i % 2 == 0 { 40.0 } else { -25.0 }; + panel.frame(); + } + assert_eq!(runs(), before, "a pan runs neither the zoom controls nor the navigation controls"); + for i in 0..4 { + panel.app().run("view.setZoom", json!({"zoom": 150 + 25 * i})).unwrap(); + panel.frame(); + } + let after = runs(); + assert!(after.0 > before.0, "a new zoom runs the zoom controls"); + assert_eq!(after.1, before.1, "a new zoom does not run the Rotation menu and the artboard navigator"); + assert_eq!(panel.value("Zoom").as_deref(), Some("225%"), "the field shows the last zoom"); + } + #[test] fn the_zoom_presets_menu_sets_a_stop_and_fits_the_view() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); From da9c3947e250e87b0ce3138b3c8971748e56dd10 Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Sun, 29 Nov 2026 11:34:41 -0800 Subject: [PATCH 122/264] Dialogs: style options dialogs keep their tab through the framework (#10109) craft-libs 186a229c8d holds storytold/craft-libs#4261, so a properties dialog keeps its bound tab when a measuring frame ends before its body runs. The style_dialog! wrapper no longer saves and restores the tab around that frame for Character Style Options, Paragraph Style Options and New Character Style or New Paragraph Style. New tests open Character Style Options on Advanced Character Formats, New Character Style on Character Color, and Document Setup on Transparency, Type and Color, and check that each tab is still shown after the first frames. With craft-libs before that change they fail with the dialog back on General. --- .../ui-egui/src/dialogs/char_style_options.rs | 10 +----- .../src/dialogs/char_style_options/tests.rs | 32 +++++++++++++++++++ crates/ui-egui/src/dialogs/document_setup.rs | 28 ++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/char_style_options.rs b/crates/ui-egui/src/dialogs/char_style_options.rs index 3e8a78a618..584964e0c4 100644 --- a/crates/ui-egui/src/dialogs/char_style_options.rs +++ b/crates/ui-egui/src/dialogs/char_style_options.rs @@ -1126,15 +1126,7 @@ macro_rules! style_dialog { } fn show(&mut self, ui: &mut egui::Ui, stack: &craft::ui::dialog::DialogStack) -> Option> { - // A measuring run can end without running the dialog's body and then sets the first tab as the - // shown one. The dialog keeps the tab that was shown before that run. - let measuring = craft::ui::runtime::measure::active(ui.ctx()); - let tab = self.inner.tab(); - let shown = craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack); - if measuring && self.inner.tab() != tab { - let _ = craft::ui::dialog::StackDialog::set_json_field(&mut self.inner, ui.ctx(), "tab", serde_json::json!(tab)); - } - shown + craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack) } fn key(&self) -> Option<&str> { diff --git a/crates/ui-egui/src/dialogs/char_style_options/tests.rs b/crates/ui-egui/src/dialogs/char_style_options/tests.rs index 258d925608..c779f4a9f6 100644 --- a/crates/ui-egui/src/dialogs/char_style_options/tests.rs +++ b/crates/ui-egui/src/dialogs/char_style_options/tests.rs @@ -1079,6 +1079,38 @@ fn new_character_style_refuses_size_and_leading_errors_at_ok() { } } +/// Character Style Options and New Character Style opened on a tab other than General still show that tab after +/// their first frames, which measure the dialog before its body runs. +#[test] +fn a_style_dialog_opened_on_a_later_tab_keeps_it_through_its_first_frames() { + use egui::{Pos2, RawInput, Rect, vec2}; + + let mut app = app(); + app.run("charStyle.new", json!({"name": "Body", "attrs": {}})).unwrap(); + let ctx = app.ui_ctx.clone().unwrap(); + let screen = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0)); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp| { + time += 0.25; + crate::testing::app_frame(app, &ctx, RawInput { time: Some(time), screen_rect: Some(screen), ..Default::default() }); + }; + frame(&mut app); + open(&mut app, "Body"); + set::(&app, "tab", json!("advanced")); + for _ in 0..5 { + frame(&mut app); + } + assert_eq!(fields::(&app)["tab"], json!("advanced"), "Character Style Options left Advanced Character Formats"); + cancel::(&mut app); + + app.run("ui.newCharStyle", json!({})).unwrap(); + set::(&app, "tab", json!("color")); + for _ in 0..5 { + frame(&mut app); + } + assert_eq!(fields::(&app)["tab"], json!("color"), "New Character Style left Character Color"); +} + #[test] fn invalid_number_keeps_last_valid_preview() { let mut app = app(); diff --git a/crates/ui-egui/src/dialogs/document_setup.rs b/crates/ui-egui/src/dialogs/document_setup.rs index 94ff0e8339..c82a6f76d5 100644 --- a/crates/ui-egui/src/dialogs/document_setup.rs +++ b/crates/ui-egui/src/dialogs/document_setup.rs @@ -907,6 +907,34 @@ mod tests { assert!(st.history.undo.is_empty()); } + /// Document Setup opened on a tab other than General still shows that tab after its first frames, which + /// measure the dialog before its body runs. + #[test] + fn a_later_tab_picked_before_the_first_frame_stays_shown() { + for tab in ["Transparency", "Type", "Color"] { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let ctx = app.ui_ctx.clone().unwrap(); + let screen = Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 900.0)); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp| { + time += 0.25; + crate::testing::app_frame(app, &ctx, egui::RawInput { time: Some(time), screen_rect: Some(screen), ..Default::default() }); + }; + frame(&mut app); + app.run("file.documentSetup", json!({})).unwrap(); + set(&app, &ctx, "tab", json!(tab)); + for _ in 0..5 { + frame(&mut app); + } + let shown = app.dialogs().unwrap().with(|h| { + use craft::ui::dialog::StackDialog as _; + h.get_by_id::(id()).and_then(|d| d.json_fields()) + }); + assert_eq!(shown.map(|f| f["tab"].clone()), Some(json!(tab)), "Document Setup left {tab}"); + } + } + #[test] fn every_tab_draws_and_ok_is_one_undo_step() { let (mut app, ctx) = setup_open(); From 3617039ef5c2b953e2f6e028a1d4cc88c680fc22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:36:48 -0800 Subject: [PATCH 123/264] Global Edit: the canvas shares the kept outlines instead of copying them each frame With one object selected and the Selection tool active, or while Global Edit is on, every frame copied each highlighted outline out of the kept list and made one overlay per object, which the canvas flattened and stroked again. With 10,000 matching objects that was most of a 27 ms frame. highlights and similar now return the kept outlines as a shared Highlights, grouped by layer color with a revision that changes only when the outlines are found again. The session sends one Overlay::Outlines per color, and the canvas shows it as a SelectionOutline keyed by that revision, so the lines are stroked again only when the outlines or the view change. --- crates/engine/src/cmd/globaledit.rs | 65 ++++++++++++++++++++++----- crates/engine/src/tests/globaledit.rs | 42 +++++++++++++++-- crates/engine/src/tooling.rs | 9 ++-- crates/tools/src/lib.rs | 5 +++ crates/ui-egui/src/canvas/overlays.rs | 10 ++++- crates/ui-egui/src/canvas/tests.rs | 24 ++++++++++ 6 files changed, 136 insertions(+), 19 deletions(-) diff --git a/crates/engine/src/cmd/globaledit.rs b/crates/engine/src/cmd/globaledit.rs index 4f498e972a..cecf216b24 100644 --- a/crates/engine/src/cmd/globaledit.rs +++ b/crates/engine/src/cmd/globaledit.rs @@ -194,6 +194,51 @@ impl Options { /// Outlines with their layer colours ([`highlights`]). pub type Outlines = Vec<(BezPath, [u8; 3])>; +/// The outlines [`highlights`] gives the canvas, grouped by layer color. The canvas asks every frame and gets the same +/// allocation back until the outlines are found again. +#[derive(Debug, Default, PartialEq)] +pub struct Highlights { + /// A number given to each set of outlines when it is found, and never to another set: the canvas keeps the lines + /// it stroked for these outlines while the number stays the same. + pub revision: u64, + /// The outlines in each layer color, the colors in the order of their first outline. + pub groups: Vec<([u8; 3], std::sync::Arc<[BezPath]>)>, +} + +/// The [`Highlights::revision`] the next set of outlines takes. +static NEXT_HIGHLIGHTS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); + +/// [`Highlights`] with no outline, shared so the frames that show none allocate nothing. +static NO_HIGHLIGHTS: std::sync::LazyLock> = std::sync::LazyLock::new(Default::default); + +impl Highlights { + /// `outlines` grouped by color, under a new revision. + fn new(outlines: Outlines) -> std::sync::Arc { + if outlines.is_empty() { + return NO_HIGHLIGHTS.clone(); + } + let mut groups: Vec<([u8; 3], Vec)> = vec![]; + for (path, color) in outlines { + match groups.iter_mut().find(|(c, _)| *c == color) { + Some((_, paths)) => paths.push(path), + None => groups.push((color, vec![path])), + } + } + let revision = NEXT_HIGHLIGHTS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + std::sync::Arc::new(Highlights { revision, groups: groups.into_iter().map(|(c, paths)| (c, paths.into())).collect() }) + } + + /// How many outlines there are, in every color. + pub fn len(&self) -> usize { + self.groups.iter().map(|(_, paths)| paths.len()).sum() + } + + /// Whether there is no outline. + pub fn is_empty(&self) -> bool { + self.groups.iter().all(|(_, paths)| paths.is_empty()) + } +} + /// A Global Edit in progress (per document; not saved, not an undo step). #[derive(Clone, Debug, PartialEq)] pub struct GlobalEdit { @@ -202,7 +247,7 @@ pub struct GlobalEdit { /// outline onto its own. pub members: Vec<(NodeId, Affine)>, /// [`highlights`] as of a document revision: the canvas asks every frame. - outlines: std::cell::RefCell>, + outlines: std::cell::RefCell)>>, } /// An outline reduced to its form: the anchors and handles placed in a unit box, with what tells @@ -1017,31 +1062,31 @@ fn keep_series_changes(before: &Document, d: &mut Document, edited: &[NodeId]) { /// highlights them while Global Edit is on. While it is off, with one supported object selected, /// they are the outlines of the objects Start Global Edit would take with the Global Edit Options /// ([`similar`]). -pub fn highlights(s: &Session) -> Outlines { - let Some(st) = s.active() else { return vec![] }; +pub fn highlights(s: &Session) -> std::sync::Arc { + let Some(st) = s.active() else { return NO_HIGHLIGHTS.clone() }; let Some(ge) = &st.global_edit else { return similar(s) }; if let Some((rev, out)) = &*ge.outlines.borrow() && *rev == st.revision { return out.clone(); } - let out = outlines(st, &ge.members); + let out = Highlights::new(outlines(st, &ge.members)); *ge.outlines.borrow_mut() = Some((st.revision, out.clone())); out } /// [`similar`]'s outlines as of a document revision and the options they were found with. -pub type SimilarCache = std::cell::RefCell>; +pub type SimilarCache = std::cell::RefCell)>>; /// Before Global Edit starts: with one supported object selected, the outlines of the other /// objects Start Global Edit would take now with the session's Global Edit Options, so the canvas /// shows them as soon as the object is selected. None while an interaction (a drag) is in /// progress, or when fewer than two objects would be taken. Kept per document revision and /// options, as finding them walks the whole document. -pub fn similar(s: &Session) -> Outlines { - let Some(st) = s.active() else { return vec![] }; +pub fn similar(s: &Session) -> std::sync::Arc { + let Some(st) = s.active() else { return NO_HIGHLIGHTS.clone() }; if st.global_edit.is_some() || st.interaction.is_some() || st.selection.objects.len() != 1 { - return vec![]; + return NO_HIGHLIGHTS.clone(); } let o = &s.global_edit_options; if let Some((rev, opts, out)) = &*st.similar_outlines.borrow() @@ -1050,10 +1095,10 @@ pub fn similar(s: &Session) -> Outlines { { return out.clone(); } - let out = match matches(s, o) { + let out = Highlights::new(match matches(s, o) { Ok(m) if m.len() >= 2 => outlines(st, &m), _ => vec![], - }; + }); *st.similar_outlines.borrow_mut() = Some((st.revision, o.clone(), out.clone())); out } diff --git a/crates/engine/src/tests/globaledit.rs b/crates/engine/src/tests/globaledit.rs index ae56fa7c5a..076816e994 100644 --- a/crates/engine/src/tests/globaledit.rs +++ b/crates/engine/src/tests/globaledit.rs @@ -150,7 +150,7 @@ fn after_an_edit_only_the_changed_objects_are_compared_again_from_scratch() { assert_eq!(since(before), (4, 2), "the selected object and the three edited copies, two of them still similar"); assert_eq!(shown.len(), 38, "the widened copy is another shape; the moved and the enlarged ones still match"); let moved = node(&s, copies[1]).stroke_path().unwrap(); - assert!(shown.iter().any(|(p, _)| *p == moved), "the moved copy is shown where it is now"); + assert!(shown.groups.iter().flat_map(|(_, paths)| paths.iter()).any(|p| *p == moved), "the moved copy is shown where it is now"); s.execute("select.globalEditOptions", &json!({"size": true})).unwrap(); assert_eq!(highlights(&s).len(), 37, "with Size, the enlarged copy is left out"); assert_eq!(crate::cmd::globaledit::match_count(&s), 38); @@ -162,9 +162,7 @@ fn the_canvas_highlights_similar_objects_before_the_start_with_the_selection_too let [a, b, ..] = squares(&mut s); let outline = node(&s, b).stroke_path().unwrap(); let shown = |s: &mut Session| { - s.overlays(ViewInfo::default()) - .iter() - .any(|o| matches!(o, vectorcraft_tools::Overlay::Path { path, width, .. } if *path == outline && *width == 1.0)) + s.overlays(ViewInfo::default()).iter().any(|o| matches!(o, vectorcraft_tools::Overlay::Outlines { paths, .. } if paths.contains(&outline))) }; sel(&mut s, &[a]); s.select_tool("selection", ViewInfo::default()).unwrap(); @@ -175,6 +173,42 @@ fn the_canvas_highlights_similar_objects_before_the_start_with_the_selection_too assert!(shown(&mut s), "while Global Edit is on, with any tool"); } +/// Each frame hands the canvas the kept outlines, one overlay per layer color sharing them, with no copy of a path; the +/// revision changes when the outlines are found again. +#[test] +fn every_frame_shares_the_kept_outlines_instead_of_copying_each_one() { + use std::sync::Arc; + use vectorcraft_tools::Overlay; + let outlines = |s: &mut Session| -> Vec<(Arc<[vectorcraft_geom::BezPath]>, u64)> { + s.overlays(ViewInfo::default()) + .into_iter() + .filter_map(|o| if let Overlay::Outlines { paths, revision, .. } = o { Some((paths, revision)) } else { None }) + .collect() + }; + let mut s = session(); + let key = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + for i in 1..200 { + rect(&mut s, 20.0 * f64::from(i % 20), 100.0 + 20.0 * f64::from(i / 20), 10.0, 10.0); + } + sel(&mut s, &[key]); + s.select_tool("selection", ViewInfo::default()).unwrap(); + let first = outlines(&mut s); + let [(paths, revision)] = &first[..] else { panic!("one overlay for the one layer color, not one per object: {}", first.len()) }; + assert_eq!(paths.len(), 199); + let second = outlines(&mut s); + let [(again, same)] = &second[..] else { panic!("{}", second.len()) }; + assert!(Arc::ptr_eq(paths, again), "the next frame gets the same outlines, not a copy"); + assert_eq!(same, revision); + s.execute("select.globalEdit", &json!({})).unwrap(); + let on = outlines(&mut s); + let [(members, started)] = &on[..] else { panic!("{}", on.len()) }; + assert_eq!(members.len(), 199); + assert_ne!(started, revision, "outlines found again take a new revision"); + let next = outlines(&mut s); + let [(kept, still)] = &next[..] else { panic!("{}", next.len()) }; + assert!(Arc::ptr_eq(members, kept) && still == started, "and are kept from frame to frame while Global Edit is on"); +} + #[test] fn size_and_appearance_options_narrow_the_match() { let mut s = session(); diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index c5d2905963..422caab5ec 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -1478,9 +1478,12 @@ impl Session { // Global Edit: the objects edited with the selected one are highlighted; before it starts, // with the Selection tool, the objects it would take. let ge_on = self.active().is_some_and(|d| d.global_edit.is_some()); - let shown = if ge_on || self.tool.id() == "selection" { crate::cmd::globaledit::highlights(self) } else { vec![] }; - for (path, color) in shown { - v.push(Overlay::Path { path, color, width: 1.0, dashed: false }); + // One overlay per layer color, sharing the kept outlines. + if ge_on || self.tool.id() == "selection" { + let shown = crate::cmd::globaledit::highlights(self); + for (color, paths) in &shown.groups { + v.push(Overlay::Outlines { paths: paths.clone(), color: *color, revision: shown.revision }); + } } if let Some((cmd, p)) = deferred_preview { v.extend(self.deferred_preview_overlays_from_command(&cmd, &p)); diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index cfcce40bf9..7d0c17f068 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -88,6 +88,11 @@ pub enum Overlay { /// the dash pattern: the pieces of one line, each starting where the one before it ends, dash /// as the whole line does. SharedPath { path: std::sync::Arc, color: [u8; 3], width: f32, dash: Option }, + /// Thin solid outlines of many objects in one color (the objects Global Edit takes). Later calls + /// return the same `paths` with the same `revision` for as long as the outlines do not change, and + /// a new `revision` when they do. The host strokes them again only when `revision` or the view + /// changes. + Outlines { paths: std::sync::Arc<[BezPath]>, color: [u8; 3], revision: u64 }, /// A line segment (smart guide, handle line). Line { a: Point, b: Point, color: [u8; 3], dashed: bool }, /// An anchor square: filled = selected. diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index 8f9bd6f663..d1f8c469a8 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -48,7 +48,7 @@ pub(super) fn show(app: &VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSpace, }); } -/// The framework control `o` stands for, if it is one: a marquee, a settled outline or a distance. +/// The framework control `o` stands for, if it is one: a marquee, a settled outline, a set of outlines or a distance. fn show_control(ui: &mut egui::Ui, rect: ScreenRect, o: &Overlay) { match o { Overlay::Marquee(r) => { @@ -65,6 +65,11 @@ fn show_control(ui: &mut egui::Ui, rect: ScreenRect, o: &Overlay) { let outline = if dash.is_some() { SelectionOutline::dashed(Label::Empty, paths) } else { SelectionOutline::solid(Label::Empty, paths) }; outline.color(data(*color)).revision(revision).show_at(ui, rect); } + Overlay::Outlines { paths, color, revision } => { + // The overlay's revision changes whenever its paths do, so the lines are stroked again only then or when + // the view changes. + SelectionOutline::solid(Label::Empty, paths).color(data(*color)).revision(*revision).show_at(ui, rect); + } Overlay::Distance { .. } => { if let Some((measure, color)) = distance_measure(o) { SmartGuides::new(&[], std::slice::from_ref(&measure)).color(color).show_at(ui, rect); @@ -180,7 +185,7 @@ impl Component for ToolMarks<'_> { } } -/// Paints the marks of `overlays` through `draw` in `view`; the marquees, shared paths and distances are controls +/// Paints the marks of `overlays` through `draw` in `view`; the marquees, shared paths, outlines and distances are controls /// of their own and paint nothing here. // PLAN: contract cv.S14 gives `paint(draw, view, overlays, options)`; the pill, ink and ring colours come from the theme, so the style goes too. fn paint(draw: &Draw<'_>, view: &CanvasView, overlays: &[Overlay], options: &PathOptionsSettings, style: &ToolMarksStyle) { @@ -244,6 +249,7 @@ fn paint(draw: &Draw<'_>, view: &CanvasView, overlays: &[Overlay], options: &Pat Overlay::Marquee(_) | Overlay::SelectionMarquee { .. } | Overlay::SharedPath { .. } + | Overlay::Outlines { .. } | Overlay::Distance { .. } | Overlay::HoverText { .. } => {} } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index ae6956a288..a5fa556b8c 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -333,6 +333,30 @@ fn a_selection_drag_draws_its_marks_in_the_frame_the_pointer_moves() { assert!(moved >= 4, "the drag moves the object: {moved} frames"); } +/// With one rectangle selected, the canvas outlines its copies, which Start Global Edit would take, at their corners. +#[test] +fn the_canvas_outlines_the_objects_global_edit_would_take() { + let mut app = drag_app(); + let rect = |app: &mut VectorcraftApp, x: f64| { + app.session.execute("shape.rectangle", &json!({"x": x, "y": 100, "width": 40, "height": 30})).unwrap()["id"].as_u64().unwrap() + }; + let key = rect(&mut app, 20.0); + let copies = [rect(&mut app, 120.0), rect(&mut app, 220.0)]; + app.select_tool("selection"); + app.session.execute("select.set", &json!({"ids": [key]})).unwrap(); + let ctx = crate::testing::ui_context(); + frame(&mut app, &ctx, vec![]); + let xf = app.canvas_view().unwrap(); + let points = painted_points(&mut app, &ctx, vec![]); + for id in copies { + let b = app.session.active().unwrap().doc.bounds_of(&[vectorcraft_doc::NodeId(id)], false).unwrap(); + for corner in [Point::new(b.x0, b.y0), Point::new(b.x1, b.y1)] { + let at = xf.to_screen(corner); + assert!(points.iter().any(|p| p.distance(at) < 1.0), "copy {id} is outlined at {at:?}"); + } + } +} + /// A Pen drag draws the handle it pulls out in the frame the pointer moves: its end at that frame's pointer, and /// none at the pointer of the frame before. #[test] From c7487a4657285922e15b78d6b6fb608a1b427fed Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:42:07 -0800 Subject: [PATCH 124/264] Missing Fonts: the frame after an open lists a document's missing fonts once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The frame after a document opens checked whether its Missing Fonts dialog waits by building the whole dialog (opening::may_switch), and the dialog pump then built it again to open it. Each build walked the document's type and resolved every font it names: 6.5 ms over the two calls at 20,000 objects. The rows are now kept in CanvasCache::missing_fonts for the document's content version and the font database's generation, the same key Type › Find Font's cache uses, and both calls read them. An edit or a font that loads while the dialog waits makes the next call list the fonts again. The Fonts folder next to the document is still looked up when the dialog opens. Rows are dropped once their document no longer waits. text.missingFonts's answer is unchanged; its rows and its folder are now two engine functions, missing_font_rows and fonts_next_to_document. Tests count the row lists (one for the check and the open together) and check that a document edited while its dialog waits lists its new font. --- crates/engine/src/cmd/fontfiles.rs | 44 ++++++++++++------- crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/caches.rs | 13 ++++++ crates/ui-egui/src/dialogs/missing_fonts.rs | 42 +++++++++++++++--- .../src/dialogs/missing_fonts/tests.rs | 34 ++++++++++++++ crates/ui-egui/src/opening.rs | 7 ++- 6 files changed, 116 insertions(+), 25 deletions(-) diff --git a/crates/engine/src/cmd/fontfiles.rs b/crates/engine/src/cmd/fontfiles.rs index c13b256210..4cc41982df 100644 --- a/crates/engine/src/cmd/fontfiles.rs +++ b/crates/engine/src/cmd/fontfiles.rs @@ -114,7 +114,17 @@ pub fn missing_fonts(d: &Document) -> Vec { /// `text.missingFonts`'s answer for the open document `st`, where searches go by `rules` (this /// computer's when `None`). pub fn missing_fonts_of(st: &DocState, rules: Option<&findfiles::Rules>) -> Value { - let fonts: Vec = missing_fonts(&st.doc) + let fonts = missing_font_rows(&st.doc); + let mut out = json!({ "count": fonts.len(), "fonts": fonts }); + if let Some(dir) = fonts_next_to_document(st, rules) { + out["fontsNextToDocument"] = json!(dir); + } + out +} + +/// `text.missingFonts`'s `fonts` rows for `d` ([`missing_fonts`]). +pub fn missing_font_rows(d: &Document) -> Vec { + missing_fonts(d) .into_iter() .map(|m| { json!({ @@ -122,26 +132,26 @@ pub fn missing_fonts_of(st: &DocState, rules: Option<&findfiles::Rules>) -> Valu "resolved": m.resolved.map(|(family, style)| json!({ "family": family, "style": style })), }) }) - .collect(); - let mut out = json!({ "count": fonts.len(), "fonts": fonts }); + .collect() +} + +/// `text.missingFonts`'s `fontsNextToDocument` for the open document `st`, where searches go by +/// `rules` (this computer's when `None`). +pub fn fonts_next_to_document(st: &DocState, rules: Option<&findfiles::Rules>) -> Option { // File › Package puts the fonts in a `Fonts` folder next to the packaged document. The folder // is made absolute against the working folder when the document's path is relative. It is // offered when a search may start there, as far as the rules tell without listing a folder. - if let Some(dir) = st.path.as_deref().and_then(|p| Path::new(p).parent()).map(|d| d.join("Fonts")).filter(|d| d.is_dir()) { - let dir = super::fileio::absolute_path(&dir.to_string_lossy()); - let system; - let rules = match rules { - Some(rules) => rules, - None => { - system = findfiles::Rules::system(); - &system - } - }; - if std::fs::canonicalize(&dir).is_ok_and(|c| rules.refusal_unlisted(&c).is_none()) { - out["fontsNextToDocument"] = json!(dir); + let dir = st.path.as_deref().and_then(|p| Path::new(p).parent()).map(|d| d.join("Fonts")).filter(|d| d.is_dir())?; + let dir = super::fileio::absolute_path(&dir.to_string_lossy()); + let system; + let rules = match rules { + Some(rules) => rules, + None => { + system = findfiles::Rules::system(); + &system } - } - out + }; + std::fs::canonicalize(&dir).is_ok_and(|c| rules.refusal_unlisted(&c).is_none()).then_some(dir) } fn missing(s: &mut Session, _: &Value) -> Result { diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 5b7221b7c2..cae4d9f39f 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -134,6 +134,7 @@ impl VectorcraftApp { print_tiling: None, live_paint_gaps: None, find_font: None, + missing_fonts: vec![], hidden_chars: Default::default(), spelling: Default::default(), text_nodes: Default::default(), diff --git a/crates/ui-egui/src/caches.rs b/crates/ui-egui/src/caches.rs index 6679ecf591..7f0ade064e 100644 --- a/crates/ui-egui/src/caches.rs +++ b/crates/ui-egui/src/caches.rs @@ -64,6 +64,10 @@ pub struct CanvasCache { /// version of the document's content and of the available fonts: the dialog reads them every /// frame. pub find_font: Option, + /// The missing fonts of each document whose Missing Fonts dialog waits to open, for a version of + /// the document's content and of the available fonts: the frame that checks whether a dialog + /// waits and the frame's pump that opens it read the same list. + pub missing_fonts: Vec, /// The marks Type → Show Hidden Characters drew on each text object in the last frame. A frame /// that does not draw them drops them ([`canvas::show`]). pub hidden_chars: canvas::marks::HiddenChars, @@ -253,6 +257,15 @@ pub struct FindFontCache { pub missing: Option, } +/// [`CanvasCache::missing_fonts`]: a document's `text.missingFonts` rows +/// ([`vectorcraft_engine::cmd::fontfiles::missing_font_rows`]). +#[derive(Clone, Debug)] +pub struct MissingFontsCache { + /// The document and the content and fonts the rows were worked out from. + pub key: FontsKey, + pub fonts: Vec, +} + /// A document's uid, a version of its content (compared by identity) and the font database's /// generation ([`vectorcraft_text::FontDb::generation`]). The weak reference keeps the version's /// allocation, so a later version is never placed at the same address while the key is kept. diff --git a/crates/ui-egui/src/dialogs/missing_fonts.rs b/crates/ui-egui/src/dialogs/missing_fonts.rs index 96a32785e3..bd06b24e40 100644 --- a/crates/ui-egui/src/dialogs/missing_fonts.rs +++ b/crates/ui-egui/src/dialogs/missing_fonts.rs @@ -35,6 +35,7 @@ use egui::{Context, Ui}; use serde_json::{Map, Value, json}; use crate::VectorcraftApp; +use crate::caches::{FontsKey, MissingFontsCache}; use crate::file_asks::{self, Owner}; /// The dialog's key and kind: the fonts a document opened without. @@ -327,19 +328,45 @@ fn after_open_for(app: &mut VectorcraftApp, r: &Value, web: bool) { } /// Whether an opened document's Missing Fonts dialog waits for the frame's pump to open it. -pub(crate) fn waiting(app: &VectorcraftApp) -> bool { - app.ui.pending_fonts.iter().any(|&uid| dialog_for(app, uid).is_some()) +pub(crate) fn waiting(app: &mut VectorcraftApp) -> bool { + let queued = app.ui.pending_fonts.clone(); + queued.into_iter().any(|uid| missing_rows(app, uid).is_some_and(|fonts| !fonts.is_empty())) } /// The Missing Fonts dialog of the open document `uid`, when fonts it uses aren't available. -fn dialog_for(app: &VectorcraftApp, uid: u64) -> Option { +fn dialog_for(app: &mut VectorcraftApp, uid: u64) -> Option { + let fonts = missing_rows(app, uid).filter(|f| !f.is_empty())?; let st = app.session.documents().iter().find(|d| d.uid == uid)?; - let r = vectorcraft_engine::cmd::fontfiles::missing_fonts_of(st, app.session.search_rules.as_ref()); - let fonts = r["fonts"].as_array().filter(|f| !f.is_empty())?.clone(); - let next = r["fontsNextToDocument"].as_str().unwrap_or_default().to_string(); + let next = vectorcraft_engine::cmd::fontfiles::fonts_next_to_document(st, app.session.search_rules.as_ref()).unwrap_or_default(); Some(MissingFontsDialog::new(State::new(uid, fonts, next, file_asks::can(app, PickKind::Folder)))) } +#[cfg(test)] +thread_local! { + /// How many times [`missing_rows`] worked out a document's missing fonts. + static ROW_SCANS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// The `text.missingFonts` rows of the open document `uid` (`None` when it is closed), kept in +/// [`crate::CanvasCache::missing_fonts`] and worked out again only for another version of its +/// content or another font generation. +fn missing_rows(app: &mut VectorcraftApp, uid: u64) -> Option> { + let st = app.session.documents().iter().find(|d| d.uid == uid)?; + // The generation is read first: fonts loaded while the rows are worked out leave the entry + // under the older generation, so the next look works them out again. + let key = FontsKey { uid, doc: std::sync::Arc::downgrade(&st.doc), generation: vectorcraft_text::FontDb::global().generation() }; + if let Some(c) = app.canvas.missing_fonts.iter().find(|c| c.key == key) { + return Some(c.fonts.clone()); + } + #[cfg(test)] + ROW_SCANS.set(ROW_SCANS.get() + 1); + let fonts = vectorcraft_engine::cmd::fontfiles::missing_font_rows(&st.doc); + let cache = &mut app.canvas.missing_fonts; + cache.retain(|c| c.key.uid != uid); + cache.push(MissingFontsCache { key, fonts: fonts.clone() }); + Some(fonts) +} + /// Once per frame: run what the finished dialog left to do, follow a running search, stop the search /// of a dialog that is gone, and with no dialog open open the dialog of the first queued document /// that is still open and still misses fonts. @@ -360,6 +387,9 @@ pub(crate) fn open_next(app: &mut VectorcraftApp) { } break; } + // Only the documents that still wait keep their rows. + let queued = &app.ui.pending_fonts; + app.canvas.missing_fonts.retain(|c| queued.contains(&c.key.uid)); } /// Run what `answer` asks, and open the dialog again when it stays open (a search starts, a search diff --git a/crates/ui-egui/src/dialogs/missing_fonts/tests.rs b/crates/ui-egui/src/dialogs/missing_fonts/tests.rs index dad177950a..de32e2cbe6 100644 --- a/crates/ui-egui/src/dialogs/missing_fonts/tests.rs +++ b/crates/ui-egui/src/dialogs/missing_fonts/tests.rs @@ -445,6 +445,40 @@ fn reopening_an_open_document_does_not_ask_about_its_fonts_again() { assert!(!is_open::(&app)); } +/// The frame after an open checks whether a Missing Fonts dialog waits (before a file that finished +/// opening may come to the front) and then opens it: the document's missing fonts are worked out +/// once for both. +#[test] +fn the_frame_after_an_open_works_out_the_missing_fonts_once() { + let root = folder("once"); + let mut app = app_for(&root); + let doc = root.join("doc.vectorcraft"); + save_doc(&mut app, &doc, "No Such Font Family", false); + open(&mut app, &doc); + ROW_SCANS.set(0); + assert!(!crate::opening::may_switch(&mut app), "the dialog waits for the pump"); + pump(&mut app); + assert_eq!(family(&app).as_deref(), Some("No Such Font Family")); + assert_eq!(ROW_SCANS.get(), 1, "one look at the document's fonts"); + assert!(app.canvas.missing_fonts.is_empty(), "the rows go once the dialog opens"); +} + +/// A document changed while its dialog waits lists the fonts of its new content. +#[test] +fn a_document_changed_while_its_dialog_waits_lists_its_new_fonts() { + let root = folder("changed"); + let mut app = app_for(&root); + let doc = root.join("doc.vectorcraft"); + save_doc(&mut app, &doc, "Alpha Missing Family", false); + open(&mut app, &doc); + assert!(!crate::opening::may_switch(&mut app)); + app.run("text.create", json!({"x": 10, "y": 80, "text": "More", "font": "Beta Missing Family"})).unwrap(); + pump(&mut app); + let fonts = fields(&app).expect("the dialog is open")["fonts"].clone(); + let families: Vec<_> = fonts.as_array().unwrap().iter().map(|f| f["family"].as_str().unwrap_or_default()).collect(); + assert_eq!(families, ["Alpha Missing Family", "Beta Missing Family"]); +} + /// A placed document that Links › Edit Original opens asks about its fonts, as File › Open does. #[test] fn edit_original_asks_about_the_placed_documents_fonts() { diff --git a/crates/ui-egui/src/opening.rs b/crates/ui-egui/src/opening.rs index f45209ee65..5e72952fe2 100644 --- a/crates/ui-egui/src/opening.rs +++ b/crates/ui-egui/src/opening.rs @@ -147,9 +147,12 @@ fn track(app: &mut VectorcraftApp, path: &str, done: Receiver bool { +pub(crate) fn may_switch(app: &mut VectorcraftApp) -> bool { + if app.any_dialog_open() || crate::dialogs::missing_fonts::waiting(app) { + return false; + } let s = &app.session; - !(app.any_dialog_open() || crate::dialogs::missing_fonts::waiting(app) || s.in_interaction() || (s.tool_busy() && s.pointer_held())) + !(s.in_interaction() || (s.tool_busy() && s.pointer_held())) } /// Open the files that are ready (each frame). Not while a dialog is open: a document that opens From 214c88d98536c143061b8560dff02f092afa1804 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:45:44 -0800 Subject: [PATCH 125/264] Tools: the controls under the tools scroll with them, as bottom_controls says The doc comment on bottom_controls still said the tools scroll above the controls in a short rail. The Tools panel's rail now uses footer_scrolls, so the controls scroll with the tools and the rail draws the rule above them. --- crates/ui-egui/src/toolbar.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 4d58c972d7..618bace39b 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -772,8 +772,8 @@ fn quad_bounds(quad: &[Point; 4]) -> vectorcraft_geom::Rect { /// The Fill/Stroke proxy, Color/Gradient/None, the drawing modes and screen mode under the rail's /// tools: in two columns the three drawing modes show, in one only the current one, which cycles /// them. A row the rail is too narrow for goes on in the next line. The All Tools drawer's Show -/// section hides any of them. The rail's footer region draws the rule that parts them from the tools, which scroll -/// above it in a short rail. +/// section hides any of them. The rail draws the rule that parts them from the tools, and they scroll with the tools +/// in a short rail. fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { let two = footer.columns > 1; let show = app.ui.toolbar_show; From a0c1a550abe31ab26eb84f340fac73018020deea Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:46:32 -0800 Subject: [PATCH 126/264] Menus: a rebuild runs each command's check once The menu model asked whether a command can run for every row that names it, so the rows that share a command (Effect's dialogs, Window's panels, the interface languages, the font sizes) ran the same check over and over on each edit and selection change. In a document with 20 selected rectangles one rebuild asked 1,910 times about 1,191 commands; Effect's dialog check alone ran 118 times. A rebuild now keeps each command's answer and reuses it for the tree's rows, the catalog's rows and Envelope Distort's Make and Reset rows. The answer depends on the command id and the app's state, not on the row's params, so the states and reasons are unchanged. --- crates/ui-egui/src/menus/model.rs | 61 ++++++++++++++++++++++++------- crates/ui-egui/src/menus/state.rs | 22 +++++++---- 2 files changed, 61 insertions(+), 22 deletions(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index fffff70049..8a49015203 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -257,7 +257,7 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) { // The Glyphs panel menu's East Asian glyph forms read the faces that draw the selected text from the layout this keeps. crate::panels::glyphs::refresh_form_faces(app); let listed = Listed::of(app); - let mut build = Build { app, lang: crate::i18n::current(), states: CommandStates::new(), refs: Vec::new() }; + let mut build = Build { app, lang: crate::i18n::current(), states: CommandStates::new(), refs: Vec::new(), checks: Checks::default() }; let menus: Vec = menu_tree_named(app.session.prefs.font_names_in_english, &listed) .into_iter() .map(|(title, nodes)| { @@ -267,7 +267,7 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) { if translated { menu.english(title) } else { menu } }) .collect(); - let Build { mut states, refs, .. } = build; + let Build { mut states, refs, mut checks, .. } = build; // The catalog is built again only when what its rows are made from changed; edits and selection changes change // the rows' states alone. @@ -291,7 +291,7 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) { CatalogRows { inputs, defs, known, accepted } } }; - row_states(app, &rows, &mut states); + row_states(app, &rows, &mut states, &mut checks); crate::panels::panel_menu_states(app, &mut states); let bar = MenuBar::new(menus); @@ -395,10 +395,10 @@ fn build_catalog(app: &VectorcraftApp, listed: &Listed, plays: &[(String, craft: /// The state of every catalog row the tree did not set, and of the engine commands the palette lists that no row /// names. -fn row_states(app: &VectorcraftApp, rows: &CatalogRows, states: &mut CommandStates) { +fn row_states(app: &VectorcraftApp, rows: &CatalogRows, states: &mut CommandStates, checks: &mut Checks) { for d in &rows.defs { if states.get(&d.command).is_none() { - states.set(d.command.clone(), row_state(app, &d.command, &d.label)); + states.set(d.command.clone(), row_state(app, &d.command, &d.label, checks)); } } // The engine commands the palette lists and no row names (Asset Export's Remove and Rename) are dimmed there and say @@ -406,11 +406,28 @@ fn row_states(app: &VectorcraftApp, rows: &CatalogRows, states: &mut CommandStat for c in crate::palette::listed_engine_commands().filter(|c| !rows.known.contains(c.id)) { let command = CommandRef::new(c.id); if states.get(&command).is_none() { - states.set(command.clone(), row_state(app, &command, c.label)); + states.set(command.clone(), row_state(app, &command, c.label, checks)); } } } +/// What [`why_off`] answered for each command id during one rebuild. The answer depends on the id and the app's state, +/// not on the row's params, so the rows that share an id (Effect's dialogs, Window's panels, the interface languages) +/// run their command's check once. +#[derive(Default)] +struct Checks(std::collections::HashMap>>); + +impl Checks { + fn why_off(&mut self, app: &VectorcraftApp, id: &str) -> Option> { + if let Some(why) = self.0.get(id) { + return why.clone(); + } + let why = why_off(app, id); + self.0.insert(id.to_owned(), why.clone()); + why + } +} + /// `defs` without the commands a linked framework set defines (Undo, Redo, Cut, Copy, Paste and Tab's panels toggles): /// the set's definition is the command's. With them, the keys each has beyond the set's, as the set's keys and those /// (Cut, Copy and Paste's F2, F3 and F4 outside macOS). @@ -445,10 +462,9 @@ fn linked_defaults(command: &CommandRef) -> Option> { /// The state of the row `command`, named `label` in the catalog: on or dimmed with its reason, checked, and its title /// where the app shows another. -fn row_state(app: &VectorcraftApp, command: &CommandRef, label: &str) -> CommandState { +fn row_state(app: &VectorcraftApp, command: &CommandRef, label: &str, checks: &mut Checks) -> CommandState { let state_id = crate::keymap::state_id(command); - let why = why_off(app, state_id); - let (enabled, checked) = shown_state_with(app, state_id, &command.params, &why).unwrap_or((false, None)); + let (enabled, checked) = shown_state_with(app, state_id, &command.params, &mut |id| checks.why_off(app, id)).unwrap_or((false, None)); let mut state = CommandState::new().enabled(enabled); if let Some(on) = checked { state = state.checked(on); @@ -458,7 +474,7 @@ fn row_state(app: &VectorcraftApp, command: &CommandRef, label: &str) -> Command state = state.title(shown.clone()); } if !enabled { - state = state.hint(off_reason_with(app, command, &shown, why)); + state = state.hint(off_reason_with(app, command, &shown, checks.why_off(app, state_id))); } state } @@ -493,6 +509,7 @@ struct Build<'a> { states: CommandStates, /// Every command reference the tree holds, its English label, and whether it is checkable. refs: Vec<(CommandRef, String, bool)>, + checks: Checks, } impl Build<'_> { @@ -548,8 +565,8 @@ impl Build<'_> { return Some(item); } let (id, params) = (command.id.as_str(), &command.params); - let why = why_off(self.app, id); - let (enabled, checked) = shown_state_with(self.app, id, params, &why)?; + let (app, checks) = (self.app, &mut self.checks); + let (enabled, checked) = shown_state_with(app, id, params, &mut |id| checks.why_off(app, id))?; let title = self.item_title(id, params, &item.label); let mut state = CommandState::new().enabled(enabled).title(title.clone()); if let Some(on) = checked { @@ -562,8 +579,7 @@ impl Build<'_> { None } else { // The reason reads the check of the command's state id, which is `id` but for the framework's own rows. - let state_id = crate::keymap::state_id(&command); - let why = if state_id == id { why } else { why_off(self.app, state_id) }; + let why = self.checks.why_off(self.app, crate::keymap::state_id(&command)); Some(off_reason_with(self.app, &command, &title, why)) }; if let Some(tip) = tip { @@ -658,6 +674,23 @@ mod tests { assert!(app.menus.states.get(&CommandRef::new("object.group")).is_some_and(CommandState::is_enabled)); } + /// A rebuild runs the check of a command that many rows share once: Effect's dialogs, Window's panels, the + /// interface languages and Envelope Distort's Release, which decides whether Make or Reset is shown. + #[test] + fn a_rebuild_checks_a_shared_command_once() { + let (mut app, ctx) = app_with_document(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + app.run("shape.rectangle", json!({"x": 20, "y": 0, "width": 10, "height": 10})).unwrap(); + app.run("select.all", json!({})).unwrap(); + super::super::state::WHY_OFF_ASKED.with_borrow_mut(Vec::clear); + refresh(&mut app, &ctx); + let asked = super::super::state::WHY_OFF_ASKED.take(); + for id in ["effect.dialog", "window.panel", "app.language", "object.envelope.release"] { + assert_eq!(asked.iter().filter(|a| *a == id).count(), 1, "{id}"); + } + assert!(app.menus.states.get(&CommandRef::new("object.group")).is_some_and(CommandState::is_enabled), "the states follow the selection"); + } + /// A rebuild asks each dimmed row's command once whether it can run, for its state and its reason together. #[test] fn a_rebuild_checks_each_dimmed_row_once() { diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index 80fb7475ad..1d0c038f04 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -153,13 +153,14 @@ pub(super) fn hidden_when_disabled(id: &str) -> bool { /// Menu items another item stands in for right now: Envelope Distort's Reset with Warp and Reset /// with Mesh take the place of Make with Warp and Make with Mesh while an envelope is selected. -fn swapped_out(app: &VectorcraftApp, id: &str) -> bool { +/// `why_off` answers [`why_off`] for Release's id. +fn swapped_out(id: &str, why_off: &mut dyn FnMut(&str) -> Option>) -> bool { let reset = match id { "object.envelope.makeWithWarp" | "object.envelope.makeWithMesh" => false, "object.envelope.resetWithWarp" | "object.envelope.resetWithMesh" => true, _ => return false, }; - enabled(app, "object.envelope.release") != reset + why_off("object.envelope.release").is_none() != reset } /// Menu items shown only with Preferences › Type › Show East Asian Options on: Type › Composite @@ -173,16 +174,21 @@ fn east_asian_hidden(app: &VectorcraftApp, id: &str) -> bool { /// another stands in for ([`swapped_out`]) or an East Asian item with those options hidden /// ([`east_asian_hidden`]). pub fn shown_state(app: &VectorcraftApp, id: &str, p: &Value) -> Option<(bool, Option)> { - shown_state_with(app, id, p, &why_off(app, id)) + shown_state_with(app, id, p, &mut |id| why_off(app, id)) } -/// [`shown_state`] from `why`, what [`why_off`] answered for `id`: a caller that also writes the reason a dimmed row -/// gives runs the command's check once. -pub(crate) fn shown_state_with(app: &VectorcraftApp, id: &str, p: &Value, why: &Option>) -> Option<(bool, Option)> { - let en = why.is_none() +/// [`shown_state`] with `why_off` answering [`why_off`] for each command id it asks about: a caller that keeps the +/// answers runs each command's check once. +pub(crate) fn shown_state_with( + app: &VectorcraftApp, + id: &str, + p: &Value, + why_off: &mut dyn FnMut(&str) -> Option>, +) -> Option<(bool, Option)> { + let en = why_off(id).is_none() && (id != crate::addons::select::link_status::COMMAND || crate::addons::select::link_status::enabled(app, p)) && (!vectorcraft_engine::cmd::plugin::is_command_id(id) || crate::dialogs::plugin::canvas_item_enabled(app, id, p)); - if (!en && hidden_when_disabled(id)) || swapped_out(app, id) || east_asian_hidden(app, id) { + if (!en && hidden_when_disabled(id)) || swapped_out(id, why_off) || east_asian_hidden(app, id) { return None; } Some((en, checked(app, id, p))) From 152a4ac5f61eddd675019151c74ff2a45c861b5c Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 20:47:54 +0100 Subject: [PATCH 127/264] Validate release RPM installs and GUI startup on target distributions --- .github/scripts/release-rpm-smoke.py | 65 +++++++++++++++++++ .github/workflows/release-rpm-smoke.yml | 86 +++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/scripts/release-rpm-smoke.py create mode 100644 .github/workflows/release-rpm-smoke.yml diff --git a/.github/scripts/release-rpm-smoke.py b/.github/scripts/release-rpm-smoke.py new file mode 100644 index 0000000000..f82b70675a --- /dev/null +++ b/.github/scripts/release-rpm-smoke.py @@ -0,0 +1,65 @@ +"""Check a real installed release RPM and exercise the GUI control channel.""" + +import json +import os +from pathlib import Path +import socket +import subprocess +import time + +results = Path("/results") +requirements = (results / "rpm-requires.txt").read_text() +for capability in ( + "libc.so.6()(64bit)", + "libm.so.6(GLIBC_2.35)(64bit)", + "libgcc_s.so.1()(64bit)", + "libxkbcommon.so.0()(64bit)", + "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", +): + if capability not in requirements.splitlines(): + raise RuntimeError(f"Missing RPM requirement: {capability}") + +version = subprocess.check_output(["vectorcraft-cli", "--version"], text=True) +(results / "cli-version.txt").write_text(version) +# Original fixture authored for this package smoke test; no external artwork. +fixture = results / "original-smoke.svg" +fixture.write_text('' + '' + '') +env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR="/tmp/vectorcraft-runtime") +Path(env["XDG_RUNTIME_DIR"]).mkdir(mode=0o700, exist_ok=True) +with (results / "gui.log").open("w") as log: + app = subprocess.Popen([ + "vectorcraft", "--control", "32180", "--automation-read-root", str(results), + "--automation-write-root", str(results), str(fixture), + ], stdout=log, stderr=subprocess.STDOUT, env=env) + try: + deadline = time.monotonic() + 90 + while True: + if app.poll() is not None: + raise RuntimeError(f"GUI exited during startup: {app.returncode}") + try: + channel = socket.create_connection(("127.0.0.1", 32180), timeout=5) + break + except OSError: + if time.monotonic() >= deadline: + raise RuntimeError("GUI control channel did not become ready") from None + time.sleep(1) + channel.settimeout(30) + with channel, channel.makefile("rwb") as stream: + for request_id, method, params in ( + (1, "ui.inspect", {}), + ): + stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) + stream.flush() + response = json.loads(stream.readline()) + (results / f"{method}.json").write_text(json.dumps(response, indent=2)) + if response.get("id") != request_id or response.get("ok") is not True: + raise RuntimeError(f"GUI request failed: {method}") + finally: + app.terminate() + try: + app.wait(timeout=10) + except subprocess.TimeoutExpired: + app.kill() + app.wait() diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml new file mode 100644 index 0000000000..440da7429d --- /dev/null +++ b/.github/workflows/release-rpm-smoke.yml @@ -0,0 +1,86 @@ +name: Release RPM smoke + +on: + workflow_dispatch: + inputs: + run-id: + description: Release workflow run containing the RPM artifacts (empty selects latest release branch run) + type: string + default: "" + pull_request: + paths: + - .github/workflows/release-rpm-smoke.yml + - .github/scripts/release-rpm-smoke.py + +permissions: + contents: read + actions: read + +jobs: + smoke: + timeout-minutes: 25 + strategy: + fail-fast: false + matrix: + platform: + - {arch: x86_64, runner: ubuntu-24.04} + - {arch: aarch64, runner: ubuntu-24.04-arm} + distro: [fedora, rocky, opensuse] + runs-on: ${{ matrix.platform.runner }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - name: Download the release packages + env: + GH_TOKEN: ${{ github.token }} + RUN_ID: ${{ inputs.run-id }} + ARCH: ${{ matrix.platform.arch }} + run: | + if [ -z "$RUN_ID" ]; then + RUN_ID=$(gh run list --workflow release.yml --branch release --limit 1 --json databaseId --jq '.[0].databaseId') + fi + [[ "$RUN_ID" =~ ^[0-9]+$ ]] + mkdir -p packages results + gh run view "$RUN_ID" --json headSha,url > results/source.json + gh run download "$RUN_ID" --name "release-linux-$ARCH" --dir packages + sha256sum packages/*.rpm > results/rpm-sha256.txt + - name: Install and start the RPM on the target distribution + env: + DISTRO: ${{ matrix.distro }} + run: | + sudo apt-get update -qq + sudo apt-get install -y xvfb + Xvfb :99 -screen 0 1440x900x24 -ac -nolisten tcp > results/xvfb.log 2>&1 & + for attempt in {1..20}; do + [ -S /tmp/.X11-unix/X99 ] && break + sleep 1 + done + case "$DISTRO" in + fedora) image=fedora:latest ;; + rocky) image=rockylinux:10 ;; + opensuse) image=opensuse/tumbleweed:latest ;; + esac + docker pull "$image" + docker image inspect "$image" --format '{{json .RepoDigests}}' > results/container-digest.json + docker run --rm --name rpm-smoke -e DISTRO -e DISPLAY=:99 -e LIBGL_ALWAYS_SOFTWARE=1 \ + -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v "$PWD/packages:/packages:ro" \ + -v "$PWD/results:/results" -v "$PWD/.github/scripts:/checks:ro" "$image" bash -euc ' + cat /etc/os-release > /results/os-release.txt + if [ "$DISTRO" = opensuse ]; then + zypper --non-interactive refresh + zypper --non-interactive install python3 Mesa-dri Mesa-libEGL1 libX11-6 libXcursor1 libXi6 libXrandr2 libxkbcommon0 + zypper --non-interactive --no-gpg-checks install /packages/*.rpm + else + dnf -y install python3 mesa-dri-drivers mesa-libEGL libX11 libXcursor libXi libXrandr libxkbcommon + dnf -y --nogpgcheck install /packages/*.rpm + fi + rpm -qp --requires /packages/*.rpm > /results/rpm-requires.txt + python3 /checks/release-rpm-smoke.py + ' + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: always() + with: + name: rpm-smoke-${{ matrix.distro }}-${{ matrix.platform.arch }} + path: results/ + if-no-files-found: error From 4f6eb4b36dbfcffe41d8b3f290b49c7cea7de633 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:53:39 -0800 Subject: [PATCH 128/264] 3D: depth, bevel and offset fields show the document's unit Extrude & Bevel's Depth and bevel Width and Height, Revolve's Offset, the classic Extrude & Bevel and Revolve rows, and the Map Art X and Y rows showed points in a document set to millimeters, inches or another unit. Each row now goes through Param::length, so its field shows and reads the document's unit while the effect keeps points. The rows set no decimals, so a typed 10 mm is kept unrounded and Up steps by the shown unit's own step. --- crates/ui-egui/src/dialogs/revolve.rs | 10 ++- crates/ui-egui/src/dialogs/revolve/tests.rs | 65 +++++++++++++++++-- crates/ui-egui/src/dialogs/three_d_classic.rs | 48 ++++++++------ 3 files changed, 93 insertions(+), 30 deletions(-) diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index a3acab8b0b..5d2d8ee72e 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -14,7 +14,6 @@ use craft::ui::contract::{Bind, CollectionEvent, Gap, Props as _, Show as _, Sho use craft::ui::layout_components::{Row, Stack}; use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, Param, ParamKind, ParamRows}; use craft::ui::pickers::Select; -use craft::ui::runtime::env::LengthUnits; use craft::ui::runtime::env::UnitKind; use craft::ui::sections::{DialogRole, FooterButton}; use craft::ui::tabs::{Tab, TabKind, TabStrip}; @@ -194,12 +193,11 @@ impl Rows<'_> { self.range(key, label, range, 1, UnitKind::Percent) } - /// A length in points, its unit shown as [`length_unit`](super::three_d_classic::length_unit) says. + /// A length in points, shown in the general unit as [`length_units`](super::three_d_classic::length_units) says. fn length(&self, key: &str, label: &'static str, range: (f64, f64)) -> Param { - // Stored in points; a pixel is a point, as the rulers count it. - let lengths = LengthUnits::new(UnitKind::Points, crate::canvas::rulers::unit_kind(self.unit), 72.0); - let shown = super::three_d_classic::length_unit(self.unit); - self.range(key, label, range, 1, shown).length(crate::fields::bare_points(lengths, self.bare_points)) + let lengths = super::three_d_classic::length_units(self.unit, self.bare_points); + let row = Param::new(key, label, ParamKind::range(range.0, range.1, self.default_number(key), SliderScale::Linear)).resettable(); + super::three_d_classic::as_length(row, lengths) } fn flag(&self, key: &str, label: &'static str) -> Param { diff --git a/crates/ui-egui/src/dialogs/revolve/tests.rs b/crates/ui-egui/src/dialogs/revolve/tests.rs index ceb96018f7..16b99491a6 100644 --- a/crates/ui-egui/src/dialogs/revolve/tests.rs +++ b/crates/ui-egui/src/dialogs/revolve/tests.rs @@ -494,10 +494,10 @@ fn the_bevel_repeat_and_the_revolve_segments_show_no_unit() { assert_eq!(unit(EXTRUDE, "object", "taper"), Some(Some(UnitKind::Percent))); } -/// The depth, bevel and offset rows of Extrude & Bevel and Revolve, classic ones included, are lengths in points: their -/// sliders show "pt" in a points document, "px" in a pixels one, and points in a document of any other unit. +/// The depth, bevel and offset rows of Extrude & Bevel and Revolve, classic ones included, hold points and show the +/// document's unit: "pt" in a points document, "px" in a pixels one, "mm" in a millimeters one, "in" in an inches one. #[test] -fn the_3d_length_rows_show_the_unit_of_the_number_they_hold() { +fn the_3d_length_rows_show_the_document_unit() { use craft::ui::patterns::form_dialogs::DialogFields; use craft::ui::runtime::env::UnitKind; use vectorcraft_doc::Unit; @@ -510,7 +510,13 @@ fn the_3d_length_rows_show_the_unit_of_the_number_they_hold() { super::params(&data, &fields, super::Place::Dialog).into_iter().find(|p| p.key == key).map(|p| p.unit) }; let mut checked = 0; - for (general, shown) in [(Unit::Points, UnitKind::Points), (Unit::Pixels, UnitKind::Pixels), (Unit::Millimeters, UnitKind::Points)] { + let units = [ + (Unit::Points, UnitKind::Points), + (Unit::Pixels, UnitKind::Pixels), + (Unit::Millimeters, UnitKind::Millimetres), + (Unit::Inches, UnitKind::Inches), + ]; + for (general, shown) in units { for key in ["depth", "bevelWidth", "bevelHeight"] { assert_eq!(unit(general, EXTRUDE, "object", key), Some(Some(shown)), "{key} in {general:?}"); checked += 1; @@ -526,7 +532,56 @@ fn the_3d_length_rows_show_the_unit_of_the_number_they_hold() { checked += 1; } } - assert_eq!(checked, 21); + assert_eq!(checked, 28); +} + +/// In a millimeters document the 3D dialogs' depth and offset fields show the 72 pt they hold as 25.4 mm, and a +/// number typed there is read in millimeters and kept unrounded; Up steps by a millimeter step. +#[test] +fn a_3d_dialog_in_a_millimeters_document_shows_its_lengths_in_millimeters() { + use craft::ui::contract::Role; + let rows = [ + (CLASSIC_EXTRUDE, "object", "depth", "Depth"), + (CLASSIC_REVOLVE, "object", "offset", "Offset"), + (EXTRUDE, "object", "depth", "Depth"), + (REVOLVE, "rotation", "offset", "Offset"), + ]; + for (effect, page, key, name) in rows { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width":300,"height":300,"units":"Millimeters"})).unwrap(); + app.run("path.create", json!({"d": SQUARE})).unwrap(); + let mut h = opened(app, json!({"effect": effect, "item": null})); + h.set("__page", json!(page)); + h.set(key, json!(72.0)); + let field = |h: &ThreeD| { + let tree = h.fixture.tree(); + h.fixture + .by_role(Role::SPIN_BUTTON) + .into_iter() + .find(|t| tree.name_of(t.node) == Some(name)) + .unwrap_or_else(|| panic!("{effect}: no {name} field")) + }; + let shown = h.fixture.tree().value_of(field(&h).node).map(str::to_owned); + assert!(shown.as_deref().is_some_and(|s| s.contains("25.4") && s.contains("mm")), "{effect} {key}: 72 pt shows as 25.4 mm: {shown:?}"); + let target = field(&h); + h.fixture.click(&target); + // Tab commits the field and leaves the dialog open (Enter would press OK). + h.fixture.key(Key::A, Modifiers::COMMAND).type_text("10").key(Key::Tab, Modifiers::NONE); + h.settle(); + let stored = h.json(key); + assert!( + stored.as_f64().is_some_and(|points| (points - 10.0 * 72.0 / 25.4).abs() < 1e-3), + "{effect} {key}: 10 mm is kept in points: {stored:?}" + ); + // Up moves by the shown unit's own step, at least a tenth of a millimeter. + let target = field(&h); + h.fixture.click(&target); + h.fixture.key(Key::ArrowUp, Modifiers::NONE).key(Key::Tab, Modifiers::NONE); + h.settle(); + let moved = h.json(key).as_f64().zip(stored.as_f64()).map(|(after, before)| after - before); + assert!(moved.is_some_and(|by| by >= 0.1 * 72.0 / 25.4 - 1e-6), "{effect} {key}: Up moves at least 0.1 mm: {moved:?}"); + h.cancel(); + } } #[test] diff --git a/crates/ui-egui/src/dialogs/three_d_classic.rs b/crates/ui-egui/src/dialogs/three_d_classic.rs index f461b3cfe2..5c7c0f8254 100644 --- a/crates/ui-egui/src/dialogs/three_d_classic.rs +++ b/crates/ui-egui/src/dialogs/three_d_classic.rs @@ -20,7 +20,7 @@ use craft::ui::list::ThumbAspect; use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, Param, ParamKind}; use craft::ui::pickers::Select; use craft::ui::primitives::ContentPainterCx; -use craft::ui::runtime::env::{Env, UnitKind}; +use craft::ui::runtime::env::{Env, LengthUnits, UnitKind}; use craft::ui::sections::{DialogRole, FooterButton}; use craft::ui::style::DataColor; use craft::ui::text::NumberField; @@ -50,13 +50,23 @@ const MAP_SYMBOL: &str = "mapSymbol"; /// The Map Art page's rows of the shown surface's map: views of `mapArt`, never effect parameters. pub(super) const MAP_ROWS: [&str; 6] = [MAP_SYMBOL, MAP_KEYS[0], MAP_KEYS[1], MAP_KEYS[2], MAP_KEYS[3], MAP_KEYS[4]]; -/// The unit shown after a 3D length row, whose slider shows the number of points it holds: the general `unit` when -/// that counts the same number (points, or pixels at 72 per inch), and points otherwise. -pub(super) fn length_unit(unit: Unit) -> UnitKind { - match crate::canvas::rulers::unit_kind(unit) { - UnitKind::Pixels => UnitKind::Pixels, - _ => UnitKind::Points, - } +/// The lengths of a 3D length row: stored in points and shown in the general `unit` (a pixel is a point, as the rulers +/// count it), a bare number read as Numbers Without Units Are Points (`bare_points`) says. +pub(super) fn length_units(unit: Unit, bare_points: bool) -> LengthUnits { + crate::fields::bare_points(LengthUnits::new(UnitKind::Points, crate::canvas::rulers::unit_kind(unit), 72.0), bare_points) +} + +/// `row`, a range row of points with no decimals set, as a length shown in `lengths.shown`. Without set decimals the +/// field keeps the shown unit's own places and step, and the points are kept unrounded, so a value typed in +/// millimeters or inches reads back as typed. +pub(super) fn as_length(row: Param, lengths: LengthUnits) -> Param { + row.unit(lengths.shown).length(lengths) +} + +/// A length row over `range` points with the effect's default, shown as [`as_length`] says. +fn length_row(effect: &str, key: &str, label: &'static str, range: (f64, f64), lengths: LengthUnits) -> Param { + let default = vectorcraft_effects::default_params(effect).and_then(|p| p.get(key).and_then(Value::as_f64)).unwrap_or(range.0); + as_length(Param::new(key, label, ParamKind::range(range.0, range.1, default, SliderScale::Linear)).resettable(), lengths) } /// Where the rows show: the 3D and Materials panel marks its fields with `__panel`. @@ -120,15 +130,15 @@ fn map_art_button(fields: &DialogFields) -> Option { /// Extrude & Bevel (Classic)'s Object page: depth and cap, then the bevel: its shape (a custom one included), its /// height and whether it is added around the shape or carved into it. pub(crate) fn object_params(data: &Data, fields: &DialogFields, effect: &str) -> Vec { - let unit = Some(length_unit(data.unit)); + let lengths = length_units(data.unit, data.bare_points); let shaped: Vec<&str> = options_of(effect, "bevel").into_iter().map(|(value, _)| value).filter(|v| *v != "none").collect(); let mut rows = vec![ Param::section(tl!("Object")), - range_row(effect, "depth", tl!("Depth"), (0.0, 2000.0), unit, 1), + length_row(effect, "depth", tl!("Depth"), (0.0, 2000.0), lengths), cap_row(effect), Param::section(c3("Bevel")), bevel_row(data, CLASSIC_EXTRUDE, place_of(fields)), - range_row(effect, "bevelHeight", tl!("Height"), (1.0, 100.0), unit, 1).enabled_when_in("bevel", shaped.clone()), + length_row(effect, "bevelHeight", tl!("Height"), (1.0, 100.0), lengths).enabled_when_in("bevel", shaped.clone()), toggle_row(effect, "bevelInside", tl!("Bevel Inside")).enabled_when_in("bevel", shaped), ]; rows.extend(map_art_button(fields)); @@ -141,7 +151,7 @@ pub(crate) fn revolve_params(data: &Data, fields: &DialogFields, effect: &str) - Param::section(tl!("Object")), range_row(effect, "angle", tl!("Angle"), (0.0, 360.0), Some(UnitKind::Degrees), 1), cap_row(effect), - range_row(effect, "offset", tl!("Offset"), (0.0, 1000.0), Some(length_unit(data.unit)), 1), + length_row(effect, "offset", tl!("Offset"), (0.0, 1000.0), length_units(data.unit, data.bare_points)), choice_row(effect, "edge", tl!("Axis side")), ]; rows.extend(map_art_button(fields)); @@ -505,7 +515,7 @@ pub(crate) fn map_art_params(data: &Data, fields: &DialogFields, effect: &str) - let flat_row = flat.clone(); rows.push(Param::custom("__mapFlat", "", move |ui, fields, _| flat_view(ui, fields, &flat_row)).full_width()); if let Some(m) = &map { - let unit = Some(length_unit(data.unit)); + let lengths = length_units(data.unit, data.bare_points); let values = [m.x, m.y, m.scale_x, m.scale_y, m.rotation]; let labels = ["X", "Y", tl!("Horizontal Scale"), tl!("Vertical Scale"), tl!("Rotation")]; let bounds = [ @@ -515,14 +525,14 @@ pub(crate) fn map_art_params(data: &Data, fields: &DialogFields, effect: &str) - GRAPHIC_SCALE_RANGE, (-360.0, 360.0), ]; - let kinds = [unit, unit, Some(UnitKind::Percent), Some(UnitKind::Percent), Some(UnitKind::Degrees)]; + // X and Y are lengths in points; the scales are shares and the rotation an angle. + let kinds = [None, None, Some(UnitKind::Percent), Some(UnitKind::Percent), Some(UnitKind::Degrees)]; for i in 0..MAP_KEYS.len() { - let row = Param::new(MAP_KEYS[i], labels[i], ParamKind::range(bounds[i].0, bounds[i].1, values[i], SliderScale::Linear)) - .decimals(2) - .on_set(set_map_value); + let row = + Param::new(MAP_KEYS[i], labels[i], ParamKind::range(bounds[i].0, bounds[i].1, values[i], SliderScale::Linear)).on_set(set_map_value); rows.push(match kinds[i] { - Some(kind) => row.unit(kind), - None => row, + Some(kind) => row.decimals(2).unit(kind), + None => as_length(row, lengths), }); } } From 61ef079f6d8a7657b486f1a4a96b9d11c46899a1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:54:12 -0800 Subject: [PATCH 129/264] =?UTF-8?q?Menus:=20Expand=E2=80=A6=20checks=20the?= =?UTF-8?q?=20selection's=20appearance=20once=20per=20rebuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each menu rebuild walked the selection's appearance twice for Object › Expand…: once in the row's check and again for its tooltip. With 10,000 objects selected the walk costs about 6 ms each time. The row's check now returns the "Expand Appearance first" reason, and the tooltip reads it from that answer. Picking a dimmed Expand… in the command palette now adds that reason to the status line's "not available right now". A new test counts the walks per rebuild: 1 with a plain or two-fill rectangle selected (2 before), 0 with nothing selected. --- crates/ui-egui/src/menus/model.rs | 30 ++++++++++++++++++++++++++++-- crates/ui-egui/src/menus/state.rs | 25 +++++++++++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index fffff70049..e3c6f74d74 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -556,8 +556,10 @@ impl Build<'_> { state = state.checked(on); } let mut item = item; - let tip = if id == "ui.expandDialog" && vectorcraft_engine::cmd::expand::has_appearance(&self.app.session) { - Some(crate::i18n::tr(self.lang, crate::dialogs::expand::appearance_first()).to_string()) + // Expand… dimmed for appearance attributes says so in its tooltip; `why` holds what its check found. + let appearance_first = crate::dialogs::expand::appearance_first(); + let tip = if id == "ui.expandDialog" && why.as_ref().is_some_and(|w| w.as_deref() == Some(appearance_first)) { + Some(crate::i18n::tr(self.lang, appearance_first).to_string()) } else if enabled { None } else { @@ -677,4 +679,28 @@ mod tests { assert!(app.menus.states.get(&CommandRef::new(id)).is_some_and(|s| !s.is_enabled()), "{id} is still dimmed"); } } + + /// A rebuild walks the selection's appearance once for Object › Expand…, for its state and its tooltip together. + #[test] + fn a_rebuild_walks_the_appearance_once_for_expand() { + let (mut app, ctx) = app_with_document(); + let expand = CommandRef::new("ui.expandDialog"); + let tooltip = |app: &VectorcraftApp| app.menus.bar.items().into_iter().find(|it| it.command == expand).and_then(|it| it.tooltip.clone()); + let walks = |app: &mut VectorcraftApp| { + super::super::state::APPEARANCE_WALKS.set(0); + refresh(app, &ctx); + super::super::state::APPEARANCE_WALKS.get() + }; + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + assert_eq!(walks(&mut app), 1, "a plain rectangle"); + assert!(app.menus.states.get(&expand).is_some_and(CommandState::is_enabled)); + assert_eq!(tooltip(&app), None); + app.run("appearance.addFill", json!({})).unwrap(); + assert_eq!(walks(&mut app), 1, "two fills"); + assert!(app.menus.states.get(&expand).is_some_and(|s| !s.is_enabled())); + assert_eq!(tooltip(&app).as_deref(), Some(crate::dialogs::expand::appearance_first())); + app.run("select.none", json!({})).unwrap(); + assert_eq!(walks(&mut app), 0, "nothing selected"); + assert_ne!(tooltip(&app).as_deref(), Some(crate::dialogs::expand::appearance_first())); + } } diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index 80fb7475ad..ad272f6236 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -295,9 +295,30 @@ pub(crate) fn why_off(app: &VectorcraftApp, id: &str) -> Option> Err(why) => Some(Some(why)), }; } + if id == "ui.expandDialog" { + return expand_dialog_off(app); + } (!ui_enabled(app, id)).then_some(None) } +#[cfg(test)] +thread_local! { + /// How many times [`expand_dialog_off`] walked the selection's appearance on this thread. + pub(crate) static APPEARANCE_WALKS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Why Object › Expand… can't open now: dimmed with nothing selected, and with +/// [`crate::dialogs::expand::appearance_first`] for appearance attributes, which Expand Appearance expands first +/// (#3089). The selection's appearance is walked once, for the row's state and its tooltip together. +fn expand_dialog_off(app: &VectorcraftApp) -> Option> { + if !app.session.active().is_some_and(|d| !d.selection.is_empty()) { + return Some(None); + } + #[cfg(test)] + APPEARANCE_WALKS.set(APPEARANCE_WALKS.get() + 1); + vectorcraft_engine::cmd::expand::has_appearance(&app.session).then(|| Some(crate::dialogs::expand::appearance_first().to_string())) +} + /// Can UI command `id` run now? fn ui_enabled(app: &VectorcraftApp, id: &str) -> bool { match id { @@ -388,10 +409,6 @@ fn ui_enabled(app: &VectorcraftApp, id: &str) -> bool { id if id.starts_with(crate::panels::symbols::USER_SLOT) => crate::panels::symbols::user_library(app, id).is_some(), "ui.saveBrushLibrary" => crate::panels::brushes::has_brushes(app), id if id.starts_with(crate::panels::brushes::USER_SLOT) => crate::panels::brushes::user_library(app, id).is_some(), - // Dimmed for appearance attributes, which Expand Appearance expands first (#3089). - "ui.expandDialog" => { - app.session.active().is_some_and(|d| !d.selection.is_empty()) && !vectorcraft_engine::cmd::expand::has_appearance(&app.session) - } "ui.spotColors" => app.session.active().is_some(), "ui.menuDialog" => app.session.active().is_some_and(|d| !d.selection.is_empty()), "ui.simplifyAuto" | "ui.simplifyMoreOptions" => crate::dialogs::simplify_slider::showing(app), From 1dc94103dafb7722e41f85dc9e2ca66fa62688df Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 20:55:27 +0100 Subject: [PATCH 130/264] Check virtual display readiness and share its IPC namespace --- .github/workflows/release-rpm-smoke.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml index 440da7429d..3486333a2b 100644 --- a/.github/workflows/release-rpm-smoke.yml +++ b/.github/workflows/release-rpm-smoke.yml @@ -56,6 +56,7 @@ jobs: [ -S /tmp/.X11-unix/X99 ] && break sleep 1 done + [ -S /tmp/.X11-unix/X99 ] case "$DISTRO" in fedora) image=fedora:latest ;; rocky) image=rockylinux:10 ;; @@ -63,7 +64,7 @@ jobs: esac docker pull "$image" docker image inspect "$image" --format '{{json .RepoDigests}}' > results/container-digest.json - docker run --rm --name rpm-smoke -e DISTRO -e DISPLAY=:99 -e LIBGL_ALWAYS_SOFTWARE=1 \ + docker run --rm --ipc=host --name rpm-smoke -e DISTRO -e DISPLAY=:99 -e LIBGL_ALWAYS_SOFTWARE=1 \ -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v "$PWD/packages:/packages:ro" \ -v "$PWD/results:/results" -v "$PWD/.github/scripts:/checks:ro" "$image" bash -euc ' cat /etc/os-release > /results/os-release.txt From c3c8a0a17a78966a8417c711b25aa596308c9eb7 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:28:17 +0100 Subject: [PATCH 131/264] Pin Binaryen 133 for the web release optimizer --- apps/vectorcraft-web/Trunk.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/vectorcraft-web/Trunk.toml b/apps/vectorcraft-web/Trunk.toml index aad9a1638f..1bb9ef3f24 100644 --- a/apps/vectorcraft-web/Trunk.toml +++ b/apps/vectorcraft-web/Trunk.toml @@ -5,6 +5,10 @@ dist = "../../dist/web" public_url = "./" filehash = true +[tools] +# Binaryen 123 crashes while optimizing the release bundle; keep the optimizer explicit. +wasm_opt = "version_133" + [serve] addresses = ["127.0.0.1"] port = 8766 From 7a09189a8811afcf751d54d9c009c09c29b6063a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 12:32:19 -0800 Subject: [PATCH 132/264] Menus: panel menu states skip three selection walks on each rebuild The menus rebuild every panel menu's states on each edit and selection change. With 10,000 objects selected, three of those menus walked the whole selection for values they did not use or had already read: - Make Opacity Mask's check sorted the selection into paint order for its outermost objects before testing whether the selection has one subject root, and it is enabled without that sort for any other count. The check now sorts only for one root and no target. - The Transparency menu built the panel's full values (opacity, blend mode, isolation and knockout compared across the selection) to read its first target. It now reads that target alone (`Session::transparency_target`), and checks Make Opacity Mask only when that object has no mask, the only case whose rows show it. - The Color and Color Wheel menus asked the session whether the fill and stroke differ, once in the Color menu and twice in the Color Wheel menu. They now read the proxies' per-revision cache, which the Tools panel's proxies fill on the same revision. On a test document of 10,000 rectangles, all selected, one pass over the panel menus' states took 24 to 31 ms before and 16.5 to 17 ms after (release build, four passes each). --- crates/engine/src/cmd/opacitymask.rs | 45 +++++++++++++++++++-- crates/ui-egui/src/menus.rs | 2 + crates/ui-egui/src/panels.rs | 49 ++++++++++++++++++++++- crates/ui-egui/src/panels/color.rs | 13 +++--- crates/ui-egui/src/panels/color_wheel.rs | 5 ++- crates/ui-egui/src/panels/transparency.rs | 32 +++++++++++++-- 6 files changed, 130 insertions(+), 16 deletions(-) diff --git a/crates/engine/src/cmd/opacitymask.rs b/crates/engine/src/cmd/opacitymask.rs index a64d038d8f..bc07e7ccb5 100644 --- a/crates/engine/src/cmd/opacitymask.rs +++ b/crates/engine/src/cmd/opacitymask.rs @@ -185,14 +185,27 @@ fn can_change_mask(s: &Session) -> std::result::Result<(), String> { /// most one outermost object, which it masks with `ids` (a call's `ids` stand in for the selection /// here). A targeted layer is one subject root however many objects it selects. `make` itself /// refuses any single target in those modes, a layer included, so a selection with a target counts -/// as one object. +/// as one object. The check sorts the selection into paint order for its outermost objects only when it has one +/// subject root and no target. fn can_make(s: &Session) -> std::result::Result<(), String> { has_doc(s)?; let Some(st) = s.active() else { return Ok(()) }; let roots = super::appearance::subject_roots(s).map_or(0, |r| r.len()); - let outermost = super::edit::outermost(&st.doc, st.selection.in_paint_order(&st.doc)).len(); - let targeted = st.selection.target.is_some(); - if roots == 1 && (outermost <= 1 || targeted) { super::maskedit::can_edit_mask(s) } else { Ok(()) } + if roots != 1 { + return Ok(()); + } + let one = st.selection.target.is_some() || { + #[cfg(test)] + OUTERMOST_FOUND.set(OUTERMOST_FOUND.get() + 1); + super::edit::outermost(&st.doc, st.selection.in_paint_order(&st.doc)).len() <= 1 + }; + if one { super::maskedit::can_edit_mask(s) } else { Ok(()) } +} + +#[cfg(test)] +thread_local! { + /// How many times [`can_make`] found the selection's outermost objects on this thread. + static OUTERMOST_FOUND: std::cell::Cell = const { std::cell::Cell::new(0) }; } fn make(s: &mut Session, p: &Value) -> Result { @@ -485,6 +498,12 @@ impl Session { _ => TransparencyInfo::default(), } } + + /// The first of the objects the Transparency panel shows ([`TransparencyInfo::ids`]), without comparing their + /// values. + pub fn transparency_target(&self) -> Option { + transparency_targets(self, &Value::Null).ok()?.first().copied() + } } fn info(s: &mut Session, p: &Value) -> Result { @@ -759,4 +778,22 @@ mod tests { let back = vectorcraft_format::load(&bytes).unwrap(); assert_eq!(back.node(NodeId(a)).unwrap().extras().mask, d.node(NodeId(a)).unwrap().extras().mask); } + + /// Make Opacity Mask's check sorts the selection for its outermost objects only when the selection has one + /// subject root; with several roots it is enabled without that sort. + #[test] + fn the_make_check_sorts_only_a_selection_with_one_root() { + let (mut s, a, b) = session_with_two(); + let found = || OUTERMOST_FOUND.get(); + select(&mut s, &[a, b]); + let before = found(); + assert_eq!(can_make(&s), Ok(())); + assert_eq!(found(), before, "two roots: no paint-order sort"); + select(&mut s, &[a]); + assert_eq!(can_make(&s), Ok(())); + assert_eq!(found(), before + 1, "one root: the outermost objects are found"); + s.execute("select.none", &json!({})).unwrap(); + assert_eq!(can_make(&s), Ok(())); + assert_eq!(found(), before + 1, "no roots: no sort"); + } } diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index d017a1a181..568b9a36d3 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -92,6 +92,8 @@ pub use run::{check_params, run_ui_command}; pub(crate) use run::{normalize_panel, opt_bool, opt_index, opt_number}; #[cfg(test)] use slots::RECENT_FONT_IDS; +#[cfg(test)] +pub(crate) use state::WHY_OFF_ASKED; pub use state::{checked, enabled, plugin_revision, shortcut_of, shown_state}; pub(crate) use state::{command_shortcuts, shown_state_with, why_off}; pub(crate) use submenus::PATH_EFFECTS; diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 2ebca9a8bc..2d1ea7cfb9 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -681,13 +681,35 @@ pub(crate) fn mixed_paints(app: &VectorcraftApp, ctx: &egui::Context) -> (bool, match pstate::>(ctx, "proxy-mixed") { Some((k, mixed)) if k == key => mixed, _ => { - let mixed = app.session.proxy_mixed(); + let mixed = walk_mixed_paints(app); set_pstate(ctx, "proxy-mixed", Some((key, mixed))); mixed } } } +/// [`mixed_paints`] for readers without a `Ui`, such as the panel menus' states: from the same cache while the app +/// has its interface context, else from a walk of the selection. +pub(crate) fn mixed_paints_now(app: &VectorcraftApp) -> (bool, bool) { + match &app.ui_ctx { + Some(ctx) => mixed_paints(app, ctx), + None => walk_mixed_paints(app), + } +} + +/// [`vectorcraft_engine::Session::proxy_mixed`], which walks the selection. +fn walk_mixed_paints(app: &VectorcraftApp) -> (bool, bool) { + #[cfg(test)] + MIXED_PAINT_WALKS.set(MIXED_PAINT_WALKS.get() + 1); + app.session.proxy_mixed() +} + +#[cfg(test)] +thread_local! { + /// How many times [`walk_mixed_paints`] walked the selection on this thread. + pub(crate) static MIXED_PAINT_WALKS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + /// The stroke the Stroke panel, Control bar and Properties show: while the Type tool edits text, /// the selected characters' stroke, else [`vectorcraft_engine::Session::shown_stroke`]. pub(crate) fn current_stroke(app: &VectorcraftApp) -> Option { @@ -1108,6 +1130,31 @@ pub(crate) fn popover_body(ui: &mut Ui, mut body: impl FnMut(&mut Ui) -> R) - mod tests { use super::*; + /// The panel menus' states (the Color and Color Wheel menus) read whether the fill and stroke differ from the + /// proxies' cache: one walk of the selection for each revision, which the proxies read too. + #[test] + fn panel_menu_states_walk_the_mixed_paints_once_per_revision() { + let mut app = crate::VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let ctx = crate::testing::ui_context(); + app.adopt_context(&ctx); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + for x in [10, 60, 110] { + app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 40, "height": 40})).unwrap(); + } + app.run("select.all", json!({})).unwrap(); + let walks = || MIXED_PAINT_WALKS.get(); + let start = walks(); + let mut states = CommandStates::new(); + panel_menu_states(&app, &mut states); + assert_eq!(walks(), start + 1, "the menus walk the selection once"); + panel_menu_states(&app, &mut states); + assert_eq!(mixed_paints(&app, &ctx), (false, false)); + assert_eq!(walks(), start + 1, "the same revision is not walked again, by the menus or the proxies"); + app.run("paint.setFill", json!({"color": "#ff0000"})).unwrap(); + panel_menu_states(&app, &mut states); + assert_eq!(walks(), start + 2, "an edit is walked again"); + } + #[test] fn proxy_events_run_their_commands() { let ran = |activated, double, swap, defaults| -> Vec<(&'static str, Value)> { proxy_commands(activated, double, swap, defaults) }; diff --git a/crates/ui-egui/src/panels/color.rs b/crates/ui-egui/src/panels/color.rs index 6208c22cb3..ba0c6cf7a3 100644 --- a/crates/ui-egui/src/panels/color.rs +++ b/crates/ui-egui/src/panels/color.rs @@ -314,14 +314,14 @@ fn target(app: &VectorcraftApp, ui: &Ui) -> Target { target_with(app, super::active_mixed(app, ui.ctx())) } -/// Whether the active proxy is "?", read from the session (the panel reads its per-frame cache). +/// Whether the active proxy is "?", from the proxies' cache ([`super::mixed_paints_now`]). fn mixed_now(app: &VectorcraftApp) -> bool { - let (fill, stroke) = app.session.proxy_mixed(); + let (fill, stroke) = super::mixed_paints_now(app); if app.session.fill_active { fill } else { stroke } } /// [`target`] with `mixed` for a "?" active proxy: the panel reads it from its per-frame cache, -/// `ui.colorPanel` from the session. +/// `ui.colorPanel` and the panel menus through [`mixed_now`]. fn target_with(app: &VectorcraftApp, mixed: bool) -> Target { if mixed { return Target::Paint(None, None); @@ -440,7 +440,7 @@ pub(crate) fn apply_output(app: &mut VectorcraftApp, out: &ColorPanelOutput) { apply_with(app, &tgt, out); } -/// [`target`] with the session's "?" state, for callers without the panel's pass. +/// [`target`] with the "?" state of [`mixed_now`], for callers without the panel's pass. pub(crate) fn target_now(app: &VectorcraftApp) -> Target { target_with(app, mixed_now(app)) } @@ -616,8 +616,9 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// The checks, titles and enabled states of [`menu_rows`]: the mode the panel shows is checked, and /// the rows that need a colour are off without one. pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { - let tgt = target_now(app); - let has_color = tgt.color().is_some() || mixed_now(app); + let mixed = mixed_now(app); + let tgt = target_with(app, mixed); + let has_color = tgt.color().is_some() || mixed; for (command, state) in ColorPanelMenu::states(LAYOUT, &app.ui.color_panel, &shown(app, &tgt), has_color) { let state = if command == ColorPanelCommand::NewSwatch && !crate::menus::enabled(app, "swatch.new") { state.enabled(false) } else { state }; states.set(command, state); diff --git a/crates/ui-egui/src/panels/color_wheel.rs b/crates/ui-egui/src/panels/color_wheel.rs index 3e706b06c1..c0389af045 100644 --- a/crates/ui-egui/src/panels/color_wheel.rs +++ b/crates/ui-egui/src/panels/color_wheel.rs @@ -618,14 +618,15 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec { /// without a solid color, and CSS oklch() also while the active document's RGB space is not sRGB. pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let srgb = cms::active().rgb_is_srgb(); - for item in items(&app.ui.color_wheel, srgb, target_now(app).color()) { + let color = target_now(app).color(); + for item in items(&app.ui.color_wheel, srgb, color) { let mut state = CommandState::new().title(item.label).enabled(item.enabled).checked(item.checked); if let Some(hint) = item.hint { state = state.hint(hint); } states.set(CommandRef::new(row_id(&item.id)), state); } - let has_color = target_now(app).color().is_some(); + let has_color = color.is_some(); for (notation, label) in copy_notations() { let oklch = notation == "oklch"; let mut state = CommandState::new().title(label.to_string()).enabled(has_color && (srgb || !oklch)); diff --git a/crates/ui-egui/src/panels/transparency.rs b/crates/ui-egui/src/panels/transparency.rs index 193837507e..8b814eac71 100644 --- a/crates/ui-egui/src/panels/transparency.rs +++ b/crates/ui-egui/src/panels/transparency.rs @@ -380,11 +380,13 @@ fn mask_items(mask: Option<&OpacityMask>, can_make: bool) -> [(&'static str, &'s } /// The masked object's mask, also while editing it (the selection then is the mask art), whether the -/// object controls apply, and whether Make is possible. +/// object controls apply, and whether Make is possible. Make's check runs only for an object without a mask, the one +/// case whose rows read it ([`mask_items`]). fn menu_context(app: &VectorcraftApp) -> (Option>, bool, bool) { let editing = app.session.active().is_some_and(|d| d.doc.mask_edit.is_some()); - let n = first_node(app, &app.session.transparency_info()); - let can_make = n.is_some() && !editing && crate::menus::enabled(app, "transparency.makeOpacityMask"); + let n = app.session.transparency_target().and_then(|id| super::layers::node_arc(&app.session.active()?.doc, id)); + let unmasked = n.as_ref().is_some_and(|n| n.extras().mask.is_none()); + let can_make = unmasked && !editing && crate::menus::enabled(app, "transparency.makeOpacityMask"); (n, object_controls(app, editing), can_make) } @@ -452,6 +454,30 @@ mod tests { app } + /// The menu's states check Make Opacity Mask only for a first object without a mask: a masked one shows Release, + /// Disable and Unlink instead, and Make dimmed without its check. + #[test] + fn the_menu_checks_make_only_for_an_object_without_a_mask() { + let mut app = new_app(); + let rectangle = |app: &mut VectorcraftApp, x| run_cmd(app, "shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})); + let masked = rectangle(&mut app, 10)["id"].clone(); + let art = rectangle(&mut app, 12)["id"].clone(); + let plain = rectangle(&mut app, 50)["id"].clone(); + run_cmd(&mut app, "transparency.makeOpacityMask", json!({"ids": [masked, art]})); + // How many times the states asked for Make's check, and whether Make is enabled. + let asked = |app: &VectorcraftApp| { + let mut states = CommandStates::new(); + crate::menus::WHY_OFF_ASKED.with_borrow_mut(Vec::clear); + menu_states(app, &mut states); + let make = crate::menus::WHY_OFF_ASKED.take().iter().filter(|a| *a == "transparency.makeOpacityMask").count(); + (make, states.get(&CommandRef::new("transparency.makeOpacityMask")).is_some_and(CommandState::is_enabled)) + }; + run_cmd(&mut app, "select.set", json!({"ids": [masked]})); + assert_eq!(asked(&app), (0, false), "a masked object: Make is dimmed without its check"); + run_cmd(&mut app, "select.set", json!({"ids": [plain]})); + assert_eq!(asked(&app), (1, true), "an object without a mask: Make's check runs once"); + } + #[test] fn transparency_shows_each_selected_symbol_parts_values() { let mut app = new_app(); From 8cd15651fbee9394615927fca81296c805f3485c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 12:33:55 -0800 Subject: [PATCH 133/264] Canvas: a touchpad pinch zooms on native Wayland Fixes #5981. The winit patch rev moves from a517b384 to 0dfcec0e (storytold/winit craft/0.30.13, with storytold/winit#20), whose Wayland backend binds zwp_pointer_gestures_v1 and reports a touchpad pinch and rotation as PinchGesture and RotationGesture. egui-winit turns them into Event::Zoom and Event::Rotate, which the canvas already reads, so a pinch zooms about the pointer and a two-finger turn rotates the view. Before, winit's Wayland backend never bound the protocol, so the gesture never reached the app. X11 and XWayland still report no pinch. The same winit range types an Alt + keypad code's character itself on Windows (W36: the WM_CHAR after Alt's release becomes a key press with that text). windows_alt_codes typed it too, which would type it twice, so it now only takes the keypad digits typed with Alt out of the frame. Docs: docs/hardware-parity.md (Trackpad row, Linux), docs/type-parity.md (Alt + numeric-keypad codes row). --- Cargo.lock | 2 +- Cargo.toml | 2 +- apps/vectorcraft/src/app.rs | 2 +- apps/vectorcraft/src/main.rs | 4 +- apps/vectorcraft/src/windows_alt_codes.rs | 175 ++++++++-------------- docs/hardware-parity.md | 2 +- docs/type-parity.md | 2 +- 7 files changed, 69 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7b77b1065..dbfa5d703c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10067,7 +10067,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=a517b3846ee8457d84ee4975110bfda6797c44dc#a517b3846ee8457d84ee4975110bfda6797c44dc" +source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" dependencies = [ "ahash", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index 41bca3bd33..5bd5b732b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -217,4 +217,4 @@ egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } +winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft/src/app.rs b/apps/vectorcraft/src/app.rs index b91282e7da..d998e23a0d 100644 --- a/apps/vectorcraft/src/app.rs +++ b/apps/vectorcraft/src/app.rs @@ -44,7 +44,7 @@ impl eframe::App for App { if let Some(window_frame) = self.window_frame.as_mut() { window_frame(); } - // The characters Alt + keypad codes typed (#5108). + // The keypad digits of Alt + keypad codes leave the frame (#5108). #[cfg(windows)] super::windows_alt_codes::raw_input_hook(raw); // Symbol-font characters a keyboard tool typed (NHM Writer legacy Tamil). diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 5a7d3e33ba..007a9a3bdb 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -695,14 +695,14 @@ fn main() -> std::process::ExitCode { // With Windows Ink, winit reports a pen as a touch and drops its barrel button and which end // is down; the message hook notes each pointer contact and whether it starts with the barrel // button held, and writes the pen's end into the pen feed (`windows_stylus`). It also notes the - // characters Alt + keypad codes type (`windows_alt_codes`). + // keypad digits of Alt + keypad codes (`windows_alt_codes`). #[cfg(windows)] let options = { use winit::platform::windows::EventLoopBuilderExtWindows as _; let mut options = options; options.event_loop_builder = Some(Box::new(|builder| { builder.with_msg_hook(|msg| { - // Alt + keypad codes (#5108), which winit drops; neither hook consumes a message. + // Alt + keypad codes (#5108); neither hook consumes a message. windows_alt_codes::msg_hook(msg); windows_stylus::msg_hook(msg) }); diff --git a/apps/vectorcraft/src/windows_alt_codes.rs b/apps/vectorcraft/src/windows_alt_codes.rs index 0abf65ddc9..c358a65653 100644 --- a/apps/vectorcraft/src/windows_alt_codes.rs +++ b/apps/vectorcraft/src/windows_alt_codes.rs @@ -4,14 +4,12 @@ //! Windows does the work: when Alt comes up after keypad digits, `TranslateMessage` posts a //! `WM_CHAR` holding the character the code stands for (in the system's ANSI code page for a code //! with a leading 0, else its OEM code page), the convention every Windows text field follows -//! (). winit -//! 0.30 reads a `WM_CHAR` only as part of the key press before it, so it drops this one, which -//! follows a key release, and egui never sees the text. winit's message hook ([`msg_hook`]) sees -//! the message before winit handles it: [`AltCodes`] notes keypad digits typed with Alt held, takes -//! the character that follows Alt's release, and [`raw_input_hook`] hands it to the frame as typed -//! text, so the Type tool (or a panel's text field) types it like any other character, in the -//! same undo step as the typing round it. The keypad digits themselves are taken out of the frame, -//! so they don't run a shortcut bound to Alt and a digit. +//! (). winit reports +//! that character as a key press of its own with the character as its text (storytold/winit W36), +//! so egui types it like any other character. Each keypad digit typed with Alt held also arrives +//! as Alt and a digit, which would run a shortcut bound to Alt and that digit: winit's message +//! hook ([`msg_hook`]) sees each message before winit handles it, [`AltCodes`] notes the keypad +//! digits typed with Alt held, and [`raw_input_hook`] takes them out of the frame. //! //! With NumLock off the keypad keys arrive as Insert, End, Down, Page Down, Left, Clear, Right, //! Home, Up and Page Up, and Windows still composes the code from them. They are told from the @@ -29,11 +27,11 @@ use std::cell::RefCell; use egui::{Event, Key}; +#[cfg(windows)] const WM_KEYDOWN: u32 = 0x0100; -const WM_KEYUP: u32 = 0x0101; -const WM_CHAR: u32 = 0x0102; const WM_SYSKEYDOWN: u32 = 0x0104; const WM_SYSKEYUP: u32 = 0x0105; +#[cfg(windows)] const WM_SYSCHAR: u32 = 0x0106; /// `VK_NUMPAD0` to `VK_NUMPAD9` (`winuser.h`): keypad digits with NumLock on. const VK_NUMPAD0: usize = 0x60; @@ -49,25 +47,15 @@ const DIGIT_KEYS: [Key; 10] = [Key::Num0, Key::Num1, Key::Num2, Key::Num3, Key:: /// Bit 24 of a key message's `lParam`: an extended key, such as the navigation keys beside the /// keypad (the keypad's own keys clear it). const EXTENDED_KEY: isize = 1 << 24; -/// `VK_MENU`, `VK_LMENU` and `VK_RMENU`: Alt. -const ALT_KEYS: [usize; 3] = [0x12, 0xA4, 0xA5]; thread_local! { /// The UI thread's sequence: [`msg_hook`] and [`raw_input_hook`] both run on it. static CODES: RefCell = RefCell::new(AltCodes::default()); } -/// Where an Alt + keypad code stands, from the keyboard messages of the thread's queue. +/// The keypad digits typed with Alt held, from the keyboard messages of the thread's queue. #[derive(Default)] struct AltCodes { - /// Keypad digits typed while Alt has been held. - digits: usize, - /// Alt came up after keypad digits: the next character message is the code's character. - armed: bool, - /// A high surrogate waiting for its low half. - high: Option, - /// Characters the codes typed, for the next frame. - typed: String, /// The digits of the keypad presses and releases with Alt held since the last frame, which /// egui reports as Alt and a digit (or, with NumLock off, Alt and a navigation key): taken /// out of the frame. @@ -88,80 +76,45 @@ fn keypad_digit(wparam: usize, lparam: isize) -> Option { impl AltCodes { /// Note a keyboard message `message` with `wparam` (the virtual-key code, or a UTF-16 unit) - /// and `lparam` (its flags). + /// and `lparam` (its flags). Windows sends a key pressed or released with Alt held as a system + /// key. fn message(&mut self, message: u32, wparam: usize, lparam: isize) { - let keypad = match message { - WM_SYSKEYDOWN | WM_SYSKEYUP => keypad_digit(wparam, lparam), - _ => None, - }; - if let Some(d) = keypad { - // Windows sends a key pressed with Alt held as a system key. - if message == WM_SYSKEYDOWN { - self.digits += 1; - self.armed = false; - } + if matches!(message, WM_SYSKEYDOWN | WM_SYSKEYUP) + && let Some(d) = keypad_digit(wparam, lparam) + { self.keypad_events.push(d); - return; - } - match message { - WM_KEYDOWN | WM_SYSKEYDOWN if ALT_KEYS.contains(&wparam) => {} - // Any other key ends the sequence and keeps its own meaning. - WM_KEYDOWN | WM_SYSKEYDOWN => self.reset(), - WM_KEYUP | WM_SYSKEYUP if ALT_KEYS.contains(&wparam) => { - self.armed = self.digits > 0; - self.digits = 0; - } - WM_CHAR | WM_SYSCHAR if self.armed => { - let unit = (wparam & 0xffff) as u16; - if (0xd800..0xdc00).contains(&unit) { - self.high = Some(unit); - return; - } - let units: Vec = self.high.take().into_iter().chain([unit]).collect(); - self.typed.extend(char::decode_utf16(units).filter_map(Result::ok).filter(|c| !c.is_control())); - self.armed = false; - } - _ => {} } } - fn reset(&mut self) { - self.digits = 0; - self.armed = false; - self.high = None; - } - - /// Hand the frame `events` the characters typed since the last frame, as typed text, and take - /// out the keypad digits typed with Alt held. + /// Take out of the frame `events` the keypad digits typed with Alt held since the last frame. + /// The character a code types comes from winit, as typed text. fn drain(&mut self, events: &mut Vec) { let mut keypad = std::mem::take(&mut self.keypad_events); - if !keypad.is_empty() { - events.retain(|e| { - let Event::Key { key, modifiers, .. } = e else { - return true; - }; - if !modifiers.alt { - return true; - } - // The first keypad key still to take out that egui reports as `key`. - let stands_for = |d: &usize| DIGIT_KEYS.get(*d) == Some(key) || NUMLOCK_OFF_EGUI_KEYS.get(*d) == Some(key); - match keypad.iter().position(stands_for) { - Some(i) => { - keypad.remove(i); - false - } - None => true, - } - }); - } - if !self.typed.is_empty() { - events.push(Event::Text(std::mem::take(&mut self.typed))); + if keypad.is_empty() { + return; } + events.retain(|e| { + let Event::Key { key, modifiers, .. } = e else { + return true; + }; + if !modifiers.alt { + return true; + } + // The first keypad key still to take out that egui reports as `key`. + let stands_for = |d: &usize| DIGIT_KEYS.get(*d) == Some(key) || NUMLOCK_OFF_EGUI_KEYS.get(*d) == Some(key); + match keypad.iter().position(stands_for) { + Some(i) => { + keypad.remove(i); + false + } + None => true, + } + }); } } -/// winit's message hook for the keyboard: notes Alt + keypad codes and the characters they type, -/// and hands each message to `windows_symbol_chars`. It never consumes the message. +/// winit's message hook for the keyboard: notes the keypad digits typed with Alt held, and hands +/// each message to `windows_symbol_chars`. It never consumes the message. #[cfg(windows)] #[allow(unsafe_code)] pub fn msg_hook(msg: *const std::ffi::c_void) { @@ -182,7 +135,7 @@ pub fn msg_hook(msg: *const std::ffi::c_void) { } } -/// Before egui reads the main window's frame: the characters Alt + keypad codes typed, as text. +/// Before egui reads the main window's frame: the keypad digits typed with Alt held are taken out. pub fn raw_input_hook(raw: &mut egui::RawInput) { CODES.with(|c| { if let Ok(mut c) = c.try_borrow_mut() { @@ -196,6 +149,9 @@ mod tests { use super::*; const ALT: usize = 0x12; + const WM_KEYDOWN: u32 = 0x0100; + const WM_KEYUP: u32 = 0x0101; + const WM_CHAR: u32 = 0x0102; /// Alt held, keypad digits `code`, Alt released, and the character Windows then posts. fn alt_code(c: &mut AltCodes, code: &str, posted: u16) { @@ -215,59 +171,53 @@ mod tests { } #[test] - fn an_alt_code_types_its_character_when_alt_comes_up() { + fn an_alt_codes_keypad_digits_leave_the_frame_and_its_character_is_typed_once() { let mut c = AltCodes::default(); alt_code(&mut c, "0176", 0xB0); alt_code(&mut c, "0151", 0x2014); - let mut events = vec![key(Key::Num0, true, true), key(Key::Num0, true, false), key(Key::Num1, false, true)]; + // winit reports each code's character as typed text. + let mut events = vec![ + key(Key::Num0, true, true), + key(Key::Num0, true, false), + key(Key::Num1, false, true), + Event::Text("°".into()), + Event::Text("—".into()), + ]; c.drain(&mut events); // The keypad digits typed with Alt are gone (eight presses and eight releases, two here); - // the digit typed without Alt stays, and the characters follow. - assert_eq!(events, vec![key(Key::Num1, false, true), Event::Text("°—".into())]); + // the digit typed without Alt stays, and each character stays once. + assert_eq!(events, vec![key(Key::Num1, false, true), Event::Text("°".into()), Event::Text("—".into())]); let mut events = vec![key(Key::Num0, true, true)]; c.drain(&mut events); assert_eq!(events.len(), 1, "counts don't carry over to a later frame"); } #[test] - fn a_character_without_a_code_before_it_is_left_to_winit() { + fn characters_are_left_to_winit() { let mut c = AltCodes::default(); - // A plain key press's character (winit types it), and Alt pressed and released alone. + // A plain key press's character, Alt pressed and released alone, and a code's character. c.message(WM_KEYDOWN, 0x41, 0); c.message(WM_CHAR, usize::from(b'a'), 0); c.message(WM_SYSKEYDOWN, ALT, 0); c.message(WM_KEYUP, ALT, 0); c.message(WM_CHAR, usize::from(b'b'), 0); + alt_code(&mut c, "0176", 0xB0); let mut events = vec![]; c.drain(&mut events); assert!(events.is_empty(), "{events:?}"); } #[test] - fn another_key_while_alt_is_held_cancels_the_code() { + fn alt_with_another_key_keeps_its_shortcut() { let mut c = AltCodes::default(); c.message(WM_SYSKEYDOWN, ALT, 0); c.message(WM_SYSKEYDOWN, VK_NUMPAD0 + 1, 0); // Alt+F: a shortcut, not a code. c.message(WM_SYSKEYDOWN, 0x46, 0); c.message(WM_KEYUP, ALT, 0); - c.message(WM_CHAR, 0x41, 0); - let mut events = vec![]; + let mut events = vec![key(Key::Num1, true, true), key(Key::F, true, true)]; c.drain(&mut events); - assert!(!events.iter().any(|e| matches!(e, Event::Text(_))), "{events:?}"); - } - - #[test] - fn a_code_above_the_basic_plane_arrives_as_two_halves() { - let mut c = AltCodes::default(); - c.message(WM_SYSKEYDOWN, ALT, 0); - c.message(WM_SYSKEYDOWN, VK_NUMPAD0 + 1, 0); - c.message(WM_KEYUP, ALT, 0); - c.message(WM_CHAR, 0xD83D, 0); - c.message(WM_CHAR, 0xDE00, 0); - let mut events = vec![]; - c.drain(&mut events); - assert_eq!(events, vec![Event::Text("😀".into())]); + assert_eq!(events, vec![key(Key::F, true, true)]); } /// Alt held, keypad digits `code` with NumLock off (keypad Insert, End, …, flags without the @@ -284,7 +234,7 @@ mod tests { } #[test] - fn with_numlock_off_the_keypad_keys_type_the_code_and_leave_the_caret_alone() { + fn with_numlock_off_the_keypad_keys_leave_the_caret_alone() { let mut c = AltCodes::default(); alt_code_numlock_off(&mut c, "0176", 0xB0); // What egui reports for keypad 0, 1, 7 and 6 with NumLock off and Alt held, a press and a @@ -296,7 +246,7 @@ mod tests { } events.push(key(Key::Home, false, true)); c.drain(&mut events); - assert_eq!(events, vec![key(Key::Home, false, true), Event::Text("°".into())]); + assert_eq!(events, vec![key(Key::Home, false, true)]); } #[test] @@ -309,11 +259,11 @@ mod tests { let mut events = vec![key(Key::Num5, true, true), key(Key::ArrowDown, true, true), key(Key::PageDown, true, true), key(Key::ArrowLeft, true, true)]; c.drain(&mut events); - assert_eq!(events, vec![Event::Text("—ê".into())]); + assert!(events.is_empty(), "{events:?}"); } #[test] - fn the_separate_navigation_keys_still_move_the_caret_and_cancel_the_code() { + fn the_separate_navigation_keys_still_move_the_caret() { let mut c = AltCodes::default(); c.message(WM_SYSKEYDOWN, ALT, 0); c.message(WM_SYSKEYDOWN, NUMLOCK_OFF_KEYS[1], 0); @@ -322,7 +272,6 @@ mod tests { c.message(WM_SYSKEYDOWN, NUMLOCK_OFF_KEYS[7], EXTENDED_KEY); c.message(WM_SYSKEYUP, NUMLOCK_OFF_KEYS[7], EXTENDED_KEY); c.message(WM_KEYUP, ALT, 0); - c.message(WM_CHAR, 0x41, 0); let mut events = vec![key(Key::End, true, true), key(Key::End, true, false), key(Key::Home, true, true), key(Key::Home, true, false)]; c.drain(&mut events); assert_eq!(events, vec![key(Key::Home, true, true), key(Key::Home, true, false)]); diff --git a/docs/hardware-parity.md b/docs/hardware-parity.md index 0c3a73b8cc..f36a536288 100644 --- a/docs/hardware-parity.md +++ b/docs/hardware-parity.md @@ -25,7 +25,7 @@ It reads the pen's tilt and barrel rotation on macOS and on Linux under X11 and | Pen tilt, bearing, barrel rotation (6D Art Pen) | yes, drives brushes | read from AppKit's tablet events (tilt, and the barrel rotation of a pen that reports one); Calligraphic and Scatter brushes vary with them (#764; not yet tried on a Mac) | with Windows Ink, read from the pen's `POINTER_PEN_INFO` (tilt and barrel rotation where its pen mask says the pen reports them); Calligraphic and Scatter brushes vary with them (#372; not yet tried with a pen) | under X11 and XWayland, read from XInput2 raw events; Calligraphic and Scatter brushes vary with them (#764); **no** on native Wayland | no | partial: native Wayland and the web read none, and Bristle brushes do not use them (an Art brush's Width and a Pattern brush's Scale follow them); 3–6 h (#372) | | Pen eraser end | yes | the eraser end (AppKit's tablet proximity events) selects the Eraser tool and the tip brings back the tool used before, as on Linux (#852; not yet tried on a Mac) | with Windows Ink, an inverted pen or its eraser button (`PEN_FLAG_INVERTED`, `PEN_FLAG_ERASER` in the pen's pointer messages) selects the Eraser tool and the tip brings back the tool used before, as on Linux (not yet tried with a pen) | under X11 and XWayland, the eraser end selects the Eraser tool and the tip brings back the tool used before (#764); **no** on native Wayland | a press of the eraser end (Pointer Events eraser button, `button` 5) selects the Eraser tool, and that press erases; a press of the tip brings back the tool used before; Pointer Events report no end while the pen hovers | partial | | Touch gestures (pinch zoom, two-finger pan, rotate view, Touch workspace) | yes (Windows touch, Surface) | trackpad pinch, scroll and rotate | pinch, pan (a second finger cancels the first finger's tool press, #4198); two-finger tap undo, three-finger redo (#585); in the Touch workspace a two-finger tap switches between the Selection tool and the last drawing tool | same where winit reports touch | eframe until the first pen contact, then Pointer Events (pen and fingers told apart); long press opens the context menu | partial: touch workspace and touch-screen rotation missing, 3–5 h | -| Trackpad (smooth scroll, pinch) | yes | yes | precision touchpads | yes | yes | done | +| Trackpad (smooth scroll, pinch) | yes | yes | precision touchpads | smooth scroll; pinch and rotate on native Wayland where the compositor offers pointer gestures (#5981), not under X11 or XWayland | yes | done | | HiDPI / Retina, per-monitor scale | yes | yes | yes | yes | yes | done; a window dragged between monitors of different scale can still grow on Windows (#1459, open); the custom title bar's window on Windows stays truly borderless so the pointer lines up with what is drawn (#1791, #1758; awaiting the reporter's confirmation) ; macOS cursors use aligned 1×/2× native image representations (#2292), covered by headless construction tests; mixed-display transitions and physical cursor sizing remain unverified, no additional hardware validated | | Multiple monitors: panels and document windows on another screen | yes | no (one OS window) | no | no | — | missing: 6–10 h (with multiple windows, gap G7) | | Display colour profile (proof and display through the monitor's ICC) | yes | yes: the window is tagged sRGB and macOS converts it | yes: the display's default ICC profile, Windows' own conversion with Advanced Color on | X11: colord or `_ICC_PROFILE`; Wayland: sRGB | — | done on macOS, Windows and X11; Wayland and floating document windows remain | diff --git a/docs/type-parity.md b/docs/type-parity.md index 1587d7f8f1..19d84fdaed 100644 --- a/docs/type-parity.md +++ b/docs/type-parity.md @@ -57,7 +57,7 @@ against Illustrator's public documentation; **estimated** unless noted. | Hidden characters (Show Hidden Characters) | done | `type.hiddenCharacters`: marks spaces, tabs, nonbreaking and narrow nonbreaking spaces, the spaces of a set width, discretionary hyphens, forced line breaks, paragraph ends and the story's end, in horizontal, vertical and right-to-left type and on a path, and none on type in a hidden group or layer; the mark shapes are VectorCraft's own. Evidence: `canvas::tests::hidden_characters_*` | | Spell check (Check Spelling, Auto Spell Check, custom dictionary) | done | the engine (#4936): `text.spelling.check` lists the unknown words of the document's type, each run in its Language, at the bytes `text.editRange` changes, and `text.spelling.suggest` gives suggestions, both from craft-proof, each paragraph on its own (English from the first dictionary it finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into it; other languages from the dictionaries craft-proof finds for them). The custom dictionary commands are done: `text.spelling.addWord`, `removeWord` and `changeWord` (Add, and Edit Custom Dictionary's Add, Delete and Change), and `text.spelling.dictionary` lists the words, saved to `Custom Dictionary.txt` beside the preferences; Ignore All: `text.spelling.ignoreAll` skips a word in the active document while it is open. Auto Spell Check is done: Edit › Spelling › Auto Spell Check (`edit.autoSpellCheck`, off at first, saved with the view settings) draws a red wavy line under the unknown words of the visible type, leaves out type with effects, and follows edits, the custom dictionary and Ignore All. A right-click on an underlined word lists the words its dictionary suggests (each replaces it in one undo step, `text.editRange`), or No Suggestions, then Ignore All and Add to Dictionary, and a right-click on type has Spelling › Auto Spell Check, checked while it is on. Edit › Edit Custom Dictionary… lists the custom dictionary's words, with an Entry field and Add, Delete and Change, applied on Done (Cancel leaves the dictionary as it was). The modal Check Spelling dialog is done: Edit › Spelling › Check Spelling… (`Cmd+I`, `ui.checkSpelling`) opens a modal dialog displaying the unrecognized word in sentence context ("Not in Dictionary"), a list of suggestions with double-click or selection to replace ("Change to" field), and action buttons: Ignore, Ignore All, Change (one-step Undo/Redo via `text.editRange`), Change All (batched across occurrences in a single undo step), Add to Dictionary (`text.spelling.addWord`), Done and Cancel, with keyboard navigation (Tab between controls, Enter to Change or Done, Escape to close). Evidence: `crates/engine/src/tests/spelling.rs`, `crates/ui-egui/src/canvas/tests.rs` (`auto_spell_check_*`), `crates/ui-egui/src/tests/contextmenu.rs` (the right-click), `crates/ui-egui/src/dialogs/custom_dictionary.rs` (the dialog), `crates/ui-egui/src/dialogs/check_spelling.rs` (the Check Spelling dialog). | | Smart Punctuation, Change Case, Find & Replace | done | Type › Smart Punctuation… opens a dialog with the ff, fi, ffi and ff, fl, ffl ligatures, Smart Quotes, Smart Spaces, En, Em Dashes, Ellipses and Expert Fractions, Replace In and Report Results, which lists the count of each replacement; ligatures and fractions are written only where the font has a glyph for them. Evidence: `tests::menucmds::smart_punctuation_ligatures_spaces_and_fractions_are_counted`, `smart_punctuation_skips_ligatures_and_fractions_the_font_lacks`, `smart_spaces_keeps_one_space_after_a_period`, `dialogs::smart_punctuation::tests::menu_item_opens_the_dialog_and_ok_reports_the_counts` | -| Alt + numeric-keypad codes while typing (Windows: `Alt+0176` → °) | partial | #5108: on Windows the character Windows posts when Alt comes up after keypad digits is typed at the caret like any other, in the typing's undo step, and the keypad digits typed with Alt run no shortcut. With NumLock off the keypad keys (Insert, End, arrows, Clear, Home, Page Up/Down without the extended-key flag) count as digits too and don't move the caret (`windows_alt_codes` unit tests; neither NumLock on nor off has been tried on a Windows machine yet). `type.insert {code}` (Windows Alt+0 code, Windows-1252 for 128–159) and `{unicode}` (hex code point) insert a character by its code (`menucmds::insert_a_character_by_its_code`). macOS and Linux have no such system convention and egui reports a keypad digit as the top-row digit, so there it does nothing; a floating panel window doesn't receive the character | +| Alt + numeric-keypad codes while typing (Windows: `Alt+0176` → °) | partial | #5108: on Windows the character Windows posts when Alt comes up after keypad digits is typed at the caret like any other, in the typing's undo step (winit reports it as typed text), and the keypad digits typed with Alt run no shortcut. With NumLock off the keypad keys (Insert, End, arrows, Clear, Home, Page Up/Down without the extended-key flag) count as digits too and don't move the caret (`windows_alt_codes` unit tests; neither NumLock on nor off has been tried on a Windows machine yet). `type.insert {code}` (Windows Alt+0 code, Windows-1252 for 128–159) and `{unicode}` (hex code point) insert a character by its code (`menucmds::insert_a_character_by_its_code`). macOS and Linux have no such system convention and egui reports a keypad digit as the top-row digit, so there it does nothing; in a floating panel window the keypad digits typed with Alt are not taken out of the frame | | Caret: the arrows and Delete step over whole clusters (Thai consonant with its marks, combining accents, emoji); Backspace removes one character | done | in text with right-to-left characters the arrows move in visual order and stop on both sides of a character drawn with no width, such as a zero width non-joiner | | Touch Type tool | done | moves, scales and rotates one character through its kerning, baseline shift, scales and rotation (`text.touchType`); a character with a preceding logical character on the same line can move along the line in either reading direction; the first logical character moves only up and down. Positive `dx` follows reading order. These direction rules are VectorCraft's choices. | | Retype (identify fonts in outlines/images) | partial | Phase 1 (#4934): Type › Retype (`type.retype`) turns outlined glyphs back into type when each shape is exactly a glyph of a loaded font, a font the document uses or a family named in `fonts` (the same up to uniform scale, rotation and translation): one object per line unless lines stack into one object as described below, in that font and size, at the same baseline and turn, with the first glyph's fill and stroke, in one undo step; shapes that match no font stay as they are and are reported. Near matches: with `tolerance` (0 to 0.05), shapes of up to 8 contours whose leftover distance from a glyph, relative to the shape's outline spread (the root mean square distance of its sampled outline points from their center), is at most the tolerance (simplified outlines, curves split in two, contours in another order or direction) match too, and each line reports a `score`; a compound path holding several glyphs is split into them and becomes type only when all of them match, a part still matching exactly when some of its contours run the other way round (an o's counter alone in an even-odd compound). A line of three or more exactly matched glyphs keeps the spacing most of its gaps share as tracking (gaps one space wide stay word spaces when type draws them). A line of two glyphs that untracked type does not draw in place takes the tracking of the nearest tracked line in the same font, size and turn, and keeps it only when type at that tracking draws both glyphs in place; a line of one or two glyphs that joins tracked lines in one object takes their tracking. Other lines are set untracked, each glyph at its own position, and lines stacked at one leading and lined up at their starts, ends or centers become one area type object with that leading and alignment (VectorCraft's own rules, checked against the layout). Window › Retype shows the Retype panel, which lists the fonts whose glyphs exactly match at least one selected outlined shape, comparing up to 96 loaded fonts with those of the document's live type first, ranked by how many shapes each matches, with samples, and sets a listed font on selected live type (`retype.find`, `type.retypeFonts`). Both also compare the installed fonts not loaded yet, reading their files within VectorCraft's own limits (256 MiB per file, 2 GiB and 500,000 glyphs per search) and loading only the fonts that match; `type.retype` matches them with its tolerance and splits compound paths for them as it does for loaded fonts; in the app the search runs in the background with Cancel (`retype.cancelSearch`). Missing (phase 2): glyphs fused into one contour, near matches and compound paths of several glyphs in the panel's list, opening the panel from the Type menu, the context menu and the Properties panel's Quick Actions, filtering the list by font source and favorites, text in images. Public behaviour: [identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html), [apply to live text](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/apply-retype-suggested-fonts-to-live-text.html) | From 28d0f76bfebe1335f7847947ac97b74fed4c69a5 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:34:39 +0100 Subject: [PATCH 134/264] Select one available release artifact pair for every RPM smoke job --- .github/workflows/release-rpm-smoke.yml | 33 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml index 3486333a2b..53bab7ff7e 100644 --- a/.github/workflows/release-rpm-smoke.yml +++ b/.github/workflows/release-rpm-smoke.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: run-id: - description: Release workflow run containing the RPM artifacts (empty selects latest release branch run) + description: Release run containing both RPM artifacts (empty selects the latest available pair) type: string default: "" pull_request: @@ -17,7 +17,33 @@ permissions: actions: read jobs: + source: + runs-on: ubuntu-24.04 + timeout-minutes: 5 + outputs: + run-id: ${{ steps.source.outputs.run-id }} + steps: + - id: source + env: + GH_TOKEN: ${{ github.token }} + RUN_ID: ${{ inputs.run-id }} + run: | + candidates="$RUN_ID" + if [ -z "$candidates" ]; then + candidates=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow release.yml --branch release --limit 10 --json databaseId --jq '.[].databaseId') + fi + for candidate in $candidates; do + [[ "$candidate" =~ ^[0-9]+$ ]] + names=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$candidate/artifacts?per_page=100" --jq '.artifacts[] | select(.expired == false) | .name') + if grep -Fxq release-linux-x86_64 <<< "$names" && grep -Fxq release-linux-aarch64 <<< "$names"; then + printf 'run-id=%s\n' "$candidate" >> "$GITHUB_OUTPUT" + exit 0 + fi + done + echo '::error::No release run has both Linux package artifacts available' + exit 1 smoke: + needs: source timeout-minutes: 25 strategy: fail-fast: false @@ -34,12 +60,9 @@ jobs: - name: Download the release packages env: GH_TOKEN: ${{ github.token }} - RUN_ID: ${{ inputs.run-id }} + RUN_ID: ${{ needs.source.outputs.run-id }} ARCH: ${{ matrix.platform.arch }} run: | - if [ -z "$RUN_ID" ]; then - RUN_ID=$(gh run list --workflow release.yml --branch release --limit 1 --json databaseId --jq '.[0].databaseId') - fi [[ "$RUN_ID" =~ ^[0-9]+$ ]] mkdir -p packages results gh run view "$RUN_ID" --json headSha,url > results/source.json From dd95b7add4789064ba43481b4dd2ec8a38ed987a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 12:36:16 -0800 Subject: [PATCH 135/264] Canvas: the bounding box follows a drag in the frame the pointer moves The bounding box, the Live Corners widgets and the shape widgets were drawn before the tool host took the frame's pointer event, so during a Selection tool drag they showed where the art was one frame earlier. With Show Bounding Box While Moving and Drawing on, the box trailed the art on every frame of a move. They are display only, so they are now drawn after the tool host, like the selection's marks, and put back at their old place in the paint order through a PaintSlot. The tool overlays that are not framework controls (path marks, anchors, handles, labels and the rest) no longer get a child Ui each, so a list of 10,000 path marks makes none. Tests: with the box shown while moving, a Selection tool drag draws it at the object's new corner and none at the old one in each frame. --- crates/ui-egui/src/canvas.rs | 26 +++++++++++++++++--------- crates/ui-egui/src/canvas/overlays.rs | 21 ++++++++++++++++++++- crates/ui-egui/src/canvas/tests.rs | 15 +++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index f340f3bac2..08f859b025 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -278,8 +278,8 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin pressed } -/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks, the -/// picture last. +/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks and the +/// display-only widgets over it, the picture last. fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: Option<&ToolPass>, win: Win, kind: BodyKind) -> Body { let live = kind == BodyKind::Live; let presenting = app.ui.screen_mode == 3; @@ -299,11 +299,12 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O crate::dialogs::simplify_slider::show(app, ui, &space.view); } guides::show(app, ui, space, win, kind); - widgets::show_hollow_corners(app, ui, space, kind); - // The selection's marks paint here, under the widgets and bars, and are drawn after the tool host has taken this - // frame's pointer event, from the document as the event leaves it. + // The hollow Live Corners, the selection's marks, and the bounding box, Live Corners and shape widgets paint here + // in that order, under the 3D handles and the bars. All of them are display only and are drawn after the tool host + // has taken this frame's pointer event, from the document as the event leaves it. + let hollow = PaintSlot::reserve(ui.painter()); let marks = PaintSlot::reserve(ui.painter()); - widgets::show(app, ui, space, win, kind); + let shown_widgets = PaintSlot::reserve(ui.painter()); if !presenting && !revolve_editing(app) { crate::panels::three_d::handles::show(app, ui, space); } @@ -339,14 +340,21 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O crate::type_editing::show(app, ui); } } - let after = PaintSlot::reserve(ui.painter()); - selection::show(app, ui, space, win, kind); - marks.extend(ui.ctx(), after.take_after(ui.ctx())); + paint_into(ui, hollow, |ui| widgets::show_hollow_corners(app, ui, space, kind)); + paint_into(ui, marks, |ui| selection::show(app, ui, space, win, kind)); + paint_into(ui, shown_widgets, |ui| widgets::show(app, ui, space, win, kind)); drops::show(app, ui, win, kind); raster::picture(app, ui, space, win, kind); out } +/// Runs `draw` now and moves the shapes it paints on `ui`'s layer to `slot`, their place in the paint order. +fn paint_into(ui: &mut Ui, slot: PaintSlot, draw: impl FnOnce(&mut Ui)) { + let after = PaintSlot::reserve(ui.painter()); + draw(ui); + slot.extend(ui.ctx(), after.take_after(ui.ctx())); +} + /// The keys held now, as the engine's tools read them, with `space` set while Space is down. pub(crate) fn held_mods(ctx: &egui::Context) -> vectorcraft_tools::Mods { let (m, space) = ctx.input(|i| (i.modifiers, i.key_down(egui::Key::Space))); diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index 8f9bd6f663..8f70ceb024 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -35,7 +35,8 @@ pub(super) fn show(app: &VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSpace, let options = super::selection::path_options(&app.session.prefs); let quiet = tool_adapter::in_gesture(app, ui.ctx()) || tool_adapter::view_tool_held(app); let lists = [extra, overlays]; - for (i, o) in extra.iter().chain(overlays).enumerate() { + // Only the overlays that are controls get a child `Ui`: a list of 10,000 path marks makes none. + for (i, o) in extra.iter().chain(overlays).enumerate().filter(|(_, o)| is_control(o)) { ui.push_id(("tool-control", i), |ui| show_control(ui, rect, o)); } for (i, list) in lists.into_iter().enumerate() { @@ -48,6 +49,24 @@ pub(super) fn show(app: &VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSpace, }); } +/// Whether `o` is shown as a framework control of its own ([`show_control`]) rather than painted by [`ToolMarks`]. +fn is_control(o: &Overlay) -> bool { + match o { + Overlay::Marquee(_) | Overlay::SelectionMarquee { .. } | Overlay::SharedPath { .. } | Overlay::Distance { .. } => true, + Overlay::Path { .. } + | Overlay::Line { .. } + | Overlay::Anchor { .. } + | Overlay::CurvePoint { .. } + | Overlay::Handle { .. } + | Overlay::Label { .. } + | Overlay::Measure { .. } + | Overlay::Highlight { .. } + | Overlay::Swatch { .. } + | Overlay::GridLine { .. } + | Overlay::HoverText { .. } => false, + } +} + /// The framework control `o` stands for, if it is one: a marquee, a settled outline or a distance. fn show_control(ui: &mut egui::Ui, rect: ScreenRect, o: &Overlay) { match o { diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index ae6956a288..9aa346194f 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -303,7 +303,22 @@ fn press(at: Pos2, pressed: bool) -> egui::Event { /// object has after that frame's event, and none at the corner it had before it. #[test] fn a_selection_drag_draws_its_marks_in_the_frame_the_pointer_moves() { + selection_drag_marks_follow(drag_app()); +} + +/// With Show Bounding Box While Moving and Drawing on, a Selection tool drag draws the bounding box and its handles in +/// the frame the pointer moves: at the corner the object has after that frame's event, and none at the corner it had +/// before it. +#[test] +fn a_selection_drag_draws_its_bounding_box_in_the_frame_the_pointer_moves() { let mut app = drag_app(); + app.session.prefs.bounding_box_while_moving_and_drawing = true; + selection_drag_marks_follow(app); +} + +/// Drags a selected rectangle with the Selection tool in six frames and checks each frame that moved it: a mark at +/// its corner after the frame's event, none at its corner before. +fn selection_drag_marks_follow(mut app: VectorcraftApp) { let id = app.session.execute("shape.rectangle", &json!({"x": 150, "y": 100, "width": 60, "height": 40})).unwrap()["id"].as_u64().unwrap(); app.select_tool("selection"); app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); From 971b9c05f78bc3ca04e68f0448a102b29482285c Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:43:31 +0100 Subject: [PATCH 136/264] Provide the X11 keyboard library in RPM test desktops --- .github/workflows/release-rpm-smoke.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml index 53bab7ff7e..a03620fd09 100644 --- a/.github/workflows/release-rpm-smoke.yml +++ b/.github/workflows/release-rpm-smoke.yml @@ -93,10 +93,10 @@ jobs: cat /etc/os-release > /results/os-release.txt if [ "$DISTRO" = opensuse ]; then zypper --non-interactive refresh - zypper --non-interactive install python3 Mesa-dri Mesa-libEGL1 libX11-6 libXcursor1 libXi6 libXrandr2 libxkbcommon0 + zypper --non-interactive install python3 Mesa-dri Mesa-libEGL1 libX11-6 libXcursor1 libXi6 libXrandr2 libxkbcommon0 libxkbcommon-x11-0 zypper --non-interactive --no-gpg-checks install /packages/*.rpm else - dnf -y install python3 mesa-dri-drivers mesa-libEGL libX11 libXcursor libXi libXrandr libxkbcommon + dnf -y install python3 mesa-dri-drivers mesa-libEGL libX11 libXcursor libXi libXrandr libxkbcommon libxkbcommon-x11 dnf -y --nogpgcheck install /packages/*.rpm fi rpm -qp --requires /packages/*.rpm > /results/rpm-requires.txt From 05464b264e357f69053aa9e8e60a7d2f057b1b5b Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:45:52 +0100 Subject: [PATCH 137/264] Authenticate the RPM smoke control connection --- .github/scripts/release-rpm-smoke.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/scripts/release-rpm-smoke.py b/.github/scripts/release-rpm-smoke.py index f82b70675a..73dc871f1d 100644 --- a/.github/scripts/release-rpm-smoke.py +++ b/.github/scripts/release-rpm-smoke.py @@ -3,6 +3,7 @@ import json import os from pathlib import Path +import secrets import socket import subprocess import time @@ -26,7 +27,9 @@ fixture = results / "original-smoke.svg" fixture.write_text('' '' '') -env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR="/tmp/vectorcraft-runtime") +token = secrets.token_hex(32) +env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR="/tmp/vectorcraft-runtime", + VECTORCRAFT_CONTROL_TOKEN=token) Path(env["XDG_RUNTIME_DIR"]).mkdir(mode=0o700, exist_ok=True) with (results / "gui.log").open("w") as log: app = subprocess.Popen([ @@ -48,6 +51,7 @@ with (results / "gui.log").open("w") as log: channel.settimeout(30) with channel, channel.makefile("rwb") as stream: for request_id, method, params in ( + (0, "auth", {"token": token}), (1, "ui.inspect", {}), ): stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) From 76aa6afeb000ec301176fe1b0900e16b4ea260d6 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:50:43 +0100 Subject: [PATCH 138/264] Mark the readiness loop counter intentionally unused --- .github/workflows/release-rpm-smoke.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml index a03620fd09..4140f57f3d 100644 --- a/.github/workflows/release-rpm-smoke.yml +++ b/.github/workflows/release-rpm-smoke.yml @@ -75,7 +75,7 @@ jobs: sudo apt-get update -qq sudo apt-get install -y xvfb Xvfb :99 -screen 0 1440x900x24 -ac -nolisten tcp > results/xvfb.log 2>&1 & - for attempt in {1..20}; do + for _attempt in {1..20}; do [ -S /tmp/.X11-unix/X99 ] && break sleep 1 done From 950467b7de8bd1571ae8e97110c791bcfeb4658c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 12:55:18 -0800 Subject: [PATCH 139/264] Menus: the start of a drag keeps every row's state While an interaction is open (a move, scale or shape drag, a dialog's preview, a typing session), the menus' state key left the document revision out, so the key changed in the frame the interaction began and the menus rebuilt every row's state for it, on top of the rebuilds for the press and the release. A rebuild costs about 8 ms on small documents and about 160 ms with 10,000 objects selected. An interaction now records the revision it began from, and the key uses that revision while the interaction is open. The key stays the same as a drag begins and through its previews, and changes when it ends. The new test drives a Selection tool move through the whole app and counts the rebuilds in each frame: one for the press and one for the release, none as the move begins. --- crates/engine/src/interaction.rs | 3 +++ crates/engine/src/session/edit.rs | 1 + crates/ui-egui/src/canvas/tests.rs | 29 +++++++++++++++++++++++++++++ crates/ui-egui/src/menus/model.rs | 6 +++--- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/interaction.rs b/crates/engine/src/interaction.rs index a2b9417461..bdc829fb37 100644 --- a/crates/engine/src/interaction.rs +++ b/crates/engine/src/interaction.rs @@ -10,6 +10,9 @@ pub struct Interaction { pub doc: Arc, /// The selection the previews start from (shared, so a preview frame copies nothing). pub selection: Arc, + /// The document's [`crate::DocState::revision`] when the interaction began. The previews change the document's + /// revision, and this value stays the same until the interaction ends. + pub revision: u64, pub preview: Option<(String, Value)>, /// The active tool began it (a drag): a command from outside the tool runs as a step of its /// own under it ([`crate::Session::outside_interaction`]). A dialog or a panel that begins an diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index d5d62e607c..0d2eaaef03 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -545,6 +545,7 @@ impl Session { effect: None, doc: st.doc.clone(), selection: Arc::new(st.selection.clone()), + revision: st.revision, preview: None, tool: false, paint, diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index ae6956a288..a51642ee92 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -841,6 +841,35 @@ fn the_move_of_a_releasing_frame_counts_for_the_tool_drag() { assert_eq!(draw(true), Rect::new(130.0, 115.0, 160.0, 130.0), "with Space held through the release the last move moves it"); } +/// A Selection tool move builds the menus' states again twice, in the frame of its press and in the frame of its +/// release, which commits the move. The frame the move begins in and the frames of its previews, which change the +/// document's revision, keep them. +#[test] +fn a_selection_move_rebuilds_the_menus_for_its_press_and_release_only() { + let (mut app, ctx, xf) = rectangle_tool(); + let id = app.session.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 60, "height": 30})).unwrap()["id"].as_u64().unwrap(); + app.select_tool("selection"); + app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); + let (from, to) = (xf.to_screen(Point::new(130.0, 115.0)), xf.to_screen(Point::new(170.0, 135.0))); + app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(from)]); + for _ in 0..2 { + app_step(&mut app, &ctx, vec![]); + } + let none = egui::Modifiers::NONE; + let mut steps = vec![vec![primary(from, true, none)]]; + steps.extend((1..=8).map(|i| vec![egui::Event::PointerMoved(from.lerp(to, i as f32 / 8.0))])); + steps.push(vec![primary(to, false, none)]); + steps.extend([vec![], vec![], vec![]]); + let mut rebuilt = vec![]; + for events in steps { + let before = app.menus.rebuilds; + app_step(&mut app, &ctx, events); + rebuilt.push(app.menus.rebuilds - before); + } + assert_eq!(drawn_paths(&app), vec![Rect::new(140.0, 120.0, 200.0, 150.0)], "the drag moves the rectangle"); + assert_eq!(rebuilt, [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], "rebuilds in each frame: press, 8 moves, release, 3 idle"); +} + /// #6369: only the selection box remains over the temporary halftone, and the original /// selection's outlines come back when Preview is turned off or the dialog is cancelled. #[test] diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index fffff70049..92c1786af4 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -89,8 +89,8 @@ pub(crate) fn translate_label(english: &'static str) -> String { /// button pressed or released or a key pressed ([`last_press`]), changes once for each, which covers what the hash /// doesn't list (panels shown, a tool picked). While an /// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's -/// preview, or a typing session), the revision, which each of its previews changes, is left out: -/// the hash changes as the interaction begins and as it ends. +/// preview, or a typing session), the hash takes the revision the interaction began from in place of the current one, +/// which each of its previews changes: the hash stays the same as the interaction begins, and changes as it ends. pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { let mut h = DefaultHasher::new(); input.hash(&mut h); @@ -101,7 +101,7 @@ pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { let s = &app.session; (s.journal.len(), s.active_index(), s.clipboard.is_empty(), s.tool_composing()).hash(&mut h); if let Some(d) = s.active() { - let revision = d.interaction.is_none().then_some(d.revision); + let revision = d.interaction.as_ref().map_or(d.revision, |it| it.revision); (d.uid, revision, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h); } (app.system_paste, app.last_effect.is_some(), app.ui.recent_files.len(), app.ui.recent_files.first(), app.recent_fonts().len()).hash(&mut h); From b893f05f61992398a07fb6d4dfe575c4aeec6c73 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 12:57:08 -0800 Subject: [PATCH 140/264] 3D: Map Art X and Y keep the points a document unit converts to Typing 10 into X in a millimeters document stored 28.35 pt instead of 28.3464567 pt, because the X and Y setters rounded to two point decimals. They now only clamp. The flat view also wrote the map back through the box on every frame, rounding the offsets again; it now writes the map only when the box was edited. --- crates/ui-egui/src/dialogs/three_d_classic.rs | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/three_d_classic.rs b/crates/ui-egui/src/dialogs/three_d_classic.rs index 5c7c0f8254..1a5acb6f6f 100644 --- a/crates/ui-egui/src/dialogs/three_d_classic.rs +++ b/crates/ui-egui/src/dialogs/three_d_classic.rs @@ -282,8 +282,9 @@ fn set_map_value(fields: &mut DialogFields, key: &str, value: Value) -> Result<( let n = value.as_f64().filter(|n| n.is_finite()).ok_or("not a number")?; let mut m = old.ok_or("the surface has no map")?; match key { - "mapX" => m.x = round_clamp(n, 2, -GRAPHIC_MAX_OFFSET, GRAPHIC_MAX_OFFSET), - "mapY" => m.y = round_clamp(n, 2, -GRAPHIC_MAX_OFFSET, GRAPHIC_MAX_OFFSET), + // X and Y arrive in points converted from the document's unit: rounding them would move a typed 10 mm. + "mapX" => m.x = n.clamp(-GRAPHIC_MAX_OFFSET, GRAPHIC_MAX_OFFSET), + "mapY" => m.y = n.clamp(-GRAPHIC_MAX_OFFSET, GRAPHIC_MAX_OFFSET), "mapScaleX" => m.scale_x = round_clamp(n, 2, GRAPHIC_SCALE_RANGE.0, GRAPHIC_SCALE_RANGE.1), "mapScaleY" => m.scale_y = round_clamp(n, 2, GRAPHIC_SCALE_RANGE.0, GRAPHIC_SCALE_RANGE.1), "mapRotation" => m.rotation = n.clamp(-360.0, 360.0), @@ -380,6 +381,12 @@ fn map_of_box(state: &BoxState, rect: Rect, base: &SurfaceMap) -> SurfaceMap { } } +/// The map a box edit leaves, or none while the box is still the one `map` drew (`drawn`), so a frame without an edit +/// keeps the map's numbers exactly as typed. +fn map_after_edit(state: &BoxState, drawn: &BoxState, rect: Rect, map: &SurfaceMap) -> Option { + (state != drawn).then(|| map_of_box(state, rect, map)).filter(|moved| moved != map) +} + /// The id of Map Art's Done, in the footer as Reset all is on the other pages. pub(crate) const MAP_DONE: &str = "mapDone"; @@ -416,6 +423,7 @@ fn flat_view(ui: &mut Ui, fields: &mut DialogFields, flat: &Flat) -> Response { } let (Some(m), Some(rect)) = (map.as_ref(), rect) else { return }; let mut state = map_box(m, rect); + let drawn = state; if m.rotation.abs() < 0.01 && let (Some(doc), Some((w, h))) = (flat.doc.as_ref(), flat.art) { @@ -432,8 +440,7 @@ fn flat_view(ui: &mut Ui, fields: &mut DialogFields, flat: &Flat) -> Response { .reference_point(false) .rotate_zone(RotateZone::border(18.0)) .show_at(ui, body.rect); - let moved = map_of_box(&state, rect, m); - if moved != *m { + if let Some(moved) = map_after_edit(&state, &drawn, rect, m) { edited = Some(moved); } }); @@ -585,4 +592,26 @@ mod tests { let turned = map(190.0); assert_eq!(map_of_box(&map_box(&turned, rect), rect, &turned).rotation, -170.0, "a turn wraps to ±180"); } + + #[test] + fn map_offsets_keep_the_points_a_document_unit_converts_to() { + // 10 mm, as the X and Y rows hand it over in points. + let ten_mm = 10.0 * 72.0 / 25.4; + let mut fields = DialogFields::new(); + store_map(&mut fields, 1, Some(&map(0.0))); + assert_eq!(set_map_value(&mut fields, "mapX", json!(ten_mm)), Ok(())); + assert_eq!(set_map_value(&mut fields, "mapY", json!(-ten_mm)), Ok(())); + let stored = maps_of(&fields).into_iter().find(|m| m.surface == 1).map(|m| (m.x, m.y)); + assert_eq!(stored, Some((ten_mm, -ten_mm)), "the typed offset is stored unrounded"); + assert_eq!(set_map_value(&mut fields, "mapX", json!(GRAPHIC_MAX_OFFSET * 2.0)), Ok(())); + assert_eq!(maps_of(&fields).first().map(|m| m.x), Some(GRAPHIC_MAX_OFFSET), "the offset still keeps to its bounds"); + + // A frame without a box edit leaves those numbers as they are. + let rect = art_rect((20.0, 10.0)); + let typed = SurfaceMap { x: ten_mm, y: -ten_mm, ..map(0.0) }; + let drawn = map_box(&typed, rect); + assert_eq!(map_after_edit(&drawn, &drawn, rect, &typed), None); + let dragged = drawn.moved(Vec2::new(1.0, 0.0)); + assert!(map_after_edit(&dragged, &drawn, rect, &typed).is_some(), "a drag still edits the map"); + } } From a3b93d585b3458c9296776a32fe6924c748ec3f7 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 15:57:37 -0500 Subject: [PATCH 141/264] ci(sonarcloud): give each main commit its own concurrency group (#10126) --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4cd4eb6387..dde1f6f5a8 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -11,7 +11,7 @@ permissions: contents: read concurrency: - group: sonarcloud-${{ github.ref }} + group: ${{ github.ref == 'refs/heads/main' && format('sonarcloud-main-{0}', github.sha) || format('sonarcloud-{0}', github.ref) }} # A push to main is the run that publishes coverage; superseded runs there would never finish. cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} From aaa54f13070fd752b2337b2e417fc61d0be18436 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 13:03:07 -0800 Subject: [PATCH 142/264] Performance: an edit skips unchanged objects without reading them After every edit, the pixel grid, color mask, Objects on Path, Shaper and symbol instance passes, and the inline graphics refresh, pair each object with its counterpart from before the edit. Each pass read both objects to compare their ids before it found that they were the same node, so moving one object in a layer of 20,000 objects read all of them in four passes. The color mask pass is new since v0.24.1, and object.move became slower than in that release. The new vectorcraft_doc::changed_nodes does the pairing for all six. An object that is the same node at the same position is skipped by a pointer comparison; only changed and new objects are looked up by id. object.move of one rectangle in a document of 20,000 objects, release build, median CPU time of 2,000 moves: main 1.25 ms, this change 1.08 ms, v0.24.1 1.06 ms. The passes' share of the move went from about 30% to 5% in a profile. --- crates/doc/src/inline.rs | 10 +------ crates/doc/src/lib.rs | 1 + crates/doc/src/node.rs | 4 +++ crates/doc/src/node/changed.rs | 33 +++++++++++++++++++++ crates/doc/src/node/tests.rs | 34 ++++++++++++++++++++++ crates/engine/src/cmd/addons/image/mask.rs | 11 ++----- crates/engine/src/cmd/object/pixelgrid.rs | 22 ++------------ crates/engine/src/cmd/objects_on_path.rs | 14 ++------- crates/engine/src/cmd/shaper.rs | 17 ++--------- 9 files changed, 84 insertions(+), 62 deletions(-) create mode 100644 crates/doc/src/node/changed.rs diff --git a/crates/doc/src/inline.rs b/crates/doc/src/inline.rs index b22f6cbfc7..731fba6d34 100644 --- a/crates/doc/src/inline.rs +++ b/crates/doc/src/inline.rs @@ -308,16 +308,8 @@ fn resolve_kids( layout: &mut dyn FnMut(&mut TextObject), changed: &mut Vec, ) -> Vec<(usize, Arc)> { - let mut by_id: Option>> = None; let mut out = vec![]; - for (i, c) in kids.iter().enumerate() { - let o = old.and_then(|old| match old.get(i) { - Some(b) if b.id == c.id => Some(b), - _ => by_id.get_or_insert_with(|| old.iter().map(|b| (b.id, b)).collect()).get(&c.id).copied(), - }); - if o.is_some_and(|o| Arc::ptr_eq(o, c)) { - continue; - } + for (i, c, o) in crate::changed_nodes(old.unwrap_or_default(), kids) { let mut c = c.clone(); if resolve_since(o.map(|o| &**o), &mut c, bounds, layout, changed) { out.push((i, c)); diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 470b0a94c4..6a331c6b77 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -116,6 +116,7 @@ pub use live_paint::{GapOptions, GapSize}; pub use metadata::{CopyrightStatus, DocMetadata}; pub use node::Knockout; pub use node::Scaling; +pub use node::changed_nodes; pub use node::{Extras, ExtrasMut, ImageObject, LAYER_COLORS, LayerColor, LiveShape, Node, NodeExtras, NodeId, NodeKind, OpacityMask}; pub use node::{ForeignAttribute, ImageMap, MAX_SVG_SCRIPTS, MAX_TAG_TEXT, MAX_TAGS, ObjectAttributes, ObjectTag, SVG_EVENTS}; pub use orient::OrientedBox; diff --git a/crates/doc/src/node.rs b/crates/doc/src/node.rs index 87b9a375db..3a4b2abd03 100644 --- a/crates/doc/src/node.rs +++ b/crates/doc/src/node.rs @@ -15,6 +15,7 @@ use crate::symbols::{SYMBOL_SQUARE, SymbolBoxes}; use crate::text::TextObject; mod attributes; +mod changed; mod clip; mod extras; mod ids; @@ -25,6 +26,9 @@ mod ops; mod wire; pub use attributes::{ForeignAttribute, ImageMap, MAX_SVG_SCRIPTS, MAX_TAG_TEXT, MAX_TAGS, ObjectAttributes, ObjectTag, SVG_EVENTS}; +#[cfg(test)] +pub(crate) use changed::COUNTERPART_LOOKUPS; +pub use changed::changed_nodes; pub use clip::{ClipPaint, Uniter}; pub use extras::{Extras, ExtrasMut, NodeExtras}; pub use ids::{LAYER_COLORS, LayerColor, NodeId}; diff --git a/crates/doc/src/node/changed.rs b/crates/doc/src/node/changed.rs new file mode 100644 index 0000000000..4aba12f78e --- /dev/null +++ b/crates/doc/src/node/changed.rs @@ -0,0 +1,33 @@ +use std::collections::HashMap; + +use super::{Arc, Node, NodeId}; + +#[cfg(test)] +thread_local! { + /// Tests: how many nodes [`changed_nodes`] looked up a counterpart for on this thread. + pub(crate) static COUNTERPART_LOOKUPS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// The nodes of `after` that are not the same nodes as their counterparts in `before` (the same +/// list before an edit), with their positions in `after`. A node's counterpart is the node at the +/// same position when it has the same id, else the node in `before` with its id, else `None` (the +/// node is new). A node that is the same node as the one at its position in `before` is skipped +/// without reading it, so a list of many unchanged nodes costs one pointer comparison per node. +pub fn changed_nodes<'a>(before: &'a [Arc], after: &'a [Arc]) -> impl Iterator, Option<&'a Arc>)> { + let mut by_id: Option>> = None; + after.iter().enumerate().filter_map(move |(i, a)| { + if before.get(i).is_some_and(|b| Arc::ptr_eq(b, a)) { + return None; + } + #[cfg(test)] + COUNTERPART_LOOKUPS.with(|c| c.set(c.get() + 1)); + let b = match before.get(i) { + Some(b) if b.id == a.id => Some(b), + _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&a.id).copied(), + }; + if b.is_some_and(|b| Arc::ptr_eq(b, a)) { + return None; + } + Some((i, a, b)) + }) +} diff --git a/crates/doc/src/node/tests.rs b/crates/doc/src/node/tests.rs index 8d6520265a..ed2fdb08d9 100644 --- a/crates/doc/src/node/tests.rs +++ b/crates/doc/src/node/tests.rs @@ -947,3 +947,37 @@ fn try_walk_ends_at_the_break() { assert_eq!(flow, ControlFlow::Break(NodeId(3))); assert_eq!(seen, [NodeId(1), NodeId(2), NodeId(3)]); } + +/// After an edit of one node in a list of 1,000, `changed_nodes` gives that node and a new one +/// with their counterparts, and looks a counterpart up for those two only: the 999 nodes that are +/// the same nodes in the same places are passed over by their pointers. +#[test] +fn changed_nodes_looks_up_only_the_nodes_that_changed() { + let leaf = |id| Arc::new(Node::group(NodeId(id), vec![])); + let before: Vec> = (0..1000).map(leaf).collect(); + let mut after = before.clone(); + let mut edited = (*after[500]).clone(); + edited.name = Some("edited".into()); + after[500] = Arc::new(edited); + after.push(leaf(5000)); + COUNTERPART_LOOKUPS.with(|c| c.set(0)); + let changed: Vec<_> = changed_nodes(&before, &after).map(|(i, a, b)| (i, a.id, b.map(|b| b.id))).collect(); + assert_eq!(changed, [(500, NodeId(500), Some(NodeId(500))), (1000, NodeId(5000), None)]); + assert_eq!(COUNTERPART_LOOKUPS.with(|c| c.get()), 2); +} + +/// A node that moved to another place in the list is paired with itself by its id and left out +/// when it is the same node; a changed node that moved is paired with its old node, and a node +/// that is gone from the list gives nothing. +#[test] +fn changed_nodes_pairs_moved_nodes_by_id() { + let leaf = |id| Arc::new(Node::group(NodeId(id), vec![])); + let before = vec![leaf(1), leaf(2), leaf(3), leaf(4)]; + let mut edited = (*before[0]).clone(); + edited.locked = true; + let after = vec![Arc::clone(&before[2]), Arc::clone(&before[1]), Arc::new(edited)]; + let changed: Vec<_> = changed_nodes(&before, &after).map(|(i, a, b)| (i, a.id, b.map(|b| b.id))).collect(); + assert_eq!(changed, [(2, NodeId(1), Some(NodeId(1)))]); + assert!(changed_nodes(&[], &after).map(|(_, _, b)| b).all(|b| b.is_none()), "every node is new against an empty list"); + assert_eq!(changed_nodes(&[], &after).count(), 3); +} diff --git a/crates/engine/src/cmd/addons/image/mask.rs b/crates/engine/src/cmd/addons/image/mask.rs index 7fdb0c5c3e..a46818befb 100644 --- a/crates/engine/src/cmd/addons/image/mask.rs +++ b/crates/engine/src/cmd/addons/image/mask.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_doc::color_mask::{ColorMask, MaskBackground, MaskMatch}; -use vectorcraft_doc::{Document, ImageBlob, Node, NodeId, NodeKind}; +use vectorcraft_doc::{Document, ImageBlob, Node, NodeId, NodeKind, changed_nodes}; use vectorcraft_geom::Affine; use super::super::super::paint::{PROCESS_ON_TRANSPARENCY, colorized_with_process}; @@ -367,14 +367,7 @@ fn stale_in(doc: &Document, n: &Arc, old: Option<&Arc>) -> bool { } let Some(children) = n.children() else { return false }; let before = old.and_then(|o| o.children()).map_or(&[][..], Vec::as_slice); - let mut by_id: Option>> = None; - children.iter().enumerate().any(|(i, c)| { - let b = match before.get(i) { - Some(b) if b.id == c.id => Some(b), - _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&c.id).copied(), - }; - stale_in(doc, c, b) - }) + changed_nodes(before, children).any(|(_, c, b)| stale_in(doc, c, b)) } /// Whether `n` is an image whose color mask was not made from its own pixels (or whose masked diff --git a/crates/engine/src/cmd/object/pixelgrid.rs b/crates/engine/src/cmd/object/pixelgrid.rs index 81909da76f..7bef1cbc69 100644 --- a/crates/engine/src/cmd/object/pixelgrid.rs +++ b/crates/engine/src/cmd/object/pixelgrid.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; -use vectorcraft_doc::{AppearanceItem, LiveShape, StrokeAlign}; +use vectorcraft_doc::{AppearanceItem, LiveShape, StrokeAlign, changed_nodes}; use super::{ Affine, Arc, Document, EngineError, Node, NodeId, NodeKind, Paint, PathData, Rect, Result, Scaling, Session, Value, Vec2, bad, json, @@ -226,15 +226,7 @@ fn refresh_symbols(before: &Document, doc: &mut Document) { /// groups too: the instances of the symbols in `natural` (`ids`), and the objects whose opacity /// mask art holds such instances (`masked`). fn changed_instances(before: &[Arc], after: &[Arc], natural: &HashMap, ids: &mut Vec, masked: &mut Vec) { - let mut by_id: Option>> = None; - for (i, a) in after.iter().enumerate() { - let b = match before.get(i) { - Some(b) if b.id == a.id => Some(b), - _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&a.id).copied(), - }; - if b.is_some_and(|b| Arc::ptr_eq(b, a)) { - continue; - } + for (_, a, b) in changed_nodes(before, after) { if a.extras().mask.as_ref().is_some_and(|m| holds_instance(&m.art, natural)) { masked.push(a.id); } @@ -423,15 +415,7 @@ pub(crate) fn keep_aligned_in(doc: &mut Document, ids: &[NodeId]) { /// pixel-aligned or hold pixel-aligned art in a linked opacity mask. Inside such an object the /// walk stops: [`keep_pixel_aligned`] visits what it holds. fn changed_aligned(before: &[Arc], after: &[Arc], out: &mut Vec) { - let mut by_id: Option>> = None; - for (i, a) in after.iter().enumerate() { - let b = match before.get(i) { - Some(b) if b.id == a.id => Some(b), - _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&a.id).copied(), - }; - if b.is_some_and(|b| Arc::ptr_eq(b, a)) { - continue; - } + for (_, a, b) in changed_nodes(before, after) { if a.extras().pixel_aligned || a.extras().mask.as_ref().is_some_and(|m| m.linked && holds_aligned(&m.art)) { out.push(a.id); } else if let Some(children) = a.children() { diff --git a/crates/engine/src/cmd/objects_on_path.rs b/crates/engine/src/cmd/objects_on_path.rs index 7dc8aec1c9..299ed5f49c 100644 --- a/crates/engine/src/cmd/objects_on_path.rs +++ b/crates/engine/src/cmd/objects_on_path.rs @@ -25,12 +25,12 @@ //! the objects squared to the path; Pivot and Rotate; path edits realign the objects; Detach and //! the objects that move up the path after it; Expand). -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_doc::objects_on_path::{CENTER, Held, ObjectsOnPath, attachable_path, held, is_objects_on_path, place}; -use vectorcraft_doc::{Document, Node, NodeId, NodeKind}; +use vectorcraft_doc::{Document, Node, NodeId, NodeKind, changed_nodes}; use vectorcraft_geom::Rect; use super::edit::{roots_of, selected_roots}; @@ -499,15 +499,7 @@ fn place_in(doc: &mut Document, id: NodeId) -> bool { /// The Objects on Path groups among `after` and inside them that are not the same nodes as before /// (`before`: the same list before the edit), outer ones first. fn changed_groups(before: &[Arc], after: &[Arc], out: &mut Vec) { - let mut by_id: Option>> = None; - for (i, a) in after.iter().enumerate() { - let b = match before.get(i) { - Some(b) if b.id == a.id => Some(b), - _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&a.id).copied(), - }; - if b.is_some_and(|b| Arc::ptr_eq(b, a)) { - continue; - } + for (_, a, b) in changed_nodes(before, after) { if is_objects_on_path(a) { out.push(a.id); } diff --git a/crates/engine/src/cmd/shaper.rs b/crates/engine/src/cmd/shaper.rs index 228251fa13..93e479033f 100644 --- a/crates/engine/src/cmd/shaper.rs +++ b/crates/engine/src/cmd/shaper.rs @@ -6,12 +6,9 @@ use super::{ CommandSpec, EngineError, Result, Session, bad, bool_or, checked_ids_param, cmd, f64_or, has_doc, id_param, number_or, object_param, point_param, }; use serde_json::{Value, json}; -use std::{ - collections::{BTreeMap, HashMap}, - sync::Arc, -}; +use std::{collections::BTreeMap, sync::Arc}; use vectorcraft_doc::shaper::{EdgeEdit, FILL_PREFIX, FaceEdit, FaceSelector, SOURCES, STROKE_PREFIX, ShaperSpec}; -use vectorcraft_doc::{Appearance, AppearanceItem, Document, Node, NodeId, NodeKind}; +use vectorcraft_doc::{Appearance, AppearanceItem, Document, Node, NodeId, NodeKind, changed_nodes}; use vectorcraft_geom::{FillRule, PathData, Point, Rect, Shape as _}; use vectorcraft_pathops as po; use vectorcraft_tools::builder::{self as b, BuilderMap}; @@ -392,15 +389,7 @@ fn generated(d: &mut Document, src: &[Arc], spec: &ShaperSpec, map: &Build } fn changed_shaper_groups(before: &[Arc], after: &[Arc], out: &mut Vec) { - let mut by_id: Option>> = None; - for (i, a) in after.iter().enumerate() { - let b = match before.get(i) { - Some(b) if b.id == a.id => Some(b), - _ => by_id.get_or_insert_with(|| before.iter().map(|b| (b.id, b)).collect()).get(&a.id).copied(), - }; - if b.is_some_and(|b| Arc::ptr_eq(b, a)) { - continue; - } + for (_, a, b) in changed_nodes(before, after) { if a.extras().shaper.is_some() { out.push(a.id); } From 8f3709ce6ec4dc00100b799074fdd5db39585ca1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 13:36:49 -0800 Subject: [PATCH 143/264] Menus: a new window keymap sets the panel rows' shortcuts without a rebuild The window builds its first keymap after the first frame's menus, and the menu model's key held the keymap's address, so the next refresh built the whole model again with nothing else changed. Only the Window menu's panel rows and the Settings rows read their shortcuts from the keymap (Build::decorate). refresh now compares a key without the keymap (rows_key) and keeps the keymap's address on its own. When only the keymap changed, it sets the shortcuts of those rows again and lays the bar out again, leaving the rows' states and the catalog as they were. state_key, which the native menu sync, Help search and the Properties panel read, still holds the keymap. The rows key also holds the user's shortcut set, which the catalog's rows are made from. --- crates/ui-egui/src/menus/model.rs | 136 +++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index fffff70049..6913942fd8 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -40,9 +40,15 @@ pub(crate) struct Menus { /// The pass number of the last frame with a pointer button or a key press ([`pressed_pass`]), `None` before the /// first: the `input` of [`state_key`]. pressed: Option, + /// The address of the window's keymap that the panel rows took their shortcuts from ([`keymap_addr`]), `None` + /// before the window has one. + keymap: Option, /// How many times [`refresh`] built the model. #[cfg(test)] pub(crate) rebuilds: u64, + /// How many times [`refresh`] set the keymap's shortcuts again without building the model ([`refresh_shortcuts`]). + #[cfg(test)] + pub(crate) shortcut_refreshes: u64, /// The menus as built, before a layout. pub(crate) bar: MenuBar, /// `bar` laid out for the shell's target: what the in-window bar shows. @@ -90,14 +96,22 @@ pub(crate) fn translate_label(english: &'static str) -> String { /// doesn't list (panels shown, a tool picked). While an /// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's /// preview, or a typing session), the revision, which each of its previews changes, is left out: -/// the hash changes as the interaction begins and as it ends. +/// the hash changes as the interaction begins and as it ends. The window's keymap, which the shown +/// shortcuts are read from, is in the hash too. pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { + let mut h = DefaultHasher::new(); + (rows_key(app, input), keymap_addr(app)).hash(&mut h); + h.finish() +} + +/// [`state_key`] without the window's keymap: what the model's rows are built from. A new keymap alone changes only +/// the shortcuts of the rows that read it, which [`refresh`] sets again without a rebuild ([`refresh_shortcuts`]). +fn rows_key(app: &VectorcraftApp, input: Option) -> u64 { let mut h = DefaultHasher::new(); input.hash(&mut h); app.run_count.hash(&mut h); - // The window's keymap, which the panel rows read their shortcuts from (`Build::decorate`): the framework builds it - // after the first frame's menus, and builds a new one when the bindings or the catalog change. - app.ui_ctx.as_ref().and_then(craft::ui::runtime::commands::keymap).map(|k| std::sync::Arc::as_ptr(&k).addr()).hash(&mut h); + // The user's shortcuts, which the catalog's rows are made from. + std::sync::Arc::as_ptr(&app.shortcut_overrides).addr().hash(&mut h); let s = &app.session; (s.journal.len(), s.active_index(), s.clipboard.is_empty(), s.tool_composing()).hash(&mut h); if let Some(d) = s.active() { @@ -126,12 +140,19 @@ pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { } /// Brings the menus up to date once per frame, before the frame's input: the model is built again -/// when the rows' state ([`state_key`]) or the shell's target changed. +/// when the rows' state ([`rows_key`]) or the shell's target changed. When only the window's keymap +/// changed (the framework builds the first one after the first frame's menus), the rows that read +/// their shortcuts from it get them again ([`refresh_shortcuts`]). pub(crate) fn refresh(app: &mut VectorcraftApp, ctx: &egui::Context) { let target = Target::of_shell(&WindowHost::of(ctx).shell()); let press = last_press(app, ctx); - let key = state_key(app, press); + let key = rows_key(app, press); + let keymap = keymap_addr(app); if app.menus.key == Some(key) && app.menus.target == Some(target) { + if app.menus.keymap != keymap { + refresh_shortcuts(app, target); + app.menus.keymap = keymap; + } return; } rebuild(app, target); @@ -141,6 +162,54 @@ pub(crate) fn refresh(app: &mut VectorcraftApp, ctx: &egui::Context) { } app.menus.key = Some(key); app.menus.target = Some(target); + app.menus.keymap = keymap; +} + +/// The address of the window's keymap, which the panel rows read their shortcuts from ([`reads_keymap`]): the framework +/// builds it after the first frame's menus, and builds a new one when the bindings or the catalog change. +fn keymap_addr(app: &VectorcraftApp) -> Option { + app.ui_ctx.as_ref().and_then(craft::ui::runtime::commands::keymap).map(|k| std::sync::Arc::as_ptr(&k).addr()) +} + +/// Whether the row running `id` with `params` shows a shortcut read from the window's keymap ([`Build::decorate`]). +fn reads_keymap(id: &str, params: &Value) -> bool { + matches!(id, "window.panel" | "edit.preferences") && !params.is_null() +} + +/// Sets the shortcuts of the rows that read the window's keymap ([`reads_keymap`]) again and lays the bar out again. +/// The rows' states and the catalog stay as the last rebuild made them. +fn refresh_shortcuts(app: &mut VectorcraftApp, target: Target) { + fn walk(app: &VectorcraftApp, nodes: &mut [Node]) { + for node in nodes { + match node { + Node::Item(item) if reads_keymap(&item.command.id, &item.command.params) => { + let shortcut = super::labels::item_shortcut(app, &item.command.id, &item.command.params); + item.shortcut = shortcut; + } + Node::Submenu { children, .. } => walk(app, children), + _ => {} + } + } + } + let mut bar = std::mem::take(&mut app.menus.bar); + for menu in &mut bar.menus { + walk(app, &mut menu.children); + } + app.menus.bar = bar; + lay_out(app, target); + #[cfg(test)] + { + app.menus.shortcut_refreshes += 1; + } +} + +/// Lays `app.menus.bar` out for `target` into `app.menus.laid`, which is edited only when the laid-out bar differs. +fn lay_out(app: &mut VectorcraftApp, target: Target) { + let options = LayoutOptions::new(APP_NAME).label(&translate_label); + let laid = layout(&app.menus.bar, target, &options).bar; + if *app.menus.laid != laid { + app.menus.laid.edit(|l| *l = laid); + } } /// The pass number of the last frame with a pointer button pressed or released or a key pressed, the frame `ctx` read @@ -294,14 +363,9 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) { row_states(app, &rows, &mut states); crate::panels::panel_menu_states(app, &mut states); - let bar = MenuBar::new(menus); - let options = LayoutOptions::new(APP_NAME).label(&translate_label); - let laid = layout(&bar, target, &options).bar; app.menus.rows = Some(rows); - app.menus.bar = bar; - if *app.menus.laid != laid { - app.menus.laid.edit(|l| *l = laid); - } + app.menus.bar = MenuBar::new(menus); + lay_out(app, target); app.menus.states.edit(|s| *s = states); } @@ -597,7 +661,7 @@ impl Build<'_> { // A panel row shows the chord of the panel's shortcut (`panel:`), which binds `window.panel {panel}`; // a Window row runs it with `toggle: true`, so the framework finds no chord for the row's own command. // Settings' first page shows Preferences' shortcut, which binds `edit.preferences` with no page. - "window.panel" | "edit.preferences" if !params.is_null() => { + _ if reads_keymap(id, params) => { let mut item = item; item.shortcut = super::labels::item_shortcut(self.app, id, params); item @@ -658,6 +722,50 @@ mod tests { assert!(app.menus.states.get(&CommandRef::new("object.group")).is_some_and(CommandState::is_enabled)); } + /// A new window keymap with nothing else changed (the framework builds the first one after the first frame's + /// menus) sets the panel rows' shortcuts from it, in the bar and in the laid-out bar, without building the menus + /// again. + #[test] + fn a_new_keymap_alone_sets_the_shortcuts_without_a_rebuild() { + fn clear(nodes: &mut [Node]) { + for node in nodes { + match node { + Node::Item(item) if reads_keymap(&item.command.id, &item.command.params) => item.shortcut = None, + Node::Submenu { children, .. } => clear(children), + _ => {} + } + } + } + fn panel_chords(bar: &MenuBar) -> usize { + bar.items() + .into_iter() + .filter(|it| it.command.id == "window.panel" && it.command.params["toggle"] == true && it.shortcut.is_some()) + .count() + } + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({})).unwrap(); + let ctx = crate::testing::ui_context(); + for _ in 0..2 { + crate::testing::app_frame(&mut app, &ctx, egui::RawInput::default()); + } + let shown = panel_chords(&app.menus.bar); + assert!(shown > 0, "the panel rows show their shortcuts' chords"); + // The menus as a refresh before the window's keymap leaves them. + app.menus.keymap = None; + for menu in &mut app.menus.bar.menus { + clear(&mut menu.children); + } + app.menus.laid.edit(|laid| laid.menus.iter_mut().for_each(|menu| clear(&mut menu.children))); + let (rebuilds, refreshes) = (app.menus.rebuilds, app.menus.shortcut_refreshes); + refresh(&mut app, &ctx); + assert_eq!(app.menus.rebuilds, rebuilds, "a new keymap alone does not build the menus again"); + assert_eq!(app.menus.shortcut_refreshes, refreshes + 1, "the new keymap sets the shortcuts"); + assert_eq!(panel_chords(&app.menus.bar), shown, "the panel rows show their chords again"); + assert_eq!(panel_chords(&app.menus.laid), shown, "the laid-out bar shows them too"); + refresh(&mut app, &ctx); + assert_eq!((app.menus.rebuilds, app.menus.shortcut_refreshes), (rebuilds, refreshes + 1), "the same keymap sets nothing again"); + } + /// A rebuild asks each dimmed row's command once whether it can run, for its state and its reason together. #[test] fn a_rebuild_checks_each_dimmed_row_once() { From 8e31fb06de54a46257000024823e59f1363efdf3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 13:47:59 -0800 Subject: [PATCH 144/264] Properties: idle frames replay the Document sections' bodies With nothing selected, the Properties panel laid out the bodies of its Document, Rulers & Grids, Guides, Snap Options, Preferences and Quick Actions sections again in every frame. Each body now shows in a MemoView keyed on what it reads: the units, the artboard count, the snap settings, the keyboard increment and its unit, Scale Strokes & Effects and the interface language. A change in the command state of one of its buttons runs it again. The Units choice, the snap checkboxes and the preference edits come back through an Outbox and run after the section, as before. The section headers and the Appearance section still run in every frame. The new test counts the body runs: none over 10 idle frames, and runs again after a command changes what one shows. --- .../panels/properties/document_sections.rs | 311 ++++++++++++++---- 1 file changed, 251 insertions(+), 60 deletions(-) diff --git a/crates/ui-egui/src/panels/properties/document_sections.rs b/crates/ui-egui/src/panels/properties/document_sections.rs index e8c14ba4dd..4774bdb750 100644 --- a/crates/ui-egui/src/panels/properties/document_sections.rs +++ b/crates/ui-egui/src/panels/properties/document_sections.rs @@ -1,10 +1,10 @@ //! The Properties panel's Document sections, shown with nothing selected. -use craft::behavior::IconId; +use craft::behavior::{EditEvent, IconId}; use craft::keymap::CommandRef; use craft::ui::buttons::{Button, ToggleButton}; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _, Sizing}; +use craft::ui::contract::{Bind, Entry, MemoProps, MemoView, Outbox, Props as _, Show as _, ShowContainer as _, Sizing}; use craft::ui::form::Field; use craft::ui::layout_components::{Grid, Row}; use craft::ui::pickers::Select; @@ -17,84 +17,212 @@ use vectorcraft_doc::Unit; use super::artboard_sections::rearrange_button; use super::object_sections::HALVES; use crate::VectorcraftApp; +use crate::edits::EditPath; use crate::panels::transform; /// The panel with nothing selected: the document's units, Document Setup and artboards, the /// Appearance fill and stroke, the view's rulers, grids, guides and snapping, the keyboard /// increment and Scale Strokes & Effects, and Quick Actions. +/// +/// The body of every section but Appearance shows in a `MemoView` keyed on what it reads, so a +/// frame that changes none of it replays the body. What a body picks comes back through an `Outbox` +/// and runs after its section. pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { + let lang = crate::i18n::current(); let units = app.session.general_unit(); + let unit = Unit::ALL.iter().position(|u| *u == units).unwrap_or(usize::MAX); let artboards = app.session.active().map_or(0, |d| d.doc.artboards.len()); + let mut picked_units = Vec::new(); super::section(tl!("Document")).show(ui, |ui, _| { - Field::new(tl!("Units")).show(ui, |ui, _| { - let entries: Vec> = Unit::ALL.iter().map(|u| Entry::new(*u, u.label())).collect(); - let out = Select::new(tl!("Units"), Bind::given(units), &entries).show(ui); - if let Some(u) = out.events.committed() { - app.run("document.setUnits", json!({ "units": u.label() })).ok(); - } - }); - Grid::new(&HALVES).show(ui, |ui, _| { - Button::command(CommandRef::new("file.documentSetup")).label(tl!("Document Setup")).sizing(Sizing::FillWidth).show(ui); - Button::command(CommandRef::with_params("tool.select", json!({ "tool": "artboard" }))) - .label(tl!("Edit Artboards")) - .sizing(Sizing::FillWidth) - .show(ui); - if artboards > 1 { - rearrange_button(ui, artboards); - } - }); + let document = DocumentProps { unit, units, artboards, lang, picked: Outbox::new(&mut picked_units) }; + let _ = MemoView::new("properties-document", document, document_body).show(ui); }); + if let Some(u) = picked_units.pop() { + app.run("document.setUnits", json!({ "units": u.label() })).ok(); + } super::section(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui)); super::section(tl!("Rulers & Grids")).show(ui, |ui, _| { - Row::new().show(ui, |ui, _| { - // The checked and enabled states and the tooltips come from the commands (Trim View turns the grid off). - for (command, icon) in [("view.rulers", "ruler"), ("view.grid", "grid-3x3"), ("view.transparencyGrid", "square-dashed")] { - ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui); - } - }); + let _ = MemoView::new("properties-rulers", Language { lang }, rulers_body).show(ui); }); super::section(tl!("Guides")).show(ui, |ui, _| { - Row::new().show(ui, |ui, _| { - for (command, icon) in [("view.guides", "layout-grid"), ("view.smartGuides", "sparkles")] { - ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui); - } - }); + let _ = MemoView::new("properties-guides", Language { lang }, guides_body).show(ui); }); + let mut snaps = Vec::new(); + let (point, grid) = (app.ui.view.snap_to_point, app.ui.view.snap_to_grid); super::section(tl!("Snap Options")).show(ui, |ui, _| { - let (point, grid) = (app.ui.view.snap_to_point, app.ui.view.snap_to_grid); - for (command, label, on) in [("view.snapToPoint", tl!("Snap to Point"), point), ("view.snapToGrid", tl!("Snap to Grid"), grid)] { - if Checkbox::new(Bind::given(on)).label(label).show(ui).value().is_some() { - app.run(command, json!({})).ok(); - } - } + let snap = SnapProps { point, grid, lang, picked: Outbox::new(&mut snaps) }; + let _ = MemoView::new("properties-snap", snap, snap_body).show(ui); }); + for command in snaps { + app.run(command, json!({})).ok(); + } + let mut prefs = Vec::new(); + let (increment, scale) = (app.session.prefs.keyboard_increment, app.session.prefs.scale_strokes); + let (bare_points, lengths) = (app.session.prefs.numbers_without_units_are_points, crate::canvas::rulers::general_lengths(app)); super::section(tl!("Preferences")).show(ui, |ui, _| { - Field::new(tl!("Keyboard Increment")).show(ui, |ui, _| { - // PLAN: assumed `canvas::rulers::general_lengths(app) -> LengthUnits` (cv.B5b) - let lengths: LengthUnits = crate::canvas::rulers::general_lengths(app); - // The engine's own range for the preference (`prefscmds.rs`): a larger value is an error. - let out = NumberField::length(tl!("Keyboard Increment"), Bind::given(Some(app.session.prefs.keyboard_increment)), lengths) - .range(0.001..=1296.0) - .show(ui); - crate::edits::apply_edits(app, &out.edit, crate::edits::EditPath::Scope, |app, v: &Option, _| { - if let Some(value) = *v { - app.run("prefs.set", json!({ "key": "keyboardIncrement", "value": value })).ok(); - } - }); - }); - let scale = app.session.prefs.scale_strokes; - let out = Checkbox::new(Bind::given(scale)).label(tl!("Scale Strokes & Effects")).show(ui); - if let Some(on) = out.value().copied() { - transform::set_pref(app, "scaleStrokes", on); + let picked = Outbox::new(&mut prefs); + let preferences = PreferencesProps { increment, unit, bare_points, lengths, scale, lang, picked }; + let _ = MemoView::new("properties-preferences", preferences, preferences_body).show(ui); + }); + for pick in prefs { + match pick { + PreferencePick::Increment(event) => { + crate::edits::apply_event(app, &event, &EditPath::Scope, &mut |app, v: &Option, _| { + if let Some(value) = *v { + app.run("prefs.set", json!({ "key": "keyboardIncrement", "value": value })).ok(); + } + }); + } + PreferencePick::ScaleStrokes(on) => transform::set_pref(app, "scaleStrokes", on), + } + } + super::section(tl!("Quick Actions")).show(ui, |ui, _| { + let _ = MemoView::new("properties-quick-actions", Language { lang }, quick_actions_body).show(ui); + }); +} + +/// What a section that reads only command states reads besides them: the interface language of its labels. +#[derive(MemoProps)] +struct Language { + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, +} + +/// What the Document section reads: the document's units and how many artboards it has. +#[derive(MemoProps)] +struct DocumentProps<'a> { + /// The index of `units` in [`Unit::ALL`]. + unit: usize, + #[memo_props(covered_by = "unit", reason = "the unit's index in Unit::ALL")] + units: Unit, + /// How many artboards the document has (Rearrange All shows for more than one). + artboards: usize, + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, + /// The units chosen in the Units menu. + picked: Outbox<'a, Unit>, +} + +/// The Document section's body: Units, Document Setup, Edit Artboards and Rearrange All. +fn document_body(p: &mut DocumentProps<'_>, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + Field::new(tl!("Units")).show(ui, |ui, _| { + let entries: Vec> = Unit::ALL.iter().map(|u| Entry::new(*u, u.label())).collect(); + let out = Select::new(tl!("Units"), Bind::given(p.units), &entries).show(ui); + if let Some(u) = out.events.committed() { + p.picked.send(*u); } }); - super::section(tl!("Quick Actions")).show(ui, |ui, _| { - Grid::new(&HALVES).show(ui, |ui, _| { - // The reference panel's buttons name the dialog without the menu's ellipsis. - for (command, label) in [("file.documentSetup", tl!("Document Setup")), ("edit.preferences", tl!("Preferences"))] { - Button::command(CommandRef::new(command)).label(label).sizing(Sizing::FillWidth).show(ui); - } - }); + Grid::new(&HALVES).show(ui, |ui, _| { + Button::command(CommandRef::new("file.documentSetup")).label(tl!("Document Setup")).sizing(Sizing::FillWidth).show(ui); + Button::command(CommandRef::with_params("tool.select", json!({ "tool": "artboard" }))) + .label(tl!("Edit Artboards")) + .sizing(Sizing::FillWidth) + .show(ui); + if p.artboards > 1 { + rearrange_button(ui, p.artboards); + } + }); +} + +/// The Rulers & Grids section's body. The checked and enabled states and the tooltips come from the commands (Trim +/// View turns the grid off). +fn rulers_body(_: &mut Language, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + Row::new().show(ui, |ui, _| { + for (command, icon) in [("view.rulers", "ruler"), ("view.grid", "grid-3x3"), ("view.transparencyGrid", "square-dashed")] { + ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui); + } + }); +} + +/// The Guides section's body: Show Guides and Smart Guides, from their commands. +fn guides_body(_: &mut Language, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + Row::new().show(ui, |ui, _| { + for (command, icon) in [("view.guides", "layout-grid"), ("view.smartGuides", "sparkles")] { + ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui); + } + }); +} + +/// What the Snap Options section reads: whether Snap to Point and Snap to Grid are on. +#[derive(MemoProps)] +struct SnapProps<'a> { + point: bool, + grid: bool, + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, + /// The command of each checkbox clicked. + picked: Outbox<'a, &'static str>, +} + +/// The Snap Options section's body: Snap to Point and Snap to Grid. +fn snap_body(p: &mut SnapProps<'_>, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + for (command, label, on) in [("view.snapToPoint", tl!("Snap to Point"), p.point), ("view.snapToGrid", tl!("Snap to Grid"), p.grid)] { + if Checkbox::new(Bind::given(on)).label(label).show(ui).value().is_some() { + p.picked.send(command); + } + } +} + +/// What the Preferences section reads: the keyboard increment in the General unit, and Scale Strokes & Effects. +#[derive(MemoProps)] +struct PreferencesProps<'a> { + /// The keyboard increment, in points. + increment: f64, + /// The index of the General unit in [`Unit::ALL`]. + unit: usize, + /// Numbers without units are points (Preferences › Units). + bare_points: bool, + #[memo_props(covered_by = "unit", reason = "made from the General unit and bare_points alone (canvas::rulers::lengths)")] + lengths: LengthUnits, + /// Scale Strokes & Effects is on. + scale: bool, + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, + /// The keyboard increment's edits and the Scale Strokes & Effects choice. + picked: Outbox<'a, PreferencePick>, +} + +/// What the Preferences section reports: an edit of the keyboard increment, or Scale Strokes & Effects turned on or +/// off. +enum PreferencePick { + Increment(EditEvent>), + ScaleStrokes(bool), +} + +/// The Preferences section's body: Keyboard Increment and Scale Strokes & Effects. +fn preferences_body(p: &mut PreferencesProps<'_>, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + Field::new(tl!("Keyboard Increment")).show(ui, |ui, _| { + // The engine's own range for the preference (`prefscmds.rs`): a larger value is an error. + let out = NumberField::length(tl!("Keyboard Increment"), Bind::given(Some(p.increment)), p.lengths).range(0.001..=1296.0).show(ui); + for event in out.edit.events.iter() { + p.picked.send(PreferencePick::Increment(event.clone())); + } + }); + let out = Checkbox::new(Bind::given(p.scale)).label(tl!("Scale Strokes & Effects")).show(ui); + if let Some(on) = out.value().copied() { + p.picked.send(PreferencePick::ScaleStrokes(on)); + } +} + +/// The Quick Actions section's body: Document Setup and Preferences. The reference panel's buttons name the dialog +/// without the menu's ellipsis. +fn quick_actions_body(_: &mut Language, ui: &mut Ui) { + #[cfg(test)] + tests::count_run(); + Grid::new(&HALVES).show(ui, |ui, _| { + for (command, label) in [("file.documentSetup", tl!("Document Setup")), ("edit.preferences", tl!("Preferences"))] { + Button::command(CommandRef::new(command)).label(label).sizing(Sizing::FillWidth).show(ui); + } }); } @@ -104,6 +232,19 @@ mod tests { use crate::tests::panel_harness::Panel; use craft::ui::contract::Role; + thread_local! { + /// How many times this thread ran a memoized Document section. + static SECTION_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; + } + + pub(super) fn count_run() { + SECTION_RUNS.with(|n| n.set(n.get() + 1)); + } + + fn runs() -> u64 { + SECTION_RUNS.with(std::cell::Cell::get) + } + #[test] fn canceling_the_units_popup_leaves_the_document_unchanged() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); @@ -135,4 +276,54 @@ mod tests { assert_eq!(panel.app().session.active().unwrap().doc.units, next, "Enter applies the chosen document unit"); assert_eq!(panel.app().session.general_unit(), next); } + + /// Frames that change nothing the sections show replay them instead of laying them out again. A change one of + /// them reads, from a command run elsewhere, runs it again, and it shows the change. + #[test] + fn idle_frames_replay_the_document_sections() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let mut panel = Panel::new(app, document_sections); + panel.room(egui::vec2(400.0, 1000.0)); + panel.frame(); + panel.frame(); + let before = runs(); + for _ in 0..10 { + panel.frame(); + } + assert_eq!(runs() - before, 0, "idle frames run the memoized sections no more"); + let point = panel.app().ui.view.snap_to_point; + panel.app().run("view.snapToPoint", json!({})).unwrap(); + panel.frame(); + panel.frame(); + assert!(runs() > before, "a new snap setting runs the sections again"); + assert_eq!(panel.app().ui.view.snap_to_point, !point); + assert_eq!(panel.toggled("Snap to Point"), Some(craft::behavior::Mixed::Same(!point)), "and the checkbox shows it"); + panel.app().run("view.rulers", json!({})).unwrap(); + let mut per_frame = Vec::new(); + for _ in 0..12 { + let at = runs(); + panel.frame(); + per_frame.push(runs() - at); + } + // A toggled button animates over the next frames, and a section runs while an animation in it has not ended. + assert_eq!(per_frame[6..], [0; 6], "idle frames after a command run them no more: {per_frame:?}"); + } + + /// The memoized sections still take input: a click on Snap to Grid turns it on, once, and Scale Strokes & Effects + /// sets its preference. + #[test] + fn the_memoized_sections_run_their_picks() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let grid = app.ui.view.snap_to_grid; + let scale = app.session.prefs.scale_strokes; + let mut panel = Panel::new(app, document_sections); + panel.room(egui::vec2(400.0, 1000.0)); + panel.frame(); + panel.click("Snap to Grid"); + assert_eq!(panel.app().ui.view.snap_to_grid, !grid, "the click toggles Snap to Grid once"); + panel.click("Scale Strokes & Effects"); + assert_eq!(panel.app().session.prefs.scale_strokes, !scale); + } } From d3e02f41a18d29e51628c13ba70769c8d8009f1e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 13:52:49 -0800 Subject: [PATCH 145/264] Performance: Properties rows read a large selection once per edit After an edit the selection keeps no record of its paints, so the Fill and Stroke chips and the Stroke and Width Profile rows looked up the groups around every selected object for Live Paint faces and edges each time they were drawn. DocState::live_paint_covered_kept keeps an empty answer for that version of the document and those objects. The Recolor quick action listed and sorted every color of the selection to see whether it held more than one. Session::several_colors_used reads the same objects and pattern tiles and stops at the second color. --- crates/engine/src/cmd.rs | 3 + crates/engine/src/cmd/paint.rs | 5 +- crates/engine/src/cmd/paint/tests.rs | 52 +++++++++ crates/engine/src/cmd/recolor.rs | 133 ++++++++++++++++++++++++ crates/engine/src/doc_state.rs | 34 ++++++ crates/ui-egui/src/panels/properties.rs | 8 +- 6 files changed, 229 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 43d6e3a7d4..3641f82d6b 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -874,6 +874,9 @@ pub(crate) use vectorcraft_doc::range::parse_range; /// What the fill and stroke proxies read from the selected objects, kept with the selection /// ([`crate::doc_state::SelectionRecord`]). pub(crate) use paint::SelectionPaints; +/// The faces and edges of Live Paint groups among objects that count with their group +/// ([`crate::DocState::live_paint_covered_kept`] keeps an empty answer). +pub(crate) use paint::live_paint_covered; #[cfg(test)] pub(crate) use paint::{PAINTS_READ, WEIGHTS_READ}; diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index c722e2a58b..2a61f7fb74 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -1470,12 +1470,13 @@ fn in_live_paint(d: &Document, id: NodeId) -> bool { impl DocState { /// [`live_paint_covered`] for `ids`, the selected objects or the selection's subjects: none - /// when the [`SelectionPaints`] of the selection say no selected object is in a Live Paint group. + /// when the [`SelectionPaints`] of the selection say no selected object is in a Live Paint group, + /// else as [`DocState::live_paint_covered_kept`] keeps it for this version of the document. pub(crate) fn selection_live_paint_covered(&self, ids: &[NodeId]) -> std::collections::HashSet { if self.selection_paints().is_some_and(|p| !p.in_live_paint()) { return std::collections::HashSet::new(); } - live_paint_covered(&self.doc, ids) + self.live_paint_covered_kept(ids) } } diff --git a/crates/engine/src/cmd/paint/tests.rs b/crates/engine/src/cmd/paint/tests.rs index ec8f02f700..9b0fb393df 100644 --- a/crates/engine/src/cmd/paint/tests.rs +++ b/crates/engine/src/cmd/paint/tests.rs @@ -242,6 +242,58 @@ fn the_question_marks_read_only_the_selected_objects() { assert!(vectorcraft_doc::tree_walks() - walks <= 1, "one walk for a large selection"); } +/// How many times this thread read the groups around selected objects for their Live Paint faces +/// and edges ([`DocState::live_paint_covered_kept`]). +fn cover_reads() -> usize { + crate::doc_state::LIVE_PAINT_COVER_READS.with(Cell::get) +} + +/// After an edit the selection keeps no record of what it holds, and the proxies, the Stroke panel +/// and the "?" ask on every frame whether its objects lie in a Live Paint group. They read the +/// objects' groups once for each version of the document and selection, not once for each question. +/// A Live Paint group selected with one of its faces still counts the face with its group. +#[test] +fn live_paint_faces_are_looked_for_once_per_document_version() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 600})).unwrap(); + let ids: Vec = (0..20).map(|i| rect(&mut s, 10.0 + 30.0 * f64::from(i), "#ff0000", "#000000")).collect(); + s.execute("select.all", &json!({})).unwrap(); + s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap(); + assert!(s.active().unwrap().selection_paints().is_none(), "the edit leaves the selection without a record"); + let ask = |s: &Session| { + for _ in 0..3 { + s.proxy_paints(); + s.shown_stroke(); + s.proxy_mixed(); + s.active().unwrap().stroke_mixed(); + } + }; + let before = cover_reads(); + ask(&s); + assert_eq!(cover_reads() - before, 1, "one read for this version of the document"); + s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap(); + let before = cover_reads(); + ask(&s); + assert_eq!(cover_reads() - before, 1, "an edit reads them again, once"); + s.execute("select.set", &json!({"ids": [ids[0].0, ids[1].0]})).unwrap(); + s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap(); + let before = cover_reads(); + ask(&s); + assert_eq!(cover_reads() - before, 1, "another selection reads them again, once"); + + // A Live Paint group with one of its edges selected too: the edge counts with its group on every ask. + s.execute("livePaint.make", &json!({"ids": [ids[2].0, ids[3].0]})).unwrap(); + let group = s.active().unwrap().selection.objects[0]; + let edge = vectorcraft_tools::builder::edges(s.active().unwrap().doc.node(group).unwrap())[0].id; + s.execute("select.set", &json!({"ids": [group.0, edge.0]})).unwrap(); + let st = s.active().unwrap(); + let covered = live_paint_covered(&st.doc, &st.selection.objects); + assert!(covered.contains(&edge)); + for _ in 0..2 { + assert_eq!(st.selection_live_paint_covered(&st.selection.objects), covered); + } +} + /// Random selections of a document with nested groups answer as a walk does. #[test] fn random_selections_match_a_walk_of_the_document() { diff --git a/crates/engine/src/cmd/recolor.rs b/crates/engine/src/cmd/recolor.rs index b4ad26400b..174f90ecb0 100644 --- a/crates/engine/src/cmd/recolor.rs +++ b/crates/engine/src/cmd/recolor.rs @@ -1027,6 +1027,76 @@ fn used_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet>) -> used.into_iter().map(|(_, u)| u).collect() } +#[cfg(test)] +thread_local! { + /// Tests: how many objects [`several_colors`] read on this thread. + static SEVERAL_COLORS_READS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Whether [`used_colors`] lists more than one color for the objects `ids`. The objects are read +/// until a second color turns up. +fn several_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet>) -> bool { + struct Seen<'a> { + first: Option, + several: bool, + patterns: Vec<&'a str>, + } + impl<'a> Seen<'a> { + fn read(&mut self, m: &'a Node) { + #[cfg(test)] + SEVERAL_COLORS_READS.with(|c| c.set(c.get() + 1)); + let (first, several) = (&mut self.first, &mut self.several); + paints( + m, + &mut |c, _, _, _| { + let k = ColorKey::of(c); + match first { + None => *first = Some(k), + Some(f) => *several |= *f != k, + } + }, + &mut self.patterns, + ); + } + fn read_tree(&mut self, n: &'a Node, only: Option<&BTreeSet>) { + if self.several || only.is_some_and(|o| !o.contains(&n.id)) { + return; + } + self.read(n); + for c in n.children().into_iter().flatten() { + self.read_tree(c, only); + } + } + } + let mut seen = Seen { first: None, several: false, patterns: vec![] }; + for n in ids.iter().filter_map(|id| d.node(*id)) { + seen.read_tree(n, only); + } + let mut next = 0; + while !seen.several + && let Some(&name) = seen.patterns.get(next) + { + next += 1; + for a in d.pattern(name).map(|def| def.art.as_slice()).unwrap_or_default() { + a.walk(&mut |m| { + if !seen.several { + seen.read(m); + } + }); + } + } + seen.several +} + +impl Session { + /// Whether the objects `recolor.colors` reads without `ids` use more than one color: the + /// selection, or with nothing selected the objects Select All takes. False without a document. + pub fn several_colors_used(&self) -> bool { + let Ok((ids, only)) = scope_ids(self, &Value::Null, "recolor.colors") else { return false }; + self.doc().is_ok_and(|st| several_colors(&st.doc, &ids, only.as_ref())) + } +} + /// Count the colors `m` holds itself with `count` (the color, its swatch, the tint the paint /// stores, and whether it is a gradient stop that mixes the swatch's ink with process inks), and /// add the patterns it is painted with to `patterns`. @@ -2050,6 +2120,69 @@ mod tests { assert!(has(&t, RED), "P100 read again at the top"); } + /// How many objects [`several_colors`] read on this thread. + fn several_reads() -> usize { + SEVERAL_COLORS_READS.with(std::cell::Cell::get) + } + + /// Whether more than one color is used ([`Session::several_colors_used`]), checked against the + /// length of `recolor.colors`'s list, with how many objects the answer read. + fn several(s: &mut Session, what: &str) -> (bool, usize) { + let before = several_reads(); + let several = s.several_colors_used(); + let reads = several_reads() - before; + let listed = s.execute("recolor.colors", &json!({})).unwrap()["colors"].as_array().map_or(0, Vec::len); + assert_eq!(several, listed > 1, "{what}: {listed} colors listed"); + (several, reads) + } + + /// The Recolor quick action asks on every change whether the selection uses more than one + /// color. The answer matches `recolor.colors`, pattern tiles and Select All's objects included, + /// and the objects are read only until a second color turns up. + #[test] + fn several_colors_stop_at_the_second_color() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 600})).unwrap(); + let ids: Vec = (0..30) + .map(|i| { + let id = + s.execute("shape.rectangle", &json!({"x": 10 + 20 * i, "y": 10, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap(); + s.execute("paint.setFill", &json!({"ids": [id], "color": "#ff0000"})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [id], "none": true})).unwrap(); + id + }) + .collect(); + s.execute("select.all", &json!({})).unwrap(); + assert_eq!(several(&mut s, "one red"), (false, 30), "one color: every object is read"); + // A blue object in the middle: the objects are read up to it, from either end. + s.execute("paint.setFill", &json!({"ids": [ids[15]], "color": "#0000ff"})).unwrap(); + let (found, reads) = several(&mut s, "a blue in the middle"); + assert!(found && matches!(reads, 15 | 16), "{reads} objects read"); + s.execute("paint.setFill", &json!({"ids": [ids[0], ids[29]], "color": "#00ff00"})).unwrap(); + assert_eq!(several(&mut s, "green at both ends"), (true, 2), "the second object holds the second color"); + s.execute("select.set", &json!({"ids": &ids[1..15]})).unwrap(); + assert!(!several(&mut s, "the red ones").0); + s.execute("select.none", &json!({})).unwrap(); + assert!(several(&mut s, "Select All's objects").0); + + // A red object filled with a pattern too: its tile's color counts. + for (tile, expect) in [(BLUE, true), (RED, false)] { + let filled = NodeId(ids[1]); + s.edit("t", |d, _| { + let art = square(d, 0.0, Paint::solid(tile)); + d.patterns.retain(|p| p.name != "Tile"); + d.patterns.push(PatternDef::new("Tile", vec![art])); + if let Some(n) = d.node_mut(filled) { + n.appearance.set_fill(Paint::Pattern { pattern: "Tile".into(), xf: Affine::IDENTITY }); + } + Ok(()) + }) + .unwrap(); + s.execute("select.set", &json!({"ids": [ids[1], ids[2]]})).unwrap(); + assert_eq!(several(&mut s, "a pattern tile").0, expect, "a tile of {tile:?}"); + } + } + /// A pattern tile's symbol instances charge the same limit as the art around it. #[test] fn pattern_tiles_charge_the_symbol_limit() { diff --git a/crates/engine/src/doc_state.rs b/crates/engine/src/doc_state.rs index e1bb6df83a..8307b6a8b1 100644 --- a/crates/engine/src/doc_state.rs +++ b/crates/engine/src/doc_state.rs @@ -203,6 +203,18 @@ pub struct DocState { /// The selected objects as [`crate::Session::select`] last checked them or the proxies last /// read them, with the document they were checked in ([`SelectionRecord`]). Not saved. pub(crate) selection_record: Option, + /// The objects that [`DocState::live_paint_covered_kept`] last found no face or edge of a Live + /// Paint group among, with the document it read. Not saved. + outside_live_paint: std::cell::RefCell>, +} + +/// Objects that hold no face or edge of a Live Paint group that counts with its group +/// ([`cmd::live_paint_covered`] is empty for them), with the document they were read in, held as +/// [`EmptyArtboards::doc`] holds it. +#[derive(Clone, Debug)] +struct OutsideLivePaint { + doc: std::sync::Weak, + ids: Vec, } /// A selection of objects alone ([`objects_only`]) with the document it was checked or read in: @@ -302,6 +314,8 @@ thread_local! { pub(crate) static EMPTY_ARTBOARD_MEASURES: std::cell::Cell = const { std::cell::Cell::new(0) }; /// Tests: how many times [`DocState::any_art_to_fit`] measured a document on this thread. pub(crate) static ART_TO_FIT_MEASURES: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// Tests: how many times [`DocState::live_paint_covered_kept`] read the objects' groups on this thread. + pub(crate) static LIVE_PAINT_COVER_READS: std::cell::Cell = const { std::cell::Cell::new(0) }; } static NEXT_DOC_UID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); @@ -522,6 +536,7 @@ impl DocState { measured_in_own: None, inline_resolved: None, selection_record: None, + outside_live_paint: Default::default(), } } /// The [`SelectionRecord`] of the selection now: `None` when the document or the selected @@ -539,6 +554,25 @@ impl DocState { pub(crate) fn selection_paints(&self) -> Option<&cmd::SelectionPaints> { self.selection_record().and_then(|r| r.paints.as_ref()) } + /// The faces and edges of Live Paint groups among `ids` that count with their group + /// ([`cmd::live_paint_covered`]). An empty answer is kept for this version of the document and + /// these objects, so the proxies and the Stroke panel, which ask on every frame, read the + /// objects' groups once after an edit. + pub(crate) fn live_paint_covered_kept(&self, ids: &[NodeId]) -> std::collections::HashSet { + let kept = |k: &OutsideLivePaint| std::ptr::eq(k.doc.as_ptr(), Arc::as_ptr(&self.doc)) && k.ids == ids; + if self.outside_live_paint.try_borrow().is_ok_and(|k| k.as_ref().is_some_and(kept)) { + return std::collections::HashSet::new(); + } + #[cfg(test)] + LIVE_PAINT_COVER_READS.with(|c| c.set(c.get() + 1)); + let covered = cmd::live_paint_covered(&self.doc, ids); + if covered.is_empty() + && let Ok(mut k) = self.outside_live_paint.try_borrow_mut() + { + *k = Some(OutsideLivePaint { doc: Arc::downgrade(&self.doc), ids: ids.to_vec() }); + } + covered + } /// Keep the [`SelectionRecord`] of the selection that [`crate::Session::select`] left, with /// Lock Guides `guides_locked`. `record` is the record of the selection before, in the same /// document: the objects that leave the selection are taken out of its paints and the objects diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs index 7e3caa1a43..b137711d0d 100644 --- a/crates/ui-egui/src/panels/properties.rs +++ b/crates/ui-egui/src/panels/properties.rs @@ -291,8 +291,9 @@ fn can_merge_live_paint(app: &VectorcraftApp) -> bool { }) } -/// Whether the selection uses more than one colour (`recolor.colors`), which offers the Recolor -/// quick action; memoised per document revision. +/// Whether the selection uses more than one colour (`recolor.colors` lists more than one, +/// [`vectorcraft_engine::Session::several_colors_used`]), which offers the Recolor quick action; +/// memoised per document revision. pub(crate) fn multi_color(app: &mut VectorcraftApp) -> bool { let Some(st) = app.session.active() else { return false }; let key = (st.uid, st.revision); @@ -301,8 +302,7 @@ pub(crate) fn multi_color(app: &mut VectorcraftApp) -> bool { { return multi; } - let r = app.session.execute("recolor.colors", &json!({})).unwrap_or_default(); - let multi = r["colors"].as_array().is_some_and(|c| c.len() > 1); + let multi = app.session.several_colors_used(); app.canvas.multi_color = Some((key, multi)); multi } From 867a6788e467a5b3fd5d09f7a5431d8c91ec05e4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:03:38 -0800 Subject: [PATCH 146/264] Tests: a held stored load waits for the test instead of a yield count HeldLoad in the plug-in tests held a stored module's load for at most 1,000,000 yield_now calls and then let it go on its own. On a busy test host that limit passed before the test released it, so the held file loaded early: a_grant_given_elsewhere_since_the_load_removed_one_is_kept and a_stored_module_without_permissions_ends_its_grant_when_it_installs failed in a full engine run and passed alone. - The hook now waits on a condition variable that release() and the drop set. A load that runs on the test's own thread is not held and sets gave_up, so a load that is no longer in the background still fails the test instead of hanging it. - stored_plugins_load_without_holding_the_plugin_changes_lock waited at most 100,000 yields for the plug-in changes lock to be free; it now waits until it is free. - canceled_loads_forget_the_grants_of_what_they_installed releases the held load before canceling, since cancel waits for a running load up to its 10 second deadline. - a_query_runs_while_the_plugins_load checks which commands wait for the loads before it runs document.info. --- crates/engine/src/tests/plugins.rs | 48 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index 6cd51a5a1d..4ecff31b3b 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -2347,29 +2347,35 @@ static STORED_HOOK: std::sync::Mutex<()> = std::sync::Mutex::new(()); struct HeldLoad { _lock: std::sync::MutexGuard<'static, ()>, entered: std::sync::Arc, - go: std::sync::Arc, + go: std::sync::Arc<(std::sync::Mutex, std::sync::Condvar)>, gave_up: std::sync::Arc, } impl HeldLoad { - /// Holds the load of the file at `path`. A load the test never lets go gives up after a - /// million yields (so a test of code that waits for it ends) and says so in `gave_up`. + /// Holds the load of the file at `path` until [`HeldLoad::release`] or the drop. A load that + /// runs on the thread that made this one is not held, since nothing could let it go: it goes + /// ahead at once and says so in `gave_up`. fn new(path: std::path::PathBuf) -> HeldLoad { - use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; + use std::sync::{Arc, Condvar, Mutex}; let lock = STORED_HOOK.lock().unwrap_or_else(|e| e.into_inner()); - let (entered, go, gave_up) = (Arc::new(AtomicBool::new(false)), Arc::new(AtomicBool::new(false)), Arc::new(AtomicBool::new(false))); + let (entered, gave_up) = (Arc::new(AtomicBool::new(false)), Arc::new(AtomicBool::new(false))); + let go = Arc::new((Mutex::new(false), Condvar::new())); let (e, g, q) = (entered.clone(), go.clone(), gave_up.clone()); + let test_thread = std::thread::current().id(); *crate::store::BEFORE_STORED_LOAD.lock().unwrap_or_else(|e| e.into_inner()) = Some(Arc::new(move |p: &std::path::Path| { if p != path { return; } e.store(true, Ordering::SeqCst); - if !(0..1_000_000).any(|_| { - std::thread::yield_now(); - g.load(Ordering::SeqCst) - }) { + if std::thread::current().id() == test_thread { q.store(true, Ordering::SeqCst); + return; + } + let (open, opened) = &*g; + let mut open = open.lock().unwrap_or_else(|e| e.into_inner()); + while !*open { + open = opened.wait(open).unwrap_or_else(|e| e.into_inner()); } })); HeldLoad { _lock: lock, entered, go, gave_up } @@ -2380,7 +2386,9 @@ impl HeldLoad { } fn release(&self) { - self.go.store(true, std::sync::atomic::Ordering::SeqCst); + let (open, opened) = &*self.go; + *open.lock().unwrap_or_else(|e| e.into_inner()) = true; + opened.notify_all(); } fn gave_up(&self) -> bool { @@ -2904,6 +2912,7 @@ fn a_folder_queued_behind_the_stored_plugins_replaces_one_with_its_id() { #[test] fn a_query_runs_while_the_plugins_load() { let id = "test.engine.background.query"; + assert!(crate::waits_for_plugin_loads("plugin.list") && !crate::waits_for_plugin_loads("document.info")); let (folder, path) = store_with("plugin-background-query", id); let held = HeldLoad::new(path); let mut s = session(); @@ -2917,7 +2926,6 @@ fn a_query_runs_while_the_plugins_load() { let waited = held.gave_up() || !s.plugins_loading(); held.release(); assert!(!waited, "document.info waited for the plug-ins to load"); - assert!(crate::waits_for_plugin_loads("plugin.list") && !crate::waits_for_plugin_loads("document.info")); s.finish_plugin_loads(); assert!(vectorcraft_plugins::registry::remove(id)); } @@ -2935,18 +2943,14 @@ fn stored_plugins_load_without_holding_the_plugin_changes_lock() { while !held.entered() && !held.gave_up() { std::thread::yield_now(); } - // Other tests take the lock for a moment; the load holding it would hold it throughout (a - // tenth of the yields the held load waits before it gives up). - let free = (0..100_000).any(|_| { + // A load run on this thread isn't held, so a free lock then shows nothing. + assert!(!held.gave_up(), "the module loaded on the test's thread"); + // Other tests take the lock for a moment; the held load holding it would hold it until it is let go. + while !crate::cmd::plugin::plugin_changes_free() { std::thread::yield_now(); - crate::cmd::plugin::plugin_changes_free() - }); - // A load that gave up waiting no longer holds anything, so a free lock then shows nothing. - let gave_up = held.gave_up(); + } held.release(); s.finish_plugin_loads(); - assert!(!gave_up, "the held load gave up before the lock was looked at"); - assert!(free, "the lock was held while the module loaded"); assert!(vectorcraft_plugins::registry::remove(id)); } @@ -2974,6 +2978,10 @@ fn canceled_loads_forget_the_grants_of_what_they_installed() { std::thread::yield_now(); } assert!(vectorcraft_plugins::registry::get(first).is_some(), "the first module installed while the second loads"); + assert!(s.plugins_loading(), "the second module is still loading"); + // Canceling waits for a running load until its deadline; the second module, let go, loads + // while the cancel runs or before it, and doesn't install either way. + held.release(); s.cancel_plugin_loads(); // The file goes once it holds no grant. let listed: Vec = std::fs::read(&grants).map(|b| serde_json::from_slice(&b).unwrap()).unwrap_or_default(); From 389fc65631585c575f7caf75be99177ecd5d3277 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:09:19 -0800 Subject: [PATCH 147/264] Canvas: a move of the selection moves its marks instead of building them again The canvas kept the selection's outlines, anchors and dots only while the document revision stayed the same, so every move command, nudge and drag step built them again from every selected object. With 10,000 selected rectangles one build took about 26 ms in a release build. A move of whole objects now records the documents before and after it and the distance (DocState::moved). The record is made only when each moved object is still the node the transform left (no later pass, such as the pixel grid snap, changed it), none is a member of a blend, and every object the selection shows, the key object and the key anchor's object included, is a moved object or inside one. Copies, scales, moves of patterns alone and moves that resize type areas make no record. The canvas moves its kept marks by that distance when the record names the document they show, or the document a drag began with. It also keeps them through a new revision of the same document and selection, as at the end of a drag. Every other change builds them as before. --- crates/engine/src/cmd/object/transform.rs | 56 +++++++- crates/engine/src/doc_state.rs | 19 +++ crates/engine/src/lib.rs | 2 +- crates/engine/src/tests.rs | 1 + crates/engine/src/tests/moved.rs | 127 +++++++++++++++++++ crates/ui-egui/src/canvas/selection.rs | 95 ++++++++++++-- crates/ui-egui/src/canvas/selection/tests.rs | 72 +++++++++++ 7 files changed, 359 insertions(+), 13 deletions(-) create mode 100644 crates/engine/src/tests/moved.rs diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index 1a15e44aa3..c86bd4c792 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -192,7 +192,11 @@ fn apply_transform_moving_guides( if copy { vec![] } else { ids } } else { let kept = if copy { preview_copies(s, &ids, with_guides, below)? } else { None }; - s.edit(label, |d, sel| { + // A move of whole objects, not of copies (which `reindex` covers): the document before it, + // and the moved objects as the transform left them, for [`moved_by`] to check after the edit. + let from = (objects && !areas && !reindex && c[..4] == [1.0, 0.0, 0.0, 1.0]).then(|| s.doc().map(|st| st.doc.clone())).transpose()?; + let mut held: Vec<(NodeId, Arc)> = vec![]; + let targets = s.edit(label, |d, sel| { let mut targets = match &kept { // The document becomes the snapshot with the kept copies, untransformed, and the // loop below transforms only the copies. @@ -229,6 +233,10 @@ fn apply_transform_moving_guides( transform_node(n, xf, sc, objects); } } + // Holding them makes any later change to them copy them first, which `moved_by` sees. + if from.is_some() { + held = targets.iter().filter_map(|id| Some((*id, node_arc(d, paths.get(id)?)?))).collect(); + } if objects { for id in &targets { super::pixelgrid::keep_compound_aligned(d, *id, sc); @@ -248,7 +256,10 @@ fn apply_transform_moving_guides( targets.extend(d.transform_ruler_guides(sel, xf)); } Ok(targets) - })? + })?; + let st = s.doc_mut()?; + st.moved = from.and_then(|from| moved_by(&from, st, &held, Vec2::new(c[4], c[5]))); + targets }; let st = s.doc_mut()?; if st.interaction.is_none() { @@ -266,6 +277,47 @@ fn apply_transform_moving_guides( Ok(json!({ "ids": ids.iter().map(|i| i.0).collect::>() })) } +/// The node at index path `path` of `d`, shared. +fn node_arc(d: &Document, path: &[usize]) -> Option> { + let (first, rest) = path.split_first()?; + let mut cur = d.layers.get(*first)?; + for &i in rest { + cur = cur.children()?.get(i)?; + } + Some(cur.clone()) +} + +/// The [`crate::Moved`] of a move by `by` that took `from` to the document of `st`, given the moved +/// objects as the transform left them (`held`). `None` unless every moved object is still that +/// node, none is a member of a blend (whose spine follows its members), and every object the +/// selection shows, the key object and the key anchor's object included, is a moved object or +/// inside one. A pass after the transform that changes a moved object, such as the one that snaps +/// moved pixel-aligned objects to the pixel grid again ([`super::pixelgrid::refresh`]), copies it +/// first, so it is no longer that node. +fn moved_by(from: &Arc, st: &crate::DocState, held: &[(NodeId, Arc)], by: Vec2) -> Option { + let d = &st.doc; + let unchanged = |(id, n): &(NodeId, Arc)| d.node(*id).is_some_and(|now| std::ptr::eq(now, Arc::as_ptr(n))); + if held.is_empty() || !held.iter().all(unchanged) { + return None; + } + let in_blend = |id: NodeId| d.parent_of(id).and_then(|p| d.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Blend { .. })); + if held.iter().any(|(id, _)| in_blend(*id)) { + return None; + } + let mut moved = std::collections::HashSet::new(); + for (_, n) in held { + n.walk(&mut |c| { + moved.insert(c.id); + }); + } + let sel = &st.selection; + let mut shown = sel.objects.iter().copied().chain(sel.key).chain(sel.key_anchor.map(|(id, _)| id)); + if !shown.all(|id| moved.contains(&id)) { + return None; + } + Some(crate::Moved { from: Arc::downgrade(from), to: Arc::downgrade(d), by, selection: sel.clone() }) +} + /// Returns the copies of `roots` for a transform or a perspective edit with `copy` in an interaction /// whose document is still its snapshot, as in a preview ([`Session::preview`] puts the snapshot /// back first). These are the copies the interaction keeps when they were made of that snapshot for diff --git a/crates/engine/src/doc_state.rs b/crates/engine/src/doc_state.rs index e1bb6df83a..39be553eb6 100644 --- a/crates/engine/src/doc_state.rs +++ b/crates/engine/src/doc_state.rs @@ -203,6 +203,24 @@ pub struct DocState { /// The selected objects as [`crate::Session::select`] last checked them or the proxies last /// read them, with the document they were checked in ([`SelectionRecord`]). Not saved. pub(crate) selection_record: Option, + /// The last move of the selected objects that changed nothing else they show ([`Moved`]). + /// Not saved. + pub moved: Option, +} + +/// A move of whole objects that took document `from` to document `to`: each object the selection +/// shows, the key object and the key anchor included, is the one in `from` moved by `by`, and +/// nothing else they are drawn from changed (no member snapped to the pixel grid, no blend spine +/// they follow, no pass after the edit). A view that drew the selection of `from` can +/// move what it drew by `by` instead of building it again. It holds the documents as +/// [`SelectionRecord::doc`] holds one, so a document changed in place no longer matches. +#[derive(Clone, Debug)] +pub struct Moved { + pub from: std::sync::Weak, + pub to: std::sync::Weak, + pub by: vectorcraft_geom::Vec2, + /// The selection the move was made with, which is also the selection after it. + pub selection: Selection, } /// A selection of objects alone ([`objects_only`]) with the document it was checked or read in: @@ -522,6 +540,7 @@ impl DocState { measured_in_own: None, inline_resolved: None, selection_record: None, + moved: None, } } /// The [`SelectionRecord`] of the selection now: `None` when the document or the selected diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 48964aad0c..3e132c5f9e 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -507,7 +507,7 @@ pub(crate) use command_sets::SELECTS_GIVEN_IDS; #[cfg(test)] use command_sets::given_ids; pub use command_sets::{DRAWS_SHAPE, FIT_ACTIVE_ARTBOARD, ON_ACTIVE_ARTBOARD, waits_for_plugin_loads, waits_for_tool_edit}; -pub use doc_state::{DocState, LayersReveal, OpenRows, RecalledSelection, WindowView}; +pub use doc_state::{DocState, LayersReveal, Moved, OpenRows, RecalledSelection, WindowView}; pub use error::{EngineError, READ_ONLY_LOCATION, Result, SCRIPT_BUSY}; #[cfg(test)] use history::history_budget_for; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 9e3cf2371e..89f74fd03d 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -118,6 +118,7 @@ mod livecorners; mod maskview; pub(super) mod menucmds; mod mesh_picks; +mod moved; mod nativefile; mod newart; mod newdoc; diff --git a/crates/engine/src/tests/moved.rs b/crates/engine/src/tests/moved.rs new file mode 100644 index 0000000000..1b70d4acf8 --- /dev/null +++ b/crates/engine/src/tests/moved.rs @@ -0,0 +1,127 @@ +//! [`DocState::moved`]: a move of whole objects names the documents before and after it and how far +//! it went, and only when every object the selection shows is the one before it, moved that far. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_geom::Vec2; + +use crate::*; + +fn session() -> Session { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + s +} + +fn id_of(v: &Value) -> NodeId { + NodeId(v["id"].as_u64().unwrap()) +} + +fn rect(s: &mut Session, x: f64) -> NodeId { + id_of(&s.execute("shape.rectangle", &json!({"x": x, "y": 20, "width": 30, "height": 20})).unwrap()) +} + +fn select(s: &mut Session, ids: &[NodeId]) { + s.execute("select.set", &json!({"ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); +} + +fn doc(s: &Session) -> Arc { + s.doc().unwrap().doc.clone() +} + +/// The move [`DocState::moved`] names, when it took `from` to the document now. +fn moved_from(s: &Session, from: &Arc) -> Option { + let st = s.doc().unwrap(); + let m = st.moved.as_ref()?; + (m.from.as_ptr() == Arc::as_ptr(from) && m.to.as_ptr() == Arc::as_ptr(&st.doc) && m.selection == st.selection).then_some(m.by) +} + +// A move of the selection, a nudge and each step of a drag name the move; the drag's steps all start from the +// document the drag began with. +#[test] +fn a_move_of_whole_objects_names_the_documents_and_the_distance() { + let mut s = session(); + let (a, b) = (rect(&mut s, 20.0), rect(&mut s, 80.0)); + select(&mut s, &[a, b]); + let before = doc(&s); + s.execute("object.move", &json!({"dx": 12, "dy": -5})).unwrap(); + assert_eq!(moved_from(&s, &before), Some(Vec2::new(12.0, -5.0)), "Object › Transform › Move"); + let before = doc(&s); + s.execute("object.nudge", &json!({"dx": 1, "dy": 0})).unwrap(); + assert_eq!(moved_from(&s, &before), Some(Vec2::new(s.prefs.keyboard_increment, 0.0)), "a nudge"); + + let start = doc(&s); + s.begin_interaction("Move").unwrap(); + for dx in [3.0, 7.5] { + s.preview("object.transform", &json!({"matrix": [1, 0, 0, 1, dx, 2], "copy": false})).unwrap(); + assert_eq!(moved_from(&s, &start), Some(Vec2::new(dx, 2.0)), "a drag's step by {dx}"); + } +} + +// A copy, a transform that is not a move, a move of patterns alone, a move that also resizes type areas, and a move +// of part of what the selection shows name no move. +#[test] +fn a_copy_a_scale_and_a_move_of_part_of_the_selection_name_no_move() { + let mut s = session(); + let (a, b) = (rect(&mut s, 20.0), rect(&mut s, 80.0)); + select(&mut s, &[a, b]); + let cases = [ + ("object.move", json!({"dx": 12, "dy": 0, "copy": true})), + ("object.transform", json!({"matrix": [2, 0, 0, 1, 0, 0]})), + ("object.move", json!({"dx": 12, "dy": 0, "objects": false, "patterns": true})), + ("object.move", json!({"dx": 12, "dy": 0, "typeAreas": true})), + ("object.transform", json!({"matrix": [1, 0, 0, 1, 5, 0], "ids": [a.0]})), + ]; + for (cmd, p) in cases { + select(&mut s, &[a, b]); + let before = doc(&s); + s.execute(cmd, &p).unwrap(); + assert_eq!(moved_from(&s, &before), None, "{cmd} {p}"); + } +} + +// The key object is shown too: a move that leaves it where it was names no move. +#[test] +fn a_key_object_left_where_it_was_names_no_move() { + let mut s = session(); + let (a, b) = (rect(&mut s, 20.0), rect(&mut s, 80.0)); + select(&mut s, &[a]); + s.active_mut().unwrap().selection.key = Some(b); + let before = doc(&s); + s.execute("object.move", &json!({"dx": 12, "dy": 0})).unwrap(); + assert_eq!(moved_from(&s, &before), None); +} + +// A pixel-aligned path snaps to the pixel grid after the transform, and an instance of a symbol aligned to the pixel +// grid snaps after the edit: neither is the object before the move moved by its distance. +#[test] +fn objects_that_snap_to_the_pixel_grid_name_no_move() { + let mut s = session(); + let a = rect(&mut s, 20.0); + select(&mut s, &[a]); + s.execute("object.setPixelAligned", &json!({"on": true})).unwrap(); + let before = doc(&s); + s.execute("object.move", &json!({"dx": 0.3, "dy": 0})).unwrap(); + assert_eq!(moved_from(&s, &before), None, "a pixel-aligned path"); + + let mut s = session(); + let art = rect(&mut s, 20.0); + let made = s.execute("symbol.new", &json!({"name": "Box", "ids": [art.0], "alignToPixelGrid": true})).unwrap(); + select(&mut s, &[id_of(&made)]); + let before = doc(&s); + s.execute("object.move", &json!({"dx": 0.3, "dy": 0})).unwrap(); + assert_eq!(moved_from(&s, &before), None, "an instance of a symbol aligned to the pixel grid"); +} + +// A member of a blend moved on its own changes the blend's spine. +#[test] +fn a_member_of_a_blend_names_no_move() { + let mut s = session(); + let (a, b) = (rect(&mut s, 20.0), rect(&mut s, 200.0)); + s.execute("object.blend.make", &json!({"ids": [a.0, b.0], "steps": 1})).unwrap(); + select(&mut s, &[a]); + let before = doc(&s); + s.execute("object.move", &json!({"dx": 12, "dy": 0})).unwrap(); + assert_eq!(moved_from(&s, &before), None); +} diff --git a/crates/ui-egui/src/canvas/selection.rs b/crates/ui-egui/src/canvas/selection.rs index e0ac7e7aee..dd2b85fcca 100644 --- a/crates/ui-egui/src/canvas/selection.rs +++ b/crates/ui-egui/src/canvas/selection.rs @@ -5,6 +5,7 @@ use std::collections::HashMap; use std::collections::hash_map::{DefaultHasher, Entry}; use std::hash::{Hash, Hasher}; +use std::sync::{Arc, Weak}; use craft::behavior::Input; use craft::behavior::Metrics; @@ -18,9 +19,9 @@ use craft::ui::canvas_controls::{HoverOutline, HoverShape, SelectionOutline}; use craft::ui::contract::{Access, Bind, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role, Show as _}; use craft::ui::style::{ComponentStyle, DataColor, StyleCx}; use egui::{Color32, Rect, Response, Shape, Stroke, StrokeKind, vec2}; -use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_doc::{Document, NodeId, NodeKind}; use vectorcraft_engine::{DocState, Prefs, ViewInfo}; -use vectorcraft_geom::{AnchorKind, BezPath, PathData, PathEl, Point}; +use vectorcraft_geom::{AnchorKind, BezPath, PathData, PathEl, Point, Vec2}; use vectorcraft_tools::Mods; use super::cursor::ViewKey; @@ -632,9 +633,13 @@ pub(super) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSp HoverOutline::new("Object highlight", Some(HoverShape::Path(h.path))).color(DataColor::new(h.color)).show_at(ui, rect); } let key = marks_key(app, st, tool, tool_points); + let view = view_key(app, st, tool, tool_points); let marks = match app.canvas.selection_marks.take() { Some(kept) if kept.key == key => kept, - _ => SelectionMarks::build(app, st, tool, tool_points, key), + Some(kept) if kept.view == view && kept.selection == st.selection => { + kept.follow(st, key).unwrap_or_else(|| SelectionMarks::build(app, st, tool, tool_points, (key, view))) + } + _ => SelectionMarks::build(app, st, tool, tool_points, (key, view)), }; for o in &marks.outlines { let mut outline = SelectionOutline::solid("Selection", &o.paths).color(DataColor::new(o.color)).revision(o.revision); @@ -663,29 +668,99 @@ pub(super) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSp } /// The outlines, anchors and dots `show` draws, kept between passes while their [`marks_key`] stays: a frame with -/// nothing changed walks no selected object. +/// nothing changed walks no selected object. They are also kept while the document and the selection stay the same +/// under another revision, and moved with the selection when a move ([`vectorcraft_engine::Moved`]) took the document +/// they show to the one now. pub(crate) struct SelectionMarks { key: u64, + /// [`view_key`] of the state they were made for. + view: u64, + /// The selection they show. + selection: vectorcraft_doc::Selection, + /// The document they show. + doc: Weak, + /// A document they show moved by a distance: the one they were built for and no distance, or the document the + /// last move they followed started from and its distance. Each step of a drag starts from the document the drag + /// began with ([`SelectionMarks::follow`]). + from: (Weak, Vec2), outlines: Vec, anchors: Anchors, dots: Dots, } impl SelectionMarks { - fn build(app: &VectorcraftApp, st: &DocState, tool: &str, tool_points: bool, key: u64) -> Self { + fn build(app: &VectorcraftApp, st: &DocState, tool: &str, tool_points: bool, (key, view): (u64, u64)) -> Self { #[cfg(test)] tests::MARKS_BUILT.with(|built| built.set(built.get() + 1)); - Self { key, outlines: outlines(app, st), anchors: anchors(app, st, tool, tool_points), dots: dots(app, st) } + let doc = Arc::downgrade(&st.doc); + Self { + key, + view, + selection: st.selection.clone(), + from: (doc.clone(), Vec2::ZERO), + doc, + outlines: outlines(app, st), + anchors: anchors(app, st, tool, tool_points), + dots: dots(app, st), + } + } + + /// The marks of `st`, whose [`marks_key`] is `key`, from these marks of the same selection and view: these marks + /// when `st` shows the same document, these marks moved by `st`'s move when it took the document they show, or the + /// document of [`SelectionMarks::from`], to the one `st` shows, else `None`. + fn follow(mut self, st: &DocState, key: u64) -> Option { + let now = Arc::as_ptr(&st.doc); + if self.doc.as_ptr() != now { + let moved = st.moved.as_ref().filter(|m| m.to.as_ptr() == now && m.selection == st.selection)?; + let by = if moved.from.ptr_eq(&self.doc) { + moved.by + } else if moved.from.ptr_eq(&self.from.0) { + moved.by - self.from.1 + } else { + return None; + }; + self.translate(by); + self.from = (moved.from.clone(), moved.by); + self.doc = moved.to.clone(); + } + self.key = key; + Some(self) + } + + /// Moves every mark by `by`. + fn translate(&mut self, by: Vec2) { + let shift = vectorcraft_geom::Affine::translate(by); + for o in &mut self.outlines { + o.paths.iter_mut().chain(o.key.as_mut()).for_each(|path| path.apply_affine(shift)); + o.revision = outline_revision(&o.paths, o.key.as_ref(), o.color.to_array()); + } + for knot in self.anchors.paths.iter_mut().flat_map(|p| &mut p.subpaths).flat_map(|sp| &mut sp.knots) { + knot.anchor += by; + knot.in_ctrl += by; + knot.out_ctrl += by; + } + let dots = &mut self.dots; + for (at, _) in dots.origins.iter_mut().chain(&mut dots.centers).chain(&mut dots.key_anchor) { + *at += by; + } } } -/// What the selection's marks are built from: the document and its selection (its uid and revision), the parts the -/// view hides, Halftone Preview, the tool whose marks show, whether that tool draws its own points, and the -/// Selection & Anchor Display preferences. +/// What the selection's marks are built from: the document and its selection (its uid and revision), and what +/// [`view_key`] hashes. fn marks_key(app: &VectorcraftApp, st: &DocState, tool: &str, tool_points: bool) -> u64 { + let mut h = DefaultHasher::new(); + (st.revision, view_key(app, st, tool, tool_points)).hash(&mut h); + h.finish() +} + +/// What the selection's marks are built from besides the document's content and the selection: the document (its +/// uid), the parts the view hides, Halftone Preview, the tool whose marks show, whether that tool draws its own points, +/// and the Selection & Anchor Display preferences. +fn view_key(app: &VectorcraftApp, st: &DocState, tool: &str, tool_points: bool) -> u64 { let mut h = DefaultHasher::new(); let hides = ViewHides::of(app); - (st.uid, st.revision, hides.templates, hides.guides, hidden(app), tool, tool_points).hash(&mut h); + (st.uid, hides.templates, hides.guides, hidden(app), tool, tool_points).hash(&mut h); let prefs = &app.session.prefs; (prefs.anchor_size, prefs.show_handles_multiple_anchors, prefs.handle_style.as_str()).hash(&mut h); h.finish() diff --git a/crates/ui-egui/src/canvas/selection/tests.rs b/crates/ui-egui/src/canvas/selection/tests.rs index 672b07094a..e413a5655c 100644 --- a/crates/ui-egui/src/canvas/selection/tests.rs +++ b/crates/ui-egui/src/canvas/selection/tests.rs @@ -918,3 +918,75 @@ fn the_canvas_builds_the_selection_marks_once_per_change() { app.select_tool("directSelection"); assert_eq!(frames(&mut app, 5), 1, "another tool builds the marks once"); } + +/// Every point of the outlines, the anchors and their handles, and the dots, in order. +fn points_of(outlines: &[Outlined], anchors: &Anchors, dots: &Dots) -> Vec { + let mut out = vec![]; + for path in outlines.iter().flat_map(|o| o.paths.iter().chain(&o.key)) { + for el in path.elements() { + match *el { + PathEl::MoveTo(a) | PathEl::LineTo(a) => out.push(a), + PathEl::QuadTo(a, b) => out.extend([a, b]), + PathEl::CurveTo(a, b, c) => out.extend([a, b, c]), + PathEl::ClosePath => {} + } + } + } + for knot in anchors.paths.iter().flat_map(|p| &p.subpaths).flat_map(|sp| &sp.knots) { + out.extend([knot.anchor, knot.in_ctrl, knot.out_ctrl]); + } + out.extend(dots.origins.iter().chain(&dots.centers).chain(&dots.key_anchor).map(|(at, _)| *at)); + out +} + +/// Whether the marks the canvas keeps are, to rounding, the ones the builders give for the state now. +fn kept_marks_are_current(app: &VectorcraftApp) -> bool { + let kept = app.canvas.selection_marks.as_ref().expect("the canvas drew the selection's marks"); + let st = app.session.active().unwrap(); + let now = points_of(&outlines(app, st), &anchors(app, st, app.session.tool_id(), false), &dots(app, st)); + let was = points_of(&kept.outlines, &kept.anchors, &kept.dots); + now.len() == was.len() && now.iter().zip(&was).all(|(a, b)| (*a - *b).hypot() < 1e-9) +} + +// Whole-app frames keep the selection's marks through a new revision of the same document and selection, and move +// them with a move of the selection instead of building them: a move command, each step of a drag, and the drag's end +// build nothing and keep the marks of the state now. A scale and an undo still build them once. +#[test] +fn a_move_of_the_selection_moves_its_marks_without_building_them() { + let (mut app, _) = scene(); + let ctx = crate::testing::ui_context(); + let frames = |app: &mut VectorcraftApp, n: usize| { + let before = MARKS_BUILT.with(std::cell::Cell::get); + for _ in 0..n { + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 850.0)); + crate::testing::app_frame(app, &ctx, egui::RawInput { screen_rect: Some(screen), ..Default::default() }); + } + MARKS_BUILT.with(std::cell::Cell::get) - before + }; + frames(&mut app, 3); + let layer = app.session.active().unwrap().doc.layers[0].id; + let revision = app.session.active().unwrap().revision; + app.run("layer.setCurrent", json!({"id": layer.0})).unwrap(); + assert_ne!(app.session.active().unwrap().revision, revision, "a new revision"); + assert_eq!(frames(&mut app, 3), 0, "a new revision of the same document and selection"); + app.run("object.move", json!({"dx": 12.25, "dy": -5})).unwrap(); + assert_eq!(frames(&mut app, 3), 0, "a move command"); + assert!(kept_marks_are_current(&app), "after a move command"); + + app.session.begin_interaction("Move").unwrap(); + for dx in [3.0, 7.5, -2.0] { + app.session.preview("object.transform", &json!({"matrix": [1, 0, 0, 1, dx, 4], "copy": false})).unwrap(); + assert_eq!(frames(&mut app, 2), 0, "a drag's step by {dx}"); + assert!(kept_marks_are_current(&app), "after a drag's step by {dx}"); + } + app.session.commit_interaction().unwrap(); + assert_eq!(frames(&mut app, 2), 0, "the drag's end"); + assert!(kept_marks_are_current(&app), "after the drag"); + + app.run("object.transform", json!({"matrix": [2, 0, 0, 1, 0, 0]})).unwrap(); + assert_eq!(frames(&mut app, 3), 1, "a scale"); + assert!(kept_marks_are_current(&app), "after a scale"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(frames(&mut app, 3), 1, "an undo"); + assert!(kept_marks_are_current(&app), "after an undo"); +} From 4bee2eef9cacb5582ed1621cc2849ea74b796de6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:09:54 -0800 Subject: [PATCH 148/264] Properties: a selection change draws the window in one pass When the selection changed, the Properties panel placed its sections by the sizes kept from the last selection, measured the new ones while drawing, and asked for the frame to be discarded and drawn again. Every selection change and the release of a move then drew the canvas and the other panels twice. The panel now shows the inspector's Panel itself and, when the document, its revision, the selection, the tool or isolation mode changed since the last frame, measures its sections with `measure_in` before showing them, so the first pass places them at their new sizes. Field ids and the scroll position stay keyed by the document as before. Selections that add labeled rows still ask for a second pass for the rows' baselines until the craft-libs pin includes craft-libs#4311. --- crates/ui-egui/src/panels/properties.rs | 40 +++++++++++-- crates/ui-egui/src/panels/properties/tests.rs | 60 +++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs index 7e3caa1a43..c1b6f36d94 100644 --- a/crates/ui-egui/src/panels/properties.rs +++ b/crates/ui-egui/src/panels/properties.rs @@ -1,13 +1,13 @@ //! The Properties panel: sections that change with the selection. -use craft::behavior::{ColumnWidth, IconId}; +use craft::behavior::{ColumnWidth, IconId, Proposal}; use craft::ui::buttons::{Button, IconButton}; -use craft::ui::contract::{LabelScheme, Props as _, Show as _, ShowContainer as _}; +use craft::ui::contract::{BodyCx, LabelScheme, Pad, Props as _, Show as _, ShowContainer as _}; use craft::ui::layout_components::{Grid, Row, Stack}; use craft::ui::patterns::panels::Inspector; use craft::ui::runtime::commands::CommandRef; -use craft::ui::sections::HeaderStrength; +use craft::ui::sections::{HeaderStrength, Panel}; use egui::Ui; use serde_json::json; use vectorcraft_doc::{LiveShape, Node, NodeKind}; @@ -27,6 +27,8 @@ pub struct PropertiesUi { pub edited_profiled: Option<(ProfiledKey, bool)>, /// The Quick Actions last listed, with the [`quick_actions_key`] they were listed at. quick_actions: Option<(u64, Vec)>, + /// The [`content_key`] the sections were last shown for. + content: Option, } /// The key of [`PropertiesUi::edited_profiled`]: (document uid, revision, active Appearance row). @@ -63,7 +65,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // Ruler guides selected on their own (a click on one): their position. let guides = super::transform::selected_guides(app); let header = heading(first.as_deref(), n_sel, editing_artboards, guides.is_some()); - inspector.target(key).header(header).show(ui, |ui, _| { + let content = content_key(app); + let changed = app.ui.properties_panel.content.replace(content) != Some(content); + let mut sections = |ui: &mut Ui, _: &mut BodyCx<'_>| { // The reference panel's labels end in a colon beside fields that keep their own width. Stack::new().fill_width().labels(LabelScheme::Form).show(ui, |ui, _| { if editing_artboards { @@ -77,7 +81,33 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { body(app, ui, first.as_deref(), n_sel, anchors); } }); - }); + }; + // The panel `Inspector::show` makes, shown here so that new sections are measured before they are placed and the + // frame is not discarded and drawn again. + let mut panel = Panel::new(header).titled().strength(HeaderStrength::Quiet).labels(LabelScheme::Inspector).pad(Pad::None); + panel = panel.id_salt(egui::IdSalt::new(key)); + if changed { + let _ = panel.measure_in(ui, Proposal::Size(ui.available_size()), &mut sections); + } + panel.show(ui, sections); +} + +/// What the sections show: the document and its revision, the selection, the tool and isolation mode. +fn content_key(app: &VectorcraftApp) -> u64 { + use std::hash::{Hash, Hasher}; + let mut h = std::collections::hash_map::DefaultHasher::new(); + app.session.tool_id().hash(&mut h); + if let Some(st) = app.session.active() { + let selection = &st.selection; + (st.uid, st.revision, st.isolation, &selection.objects, selection.key, selection.target, &selection.slices).hash(&mut h); + for (id, anchors) in &selection.anchors { + (id, anchors.len()).hash(&mut h); + } + for (id, segments) in &selection.segments { + (id, segments.len()).hash(&mut h); + } + } + h.finish() } /// The document's uid: production's field ids do not change with the selection, so neither does the key and the diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index 4a8158364a..f10c38ae6a 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -130,6 +130,66 @@ fn one_clip_group_has_edit_clipping_path_and_edit_contents_at_the_top() { assert_eq!(selected(&panel), std::slice::from_ref(&mask), "Edit Clipping Path selects the clipping path"); } +/// Selecting a second object, and going back to one, draws the panel in one pass: the sections are measured for the +/// new selection before they are placed, so the frame is not discarded and drawn again. The frame after each change +/// and a frame with no change take one pass too. +#[test] +fn a_selection_change_draws_the_panel_in_one_pass() { + let mut app = new_app(); + let (a, b) = (rect(&mut app, 20.0, 20.0, 40.0, 40.0), rect(&mut app, 120.0, 20.0, 60.0, 30.0)); + app.run("select.set", json!({"ids": [a]})).unwrap(); + let mut panel = Panel::new(app, show); + let passes = |panel: &mut Panel| { + let before = panel.ctx().cumulative_pass_nr(); + panel.frame(); + panel.ctx().cumulative_pass_nr() - before + }; + panel.frame(); + assert_eq!(passes(&mut panel), 1, "a settled frame"); + for round in 0..2 { + for (what, ids) in [("select two", json!([a, b])), ("select one", json!([b])), ("select the other", json!([a]))] { + panel.app().run("select.set", json!({ "ids": ids })).unwrap(); + assert_eq!(passes(&mut panel), 1, "{what}, round {round}"); + assert_eq!(passes(&mut panel), 1, "the frame after {what}, round {round}"); + } + } +} + +/// The same selection changes in the whole window, with the Properties panel docked: each frame takes one pass, so +/// the canvas and the other panels are drawn once. +#[test] +fn a_selection_change_draws_the_window_in_one_pass() { + let mut app = new_app(); + let (a, b) = (rect(&mut app, 20.0, 20.0, 40.0, 40.0), rect(&mut app, 120.0, 20.0, 60.0, 30.0)); + app.run("select.set", json!({"ids": [a]})).unwrap(); + app.run("window.panel", json!({"panel": "properties"})).unwrap(); + let ctx = crate::testing::ui_context(); + let mut time = 0.0; + let mut passes = |app: &mut VectorcraftApp| { + time += 1.0 / 60.0; + let raw = egui::RawInput { + time: Some(time), + screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), + focused: true, + ..Default::default() + }; + let before = ctx.cumulative_pass_nr(); + let _ = crate::testing::app_frame(app, &ctx, raw); + ctx.cumulative_pass_nr() - before + }; + for _ in 0..4 { + passes(&mut app); + } + assert_eq!(passes(&mut app), 1, "a settled frame"); + for round in 0..2 { + for (what, ids) in [("select two", json!([a, b])), ("select one", json!([b])), ("select the other", json!([a]))] { + app.run("select.set", json!({ "ids": ids })).unwrap(); + assert_eq!(passes(&mut app), 1, "{what}, round {round}"); + assert_eq!(passes(&mut app), 1, "the frame after {what}, round {round}"); + } + } +} + /// Start Global Edit in Quick Actions starts it on the one selected path, the button then reads /// Stop Global Edit, and Escape stops it. Selected type has no Start Global Edit button. #[test] From e3077d3c1f4e6a34a4237e7233ef40d033bd668b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:18:39 -0800 Subject: [PATCH 149/264] Script check: test the computed-key case of an own saveAs in its own script A computed key such as c[k] = w makes the check unsure for the whole script, so since the last commit every saveAs in that script counts as a write, the ones before the computed key included. The test put that case in the same script as the others, so the own saveAs calls it expected to write nothing were reported. The computed-key case now has its own script and assertion, and the other cases keep theirs. --- crates/scriptcheck/src/tests.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 61474e854f..0493014da0 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -671,18 +671,16 @@ fn the_scripts_own_save_as_writes_no_file() { fn a_changed_or_shared_own_save_as_writes_a_file() { let r = report(concat!( "var f = new File(p);\n", - "var a = {saveAs: function () {}}; var b = {saveAs: function () {}}; var c = {saveAs: function () {}};\n", + "var a = {saveAs: function () {}}; var b = {saveAs: function () {}};\n", "var d = {saveAs: function () {}}; var e = {saveAs: function () {}}; var g = {saveAs: function () {}};\n", "a.saveAs(f); b['saveAs'](f); a.n = 1; a.n;\n", "a.saveAs = app.activeDocument.saveAs;\n", "b['saveAs'] = w;\n", - "c[k] = w;\n", "delete d.saveAs;\n", "var h = e;\n", "use(g);\n", "a.saveAs(f);\n", "b.saveAs(f);\n", - "c.saveAs(f);\n", "d.saveAs(f);\n", "e.saveAs(f);\n", "g['saveAs'](f);\n", @@ -693,7 +691,11 @@ fn a_changed_or_shared_own_save_as_writes_a_file() { "q['saveAs'](f);\n", "s.saveAs(f);\n", )); - assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[11, 12, 13, 14, 15, 16, 18, 19, 21, 22][..])); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[10, 11, 12, 13, 14, 16, 17, 19, 20][..])); + // A computed key may name any variable, so every `saveAs` in the script may write, the ones + // before the computed key included. + let r = report("var f = new File(p);\nvar c = {saveAs: function () {}};\nc.saveAs(f);\nc[k] = w;\nc.saveAs(f);\n"); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 5][..])); } /// Only a `var` statement directly in a function body or the global code that gives its first name From 7574374bc038b280468681ed88177f3ec9a3a0ed Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:45:51 -0800 Subject: [PATCH 150/264] Docs: Edit Points Only names the paths a group leaves out A group or compound path selected whole gives way to its visible, unlocked paths, without a Shaper Group's original shapes and, while guides are locked, without paths made into guides. --- docs/target-app-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ad53f0194a..88004065be 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1529,7 +1529,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Polygonal Lasso selects anchor points (and gradient mesh points) inside a straight-edged loop, with the Lasso's rule for which points are inside, and is listed under Object › Plug-ins. Its tool is also in the Lasso tool's group in both shipped toolbars, after the Enclosing Lasso, and All Tools lists it there, under Select; a toolbar edited before it joined keeps its saved layout until Reset Toolbar (tests `polygonal_lasso_is_in_the_lasso_flyout`, `a_saved_toolbar_without_polygonal_lasso_keeps_its_layout` and `a_torn_off_lasso_group_shows_polygonal_lasso` in `edit_toolbar::tests`, `polygonal_lasso_is_in_the_lasso_group_once` in `addons::tests`, `headless_lists_the_lasso_group` in `vectorcraft-mcp`). It has no default shortcut. Each click sets a vertex. A double-click, Enter or a click on the first vertex closes the loop, Backspace or Delete removes the last vertex, Escape drops the loop, and Shift keeps the next segment to 45° steps. Shift or Alt held at the first click adds to or subtracts from the selection. This is a VectorCraft addition; scores and estimates are unchanged. Select by Artboards (Object › Plug-ins › Selection Tools, a VectorCraft addition: #5525, #5548, #5549) selects the objects overlapping, fully inside or fully outside one or more chosen artboards (`addon.select.byArtboards {artboards, relation}`). Overlapping is All on Active Artboard's test, shared as `select::on_artboard`; Fully inside means within one artboard, edges included; Fully outside means on none. It looks at what Select All takes, so hidden, locked and locked-artboard art stays out. Its dialog lists each artboard's number, name and size in the document's units, filters by name, chooses rows with click, Shift-click and Cmd/Ctrl-click, and fits a row's artboard in the window on double-click (`view.goToArtboard`). Tests: `crates/engine/src/cmd/addons/select/tests.rs`, `crates/ui-egui/src/addons/select/tests.rs`, `crates/engine/tests/command_sweep.rs`. Select by Link Status (Object › Plug-ins › Selection Tools and the Links panel menu, a VectorCraft addition: #5526) selects the image objects and placed documents whose link is linked (its file found unchanged), embedded, missing or modified, as `links.list` reports it (`addon.select.byLinkStatus {status, ids?, add?, zoom?}`); Select Linked, Embedded, Missing and Modified are off when no image has that status and add to the selection with Shift. Objects that are hidden or locked, inside a hidden or locked object or layer, on a template layer, on a locked artboard, or outside the isolated group are left out (the `select::is_selectable` test) and returned with the reason, and the status bar says how many, in plural forms of every catalog. Select by Link Status… lists each image and placed document with its name, status and format, searches by name, filters by status, picks rows with checkboxes and All / None, and zooms to the selection with the existing Zoom to Selection (`addon.arrange.zoomSelection`). Missing-link markers on the canvas are #5547. Tests: `crates/engine/src/cmd/addons/select/tests.rs` (`by_link_status`), `crates/ui-egui/src/addons/select/link_status/tests.rs`, `crates/engine/tests/command_sweep.rs`. - Edit Points Only (Object › Plug-ins › Selection Tools, a VectorCraft addition) narrows a Direct Selection to its selected anchor points (`addon.select.editPointsOnly {segmentEnds?}`): selected segments leave the selection, and the points at their ends leave it too unless Keep Ends of Selected Segments is on; paths selected whole keep every point; a group or compound path selected whole gives way to the visible, unlocked paths inside it; type, images, symbols and other objects without anchor points leave the selection. Only the selection changes, so there is no undo step; with nothing left to keep it is an error and the selection stays as it was. The dialog previews the narrowed selection, and Cancel puts the selection back. Tests: `crates/engine/src/cmd/addons/select/tests.rs` (`edit_points_only`), `crates/ui-egui/src/addons/select/points_only/tests.rs`, `crates/engine/tests/command_sweep.rs`. + Edit Points Only (Object › Plug-ins › Selection Tools, a VectorCraft addition) narrows a Direct Selection to its selected anchor points (`addon.select.editPointsOnly {segmentEnds?}`): selected segments leave the selection, and the points at their ends leave it too unless Keep Ends of Selected Segments is on; paths selected whole keep every point; a group or compound path selected whole gives way to the visible, unlocked paths inside it, leaving out a Shaper Group's original shapes and, while guides are locked, paths made into guides; type, images, symbols and other objects without anchor points leave the selection. Only the selection changes, so there is no undo step; with nothing left to keep it is an error and the selection stays as it was. The dialog previews the narrowed selection, and Cancel puts the selection back. Tests: `crates/engine/src/cmd/addons/select/tests.rs` (`edit_points_only`), `crates/ui-egui/src/addons/select/points_only/tests.rs`, `crates/engine/tests/command_sweep.rs`. The Links panel provides an item right-click context menu on link rows offering Relink…, Go To Link, Update Link, Edit Original, Show in Folder, Separator, and Embed Image / Unembed…. Right-clicking an unselected row selects that row first; right-clicking a row that is already part of a multi-selection preserves the multi-selection. Tests: `panels::tests_links::right_click_context_menu_in_links_panel`. The Location row of the Links panel's Link Info has a folder button, Show in Folder, that opens the folder of the file Link Info shows in the system's file manager (`links.reveal {id}` with that image's id); the help page describes a folder icon on this row ([Links information](https://helpx.adobe.com/illustrator/using/links-info.html)). The button's name and its off state while the file is missing or no file manager is available (the web build) are VectorCraft's own. Tests: `panels::tests_links::link_infos_location_row_shows_the_file_in_its_folder`. A marquee selects a clip group, or an object on a layer with a clipping mask, only when it reaches the area inside the clipping path, and it measures the art only within that path's bounds. Within the bounds of a mask that is not a rectangle, it can still select art that the mask hides. Direct Selection's marquee still selects the hidden anchor points inside it (#2345). From d7a71b7a58ebd422beb2fb7653e43d81af5b9d2d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:47:33 -0800 Subject: [PATCH 151/264] Global Edit: moving the selected object keeps the preview without walking the document With one object selected, the preview of the objects Start Global Edit would take walked every selectable object again after each edit. After an edit that replaced only the selected object, and left it the same shape, size and appearance (a move), the same objects match, so the outlines found before are kept. The check compares the two documents: the layers may differ only in the selected object and in the layers and groups that hold it, which must be the same apart from their contents; the symbols and the rest of the document must be the same. The selected object's form, box, geometric size and fill and stroke are compared within a millionth of the matching tolerance, since a move rounds the form differently in its unit box. Any other change walks the document as before. The preview is now also empty while a part of a dynamic symbol instance is selected, as Start Global Edit is refused then. --- crates/engine/src/cmd/globaledit.rs | 166 +++++++++++++++++++-- crates/engine/src/tests/globaledit.rs | 201 +++++++++++++++++++++++++- 2 files changed, 357 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/cmd/globaledit.rs b/crates/engine/src/cmd/globaledit.rs index 4f498e972a..5c455f897e 100644 --- a/crates/engine/src/cmd/globaledit.rs +++ b/crates/engine/src/cmd/globaledit.rs @@ -222,6 +222,8 @@ thread_local! { pub(crate) static FORMS_MADE: std::cell::Cell = const { std::cell::Cell::new(0) }; /// Tests: how many times [`outlines`] made the outline of a highlighted object on this thread. pub(crate) static OUTLINES_MADE: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// Tests: how many objects [`matches`] looked at on this thread. + pub(crate) static OBJECTS_WALKED: std::cell::Cell = const { std::cell::Cell::new(0) }; } impl Form { @@ -482,6 +484,8 @@ fn matches(s: &Session, o: &Options) -> Result> { let mut cache = st.global_edit_forms.0.borrow_mut(); let mut pass = cache.forms.pass(); super::select::walk_selectable(d, st.isolation, |n| { + #[cfg(test)] + OBJECTS_WALKED.with(|c| c.set(c.get() + 1)); if n.id == *id || out.len() >= MAX_MEMBERS { return false; } @@ -1030,34 +1034,178 @@ pub fn highlights(s: &Session) -> Outlines { out } -/// [`similar`]'s outlines as of a document revision and the options they were found with. -pub type SimilarCache = std::cell::RefCell>; +/// [`similar`]'s outlines as of a document revision, with what they were found from. +pub type SimilarCache = std::cell::RefCell>; + +/// [`similar`]'s outlines and what they were found from. +#[derive(Clone, Debug)] +pub struct Similar { + revision: u64, + options: Options, + /// The document, the one selected object and the isolated object they were found with. + doc: Arc, + key: NodeId, + isolation: Option, + out: Outlines, +} /// Before Global Edit starts: with one supported object selected, the outlines of the other /// objects Start Global Edit would take now with the session's Global Edit Options, so the canvas /// shows them as soon as the object is selected. None while an interaction (a drag) is in /// progress, or when fewer than two objects would be taken. Kept per document revision and -/// options, as finding them walks the whole document. +/// options, as finding them walks the whole document. After an edit that replaced only the +/// selected object, and left what the others are compared with as it was (a move), the outlines +/// found before are kept without a walk. pub fn similar(s: &Session) -> Outlines { let Some(st) = s.active() else { return vec![] }; - if st.global_edit.is_some() || st.interaction.is_some() || st.selection.objects.len() != 1 { + // Global Edit is refused while an object of a dynamic symbol instance's art is selected. + if st.global_edit.is_some() || st.interaction.is_some() || st.selection.objects.len() != 1 || super::edit::refuse_symbol_part(s).is_err() { return vec![]; } let o = &s.global_edit_options; - if let Some((rev, opts, out)) = &*st.similar_outlines.borrow() - && *rev == st.revision - && opts == o + let key = st.selection.objects[0]; + if let Some(c) = &mut *st.similar_outlines.borrow_mut() + && c.options == *o + && c.key == key + && c.isolation == st.isolation + && (c.revision == st.revision || Arc::ptr_eq(&c.doc, &st.doc) || only_key_changed(&c.doc, &st.doc, key)) { - return out.clone(); + c.revision = st.revision; + c.doc = st.doc.clone(); + return c.out.clone(); } let out = match matches(s, o) { Ok(m) if m.len() >= 2 => outlines(st, &m), _ => vec![], }; - *st.similar_outlines.borrow_mut() = Some((st.revision, o.clone(), out.clone())); + *st.similar_outlines.borrow_mut() = + Some(Similar { revision: st.revision, options: o.clone(), doc: st.doc.clone(), key, isolation: st.isolation, out: out.clone() }); out } +/// Would [`matches`] find the same objects in `now` as in `then`, with `key` selected in both? +/// True when the layers differ only in `key` and in the layers and groups that hold it (the same +/// apart from their contents), `key` is compared with the others as before ([`same_key`]), and the +/// rest of the document is the same. A group that holds `key` is never like it (its form holds +/// `key`'s and more), so the walk looks into it before and after alike. +fn only_key_changed(then: &Document, now: &Document, key: NodeId) -> bool { + let mut found = None; + let same_symbol = |a: &vectorcraft_doc::Symbol, b: &vectorcraft_doc::Symbol| { + a.name == b.name && a.dynamic == b.dynamic && (Arc::ptr_eq(&a.art, &b.art) || a.art == b.art) + }; + // Everything else in the document (artboards, symbol settings, editing modes) as it was: the + // symbols' art is compared on its own, as one copy when no edit changed it. + let rest = |d: &Document| { + let mut d = d.clone(); + d.layers.clear(); + d.symbols.clear(); + d + }; + if then.symbols.len() != now.symbols.len() + || !then.symbols.iter().zip(&now.symbols).all(|(a, b)| same_symbol(a, b)) + || rest(then) != rest(now) + || !changed_only(&then.layers, &now.layers, key, &mut found) + { + return false; + } + found.is_none_or(|(a, b)| same_key(a, b, &now.symbol_boxes())) +} + +/// Do `then` and `now` hold the same objects, apart from `key` and the layers and groups on the way +/// to it? `found` takes the two versions of `key` when it changed. +fn changed_only<'a>(then: &'a [Arc], now: &'a [Arc], key: NodeId, found: &mut Option<(&'a Node, &'a Node)>) -> bool { + if then.len() != now.len() { + return false; + } + then.iter().zip(now).all(|(a, b)| { + if Arc::ptr_eq(a, b) { + return true; + } + if a.id != b.id { + return false; + } + if a.id == key { + return found.replace((a, b)).is_none(); + } + match (holder_children(a), holder_children(b)) { + (Some(x), Some(y)) => same_holder(a, b) && changed_only(x, y, key, found), + _ => false, + } + }) +} + +/// The objects in a layer or a group. +fn holder_children(n: &Node) -> Option<&[Arc]> { + match &n.kind { + NodeKind::Layer { children, .. } | NodeKind::Group { children, .. } => Some(children), + _ => None, + } +} + +/// Are two versions of a layer or a group the same apart from the objects in them? +fn same_holder(a: &Node, b: &Node) -> bool { + let Node { id, name, visible, locked, opacity, blend, isolate, knockout, knockout_shape, appearance, kind, bbox_angle, extras } = a; + let kinds = match (kind, &b.kind) { + ( + NodeKind::Layer { color, template, printable, children: _, clip, preview, dim_images }, + NodeKind::Layer { color: c, template: t, printable: p, children: _, clip: cl, preview: pv, dim_images: di }, + ) => color == c && template == t && printable == p && clip == cl && preview == pv && dim_images == di, + (NodeKind::Group { children: _, clip }, NodeKind::Group { children: _, clip: c }) => clip == c, + _ => false, + }; + kinds + && *id == b.id + && *name == b.name + && *visible == b.visible + && *locked == b.locked + && *opacity == b.opacity + && *blend == b.blend + && *isolate == b.isolate + && *knockout == b.knockout + && *knockout_shape == b.knockout_shape + && *appearance == b.appearance + && *bbox_angle == b.bbox_angle + && *extras == b.extras +} + +/// How far apart two versions of the selected object's form may lie, in its unit box, and how much +/// their sizes may differ (relative), for [`similar`] to keep the objects found like the first: a +/// millionth of [`SAME`]. A move leaves the form the same but for rounding (the form is placed in +/// its unit box by a transform that includes the move), well within this. +const KEPT: f64 = 1e-12; + +/// Are two versions of the selected object compared with the other objects in the same way by +/// [`matches`]: the same form in a box of the same size and the same geometric size (a perspective +/// projection changes that alone), within [`KEPT`], and the same fill and stroke in each object in +/// them? +fn same_key(a: &Node, b: &Node, symbols: &vectorcraft_doc::SymbolBoxes<'_>) -> bool { + let near = |x: f64, y: f64| (x - y).abs() <= KEPT * x.abs().max(y.abs()).max(1.0); + fn same_look(a: &Node, b: &Node) -> bool { + fill_of(a) == fill_of(b) + && stroke_of(a) == stroke_of(b) + && match (a.children(), b.children()) { + (Some(x), Some(y)) => x.len() == y.len() && x.iter().zip(y).all(|(p, q)| same_look(p, q)), + (x, y) => x.is_none() && y.is_none(), + } + } + if !(supported(a) && supported(b)) { + return false; + } + let (Some(f), Some(g)) = (Form::of(a), Form::of(b)) else { return false }; + let (fl, gl) = (f.frame.as_coeffs(), g.frame.as_coeffs()); + let sizes = match (a.geometric_bounds_with(symbols), b.geometric_bounds_with(symbols)) { + (Some(x), Some(y)) => near(x.width(), y.width()) && near(x.height(), y.height()), + (x, y) => x.is_none() && y.is_none(), + }; + f.tag == g.tag + && f.symbols == g.symbols + && f.points.len() == g.points.len() + && f.points.iter().zip(&g.points).all(|(p, q)| p.distance(*q) <= KEPT) + && fl[..4].iter().zip(&gl[..4]).all(|(x, y)| near(*x, *y)) + && sizes + && same_look(a, b) +} + /// The outlines of `members` that are not selected, hold no selected object and sit inside no /// selected object, in their layer's color. fn outlines(st: &crate::DocState, members: &[(NodeId, Affine)]) -> Outlines { diff --git a/crates/engine/src/tests/globaledit.rs b/crates/engine/src/tests/globaledit.rs index ae56fa7c5a..db2bd921e7 100644 --- a/crates/engine/src/tests/globaledit.rs +++ b/crates/engine/src/tests/globaledit.rs @@ -137,7 +137,7 @@ fn after_an_edit_only_the_changed_objects_are_compared_again_from_scratch() { s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap(); let before = made(); assert_eq!(highlights(&s).len(), 39); - assert_eq!(since(before), (1, 0), "the selected object only: the copies are unchanged"); + assert_eq!(since(before), (2, 0), "the selected object before and after the move only: the copies are unchanged"); sel(&mut s, &[copies[0]]); s.execute("object.scale", &json!({"sx": 200, "sy": 100})).unwrap(); sel(&mut s, &[copies[1]]); @@ -156,6 +156,205 @@ fn after_an_edit_only_the_changed_objects_are_compared_again_from_scratch() { assert_eq!(crate::cmd::globaledit::match_count(&s), 38); } +#[test] +fn an_edit_to_the_selected_object_alone_keeps_the_similar_objects_without_a_walk() { + use crate::cmd::globaledit::{OBJECTS_WALKED, highlights}; + let walked = || OBJECTS_WALKED.with(std::cell::Cell::get); + // The outlines `highlights` gives, and how many objects it looked at for them. + let shown = |s: &Session| { + let before = walked(); + let out = highlights(s); + (out, walked() - before) + }; + // The outlines a walk finds, the options set again so that nothing is kept. + let fresh = |s: &mut Session| { + let size = s.global_edit_options.size; + s.execute("select.globalEditOptions", &json!({"size": !size})).unwrap(); + highlights(s); + s.execute("select.globalEditOptions", &json!({"size": size})).unwrap(); + let before = walked(); + let out = highlights(s); + assert!(walked() > before, "a walk"); + out + }; + let mut s = session(); + let key = rect(&mut s, 0.37, 0.91, 10.3, 10.3); + let copies: Vec = (1..40).map(|i| rect(&mut s, 20.0 * f64::from(i % 20), 100.0 + 20.0 * f64::from(i / 20), 10.3, 10.3)).collect(); + sel(&mut s, &[key]); + let (first, n) = shown(&s); + assert_eq!(first.len(), 39); + assert!(n >= 40, "the first preview walks every object"); + + // The move rounds the form in its unit box differently; the same objects are like it. + s.execute("object.move", &json!({"dx": 3.17, "dy": 1.29})).unwrap(); + let (out, n) = shown(&s); + assert_eq!(n, 0, "a move of the selected object alone compares the others as before"); + assert_eq!(out, first); + assert_eq!(out, fresh(&mut s)); + + // Another object moved: it is shown where it is now. + sel(&mut s, &[copies[0]]); + s.execute("object.move", &json!({"dx": 300, "dy": 0})).unwrap(); + sel(&mut s, &[key]); + let (out, n) = shown(&s); + assert!(n > 0, "another object changed"); + let moved = node(&s, copies[0]).stroke_path().unwrap(); + assert!(out.iter().any(|(p, _)| *p == moved), "the moved copy is shown where it is now"); + assert_eq!(out, fresh(&mut s)); + + // The selected object took another shape: none of the squares is like it. + s.execute("object.scale", &json!({"sx": 200, "sy": 100})).unwrap(); + let (out, n) = shown(&s); + assert!(n > 0 && out.is_empty(), "the widened square matches none of the squares"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(shown(&s).0.len(), 39); + + // With Size, a larger copy of the selected square is another size. + s.execute("select.globalEditOptions", &json!({"size": true})).unwrap(); + assert_eq!(shown(&s).0.len(), 39); + s.execute("object.scale", &json!({"sx": 200, "sy": 200})).unwrap(); + let (out, n) = shown(&s); + assert!(n > 0 && out.is_empty(), "the enlarged square has the size of none of them"); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("select.globalEditOptions", &json!({"size": false})).unwrap(); + + // With Appearance, another fill on the selected square leaves the others out. + s.execute("select.globalEditOptions", &json!({"appearance": true})).unwrap(); + assert_eq!(shown(&s).0.len(), 39); + s.execute("paint.setFill", &json!({"color": "#12ab34"})).unwrap(); + let (out, n) = shown(&s); + assert!(n > 0 && out.is_empty(), "the others have another fill now"); + s.execute("select.globalEditOptions", &json!({"appearance": false})).unwrap(); + + // Reflected, the selected kite keeps its size but is no longer like its copy. + let lone = kite(&mut s, 0.0, 500.0, 1.0); + kite(&mut s, 200.0, 500.0, 1.0); + sel(&mut s, &[lone]); + assert_eq!(shown(&s).0.len(), 1); + s.execute("object.reflect", &json!({"axis": "vertical"})).unwrap(); + let (out, n) = shown(&s); + assert!(n > 0 && out.is_empty(), "a reflected copy is not like it"); +} + +#[test] +fn another_layer_locked_leaves_its_objects_out_of_the_similar_objects() { + use crate::cmd::globaledit::highlights; + let mut s = session(); + let key = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + rect(&mut s, 20.0, 0.0, 10.0, 10.0); + let other = NodeId(s.execute("layer.new", &json!({})).unwrap()["id"].as_u64().unwrap()); + rect(&mut s, 40.0, 0.0, 10.0, 10.0); + rect(&mut s, 60.0, 0.0, 10.0, 10.0); + sel(&mut s, &[key]); + assert_eq!(highlights(&s).len(), 3); + s.execute("layer.setProps", &json!({"id": other.0, "locked": true})).unwrap(); + assert_eq!(s.doc().unwrap().selection.objects, [key]); + assert_eq!(highlights(&s).len(), 1, "the squares on the locked layer are left out"); +} + +#[test] +fn a_new_artboard_brings_the_objects_on_it_into_the_similar_objects() { + use crate::cmd::globaledit::highlights; + let mut s = session(); + let key = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + rect(&mut s, 20.0, 0.0, 10.0, 10.0); + rect(&mut s, 1100.0, 100.0, 10.0, 10.0); + s.execute("select.globalEditOptions", &json!({"includeCanvas": false})).unwrap(); + sel(&mut s, &[key]); + assert_eq!(highlights(&s).len(), 1, "the square on the canvas is left out"); + s.execute("artboard.new", &json!({"x": 1000, "y": 0, "width": 400, "height": 400})).unwrap(); + sel(&mut s, &[key]); + assert_eq!(highlights(&s).len(), 2, "the square is on an artboard now"); +} + +#[test] +fn a_symbol_redrawn_brings_its_instances_onto_the_artboard() { + use crate::cmd::globaledit::highlights; + let mut s = session(); + let r = rect(&mut s, 0.0, 0.0, 40.0, 40.0); + let key = NodeId(s.execute("symbol.new", &json!({"ids": [r.0], "name": "Tile"})).unwrap()["id"].as_u64().unwrap()); + s.execute("symbol.place", &json!({"name": "Tile", "x": 1000, "y": 300})).unwrap(); + s.execute("select.globalEditOptions", &json!({"includeCanvas": false})).unwrap(); + sel(&mut s, &[key]); + assert!(highlights(&s).is_empty(), "the other instance is on the canvas"); + // The symbol's art drawn 400 pt to the left: the other instance lies on the artboard. + let st = s.doc_mut().unwrap(); + let d = std::sync::Arc::make_mut(&mut st.doc); + let art = std::sync::Arc::make_mut(&mut d.symbols[0].art); + art.transform(Affine::translate((-400.0, 0.0)), vectorcraft_doc::Scaling::default()); + st.revision += 1; + assert_eq!(highlights(&s).len(), 1, "the other instance is on the artboard now"); +} + +#[test] +fn a_symbol_instance_put_in_perspective_has_another_size() { + use crate::cmd::globaledit::highlights; + let mut s = session(); + s.execute("perspective.grid.preset", &json!({"kind": 2})).unwrap(); + let r = rect(&mut s, 450.0, 300.0, 100.0, 100.0); + let key = NodeId(s.execute("symbol.new", &json!({"ids": [r.0], "name": "Tile"})).unwrap()["id"].as_u64().unwrap()); + s.execute("symbol.place", &json!({"name": "Tile", "x": 100, "y": 100})).unwrap(); + s.execute("select.globalEditOptions", &json!({"size": true})).unwrap(); + sel(&mut s, &[key]); + assert_eq!(highlights(&s).len(), 1); + let size = |s: &Session| bounds(s, key).size(); + let was = size(&s); + s.execute("perspective.attach", &json!({"ids": [key.0], "plane": "right"})).unwrap(); + sel(&mut s, &[key]); + assert_ne!(size(&s), was, "the projection changes the instance's size"); + assert!(highlights(&s).is_empty(), "the other instance has the size the selected one had"); +} + +#[test] +fn a_part_of_a_dynamic_symbol_instance_selected_shows_no_similar_objects() { + use crate::cmd::globaledit::highlights; + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let b = rect(&mut s, 20.0, 0.0, 10.0, 10.0); + let inst = NodeId(s.execute("symbol.new", &json!({"name": "Pair", "ids": [a.0, b.0], "type": "dynamic"})).unwrap()["id"].as_u64().unwrap()); + s.execute("symbol.place", &json!({"name": "Pair", "x": 300, "y": 300})).unwrap(); + sel(&mut s, &[inst]); + assert_eq!(highlights(&s).len(), 1); + s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [1]})).unwrap(); + assert_eq!(s.doc().unwrap().selection.objects, [inst]); + assert!(highlights(&s).is_empty(), "Global Edit does not take a part of the art"); + sel(&mut s, &[inst]); + assert_eq!(highlights(&s).len(), 1, "the whole instance again"); +} + +#[test] +fn a_group_selected_inside_a_group_keeps_its_similar_objects_after_a_move() { + use crate::cmd::globaledit::{OBJECTS_WALKED, highlights}; + let walked = || OBJECTS_WALKED.with(std::cell::Cell::get); + let mut s = session(); + let group = |s: &mut Session, ids: &[NodeId]| { + sel(s, ids); + NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()) + }; + // A group of two squares inside an outer group with a third square, and a copy of the outer + // group: the copy is like the outer group, not like the inner one. + let a = [rect(&mut s, 0.0, 0.0, 10.0, 10.0), rect(&mut s, 20.0, 0.0, 10.0, 10.0)]; + let inner = group(&mut s, &a); + let third = rect(&mut s, 40.0, 0.0, 10.0, 10.0); + let outer = group(&mut s, &[inner, third]); + let b = [rect(&mut s, 0.0, 100.0, 10.0, 10.0), rect(&mut s, 20.0, 100.0, 10.0, 10.0)]; + let inner_copy = group(&mut s, &b); + let third_copy = rect(&mut s, 40.0, 100.0, 10.0, 10.0); + group(&mut s, &[inner_copy, third_copy]); + sel(&mut s, &[inner]); + let first = highlights(&s); + assert_eq!(crate::cmd::globaledit::match_count(&s), 2, "the copy's inner group; the outer group {outer} holds the selected one"); + assert!(!first.is_empty()); + s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap(); + let before = walked(); + assert_eq!(highlights(&s), first); + assert_eq!(walked(), before, "the outer group changed with the selected group only"); + s.execute("select.globalEditOptions", &json!({"size": true})).unwrap(); + s.execute("select.globalEditOptions", &json!({"size": false})).unwrap(); + assert_eq!(highlights(&s), first, "a walk finds the same"); + assert!(walked() > before); +} + #[test] fn the_canvas_highlights_similar_objects_before_the_start_with_the_selection_tool_only() { let mut s = session(); From 2f508db904b14e42d36d5ddd47d6c648ebf9c9bd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:55:41 -0800 Subject: [PATCH 152/264] Properties: the Preferences key reads the General unit after a Units pick The Preferences section's memo key took the General unit's index before the Units commit ran, while its lengths were read after it. On the frame that picked new units the key still matched the previous frame, so the section replayed and the Keyboard Increment showed the old unit for that frame. The key now reads the unit next to the lengths. --- .../panels/properties/document_sections.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/ui-egui/src/panels/properties/document_sections.rs b/crates/ui-egui/src/panels/properties/document_sections.rs index 4774bdb750..cff44b4f44 100644 --- a/crates/ui-egui/src/panels/properties/document_sections.rs +++ b/crates/ui-egui/src/panels/properties/document_sections.rs @@ -57,6 +57,9 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { app.run(command, json!({})).ok(); } let mut prefs = Vec::new(); + // Read again after the Units commit above, so the key and `lengths` come from the same General unit. + let general = app.session.general_unit(); + let unit = Unit::ALL.iter().position(|u| *u == general).unwrap_or(usize::MAX); let (increment, scale) = (app.session.prefs.keyboard_increment, app.session.prefs.scale_strokes); let (bare_points, lengths) = (app.session.prefs.numbers_without_units_are_points, crate::canvas::rulers::general_lengths(app)); super::section(tl!("Preferences")).show(ui, |ui, _| { @@ -310,6 +313,31 @@ mod tests { assert_eq!(per_frame[6..], [0; 6], "idle frames after a command run them no more: {per_frame:?}"); } + /// The frame that picks new units in the Units menu shows the Keyboard Increment in them: the Preferences + /// section's key reads the General unit after the pick runs, as its lengths do. + #[test] + fn the_frame_that_picks_units_shows_the_increment_in_them() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let initial = app.session.general_unit(); + let mut panel = Panel::new(app, document_sections); + panel.room(egui::vec2(400.0, 1000.0)); + panel.frame(); + let before = panel.value("Keyboard Increment"); + panel.click_role("Units", Role::COMBO_BOX); + panel.key(egui::Key::ArrowDown, egui::Modifiers::NONE); + panel.key(egui::Key::ArrowDown, egui::Modifiers::NONE); + let enter = + |pressed| egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::NONE }; + panel.frame_with(vec![enter(true), enter(false)]); + assert_ne!(panel.app().session.general_unit(), initial, "Enter applies the chosen unit"); + let picked = panel.value("Keyboard Increment"); + panel.frame(); + let settled = panel.value("Keyboard Increment"); + assert_ne!(settled, before, "the increment shows in the new unit"); + assert_eq!(picked, settled, "the frame of the pick already shows the increment in the new unit"); + } + /// The memoized sections still take input: a click on Snap to Grid turns it on, once, and Scale Strokes & Effects /// sets its preference. #[test] From cb6703c0f106b60f5db565fdc1d89a1bff4f7b22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:58:15 -0800 Subject: [PATCH 153/264] Menus: an interaction a dialog or the font menu begins reads the menus CI failed `the_font_menu_preview_reads_the_menus_when_it_ends`: with the state key holding the revision an interaction began from, the key no longer changed when the font menu's preview began, so the menus were not read then, though commands that check for an open interaction change state at that point and the menu stays open while it previews. The key now also holds whether an interaction that the active tool did not begin is open. A tool's drag still keeps the key as it begins; a dialog's, a panel's or the font menu's preview changes it as it begins and as it ends. `Interaction::by_tool` reads the flag for the UI crate. --- crates/engine/src/interaction.rs | 7 +++++++ crates/ui-egui/src/menus/model.rs | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/interaction.rs b/crates/engine/src/interaction.rs index bdc829fb37..387fc0e009 100644 --- a/crates/engine/src/interaction.rs +++ b/crates/engine/src/interaction.rs @@ -55,6 +55,13 @@ pub struct Interaction { pub keep_on_switch: bool, } +impl Interaction { + /// The active tool began it (a drag). + pub fn by_tool(&self) -> bool { + self.tool + } +} + /// An interaction that a command from outside the tool set aside while it runs /// ([`crate::Session::outside_interaction`]). #[derive(Debug)] diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 92c1786af4..dc4357363b 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -90,7 +90,9 @@ pub(crate) fn translate_label(english: &'static str) -> String { /// doesn't list (panels shown, a tool picked). While an /// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's /// preview, or a typing session), the hash takes the revision the interaction began from in place of the current one, -/// which each of its previews changes: the hash stays the same as the interaction begins, and changes as it ends. +/// which each of its previews changes, and changes as it ends. The hash stays the same as a tool's drag begins. An +/// interaction that a dialog, a panel or the font menu begins changes the hash as it begins, since commands that check +/// for an open interaction change state then and the menus stay open while it previews. pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { let mut h = DefaultHasher::new(); input.hash(&mut h); @@ -102,7 +104,8 @@ pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { (s.journal.len(), s.active_index(), s.clipboard.is_empty(), s.tool_composing()).hash(&mut h); if let Some(d) = s.active() { let revision = d.interaction.as_ref().map_or(d.revision, |it| it.revision); - (d.uid, revision, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h); + let previewing = d.interaction.as_ref().is_some_and(|it| !it.by_tool()); + (d.uid, revision, previewing, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h); } (app.system_paste, app.last_effect.is_some(), app.ui.recent_files.len(), app.ui.recent_files.first(), app.recent_fonts().len()).hash(&mut h); // Apply Last Filter and Last Filter… are named after the filter that ran last. From bcd1fcac61fd16ed8f50dc2ce937b996c2d850e3 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 23:58:30 +0100 Subject: [PATCH 154/264] Harden RPM smoke lifecycle and cover failure paths --- .github/scripts/release-rpm-smoke.py | 119 +++++++++--------- .../scripts/tests/test_release_rpm_smoke.py | 116 +++++++++++++++++ .github/workflows/release-rpm-smoke.yml | 10 +- .github/workflows/sonarcloud.yml | 3 + 4 files changed, 188 insertions(+), 60 deletions(-) create mode 100644 .github/scripts/tests/test_release_rpm_smoke.py diff --git a/.github/scripts/release-rpm-smoke.py b/.github/scripts/release-rpm-smoke.py index 73dc871f1d..3d70cca7c1 100644 --- a/.github/scripts/release-rpm-smoke.py +++ b/.github/scripts/release-rpm-smoke.py @@ -7,63 +7,68 @@ import secrets import socket import subprocess import time +import tempfile -results = Path("/results") -requirements = (results / "rpm-requires.txt").read_text() -for capability in ( - "libc.so.6()(64bit)", - "libm.so.6(GLIBC_2.35)(64bit)", - "libgcc_s.so.1()(64bit)", - "libxkbcommon.so.0()(64bit)", - "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", -): - if capability not in requirements.splitlines(): - raise RuntimeError(f"Missing RPM requirement: {capability}") -version = subprocess.check_output(["vectorcraft-cli", "--version"], text=True) -(results / "cli-version.txt").write_text(version) -# Original fixture authored for this package smoke test; no external artwork. -fixture = results / "original-smoke.svg" -fixture.write_text('' - '' - '') -token = secrets.token_hex(32) -env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR="/tmp/vectorcraft-runtime", - VECTORCRAFT_CONTROL_TOKEN=token) -Path(env["XDG_RUNTIME_DIR"]).mkdir(mode=0o700, exist_ok=True) -with (results / "gui.log").open("w") as log: - app = subprocess.Popen([ - "vectorcraft", "--control", "32180", "--automation-read-root", str(results), - "--automation-write-root", str(results), str(fixture), - ], stdout=log, stderr=subprocess.STDOUT, env=env) - try: - deadline = time.monotonic() + 90 - while True: - if app.poll() is not None: - raise RuntimeError(f"GUI exited during startup: {app.returncode}") - try: - channel = socket.create_connection(("127.0.0.1", 32180), timeout=5) - break - except OSError: - if time.monotonic() >= deadline: - raise RuntimeError("GUI control channel did not become ready") from None - time.sleep(1) - channel.settimeout(30) - with channel, channel.makefile("rwb") as stream: - for request_id, method, params in ( - (0, "auth", {"token": token}), - (1, "ui.inspect", {}), - ): - stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) - stream.flush() - response = json.loads(stream.readline()) - (results / f"{method}.json").write_text(json.dumps(response, indent=2)) - if response.get("id") != request_id or response.get("ok") is not True: - raise RuntimeError(f"GUI request failed: {method}") - finally: - app.terminate() +def run_smoke(results): + requirements = (results / "rpm-requires.txt").read_text() + for capability in ( + "libc.so.6()(64bit)", + "libm.so.6(GLIBC_2.35)(64bit)", + "libgcc_s.so.1()(64bit)", + "libxkbcommon.so.0()(64bit)", + "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", + ): + if capability not in requirements.splitlines(): + raise RuntimeError(f"Missing RPM requirement: {capability}") + + version = subprocess.check_output(["vectorcraft-cli", "--version"], text=True) + (results / "cli-version.txt").write_text(version) + # Original fixture authored for this package smoke test; no external artwork. + fixture = results / "original-smoke.svg" + fixture.write_text('' + '' + '') + token = secrets.token_hex(32) + with tempfile.TemporaryDirectory(prefix="vectorcraft-runtime-") as runtime, (results / "gui.log").open("w") as log: + env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR=runtime, + VECTORCRAFT_CONTROL_TOKEN=token) + app = subprocess.Popen([ + "vectorcraft", "--control", "32180", "--automation-read-root", str(results), + "--automation-write-root", str(results), str(fixture), + ], stdout=log, stderr=subprocess.STDOUT, env=env) try: - app.wait(timeout=10) - except subprocess.TimeoutExpired: - app.kill() - app.wait() + deadline = time.monotonic() + 90 + while True: + if app.poll() is not None: + raise RuntimeError(f"GUI exited during startup: {app.returncode}") + try: + channel = socket.create_connection(("127.0.0.1", 32180), timeout=5) + break + except OSError: + if time.monotonic() >= deadline: + raise RuntimeError("GUI control channel did not become ready") from None + time.sleep(1) + channel.settimeout(30) + with channel, channel.makefile("rwb") as stream: + for request_id, method, params in ( + (0, "auth", {"token": token}), + (1, "ui.inspect", {}), + ): + stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) + stream.flush() + response = json.loads(stream.readline()) + (results / f"{method}.json").write_text(json.dumps(response, indent=2)) + if response.get("id") != request_id or response.get("ok") is not True: + raise RuntimeError(f"GUI request failed: {method}") + finally: + app.terminate() + try: + app.wait(timeout=10) + except subprocess.TimeoutExpired: + app.kill() + app.wait() + + +if __name__ == "__main__": + run_smoke(Path("/results")) diff --git a/.github/scripts/tests/test_release_rpm_smoke.py b/.github/scripts/tests/test_release_rpm_smoke.py new file mode 100644 index 0000000000..9d92237534 --- /dev/null +++ b/.github/scripts/tests/test_release_rpm_smoke.py @@ -0,0 +1,116 @@ +"""Exercise failures that an installed-package happy-path check cannot reproduce.""" +import importlib.util +import json +from pathlib import Path +import subprocess +import tempfile +import unittest +from unittest.mock import MagicMock, patch + +spec = importlib.util.spec_from_file_location("rpm_smoke", Path(__file__).parents[1] / "release-rpm-smoke.py") +smoke = importlib.util.module_from_spec(spec) +spec.loader.exec_module(smoke) + + +class SmokeLifecycleTests(unittest.TestCase): + def setUp(self): + self.folder = tempfile.TemporaryDirectory() + self.addCleanup(self.folder.cleanup) + self.results = Path(self.folder.name) + (self.results / "rpm-requires.txt").write_text("\n".join([ + "libc.so.6()(64bit)", "libm.so.6(GLIBC_2.35)(64bit)", + "libgcc_s.so.1()(64bit)", "libxkbcommon.so.0()(64bit)", + "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", + ])) + self.app = MagicMock() + self.app.poll.return_value = None + self.channel = MagicMock() + self.stream = self.channel.makefile.return_value.__enter__.return_value + self.stream.readline.side_effect = [ + b'{"id":0,"ok":true}\n', b'{"id":1,"ok":true,"result":{"window":"fixture"}}\n', + ] + self.runtime = None + + def launch(*args, **kwargs): + self.runtime = Path(kwargs["env"]["XDG_RUNTIME_DIR"]) + self.assertTrue(self.runtime.is_dir()) + return self.app + + self.launch = self.start_patch(smoke.subprocess, "Popen", side_effect=launch) + self.start_patch(smoke.subprocess, "check_output", return_value="vectorcraft-cli 0.25.0\n") + self.connect = self.start_patch(smoke.socket, "create_connection", return_value=self.channel) + self.start_patch(smoke.time, "sleep") + + def start_patch(self, owner, name, **kwargs): + patcher = patch.object(owner, name, **kwargs) + result = patcher.start() + self.addCleanup(patcher.stop) + return result + + def assert_cleaned_up(self): + self.app.terminate.assert_called_once() + self.assertFalse(self.runtime.exists()) + + def test_success_records_inspection_and_removes_private_runtime(self): + smoke.run_smoke(self.results) + report = json.loads((self.results / "ui.inspect.json").read_text()) + self.assertEqual(report["result"], {"window": "fixture"}) + requests = [json.loads(call.args[0]) for call in self.stream.write.call_args_list] + self.assertEqual(requests[0]["method"], "auth") + self.assertEqual(requests[0]["params"]["token"], self.launch.call_args.kwargs["env"]["VECTORCRAFT_CONTROL_TOKEN"]) + self.assert_cleaned_up() + + def test_missing_runtime_dependency_prevents_launch(self): + (self.results / "rpm-requires.txt").write_text("") + with self.assertRaisesRegex(RuntimeError, "Missing RPM requirement"): + smoke.run_smoke(self.results) + self.launch.assert_not_called() + + def test_child_exit_during_startup_is_a_failure(self): + self.app.poll.return_value = 1 + self.app.returncode = 1 + with self.assertRaisesRegex(RuntimeError, "exited during startup"): + smoke.run_smoke(self.results) + self.assert_cleaned_up() + + def test_connection_is_retried_until_ready(self): + self.connect.side_effect = [OSError("not ready"), self.channel] + smoke.run_smoke(self.results) + self.assertEqual(self.connect.call_count, 2) + self.assert_cleaned_up() + + def test_startup_timeout_stops_child(self): + self.connect.side_effect = OSError("not ready") + self.start_patch(smoke.time, "monotonic", side_effect=[0, 91]) + with self.assertRaisesRegex(RuntimeError, "did not become ready"): + smoke.run_smoke(self.results) + self.assert_cleaned_up() + + def test_auth_refusal_prevents_inspection(self): + self.stream.readline.side_effect = [b'{"id":0,"ok":false}\n'] + with self.assertRaisesRegex(RuntimeError, "request failed: auth"): + smoke.run_smoke(self.results) + self.assertFalse((self.results / "ui.inspect.json").exists()) + self.assert_cleaned_up() + + def test_response_for_another_request_is_rejected(self): + self.stream.readline.side_effect = [b'{"id":0,"ok":true}\n', b'{"id":99,"ok":true}\n'] + with self.assertRaisesRegex(RuntimeError, "request failed: ui.inspect"): + smoke.run_smoke(self.results) + self.assert_cleaned_up() + + def test_malformed_response_still_stops_child(self): + self.stream.readline.side_effect = [b'not json\n'] + with self.assertRaises(json.JSONDecodeError): + smoke.run_smoke(self.results) + self.assert_cleaned_up() + + def test_unresponsive_child_is_killed_after_termination_timeout(self): + self.app.wait.side_effect = [subprocess.TimeoutExpired("vectorcraft", 10), 0] + smoke.run_smoke(self.results) + self.app.kill.assert_called_once() + self.assert_cleaned_up() + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml index 4140f57f3d..61948e0f35 100644 --- a/.github/workflows/release-rpm-smoke.yml +++ b/.github/workflows/release-rpm-smoke.yml @@ -11,13 +11,14 @@ on: paths: - .github/workflows/release-rpm-smoke.yml - .github/scripts/release-rpm-smoke.py + - .github/scripts/tests/test_release_rpm_smoke.py -permissions: - contents: read - actions: read +permissions: {} jobs: source: + permissions: + actions: read runs-on: ubuntu-24.04 timeout-minutes: 5 outputs: @@ -43,6 +44,9 @@ jobs: echo '::error::No release run has both Linux package artifacts available' exit 1 smoke: + permissions: + contents: read + actions: read needs: source timeout-minutes: 25 strategy: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4cd4eb6387..223859d9b9 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -21,4 +21,7 @@ jobs: # The reusable workflow defaults build-jobs to 2 so a cold instrumented # archive stays within hosted-runner memory (craft-common-actions#333). uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main + with: + python-coverage-source: .github/scripts + python-coverage-script: .github/scripts/tests/test_release_rpm_smoke.py secrets: inherit From 3aa41526e2009af448624f9c93cceb6a7a7fed59 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 15:02:34 -0800 Subject: [PATCH 155/264] Performance: the color check stops walking objects after a second color several_colors kept looking up the remaining ids, walking the remaining children of a group and the rest of a pattern tile after it had found two colors. It now stops as soon as the second color turns up. --- crates/engine/src/cmd/recolor.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/recolor.rs b/crates/engine/src/cmd/recolor.rs index 174f90ecb0..a0ba6d243c 100644 --- a/crates/engine/src/cmd/recolor.rs +++ b/crates/engine/src/cmd/recolor.rs @@ -1065,12 +1065,18 @@ fn several_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet>) self.read(n); for c in n.children().into_iter().flatten() { self.read_tree(c, only); + if self.several { + return; + } } } } let mut seen = Seen { first: None, several: false, patterns: vec![] }; for n in ids.iter().filter_map(|id| d.node(*id)) { seen.read_tree(n, only); + if seen.several { + return true; + } } let mut next = 0; while !seen.several @@ -1078,11 +1084,13 @@ fn several_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet>) { next += 1; for a in d.pattern(name).map(|def| def.art.as_slice()).unwrap_or_default() { - a.walk(&mut |m| { - if !seen.several { - seen.read(m); - } + let _ = a.try_walk(&mut |m| { + seen.read(m); + if seen.several { std::ops::ControlFlow::Break(()) } else { std::ops::ControlFlow::Continue(()) } }); + if seen.several { + break; + } } } seen.several From 2960e55b6c38ff109e56ce1879a142a4ee929294 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 15:40:43 -0800 Subject: [PATCH 156/264] Match Objects: a stacking match keeps clipping paths and settles Intertwine groups Merging main made DIALOGS one entry short: Offset Objects and Match Objects both joined it, so vectorcraft-ui-egui did not compile. The table now declares seven entries. A stacking match moved a clipping path out of its clip position and could move a member out of an Intertwine group with its old overlap tiers. It now refuses to move a clipping path, refuses a destination that would nest Intertwine art, and clears the tiers of members that leave their group. A stacking or rotate-only match no longer needs bounds on the source. A size match measures each target after it is sized and turned, in its final frame, and is refused when a target can't take the requested size, instead of reporting success with the size unchanged. A target with no bounds that needs to turn is refused. --- crates/engine/src/cmd/addons/arrange.rs | 74 ++++++-- crates/engine/src/cmd/addons/arrange/tests.rs | 173 +++++++++++++++++- crates/ui-egui/src/addons/arrange.rs | 2 +- docs/mcp.md | 2 +- docs/target-app-parity.md | 2 +- 5 files changed, 238 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index 6ded16116a..136ec7ffbf 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -95,7 +95,7 @@ pub fn specs() -> Vec { "Match Objects", ["Object", "Plug-ins", "Arrange Tools"], None, - "{source?: \"key\" (the key object, select.key) | \"top\" (the frontmost selected object) | \"bottom\" (the backmost) (default: the key object when the selection has one, else \"top\"), size?: \"none\" | \"width\" (each target takes the source's width, its height following in proportion) | \"height\" (the source's height, the width following in proportion) | \"both\" (the source's width and height, each on its own) (\"none\"), rotate?: false (true: each target turns, clockwise or counter-clockwise, to the source's bounding-box angle), stacking?: false (true: the targets go directly above the source in the stacking order, in its layer or group, in the order they had), reference?: 0..8 (the 9-point grid row by row from the top-left; 4, the center: the point of each target that stays put as it is sized and turned), scaleStrokes?: the Scale Strokes & Effects preference, patterns?: the Transform Pattern Tiles preference (at least one of size, rotate and stacking)} make the other selected objects (the top-level ones, at most 20000) match the source, which stays as it is, as one undo step (none when nothing changes). Sizes are measured and set as object.setBounds measures them (Use Preview Bounds), each in the object's own bounding-box frame; to match places, use object.align {to: \"key\"} → {source, count}", + "{source?: \"key\" (the key object, select.key) | \"top\" (the frontmost selected object) | \"bottom\" (the backmost) (default: the key object when the selection has one, else \"top\"), size?: \"none\" | \"width\" (each target takes the source's width, its height following in proportion) | \"height\" (the source's height, the width following in proportion) | \"both\" (the source's width and height, each on its own) (\"none\"), rotate?: false (true: each target turns, clockwise or counter-clockwise, to the source's bounding-box angle), stacking?: false (true: the targets go directly above the source in the stacking order, in its layer or group, in the order they had), reference?: 0..8 (the 9-point grid row by row from the top-left; 4, the center: the point of each target that stays put as it is sized and turned), scaleStrokes?: the Scale Strokes & Effects preference, patterns?: the Transform Pattern Tiles preference (at least one of size, rotate and stacking)} make the other selected objects (the top-level ones, at most 20000) match the source, which stays as it is, as one undo step (none when nothing changes). Sizes are measured and set as object.setBounds measures them (Use Preview Bounds), each in the object's own bounding-box frame, and a size that a target has no width or height to take is refused, as is a stacking match that would move a clipping path; to match places, use object.align {to: \"key\"} → {source, count}", has_multi, match_objects ), @@ -418,8 +418,13 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { if targets.is_empty() { return Err(bad(C, "select at least two objects")); } - let sb = box_of(s, source)?; - let (w, h) = (sb.rect.width(), sb.rect.height()); + // Only sizing measures the source; a stacking or rotate match doesn't need its bounds. + let (w, h) = if size == "none" { + (0.0, 0.0) + } else { + let sb = box_of(s, source)?; + (sb.rect.width(), sb.rect.height()) + }; let wanted = match size { "width" if w < LEAST => return Err(bad(C, "the source object has no width")), "height" if h < LEAST => return Err(bad(C, "the source object has no height")), @@ -432,7 +437,16 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { let angle = s.doc()?.doc.bbox_angle(&[source]); let mut xfs = Vec::with_capacity(targets.len()); for &id in &targets { - let Some(b) = s.transform_box(&[id]) else { continue }; + let turn = if rotate { vectorcraft_geom::normalize_deg(angle - s.doc()?.doc.bbox_angle(&[id])) } else { 0.0 }; + let Some(b) = s.transform_box(&[id]) else { + if wanted.is_some() { + return Err(bad(C, format!("object {} has no bounds to size", id.0))); + } + if turn.abs() > 1e-9 { + return Err(bad(C, format!("object {} has no bounds to rotate", id.0))); + } + continue; + }; let mut xf = Affine::IDENTITY; if let Some(q) = &wanted { let mut q = q.clone(); @@ -440,13 +454,33 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { q["strokes"] = json!(strokes); xf = object_bounds_transform(s, &q, id)?; } - if rotate { - // Turned about the reference point, which the sizing keeps in place; angles are - // counter-clockwise and y is down. - let turn = vectorcraft_geom::normalize_deg(angle - s.doc()?.doc.bbox_angle(&[id])); - if turn.abs() > 1e-9 { - let at = b.to_doc() * vectorcraft_geom::reference_point(b.rect, reference as usize); - xf = Affine::rotate_about(-turn.to_radians(), at) * xf; + if turn.abs() > 1e-9 { + // Rotation uses the reference point that sizing keeps in place. + let at = b.to_doc() * vectorcraft_geom::reference_point(b.rect, reference as usize); + xf = Affine::rotate_about(-turn.to_radians(), at) * xf; + } + if wanted.is_some() { + let sc = scaling(s, &json!({ "strokes": strokes })); + let d = &s.doc()?.doc; + let symbols = d.symbol_boxes(); + let measure = |xf| { + d.node(id).and_then(|n| { + let mut n = n.clone(); + transform_node(&mut n, xf, sc, true); + let frame = OrientedBox { angle: n.bbox_angle, rect: Rect::ZERO }; + effects::preview::bounds_in_with(&symbols, &n, frame.to_doc().inverse(), s.bounds_measure()) + }) + }; + let misses = |measured: Option| { + measured.is_none_or(|r| match size { + "width" => (r.width() - w).abs() > 1e-6, + "height" => (r.height() - h).abs() > 1e-6, + _ => (r.width() - w).abs() > 1e-6 || (r.height() - h).abs() > 1e-6, + }) + }; + // The sized and turned object, measured in its final frame, must have the size asked for. + if misses(measure(xf)) { + return Err(bad(C, format!("object {} can't take the requested size", id.0))); } } xfs.push((id, xf)); @@ -454,6 +488,22 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { let still = |xf: &Affine| xf.as_coeffs().iter().zip(Affine::IDENTITY.as_coeffs()).all(|(a, b)| (a - b).abs() <= 1e-9); xfs.retain(|(_, xf)| !still(xf)); let restack = stacking && !stacked_above(&s.doc()?.doc, source, &targets); + let (mut placed, mut left) = (vec![], vec![]); + if restack { + let d = &s.doc()?.doc; + // In a clip group or a clipping layer the bottom child is the clipping path: it stays there. + let is_clip = + |id: &NodeId| d.position(*id).is_some_and(|(_, idx, _)| idx == 0) && d.parent_of(*id).and_then(|p| d.node(p)).is_some_and(Node::clips); + if targets.iter().any(is_clip) { + return Err(bad(C, "a clipping path can't change its place in the stacking order")); + } + let parent = d.parent_of(source); + if let Some(what) = targets.iter().filter_map(|id| d.node(*id)).find_map(|n| crate::cmd::intertwine::refused_in(d, parent, n)) { + return Err(bad(C, format!("{what} can't be intertwined"))); + } + placed = targets.iter().map(|i| (*i, d.parent_of(*i))).collect::)>>(); + left = crate::cmd::intertwine::groups_of(d, &targets); + } let count = json!({ "source": source.0, "count": targets.len() }); if xfs.is_empty() && !restack { return Ok(count); @@ -471,6 +521,8 @@ fn match_objects(s: &mut Session, p: &Value) -> Result { if restack { let moved = d.remove_many(&targets)?; d.insert_beside(vec![(source, moved.into_iter().map(Arc::unwrap_or_clone).collect())], false)?; + // Targets moved out of an Intertwine group leave it as ordinary art. + crate::cmd::intertwine::settle_members(d, &placed, &left)?; } Ok(()) })?; diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index ea5d4aca06..265ab50a6a 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -424,6 +424,65 @@ fn match_turns_the_others_to_the_sources_angle() { assert!(s.transform_box(&[a]).unwrap().angle.abs() < 1e-6); } +#[test] +fn match_size_and_rotation_measure_pixel_aligned_art_in_its_final_frame() { + for size in ["width", "height", "both"] { + let mut s = session(); + let target = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + select(&mut s, &[target]); + s.execute("object.setPixelAligned", &json!({"on": true})).unwrap(); + let source = rect(&mut s, 100.0, 0.0, 10.5, 10.5); + select(&mut s, &[source]); + s.execute("object.rotate", &json!({"angle": 30})).unwrap(); + let wanted = s.transform_box(&[source]).unwrap(); + select(&mut s, &[target, source]); + s.execute("select.key", &json!({"id": source.0})).unwrap(); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + let r = s.execute("addon.arrange.match", &json!({"size": size, "rotate": true})).unwrap(); + assert_eq!(r, json!({"source": source.0, "count": 1})); + let measured = s.transform_box(&[target]).unwrap(); + assert!((measured.angle - wanted.angle).abs() < 1e-6, "{size}: {measured:?}"); + assert!((measured.rect.width() - wanted.rect.width()).abs() < 1e-6, "{size}: {measured:?}"); + assert!((measured.rect.height() - wanted.rect.height()).abs() < 1e-6, "{size}: {measured:?}"); + assert_eq!(steps(&s), n + 1); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(*s.doc().unwrap().doc == *before); + } +} + +#[test] +fn match_rotation_refuses_a_target_without_bounds_when_its_angle_differs() { + for angle in [0, 30] { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let target = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[a]); + s.execute("edit.clear", &json!({})).unwrap(); + let b = rect(&mut s, 100.0, 0.0, 10.0, 10.0); + let source = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("object.rotate", &json!({"angle": angle})).unwrap(); + select(&mut s, &[b]); + s.execute("edit.clear", &json!({})).unwrap(); + assert!(s.transform_box(&[target]).is_none()); + assert!(s.transform_box(&[source]).is_none()); + assert!((s.doc().unwrap().doc.bbox_angle(&[source]) - f64::from(angle)).abs() < 1e-6); + select(&mut s, &[target, source]); + s.execute("select.key", &json!({"id": source.0})).unwrap(); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + let result = s.execute("addon.arrange.match", &json!({"rotate": true})); + if angle == 0 { + assert_eq!(result.unwrap(), json!({"source": source.0, "count": 1})); + } else { + let error = result.unwrap_err().to_string(); + assert!(error.contains(&format!("object {} has no bounds to rotate", target.0)), "{error}"); + } + assert_eq!(steps(&s), n); + assert!(*s.doc().unwrap().doc == *before); + } +} + #[test] fn match_puts_the_others_directly_above_the_source() { let mut s = session(); @@ -514,10 +573,122 @@ fn replays_the_stroke_scaling_it_ran_with(cmd: &str, p: Value) { s.execute("edit.undo", &json!({})).unwrap(); s.execute("prefs.set", &json!({"key": "scaleStrokes", "value": false})).unwrap(); select(&mut s, &[a, b]); - s.execute(&id, &q).unwrap(); + s.replay(&id, &q).unwrap(); assert!((weight(&s) - 4.0).abs() < 1e-9, "{cmd} replayed: {}", weight(&s)); } +#[test] +fn match_stacking_leaves_a_clipping_path_in_place() { + let mut s = session(); + let art = rect(&mut s, 0.0, 0.0, 40.0, 40.0); + let mask = rect(&mut s, 10.0, 10.0, 10.0, 10.0); + select(&mut s, &[art, mask]); + s.execute("object.clippingMask.make", &json!({})).unwrap(); + let x = rect(&mut s, 200.0, 0.0, 10.0, 10.0); + select(&mut s, &[mask, x]); + s.execute("select.key", &json!({"id": x.0})).unwrap(); + refuses(&mut s, "addon.arrange.match", &[json!({"stacking": true})]); +} + +#[test] +fn match_size_refuses_a_target_with_no_width() { + let mut s = session(); + let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 0, "y2": 50})).unwrap()["id"].as_u64().unwrap()); + let b = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + select(&mut s, &[line, b]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + refuses(&mut s, "addon.arrange.match", &[json!({"size": "width"}), json!({"size": "both"})]); + // Its height can still take the source's. + s.execute("addon.arrange.match", &json!({"size": "height"})).unwrap(); + assert!((bounds(&s, line).height() - 20.0).abs() < 1e-6, "{:?}", bounds(&s, line)); +} + +#[test] +fn match_size_uses_preview_bounds_for_a_target_with_no_geometric_width() { + let mut s = session(); + s.execute("prefs.set", &json!({"key": "usePreviewBounds", "value": true})).unwrap(); + let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 0, "y2": 50})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[line]); + s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap(); + s.execute("stroke.set", &json!({"weight": 2, "cap": "butt"})).unwrap(); + let b = rect(&mut s, 100.0, 0.0, 2.0, 100.0); + select(&mut s, &[b]); + s.execute("paint.setStroke", &json!({"none": true})).unwrap(); + select(&mut s, &[line, b]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + s.execute("addon.arrange.match", &json!({"size": "both", "scaleStrokes": false})).unwrap(); + let measured = s.transform_box(&[line]).unwrap().rect; + let wanted = s.transform_box(&[b]).unwrap().rect; + assert!((measured.width() - wanted.width()).abs() < 1e-6, "{measured:?}"); + assert!((measured.height() - wanted.height()).abs() < 1e-6, "{measured:?}"); + select(&mut s, &[b]); + s.execute("object.setBounds", &json!({"width": 4})).unwrap(); + select(&mut s, &[line, b]); + s.execute("select.key", &json!({"id": b.0})).unwrap(); + refuses(&mut s, "addon.arrange.match", &[json!({"size": "both", "scaleStrokes": false})]); +} + +#[test] +fn match_stacking_takes_a_member_out_of_its_intertwine_group() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 40.0, 40.0); + let b = rect(&mut s, 20.0, 20.0, 40.0, 40.0); + select(&mut s, &[a, b]); + let g = NodeId(s.execute("object.intertwine.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("object.intertwine.arrange", &json!({"at": [30, 30], "order": "front", "member": a.0})).unwrap(); + assert!(s.doc().unwrap().doc.node(a).unwrap().extras().intertwine.is_some(), "a is drawn over b in their overlap"); + let c = rect(&mut s, 200.0, 0.0, 10.0, 10.0); + select(&mut s, &[a, c]); + s.execute("select.key", &json!({"id": c.0})).unwrap(); + s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap(); + let d = &s.doc().unwrap().doc; + assert_ne!(d.parent_of(a), Some(g), "a left the Intertwine group"); + let e = d.node(a).unwrap().extras(); + assert!(e.intertwine.is_none() && e.intertwine_tiers.is_empty(), "a keeps no Intertwine areas"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(g), "undo puts a back in its group"); +} + +#[test] +fn match_stacking_needs_no_bounds_on_the_source() { + let mut s = session(); + let b = rect(&mut s, 100.0, 0.0, 20.0, 20.0); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + let g = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute("edit.clear", &json!({})).unwrap(); + select(&mut s, &[b, g]); + s.execute("select.key", &json!({"id": g.0})).unwrap(); + s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap(); + assert_eq!(layer_order(&s), [g, b], "b goes directly above the empty group"); +} + +#[test] +fn match_stacking_refuses_intertwine_nesting_beside_an_empty_group() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 40.0, 40.0); + let source = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + let b = rect(&mut s, 20.0, 20.0, 40.0, 40.0); + select(&mut s, &[source, b]); + let parent = NodeId(s.execute("object.intertwine.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[a]); + s.execute("edit.clear", &json!({})).unwrap(); + assert!(s.transform_box(&[source]).is_none()); + assert_eq!(s.doc().unwrap().doc.parent_of(source), Some(parent)); + let c = rect(&mut s, 100.0, 0.0, 40.0, 40.0); + let d = rect(&mut s, 120.0, 20.0, 40.0, 40.0); + select(&mut s, &[c, d]); + let target = NodeId(s.execute("object.intertwine.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[source, target]); + s.execute("select.key", &json!({"id": source.0})).unwrap(); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + let error = s.execute("addon.arrange.match", &json!({"stacking": true})).unwrap_err().to_string(); + assert!(error.contains("can't be intertwined"), "{error}"); + assert_eq!(steps(&s), n); + assert!(*s.doc().unwrap().doc == *before); +} + #[test] fn match_replays_with_the_stroke_scaling_it_ran_with() { replays_the_stroke_scaling_it_ran_with("addon.arrange.match", json!({"size": "both"})); diff --git a/crates/ui-egui/src/addons/arrange.rs b/crates/ui-egui/src/addons/arrange.rs index 3c8483000d..a05d713244 100644 --- a/crates/ui-egui/src/addons/arrange.rs +++ b/crates/ui-egui/src/addons/arrange.rs @@ -30,7 +30,7 @@ const MATCH: &str = "addon.arrange.match"; const OPACITY: &str = "addon.arrange.randomizeOpacity"; const SORT: &str = "addon.arrange.sort"; /// Each dialog's command and heading. -const DIALOGS: [(&str, &str); 6] = [ +const DIALOGS: [(&str, &str); 7] = [ (GRID, "Arrange in Grid"), (OFFSET, "Offset Objects"), (REPLACE, "Replace with Top Object"), diff --git a/docs/mcp.md b/docs/mcp.md index 42bd2ef607..a9e9d9649a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17581,7 +17581,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.swap` | `size` (false); `scaleStrokes` (the Scale Strokes & Effects preference) | Swaps the bounds centres of exactly two selected objects (off otherwise); with `size`, each also takes the other's width and height. | | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | -| `addon.arrange.match` | `source`: `key` (the key object, `select.key`), `top` (the frontmost selected object), `bottom` (the backmost) (the key object when the selection has one, else `top`); `size`: `none`, `width` (the height follows in proportion), `height` (the width follows in proportion), `both` (`none`); `rotate` (false); `stacking` (false); `reference` 0…8 (4, the center); `scaleStrokes`; `patterns` (the Transform Pattern Tiles preference); at least one of `size`, `rotate` and `stacking` | Makes the other selected objects (at most 20000) match the source, which stays as it is. `size` gives each one the source's width, height or both, measured in each object's own bounding-box frame; `rotate` turns each one to the source's bounding-box angle; both keep each object's reference point in place. `stacking` puts the others directly above the source, in its layer or group, in the order they had. `source: "key"` without a key object, and a `size` that takes a width or a height the source does not have, are refused. To match places, use `object.align {to: "key"}`. → `{source, count}` | +| `addon.arrange.match` | `source`: `key` (the key object, `select.key`), `top` (the frontmost selected object), `bottom` (the backmost) (the key object when the selection has one, else `top`); `size`: `none`, `width` (the height follows in proportion), `height` (the width follows in proportion), `both` (`none`); `rotate` (false); `stacking` (false); `reference` 0…8 (4, the center); `scaleStrokes`; `patterns` (the Transform Pattern Tiles preference); at least one of `size`, `rotate` and `stacking` | Makes the other selected objects (at most 20000) match the source, which stays as it is. `size` gives each one the source's width, height or both, measured in each object's own bounding-box frame; `rotate` turns each one to the source's bounding-box angle; both keep each object's reference point in place. `stacking` puts the others directly above the source, in its layer or group, in the order they had. `source: "key"` without a key object, and a `size` that takes a width or a height the source or a target does not have, and a `stacking` match that would move a clipping path, are refused. To match places, use `object.align {to: "key"}`. → `{source, count}` | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | | `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index bde309e3c9..395fdda4de 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3148,7 +3148,7 @@ dialogs, Preview and Cancel, Zoom to Selection) and `command_sweep`. Commands: ` ## Arrange Tools add-on: Match Objects (2026-11-29) -A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Arrange Tools › Match Objects… makes the other top-level selected objects (at most 20000) match one of them, the source: the key object, or the top or the bottom selected object. Each can take the source's width (the height following in proportion), its height (the width following), or both, measured as `object.setBounds` measures them (Use Preview Bounds) in each object's own bounding-box frame; its bounding-box angle; and its stacking place, directly above the source in its layer or group, in the order they had. Sizing and turning keep each object's reference point in place, and strokes, effects and pattern tiles follow Scale Strokes & Effects and Transform Pattern Tiles. The source stays as it is, the dialog previews on the canvas, and OK is one undo step; no step when nothing changes. Places are matched with Align to Key Object (`object.align {to: "key"}`). Tests: `match_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (each size, the key, top and bottom sources, angles about the center, stacking within and across layers, no step when matched, bad params), `real_match_keyboard_edits_preview_confirm_and_cancel` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. +A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Arrange Tools › Match Objects… makes the other top-level selected objects (at most 20000) match one of them, the source: the key object, or the top or the bottom selected object. Each can take the source's width (the height following in proportion), its height (the width following), or both, measured as `object.setBounds` measures them (Use Preview Bounds) in each object's own bounding-box frame; its bounding-box angle; and its stacking place, directly above the source in its layer or group, in the order they had (a clipping path keeps its place, so such a match is refused). Sizing and turning keep each object's reference point in place, and strokes, effects and pattern tiles follow Scale Strokes & Effects and Transform Pattern Tiles. The source stays as it is, the dialog previews on the canvas, and OK is one undo step; no step when nothing changes. Places are matched with Align to Key Object (`object.align {to: "key"}`). Tests: `match_*` in `cmd::addons::arrange::tests` in `vectorcraft-engine` (each size, the key, top and bottom sources, angles about the center, stacking within and across layers, no step when matched, bad params), `real_match_keyboard_edits_preview_confirm_and_cancel` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Arrange Tools add-on. ## Arrange Tools add-on: Group Overlapping Objects (2026-11-01) From c1bfae38c20f96181fbe62dced597f63a1996576 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:11:19 -0800 Subject: [PATCH 157/264] Selection Tools: Edit Points Only keeps explicit anchor picks inside selected groups A path's own anchor pick now wins over its group's whole-path expansion in either selection order, a segmentEnds of null is rejected, and OK in the dialog runs the command outside the preview so dropping Puppet Warp pins adds no undo step. The docs say whole paths still take object transforms. --- crates/engine/src/cmd/addons/select.rs | 10 +++- crates/engine/src/cmd/addons/select/tests.rs | 46 ++++++++++++++++++- crates/ui-egui/src/addons/dialogs.rs | 12 ++++- .../src/addons/select/points_only/tests.rs | 26 +++++++++++ crates/ui-egui/src/dialogs/preview.rs | 6 +++ docs/mcp.md | 18 ++++---- 6 files changed, 105 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/cmd/addons/select.rs b/crates/engine/src/cmd/addons/select.rs index 6c3346ca80..bda973fb2c 100644 --- a/crates/engine/src/cmd/addons/select.rs +++ b/crates/engine/src/cmd/addons/select.rs @@ -54,7 +54,7 @@ pub fn specs() -> Vec { "Edit Points Only", ["Object", "Plug-ins", "Selection Tools"], None, - "{segmentEnds?: false (true: the points at the ends of each selected segment stay selected, as anchor points)} narrow the selection to the anchor points selected in it, so that a move or transform that follows acts on those points alone: a path with selected anchor points keeps them; a path with selected segments drops the segments and keeps its other selected anchor points, and the points at the segments' ends leave the selection unless segmentEnds is true; a path selected whole keeps all its points; a group or compound path selected whole gives way to the paths inside it, each selected whole, leaving out hidden and locked ones, a Shaper Group's original shapes and, while guides are locked, paths made into guides; type, images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. With nothing selected, or no anchor point left to keep, it is an error that leaves the selection as it was. Only the selection changes, not the document, so there is nothing to undo → {changed (false when the selection already held only anchor points), count (the paths left selected), points (the anchor points selected on them)}", + "{segmentEnds?: false (true: the points at the ends of each selected segment stay selected, as anchor points; any non-boolean value, including null, is an error)} narrow the selection to paths and their selected anchor points: a path with selected anchor points keeps them; a path with selected segments drops the segments and keeps its other selected anchor points, and the points at the segments' ends leave the selection unless segmentEnds is true; a path selected whole stays selected whole and still receives object transforms, including stroke and effect scaling when enabled; a group or compound path selected whole gives way to the paths inside it, each selected whole unless it has an explicit anchor pick, leaving out hidden and locked ones, a Shaper Group's original shapes and, while guides are locked, paths made into guides; explicit anchor picks take precedence regardless of selection order; type, images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. With nothing selected, or no anchor point left to keep, it is an error that leaves the selection as it was. The command does not add an undo step → {changed (false when the selection already held only anchor points), count (the paths left selected), points (the anchor points selected on them)}", has_doc, edit_points_only ), @@ -242,7 +242,10 @@ fn paths_inside<'a>(n: &'a Node, guides_locked: bool, out: &mut Vec<&'a Node>) { /// `addon.select.editPointsOnly`: narrow the selection to the anchor points selected in it. fn edit_points_only(s: &mut Session, p: &Value) -> Result { const C: &str = "addon.select.editPointsOnly"; - let keep_ends = switch_or(p, "segmentEnds", false, C)?; + let keep_ends = match p.get("segmentEnds") { + None => false, + Some(value) => value.as_bool().ok_or_else(|| bad(C, "`segmentEnds` must be true or false"))?, + }; let guides_locked = s.menu.guides_locked; let st = s.doc()?; let (doc, sel) = (&st.doc, &st.selection); @@ -278,6 +281,9 @@ fn edit_points_only(s: &mut Session, p: &Value) -> Result { let mut inside = vec![]; paths_inside(n, guides_locked, &mut inside); for c in inside { + if sel.objects.contains(&c.id) && sel.anchors.contains_key(&c.id) { + continue; + } if seen.insert(c.id) { kept.push((c.id, c.path_data().map_or(0, |path| path.anchors().count()), None)); } diff --git a/crates/engine/src/cmd/addons/select/tests.rs b/crates/engine/src/cmd/addons/select/tests.rs index 85844c241d..ec6054a237 100644 --- a/crates/engine/src/cmd/addons/select/tests.rs +++ b/crates/engine/src/cmd/addons/select/tests.rs @@ -426,6 +426,44 @@ mod edit_points_only { assert_eq!(picked(&s), (vec![a, b], BTreeMap::new())); } + #[test] + fn explicit_anchor_picks_override_group_expansion_in_either_order() { + for group_first in [true, false] { + let (mut s, a, b) = two(); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.select(|_, sel| { + sel.set(if group_first { vec![group, a] } else { vec![a, group] }); + sel.anchors.insert(a, refs(&[(0, 0)])); + }) + .unwrap(); + let before = s.doc().unwrap().doc.node(a).unwrap().path_data().unwrap().clone(); + assert_eq!(s.execute(C, &json!({})).unwrap(), json!({"changed": true, "count": 2, "points": 5})); + assert_eq!(s.doc().unwrap().selection.anchors[&a], refs(&[(0, 0)])); + s.execute("object.move", &json!({"dx": 10, "dy": 20})).unwrap(); + let after = s.doc().unwrap().doc.node(a).unwrap().path_data().unwrap(); + for ((_, i, old), (_, _, new)) in before.anchors().zip(after.anchors()) { + if i == 0 { + assert_ne!(new.p, old.p); + } else { + assert_eq!(new.p, old.p, "unselected anchors stay in place"); + } + } + } + } + + #[test] + fn whole_paths_keep_object_transforms_and_stroke_scaling() { + let (mut s, a, _) = two(); + s.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + s.execute("stroke.set", &json!({"weight": 4})).unwrap(); + let before = s.doc().unwrap().doc.node(a).unwrap().appearance.stroke_width(); + s.execute(C, &json!({})).unwrap(); + assert!(!s.doc().unwrap().selection.anchors.contains_key(&a)); + s.execute("object.transform", &json!({"matrix": [2, 0, 0, 2, 0, 0], "strokes": true})).unwrap(); + assert!(s.doc().unwrap().doc.node(a).unwrap().appearance.stroke_width() > before); + } + #[test] fn groups_and_compound_paths_give_way_to_their_paths_and_other_objects_leave() { let (mut s, a, b) = two(); @@ -487,7 +525,13 @@ mod edit_points_only { let e = s.execute(C, &json!({})).unwrap_err().to_string(); assert!(e.contains("no anchor points are selected"), "{e}"); assert_eq!(s.doc().unwrap().selection, before); - for p in [json!({"segmentEnds": "yes"}), json!({"segmentEnds": 1}), json!({"segmentEnds": [true]}), json!({"segmentEnd": true})] { + for p in [ + json!({"segmentEnds": null}), + json!({"segmentEnds": "yes"}), + json!({"segmentEnds": 1}), + json!({"segmentEnds": [true]}), + json!({"segmentEnd": true}), + ] { s.execute("select.anchors", &json!({"id": b.0, "anchors": [[0, 0]]})).unwrap(); s.execute("select.segments", &json!({"id": a.0, "segments": [[0, 0]], "mode": "add"})).unwrap(); let before = s.doc().unwrap().selection.clone(); diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index 3273764d5f..c2d1f138de 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -157,8 +157,16 @@ fn pump_commit(app: &mut VectorcraftApp) { app.status("The document was reverted. Reopen this dialog to continue."); } else if !on_document { app.status("The add-on settings apply only to the drawing where the dialog opened."); - } else if let Err(error) = preview.commit(app, spec.command, (spec.params)(&result.fields)) { - app.status(error); + } else { + let params = (spec.params)(&result.fields); + let answer = if spec.command == super::select::points_only::COMMAND { + preview.commit_selection(app, spec.command, params) + } else { + preview.commit(app, spec.command, params) + }; + if let Err(error) = answer { + app.status(error); + } } } Some(None) => { diff --git a/crates/ui-egui/src/addons/select/points_only/tests.rs b/crates/ui-egui/src/addons/select/points_only/tests.rs index 21285a1e8e..ba0bc13b73 100644 --- a/crates/ui-egui/src/addons/select/points_only/tests.rs +++ b/crates/ui-egui/src/addons/select/points_only/tests.rs @@ -55,6 +55,32 @@ fn the_dialog_previews_keeps_on_ok_and_takes_the_segment_ends_from_the_keyboard( assert_eq!(app.session.doc().unwrap().history.undo.len(), undo, "a selection change is not an undo step"); } +#[test] +fn ok_drops_puppet_pins_without_an_undo_step() { + for previewing in [true, false] { + let (mut app, a, b) = app(); + app.run("select.set", json!({"ids": [a.0, b.0]})).unwrap(); + app.run("object.group", json!({})).unwrap(); + app.run("object.puppetWarp", json!({"pins": [[35, 35]], "moved": [[35, 35]], "rest": true})).unwrap(); + assert!(app.session.doc().unwrap().doc.puppet.is_some()); + let undo = app.session.doc().unwrap().history.undo.len(); + host::open_item(&mut app, "Selection Tools", "Edit Points Only…"); + let id = host::dialog_id(&app); + if previewing { + host::frame(&mut app); + assert!(app.session.doc().unwrap().doc.puppet.is_none()); + } + assert!(host::confirm(&app, id)); + host::frame(&mut app); + assert!(!app.any_dialog_open()); + let st = app.session.doc().unwrap(); + assert!(st.doc.puppet.is_none()); + assert_eq!(st.selection.objects, vec![a, b]); + assert!(!app.session.in_interaction()); + assert_eq!(st.history.undo.len(), undo, "pin cleanup does not add an undo step"); + } +} + #[test] fn cancel_puts_the_selection_back() { let (app, _, b) = app(); diff --git a/crates/ui-egui/src/dialogs/preview.rs b/crates/ui-egui/src/dialogs/preview.rs index 2e029fc1c6..f1585adc6b 100644 --- a/crates/ui-egui/src/dialogs/preview.rs +++ b/crates/ui-egui/src/dialogs/preview.rs @@ -125,6 +125,12 @@ impl LivePreview { Ok(Value::Null) } + /// OK for a selection command: rolls its preview back and runs the command without an interaction. + pub(crate) fn commit_selection(self, app: &mut VectorcraftApp, cmd: &str, params: Value) -> Result { + self.cancel(app); + Self::default().commit(app, cmd, params) + } + /// Cancel: rolls a shown preview back, and leaves any other edit in progress as it is. pub(crate) fn cancel(self, app: &mut VectorcraftApp) { if self.previewed.is_some() && self.owns(app) { diff --git a/docs/mcp.md b/docs/mcp.md index 1c9c20ff48..65c28a7c38 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17313,18 +17313,20 @@ locked". Select by Link Status… lists every image and placed document with its name and filters by status (Show), chooses rows with checkboxes (All / None act on the rows shown), and on Select selects the rows chosen, zooming to them when Zoom to Selection is on (the default). -`addon.select.editPointsOnly {segmentEnds?}` (Edit Points Only…) narrows the selection to the anchor points selected in -it, so that a move or transform that follows acts on those points alone. A path with selected anchor points keeps them. +`addon.select.editPointsOnly {segmentEnds?}` (Edit Points Only…) narrows the selection to paths and their selected +anchor points. A path with selected anchor points keeps them. A path with selected segments drops the segments and keeps its other selected anchor points; the points at the ends of the segments leave the selection unless `segmentEnds` is `true` (default `false`), which keeps them as selected anchor -points. A path selected whole keeps all its points. A group or compound path selected whole is replaced by the paths -inside it, each selected whole, without hidden and locked ones, without a Shaper Group's original shapes and, while -guides are locked, without paths made into guides. Type, -images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. Only the -selection changes, so there is nothing to undo. It returns `{changed, count, points}`: `changed` is `false` when the +points. A path selected whole stays selected whole and still receives object transforms, including stroke and effect +scaling when enabled. A group or compound path selected whole is replaced by the paths +inside it, each selected whole unless it has an explicit anchor pick. Explicit anchor picks take precedence regardless +of selection order. The command leaves out hidden and locked paths, a Shaper Group's original shapes and, while +guides are locked, paths made into guides. Type, +images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. The command +does not add an undo step. It returns `{changed, count, points}`: `changed` is `false` when the selection already held only anchor points, `count` is the number of paths left selected and `points` the number of anchor points selected on them. Nothing selected, no anchor point left to keep ("no anchor points are selected"), or a -`segmentEnds` that is not `true` or `false` is an error, and the selection is left as it was. +`segmentEnds` that is not `true` or `false` (including `null`) is an error, and the selection is left as it was. ```json {"name":"run_command","arguments":{"command":"addon.select.editPointsOnly","params":{"segmentEnds":false}}} From 5367d0e668e99cddd97366274576fd3f9dc4f968 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:32:05 -0800 Subject: [PATCH 158/264] Sonar: exclude lcov.info, tests and the catalog tables, and set the Python version The SonarCloud scan printed three warnings that sonar-project.properties can clear: - sonar.exclusions=lcov.info: sonar.sources=. indexed the coverage report (over 20 MB), and the scanner warned and dropped it. - sonar.cpd.exclusions: duplication now skips the test-file patterns, crates/ui-egui/src/menus/ui_commands.rs and the MCP catalog generated from it, which gave 32 "Too many duplication" warnings. The value is on one line because the shared Sonar workflow reads it with one sed line and adds **/i18n/**. - sonar.python.version=3.12, 3.13, 3.14, 3.15: the versions CI runs the scripts in packaging/ and scripts/ with (3.12 on Ubuntu 24.04, 3.13 from setup-python in the nightly jobs, 3.15 on macOS 15). --- sonar-project.properties | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 9523d64b0e..cf06216650 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -10,6 +10,17 @@ sonar.sources=. sonar.tests=. sonar.test.inclusions=**/tests/**,**/tests.rs,**/*_tests.rs,**/tests_*.rs +# The coverage job writes lcov.info at the root, where sonar.sources=. would index it. +sonar.exclusions=lcov.info + +# Duplication skips test files, the UI command table and the MCP catalog generated from it. +# The shared Sonar workflow reads this property from a single line and adds **/i18n/** to it. +sonar.cpd.exclusions=**/tests/**,**/tests.rs,**/*_tests.rs,**/tests_*.rs,crates/ui-egui/src/menus/ui_commands.rs,crates/mcp/src/ui_catalog.rs + +# CI runs the scripts in packaging/ and scripts/ with Python 3.12 (Ubuntu 24.04), 3.13 +# (setup-python in the nightly jobs) and 3.15 (macOS 15). +sonar.python.version=3.12, 3.13, 3.14, 3.15 + # S4790 (weak hash): MD5 is the key derivation of the PDF standard security handler revisions 2-4 # (ISO 32000-1 §7.6.3.3), which PDF 1.3-1.6 files use. It is needed to read those files and to write # the compatibility the user picks, not chosen for new security: the default is 256-bit AES From c1eb29c054149dcea42ac9275ac7d6199777f37c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:39:26 -0800 Subject: [PATCH 159/264] Docs: doc comments name U+FFFD in place of the literal character Two doc comments held a literal U+FFFD replacement character, which SonarCloud reports as "Invalid character encountered". They now write it as `\u{FFFD}`: - crates/ui-egui/src/panels/actions/playback.rs (`shown_text`) - crates/pdf/src/tests/realtext.rs (the #708, #811 test) --- crates/pdf/src/tests/realtext.rs | 2 +- crates/ui-egui/src/panels/actions/playback.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/pdf/src/tests/realtext.rs b/crates/pdf/src/tests/realtext.rs index 7d1ac97027..7fcd06dd56 100644 --- a/crates/pdf/src/tests/realtext.rs +++ b/crates/pdf/src/tests/realtext.rs @@ -801,7 +801,7 @@ fn digits_unnamed(text: &str) -> Vec { out } -/// #708, #811: a glyph whose ToUnicode value is U+FFFD isn't type showing "�". This subset font +/// #708, #811: a glyph whose ToUnicode value is U+FFFD isn't type showing `\u{FFFD}`. This subset font /// has no character map of its own, but the font is installed: each digit is found by its outline /// there, so the whole text stays one type object, with no outlines left behind. #[test] diff --git a/crates/ui-egui/src/panels/actions/playback.rs b/crates/ui-egui/src/panels/actions/playback.rs index bff0bd1d4d..ca9547889f 100644 --- a/crates/ui-egui/src/panels/actions/playback.rs +++ b/crates/ui-egui/src/panels/actions/playback.rs @@ -158,7 +158,7 @@ pub(crate) fn step_place(step: usize, in_batch: Option) -> String { } } -/// `text` as a status message shows it: control characters become `�`, and text past 80 +/// `text` as a status message shows it: control characters become `\u{FFFD}`, and text past 80 /// characters ends in `…`. pub(crate) fn shown_text(text: &str) -> String { const MAX: usize = 80; From 9d2b0a93d909dde08ebec7d58988e92fa3ea5d89 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:39:45 -0800 Subject: [PATCH 160/264] Packaging: unsigned Windows builds the caller asked for print a notice sign.ps1 printed "Windows signing secrets not set" as a ::warning:: annotation in every workflow that builds without signing secrets, including the Windows ARM64 package job, which has none by design. A caller that wants unsigned output now sets CRAFT_ALLOW_UNSIGNED=1, and the same message is printed as a ::notice:: instead. Without the variable the warning stays. Any other value is rejected with an error. -Required still refuses to run without signing material. The signing suite checks the warning without the variable, the notice with CRAFT_ALLOW_UNSIGNED=1, and the error for other values. --- packaging/windows/nightly-signing-tests.ps1 | 23 +++++++++++++++++++++ packaging/windows/sign.ps1 | 15 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packaging/windows/nightly-signing-tests.ps1 b/packaging/windows/nightly-signing-tests.ps1 index 51a8e2ade9..535ad4e222 100644 --- a/packaging/windows/nightly-signing-tests.ps1 +++ b/packaging/windows/nightly-signing-tests.ps1 @@ -73,6 +73,29 @@ try { Clear-SigningFixtures Write-Output 'PASS: supported-configuration-presence-without-signing' + # The unsigned message is captured here, so it does not become an annotation of this job. + $optInFile = Join-Path $root 'opt-in-sentinel.exe' + [IO.File]::WriteAllText($optInFile, 'generated sentinel, not a real executable') + $savedActions = $env:GITHUB_ACTIONS + try { + $env:GITHUB_ACTIONS = 'true' + $env:CRAFT_ALLOW_UNSIGNED = $null + $default = (& $sign $optInFile) -join "`n" + Assert-Policy ($default.Contains('::warning::Windows signing secrets not set')) "unsigned output without the opt-in must warn; got: $default" + $env:CRAFT_ALLOW_UNSIGNED = '1' + $optedIn = (& $sign $optInFile) -join "`n" + Assert-Policy ($optedIn.Contains('::notice::Windows signing secrets not set')) "opted-in unsigned output must be a notice; got: $optedIn" + Assert-Policy (-not $optedIn.Contains('::warning::')) "opted-in unsigned output must not warn; got: $optedIn" + foreach ($value in @('true', '0', 'yes')) { + $env:CRAFT_ALLOW_UNSIGNED = $value + Invoke-Refusal { & $sign $optInFile } 'CRAFT_ALLOW_UNSIGNED must be 1 or unset' + } + } finally { + $env:CRAFT_ALLOW_UNSIGNED = $null + $env:GITHUB_ACTIONS = $savedActions + } + Write-Output 'PASS: opted-in-unsigned-output-is-a-notice' + # Load the policy function without signing. These objects are not crypto evidence. . $sign -CheckOnly foreach ($value in @($null, [pscustomobject]@{Status='NotSigned';SignerCertificate='fixture'}, [pscustomobject]@{Status='HashMismatch';SignerCertificate='fixture'}, [pscustomobject]@{Status='Valid';SignerCertificate=$null})) { diff --git a/packaging/windows/sign.ps1 b/packaging/windows/sign.ps1 index 11a391dd60..2a768c7338 100644 --- a/packaging/windows/sign.ps1 +++ b/packaging/windows/sign.ps1 @@ -9,7 +9,8 @@ AZURE_SIGNING_ENDPOINT (e.g. https://eus.codesigning.azure.net), AZURE_SIGNING_ACCOUNT, AZURE_CERT_PROFILE With neither, it prints a warning and leaves the files unsigned (exit code 0), so test builds - still produce installers. Nightly callers require signing with -Required and can check the + still produce installers. A caller that builds unsigned on purpose sets CRAFT_ALLOW_UNSIGNED=1, + and the message is then a notice instead of a warning. Nightly callers require signing with -Required and can check the signing configuration with -Required -CheckOnly. Compilation uses the separate -CheckBuildEnvironment mode, which refuses any signing material without importing a key. @@ -38,6 +39,10 @@ function Write-Warn([string] $Message) { if ($env:GITHUB_ACTIONS) { Write-Output "::warning::$Message" } else { Write-Warning $Message } } +function Write-Note([string] $Message) { + if ($env:GITHUB_ACTIONS) { Write-Output "::notice::$Message" } else { Write-Output $Message } +} + function Find-SignTool { if ($env:SIGNTOOL) { return $env:SIGNTOOL } $onPath = Get-Command signtool.exe -ErrorAction SilentlyContinue @@ -64,6 +69,11 @@ if ($CheckBuildEnvironment) { } return } +$allowUnsigned = switch -CaseSensitive ([string]$env:CRAFT_ALLOW_UNSIGNED) { + '' { $false } + '1' { $true } + default { throw "CRAFT_ALLOW_UNSIGNED must be 1 or unset, got '$env:CRAFT_ALLOW_UNSIGNED'" } +} $haveCert = [bool]$env:WINDOWS_CERTIFICATE $haveAzure = -not ($azureVars | Where-Object { -not [Environment]::GetEnvironmentVariable($_) }) @@ -78,7 +88,8 @@ if (-not $Files) { throw 'At least one file is required for signing' } $Files = $Files | ForEach-Object { (Resolve-Path $_).Path } if (-not $haveCert -and -not $haveAzure) { - Write-Warn "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')" + $message = "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')" + if ($allowUnsigned) { Write-Note $message } else { Write-Warn $message } exit 0 } From 9a588078419876ffa2ec576ecc13678718a74812 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:44:27 -0800 Subject: [PATCH 161/264] Performance: a move finds the selected objects' places in fewer walks of the tree With 10,000 objects selected, object.move walked the document's tree five times and looked each object up by id three times. It now walks the tree three times and looks each object up once. - The selected roots (for the menus, for Move, Rotate, Scale and the other transforms, for Copy and Cut, and inside an isolated group) are put in paint order and reduced to their top-level objects from one walk instead of two. - A transform finds the objects' places once for Transform Patterns and for the edit, instead of once for each. - After a transform, the check for a pixel-aligned compound path reads the parent at the object's place instead of looking the object and its parent up by id. --- crates/engine/src/cmd/edit.rs | 30 +++++++++++++++++++---- crates/engine/src/cmd/edit/tests.rs | 30 +++++++++++++++++++++++ crates/engine/src/cmd/object/pixelgrid.rs | 12 +++++++++ crates/engine/src/cmd/object/transform.rs | 18 +++++++++----- crates/engine/src/tests/large_edits.rs | 18 ++++++++++++++ 5 files changed, 97 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 4fc1b83c29..70d7547313 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -967,7 +967,8 @@ pub(crate) fn selection_roots(st: &crate::DocState) -> Vec { } #[cfg(test)] ROOTS_FOUND.set(ROOTS_FOUND.get() + 1); - let roots = roots_of(&st.doc, st.selection.in_paint_order(&st.doc)); + let (ids, paths) = placed_in_paint_order(&st.doc, &st.selection.objects); + let roots = roots_placed(&st.doc, ids, &paths, |_, _| false); *kept = Some((Arc::downgrade(&st.doc), st.selection.objects.clone(), roots.clone())); roots }) @@ -1015,7 +1016,19 @@ pub(crate) fn no_symbol_part(s: &Session) -> std::result::Result<(), String> { pub(crate) fn selected_roots_to_transform(s: &Session) -> Result> { refuse_symbol_part(s)?; let st = s.doc()?; - Ok(roots_within(&st.doc, st.selection.in_paint_order(&st.doc), |_, _| true)) + let (ids, paths) = placed_in_paint_order(&st.doc, &st.selection.objects); + Ok(roots_placed(&st.doc, ids, &paths, |_, _| true)) +} + +/// The objects of `objects` that are in `doc`, in paint order as +/// [`vectorcraft_doc::Selection::in_paint_order`] gives them, with their places in the tree. One +/// walk finds the places for both the order and [`roots_placed`] ([`roots_within`] after +/// `in_paint_order` walks the tree twice). +fn placed_in_paint_order(doc: &Document, objects: &[NodeId]) -> (Vec, HashMap>) { + let paths = doc.index_paths(objects.iter().copied()); + let mut ids: Vec = objects.iter().copied().filter(|id| paths.contains_key(id)).collect(); + ids.sort_by(|a, b| paths.get(a).cmp(&paths.get(b))); + (ids, paths) } /// [`selected_roots`] for the selected objects inside the isolated object `root` @@ -1027,8 +1040,9 @@ pub(crate) fn selected_roots_to_transform(s: &Session) -> Result> { pub(crate) fn selected_roots_inside(s: &Session, root: NodeId, members: bool) -> Result> { refuse_symbol_part(s)?; let st = s.doc()?; - let ids = st.selection.in_paint_order(&st.doc).into_iter().filter(|id| super::inside_isolation(&st.doc, root, *id)).collect(); - Ok(roots_within(&st.doc, ids, |compound, _| members || compound == root)) + let (ids, paths) = placed_in_paint_order(&st.doc, &st.selection.objects); + let ids = ids.into_iter().filter(|id| super::inside_isolation(&st.doc, root, *id)).collect(); + Ok(roots_placed(&st.doc, ids, &paths, |compound, _| members || compound == root)) } /// The top-level objects among `ids` (in paint order): compound-path members stand for their @@ -1042,6 +1056,11 @@ pub(crate) fn roots_of(doc: &Document, ids: Vec) -> Vec { fn roots_within(doc: &Document, ids: Vec, keep_member: impl Fn(NodeId, NodeId) -> bool) -> Vec { // Every id's place in the tree, found in one walk (a lookup per id is a walk per id). let paths = doc.index_paths(ids.iter().copied()); + roots_placed(doc, ids, &paths, keep_member) +} + +/// [`roots_within`] with `paths`, the places of `ids` in `doc`'s tree, found already. +fn roots_placed(doc: &Document, ids: Vec, paths: &HashMap>, keep_member: impl Fn(NodeId, NodeId) -> bool) -> Vec { // A compound-path member acts as its compound (compounds are one object). let mut sel: Vec<(NodeId, Option>)> = ids .into_iter() @@ -1105,7 +1124,8 @@ fn copy_cut_targets(s: &Session) -> Result<(bool, Vec)> { st.doc.node(compound).and_then(|n| n.children()).is_some_and(|members| !members.is_empty() && members.iter().all(|m| whole(m))) }) }; - let roots = roots_within(&st.doc, st.selection.in_paint_order(&st.doc), |compound, _member| in_isolated_compound || !all_members_whole(compound)); + let (ids, paths) = placed_in_paint_order(&st.doc, &st.selection.objects); + let roots = roots_placed(&st.doc, ids, &paths, |compound, _member| in_isolated_compound || !all_members_whole(compound)); Ok((direct, roots)) } diff --git a/crates/engine/src/cmd/edit/tests.rs b/crates/engine/src/cmd/edit/tests.rs index 7ac2d9c162..7e0471f0f5 100644 --- a/crates/engine/src/cmd/edit/tests.rs +++ b/crates/engine/src/cmd/edit/tests.rs @@ -348,6 +348,36 @@ fn direct_selection_cut_timing() { } } +/// Finding the selected roots (for the menus, for Move and its siblings, for Copy and Cut, and +/// inside an isolated group) walks the tree once for the paint order and the roots together, in +/// paint order whatever order the objects were selected in. +#[test] +fn finding_the_selected_roots_walks_the_tree_once() { + let mut s = session(2_000, square); + let all = crate::tests_large_edits::layer(&s, 0); + let reversed: Vec = all.iter().rev().map(|id| id.0).collect(); + s.execute("select.set", &json!({"ids": reversed})).unwrap(); + type Find = fn(&Session) -> Vec; + let finds: [(&str, Find); 3] = [ + ("the selected roots", |s| selected_roots(s).unwrap()), + ("the roots to transform", |s| selected_roots_to_transform(s).unwrap()), + ("Copy's targets", |s| copy_cut_targets(s).unwrap().1), + ]; + for (what, find) in finds { + let walks = tree_walks(); + assert!(find(&s) == all, "{what} in paint order"); + assert_eq!(tree_walks() - walks, 1, "finding {what} walked the tree {} times", tree_walks() - walks); + } + s.execute("object.group", &json!({})).unwrap(); + let group = s.doc().unwrap().doc.layers[0].children().unwrap()[0].id; + s.execute("select.set", &json!({"ids": reversed})).unwrap(); + // The first call also builds the lookup cache that the isolation check reads. + assert!(selected_roots_inside(&s, group, false).unwrap() == all, "the roots inside the group in paint order"); + let walks = tree_walks(); + assert!(selected_roots_inside(&s, group, false).unwrap() == all); + assert_eq!(tree_walks() - walks, 1, "finding the roots inside the group walked the tree {} times", tree_walks() - walks); +} + /// The selected roots are found once for a document version and its selected objects, however many enabled checks /// read them, and found again after the selection changes, after an edit, and for another selection. #[test] diff --git a/crates/engine/src/cmd/object/pixelgrid.rs b/crates/engine/src/cmd/object/pixelgrid.rs index 81909da76f..220ed30099 100644 --- a/crates/engine/src/cmd/object/pixelgrid.rs +++ b/crates/engine/src/cmd/object/pixelgrid.rs @@ -142,6 +142,18 @@ pub(crate) fn keep_compound_aligned(d: &mut Document, id: NodeId, sc: Scaling) { } } +/// [`keep_compound_aligned`] for the object at `path` in `d`'s tree, found already: the compound +/// path is read at the parent's place, without looking either object up by id. +pub(crate) fn keep_compound_aligned_at(d: &mut Document, path: &[usize], sc: Scaling) { + let Some((_, up)) = path.split_last() else { return }; + if up.is_empty() || !d.node_at(up).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. }) && n.extras().pixel_aligned) { + return; + } + if let Some(n) = d.node_mut_at(up) { + snap_object(n, sc); + } +} + /// After any edit ([`Session::edit`]): snap each pixel-aligned object that the edit changed or added /// (its node in `doc` is not the one in `before`), with the pixel-aligned art of its linked opacity /// mask, to the pixel grid. Objects the edit did not touch are not visited. diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index 1a15e44aa3..3f471a00fe 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -66,10 +66,15 @@ pub(super) fn scaling_options(s: &Session, p: &Value) -> Scaling { /// param, else General › Transform Pattern Tiles)? Noted in the journal when they or the art of /// their linked opacity masks use a pattern, so a replay moves their tiles alike whatever the preference is then. pub(crate) fn transform_patterns(s: &mut Session, p: &Value, ids: &[NodeId]) -> Result { + let paths = s.doc()?.doc.index_paths(ids.iter().copied()); + transform_patterns_at(s, p, ids, &paths) +} + +/// [`transform_patterns`] with `paths`, the places of `ids` in the document's tree, found already. +fn transform_patterns_at(s: &mut Session, p: &Value, ids: &[NodeId], paths: &std::collections::HashMap>) -> Result { let on = bool_or(p, "patterns", s.prefs.transform_pattern_tiles); let d = &s.doc()?.doc; let mut uses = false; - let paths = d.index_paths(ids.iter().copied()); for n in ids.iter().filter_map(|id| paths.get(id)).filter_map(|p| d.node_at(p)) { uses |= uses_pattern_with_masks(n); } @@ -152,7 +157,9 @@ fn apply_transform_moving_guides( let areas = bool_or(p, "typeAreas", false); let objects = transforms_objects(p); let mut sc = if Scaling::factor(xf).is_some() { scaling(s, p) } else { Scaling::default() }; - sc.patterns = transform_patterns(s, p, &ids)?; + // The places of `ids`, found in one walk for Transform Patterns and for the edit below. + let paths = s.doc()?.doc.index_paths(ids.iter().copied()); + sc.patterns = transform_patterns_at(s, p, &ids, &paths)?; let c = xf.as_coeffs(); let is_translation = (c[0] - 1.0).abs() < 1e-9 && c[1].abs() < 1e-9 && c[2].abs() < 1e-9 && (c[3] - 1.0).abs() < 1e-9; let delta = guides.unwrap_or(Vec2::new(c[4], c[5])); @@ -174,8 +181,6 @@ fn apply_transform_moving_guides( // An edit normally preserves the tree positions already found here. Settling an active // typing session can change the document before the edit closure runs, so look up again then. let reindex = copy || (!s.previewing && crate::cmd::typing_in_progress(s)); - let d = &s.doc()?.doc; - let paths = d.index_paths(ids.iter().copied()); let none = paths.is_empty() && !has_guides; // A move of direct-selected anchors may re-map the handles beside them (`interpolate`). let mut interpolate = None; @@ -230,8 +235,9 @@ fn apply_transform_moving_guides( } } if objects { - for id in &targets { - super::pixelgrid::keep_compound_aligned(d, *id, sc); + // The transforms above leave every object at its place, so `paths` still holds them. + for p in targets.iter().filter_map(|id| paths.get(id)) { + super::pixelgrid::keep_compound_aligned_at(d, p, sc); } // Moving all of the tile art moves the tile as far. if let Some(before) = tile_art { diff --git a/crates/engine/src/tests/large_edits.rs b/crates/engine/src/tests/large_edits.rs index 0394fb18fa..2806cdd925 100644 --- a/crates/engine/src/tests/large_edits.rs +++ b/crates/engine/src/tests/large_edits.rs @@ -253,6 +253,24 @@ fn transform_each_with_copy_of_50000_objects_takes_few_tree_walks() { undo_gives_back(&mut s, &before); } +/// A move of 10,000 selected objects walks the tree once for the paint order and the top-level +/// objects, once for Transform Patterns and the edit, and once for the selection's check after the +/// edit. It reads each object's compound path at the object's place, so the only lookups by id are +/// the range check's, one per object. +#[test] +fn moving_10000_selected_objects_walks_the_tree_three_times() { + let n = 10_000; + let mut s = session(n, square); + let ids = layer(&s, 0); + let (walks, lookups) = (vectorcraft_doc::tree_walks(), vectorcraft_doc::path_lookups()); + s.execute("object.move", &json!({"dx": 3, "dy": 0})).unwrap(); + let (walks, lookups) = (vectorcraft_doc::tree_walks() - walks, vectorcraft_doc::path_lookups() - lookups); + assert_eq!(walks, 3, "walked the tree {walks} times"); + assert!(lookups <= n as u64, "{lookups} lookups by id for {n} objects"); + assert_eq!(bounds(&s, ids[n - 1]), square_at(n - 1) + vectorcraft_geom::Vec2::new(3.0, 0.0)); + assert!(selected(&s, &ids)); +} + #[test] fn offset_path_of_50000_objects_takes_few_tree_walks() { let s = session(50_000, square); From f99ef023ad76a2a1da0e76a7abd3706119e60b69 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:49:37 -0800 Subject: [PATCH 162/264] Scripts: close checks the artboards the saved file keeps; saves report warnings Document.close(SaveOptions.SAVECHANGES) now judges artboard loss by the file the save writes. A PDF last saved with useArtboards: false is refused, since it holds one page of the art's bounds. A native or .ai file saved with separateArtboards is saved and closed whatever its range names, since the range picks only the separate files; a version 7 .ai file keeps the range check. Document.saveAs, Document.exportFile, app.open and the save that close(SaveOptions.SAVECHANGES) runs write each warning of their command to the console after the method's name (for example "saveAs: SVG keeps 1 of the document's 2 artboards ..."). Script Check reports a file write for a saveAs or exportFile call on the script's own object when the variable is assigned in a loop around the call, since a later iteration may run the call on a document. Loop bodies without braces follow if, else and line breaks, and a variable of the same name that a function declares is kept apart. A test shows that a waiting point change counts as unsaved for Document.saved and close(). --- crates/engine/src/cmd/fileio.rs | 6 + crates/engine/src/script/dom/save_open.rs | 33 ++- crates/engine/src/tests/script_save_open.rs | 73 ++++++ crates/scriptcheck/src/analyze.rs | 6 +- crates/scriptcheck/src/analyze/declared.rs | 263 +++++++++++++++++++- crates/scriptcheck/src/analyze/features.rs | 23 +- crates/scriptcheck/src/tests.rs | 63 +++++ docs/mcp.md | 8 +- docs/target-app-parity.md | 2 +- 9 files changed, 458 insertions(+), 19 deletions(-) diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 51d7590f35..21424f7bdc 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -126,6 +126,12 @@ pub use screens::{ preset_rows as screen_preset_rows, }; pub(crate) use svg::lost_artboards_warning as svg_lost_artboards_warning; + +/// Does a save in `format` (a format id) with options `p` write a legacy version 7 `.ai` file, +/// which holds the artboards its own options pick? An unknown version counts as one. +pub(crate) fn saves_legacy_ai(format: &str, p: &serde_json::Value) -> bool { + format == "ai" && formats::format(format).is_none_or(|f| legacy_ai::wanted("file.saveAs", f, p).unwrap_or(true)) +} pub use svg::options_map as svg_options; /// Atomic file writes (a temporary file renamed over the target: a failed write never damages the /// file it replaces), for the apps' own writers too. diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index bf49aae883..9106158e60 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -665,6 +665,17 @@ fn exactly(h: &Host, f: impl FnOnce() -> Answer) -> Answer { r } +/// Runs command `id` with `p` and writes each warning it gives to the console after `method`'s +/// name, as `app.documents.addDocument` does: what a save or an export leaves out of its file, or +/// a linked image an open could not read. → the command's answer. +fn warned(h: &Host, method: &str, id: &str, p: &Value) -> Answer { + let (answer, value) = super::super::command_value(h, id, p)?; + for w in value.get("warnings").and_then(Value::as_array).into_iter().flatten().filter_map(Value::as_str) { + super::super::each_line(&format!("{method}: {w}"), |line, cut| h.line(super::super::console::Entry::Log(line), cut)); + } + Ok(answer) +} + /// The path to give a command for the real path `real`. fn plain(real: std::path::PathBuf) -> String { crate::cmd::findfiles::plain(real).to_string_lossy().into_owned() @@ -728,7 +739,7 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer { } let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?; p.insert("path".into(), json!(plain(real))); - exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "file.saveAs", &Value::Object(p))))?; + exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "saveAs", "file.saveAs", &Value::Object(p))))?; Ok(Data::Undefined) } @@ -782,7 +793,7 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer { let named = with_extension(path, &kind, svgz); let real = h.disk.borrow().save_target(&named).map_err(|m| refused(m, &named))?; p.insert("path".into(), json!(plain(real))); - exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "document.export", &Value::Object(p))))?; + exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "exportFile", "document.export", &Value::Object(p))))?; Ok(Data::Undefined) } @@ -831,7 +842,7 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { } h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; p.insert("path".into(), json!(plain(std::path::PathBuf::from(path)))); - let r = exactly(h, || command(h, "document.open", &Value::Object(p)))?; + let r = exactly(h, || warned(h, "open", "document.open", &Value::Object(p)))?; let index = match &r { Data::Object(items) => items.iter().find_map(|(k, v)| match (k.as_str(), v) { ("index", Data::Number(n)) => whole(*n).and_then(|i| usize::try_from(i).ok()), @@ -925,12 +936,24 @@ const NO_FILE_TO_SAVE: &str = const SAVES_SOME_ARTBOARDS: &str = "the save would keep only some of its artboards: save it with saveAs first, or close with SaveOptions.DONOTSAVECHANGES"; -/// Whether saving `st` with its remembered options would omit artboards. +/// Whether the file that saving `st` with its remembered options writes would omit artboards. A +/// PDF with `useArtboards: false` holds one page of the art's bounds. A native file, or a `.ai` +/// file other than a legacy version 7 one, with `separateArtboards` holds every artboard, and its +/// `range` names only the separate files. fn picks_artboards(st: &crate::doc_state::DocState) -> bool { let options = Value::Object(crate::cmd::fileio::remembered_save_options(st)); if matches!(st.format, "svg" | "svgz") && crate::cmd::fileio::svg_lost_artboards_warning(&st.doc, &options, st.format).is_some() { return true; } + if st.format == "pdf" && options.get("useArtboards") == Some(&Value::Bool(false)) { + return true; + } + if matches!(st.format, "vectorcraft" | "template" | "ai" | "ait") + && options.get("separateArtboards") == Some(&Value::Bool(true)) + && !crate::cmd::fileio::saves_legacy_ai(st.format, &options) + { + return false; + } let count = st.doc.artboards.len(); let pick = serde_json::from_value::(options); match pick.map_err(|e| e.to_string()).and_then(|p| p.resolve(count)) { @@ -969,7 +992,7 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { let name = super::with_doc(h, doc, |_, st| st.title()); let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?; let p = json!({"path": plain(real), "format": format}); - exactly(h, || on_doc(h, doc.uid, false, |h| command(h, "file.saveAs", &p)))?; + exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "close", "file.saveAs", &p)))?; } _ => return Err(HostError::Error(UNSAVED_CHANGES.into())), } diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 8c09da874c..da96519b6e 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -1010,6 +1010,42 @@ fn closing_with_save_changes_accepts_a_range_covering_all_current_artboards() { let _ = std::fs::remove_dir_all(base); } +/// The artboard check of `close(SaveOptions.SAVECHANGES)` follows the file the save writes: a PDF +/// last saved without its artboards (`useArtboards: false`) is refused, and a `.ai` file whose +/// `range` names only the separate artboard files keeps every artboard and is saved. +#[test] +fn closing_with_save_changes_checks_the_artboards_the_file_keeps() { + let base = folder("closeencoder"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let pdf = dir.join("art.pdf"); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap(); + s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 20})).unwrap(); + s.execute("document.save", &json!({"path": pdf.to_string_lossy(), "useArtboards": false})).unwrap(); + let before = std::fs::read(&pdf).unwrap(); + let e = failure( + &mut s, + &base, + "Folder.userData; vc.run('shape.rectangle', {x: 10, y: 10, width: 5, height: 5}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(e.contains("some of its artboards"), "{e}"); + assert_eq!(std::fs::read(&pdf).unwrap(), before, "the PDF is left as it was"); + let mut s = session(&base); + data_folder(&mut s, &base); + let ai = dir.join("all.ai"); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap(); + s.execute("document.save", &json!({"path": ai.to_string_lossy(), "separateArtboards": true, "range": "2"})).unwrap(); + let before = std::fs::read(&ai).unwrap(); + logged( + &mut s, + &base, + "Folder.userData; vc.run('shape.rectangle', {x: 10, y: 10, width: 5, height: 5}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(s.documents().is_empty(), "the .ai file keeps every artboard, so it closes"); + assert_ne!(std::fs::read(&ai).unwrap(), before, "and the change is saved"); + let _ = std::fs::remove_dir_all(base); +} + #[test] fn closing_with_save_changes_refuses_svg_artboard_loss_before_writing() { let base = folder("closesvgboards"); @@ -1098,6 +1134,43 @@ fn setting_saved_records_the_saved_state() { let _ = std::fs::remove_dir_all(base); } +/// The warnings of a save go to the console after the method's name. +#[test] +fn save_as_writes_its_warnings_to_the_console() { + let base = folder("warnings"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap(); + let r = run(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&dir.join("two.svg")))).unwrap(); + let lines = r["console"]["lines"].as_array().cloned().unwrap_or_default(); + assert!(lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("saveAs: ")), "{lines:?}"); + let _ = std::fs::remove_dir_all(base); +} + +/// A point change that waits to be written counts as an unsaved change for `saved` and `close`. +#[test] +fn waiting_point_changes_count_as_unsaved_changes() { + let base = folder("pendingpoints"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + let d = quoted(&dir); + let out = logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.documents.add(DocumentColorSpace.RGB, 200, 100);\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 50, height: 20}}); d.saveAs(new File({d} + '/a.svg'));\n\ + d.pathItems[0].pathPoints[0].anchor = [1, 2]; vc.log(d.saved);\n\ + d.saved = true; d.pathItems[0].pathPoints[0].anchor = [3, 4];\n\ + var e = ''; try {{ d.close(); }} catch (x) {{ e = String(x); }} vc.log([e, app.documents.length]);" + ), + ); + assert_eq!(out[0], json!(false), "a waiting point change is unsaved"); + assert!(out[1][0].as_str().unwrap().contains("unsaved changes"), "{}", out[1]); + assert_eq!(out[1][1], json!(1), "close() keeps the document open"); + let _ = std::fs::remove_dir_all(base); +} + #[test] fn unchanged_saved_assignments_do_not_record_commands() { let base = folder("savednoop"); diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index 869938027f..a66b20ef06 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -531,6 +531,8 @@ impl Chain { /// member chain or a File object assigned in it to an outer name stays. struct Scope { depth: usize, + /// The offset of the body's `{` in the text, which [`Declared::looped`] names it by. + start: usize, saved: HashMap, /// The bracket depth of the `var` statement the body is in, if any: it goes on when the body /// closes. @@ -1234,7 +1236,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { if body { let params = self.params.take().map(|(_, names)| names).unwrap_or_default(); if self.scopes.len() < self.acc.limits.nesting { - self.scopes.push(Scope { depth: self.depth(), saved: HashMap::new(), var_depth: self.var_depth.take() }); + self.scopes.push(Scope { depth: self.depth(), start: t.start, saved: HashMap::new(), var_depth: self.var_depth.take() }); // The parameters are the body's own names, and so are the names it declares. for name in params { self.acc.steps = self.acc.steps.saturating_add(1); @@ -1454,11 +1456,13 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// The variable of the [`ObjectValue::whole`] literal whose `}` the token before `t` was joins /// [`Analyzer::writers`] when `t` ends the value (`;`, `,` or a line break). It is read before `t` /// closes a function body, so a literal given to the body's own variable stays inside the body. + /// Calls inside a loop that assigns the variable use [`Declared::looped`] to classify its methods. fn settle_literal(&mut self, t: &Sig<'s>) { if let Some((name, bits)) = self.closed.take() && (t.is(";") || t.is(",") || (t.nl && !goes_on_with(t))) && !self.later_full && !self.later.contains(&name) + && !self.declared.looped_full && (self.writers.contains_key(&name) || self.acc.room(self.writers.len())) { self.writers.insert(name, bits); diff --git a/crates/scriptcheck/src/analyze/declared.rs b/crates/scriptcheck/src/analyze/declared.rs index 48f071d2ac..9079c352ef 100644 --- a/crates/scriptcheck/src/analyze/declared.rs +++ b/crates/scriptcheck/src/analyze/declared.rs @@ -1,6 +1,6 @@ //! The names declared, read before the analysis. -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use super::{Acc, Brackets, Lexer, LineBreaks, Read, Sig, T, catalog, for_in, goes_on_after, goes_on_with, is, member_mark, unquote, word}; @@ -14,6 +14,10 @@ const UNREAD_BINDINGS: &[&str] = &["with", "eval", "Function", catalog::DOLLAR_E /// The property a function reaches `Function` through. const CONSTRUCTOR: &str = "constructor"; +/// The statements whose parentheses the rest of the statement follows, so a line break after them +/// does not end a loop's body without braces. +const HEADS: &[&str] = &["if", "while", "for", "with", "switch"]; + /// The longest property name, in characters, that [`Declared::rebound`] keeps. A string literal in /// brackets that spells a longer one sets [`Declared::unsure`]. const PROPERTY_CHARS: usize = 256; @@ -36,6 +40,16 @@ pub(crate) struct Declared<'s> { /// The property names a member assignment writes (`o.d = …`, `o['d'] = …`). The object may be /// the global object, so a variable of that name may get a value the analysis doesn't read. pub(super) rebound: HashSet, + /// The variables assigned inside a loop, its parentheses included (`name = …`), each by the + /// offset of the `{` of the function body that declares it (`None`: the global code's), with the + /// outermost loops that assign it, entries of `loop_spans`. + pub(super) looped: HashMap<(Option, &'s str), Vec>, + /// For each outermost loop, the offsets in the text where it starts and ends (`usize::MAX`: at + /// the end of the text). + pub(super) loop_spans: Vec<(usize, usize)>, + /// `looped` or `loop_spans` ran out of room, or loops nest past [`crate::Limits::nesting`]: any + /// variable may be assigned in a loop. + pub(super) looped_full: bool, /// The file gives names values the analysis doesn't read in other ways ([`UNREAD_BINDINGS`] or /// a `constructor` property used, a property read, called or assigned whose name in brackets is /// not one string or number literal, which may be a variable's name on the global object @@ -48,12 +62,14 @@ pub(crate) struct Declared<'s> { /// A function body [`Declarations`] is reading: the bracket depth inside it, its entry in /// [`Declared::bodies`], the names it declares so far, and the bracket depth of the `var` statement -/// the body is in, which goes on when the body closes. +/// the body is in, which goes on when the body closes, and the names assigned in a loop inside it +/// so far, each with its loops ([`Declared::looped`]). struct Body<'s> { depth: usize, index: usize, names: HashSet<&'s str>, var_depth: Option, + looped: HashMap<&'s str, Vec>, } /// A `[` [`Declarations`] is reading: the bracket depth inside it, whether a property's name in @@ -87,9 +103,43 @@ struct Declarations<'s, 'a, 'l> { untracked: Option, /// The `[` brackets being read, the innermost last, up to [`crate::Limits::nesting`]. keys: Vec, + /// The loops being read, the innermost last, up to [`crate::Limits::nesting`]. + loops: Vec, out: Declared<'s>, } +/// A loop [`Declarations`] is reading: the bracket depth of its keyword, how far it has been read, +/// and, for a body without braces, whether the last `{` at that depth opened a block (not an object +/// literal), whether an `if`, `while`, `for` or `with` at that depth waits for its `)`, and whether +/// the last token was that `)`. +struct Loop { + depth: usize, + stage: Stage, + block: bool, + head: bool, + after_head: bool, + /// The loop starts with `do` and has a trailing condition. + do_loop: bool, +} + +/// How far a [`Loop`] has been read. +#[derive(Clone, Copy, PartialEq)] +enum Stage { + /// The parentheses after `for` or `while`. + Head, + /// The parentheses after the `while` of a `do` loop. + DoHead, + /// The body's first token is next. + Start, + /// A body in braces. + Block, + /// A body that is one statement without braces. + Statement, + /// The statement of a body without braces has reached its end: the loop ends at the next token, + /// unless it is `else`, which goes on with the statement. + Tail, +} + /// What `src` declares ([`Declared`]), read in one pass over its tokens. pub(crate) fn declarations<'s>(src: &'s str, acc: &mut Acc) -> Declared<'s> { let mut lexer = Lexer::new(src, acc.limits.nesting); @@ -103,6 +153,7 @@ pub(crate) fn declarations<'s>(src: &'s str, acc: &mut Acc) -> Declared<'s> { bodies: vec![], untracked: None, keys: vec![], + loops: vec![], out: Declared::default(), }; let mut breaks = LineBreaks::default(); @@ -113,6 +164,10 @@ pub(crate) fn declarations<'s>(src: &'s str, acc: &mut Acc) -> Declared<'s> { Read::Token(sig) => d.token(sig), } } + // A body the file does not close keeps its names assigned in a loop as well. + while let Some(body) = d.bodies.pop() { + d.settle_looped(body); + } let mut out = d.out; out.unsure |= out.rebound.contains(catalog::FOLDER); acc.steps = acc.steps.saturating_add(lexer.steps); @@ -138,12 +193,22 @@ impl<'s> Declarations<'s, '_, '_> { if t.nl && self.var_depth == Some(self.depth()) && !goes_on_after(h0) && !goes_on_with(&t) { self.var_depth = None; } + self.loop_start(&t); if t.kind == T::Punct { self.bracket(&t); } else if t.kind == T::Ident { self.declaration(&t); } let depth = self.depth(); + self.loop_end(&t, depth); + if t.is("=") + && !self.loops.is_empty() + && !member_mark(h1) + && !is(h1, "@") + && let Some(name) = h0.filter(|s| s.kind == T::Ident) + { + self.looped(name.text); + } if let Some(after_new) = self.assign.take() { if t.word("new") && !after_new { self.assign = Some(true); @@ -167,6 +232,191 @@ impl<'s> Declarations<'s, '_, '_> { self.h = [Some(t), h0, h1]; } + /// `t`, a token before the brackets are followed past it: the body of the innermost loop starts + /// at it, and `for`, `while` and `do` start a loop. Past [`crate::Limits::nesting`] loops, any + /// variable may be assigned in one ([`Declared::looped_full`]). + fn loop_start(&mut self, t: &Sig<'s>) { + let [h0, ..] = self.h; + let depth = self.depth(); + while let Some(l) = self.loops.last_mut() { + let after_head = std::mem::take(&mut l.after_head); + match l.stage { + Stage::Start => { + l.stage = if t.is("{") { Stage::Block } else { Stage::Statement }; + l.head = HEADS.iter().any(|w| t.word(w)) && !member_mark(h0); + break; + } + // A line break ends a body of one statement where the tokens on either side of it + // don't go on with it, as in [`Analyzer::token`], and it does not follow the + // parentheses of an `if` or another statement that the body goes on with. + Stage::Statement + if t.nl && depth == l.depth && !goes_on_after(h0) && !goes_on_with(t) && !after_head && !word(h0, "else") && !word(h0, "do") => + { + l.stage = Stage::Tail; + } + Stage::Statement => { + if depth == l.depth { + if t.is("{") { + l.block = t.stmt || after_head || word(h0, "else"); + } else if HEADS.iter().any(|w| t.word(w)) && !member_mark(h0) { + l.head = true; + } + } + break; + } + Stage::Tail if l.do_loop && t.word("while") => { + l.stage = Stage::DoHead; + return; + } + Stage::Tail if t.word("else") => { + l.stage = Stage::Statement; + break; + } + Stage::Tail => { + self.pop_loop(t.start); + // A body of one statement that is this loop ends with it. + if let Some(outer) = self.loops.last_mut() + && outer.stage == Stage::Statement + && outer.depth == depth + { + outer.stage = Stage::Tail; + } + } + _ => break, + } + } + let stage = if (t.word("for") || t.word("while")) && !member_mark(h0) { + Stage::Head + } else if t.word("do") && !member_mark(h0) { + Stage::Start + } else { + return; + }; + if self.loops.len() >= self.acc.limits.nesting || (self.loops.is_empty() && !self.acc.room(self.out.loop_spans.len())) { + self.out.looped_full = true; + } else { + if self.loops.is_empty() { + self.out.loop_spans.push((t.start, usize::MAX)); + } + self.loops.push(Loop { depth, stage, block: false, head: false, after_head: false, do_loop: t.word("do") }); + } + } + + /// Ends the innermost loop at offset `at`, which ends the outermost one in + /// [`Declared::loop_spans`]. + fn pop_loop(&mut self, at: usize) { + self.loops.pop(); + if self.loops.is_empty() + && let Some((_, end)) = self.out.loop_spans.last_mut() + { + *end = at; + } + } + + /// `t`, after the brackets are followed past it to `depth`: the parentheses of a loop end at the + /// `)` back at its depth, and a body in braces at the `}` back at it. A body of one statement + /// reaches its end ([`Stage::Tail`]) at a `;` at the loop's depth, at a `}` there that closes a + /// block, or with a loop that is that statement. A bracket closing below a loop's depth ends it. + fn loop_end(&mut self, t: &Sig<'s>, depth: usize) { + let mut inner = false; + while let Some(l) = self.loops.last_mut() { + let ended = depth < l.depth + || match l.stage { + Stage::Head => { + if t.is(")") && depth == l.depth { + l.stage = Stage::Start; + } + false + } + Stage::DoHead => t.is(")") && depth == l.depth, + Stage::Block => { + if t.is("}") && depth == l.depth && l.do_loop { + l.stage = Stage::Tail; + false + } else { + t.is("}") && depth == l.depth + } + } + Stage::Statement => { + if depth == l.depth { + if t.is(";") || (t.is("}") && l.block) || inner { + l.stage = Stage::Tail; + } else if t.is(")") && l.head { + l.head = false; + l.after_head = true; + } + } + false + } + Stage::Start | Stage::Tail => false, + }; + if !ended { + break; + } + self.pop_loop(t.start); + inner = true; + } + } + + /// `name` is assigned in the loops being read: kept with the outermost one for the innermost + /// function body that declares it when that body closes ([`Self::settle_looped`]), or for the + /// global code. + fn looped(&mut self, name: &'s str) { + let id = self.out.loop_spans.len().saturating_sub(1); + match self.bodies.last_mut() { + Some(body) if body.looped.contains_key(name) || self.acc.room(body.looped.len()) => { + let ids = body.looped.entry(name).or_default(); + if !ids.contains(&id) { + ids.push(id); + } + } + Some(_) => self.out.looped_full = true, + None => self.keep_looped(None, name, vec![id]), + } + } + + /// The names assigned in a loop inside `body`, which is closing: the body's own are kept for it, + /// and the others go to the body around it, or to the global code. + fn settle_looped(&mut self, body: Body<'s>) { + let start = self.out.bodies.get(body.index).map(|(at, _)| *at); + for (name, ids) in body.looped { + if body.names.contains(name) { + self.keep_looped(start, name, ids); + } else if let Some(outer) = self.bodies.last_mut() { + if outer.looped.contains_key(name) || self.acc.room(outer.looped.len()) { + let kept = outer.looped.entry(name).or_default(); + for id in ids { + if !kept.contains(&id) { + kept.push(id); + } + } + } else { + self.out.looped_full = true; + } + } else { + self.keep_looped(None, name, ids); + } + } + } + + /// Keeps `name` of `body` as assigned in outermost loops `ids`. + fn keep_looped(&mut self, body: Option, name: &'s str, ids: Vec) { + let len = self.out.looped.len(); + match self.out.looped.get_mut(&(body, name)) { + Some(kept) => { + for id in ids { + if !kept.contains(&id) { + kept.push(id); + } + } + } + None if self.acc.room(len) => { + self.out.looped.insert((body, name), ids); + } + None => self.out.looped_full = true, + } + } + /// `t`, a token before the brackets are followed past it: notes in [`Declared::rebound`] and /// [`Declared::unsure`] the ways the file gives names values the analysis doesn't read. fn unread_binding(&mut self, t: &Sig<'s>) { @@ -234,7 +484,13 @@ impl<'s> Declarations<'s, '_, '_> { if self.bodies.len() < self.acc.limits.nesting { let index = self.out.bodies.len(); self.out.bodies.push((t.start, vec![])); - self.bodies.push(Body { depth: self.depth(), index, names: HashSet::new(), var_depth: self.var_depth.take() }); + self.bodies.push(Body { + depth: self.depth(), + index, + names: HashSet::new(), + var_depth: self.var_depth.take(), + looped: HashMap::new(), + }); } else if self.untracked.is_none() { self.untracked = Some(self.depth()); } @@ -261,6 +517,7 @@ impl<'s> Declarations<'s, '_, '_> { } while let Some(body) = self.bodies.pop_if(|b| depth < b.depth) { self.var_depth = body.var_depth; + self.settle_looped(body); } if self.untracked.is_some_and(|d| depth < d) { self.untracked = None; diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index bf808469e5..8b6b4c5f1d 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -292,8 +292,8 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } // `local['saveAs']`: what the object before the bracket defines, for a call that may follow. - "[" => self.index_receiver = self.writer_bits(h0, h1), - "(" => self.call(line), + "[" => self.index_receiver = self.writer_bits(h0, h1, Some(t.start)), + "(" => self.call(t, line), // `Name.prototype["+"] = …` defines an operator. "=" => { let operator = || h1.filter(|s| s.kind == T::Str).is_some_and(|s| catalog::OPERATORS.contains(&unquote(s.text, 4).as_str())); @@ -308,7 +308,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } /// `(` after a name: a call. - fn call(&mut self, line: Option) { + fn call(&mut self, t: &Sig<'s>, line: Option) { let [h0, h1, h2, h3] = self.h; // `doc['saveAs'](f)`: a document method named by a string literal in brackets. if is(h0, "]") @@ -342,7 +342,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } else if catalog::FOLDER_READS.contains(&n) || (file && catalog::FILE_READS.contains(&n)) { self.acc.feature(FeatureId::FileRead, line); } else if (file && catalog::FILE_WRITES.contains(&n)) - || (catalog::DOM_FILE_WRITES.contains(&n) && !Self::defines(self.writer_bits(h2, h3), n)) + || (catalog::DOM_FILE_WRITES.contains(&n) && !Self::defines(self.writer_bits(h2, h3, Some(t.start)), n)) { self.acc.feature(FeatureId::FileWrite, line); self.acc.outside(OutsideId::FilesWritten, line, None); @@ -369,9 +369,18 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { /// The methods that `receiver`, which `before` comes before, defines when it is a variable holding /// an object literal of the script's own ([`Analyzer::writers`]), not a property of the same name; /// 0 for anything else. A receiver the check does not follow may be a document. - fn writer_bits(&self, receiver: Option>, before: Option>) -> u8 { + /// At call offset `at`, a variable assigned in a loop containing that offset may be a document. + fn writer_bits(&self, receiver: Option>, before: Option>, at: Option) -> u8 { match receiver { - Some(r) if !self.unsure && r.kind == T::Ident && !member_mark(before) => self.writers.get(r.text).copied().unwrap_or(0), + Some(r) if !self.unsure && r.kind == T::Ident && !member_mark(before) => { + let looped = at.is_some_and(|at| { + self.declared.looped_full + || self.declared.looped.get(&(self.scopes.last().map(|s| s.start), r.text)).is_some_and(|ids| { + ids.iter().any(|id| self.declared.loop_spans.get(*id).is_some_and(|(start, end)| *start <= at && at < *end)) + }) + }); + if looped { 0 } else { self.writers.get(r.text).copied().unwrap_or(0) } + } _ => 0, } } @@ -400,7 +409,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.reassigned_later(&name); } } - let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before) != 0).map(|s| s.text); + let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before, None) != 0).map(|s| s.text); let escaped = if word(h0, "delete") { // `delete local…` writer(Some(*t), h0) diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 0493014da0..a580c3d311 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -698,6 +698,69 @@ fn a_changed_or_shared_own_save_as_writes_a_file() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 5][..])); } +/// A variable assigned in a loop may hold a document when a later iteration calls its `saveAs`, +/// before the assignment in the text: the call writes a file. One assigned only after a loop does +/// not. +#[test] +fn an_own_save_as_reassigned_later_in_a_loop_writes_a_file() { + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {}}; var b = {saveAs: function () {}}; var c = {saveAs: function () {}};\n", + "var d = {saveAs: function () {}};\n", + "for (var i = 0; i < 2; i++) { a.saveAs(f); a = app.activeDocument; }\n", + "while (n--) b.saveAs(f), b = app.activeDocument;\n", + "do { c.saveAs(f); } while ((c = next()));\n", + "for (;;) { d.saveAs(f); break; }\n", + "d = app.activeDocument;\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 5, 6][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[4, 5, 6][..])]); + // The `else` of a body without braces is in the loop; a statement after a line break that ends + // such a body is not, and neither is a variable of the same name that a function declares. + let r = report(concat!( + "var f = new File(p);\n", + "var e = {saveAs: function () {}}; var g = {saveAs: function () {}}; var h = {saveAs: function () {}};\n", + "while (n--) if (n) e.saveAs(f); else e = app.activeDocument;\n", + "while (n--) g.saveAs(f), n\n", + "g = app.activeDocument\n", + "function k() { var h; for (;;) h = app.activeDocument; }\n", + "h.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3][..])); + // An object literal's `}` does not end a body without braces, a call's `)` before a line break + // does, and a literal given after the last loop that assigns its variable is the script's own. + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {}}; var b = {saveAs: function () {}};\n", + "while (n--) a.saveAs(f), t = {}, a = app.activeDocument;\n", + "b.saveAs(f);\n", + "while (n--) tick()\n", + "b = app.activeDocument\n", + "for (;;) { c = app.activeDocument; }\n", + "var c = {saveAs: function () {}};\n", + "c.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3][..])); + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {}};\n", + "while (n--) if (n)\n", + " a.saveAs(f), a = app.activeDocument;\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4][..])); + let r = report(concat!( + "var f = new File(p);\n", + "var a = {saveAs: function () {}}; var b = {saveAs: function () {}};\n", + "a.saveAs(f); b['saveAs'](f);\n", + "while (n--) { a.saveAs(f); a = app.activeDocument; }\n", + "while (n--) { b['saveAs'](f); b = app.activeDocument; }\n", + "var a = {saveAs: function () {}};\n", + "a.saveAs(f);\n", + "while (n--) { a.saveAs(f); a = app.activeDocument; }\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 5, 8][..])); +} + /// Only a `var` statement directly in a function body or the global code that gives its first name /// the literal as its whole value makes the literal's `saveAs` the script's own, from the end of the /// statement. A literal given in a branch, one the value goes on from, one given by an assignment diff --git a/docs/mcp.md b/docs/mcp.md index 2fcb2dc34f..c073a93f02 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3168,9 +3168,13 @@ through `$`: was last saved in and after the same write-access check of the path as `saveAs`, and throws an error and leaves the document open when the document has no file (a converted or recovered document included) or when the save would omit artboards. These refusals occur before writing any files. An SVG or SVGZ save of several - artboards requires Preserve Editing Capabilities to close with `SaveOptions.SAVECHANGES`. + artboards requires Preserve Editing Capabilities to close with `SaveOptions.SAVECHANGES`. A PDF last saved with + `useArtboards: false` omits artboards; a native or `.ai` file (other than a version 7 `.ai` file) saved with + `separateArtboards` keeps every artboard whatever its range names. `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot - show the prompt. A bad value throws an error before anything is written. + show the prompt. A bad value throws an error before anything is written. The warnings of the save or export that + `saveAs`, `exportFile`, `app.open` and `close` run go to the console, each after the method's name + (`saveAs: …`). - `Document.pathItems` (https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/) lists the document's paths in the order of `pageItems`, paths inside groups and compound paths included, with `length`, `[i]`, `index(key)`, `getByName(name)`, `removeAll()`, `add()` (a path with no points, from `path.create`, painted as new art; when new diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 13d8c9200e..2ed9a978e8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1127,7 +1127,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Scripts: `document.characterStyles` and `document.paragraphStyles` add, find, rename, redefine, apply and remove character and paragraph styles, with the Normal styles listed first and kept, and a text range lists the styles its text is in, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyle/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyle/ and https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ describe them (`docs/mcp.md`). Style names of 1 to 256 characters without control characters, and at most 4,096 styles named in one run, are VectorCraft's own rules. Load Character Styles, Load Paragraph Styles and Load All Styles refuse a file larger than 64 MB. A paragraph style's character attributes are not there yet. `crates/engine/src/tests/script_styles.rs`. - Scripts: a text frame's `nextFrame` and `previousFrame` read and set its links to the frames before and after it, `areaText` and `pathText` thread a new frame to a base frame, and `document.stories` lists the stories, each with its frames in thread order and its text across them as one text range with its characters, words and paragraphs, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItem/, https://ai-scripting.docsforadobe.dev/jsobjref/Story/ and https://ai-scripting.docsforadobe.dev/jsobjref/Stories/ describe them; `text.thread.setNeighbor` links or unlinks two frames by id (`docs/mcp.md`). Which links are refused, and how a story is listed and found, are VectorCraft's own rules. `crates/engine/src/tests/script_threads.rs`. - Scripts: `PageItem.tags` reads, adds, renames and deletes an object's tags, name and value pairs that the native file keeps, and `Document.tags` reads, renames and deletes the tags of every page item but adds none (its `add` throws; a script adds a tag through the page item's `tags`), as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Tags/ and https://ai-scripting.docsforadobe.dev/jsobjref/Tag/ describe them, through `object.tags` and the `object.tag.*` commands, at most 64 tags an object (`docs/mcp.md`). `crates/engine/src/tests/script_tags.rs`. - - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe, and read and write only where the script's `File` objects may (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. + - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe, and read and write only where the script's `File` objects may; the warnings of each save, export and open go to the console (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). A script can check a member with `hasOwnProperty`, and can read a collection by name and name `activeDocument`, `documents` and `selection` without `app.` (https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/). A key such as `1` is an array index and reads that position; in `pageItems` and `documents`, a number that is not an array index, such as `-1` or `1.5`, is looked up by name when the key is the text JavaScript writes for that number. VectorCraft's own rule. `app.executeMenuCommand` runs the menu items Select All, Deselect, Group, Ungroup, Make and Release Clipping Mask, Make and Release Compound Path, and Fit to Artwork Bounds by their menu command names (https://community.adobe.com/questions-652/a-list-of-illustrator-menu-commands-we-can-call-from-javascript-769510, https://gist.github.com/shalakolee/df3246659d4289eb99149b9ed00a00ee). The `parent` of a page item at the top of a layer is a `Layer` with `name`, `typename` and `toString`. A page item's `blendingMode` reads and sets its blend mode with the `BlendModes` values (https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/). `Document.views` lists the document's drawn windows with their bounds, center, zoom and screen mode (https://ai-scripting.docsforadobe.dev/jsobjref/View/). Zoom follows each window's displayed percentage, including display density with Display Print Size at 100% Zoom enabled; bounds retain the physical camera scale. View objects keep their targets when windows are renumbered. View changes run no command, add no undo step, and remain when a script fails. A center outside the canvas after coordinate conversion throws a `RangeError`. `Document.layers`, `Document.activeLayer`, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - Scripts: `app.redraw()` (https://ai-scripting.docsforadobe.dev/jsobjref/Application/) returns without changing the documents or adding an undo step; the app goes on drawing the documents as they were before the run until the run ends. VectorCraft's own rule. `crates/engine/src/tests/script_dom.rs`. From d2b18d1270e7ac79734a1c4657d24cceacd248c0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:50:38 -0800 Subject: [PATCH 163/264] Text: web-fonts.txt lists only faces that craft-fonts ships crates/text/web-fonts.txt listed 30 background faces (Cairo, Tajawal, Almarai, IBM Plex Sans Arabic, Noto Kufi Arabic, Amiri, Alexandria, Fustat, Reem Kufi, Aref Ruqaa and Gulzar) that craft-fonts does not have yet; they are added by storytold/craft-fonts#11 and #13, which are still open. Every build with CRAFT_FONTS_DIR printed "web build won't fetch: Cairo Regular, Tajawal ExtraLight, ..." from crates/text/build.rs and xtask/src/web_fonts.rs, and the web build fetched none of them. The rows are removed. The startup and demand faces stay. The rows go back in when craft-fonts #11 and #13 merge. --- crates/text/web-fonts.txt | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/crates/text/web-fonts.txt b/crates/text/web-fonts.txt index 235ba98e13..d46cfe41c5 100644 --- a/crates/text/web-fonts.txt +++ b/crates/text/web-fonts.txt @@ -8,35 +8,5 @@ startup | Noto Sans Arabic | Regular startup | Noto Sans Thai | Regular startup | Noto Sans Georgian | Regular -background | Cairo | Regular -background | Tajawal | ExtraLight -background | Tajawal | Light -background | Tajawal | Regular -background | Tajawal | Medium -background | Tajawal | Bold -background | Tajawal | ExtraBold -background | Tajawal | Black -background | Almarai | Light -background | Almarai | Regular -background | Almarai | Bold -background | Almarai | ExtraBold -background | IBM Plex Sans Arabic | Thin -background | IBM Plex Sans Arabic | ExtraLight -background | IBM Plex Sans Arabic | Light -background | IBM Plex Sans Arabic | Regular -background | IBM Plex Sans Arabic | Medium -background | IBM Plex Sans Arabic | SemiBold -background | IBM Plex Sans Arabic | Bold -background | Noto Kufi Arabic | Regular -background | Amiri | Regular -background | Amiri | Italic -background | Amiri | Bold -background | Amiri | Bold Italic -background | Alexandria | Regular -background | Fustat | Regular -background | Reem Kufi | Regular -background | Aref Ruqaa | Regular -background | Aref Ruqaa | Bold -background | Gulzar | Regular demand | NanumGothic | Regular demand | Noto Sans Devanagari | Regular From 42f973a5bc04d84293c9896edde56e70adc2920e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:50:38 -0800 Subject: [PATCH 164/264] xtask: the cache warm builds integration tests too `cargo xtask ci warm` built each test shard with `--lib --bins --no-run`, while the shards run `--lib --bins --tests`. The warm build left out the integration test executables the shards then build, and cargo warned `unused dependency vectorcraft-testkit` for apps/vectorcraft-cli, whose only use is in tests/it. The warm build now selects the same targets as the test shards, through one `TARGETS` list that both use. --- xtask/src/main.rs | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 08a55df09a..5484c0d3e9 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -267,12 +267,14 @@ fn cmd_test() -> Result<(), String> { test_packages(&["--workspace".to_owned()], "--workspace", None) } +/// The test targets that [`test_packages`] runs and `ci warm` builds. +const TARGETS: [&str; 3] = ["--lib", "--bins", "--tests"]; + /// [`cmd_test`] for the packages `select` picks (`--workspace` or `-p` ids), shown as `shown`; /// with `part`, only that part's share of their tests (xtask/src/shards.rs), which needs nextest. /// A part runs its counted share, then its pinned tests, each with nextest's default thread count. /// Every run finishes before the first error is returned. fn test_packages(select: &[String], shown: &str, part: Option) -> Result<(), String> { - const TARGETS: [&str; 3] = ["--lib", "--bins", "--tests"]; if let Some(part) = part { if !has_nextest() { return Err(format!("cargo nextest run {shown}: a shard that runs part of a crate's tests needs cargo-nextest")); @@ -393,11 +395,13 @@ fn cmd_ci_shard() -> Result<(), String> { run_steps(&steps) } -/// `cargo xtask ci warm`: for each test shard, builds its crates' library and binary tests without -/// running them, then builds what the checks shard builds, so one dependency-cache entry holds the -/// dependencies of every shard with the features that shard builds them with (cargo resolves -/// features over the packages each command selects). The integration tests are left out: they -/// build no dependency that the library tests do not, since both take the crate's dev-dependencies. +/// `cargo xtask ci warm`: for each test shard, builds its crates' library, binary and integration +/// tests without running them, then builds what the checks shard builds, so one dependency-cache +/// entry holds the dependencies of every shard with the features that shard builds them with (cargo +/// resolves features over the packages each command selects). The test builds select the same +/// targets as the test shards ([`TARGETS`]), so the cache also holds the test executables the +/// shards run, and cargo does not warn (`cargo::unused_dependencies`) about a dev-dependency that +/// only an integration test uses. /// /// In a leg that saves the cache, every build records its units in `CRAFT_CACHE_UNITS` /// (xtask/src/cache_units.rs), xtask's own build included. @@ -414,9 +418,8 @@ fn cmd_ci_warm() -> Result<(), String> { steps.push(( "build tests", Box::new(move || { - let mut c = cargo(); - c.arg("test").args(shards::select(&crates)).args(["--lib", "--bins", "--no-run"]); - cache_units::run(c, &format!("cargo test --lib --bins --no-run ({})", shards::names(&crates))) + let (c, what) = warm_tests(&crates); + cache_units::run(c, &what) }), )); } @@ -447,6 +450,13 @@ fn cmd_ci_warm() -> Result<(), String> { run_steps(&steps) } +/// The command `ci warm` builds one test shard's tests with, and its description. +fn warm_tests(crates: &[shards::Member]) -> (Command, String) { + let mut c = cargo(); + c.arg("test").args(shards::select(crates)).args(TARGETS).arg("--no-run"); + (c, format!("cargo test {} --no-run ({})", TARGETS.join(" "), shards::names(crates))) +} + /// Runs `steps` in turn, stopping at the first that fails; the summary names the steps that passed /// and, after a failure, the one that failed and those skipped. fn run_steps(steps: &[Step]) -> Result<(), String> { @@ -588,3 +598,20 @@ fn i18n_report_packages(select: &[String], shown: &str) -> Result<(), String> { c.arg("test").args(select).args(["--lib", "--bins", "--tests", "--", "i18n::tests::untranslated_report", "--exact", "--nocapture"]); run(c, &format!("cargo test {shown} --lib --bins --tests -- i18n::tests::untranslated_report --exact --nocapture")) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn warm_builds_the_test_targets_the_shards_run() { + let crates = [shards::Member { name: "a".into(), id: "path+file:///w/a#0.1.0".into(), version: "0.1.0".into(), doctests: true }]; + let (c, what) = warm_tests(&crates); + let args: Vec = c.get_args().map(|a| a.to_string_lossy().into_owned()).collect(); + assert_eq!(args, ["test", "-p", "path+file:///w/a#0.1.0", "--lib", "--bins", "--tests", "--no-run"]); + for target in TARGETS { + assert!(args.iter().any(|a| a == target), "ci warm does not build {target}"); + } + assert_eq!(what, "cargo test --lib --bins --tests --no-run (a)"); + } +} From dc597fbc13bc2bb07906187fe21b3e53956e8d76 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 16:55:30 -0800 Subject: [PATCH 165/264] Tests: the selection-move rebuild count holds the font and plug-in catalogs steady a_selection_move_rebuilds_the_menus_for_its_press_and_release_only counts the menus' rebuilds in each frame. A font or plug-in that a test running alongside adds, or the installed fonts' scan ending, also rebuilds the menus, and the exact count then failed. The test now holds the fonts and plug-ins steady for the whole run, and runs the move again on a new app, at most 20 times, until the script and proof-setup revisions held still through it. It asserts the same counts. --- crates/ui-egui/Cargo.toml | 1 + crates/ui-egui/src/canvas/tests.rs | 65 ++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 95487e91c0..3e979ac08f 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -104,6 +104,7 @@ vectorcraft-testkit = { workspace = true } vectorcraft-tools = { workspace = true, features = ["testing"] } # A variable font built in code (no font file is committed). vectorcraft-text = { workspace = true, features = ["test-fonts"] } +vectorcraft-plugins = { workspace = true, features = ["test-steady"] } wat = { workspace = true } [build-dependencies] diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 223dd83d0b..ab21113b8a 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -867,29 +867,52 @@ fn the_move_of_a_releasing_frame_counts_for_the_tool_drag() { /// A Selection tool move builds the menus' states again twice, in the frame of its press and in the frame of its /// release, which commits the move. The frame the move begins in and the frames of its previews, which change the -/// document's revision, keep them. +/// document's revision, keep them. The menus are also built again when a process-wide catalog changes, so the fonts +/// and plug-ins are held steady against tests running alongside for the whole run, and the move runs again on a new +/// app, at most 20 times, until the other catalogs held still through it. #[test] fn a_selection_move_rebuilds_the_menus_for_its_press_and_release_only() { - let (mut app, ctx, xf) = rectangle_tool(); - let id = app.session.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 60, "height": 30})).unwrap()["id"].as_u64().unwrap(); - app.select_tool("selection"); - app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); - let (from, to) = (xf.to_screen(Point::new(130.0, 115.0)), xf.to_screen(Point::new(170.0, 135.0))); - app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(from)]); - for _ in 0..2 { - app_step(&mut app, &ctx, vec![]); - } - let none = egui::Modifiers::NONE; - let mut steps = vec![vec![primary(from, true, none)]]; - steps.extend((1..=8).map(|i| vec![egui::Event::PointerMoved(from.lerp(to, i as f32 / 8.0))])); - steps.push(vec![primary(to, false, none)]); - steps.extend([vec![], vec![], vec![]]); - let mut rebuilt = vec![]; - for events in steps { - let before = app.menus.rebuilds; - app_step(&mut app, &ctx, events); - rebuilt.push(app.menus.rebuilds - before); - } + let fonts = vectorcraft_text::FontDb::global(); + let _steady = (vectorcraft_text::test_fonts::steady_fonts(fonts), vectorcraft_plugins::steady::steady_plugins()); + let catalogs = || { + ( + crate::menus::plugin_revision(), + fonts.generation(), + fonts.installed_fonts_ready(), + crate::scripts_menu::revision(), + crate::dialogs::proof_setup::saved_revision(), + ) + }; + let run = || { + let (mut app, ctx, xf) = rectangle_tool(); + let id = app.session.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 60, "height": 30})).unwrap()["id"].as_u64().unwrap(); + app.select_tool("selection"); + app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); + let (from, to) = (xf.to_screen(Point::new(130.0, 115.0)), xf.to_screen(Point::new(170.0, 135.0))); + app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(from)]); + for _ in 0..2 { + app_step(&mut app, &ctx, vec![]); + } + let none = egui::Modifiers::NONE; + let mut steps = vec![vec![primary(from, true, none)]]; + steps.extend((1..=8).map(|i| vec![egui::Event::PointerMoved(from.lerp(to, i as f32 / 8.0))])); + steps.push(vec![primary(to, false, none)]); + steps.extend([vec![], vec![], vec![]]); + let mut rebuilt = vec![]; + for events in steps { + let before = app.menus.rebuilds; + app_step(&mut app, &ctx, events); + rebuilt.push(app.menus.rebuilds - before); + } + (app, rebuilt) + }; + let (app, rebuilt) = (0..20) + .find_map(|_| { + let before = catalogs(); + let out = run(); + (catalogs() == before).then_some(out) + }) + .unwrap_or_else(|| panic!("tests running alongside kept changing the font and plug-in catalogs")); assert_eq!(drawn_paths(&app), vec![Rect::new(140.0, 120.0, 200.0, 150.0)], "the drag moves the rectangle"); assert_eq!(rebuilt, [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], "rebuilds in each frame: press, 8 moves, release, 3 idle"); } From 8d5fb2ff6b6d0de7a9f2dc32ed403705a1e79e9f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 17:19:26 -0800 Subject: [PATCH 166/264] Selection Tools: Edit Points Only skips hidden and locked art and keeps the Appearance row Edit Points Only now leaves out selected paths and groups that are hidden or locked, themselves or through an ancestor. Group expansion looks up explicit anchor picks in a set instead of scanning the selection for each path. Canceling the preview restores the active Appearance row, and a preview or OK that succeeds clears the earlier status error. --- crates/engine/src/cmd/addons/select.rs | 6 +- crates/engine/src/cmd/addons/select/tests.rs | 73 +++++++++++++++++++ crates/engine/src/interaction.rs | 1 + crates/engine/src/session/edit.rs | 12 ++- crates/ui-egui/src/addons/dialogs.rs | 5 ++ .../src/addons/select/points_only/tests.rs | 22 ++++++ 6 files changed, 116 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/select.rs b/crates/engine/src/cmd/addons/select.rs index bda973fb2c..fb8c49aed6 100644 --- a/crates/engine/src/cmd/addons/select.rs +++ b/crates/engine/src/cmd/addons/select.rs @@ -254,9 +254,13 @@ fn edit_points_only(s: &mut Session, p: &Value) -> Result { } // Each path once, in selection order, with its points kept: `None` for all of them. let mut seen = HashSet::new(); + let explicit: HashSet = sel.objects.iter().copied().filter(|id| sel.anchors.contains_key(id)).collect(); let mut kept: Vec<(NodeId, usize, Option>)> = vec![]; for id in &sel.objects { let Some(n) = doc.node(*id) else { continue }; + if !doc.ancestry(*id).is_some_and(|ancestors| ancestors.iter().all(|id| doc.node(*id).is_some_and(|n| n.visible && !n.locked))) { + continue; + } match &n.kind { NodeKind::Path { path, .. } => { let Some(refs) = sel.anchors.get(id) else { @@ -281,7 +285,7 @@ fn edit_points_only(s: &mut Session, p: &Value) -> Result { let mut inside = vec![]; paths_inside(n, guides_locked, &mut inside); for c in inside { - if sel.objects.contains(&c.id) && sel.anchors.contains_key(&c.id) { + if explicit.contains(&c.id) { continue; } if seen.insert(c.id) { diff --git a/crates/engine/src/cmd/addons/select/tests.rs b/crates/engine/src/cmd/addons/select/tests.rs index ec6054a237..6171c08ef9 100644 --- a/crates/engine/src/cmd/addons/select/tests.rs +++ b/crates/engine/src/cmd/addons/select/tests.rs @@ -452,6 +452,79 @@ mod edit_points_only { } } + #[test] + fn hidden_or_locked_selected_nodes_and_their_ancestors_are_left_out() { + for locked in [false, true] { + for target in ["path", "group", "ancestor", "layer"] { + let (mut s, a, b) = two(); + let good = rect(&mut s, 200.0, 10.0, 20.0, 20.0); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + let blocked = match target { + "path" => a, + "layer" => s.doc().unwrap().doc.layers[0].id, + _ => group, + }; + let doc = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc); + let node = doc.node_mut(blocked).unwrap(); + if locked { + node.locked = true; + } else { + node.visible = false; + } + let selected = if matches!(target, "path" | "ancestor") { a } else { group }; + s.execute("select.set", &json!({"ids": [good.0, selected.0]})).unwrap(); + if target == "layer" { + let before = s.doc().unwrap().selection.clone(); + assert!(s.execute(C, &json!({})).is_err()); + assert_eq!(s.doc().unwrap().selection, before); + } else { + s.execute(C, &json!({})).unwrap(); + assert_eq!(picked(&s), (vec![good], BTreeMap::new()), "{target}, locked: {locked}"); + } + } + } + } + + #[test] + fn group_expansion_does_not_scan_the_selection_for_each_descendant() { + let source = include_str!("../select.rs"); + let command = source.split("fn edit_points_only(").nth(1).unwrap(); + assert!(!command.contains("sel.objects.contains(&c.id)"), "descendant lookup must not scan every selected object"); + + let (mut s, _, _) = two(); + let mut groups = vec![]; + let mut paths = vec![]; + for x in [10.0, 100.0, 200.0] { + let a = rect(&mut s, x, 100.0, 20.0, 20.0); + let b = rect(&mut s, x, 150.0, 20.0, 20.0); + s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap(); + groups.push(NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap())); + paths.extend([a, b]); + } + s.select(|_, sel| sel.set(groups)).unwrap(); + s.execute(C, &json!({})).unwrap(); + assert_eq!(picked(&s), (paths, BTreeMap::new())); + } + + #[test] + fn canceling_a_selection_preview_restores_the_active_appearance_item() { + let (mut s, a, b) = two(); + mixed(&mut s, a, b); + s.execute("appearance.addFill", &json!({})).unwrap(); + s.execute("appearance.setActiveItem", &json!({"index": 0})).unwrap(); + let before = s.doc().unwrap().doc.node(a).unwrap().appearance.items.clone(); + s.begin_interaction("Edit Points Only").unwrap(); + s.preview(C, &json!({})).unwrap(); + assert_eq!(s.appearance_item(), None); + s.cancel_interaction().unwrap(); + assert_eq!(s.appearance_item(), Some(0)); + s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap(); + let after = &s.doc().unwrap().doc.node(a).unwrap().appearance.items; + assert_ne!(after[0], before[0]); + assert_eq!(&after[1..], &before[1..]); + } + #[test] fn whole_paths_keep_object_transforms_and_stroke_scaling() { let (mut s, a, _) = two(); diff --git a/crates/engine/src/interaction.rs b/crates/engine/src/interaction.rs index a2b9417461..dc7b5684fe 100644 --- a/crates/engine/src/interaction.rs +++ b/crates/engine/src/interaction.rs @@ -10,6 +10,7 @@ pub struct Interaction { pub doc: Arc, /// The selection the previews start from (shared, so a preview frame copies nothing). pub selection: Arc, + pub(crate) active_appearance_item: Option, pub preview: Option<(String, Value)>, /// The active tool began it (a drag): a command from outside the tool runs as a step of its /// own under it ([`crate::Session::outside_interaction`]). A dialog or a panel that begins an diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index d5d62e607c..45d0dfd370 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -536,6 +536,7 @@ impl Session { } self.clear_deferred_overlay_cache(); let paint = self.paint.clone(); + let active_appearance_item = self.active_appearance_item.clone(); let st = self.doc_mut()?; if st.interaction.is_some() { return Ok(()); @@ -545,6 +546,7 @@ impl Session { effect: None, doc: st.doc.clone(), selection: Arc::new(st.selection.clone()), + active_appearance_item, preview: None, tool: false, paint, @@ -577,7 +579,7 @@ impl Session { // preview starts from the colors the interaction began with; so does a preview with // `defaultsOnly: true`, and one after it. let tool_paints = self.tool_paints(false) || self.tool_paints(true); - let (paint, restore_paint) = { + let (paint, restore_paint, active_appearance_item) = { let menu = self.menu.clone(); let st = self.doc_mut()?; let Some(it) = &mut st.interaction else { return Err(EngineError::Other("no interaction in progress".into())) }; @@ -599,6 +601,7 @@ impl Session { || it.preview.as_ref().is_some_and(|(id, p)| id == "command.batch" || cmd::asks_defaults_only(p)) || it.color_mode_paints.is_some(); let paint = it.paint.clone(); + let active_appearance_item = it.active_appearance_item.clone(); it.preview_paint = None; it.color_mode_paints = None; it.deferred_color_mode = None; @@ -615,8 +618,9 @@ impl Session { // undone with it. st.restore_isolation(isolation, &undone); cmd::globaledit::follow_history(st); - (paint, restore_paint) + (paint, restore_paint, active_appearance_item) }; + self.active_appearance_item = active_appearance_item; if restore_paint { self.paint = paint.clone(); } @@ -782,10 +786,14 @@ impl Session { self.paint = paint; } let menu = self.menu.clone(); + let active_appearance_item = self.active().and_then(|st| st.interaction.as_ref()).map(|it| it.active_appearance_item.clone()); let st = self.doc_mut()?; st.undo_interaction(); // Guides locked and slices locked or hidden during the interaction stay deselected. deselect_hidden(&menu, &st.doc, &mut st.selection); + if let Some(active_appearance_item) = active_appearance_item { + self.active_appearance_item = active_appearance_item; + } // A canceled preview's Assign Profile is undone with it. self.sync_front_profiles(); // With New Art Has Basic Appearance off, new art takes the appearance of the selection as diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index c2d1f138de..f0642c31fc 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -140,6 +140,9 @@ fn pump_commit(app: &mut VectorcraftApp) { let label = vectorcraft_engine::find_command(spec.command).map_or(spec.command, |command| command.label); let answer = preview.run(app, *previewing, label, spec.command, params); app.addon_dialogs.preview = preview; + if spec.command == super::select::points_only::COMMAND && matches!(&answer, Some(Ok(_))) { + app.ui.status.clear(); + } if let (Some(found), Some(answer)) = (spec.found, answer) { host.with(|h| { if let Some(d) = h.get_mut_by_id::(id) { @@ -166,6 +169,8 @@ fn pump_commit(app: &mut VectorcraftApp) { }; if let Err(error) = answer { app.status(error); + } else if spec.command == super::select::points_only::COMMAND { + app.ui.status.clear(); } } } diff --git a/crates/ui-egui/src/addons/select/points_only/tests.rs b/crates/ui-egui/src/addons/select/points_only/tests.rs index ba0bc13b73..ff0fef879f 100644 --- a/crates/ui-egui/src/addons/select/points_only/tests.rs +++ b/crates/ui-egui/src/addons/select/points_only/tests.rs @@ -96,6 +96,28 @@ fn cancel_puts_the_selection_back() { assert_eq!(app.session.doc().unwrap().selection, before); } +#[test] +fn keeping_segment_ends_clears_the_preview_error() { + for previewing in [true, false] { + let (mut app, a, _) = app(); + app.run("select.segments", json!({"id": a.0, "segments": [[0, 0]]})).unwrap(); + host::open_item(&mut app, "Selection Tools", "Edit Points Only…"); + let id = host::dialog_id(&app); + host::frame(&mut app); + assert!(app.ui.status.contains("no anchor points are selected"), "{}", app.ui.status); + host::set(&app, id, "segmentEnds", json!(true)); + if previewing { + host::frame(&mut app); + assert!(app.ui.status.is_empty(), "{}", app.ui.status); + assert_eq!(points(&app, a), (Some(refs(&[(0, 0), (0, 1)])), false)); + } + assert!(host::confirm(&app, id)); + host::frame(&mut app); + assert!(app.ui.status.is_empty(), "{}", app.ui.status); + assert!(!app.any_dialog_open()); + } +} + #[test] fn ok_with_nothing_to_keep_says_why_and_leaves_the_selection() { let (mut app, a, _) = app(); From b8c754e7a2c9379c399eecb2692570bc35bae54b Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 02:24:25 +0100 Subject: [PATCH 167/264] Import the generated RPM helper coverage report --- sonar-project.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 9523d64b0e..2f69afe794 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,3 +18,6 @@ sonar.issue.ignore.multicriteria=pdf_md5 sonar.issue.ignore.multicriteria.pdf_md5.ruleKey=rust:S4790 sonar.issue.ignore.multicriteria.pdf_md5.resourceKey=crates/pdf/src/encrypt.rs sonar.coverage.exclusions=packaging/** + +# Produced by the shared workflow Python coverage step. +sonar.python.coverage.reportPaths=python-coverage.xml From 8e68c5edcf092ecd8993ea6aed7c630c2f921903 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 17:43:37 -0800 Subject: [PATCH 168/264] Shape Builder: Pick Color From defaults to Color Swatches While the Shape Builder is active, a fill picked from a swatch or a color changes only the current fill, and the selected art keeps its own. With Pick Color From set to Artwork, a merge takes the look of the art, so the picked color never reached the merged shape and the tool looked as if it could not fill. Pick Color From now defaults to Color Swatches: a merge fills with the picked color, and the Left and Right arrow keys step through the color swatches. A pickColorFrom saved with the preferences is kept, so a saved Artwork stays Artwork; preferences saved without one take Color Swatches. The shapeBuilder.merge command still defaults to artwork when its pickColorFrom is left out. Docs: docs/mcp.md and the tool options params text. --- crates/engine/src/tests/build.rs | 30 ++++++++++++++++++++++- crates/engine/src/tests/toolsettings.rs | 25 +++++++++++++++++++ crates/mcp/src/ui_catalog.rs | 2 +- crates/tools/src/builder.rs | 6 ++--- crates/ui-egui/src/dialogs/option_form.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- docs/mcp.md | 9 ++++--- 7 files changed, 65 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 6ccdfad0a5..adb5d04af5 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -1753,7 +1753,8 @@ fn shape_builder_swatches_keep_the_current_fill_and_the_first_covered_objects_lo } /// The Shape Builder tool sends the point where the drag started first and the point where it -/// ended last, so a drag from the hole into the square takes the square's look. +/// ended last, so with Pick Color From Artwork a drag from the hole into the square takes the +/// square's look. #[test] fn shape_builder_tool_drag_from_the_hole_takes_the_look_where_it_ends() { let mut s = session(); @@ -1762,6 +1763,7 @@ fn shape_builder_tool_drag_from_the_hole_takes_the_look_where_it_ends() { select_ids(&mut s, &bars.iter().copied().chain([red]).collect::>()); let v = ViewInfo::default(); s.select_tool("shapeBuilder", v).unwrap(); + s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": {"pickColorFrom": "artwork"}})).unwrap(); s.pointer(&PointerEvent::new(PointerKind::Down, 50.0, 50.0), v).unwrap(); s.pointer(&PointerEvent::new(PointerKind::Drag, 85.0, 50.0), v).unwrap(); s.pointer(&PointerEvent::new(PointerKind::Drag, 120.0, 50.0), v).unwrap(); @@ -1853,6 +1855,7 @@ fn shape_builder_arrow_keys_step_the_current_fill_through_the_swatches() { let v = ViewInfo::default(); s.select_tool("shapeBuilder", v).unwrap(); let chips = |s: &mut Session| s.overlays(v).iter().filter(|o| matches!(o, vectorcraft_tools::Overlay::Swatch { .. })).count(); + s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": {"pickColorFrom": "artwork"}})).unwrap(); assert!(!s.tool_claims_key(ToolKey::Right, v), "Artwork leaves the arrows to nudging"); let values = json!({"pickColorFrom": "swatches", "cursorSwatchPreview": true}); s.set_tool_option_cmd(&json!({"tool": "shapeBuilder", "values": values})).unwrap(); @@ -2071,6 +2074,31 @@ fn shape_builder_fill_preview_is_put_back_by_a_cancel() { assert_eq!(s.paint.fill, before, "the cancel puts the fill back"); } +/// With the Shape Builder's default options, a fill picked while it is active (a swatch or a +/// color) fills the next merge: the tool sends `pickColorFrom: "swatches"`, and the merged shape +/// is not the red or blue of the art. +#[test] +fn shape_builder_default_merge_fills_with_the_picked_fill() { + let v = ViewInfo::default(); + for pick in [json!({"swatch": "Leaf"}), json!({"color": "#ff8800"})] { + let mut s = session(); + two(&mut s); + s.execute("swatch.new", &json!({"name": "Leaf", "color": "#00ff00"})).unwrap(); + s.select_tool("shapeBuilder", v).unwrap(); + s.execute("paint.setFill", &pick).unwrap(); + let picked = s.paint.fill.clone(); + s.pointer(&PointerEvent::new(PointerKind::Down, 25.0, 50.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 75.0, 50.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 125.0, 50.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Up, 125.0, 50.0), v).unwrap(); + let (cmd, params) = s.journal.last().unwrap().clone(); + assert_eq!((cmd.as_str(), ¶ms["pickColorFrom"]), ("shapeBuilder.merge", &json!("swatches")), "{pick}"); + let d = &s.doc().unwrap().doc; + let fills: Vec = d.children(d.default_layer()).into_iter().flatten().map(|n| n.appearance.fill_paint()).collect(); + assert_eq!(fills, vec![picked], "{pick}: the two squares merged into one shape with the picked fill"); + } +} + /// With Pick Color From Color Swatches, a merge fills with the fill chosen while the Shape Builder /// is active, and the Gradient panel's eyedropper samples into a stop of that fill's gradient. #[test] diff --git a/crates/engine/src/tests/toolsettings.rs b/crates/engine/src/tests/toolsettings.rs index 7a28a84ec7..76fda42a5b 100644 --- a/crates/engine/src/tests/toolsettings.rs +++ b/crates/engine/src/tests/toolsettings.rs @@ -698,3 +698,28 @@ fn a_parametric_shape_kind_and_its_values_set_together() { assert_eq!(s.tool_options_of("parametricShape")["kind"], json!("star"), "a refused call sets nothing"); } } + +/// The Shape Builder picks colors from the color swatches by default: a fresh session, and saved +/// preferences that hold other Shape Builder options but no `pickColorFrom`, give `swatches`. A +/// saved `artwork` (or `swatches`) is kept. +#[test] +fn shape_builder_pick_color_from_defaults_to_swatches_and_keeps_a_saved_choice() { + let mut s = session(); + select(&mut s, "shapeBuilder"); + assert_eq!(s.tool_options()["pickColorFrom"], json!("swatches"), "a fresh session"); + for (saved, want) in [ + (json!({"highlightFill": false}), "swatches"), + (json!({"pickColorFrom": "artwork"}), "artwork"), + (json!({"pickColorFrom": "swatches"}), "swatches"), + ] { + let mut prefs = s.prefs.clone(); + prefs.tool_settings.insert("shapeBuilder".into(), saved.as_object().unwrap().clone()); + let saved_text = serde_json::to_string(&prefs).unwrap(); + let mut next = session(); + next.apply_prefs(serde_json::from_str(&saved_text).unwrap()); + select(&mut next, "shapeBuilder"); + assert_eq!(next.tool_options()["pickColorFrom"], json!(want), "saved {saved}"); + select(&mut next, "selection"); + assert_eq!(next.prefs.tool_settings["shapeBuilder"]["pickColorFrom"], json!(want), "stored again: {saved}"); + } +} diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 9730bd7853..b6f0866d96 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1192,7 +1192,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "tool.options", "Tool Options…", "", - "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (artwork), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", + "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", ), ( "ui.colorGuideOptions", diff --git a/crates/tools/src/builder.rs b/crates/tools/src/builder.rs index cdc7f6f7dc..42886ec013 100644 --- a/crates/tools/src/builder.rs +++ b/crates/tools/src/builder.rs @@ -66,11 +66,11 @@ pub struct ShapeBuilderOptions { /// region as if an invisible edge closed it. When it is off, the path cuts the regions it crosses /// as a line does. pub open_filled_as_closed: bool, - /// Pick Color From Color Swatches (`pickColorFrom: "swatches"`; off: `"artwork"`): a merge + /// Pick Color From Color Swatches (`pickColorFrom: "swatches"`, on; off: `"artwork"`): a merge /// fills the new shape with the current fill, and the Left and Right arrow keys step the current /// fill through the document's color swatches. With Artwork, the shape takes the look of the /// object where the drag starts, else of the one where it ends, else of the front-most selected - /// object. + /// object. A saved `pickColorFrom` is kept; preferences without one take Color Swatches. pub swatches: bool, /// Cursor Swatch Preview (`cursorSwatchPreview`, off): with Color Swatches, the current fill /// and the swatches before and after it show as chips above the pointer while no drag is on. @@ -105,7 +105,7 @@ impl Default for ShapeBuilderOptions { fn default() -> Self { Self { open_filled_as_closed: true, - swatches: false, + swatches: true, cursor_swatch_preview: false, straight_line: false, highlight_fill: true, diff --git a/crates/ui-egui/src/dialogs/option_form.rs b/crates/ui-egui/src/dialogs/option_form.rs index fde3f40932..7b1bf40418 100644 --- a/crates/ui-egui/src/dialogs/option_form.rs +++ b/crates/ui-egui/src/dialogs/option_form.rs @@ -631,7 +631,7 @@ pub(super) mod tests { tool: "shapeBuilder", opens_on: vec![ ("openFilledAsClosed", json!(true)), - ("pickColorFrom", json!("artwork")), + ("pickColorFrom", json!("swatches")), ("cursorSwatchPreview", json!(false)), ("selection", json!("freeform")), ("highlightFill", json!(true)), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index f5e6908a8a..e76772d154 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1193,7 +1193,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "tool.options", "Tool Options…", "", - "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (artwork), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", + "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", ), ( "ui.colorGuideOptions", diff --git a/docs/mcp.md b/docs/mcp.md index a9e9d9649a..5ec8ceafd4 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -15725,10 +15725,11 @@ a flare into a plain group of its parts. The document saves a flare's settings. The Shape Builder tool's options are its Shape Builder Tool Options (dialog `shapeBuilderOptions`): `openFilledAsClosed` (on: a filled open path bounds a region as if an invisible edge closed it; a path counts as filled when any of its fill rows is shown, painted and above 0% opacity, whichever row is on top; off: it cuts regions -as an unfilled path does), `pickColorFrom` (`artwork`, the default: a merged shape takes the appearance, opacity and -blending mode of the front-most selected object under the drag's first point, else of the one under its last point, -else of the front-most selected object; `swatches`: the current fill, and the Left and Right arrow keys without -Shift, Alt or Cmd/Ctrl step the current fill through the document's color swatches), `cursorSwatchPreview` (off; with `swatches`, chips above the +as an unfilled path does), `pickColorFrom` (`swatches`, the default: a merged shape fills with the current fill, and +the Left and Right arrow keys without Shift, Alt or Cmd/Ctrl step the current fill through the document's color +swatches; `artwork`: a merged shape takes the appearance, opacity and blending mode of the front-most selected object +under the drag's first point, else of the one under its last point, else of the front-most selected object; a +`pickColorFrom` saved with the preferences is kept, and preferences saved without one take `swatches`), `cursorSwatchPreview` (off; with `swatches`, chips above the pointer show the current fill and the swatches before and after it), `selection` (`freeform`, the default, or `straightLine`: a drag touches what the line from its first point to the pointer crosses), `highlightFill` (on by default; when it is off, merge mode shades no regions), `gapDetection` (off) with `gapLength` (pt, 0 to 72; 3), `clickStrokeSplitsPath` (In Merge Mode, From 3e29a71b9986754961467c16f90c0ec93485d7c7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:05:26 -0800 Subject: [PATCH 169/264] Selection Tools: Edit Points Only keeps Appearance row changes and other status messages Replacing or canceling a drag's preview restores the Appearance row only when the preview itself changed it, so a row set or cleared during the drag stays. The dialog clears only its own preview error, and only while it is still the current status message. The group expansion test checks behavior instead of source text. --- crates/engine/src/cmd/addons/select.rs | 2 +- crates/engine/src/cmd/addons/select/tests.rs | 50 +++++++++++++++++-- crates/engine/src/cmd/appearance.rs | 17 ++++++- crates/engine/src/interaction.rs | 8 ++- crates/engine/src/session/edit.rs | 28 +++++++---- crates/ui-egui/src/addons/dialogs.rs | 25 ++++++++-- .../src/addons/select/points_only/tests.rs | 42 ++++++++++++++++ docs/mcp.md | 4 ++ 8 files changed, 154 insertions(+), 22 deletions(-) diff --git a/crates/engine/src/cmd/addons/select.rs b/crates/engine/src/cmd/addons/select.rs index fb8c49aed6..e99294a4b0 100644 --- a/crates/engine/src/cmd/addons/select.rs +++ b/crates/engine/src/cmd/addons/select.rs @@ -54,7 +54,7 @@ pub fn specs() -> Vec { "Edit Points Only", ["Object", "Plug-ins", "Selection Tools"], None, - "{segmentEnds?: false (true: the points at the ends of each selected segment stay selected, as anchor points; any non-boolean value, including null, is an error)} narrow the selection to paths and their selected anchor points: a path with selected anchor points keeps them; a path with selected segments drops the segments and keeps its other selected anchor points, and the points at the segments' ends leave the selection unless segmentEnds is true; a path selected whole stays selected whole and still receives object transforms, including stroke and effect scaling when enabled; a group or compound path selected whole gives way to the paths inside it, each selected whole unless it has an explicit anchor pick, leaving out hidden and locked ones, a Shaper Group's original shapes and, while guides are locked, paths made into guides; explicit anchor picks take precedence regardless of selection order; type, images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. With nothing selected, or no anchor point left to keep, it is an error that leaves the selection as it was. The command does not add an undo step → {changed (false when the selection already held only anchor points), count (the paths left selected), points (the anchor points selected on them)}", + "{segmentEnds?: false (true: the points at the ends of each selected segment stay selected, as anchor points; any non-boolean value, including null, is an error)} narrow the selection to paths and their selected anchor points: a path with selected anchor points keeps them; a path with selected segments drops the segments and keeps its other selected anchor points, and the points at the segments' ends leave the selection unless segmentEnds is true; a path selected whole stays selected whole and still receives object transforms, including stroke and effect scaling when enabled; a group or compound path selected whole gives way to the paths inside it, each selected whole unless it has an explicit anchor pick, leaving out hidden and locked ones, a Shaper Group's original shapes and, while guides are locked, paths made into guides; explicit anchor picks take precedence regardless of selection order; type, images, symbols, meshes and other objects without anchor points, and ruler guides, leave the selection. With nothing selected, or no anchor point left to keep, it is an error that leaves the selection as it was. The command does not add an undo step. In the desktop dialog, a successful preview or OK clears only that dialog's preview error if it is still the current status message → {changed (false when the selection already held only anchor points), count (the paths left selected), points (the anchor points selected on them)}", has_doc, edit_points_only ), diff --git a/crates/engine/src/cmd/addons/select/tests.rs b/crates/engine/src/cmd/addons/select/tests.rs index 6171c08ef9..4b86ae5802 100644 --- a/crates/engine/src/cmd/addons/select/tests.rs +++ b/crates/engine/src/cmd/addons/select/tests.rs @@ -487,11 +487,7 @@ mod edit_points_only { } #[test] - fn group_expansion_does_not_scan_the_selection_for_each_descendant() { - let source = include_str!("../select.rs"); - let command = source.split("fn edit_points_only(").nth(1).unwrap(); - assert!(!command.contains("sel.objects.contains(&c.id)"), "descendant lookup must not scan every selected object"); - + fn group_expansion_selects_each_descendant_path() { let (mut s, _, _) = two(); let mut groups = vec![]; let mut paths = vec![]; @@ -507,6 +503,48 @@ mod edit_points_only { assert_eq!(picked(&s), (paths, BTreeMap::new())); } + #[test] + fn appearance_row_commands_survive_preview_replacement_and_cancel() { + for index in [json!(1), Value::Null] { + for selection_preview in [false, true] { + let (mut s, a, b) = two(); + mixed(&mut s, a, b); + s.execute("appearance.addFill", &json!({})).unwrap(); + s.execute("appearance.setActiveItem", &json!({"index": 0})).unwrap(); + s.begin_interaction("Drag").unwrap(); + s.doc_mut().unwrap().interaction.as_mut().unwrap().tool = !selection_preview; + if selection_preview { + s.preview(C, &json!({})).unwrap(); + assert_eq!(s.appearance_item(), None); + } else { + s.preview("object.move", &json!({"dx": 10, "dy": 0})).unwrap(); + } + s.execute("appearance.setActiveItem", &json!({"index": index})).unwrap(); + let expected = index.as_u64().map(|i| i as usize); + s.preview("object.move", &json!({"dx": 20, "dy": 0})).unwrap(); + assert_eq!(s.appearance_item(), expected, "replacement preserves the explicit row command"); + s.cancel_interaction().unwrap(); + assert_eq!(s.appearance_item(), expected, "cancel preserves the explicit row command"); + } + } + } + + #[test] + fn cancel_preserves_an_appearance_row_command_without_another_preview() { + for index in [json!(1), Value::Null] { + let (mut s, a, b) = two(); + mixed(&mut s, a, b); + s.execute("appearance.addFill", &json!({})).unwrap(); + s.execute("appearance.setActiveItem", &json!({"index": 0})).unwrap(); + s.begin_interaction("Drag").unwrap(); + s.doc_mut().unwrap().interaction.as_mut().unwrap().tool = true; + s.preview(C, &json!({})).unwrap(); + s.execute("appearance.setActiveItem", &json!({"index": index})).unwrap(); + s.cancel_interaction().unwrap(); + assert_eq!(s.appearance_item(), index.as_u64().map(|i| i as usize)); + } + } + #[test] fn canceling_a_selection_preview_restores_the_active_appearance_item() { let (mut s, a, b) = two(); @@ -517,6 +555,8 @@ mod edit_points_only { s.begin_interaction("Edit Points Only").unwrap(); s.preview(C, &json!({})).unwrap(); assert_eq!(s.appearance_item(), None); + s.preview(C, &json!({"segmentEnds": true})).unwrap(); + assert_eq!(s.appearance_item(), None); s.cancel_interaction().unwrap(); assert_eq!(s.appearance_item(), Some(0)); s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap(); diff --git a/crates/engine/src/cmd/appearance.rs b/crates/engine/src/cmd/appearance.rs index d319e0d2a4..a530efce99 100644 --- a/crates/engine/src/cmd/appearance.rs +++ b/crates/engine/src/cmd/appearance.rs @@ -139,7 +139,7 @@ pub fn specs() -> Vec { "Select Appearance Item", [], None, - "{index: paint-order item index in the first selected object's stack | null} make that fill/stroke row the target of the paint.setFill/setStroke, stroke.set/setAdvanced, paint.editGradient/setGradientGeom, transparency.set and effect.* calls that omit `item` (a fill row brings the Fill proxy forward, a stroke row the Stroke proxy); null or any selection change clears it → {index}", + "{index: paint-order item index in the first selected object's stack | null} make that fill/stroke row the target of the paint.setFill/setStroke, stroke.set/setAdvanced, paint.editGradient/setGradientGeom, transparency.set and effect.* calls that omit `item` (a fill row brings the Fill proxy forward, a stroke row the Stroke proxy); null or any selection change clears it. A row set or cleared outside a drag's preview stays set or cleared when the preview is replaced or canceled → {index}", has_selection, set_active_item ), @@ -174,7 +174,7 @@ pub fn specs() -> Vec { } /// The Appearance panel's active row, remembered for the selection it was chosen in. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub(crate) struct ActiveItem { doc: u64, objects: Vec, @@ -956,6 +956,7 @@ fn set_active_item(s: &mut Session, p: &Value) -> Result { let index = match p.get("index") { Some(Value::Null) => { s.active_appearance_item = None; + clear_preview_item(s); return Ok(json!({ "index": Value::Null })); } Some(_) => index_param(p, "index", C)?, @@ -968,9 +969,21 @@ fn set_active_item(s: &mut Session, p: &Value) -> Result { let doc = st.uid; s.fill_active = fill; s.active_appearance_item = Some(ActiveItem { doc, objects, index }); + clear_preview_item(s); Ok(json!({ "index": index })) } +fn clear_preview_item(s: &mut Session) { + if !s.previewing { + if let Some(it) = s.active_mut().and_then(|st| st.interaction.as_mut()) { + it.active_appearance_item = None; + } + if let Some(held) = &mut s.held_interaction { + held.interaction.active_appearance_item = None; + } + } +} + fn add_item(s: &mut Session, p: &Value, fill: bool) -> Result { let cmd = if fill { "appearance.addFill" } else { "appearance.addStroke" }; let mut ids = row_targets(s, p, cmd)?; diff --git a/crates/engine/src/interaction.rs b/crates/engine/src/interaction.rs index dc7b5684fe..748dd764cc 100644 --- a/crates/engine/src/interaction.rs +++ b/crates/engine/src/interaction.rs @@ -10,7 +10,7 @@ pub struct Interaction { pub doc: Arc, /// The selection the previews start from (shared, so a preview frame copies nothing). pub selection: Arc, - pub(crate) active_appearance_item: Option, + pub(crate) active_appearance_item: Option, pub preview: Option<(String, Value)>, /// The active tool began it (a drag): a command from outside the tool runs as a step of its /// own under it ([`crate::Session::outside_interaction`]). A dialog or a panel that begins an @@ -53,6 +53,12 @@ pub struct Interaction { pub keep_on_switch: bool, } +#[derive(Clone, Debug)] +pub(crate) struct PreviewAppearanceItem { + pub(crate) before: Option, + pub(crate) after: Option, +} + /// An interaction that a command from outside the tool set aside while it runs /// ([`crate::Session::outside_interaction`]). #[derive(Debug)] diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 45d0dfd370..e337be95ab 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -536,7 +536,6 @@ impl Session { } self.clear_deferred_overlay_cache(); let paint = self.paint.clone(); - let active_appearance_item = self.active_appearance_item.clone(); let st = self.doc_mut()?; if st.interaction.is_some() { return Ok(()); @@ -546,7 +545,7 @@ impl Session { effect: None, doc: st.doc.clone(), selection: Arc::new(st.selection.clone()), - active_appearance_item, + active_appearance_item: None, preview: None, tool: false, paint, @@ -574,12 +573,14 @@ impl Session { if self.script_running() { return Err(EngineError::Busy); } + self.restore_preview_appearance_item(); + let before_item = self.active_appearance_item.clone(); // While the active tool paints with the chosen fill or stroke (the Live Paint Bucket, the // Shape Builder), paint previews of that kind change only the colors it paints with, so each // preview starts from the colors the interaction began with; so does a preview with // `defaultsOnly: true`, and one after it. let tool_paints = self.tool_paints(false) || self.tool_paints(true); - let (paint, restore_paint, active_appearance_item) = { + let (paint, restore_paint) = { let menu = self.menu.clone(); let st = self.doc_mut()?; let Some(it) = &mut st.interaction else { return Err(EngineError::Other("no interaction in progress".into())) }; @@ -601,7 +602,6 @@ impl Session { || it.preview.as_ref().is_some_and(|(id, p)| id == "command.batch" || cmd::asks_defaults_only(p)) || it.color_mode_paints.is_some(); let paint = it.paint.clone(); - let active_appearance_item = it.active_appearance_item.clone(); it.preview_paint = None; it.color_mode_paints = None; it.deferred_color_mode = None; @@ -618,9 +618,8 @@ impl Session { // undone with it. st.restore_isolation(isolation, &undone); cmd::globaledit::follow_history(st); - (paint, restore_paint, active_appearance_item) + (paint, restore_paint) }; - self.active_appearance_item = active_appearance_item; if restore_paint { self.paint = paint.clone(); } @@ -642,8 +641,11 @@ impl Session { } let params = self.noted(params); let batch_paint = (r.is_ok() && cmd == "command.batch").then(|| self.paint.clone()); + let after_item = self.active_appearance_item.clone(); let st = self.doc_mut()?; if let Some(it) = &mut st.interaction { + it.active_appearance_item = + (before_item != after_item).then_some(crate::interaction::PreviewAppearanceItem { before: before_item, after: after_item }); it.used_defaults_only |= ran_defaults_only; // A failed preview leaves the document at the snapshot, so nothing is left to commit // (not even an earlier successful preview, which the reset above already undid). @@ -761,8 +763,18 @@ impl Session { } } + fn restore_preview_appearance_item(&mut self) { + let changed = self.active_mut().and_then(|st| st.interaction.as_mut()).and_then(|it| it.active_appearance_item.take()); + if let Some(changed) = changed + && self.active_appearance_item == changed.after + { + self.active_appearance_item = changed.before; + } + } + pub fn cancel_interaction(&mut self) -> Result<()> { self.put_back_interaction(); + self.restore_preview_appearance_item(); self.clear_deferred_overlay_cache(); self.decoded_images.empty(); self.pending_paint = None; @@ -786,14 +798,10 @@ impl Session { self.paint = paint; } let menu = self.menu.clone(); - let active_appearance_item = self.active().and_then(|st| st.interaction.as_ref()).map(|it| it.active_appearance_item.clone()); let st = self.doc_mut()?; st.undo_interaction(); // Guides locked and slices locked or hidden during the interaction stay deselected. deselect_hidden(&menu, &st.doc, &mut st.selection); - if let Some(active_appearance_item) = active_appearance_item { - self.active_appearance_item = active_appearance_item; - } // A canceled preview's Assign Profile is undone with it. self.sync_front_profiles(); // With New Art Has Basic Appearance off, new art takes the appearance of the selection as diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index f0642c31fc..a1c9dcf5b8 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -34,6 +34,7 @@ pub(crate) struct Spec { pub(crate) struct AddonDialogs { open: Option, preview: LivePreview, + preview_error: Option<(u64, String)>, /// The open Tangent Circle Tool radius dialog. pub(crate) tangent_radius: Option, } @@ -65,6 +66,7 @@ fn active_document(app: &VectorcraftApp) -> Option<(u64, u64)> { /// Closes the open add-on dialog without an answer and rolls its preview back. fn close_open(app: &mut VectorcraftApp) { let Some(open) = app.addon_dialogs.open.take() else { return }; + app.addon_dialogs.preview_error = None; let id = open.id; if let (Some(host), Some(ctx)) = (app.dialogs(), app.ui_ctx.clone()) { host.with(|h| { @@ -133,6 +135,7 @@ fn pump_commit(app: &mut VectorcraftApp) { if !on_document { // Switching drawings already ends the old preview. Discard its bookkeeping without touching the other drawing. app.addon_dialogs.preview = LivePreview::default(); + app.addon_dialogs.preview_error = None; } let live = host.with(|h| h.get_mut_by_id::(id).map(|d| (d.is_previewing(), (spec.params)(d.fields())))); if on_document && let Some((previewing, params)) = &live { @@ -140,8 +143,12 @@ fn pump_commit(app: &mut VectorcraftApp) { let label = vectorcraft_engine::find_command(spec.command).map_or(spec.command, |command| command.label); let answer = preview.run(app, *previewing, label, spec.command, params); app.addon_dialogs.preview = preview; - if spec.command == super::select::points_only::COMMAND && matches!(&answer, Some(Ok(_))) { - app.ui.status.clear(); + if spec.command == super::select::points_only::COMMAND { + match &answer { + Some(Err(_)) => app.addon_dialogs.preview_error = Some((app.ui.status_sets, app.ui.status.clone())), + Some(Ok(_)) => clear_preview_error(app), + None => {} + } } if let (Some(found), Some(answer)) = (spec.found, answer) { host.with(|h| { @@ -170,18 +177,30 @@ fn pump_commit(app: &mut VectorcraftApp) { if let Err(error) = answer { app.status(error); } else if spec.command == super::select::points_only::COMMAND { - app.ui.status.clear(); + clear_preview_error(app); } } + app.addon_dialogs.preview_error = None; } Some(None) => { app.addon_dialogs.open = None; + app.addon_dialogs.preview_error = None; mem::take(&mut app.addon_dialogs.preview).cancel(app); } None if live.is_none() => { app.addon_dialogs.open = None; + app.addon_dialogs.preview_error = None; mem::take(&mut app.addon_dialogs.preview).cancel(app); } None => {} } } + +fn clear_preview_error(app: &mut VectorcraftApp) { + if let Some((sets, error)) = app.addon_dialogs.preview_error.take() + && app.ui.status_sets == sets + && app.ui.status == error + { + app.ui.status.clear(); + } +} diff --git a/crates/ui-egui/src/addons/select/points_only/tests.rs b/crates/ui-egui/src/addons/select/points_only/tests.rs index ff0fef879f..75ddaf5703 100644 --- a/crates/ui-egui/src/addons/select/points_only/tests.rs +++ b/crates/ui-egui/src/addons/select/points_only/tests.rs @@ -96,6 +96,48 @@ fn cancel_puts_the_selection_back() { assert_eq!(app.session.doc().unwrap().selection, before); } +#[test] +fn successful_preview_and_confirmation_preserve_another_status() { + for previewing in [true, false] { + let (mut app, _, _) = app(); + host::open_item(&mut app, "Selection Tools", "Edit Points Only…"); + let id = host::dialog_id(&app); + app.status("The active text edit reported a warning."); + if previewing { + host::frame(&mut app); + assert_eq!(app.ui.status, "The active text edit reported a warning."); + } + assert!(host::confirm(&app, id)); + host::frame(&mut app); + assert_eq!(app.ui.status, "The active text edit reported a warning."); + assert!(!app.any_dialog_open()); + } +} + +#[test] +fn recovering_from_a_preview_error_preserves_a_later_status() { + for previewing in [true, false] { + for same_text in [true, false] { + let (mut app, a, _) = app(); + app.run("select.segments", json!({"id": a.0, "segments": [[0, 0]]})).unwrap(); + host::open_item(&mut app, "Selection Tools", "Edit Points Only…"); + let id = host::dialog_id(&app); + host::frame(&mut app); + assert!(app.ui.status.contains("no anchor points are selected")); + let status = if same_text { app.ui.status.clone() } else { "Another command reported a warning.".to_owned() }; + app.status(status.clone()); + host::set(&app, id, "segmentEnds", json!(true)); + if previewing { + host::frame(&mut app); + assert_eq!(app.ui.status, status); + } + assert!(host::confirm(&app, id)); + host::frame(&mut app); + assert_eq!(app.ui.status, status); + } + } +} + #[test] fn keeping_segment_ends_clears_the_preview_error() { for previewing in [true, false] { diff --git a/docs/mcp.md b/docs/mcp.md index 65c28a7c38..c6a4aff22a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -985,6 +985,8 @@ Cmd+Alt+/ runs `appearance.addStroke` (`press_key {key: "/", mods: {cmd: true, a `item` to edit one of them; `run_command appearance.setActiveItem {"index": n}` makes that row the target of later calls that omit `item` (as clicking the row in the Appearance panel does) until the selection changes; the proxy of its kind (`paint.proxies`) and the Gradient tool's annotator then show that row. +An `appearance.setActiveItem` call made outside a drag's preview keeps its selected row, including an explicit +`index: null`, when the preview is replaced or canceled. `inspect_document` reports it as `paint.appearanceItem`. `paint.setFill` and `paint.setStroke` also take `opacity` (0 to 100, a percentage as in `transparency.set`), which sets the opacity of the fill or stroke row they paint, with or without a new paint, as one undo step. An opacity that no target takes is an error and also leaves the paint @@ -17335,6 +17337,8 @@ anchor points selected on them. Nothing selected, no anchor point left to keep ( In the desktop app, Object › Plug-ins › Selection Tools › Edit Points Only… opens a dialog with Keep Ends of Selected Segments (off). With Preview on, the canvas shows the narrowed selection; OK keeps it and Cancel puts the selection back. +After a failed preview, a successful preview or OK clears the dialog's error only if that error is still the current +status message. Messages from other commands stay displayed. ### Vector Halftone (live) From 4f95a30c987126e25cdba53122228708a29f25c9 Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Sun, 29 Nov 2026 18:22:52 -0800 Subject: [PATCH 170/264] Images: a selected image's color mode is read from its file header (#10167) --- crates/engine/src/cmd/place.rs | 24 ++++++++++---- crates/engine/src/tests/place.rs | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/place.rs b/crates/engine/src/cmd/place.rs index 58612c744c..ba2b523f62 100644 --- a/crates/engine/src/cmd/place.rs +++ b/crates/engine/src/cmd/place.rs @@ -1231,12 +1231,24 @@ fn queue(s: &mut Session, p: &Value) -> Result { // ---------- queries ---------- -/// The colour mode an image file stores its pixels in. -fn color_mode(bytes: &[u8]) -> &'static str { - match craft_image_codecs::decode(bytes).ok().map(|img| img.layout()) { - Some(craft_image_codecs::ChannelLayout::Gray | craft_image_codecs::ChannelLayout::GrayA) => "Grayscale", - Some(craft_image_codecs::ChannelLayout::Cmyk | craft_image_codecs::ChannelLayout::CmykA) => "CMYK", - _ => "RGB", +/// The colour mode an image file stores its pixels in. A PNG, JPEG, TIFF, PSD, GIF or BMP file's +/// header says it and a WebP file is always RGB, so their pixels are not decoded; the Control bar +/// and the Properties panel ask `image.info` again after every change, each step of a drag +/// included. A file in another format is decoded. +pub(crate) fn color_mode(bytes: &[u8]) -> &'static str { + use craft_image_codecs::{ChannelLayout as L, RasterColorType as T}; + match craft_image_codecs::inspect_raster(bytes) { + Ok(Some(i)) => match i.color_type { + T::Bitmap | T::Gray | T::GrayAlpha => "Grayscale", + T::Cmyk | T::CmykAlpha => "CMYK", + _ => "RGB", + }, + _ if craft_image_codecs::detect(bytes) == Some(craft_image_codecs::Format::WebP) => "RGB", + _ => match craft_image_codecs::decode(bytes).ok().map(|img| img.layout()) { + Some(L::Gray | L::GrayA) => "Grayscale", + Some(L::Cmyk | L::CmykA) => "CMYK", + _ => "RGB", + }, } } diff --git a/crates/engine/src/tests/place.rs b/crates/engine/src/tests/place.rs index 94da32aa01..c38dd53452 100644 --- a/crates/engine/src/tests/place.rs +++ b/crates/engine/src/tests/place.rs @@ -247,6 +247,62 @@ fn replace_keeps_the_transform_and_the_stacking_place() { assert_eq!(top_children(&s)[0].id.0, first.as_u64().unwrap(), "one undo step brings the old image back"); } +/// `image.info` reads a PNG's colour mode from its header without decoding its pixels: a grayscale +/// PNG whose compressed pixel data is unreadable still says Grayscale. The Control bar asks again +/// after every step of a drag, so a decode there redid a large image's whole decode each step. +#[test] +fn image_color_mode_reads_the_header_without_decoding_the_pixels() { + let raw: Vec = (0..64u32 * 64).map(|i| (i * 7 % 251) as u8).collect(); + let gray = craft_image_codecs::Image::from_raw(64, 64, craft_image_codecs::ChannelLayout::Gray, craft_image_codecs::SampleType::U8, raw).unwrap(); + let mut png = craft_image_codecs::encode(&gray, craft_image_codecs::Format::Png, &craft_image_codecs::EncodeOptions::default()).unwrap(); + assert_eq!(cmd::place::color_mode(&png), "Grayscale"); + // Each IDAT chunk's data zeroed (an invalid zlib stream) under a correct CRC. + let mut at = 8; + let mut idat = 0; + while at + 12 <= png.len() { + let len = u32::from_be_bytes(png[at..at + 4].try_into().unwrap()) as usize; + if &png[at + 4..at + 8] == b"IDAT" { + png[at + 8..at + 8 + len].fill(0); + let crc = crc32fast::hash(&png[at + 4..at + 8 + len]); + png[at + 8 + len..at + 12 + len].copy_from_slice(&crc.to_be_bytes()); + idat += 1; + } + at += 12 + len; + } + assert!(idat > 0, "the PNG has pixel data"); + assert!(craft_image_codecs::decode(&png).is_err(), "the pixels no longer decode"); + assert_eq!(cmd::place::color_mode(&png), "Grayscale", "the header alone gives the colour mode"); +} + +/// The colour mode read from a file's header is the one its decoded pixels have, in every format +/// and channel layout the codecs write. +#[test] +fn image_color_mode_from_the_header_matches_the_decoded_pixels() { + use craft_image_codecs::{ChannelLayout as L, Format as F}; + let decoded = |bytes: &[u8]| match craft_image_codecs::decode(bytes).map(|i| i.layout()) { + Ok(L::Gray | L::GrayA) => "Grayscale", + Ok(L::Cmyk | L::CmykA) => "CMYK", + Ok(_) => "RGB", + Err(e) => panic!("the written file decodes: {e}"), + }; + let mut seen = std::collections::BTreeSet::new(); + let mut checked = 0; + for format in [F::Png, F::Jpeg, F::Tiff, F::Gif, F::Bmp, F::WebP] { + for layout in [L::Gray, L::GrayA, L::Rgb, L::Rgba, L::Cmyk] { + let n = 16 * 16 * layout.channels(); + let raw: Vec = (0..n).map(|i| (i * 13 % 256) as u8).collect(); + let img = craft_image_codecs::Image::from_raw(16, 16, layout, craft_image_codecs::SampleType::U8, raw).unwrap(); + let Ok(bytes) = craft_image_codecs::encode(&img, format, &craft_image_codecs::EncodeOptions::default()) else { continue }; + let want = decoded(&bytes); + assert_eq!(cmd::place::color_mode(&bytes), want, "{format:?} written from {layout:?}"); + seen.insert(want); + checked += 1; + } + } + assert!(checked >= 12, "{checked} files written"); + assert_eq!(seen.into_iter().collect::>(), ["CMYK", "Grayscale", "RGB"]); +} + #[test] fn replace_needs_exactly_one_selected_object() { let mut s = session(); From 45b0cb12f0e499d5df58e843ff7aa0772dd7a6e7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:39:59 -0800 Subject: [PATCH 171/264] Docs: three-d.md matches what main ships Graphics map onto Inflate's puffed front and back (#7767), so the unbuilt list no longer names graphics on Inflate and the Graphics sentence names Inflate's faces. The 3D (Classic) effects export as meshes through Asset Export (#6168, #7852), so only Turntable stays named as unbuilt there. --- docs/three-d.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/three-d.md b/docs/three-d.md index a8f220bc59..d5bb4665a9 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -709,11 +709,11 @@ and [Create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effe pages, and the archived Extrude & Bevel option list (depth 0–2,000, cap on/off, bevel height, bevel extent in or out, perspective). No Adobe software, assets, presets or bevel shapes were used. -- **Materials** (base and Adobe Substance), graphics on Inflate, shadows of lights after the first, and +- **Materials** (base and Adobe Substance), shadows of lights after the first, and **ray-traced rendering** are not built: shading uses directional lights, in the paint of the fill or stroke the solid is built for ([Fills and strokes](#fills-and-strokes)), and only the first light casts a shadow ([Shadows](#shadows)). Graphics map onto planar faces, Extrude & Bevel's side as one surface unrolled flat, and - Revolve's side only ([Graphics](#graphics)). + Revolve's side and Inflate's puffed front and back only ([Graphics](#graphics)). - The bevel shapes and their names are our own. Custom bevels come from VectorCraft's own bevels file ([Custom bevels](#custom-bevels)) and are cut into straight lines. - Visibility is a painter's algorithm: faces of a closed solid turned away are left out, and the rest are drawn @@ -766,7 +766,7 @@ out, perspective). No Adobe software, assets, presets or bevel shapes were used. draws the shading over it as overprinting black, without the highlight. The shading is on the black plate in Separations Preview and PDF output. Their Rotation tab has the track cube ([Track cube](#track-cube)). Extrude & Bevel (Classic) and Revolve (Classic) take Map Art - ([Map Art](#map-art)). Turntable and 3D export are separate, unbuilt items. + ([Map Art](#map-art)). Turntable is a separate, unbuilt item. Release measurements and a repeatable CLI scene are in [3D lighting performance](3d-lighting-performance.md). From 4c24874e2e22fc7777aafc3b113eae3d90d679dc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:40:13 -0800 Subject: [PATCH 172/264] Docs: type-parity.md matches what main ships MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CJK row lists custom kinsoku sets as done, through Type › Kinsoku Shori Settings… (#7229); custom mojikumi sets and the Mojikumi Settings dialog stay missing. The Retype row no longer lists the Properties panel's Quick Actions among the missing ways to open the Retype panel, since its Retype Quick Action does that (#8778). --- docs/type-parity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/type-parity.md b/docs/type-parity.md index 1587d7f8f1..60b4a7117d 100644 --- a/docs/type-parity.md +++ b/docs/type-parity.md @@ -60,7 +60,7 @@ against Illustrator's public documentation; **estimated** unless noted. | Alt + numeric-keypad codes while typing (Windows: `Alt+0176` → °) | partial | #5108: on Windows the character Windows posts when Alt comes up after keypad digits is typed at the caret like any other, in the typing's undo step, and the keypad digits typed with Alt run no shortcut. With NumLock off the keypad keys (Insert, End, arrows, Clear, Home, Page Up/Down without the extended-key flag) count as digits too and don't move the caret (`windows_alt_codes` unit tests; neither NumLock on nor off has been tried on a Windows machine yet). `type.insert {code}` (Windows Alt+0 code, Windows-1252 for 128–159) and `{unicode}` (hex code point) insert a character by its code (`menucmds::insert_a_character_by_its_code`). macOS and Linux have no such system convention and egui reports a keypad digit as the top-row digit, so there it does nothing; a floating panel window doesn't receive the character | | Caret: the arrows and Delete step over whole clusters (Thai consonant with its marks, combining accents, emoji); Backspace removes one character | done | in text with right-to-left characters the arrows move in visual order and stop on both sides of a character drawn with no width, such as a zero width non-joiner | | Touch Type tool | done | moves, scales and rotates one character through its kerning, baseline shift, scales and rotation (`text.touchType`); a character with a preceding logical character on the same line can move along the line in either reading direction; the first logical character moves only up and down. Positive `dx` follows reading order. These direction rules are VectorCraft's choices. | -| Retype (identify fonts in outlines/images) | partial | Phase 1 (#4934): Type › Retype (`type.retype`) turns outlined glyphs back into type when each shape is exactly a glyph of a loaded font, a font the document uses or a family named in `fonts` (the same up to uniform scale, rotation and translation): one object per line unless lines stack into one object as described below, in that font and size, at the same baseline and turn, with the first glyph's fill and stroke, in one undo step; shapes that match no font stay as they are and are reported. Near matches: with `tolerance` (0 to 0.05), shapes of up to 8 contours whose leftover distance from a glyph, relative to the shape's outline spread (the root mean square distance of its sampled outline points from their center), is at most the tolerance (simplified outlines, curves split in two, contours in another order or direction) match too, and each line reports a `score`; a compound path holding several glyphs is split into them and becomes type only when all of them match, a part still matching exactly when some of its contours run the other way round (an o's counter alone in an even-odd compound). A line of three or more exactly matched glyphs keeps the spacing most of its gaps share as tracking (gaps one space wide stay word spaces when type draws them). A line of two glyphs that untracked type does not draw in place takes the tracking of the nearest tracked line in the same font, size and turn, and keeps it only when type at that tracking draws both glyphs in place; a line of one or two glyphs that joins tracked lines in one object takes their tracking. Other lines are set untracked, each glyph at its own position, and lines stacked at one leading and lined up at their starts, ends or centers become one area type object with that leading and alignment (VectorCraft's own rules, checked against the layout). Window › Retype shows the Retype panel, which lists the fonts whose glyphs exactly match at least one selected outlined shape, comparing up to 96 loaded fonts with those of the document's live type first, ranked by how many shapes each matches, with samples, and sets a listed font on selected live type (`retype.find`, `type.retypeFonts`). Both also compare the installed fonts not loaded yet, reading their files within VectorCraft's own limits (256 MiB per file, 2 GiB and 500,000 glyphs per search) and loading only the fonts that match; `type.retype` matches them with its tolerance and splits compound paths for them as it does for loaded fonts; in the app the search runs in the background with Cancel (`retype.cancelSearch`). Missing (phase 2): glyphs fused into one contour, near matches and compound paths of several glyphs in the panel's list, opening the panel from the Type menu, the context menu and the Properties panel's Quick Actions, filtering the list by font source and favorites, text in images. Public behaviour: [identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html), [apply to live text](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/apply-retype-suggested-fonts-to-live-text.html) | +| Retype (identify fonts in outlines/images) | partial | Phase 1 (#4934): Type › Retype (`type.retype`) turns outlined glyphs back into type when each shape is exactly a glyph of a loaded font, a font the document uses or a family named in `fonts` (the same up to uniform scale, rotation and translation): one object per line unless lines stack into one object as described below, in that font and size, at the same baseline and turn, with the first glyph's fill and stroke, in one undo step; shapes that match no font stay as they are and are reported. Near matches: with `tolerance` (0 to 0.05), shapes of up to 8 contours whose leftover distance from a glyph, relative to the shape's outline spread (the root mean square distance of its sampled outline points from their center), is at most the tolerance (simplified outlines, curves split in two, contours in another order or direction) match too, and each line reports a `score`; a compound path holding several glyphs is split into them and becomes type only when all of them match, a part still matching exactly when some of its contours run the other way round (an o's counter alone in an even-odd compound). A line of three or more exactly matched glyphs keeps the spacing most of its gaps share as tracking (gaps one space wide stay word spaces when type draws them). A line of two glyphs that untracked type does not draw in place takes the tracking of the nearest tracked line in the same font, size and turn, and keeps it only when type at that tracking draws both glyphs in place; a line of one or two glyphs that joins tracked lines in one object takes their tracking. Other lines are set untracked, each glyph at its own position, and lines stacked at one leading and lined up at their starts, ends or centers become one area type object with that leading and alignment (VectorCraft's own rules, checked against the layout). Window › Retype shows the Retype panel, which lists the fonts whose glyphs exactly match at least one selected outlined shape, comparing up to 96 loaded fonts with those of the document's live type first, ranked by how many shapes each matches, with samples, and sets a listed font on selected live type (`retype.find`, `type.retypeFonts`). Both also compare the installed fonts not loaded yet, reading their files within VectorCraft's own limits (256 MiB per file, 2 GiB and 500,000 glyphs per search) and loading only the fonts that match; `type.retype` matches them with its tolerance and splits compound paths for them as it does for loaded fonts; in the app the search runs in the background with Cancel (`retype.cancelSearch`). Missing (phase 2): glyphs fused into one contour, near matches and compound paths of several glyphs in the panel's list, opening the panel from the Type menu and the context menu, filtering the list by font source and favorites, text in images. Public behaviour: [identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html), [apply to live text](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/apply-retype-suggested-fonts-to-live-text.html) | | Snap to Glyph | done | View › Snap to Glyph (`view.snapToGlyph`): with Smart Guides on, new point type and drawing tools snap to live-text baselines and glyph bounds, the corners of each glyph's box included, turning with rotated type (#5112; `guides::tests::a_drawn_point_lands_on_a_corner_of_a_glyphs_bounds`, `Targets::for_drawing`, `tools::text_tests::snap_to_glyph_lines_up_new_point_type_with_a_baseline`). With Alignment Guides on as well, and Snap to Grid and Snap to Pixel off, both ends of a Measure or Measure & Inspect drag snap to those guides and show them during the drag (`Targets::for_measure`, `xform::measure::tests::its_ends_land_on_glyph_guides_with_snap_to_glyph`). That the Measure tools take the guides is VectorCraft's choice; they leave out Anchor Point, which [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/special-characters-glyphs/snap-to-glyph.html) limits to the Pen tool and objects moved with the Selection tool. Character panel menu › Show Snap to Glyph Options: Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides and Anchor Point each turn their guides on or off (`view.snapToGlyph.options`, all on by default; #4232), after a Snap to Glyph checkbox for View › Snap to Glyph; showing them scrolls the panel to them (#5273) | | Thai, Lao, Khmer, Myanmar: shaping (marks, reordering), lines broken between words, word-by-word caret and double-click | done | words found by ICU4X's line segmenter: dictionaries on the desktop, LSTM models on the web | | Middle Eastern: bidirectional layout, Paragraph Direction | done | PDF export keeps harakat and zero-advance Noto Arabic dot glyphs in one compatible batch per layout line, with per-glyph vertical offsets (#6309). `crates/pdf/src/tests/realtext.rs` (`mark_text_*`) checks decoded cluster mappings, mixed Arabic/Latin/digits, contour placement against outline export, vertical columns, differing path rotations and PDF/X-1a/3/4. Editable-text import still needs ActualText support (#6165); separately styled or differently rotated clusters and external viewer search/copy remain outside this export-only evidence. | @@ -70,7 +70,7 @@ against Illustrator's public documentation; **estimated** unless noted. | Middle Eastern & South Asian composers and Standard composers (Paragraph panel menu, paragraph styles, `text.setFormat {composer}`) | done / partial | #4935: per paragraph, four choices. Middle Eastern & South Asian Single-line and Every-line are how all type was already set (complex-script shaping on) and stay the default, so existing documents do not change. Standard Single-line and Every-line break lines the same way and set Indic, Arabic and Hebrew type glyph by glyph as the font maps its characters (no conjuncts, reordering, mark placement or joining), for legacy fonts that keep a script on Latin character codes. Indic, Arabic and the other joining scripts and Hebrew are the scripts left unshaped (their letters do not join, so Insert Kashidas adds no tatweel); Latin, Greek, Cyrillic, CJK, Thai and the rest keep their kerning and ligatures. The native file and paragraph styles keep the choice (`standardSingleLine` / `standardEveryLine`; an older VectorCraft cannot read a file that uses them). `.ai`, EPS and PDF import and export carry no composer: this app has no recorded format for it, so a Standard paragraph opened from or saved to those files comes back Middle Eastern & South Asian. Evidence: `tests::composers`, `tests::panelcmds::text_set_format_takes_the_four_composers`, `native_v3::all_four_composers_round_trip` | | Middle Eastern: split caret | missing | Character Direction is done; editable bidirectional SVG text remains incomplete. | | CJK: input methods (marked text, candidate window) | done | | -| CJK: kinsoku (Hard, Soft, None), the predefined mojikumi sets (None, YakumonoHankaku, GyomatsuYakumonoHankaku, GyomatsuYakumonoZenkaku, YakumonoZenkaku, with VectorCraft's own spacing for each) and Line-end Punctuation Half Width, tate-chu-yoko (auto) | done / partial | custom kinsoku sets, custom mojikumi sets and the Mojikumi Settings dialog missing | +| CJK: kinsoku (Hard, Soft, None), the predefined mojikumi sets (None, YakumonoHankaku, GyomatsuYakumonoHankaku, GyomatsuYakumonoZenkaku, YakumonoZenkaku, with VectorCraft's own spacing for each) and Line-end Punctuation Half Width, tate-chu-yoko (auto) | done / partial | custom kinsoku sets done (Type › Kinsoku Shori Settings…, #7229); custom mojikumi sets and the Mojikumi Settings dialog missing | | CJK: Kinsoku Shori Type (Push In First, Push Out First, Push Out Only) | done | Paragraph panel menu › Kinsoku Shori Type (`text.setFormat {kinsokuType}`), with the East Asian options ([Formatting Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)); Push Out Only is the default, and a push-in closes the line's gaps next to CJK characters by at most a tenth of an em each (VectorCraft's own limit). Evidence: `layout::wrapping_tests::kinsoku_shori_type_pushes_a_closing_bracket_in_or_out`, `tests::vertical::kinsoku_shori_type_pushes_a_closing_bracket_in_or_out`, `typecmd::area_tests::kinsoku_shori_type_is_set_per_paragraph_and_saved_only_when_not_push_out_only` | | CJK: Kurikaeshi Moji Shori | done | Paragraph panel menu › Kurikaeshi Moji Shori (`text.setFormat {kurikaeshiMojiShori}`), with the East Asian options ([Format East Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)): a repeat mark (々, ゝ, ゞ, ヽ, ヾ) that starts a line of point or area type is drawn as the character it repeats, and the text keeps the mark; SVG export with live type writes the drawn character. The set of marks and the voicing rules are VectorCraft's own. Off by default, saved natively only when on, carried by paragraph styles. Evidence: `tests::repeat_marks_stand_for_the_character_before_them`, `tests::kurikaeshi_moji_shori_draws_the_repeated_character_at_a_line_start`, `typecmd::area_tests::kurikaeshi_moji_shori_is_set_per_paragraph_and_saved_only_when_on`, `threads::tests::a_continued_frame_carries_the_character_a_repeat_mark_stands_for`, `panels::paragraph::tests::kurikaeshi_moji_shori_toggle_follows_the_selected_paragraphs`, `text_layout::a_repeat_mark_at_a_line_start_is_written_as_the_character_it_draws` | | CJK: Proportional Metrics (`palt` in horizontal type, `vpal` in vertical type) | done | #966 | From 848d8881b25195f85e88587f6ee74a1672863e4a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:40:28 -0800 Subject: [PATCH 173/264] Docs: file-format-parity.md matches what main ships The PDF embedded-font paragraph now records that full workspace CI passed on #4569 before it merged; hardening paths outside those suites stay pending. The read-only Save summary now records that the focused engine regressions from #6671 passed; native panel acceptance stays pending. --- docs/file-format-parity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index a22db526d1..6287e13f47 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -43,7 +43,7 @@ Paragraph reconstruction binds the source lines' validated carried faces before checking wrapping. The native-reopen regressions compare conflicting-glyph positions and wrapped paragraph ink bounds with outline imports, including filled-and-stroked `TJ` text. The focused engine PDF-fidelity, PDF file-font/stroked-text and text binding/shared-outline suites passed -56 tests on the canonical-main integration candidate. Full workspace CI and hardening paths +56 tests on the canonical-main integration candidate, and full workspace CI passed on #4569 before it merged. Hardening paths outside those suites remain pending. Existing PDF respacing and composite-font regressions remain; no parity score or estimate changes. @@ -55,7 +55,7 @@ from the public specifications, and users' own `.ai` files are used locally only ## Summary -Ordinary File > Save offers Save As when its own location refuses writes with a terminal permission/read-only error (#6146). The picker suggests the original filename and format, keeps the original options when the format is unchanged, and opens the chosen format’s Save options when it changes. It starts in Documents (home or host default if unavailable). Cancel leaves the document modified at its original path. Explicit Save As/Copy/export, recovery failures and Close/Quit keep their existing error dialog. Non-UI saves return `READ_ONLY_LOCATION: ` without opening a panel. Focused UI regressions passed; engine regression execution and native panel acceptance pending; format scores unchanged. +Ordinary File > Save offers Save As when its own location refuses writes with a terminal permission/read-only error (#6146). The picker suggests the original filename and format, keeps the original options when the format is unchanged, and opens the chosen format’s Save options when it changes. It starts in Documents (home or host default if unavailable). Cancel leaves the document modified at its original path. Explicit Save As/Copy/export, recovery failures and Close/Quit keep their existing error dialog. Non-UI saves return `READ_ONLY_LOCATION: ` without opening a panel. Focused UI and engine regressions passed (#6671); native panel acceptance pending; format scores unchanged. | | Illustrator | VectorCraft | Notes | |---|---:|---:|---| From d4ba715061fe09f920606714bf7b655f3a4e6695 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:40:34 -0800 Subject: [PATCH 174/264] Docs: effects-parity.md matches what main ships - 3D and Materials: the summary row counts Revolve (Classic) and Rotate (Classic) beside Extrude & Bevel (Classic) (#6174, #6817, #6826). - Path: Use Preview Bounds measures type with Outline Object by its glyph outlines in Align, Distribute and the Transform panel (#2595). - Stylize: Scribble Options has its Settings presets (#4274). - Warp: the Mesh tool and Direct Selection edit a warp envelope's points (#7064). --- docs/effects-parity.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/effects-parity.md b/docs/effects-parity.md index bdf38e3fe6..2e4ef4dd15 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -13,7 +13,7 @@ Part of [target-app-parity.md](target-app-parity.md); open work is in [gaps.md]( |---|---:|---:|---:|---:| | Illustrator effects (vector and stylize) | 50 | 50 | 100% | — | | Photoshop effects (raster, Effect Gallery) | 57 | 57 | 100% | — | -| 3D and Materials | 4 (+3 Classic) | 4 (+1 Classic; initial: Extrude & Bevel, Revolve, Inflate, Rotate, Extrude & Bevel (Classic)) | ~25% | 25–45 | +| 3D and Materials | 4 (+3 Classic) | 4 (+3 Classic; initial: Extrude & Bevel, Revolve, Inflate, Rotate, Extrude & Bevel (Classic), Revolve (Classic), Rotate (Classic)) | ~25% | 25–45 | | Beyond Illustrator: Effect › Color Adjustments (6), effect plug-ins (WebAssembly) | — | 6 + plug-ins | — | — | ## Illustrator effects @@ -23,12 +23,12 @@ Part of [target-app-parity.md](target-app-parity.md); open work is in [gaps.md]( | Convert to Shape | Rectangle, Rounded Rectangle, Ellipse | 3/3 | — | | Crop Marks | Crop Marks | 1/1 | — | | Distort & Transform | Free Distort, Pucker & Bloat, Roughen, Transform, Tweak, Twist, Zig Zag | 7/7 | Free Distort's dialog has a handle on each corner of the object's bounds, moved by dragging or with the arrow keys; Zig Zag's ridges are evenly spaced along each segment (#1558), and Smooth points make a continuous wave whose peaks and valleys have handles along the path (#2343); Roughen with Smooth keeps turn-backs smooth instead of cusps that draw as spikes (#1646); Expand Appearance of a path whose Transform effect makes copies gives a group of one object per copy, each painted as the path, and a second Transform effect's copies nest in a group per copy of the first (#5612); drawn, each copy of a path with a fill and a stroke (or several, an even-odd fill or a partly transparent one) paints below the one before, the fills above covering the strokes of the copies below, instead of one path of every copy (#5920), and a group's copies each hold all its members except guides, the original group on top (#6316); a clipping group, a group with a fill or stroke of its own, a group whose type is kept as type, and a group with a member that carries a geometry, Pathfinder or 3D effect copy each member in its place; Twist's handles follow the rotation's derivative, so a strongly twisted path is a smooth spiral without kinks where its pieces join (#7069, `twist_joins_its_pieces_smoothly`). | -| Path | Offset Path, Outline Object, Outline Stroke | 3/3 | With Use Preview Bounds on, Align, Distribute and the Transform panel still measure type that carries Outline Object by its layout box (preview bounds leave out effects) | +| Path | Offset Path, Outline Object, Outline Stroke | 3/3 | — | | Pathfinder | Add, Intersect, Exclude, Subtract, Minus Back, Divide, Trim, Merge, Crop, Outline, Hard Mix, Soft Mix, Trap | 13/13 | Trap traps only solid fills (gradients and patterns hide what is below them but don't trap) and spreads each colour's visible area as a whole; the public page gives no default values, so Trap's 0.25 pt, 100% and 40% are VectorCraft's own; each of the other Pathfinder effects keeps its own Precision, Remove Redundant Points and Divide and Outline Will Remove Unpainted Artwork, taken from Pathfinder Options when applied and edited in Pathfinder Options opened from its Appearance panel row ([Pathfinder effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/combine-objects-using-pathfinder-effects.html)) | | Rasterize | Rasterize… (as a live effect) | 1/1 | — | -| Stylize | Drop Shadow, Feather, Inner Glow, Outer Glow, Round Corners, Scribble | 6/6 | Scribble Options' Settings presets | +| Stylize | Drop Shadow, Feather, Inner Glow, Outer Glow, Round Corners, Scribble | 6/6 | — | | SVG Filters | Apply SVG Filter… and the filter list | 1/1 | The submenu lists 14 default filters and then the document's own; the public page names no default set, so the set, names and values are VectorCraft's own, and a default is copied into the document when it is applied or edited. A filter that is the object's last effect is written to SVG as a `` element; otherwise SVG export draws the object as an image. A filter on a turned, skewed or unevenly scaled object in an imported SVG is kept and runs in that object's user space, and SVG export writes it back under the same transform. A blur or drop shadow that blurs more in one direction than another in the document (two different standard deviations, or one in a skewed or unevenly scaled user space) is kept as this effect rather than opened as an even Gaussian Blur or Drop Shadow | -| Warp | Arc, Arc Lower, Arc Upper, Arch, Bulge, Shell Lower, Shell Upper, Flag, Wave, Fish, Rise, Fisheye, Inflate, Squeeze, Twist | 15/15 | warp point editing in envelopes; each style bends the bounds as one Bézier patch (`version` 1), so Arc's edges are cubic curves close to concentric arcs; warps saved without a version keep the earlier map, where Arc is a circular arc in the object's own proportions (#1578) | +| Warp | Arc, Arc Lower, Arc Upper, Arch, Bulge, Shell Lower, Shell Upper, Flag, Wave, Fish, Rise, Fisheye, Inflate, Squeeze, Twist | 15/15 | each style bends the bounds as one Bézier patch (`version` 1), so Arc's edges are cubic curves close to concentric arcs; warps saved without a version keep the earlier map, where Arc is a circular arc in the object's own proportions (#1578) | Document Raster Effects Settings exists. When the 64 million pixel cap on an effect image lowers its resolution, PDF export warns once per object with the requested and the lowest achieved ppi From 51f49815a4ff5dd4d5febd97f6214898e99a55b3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:40:37 -0800 Subject: [PATCH 175/264] Docs: hardware-parity.md matches what main ships - Summary: Windows reads the pen's tilt and barrel rotation with Windows Ink (#372). - Pen tilt row: Bristle brushes follow the recorded pen pose (#8490). - Touch gestures row: the Touch workspace ships (#3139); touch-screen rotation is still missing. - Multiple monitors row: floating panels (#4135) and floating document windows (#5278) are OS windows, and a floating panel reopens on the monitor where it was left (#6038); Wayland remains. - 3D GPU rendering row: 3D and Materials ship (#1453) and draw on the CPU, shaded or wireframe, with no ray tracing. No status line, revision-history row or score changes. --- docs/hardware-parity.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/hardware-parity.md b/docs/hardware-parity.md index 0c3a73b8cc..2f77e494bb 100644 --- a/docs/hardware-parity.md +++ b/docs/hardware-parity.md @@ -13,7 +13,7 @@ documentation (GPU Performance, touch workspace, pen pressure pages); ours from the GPU only to composite, so any GPU that can show a window works, at the cost of GPU-accelerated preview on huge documents. VectorCraft reads pen pressure on Windows, on the web, on macOS, and on Linux under X11 and XWayland, and it reads the pen's eraser end on Windows, on macOS, on Linux under X11 and XWayland, and on the web when it presses. -It reads the pen's tilt and barrel rotation on macOS and on Linux under X11 and XWayland. +It reads the pen's tilt and barrel rotation on Windows with Windows Ink (#372), on macOS and on Linux under X11 and XWayland. | Feature | Illustrator | VectorCraft macOS | Windows | Linux | Web | Status / hours | |---|---|---|---|---|---|---| @@ -22,14 +22,14 @@ It reads the pen's tilt and barrel rotation on macOS and on Linux under X11 and | Hybrid-graphics GPU choice | automatic | power-saving GPU by default, Preferences › Graphics Processor | same; DX12 then OpenGL; no Vulkan unless asked (#545, #806) | the desktop's GPU | browser | done | | Restart on another GPU when the first fails to present | — | yes (#502, #964) | yes | yes | restart on lost device (#369) | done | | Pen pressure | yes (Wacom, Windows Ink, macOS tablet events) | yes, read from AppKit's tablet events before the window gets them (winit reports none), each move of a stroke with its own pressure, mouse event coalescing off (#852; not yet tried on a Mac) | yes (pointer force via `WM_POINTER`) | under X11 and XWayland (Preferences › Performance › Linux Display Server, #1151, #2028; Automatic uses XWayland when a pen is attached on a Wayland session, #4967), read from XInput2 raw events (#764); **no** on native Wayland, where winit reports none and the pen may not reach the window (#491) | browser pointer events, with coalesced events; Apple Pencil on iPad (hover, palm rejection: fingers navigate after a pen contact until reload) | partial: 2–4 h for Wayland (winit 0.31), plus a check on a Mac | -| Pen tilt, bearing, barrel rotation (6D Art Pen) | yes, drives brushes | read from AppKit's tablet events (tilt, and the barrel rotation of a pen that reports one); Calligraphic and Scatter brushes vary with them (#764; not yet tried on a Mac) | with Windows Ink, read from the pen's `POINTER_PEN_INFO` (tilt and barrel rotation where its pen mask says the pen reports them); Calligraphic and Scatter brushes vary with them (#372; not yet tried with a pen) | under X11 and XWayland, read from XInput2 raw events; Calligraphic and Scatter brushes vary with them (#764); **no** on native Wayland | no | partial: native Wayland and the web read none, and Bristle brushes do not use them (an Art brush's Width and a Pattern brush's Scale follow them); 3–6 h (#372) | +| Pen tilt, bearing, barrel rotation (6D Art Pen) | yes, drives brushes | read from AppKit's tablet events (tilt, and the barrel rotation of a pen that reports one); Calligraphic and Scatter brushes vary with them (#764; not yet tried on a Mac) | with Windows Ink, read from the pen's `POINTER_PEN_INFO` (tilt and barrel rotation where its pen mask says the pen reports them); Calligraphic and Scatter brushes vary with them (#372; not yet tried with a pen) | under X11 and XWayland, read from XInput2 raw events; Calligraphic and Scatter brushes vary with them (#764); **no** on native Wayland | no | partial: native Wayland and the web read none (an Art brush's Width, a Pattern brush's Scale and Bristle brushes follow them, #8490); 3–6 h (#372) | | Pen eraser end | yes | the eraser end (AppKit's tablet proximity events) selects the Eraser tool and the tip brings back the tool used before, as on Linux (#852; not yet tried on a Mac) | with Windows Ink, an inverted pen or its eraser button (`PEN_FLAG_INVERTED`, `PEN_FLAG_ERASER` in the pen's pointer messages) selects the Eraser tool and the tip brings back the tool used before, as on Linux (not yet tried with a pen) | under X11 and XWayland, the eraser end selects the Eraser tool and the tip brings back the tool used before (#764); **no** on native Wayland | a press of the eraser end (Pointer Events eraser button, `button` 5) selects the Eraser tool, and that press erases; a press of the tip brings back the tool used before; Pointer Events report no end while the pen hovers | partial | -| Touch gestures (pinch zoom, two-finger pan, rotate view, Touch workspace) | yes (Windows touch, Surface) | trackpad pinch, scroll and rotate | pinch, pan (a second finger cancels the first finger's tool press, #4198); two-finger tap undo, three-finger redo (#585); in the Touch workspace a two-finger tap switches between the Selection tool and the last drawing tool | same where winit reports touch | eframe until the first pen contact, then Pointer Events (pen and fingers told apart); long press opens the context menu | partial: touch workspace and touch-screen rotation missing, 3–5 h | +| Touch gestures (pinch zoom, two-finger pan, rotate view, Touch workspace) | yes (Windows touch, Surface) | trackpad pinch, scroll and rotate | pinch, pan (a second finger cancels the first finger's tool press, #4198); two-finger tap undo, three-finger redo (#585); in the Touch workspace a two-finger tap switches between the Selection tool and the last drawing tool | same where winit reports touch | eframe until the first pen contact, then Pointer Events (pen and fingers told apart); long press opens the context menu | partial: touch-screen rotation missing (the Touch workspace ships, #3139), 3–5 h | | Trackpad (smooth scroll, pinch) | yes | yes | precision touchpads | yes | yes | done | | HiDPI / Retina, per-monitor scale | yes | yes | yes | yes | yes | done; a window dragged between monitors of different scale can still grow on Windows (#1459, open); the custom title bar's window on Windows stays truly borderless so the pointer lines up with what is drawn (#1791, #1758; awaiting the reporter's confirmation) ; macOS cursors use aligned 1×/2× native image representations (#2292), covered by headless construction tests; mixed-display transitions and physical cursor sizing remain unverified, no additional hardware validated | -| Multiple monitors: panels and document windows on another screen | yes | no (one OS window) | no | no | — | missing: 6–10 h (with multiple windows, gap G7) | +| Multiple monitors: panels and document windows on another screen | yes | yes: floating panels (#4135) and floating document windows (#5278) are OS windows, and a floating panel reopens on the monitor where it was left (#6038) | yes | under X11; on Wayland they are windows inside the main window | — | partial: Wayland remains, 6–10 h (with multiple windows, gap G7) | | Display colour profile (proof and display through the monitor's ICC) | yes | yes: the window is tagged sRGB and macOS converts it | yes: the display's default ICC profile, Windows' own conversion with Advanced Color on | X11: colord or `_ICC_PROFILE`; Wayland: sRGB | — | done on macOS, Windows and X11; Wayland and floating document windows remain | -| 3D GPU rendering (Materials, ray tracing) | yes | — | — | — | — | blocked on 3D (gap G3) | +| 3D GPU rendering (Materials, ray tracing) | yes | — | — | — | — | missing: 3D and Materials draw on the CPU, shaded or wireframe, with no ray tracing (#1453; gap G3) | ## Revision history From 47d067bfca55c63bfc601c7fd28a559596da50e6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:41:10 -0800 Subject: [PATCH 176/264] Docs: ui-parity.md matches what main ships The two duplicate Simplify rows are marked done: the slider opens at the Auto-Simplify level (#3750), and with part of a path direct-selected only the selected runs are simplified (#3814). The Actions panel row names New Action (#5270) and Action Options setting a function key that plays the action; editing actions remains. The dynamic symbols row adds gradient and pattern fills and strokes and the Transparency panel's opacity and blend for a picked part (#6308), and .ai editing data keeping dynamic symbols (#8747). --- docs/ui-parity.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 51af6698d5..d131053a67 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -243,8 +243,8 @@ tools, never checked side by side) isn't captured row by row. | Smooth (Object › Path › Smooth…: slider from minimum to maximum smoothing, Auto-Smooth) ([smooth slider](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/refine-path-segments-with-the-smooth-slider.html)) | done | #4115: the slider under the selection previews `object.path.smooth {level}`, Auto-Smooth picks level 50 and takes a shaky line to one smooth curve, direct-selected anchors smooth only their section, Enter or a click outside keeps one undo step and Escape restores; the smoothing rule beyond the two ends is VectorCraft's own (`tests/smooth_path.rs`, `smooth_slider_previews_auto_smooth_and_keeps_the_result`) | | Draw Inside in isolation mode: art drawn or pasted inside the isolated object takes isolation mode into its clip group, clickable and undimmed ([isolation mode](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/isolate-objects.html), [drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) | done | #3705; `drawing_inside_an_isolated_object_keeps_the_new_art_in_isolation_mode` | | Draw Inside marks the object it draws into: a dotted open rectangle round its corners, in its layer's colour, while the mode lasts, selected or not | done | #4319, `canvas::tests::draw_inside_marks_the_corners_of_its_object` ([drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) | -| Simplify (slider, auto, corner angle threshold) | partial | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, and the dialog's option to open it directly with its last settings; the slider opens at 1 pt rather than at the Auto-Simplify level, and simplifying only a Direct Selection part of a path remains missing | -| Simplify (slider, auto, corner angle threshold) | partial | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, opening at the Auto-Simplify level for the selection with that result previewed, and the dialog's option to open it directly with its last settings; simplifying only a Direct Selection part of a path remains missing | +| Simplify (slider, auto, corner angle threshold) | done | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, and the dialog's option to open it directly with its last settings; the slider opens at the Auto-Simplify level (#3750), and with part of a path direct-selected only the selected runs are simplified (#3814) | +| Simplify (slider, auto, corner angle threshold) | partial | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, opening at the Auto-Simplify level for the selection with that result previewed, and the dialog's option to open it directly with its last settings; with part of a path direct-selected, only the selected runs are simplified (#3814) | ## Direct Selection, anchors and handles @@ -500,7 +500,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Actions panel: ≡ › Action Options… renames the selected action and sets its function key and color ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | partial | `ui.action.options`; `panels/actions.rs` tests (part of #1629). Button Mode shows the color | | Actions panel: ≡ › Button Mode shows each action by name as a button in its Action Options color, without sets or steps; a click on a button plays the action, and choosing Button Mode again shows the list ([the help page](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | done | `ui.action.buttonMode`, `ui.action.playAt`; `panels/actions.rs` tests. VectorCraft's own rules: every set's actions show in set order, an action without a color is an ordinary button, the mode is kept with the UI preferences, and it cannot be turned on while an action records | | Actions panel: ≡ › Playback Options… plays actions Accelerated, Step by Step or with a pause between steps ([Specify playback speed](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/specify-playback-speed.html)) | done | `ui.action.playbackOptions`; `panels/actions.rs` tests. The pause is a whole number of seconds from 1 to 60 (VectorCraft's own range); Batch… plays at full speed | -| Actions panel: a clicked action stays selected for Play Current Selection and Delete Selection | partial | #1853 (part of #1629); editing actions and action shortcuts remain | +| Actions panel: a clicked action stays selected for Play Current Selection and Delete Selection | partial | #1853 (part of #1629); editing actions remains; New Action (#5270) and Action Options set a function key that plays the action | | Actions panel: Create New Set (bottom bar, ≡ › New Set…) names a new set and Set Options… renames the current one; a click on a set's name makes it current and a recording goes into the current set ([helpx: Automation with actions](https://helpx.adobe.com/illustrator/using/automation-actions.html)); the current set is kept with the UI preferences, and with no set current a recording goes into the first set, which becomes current | partial | #3712; dragging actions between sets remains | | Actions panel: Create New Action (bottom bar, ≡ › New Action…) asks for the name, set, function key and color, and Record adds the action and records into it ([Create new actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/record-actions.html)) | partial | `ui.action.new`, `ui.action.play`; `panels/actions.rs` tests. A function key plays its action, even when a command has the same shortcut, and the command keeps it. Button Mode shows the color | | Actions panel: Delete Selection (bottom bar) deletes the selected set with its actions and keeps the other sets ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | partial | `ui.actionSet.delete`; `panels/actions.rs` tests. VectorCraft's own rules, which the overview does not cover: deleting a set asks first (a selected action is still deleted at once), Shift-click on a set's name selects a range of sets, ≡ › Delete does the same as the button, and Default Actions and the last set can be deleted. Undo does not restore a deleted set, and recorded commands cannot be selected or deleted | @@ -523,7 +523,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Brush libraries: Window › Brush Libraries (Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive, Bristle Brushes, Pattern Borders, Decorative, Scatter Shapes, Stipple, Game Trails, Energy Beams, Dry Media, Tech Circuit, Engraving, Arrows, User Defined, Other Library…, Save Brushes…) and the Brushes panel's Brush Libraries Menu button and its menu's Open Brush Library / Save Brush Library…; a click on a library brush adds it to the document's Brushes (one undo step, it becomes the current brush, and selected paths take it in the same step), Shift/Cmd-clicks select for Add to Brushes, a brush dragged onto a path is added and applied to it and one dragged onto the Brushes panel is added; thumbnails render with the library's patterns and symbols | done | [public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html), [Brushes panel overview](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html); `window.brushLibrary`, `window.brushLibrary.other`, `ui.saveBrushLibrary` (dialog `saveBrushLibrary`), `window.userBrushLibrary1`…`10`; `panels::tests_brush_libraries`; fifteen built-in libraries (original, generated in code) | | Brushes panel menu › Options of Selected Object…: changes the selected brushed paths' brush settings on those paths only, leaving the brush and its other strokes as they are; the brush type's options dialog opens without the Name row (and without an art brush's scale and direction options or a pattern brush's tiles), and OK sends only the values changed in it | done | [Modify brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/modify-brushes.html), [Brushes panel overview](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html); `brush.objectOptions`, `ui.brushObjectOptions`; which fields a path can set is VectorCraft's own choice (calligraphic, scatter, art and pattern brushes; not bristle); `options_of_selected_object_*` tests in `crates/engine/src/tests/brushsym.rs` and `crates/ui-egui/src/dialogs/brush_options/tests.rs`, brush tests in `crates/brush/src/tests.rs` | | Symbols panel: New Symbol opens Symbol Options (Name) before making the symbol; Alt-click skips it | partial | #1560 (#1566); Registration 9-point grid in Symbol Options (`symbol.new` / `symbol.place`); Export Type (Graphic / Movie Clip) and Enable Guides for 9-Slice Scaling (scaled instances keep their corners; in symbol editing mode the guides are drawn over the art and the Selection tool drags them); Symbol Type (Dynamic Symbol / Static Symbol, new symbols dynamic; #4938); Align to Pixel Grid (`alignToPixelGrid` on `symbol.new` / `symbol.options`: the art snaps at the symbol's natural size and instances at that size stay on whole points; [Aligning symbols to pixel grid](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=28)) | -| Dynamic symbols: an instance changes the fill, stroke, opacity and blend of objects in its symbol's art and stays linked; Reset in the Properties panel's Quick Actions and the Symbols panel menu (Reset Symbol Instance) | partial | #4938; `symbol.instance.setAppearance` (by child-index path) and `symbol.instance.reset`; redefining keeps the changes, Break Link bakes them; Direct Selection of a path, compound path or type object inside an instance, with the Fill/Stroke controls setting its solid fill or stroke, is on canvas; on-canvas editing beyond a solid fill and stroke, and `.ai` read and write, remain | +| Dynamic symbols: an instance changes the fill, stroke, opacity and blend of objects in its symbol's art and stays linked; Reset in the Properties panel's Quick Actions and the Symbols panel menu (Reset Symbol Instance) | partial | #4938; `symbol.instance.setAppearance` (by child-index path) and `symbol.instance.reset`; redefining keeps the changes, Break Link bakes them; Direct Selection of a path, compound path or type object inside an instance, with the Fill/Stroke controls setting its fill or stroke (solid, gradient or pattern) and the Transparency panel setting its opacity and blend, is on canvas (#6308); `.ai` editing data keeps dynamic symbols and their instance changes when VectorCraft writes and reads it (#8747); on-canvas editing beyond fill, stroke, opacity and blend, and reading other apps' dynamic symbol records, remain | | Pathfinder Trim, Merge and Crop remove strokes; Merge joins same-fill objects whatever their strokes | done | #1570 (#1572) | | Pathfinder panel on one group selected alone; a greyed-out button says what it needs | partial | #1450; the group's members are combined; one plain path selected alone stays disabled (the public documentation doesn't say what the operations do to a single path) | | Pathfinder Divide: an open cutting line splits a filled path | done | #1307; straight, crossed, bent and curved cutters, holes and frontmost appearance regression-tested; native automation: independent piece movement, one Undo/Redo, saved-document round trip and window capture; existing bounded-map fallback remains | From c8c434f4aac929074c514c87826c82ec0a5934a2 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 03:42:50 +0100 Subject: [PATCH 177/264] Compile macOS release architectures on separate standard runners --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 538d09cc31..ea3bf92583 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,7 @@ jobs: app-name: vectorcraft app-title: VectorCraft macos-runner: macos-15 + macos-split-build: true craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 web-craft-fonts: true version: ${{ inputs.version }} From 059946687aff86d62e1148059b6a2012065c0d24 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:44:10 -0800 Subject: [PATCH 178/264] Docs: target-app-parity.md matches what main ships Lines that listed shipped features as remaining now name the pull request that built them: Touch Type (#2469), the Dimension tool (#1788), the freehand Keep selected (#2246), Alt to the Smooth tool (#2685), Blob Brush Merge Only with Selection (#2367), Live Corners' Relative rounding (#3091), Global Edit of similar groups (#4983), Consolidate All Windows (#5216), Select All across threaded frames (#5542), the Bullets and Numbering dialog and list levels (#5037), Convert to Text (#4093), the spelling dialogs (#6341, #6425, #7744), Retype's installed-font search (#8823), Retype in Quick Actions (#8778) and Cursor Swatch Preview (#7265). The #1758 entry records the reporter's confirmation. Scores, status lines and revision-history rows are unchanged. --- docs/target-app-parity.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 395fdda4de..4df379b998 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -347,7 +347,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Area | Weight | Done | Main gaps | One agent (h) | Kind | |---|---:|---:|---|---:|---| | Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); deletion splits an ordinary contour into selected sibling objects with bounds-fitted gradients kept in place (#3380, deletion only; `crates/engine/tests/it/delete_path_pieces.rs`); open-path anchor Delete keeps gaps; Select › Start Global Edit finds the paths, compound paths and symbol instances of the selected object's shape (Appearance, Size and artboard options) and gives an edit of one to all of them in proportion, as one undo step (#3521), and on a group the groups like it, an edit inside one reaching the same object in the others (#4939), and a Shift-click on a highlighted match leaves it out; the Align panel menu's Align to Glyph Bounds › Point Text and Area Text measure type by its glyphs' ink for Align and Distribute (#4231); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of rotated copies, transform nuances (no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | estimated; fill-stack selection regression-tested (`crates/engine/tests/path_fill_hits.rs`, #6625); cap/join follow-up CPU regressions passed; Global Edit regression-tested (`crates/engine/src/tests/globaledit.rs`; Quick Action, menu label and Escape in `panels::properties::tests::start_global_edit_quick_action_and_escape`) | -| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options, Touch Type, Dimension tool; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged; Scissors shares the Pen's path/align/intersect/anchor snaps (#6470), source and headless regressions below; Eraser preserves fill-only open-path area outside fixed and varied tip sweeps and Alt-drag marquees, including compound holes; clipping masks keep their remaining contours and empty-mask role; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior and result structure (#6582; `crates/engine/tests/eraser_open_fill.rs`), score and hours unchanged; Scissors cut-point preview covered in tool and Session regressions (#8655), scores and hours unchanged | +| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options; Touch Type (#2469) and the Dimension tool (#1788) are done; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged; Scissors shares the Pen's path/align/intersect/anchor snaps (#6470), source and headless regressions below; Eraser preserves fill-only open-path area outside fixed and varied tip sweeps and Alt-drag marquees, including compound holes; clipping masks keep their remaining contours and empty-mask role; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior and result structure (#6582; `crates/engine/tests/eraser_open_fill.rs`), score and hours unchanged; Scissors cut-point preview covered in tool and Session regressions (#8655), scores and hours unchanged | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 80% | Shape Builder on the reporter's file (#937: art past 4,096 segments is cut by lines again; unconfirmed on the file itself); gap detection shares Live Paint’s finder, with a 72 pt custom cap and the existing options; Live Paint Gap Options | 4–8 | estimated; Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog (lowered from 86%: open issues); compound attributes regression-tested (#1197); single-result source names survive SVG export/import (#1293), with [SVG ID semantics](https://www.w3.org/TR/SVG2/struct.html#IDAttribute) and original-shape tests; Simplify component selection and preview regression-tested (#1272); Simplify of a Direct Selection part of a path regression-tested (`tests/simplify_part.rs`); Divide open-cutting-path geometry and appearance regression-tested (#1307); the Shape Builder's edge-source grid is bounded in memory and files a segment once per cell (`planar.rs` test `rect_index_holds_a_bounded_number_of_references`); live compound shapes (Make, Alt-click, member Shape Modes, Release, Expand, saved and exported) regression-tested (#4522); Live Paint Bucket face drags, including narrow faces and one Undo, regression-tested (#6373) | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | Picker Lab entry, picker libraries and Assign-row menus complete the deferred #4028 UI paths (#8031); scores and estimates unchanged; Eyedropper copies effective character dimensions across text transforms (#6404); 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors| 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged; a point on a gradient mesh's outline locates on its edge on every side (#7006: `mesh_locate_takes_a_point_on_any_side_of_the_outline`, `mesh_add_line_exactly_on_the_edge_needs_no_tolerance`), score and hours unchanged; Color panel spectrum grows with the resized panel (#8005); the Color Wheel panel's Show Opacity sets the opacity of the fill, stroke, gradient stop or freeform point it edits (part of #978), score and hours unchanged; gradient stop editor color-mode menu (#7918) | | Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) | @@ -616,9 +616,9 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale) | Area | Weight | Done | Missing (main items) | One agent (h) | |---|---:|---:|---|---:| | Selection, transform & align tools | 6 | 85% | Free Transform/Scale/Reflect along a rotated box, Global Edit of similar groups, transform nuances (the rotated persistent bounding box is done) | 4–6 | -| Drawing tools | 7 | 85% | rough-square Shaper recognition and orientation steps corrected; editable Shaper Groups landed; remaining: Shaper construction widget/gesture refinements, pencil and the remaining pen modifier nuances, the freehand Tool Options' Keep selected, Alt to the Smooth tool, Blob Brush Merge Only with Selection, Touch Type, Live Corners' Relative rounding (Curvature point display improved, #1236 in part) | 8–13 | +| Drawing tools | 7 | 85% | rough-square Shaper recognition and orientation steps corrected; editable Shaper Groups landed; the freehand Tool Options' Keep selected (#2246), Alt to the Smooth tool (#2685), Blob Brush Merge Only with Selection (#2367), Touch Type (#2469) and Live Corners' Relative rounding (#3091) are done; remaining: Shaper construction widget/gesture refinements, pencil and the remaining pen modifier nuances (Curvature point display improved, #1236 in part) | 8–13 | | Selection, transform & align tools | 6 | 85% | Free Transform/Scale/Reflect along a rotated box, Global Edit of similar groups, transform nuances (the rotated persistent bounding box is done; no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | -| Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of similar groups, transform nuances (the rotated persistent bounding box is done) | 4–6 | +| Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); remaining: Free Transform/Scale/Reflect along a rotated box, transform nuances (the rotated persistent bounding box and Global Edit of similar groups, #4983, are done) | 4–6 | | Drawing tools | 7 | 86% | Eraser preserves fill when cutting fill-only open paths with fixed or varied tips or Alt-drag marquees; painted-stroke paths retain main behavior and clipping masks keep their remaining contours or empty geometry, with reproducible evaluated gradient placement preserved on ordinary paths, compounds, groups and layers (#6582); replacement-art effects, plug-ins/Rasterize, along/across strokes and placements that cannot be reproduced retain fitting; rough-square Shaper recognition and orientation steps corrected; editable Shaper Groups landed; Pencil: Alt key toggles to Smooth Tool (#2001); remaining: Shaper construction widget/gesture refinements, pencil and the remaining pen modifier nuances, Blob Brush Merge Only with Selection, Touch Type, Live Corners' Relative rounding | 7–12 | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 86% | Live Paint gap options, Shape Builder gap detection, options (Tool Options dialog, clicking a stroke in merge mode) and Shift-drag marquee | 3–6 | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 96% | Picker Lab entry, picker libraries and Assign-row menus complete the deferred #4028 UI paths (#8031); scores and estimates unchanged; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); freeform gradients in SVG/PDF and mixed spot/process gradients in SVG (exported as stops; PDF export keeps the spot inks in a DeviceN shading, except next to RGB or Lab stops; dithered fills and Perceptual gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve are written as images in process colors), pattern fills in Expand | 2–4; Eyedropper source reads regression-tested (#1251) | @@ -640,8 +640,8 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale) | Export for Screens, Asset Export, slices, Save for Web | 3 | 85% | polish only (all four are done) | 2–4 | | Print, colour management, separations, flattener | 3 | 80% | Production Preflight available; print preview fidelity remains (flattener presets in PDF and print, overprint in PDF and composite print, Print dialog, presets, PostScript, marks, separations, Print Tiling, print overprint/flattener/bitmap options and printer profile are done, as are the Japanese papers in its Media list: JIS B4/B5/B6, はがき, 往復はがき, 封筒 長形3号/長形4号/角形2号/角形3号 and 四六判, beside the ISO B4/B5 that settings saved before them keep) | 1–2 | | Automation | 3 | 65% | scripting surface, batch (MCP drops malformed app replies without replay; Variables: text/visibility variables bound to objects, an object may carry several, dataset rows applied in one undo step, panel and Window › Variables with dialogs; image/graph kinds and dataset import/export open) | 6–10 | -| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 80% | macOS native menu dismissal fixed (M14.8); Variables, Links, Asset Export, CSS Properties, Attributes, the canvas context menu and docking panels into any dock group by dragging (as tabs, a top/bottom split or icons) are done; remaining: Properties per context, Consolidate All Windows, floating panels outside the app window, context menus in the panels that have none, about 13 Preferences options stored but not yet acted on (#394: Open Documents As Tabs, Real-time Drawing, hyphenation language, devices…) | 13–20 | -| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 80% | macOS native menu dismissal fixed (M14.8); Variables, Links, Asset Export, CSS Properties, Attributes, the canvas context menu and docking panels into any dock group by dragging (as tabs, a top/bottom split or icons) are done; remaining: Properties per context, Consolidate All Windows, floating panels outside the app window, context menus in the panels that have none, about 14 Preferences options stored but not yet acted on (#394: Highlight Alternate Glyphs, Open Documents As Tabs, Real-time Drawing, hyphenation language, devices…) | 13–20 | +| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 80% | macOS native menu dismissal fixed (M14.8); Variables, Links, Asset Export, CSS Properties, Attributes, the canvas context menu, Consolidate All Windows (#5216) and docking panels into any dock group by dragging (as tabs, a top/bottom split or icons) are done; remaining: Properties per context, floating panels outside the app window, context menus in the panels that have none, about 13 Preferences options stored but not yet acted on (#394: Open Documents As Tabs, Real-time Drawing, hyphenation language, devices…) | 13–20 | +| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 80% | macOS native menu dismissal fixed (M14.8); Variables, Links, Asset Export, CSS Properties, Attributes, the canvas context menu, Consolidate All Windows (#5216) and docking panels into any dock group by dragging (as tabs, a top/bottom split or icons) are done; remaining: Properties per context, floating panels outside the app window, context menus in the panels that have none, about 14 Preferences options stored but not yet acted on (#394: Highlight Alternate Glyphs, Open Documents As Tabs, Real-time Drawing, hyphenation language, devices…) | 13–20 | | Libraries, Links, Package | 2 | 82% | the Libraries panel is local only (no cloud by design: libraries are files on this machine) and has no shared libraries, linked graphics or gradients and patterns as items yet; its graphics, colours and text styles (#745), its search, groups and library export/import as `.vclibrary` files (#926), a list that scrolls, with items and groups reordered by dragging and items dragged into and out of groups, art and swatches dragged in added where they are dropped, and items shown as icons or in a list with their names, are done; Links and Package are done; placed VectorCraft documents are done (linked by default, vectors in every output, previews, Break Link, Expand, Edit Original, refresh on save) | 2–3 | | **Feature parity** | **103** | **~75%** | | **~210–330** | | Interaction-fidelity pass (side by side with Illustrator: every tool modifier, cursor, dialog, Properties context) | | | | 60–90 | @@ -1474,7 +1474,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - While Tab or Shift+Tab hides the panels, the Window menu checks no panel, and choosing a panel there, or pressing its function key, shows the dock with that panel in its earlier place instead of closing it; the toolbar and the Control bar stay as they are. In Presentation Mode no panel is checked, and `window.panel` fails and changes nothing. A tool double-click that opens the Gradient or Magic Wand panel and a Character field shortcut also show the hidden dock (`window_panel_from_tab_hidden_dock_reveals_named_front_tab`, `window_panel_from_shift_tab_hidden_floating_window_reveals_it`, `function_key_from_tab_hidden_dock_reveals_named_group`, `presentation_panel_command_reports_unavailable_without_mutating_layout`). - The function key shortcuts for Brushes, Color, Layers, Info, Gradient, Stroke, Attributes, Graphic Styles, Appearance, Align, Transform, Pathfinder, Transparency, and Symbols activate a background tab on the first press, hide its expanded dock or floating group when that tab is in front, and restore the group with all its tabs together on the next press; in an icon column they open and close the flyout while keeping the icons. A reassigned chord keeps that behavior, and Window > a hidden sibling restores the group. - On Windows and Linux, F2, F3 and F4 run Cut, Copy and Paste alongside Ctrl+X, Ctrl+C and Ctrl+V, and in the web build they do so everywhere except macOS. The Edit menu keeps the Ctrl shortcuts, and Keyboard Shortcuts lists both keys of each row. On macOS only Cmd+X, Cmd+C and Cmd+V are the defaults. F2, F3 and F4 do not run these commands in a focused text field or while the Type tool edits text. A saved shortcut set that assigns one of these keys to another command keeps that assignment. Public reference: [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html). - - Cmd/Ctrl+A follows the keyboard: in a panel, dialog or search field it selects the field's text, while the Type tool edits it selects all of that text (also `select.all` over MCP), and only otherwise every object. On macOS the menu bar's Select All, Cut, Copy and Paste (keys or clicks) act on a focused field too, and elsewhere the in-window menus' do: the field that had the keyboard when the menu opened gets them, with its selection, and the keyboard back (#516). Not yet: Select All across threaded frames (one frame's text is selected). + - Cmd/Ctrl+A follows the keyboard: in a panel, dialog or search field it selects the field's text, while the Type tool edits it selects all of that text (also `select.all` over MCP), and only otherwise every object. On macOS the menu bar's Select All, Cut, Copy and Paste (keys or clicks) act on a focused field too, and elsewhere the in-window menus' do: the field that had the keyboard when the menu opened gets them, with its selection, and the keyboard back (#516). In a frame of threaded text, Select All selects the whole story (#5542). - Cmd/Ctrl+A follows the keyboard: in a panel, dialog or search field it selects the field's text, while the Type tool edits it selects all of that text (also `select.all` over MCP), and only otherwise every object. On macOS the menu bar's Select All, Cut, Copy and Paste (keys or clicks) act on a focused field too, and elsewhere the in-window menus' do: the field that had the keyboard when the menu opened gets them, with its selection, and the keyboard back (#516). In a frame of threaded text, Select All selects the whole story, highlighted in every frame: Copy and Cut take all of it, typing or Delete replaces it as one undo step, and a fill, a size step or a Character or Paragraph panel change applies to every frame's text (VectorCraft's own behavior; `textedit::select_all_in_a_threaded_frame_selects_the_whole_story`, `textedit::typing_over_the_whole_story_replaces_every_frames_text_in_one_step`). - With text selected in a panel's label, such as a Document Info value, Cmd/Ctrl+C and Cmd/Ctrl+X copy that text and do not copy or cut the art, and so do F3 and F2 where they are Copy and Cut, any other keys assigned to Copy or Cut, and the menu bar's Copy and Cut on macOS. When the selected label is not drawn (the panels are hidden), Copy and Cut act on the art instead (#8432; VectorCraft's own behavior; `selectall::copy_and_cut_copy_the_text_selected_in_a_panel_label`, `selectall::copy_sent_on_from_another_window_copies_the_text_only_when_it_is_this_windows`, `selectall::panel_text_copied_before_the_art_formats_are_written_stays_on_the_clipboard`, `shortcuts::tests::a_window_notes_only_its_labels_copies_until_the_next_main_window_pass`, `shortcuts::tests::a_window_notes_a_copy_of_text_dragged_across_its_label`). Not yet: the in-window Edit menu's Copy and Cut (the click on the menu clears the label's selection first), and, while the selected text is in a floating panel's own window, the menu bar's Copy and Cut, and F3 and F2 (they do not copy the text). - With the whole story of threaded text selected by Select All, Remove Line Breaks, Remove Paragraph Breaks and Type › Bullets and Numbering › Convert to Text act on the text of every frame as one undo step, locked and hidden frames included, and the story stays selected after Convert to Text; a selection inside one frame changes only that frame (VectorCraft's own behavior; `textedit::remove_breaks_takes_the_whole_story_that_select_all_selected`, `textedit::convert_to_text_takes_the_whole_story_that_select_all_selected`, `textedit::convert_to_text_of_the_whole_story_converts_locked_and_hidden_frames`, `textedit::remove_breaks_of_the_whole_story_takes_locked_and_hidden_frames`). @@ -1984,7 +1984,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Paint-only Arabic harakat (marks whose character styles differ only in fill, stroke and related paint) stay inside one shaping cluster so letters keep their joining forms; when a second character-level shaping pass matches the monotone glyphs, a glyph may take a later in-cluster character's run only when GDEF classifies it as a mark (class 3) and that character is a harakat; otherwise it keeps the shaping cluster's first character. Insert Kashidas tatweels take the base letter's paint rather than a trailing mark's. Fonts without GDEF and some AAT/`morx` ligatures can leave a mark painted as its letter (`crates/text/src/tests/harakat.rs`). Character panel › Adjust Horizontal and Adjust Vertical Diacritic Position (with the Middle Eastern options; `text.setFormat` or `text.setRangeStyle {diacriticHorizontal, diacriticVertical}`, VectorCraft's own thousandths of an em from -1000 to 1000, 0 by default) move the selected characters' mark glyphs (GDEF class 3) right or left and up or down while the letters stay in place ([the reference, page 549](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=549)); an Arabic harakat or Hebrew point styled apart takes its own values, character styles carry both (Character Style Options › Advanced Character Formats edits them), the canvas and PDF draw the moved marks and SVG writes such type as outlines (`tests::harakat::diacritic_positions_move_marks_and_keep_letters`). The Paragraph panel's Bullets button, Type › Bullets and Numbering › Apply Bullets and the context menu's Apply Bullets (`text.setFormat {list, bullet}`, `type.applyBullets`) make paragraphs a bulleted list with the documented presets (none, filled dot, dash, hollow circle, filled square; [Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html)): the bullet starts each paragraph's first line in its first character's font, size and color, the first line's text starts at the next tab stop after the bullet (the left indent counts as a stop), the lines it wraps to start at the left indent, a paragraph with no indents gets 18 pt and -18 pt, and Return continues the list; Reset Panel turns it off, and paragraph styles and the native file keep it. - The Paragraph panel's Bullets button, Type › Bullets and Numbering › Apply Bullets and the context menu's Apply Bullets (`text.setFormat {list, bullet}`, `type.applyBullets`) make paragraphs a bulleted list with the documented presets (none, filled dot, dash, hollow circle, filled square; [Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html)): the bullet starts each paragraph's first line in its first character's font, size and color, the first line's text starts at the next tab stop after the bullet (the left indent counts as a stop), the lines it wraps to start at the left indent, a paragraph with no indents gets 18 pt and -18 pt, and Return continues the list; Reset Panel turns it off, and paragraph styles and the native file keep it. The Bullets and Numbering dialog, levels and Convert to Text are not built yet. + The Paragraph panel's Bullets button, Type › Bullets and Numbering › Apply Bullets and the context menu's Apply Bullets (`text.setFormat {list, bullet}`, `type.applyBullets`) make paragraphs a bulleted list with the documented presets (none, filled dot, dash, hollow circle, filled square; [Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html)): the bullet starts each paragraph's first line in its first character's font, size and color, the first line's text starts at the next tab stop after the bullet (the left indent counts as a stop), the lines it wraps to start at the left indent, a paragraph with no indents gets 18 pt and -18 pt, and Return continues the list; Reset Panel turns it off, and paragraph styles and the native file keep it. The Bullets and Numbering dialog and list levels (#5037) and Convert to Text (#4093) are built too. The Paragraph panel's Numbered List button, Type › Bullets and Numbering › Apply Numbers and the context menu's Apply Numbers (`text.setFormat {list, number}`, `type.applyNumbers`) make paragraphs a numbered list with the documented presets (1, A, a, I, i, 01, 001, and None, which turns the list off; [Bullets and numbering](https://web.archive.org/web/20250807202418/https://helpx.adobe.com/illustrator/using/bullets-numbering.html), [Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html)): each paragraph starts with its number and a period, counted through the list paragraphs of the story and its threaded frames, with the text and indents as in a bulleted list; letters go on from Z to AA, and roman numerals go on from III to IV, an empty paragraph is not numbered, and a paragraph in no list starts the count again at 1. More Options in the Bullets and Numbered List presets (`ui.bulletsAndNumbering`) opens the Bullets and Numbering dialog ([Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html)): a Bullets tab and a Numbers tab with the presets, and the Position group's Alignment, Left Indent and First Line Indent, shown on the type while the dialog is open; OK applies them with `text.setFormat` (Alignment is its `listAlign`) as one undo step, and Cancel puts the type back. Alignment Left starts the marker at the first line's start, and Right ends it where the text starts. The cited page does not say where the marker sits for each choice, so these meanings are VectorCraft's own rule. Paragraph styles and the native file keep the alignment. Tab and Shift+Tab with the caret at the start of a list paragraph (`text.setFormat {listLevel}`), and the Bullets and Numbering dialog's Level field (OK sends it as `listLevel`), move the paragraph down and up the list's nine levels ([Create bulleted or numbered lists](https://web.archive.org/web/20260417034638/https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/create-bulleted-or-numbered-lists.html), [Bullets and numbering](https://web.archive.org/web/20250807202418/https://helpx.adobe.com/illustrator/using/bullets-numbering.html)): each level past the first sets the paragraph 18 pt further in, each level counts its own numbers from 1, and a paragraph back at a shallower level goes on with that level's count, through threaded frames too. Elsewhere Tab inserts a tab as before; one Undo takes a level change back, and paragraph styles and the native file keep the level. Convert to Text writes each level's numbers and keeps a deeper paragraph's indent. @@ -2643,7 +2643,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Files and untrusted input, 2026-10-14 merges: EPS import: a stitched shading keeps its hard colour changes (#1654, #1653). WMF/EMF import refuses an oversized embedded PNG or JPEG from its header, before any pixels are decoded (#1776). PDF open no longer takes exponential time on a crafted name tree with shared nodes when it looks for the editing data (#1781). The size limits on a native file's embedded data also apply to files read from memory, not only streamed ones (#1783). Saving over a private file on Unix no longer leaves a readable temporary copy beside it while the file is written (#1778). An Export for Screens suffix can no longer place files outside the export folder (#1777). Package refuses a folder where it would overwrite the open document or one of its linked files (#1786). ruzstd 0.9.1 fixes a decompression bomb (RUSTSEC-2026-0344) reachable from EPS/`.ai` and Affinity import (#1807). File Info dates are stamped only after a save succeeds, so a failed save no longer changes them (#1774). Linked files that change during a drag are updated after the drag instead of being missed (#1773). - EPS import: `readhexstring` and `readline` read the data left in a file in one pass instead of one byte per call, with the same bytes, result and next unread byte as before (about nine times less reader time on 6 MB of hex image data and on 8 MB of lines). - EPS import: `token` on a string, `search` and `anchorsearch` read their strings in place instead of copying the rest of the string on each call, with the same results, errors and operation count as before. Walking a 512 KiB string by what each call leaves takes 16 ms instead of 518 ms with `token` and 1.0 ms instead of 27 ms with `search`, and a 64 KiB string 2.2 ms instead of 10 ms with `token`; on a 4 KiB string the difference is under 0.1 ms (release build on Linux under load from other builds, median of 7 alternating runs, `cargo test --release -p vectorcraft-eps --lib tests_strings::string_walks_timed -- --ignored --nocapture`). -- **Fields, search and window, 2026-10-14 merges:** Fields commit what was typed when you click away or move to another field, as Enter does; Escape still discards it (#1787). Up and Down move through the command search results and Enter runs the highlighted one (#1798, #1757). Slider rails show on Medium Dark (#1808, #1662). On Windows the custom title bar's window stays truly borderless, so the pointer lines up with what is drawn on systems where the hidden caption offset it (#1791, #1758; awaiting the reporter's confirmation). +- **Fields, search and window, 2026-10-14 merges:** Fields commit what was typed when you click away or move to another field, as Enter does; Escape still discards it (#1787). Up and Down move through the command search results and Enter runs the highlighted one (#1798, #1757). Slider rails show on Medium Dark (#1808, #1662). On Windows the custom title bar's window stays truly borderless, so the pointer lines up with what is drawn on systems where the hidden caption offset it (#1791, #1758; the reporter confirmed it on 0.11.0). - **Tools, panels and type, later 2026-10-14 merges:** the Transform panel's, Properties panel's and Control bar's X, Y, W and H show and edit the bounds of the anchor points selected with Direct Selection, and a whole-object selection is unchanged (#1839, fixes #1824). With Snap to Grid on, anchors and objects snap to the grid even when Snap to Pixel is also ticked: the grid wins (#1840; #1816 stays open until the reporter confirms). A marquee with the Selection or Direct Selection tool also selects the unlocked ruler guides it crosses (#1836). The toolbar shows no group labels by default (a preference brings them back) and runs on in one or two columns; the All Tools drawer lists the tools by flyout group with their shortcuts, has a menu (Reset, Basic, Advanced) and a Show section for the Fill/Stroke, Coloring, Draw Mode and Screen Mode controls (`toolbar.show`, #1751). An action clicked in the Actions panel stays selected, so Play Current Selection and Delete Selection act on it (#1853, part of #1629; editing actions and action shortcuts remain). Redo pressed during a drag keeps the drag as a step instead of losing the redone edit (#1856, #1719). Preferences are written as soon as OK is pressed, so they survive a session that doesn't end with a normal quit (#1857; #1747 stays open until the reporter confirms). New and Redefine Character Style take the format of the selected text range, also while typing (#1634). Type inside symbols, pattern tiles, graph designs and opacity masks gets its layout bounds back when a native file opens, so warped type in a symbol looks the same after save and reopen (#1833, #1738). Editing, renaming, deleting or merging a global swatch reaches the art of opacity masks, and a swatch used only in a mask is no longer listed as unused (#1830, #1735). On macOS, Save As, Save a Copy and the first Save show their sheet again; the Format menu on the sheet (#866) is withdrawn until the format can be set before the sheet opens, and #866 is open again (#1855; #1800, #1831 and #1518 stay open until confirmed on a Mac). - **Files and untrusted input, later 2026-10-14 merges:** SVG import applies style sheet rules with `:not()` selectors, with their nesting bounded (#1799, #1557), no longer stalls on a style sheet with many stacked descendant selectors over deep nesting (#1834, #1703), and reads an SVG's linked files within the automation roots in force again (#1870). DXF export writes the VPORT record's view direction once (group code 36 was written twice, which strict readers reject, #1789). A deeply nested file no longer overflows the stack: nesting is capped at 32 objects (deeper groups are merged with a warning; SVG past 256 elements and PDF past 256 nested arrays are refused), symbols and patterns that use themselves open without the offending instance or paint, and a document nested more than about 40 deep can no longer be saved to a file that won't open again (#1852). PDF and `.ai` files nested deeply inside compressed streams, page trees holding themselves and functions or colour spaces built on themselves no longer crash the app (hayro 0.8; the import runs on a 16 MB thread, #1871); a decompression bomb or impossible predictor parameters are refused (#1873, #1700, #1701); a brush whose art draws the brush again through a symbol or pattern no longer crashes the app, and graph designs, Affinity, DXF, metafiles and plug-ins were probed with hostile input (#1872). Hostile EPS, Affinity and native files can no longer run memory or CPU away through ASCII85 data, PostScript objects holding themselves, flat-colour pixel layers or far and overlapping data offsets (#1863: #1715, #1714, #1704, #1699), and the save fallback for folders that refuse a rename keeps the old file's content until the new one is in (#1695). A file whose ids sit at their largest value no longer breaks new objects (#1718); a failed `command.batch` puts each document back whole, its file, history and a drag in progress included (#1697); a control request that timed out before the app took it never runs later, and the reply says which case it was (#1725, [control-protocol.md](control-protocol.md)); the Eyedropper and recolouring refuse an image too large as RGBA before decoding it (#1717) (all #1862). A save or export that fails is reported in a dialog that names the file and stays until closed, with the document left modified and the old file untouched (#1685); a browser download that can't start fails the save instead of marking it saved (#1693); a file that finishes opening waits while a dialog is open, so Save As options can't save the wrong document (#1694) (all #1865). krilla is built without its text shaping, so the unmaintained rustybuzz and ttf-parser don't ship (#1874, #1730); the CI gate compiles the web app for wasm, and the web's SVG nesting cap (34) follows from its 1 MiB stack (#1875). - **Rendering, later 2026-10-14 merges:** copies, symbol instances and repeats that share an appearance keep their stroke outlines between frames (#1667). Wide drop shadows and glows at high zoom render within the raster budget (#1706); stacked Transform effects are bounded (#1705); 3D effects keep the area a nonzero compound path fills (#1724); pattern tiles redraw when a symbol, pattern or image their art shows changes (#1723); a template layer dims its images by its Dim Images percentage instead of fading the whole layer (#1683) (all #1864). @@ -3300,13 +3300,13 @@ A double-click on a Repeat (Radial, Grid or Mirror) with the Selection tool ente ## Spell check engine (2026-11-08) -Edit › Spelling has the commands its Check Spelling dialog will use, as the public documentation describes checking the document's text, suggesting replacements and changing a word ([Check and correct spelling](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/check-and-correct-spelling.html)). `text.spelling.check` lists the words the dictionaries don't know in every visible, unlocked type object, or in the ones given by `ids`, in paint order, each run checked in its Character panel Language (English when it has none; nothing in a language without a dictionary). Each word comes with its object and byte range, which `text.editRange` changes as one undo step. `text.spelling.suggest` gives one word's suggestions. Both come from craft-proof in [storytold/craft-libs](https://github.com/storytold/craft-libs), which checks each paragraph on its own. English words come from the first dictionary craft-proof finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary for that English built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into craft-proof (#4936; `tests/spelling.rs`). The Check Spelling dialog, Auto Spell Check and Edit Custom Dictionary remain, so the Edit › Spelling menu items are still placeholders. +Edit › Spelling has the commands its Check Spelling dialog uses, as the public documentation describes checking the document's text, suggesting replacements and changing a word ([Check and correct spelling](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/check-and-correct-spelling.html)). `text.spelling.check` lists the words the dictionaries don't know in every visible, unlocked type object, or in the ones given by `ids`, in paint order, each run checked in its Character panel Language (English when it has none; nothing in a language without a dictionary). Each word comes with its object and byte range, which `text.editRange` changes as one undo step. `text.spelling.suggest` gives one word's suggestions. Both come from craft-proof in [storytold/craft-libs](https://github.com/storytold/craft-libs), which checks each paragraph on its own. English words come from the first dictionary craft-proof finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary for that English built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into craft-proof (#4936; `tests/spelling.rs`). The Check Spelling dialog, Auto Spell Check and Edit Custom Dictionary followed (below; #6341, #6425, #7744). -The custom dictionary and Ignore All followed (2026-11-09), as the same page describes them: Add puts a word in the custom dictionary, which Edit Custom Dictionary adds to, deletes from and changes, and Ignore All skips a word in the current document (#4936). `text.spelling.addWord`, `removeWord` and `changeWord` keep the dictionary in craft-proof, which every language's check reads, and the desktop app saves it to `Custom Dictionary.txt` beside its preferences (none in runs without preferences); `text.spelling.dictionary` lists it. `text.spelling.ignoreAll` keeps a word for the active document while it is open, not saved and not undoable (`tests/spelling.rs`). The dialogs remain. +The custom dictionary and Ignore All followed (2026-11-09), as the same page describes them: Add puts a word in the custom dictionary, which Edit Custom Dictionary adds to, deletes from and changes, and Ignore All skips a word in the current document (#4936). `text.spelling.addWord`, `removeWord` and `changeWord` keep the dictionary in craft-proof, which every language's check reads, and the desktop app saves it to `Custom Dictionary.txt` beside its preferences (none in runs without preferences); `text.spelling.dictionary` lists it. `text.spelling.ignoreAll` keeps a word for the active document while it is open, not saved and not undoable (`tests/spelling.rs`). The dialogs followed (below). -Auto Spell Check followed (2026-11-09): the same page has Edit › Spelling › Auto Spell Check underline potential spelling errors with a red line as you type, and says it isn't available for text with effects applied (#4936). `edit.autoSpellCheck` turns it on and off (off at first, saved with the view settings); the canvas draws a red wavy line under each word `text.spelling.check` would list in the visible type, leaves out type with an effect shown on it or on its fills and strokes, and checks a type object again when it is edited, when the custom dictionary changes and when Ignore All adds a word (`ui-egui/src/canvas/tests.rs`, `auto_spell_check_*`; `tests/spelling.rs`). The dialogs remain. +Auto Spell Check followed (2026-11-09): the same page has Edit › Spelling › Auto Spell Check underline potential spelling errors with a red line as you type, and says it isn't available for text with effects applied (#4936). `edit.autoSpellCheck` turns it on and off (off at first, saved with the view settings); the canvas draws a red wavy line under each word `text.spelling.check` would list in the visible type, leaves out type with an effect shown on it or on its fills and strokes, and checks a type object again when it is edited, when the custom dictionary changes and when Ignore All adds a word (`ui-egui/src/canvas/tests.rs`, `auto_spell_check_*`; `tests/spelling.rs`). The dialogs followed (below). -The right-click followed (2026-11-10), as the same page's "Correct spelling errors during Auto Spell Check" describes it: right-click a word with a red underline, then choose a suggested word, Ignore All to skip it in the current document, or Add to Dictionary (#4936). The canvas context menu lists the words `text.spelling.suggest` gives for it in its run's language, each replacing the word with `text.editRange` as one undo step, or No Suggestions; then Ignore All (`text.spelling.ignoreAll`) and Add to Dictionary (`text.spelling.addWord`). It lists nothing for a word that is right, with Auto Spell Check off, or once the word under the right-click has changed (`ui-egui/src/tests/contextmenu.rs`). The dialogs remain. +The right-click followed (2026-11-10), as the same page's "Correct spelling errors during Auto Spell Check" describes it: right-click a word with a red underline, then choose a suggested word, Ignore All to skip it in the current document, or Add to Dictionary (#4936). The canvas context menu lists the words `text.spelling.suggest` gives for it in its run's language, each replacing the word with `text.editRange` as one undo step, or No Suggestions; then Ignore All (`text.spelling.ignoreAll`) and Add to Dictionary (`text.spelling.addWord`). It lists nothing for a word that is right, with Auto Spell Check off, or once the word under the right-click has changed (`ui-egui/src/tests/contextmenu.rs`). The dialogs followed (below). The page's other way to turn Auto Spell Check on followed (2026-11-10): right-click the text and choose Spelling › Auto Spell Check (#4936). A right-click on type (which selects it) has a Spelling submenu with Auto Spell Check, which runs `edit.autoSpellCheck` as Edit › Spelling does. The context menu draws no check marks, its toggles saying what they do (Show Rulers, Hide Guides), but a submenu that holds only toggles shows them, and so does Spelling, so Auto Spell Check is checked while it is on; other art has no Spelling submenu (`right_click_on_type_turns_auto_spell_check_on_and_off`). Check Spelling… followed in the same submenu (2026-11-15), after Auto Spell Check as in Edit › Spelling, as the page also describes opening the Check Spelling dialog from Spelling in the menu of right-clicked text. It runs `ui.checkSpelling` on the selection, which the right-click made the type under the pointer, and a right-click on an underlined word has it too (`right_click_on_type_opens_check_spelling`, `right_click_on_an_underlined_word_also_offers_check_spelling`). @@ -3316,15 +3316,15 @@ Check Spelling followed (2026-11-15): Edit › Spelling › Check Spelling… (` ## Retype, phase 1 (2026-11-18) -The public pages describe Retype finding the fonts that match selected outlined text (or text in an image), from the fonts on the device among others, and applying them to live text ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html), [apply to live text](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/apply-retype-suggested-fonts-to-live-text.html)). Phase 1 (#4934) is local and exact: Type › Retype (`type.retype`) compares each selected glyph shape with the glyphs of the loaded fonts, the document's fonts and any families named in `fonts`, the same up to uniform scale, rotation and translation, and sets the matched characters as point text in that font and size at the same baseline, one object per line, in one undo step. Shapes that match no font stay and are reported. The search is bounded, not exhaustive: at most 96 faces (named families first, then the document's fonts, then the other loaded faces), the first 65,536 encoded characters of each, and glyphs of plain-shape characters (box drawing, blocks, geometric shapes, private use) are left out; a glyph outside those limits is reported as matching no font. Exact matching also reads a curve an exporter split in two as a different shape; near matching with a tolerance (below) reads it as the glyph. Tested by round trips through Create Outlines (plain, bold and turned, serif, word spaces), a drawn shape and a mixed selection (`crates/engine/src/cmd/retype_tests.rs`). Installed fonts not yet loaded and images remain (phase 2). +The public pages describe Retype finding the fonts that match selected outlined text (or text in an image), from the fonts on the device among others, and applying them to live text ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html), [apply to live text](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/apply-retype-suggested-fonts-to-live-text.html)). Phase 1 (#4934) is local and exact: Type › Retype (`type.retype`) compares each selected glyph shape with the glyphs of the loaded fonts, the document's fonts and any families named in `fonts`, the same up to uniform scale, rotation and translation, and sets the matched characters as point text in that font and size at the same baseline, one object per line, in one undo step. Shapes that match no font stay and are reported. The search is bounded, not exhaustive: at most 96 faces (named families first, then the document's fonts, then the other loaded faces), the first 65,536 encoded characters of each, and glyphs of plain-shape characters (box drawing, blocks, geometric shapes, private use) are left out; a glyph outside those limits is reported as matching no font. Exact matching also reads a curve an exporter split in two as a different shape; near matching with a tolerance (below) reads it as the glyph. Tested by round trips through Create Outlines (plain, bold and turned, serif, word spaces), a drawn shape and a mixed selection (`crates/engine/src/cmd/retype_tests.rs`). Images remain (phase 2). Installed fonts not yet loaded, and loaded faces past the first 96, are compared too (#8823; see Retype installed fonts). ## Retype near matches (2026-11-18) -The public page orders Retype's matching fonts by how close each is to the text's appearance ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html)), so outlines need not be exactly a font's glyphs. `type.retype` takes a `tolerance` (0 to 0.05, default 0 for exact matches only). Above 0, a shape of up to 8 contours that is no glyph exactly is read at equal steps of length from any start and in either direction, its contours paired with the glyph's by length, and it becomes the glyph it is closest to when the leftover distance, relative to the shape's size, is at most the tolerance and the glyph's outline and the shape's each lie within three times the tolerance (relative to the shape's size, and at least 0.5%) of the other. A near-matched glyph may differ from its line by the tolerance in size, turn and place; an exact glyph keeps the exact limits unless the line's first glyph, whose size and turn the line takes, is a near match. Each line in the result has a `score` from 1 (exact) to 0. A compound path holding several glyphs (a word made into one compound path) is split into groups of contours and matched in runs of up to three groups, and becomes type only when every glyph does; exact matching of those groups also reads contours that run the other way round, as Make Compound Path leaves them. Exact matches of the whole shape come first, then exact matches of its groups, then near matches. The tolerance, the score and the splitting are VectorCraft's own. Tested with outlines flattened into lines, restarted, reversed and simplified, a curve split in two, contours in another order, turned lines of round glyphs, a word made into one compound path, and a compound with a part that is no glyph (`crates/engine/src/cmd/retype_tests.rs`, `crates/text/src/retype.rs`). The Retype panel's list (below) still takes exact matches of whole shapes only. Glyphs fused into one contour, installed fonts not yet loaded and images remain. +The public page orders Retype's matching fonts by how close each is to the text's appearance ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html)), so outlines need not be exactly a font's glyphs. `type.retype` takes a `tolerance` (0 to 0.05, default 0 for exact matches only). Above 0, a shape of up to 8 contours that is no glyph exactly is read at equal steps of length from any start and in either direction, its contours paired with the glyph's by length, and it becomes the glyph it is closest to when the leftover distance, relative to the shape's size, is at most the tolerance and the glyph's outline and the shape's each lie within three times the tolerance (relative to the shape's size, and at least 0.5%) of the other. A near-matched glyph may differ from its line by the tolerance in size, turn and place; an exact glyph keeps the exact limits unless the line's first glyph, whose size and turn the line takes, is a near match. Each line in the result has a `score` from 1 (exact) to 0. A compound path holding several glyphs (a word made into one compound path) is split into groups of contours and matched in runs of up to three groups, and becomes type only when every glyph does; exact matching of those groups also reads contours that run the other way round, as Make Compound Path leaves them. Exact matches of the whole shape come first, then exact matches of its groups, then near matches. The tolerance, the score and the splitting are VectorCraft's own. Tested with outlines flattened into lines, restarted, reversed and simplified, a curve split in two, contours in another order, turned lines of round glyphs, a word made into one compound path, and a compound with a part that is no glyph (`crates/engine/src/cmd/retype_tests.rs`, `crates/text/src/retype.rs`). The Retype panel's list (below) still takes exact matches of whole shapes only. Glyphs fused into one contour and images remain; installed fonts not yet loaded are compared too (#8823, see Retype installed fonts). ## Retype panel (2026-11-18) -The identify-fonts page has the Retype panel list ten matching fonts ordered by closeness, with five more on request, previews in one of three text sizes and the user's own sample text ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html)). Window › Retype shows the Retype panel. Find Matching Fonts (`retype.find`, on `type.retypeFonts`) lists the fonts whose glyphs the selected shapes exactly match, comparing up to 96 loaded fonts with those of the document's live type first, so a matching font past that limit is not listed; Find more font matches adds five. The 96-font limit is VectorCraft's own. The order is VectorCraft's own: by how many shapes each font matches, then by how closely. The sample sizes (Small, Medium, Large) and the 100-character sample text limit are VectorCraft's own too. Each row shows a sample in the font, in the size the panel menu sets and with the text typed in the panel, and a click on a row sets the font on the selected live type. Tested in `crates/engine/src/cmd/retype_fonts_tests.rs` and `crates/ui-egui/src/panels/retype/tests.rs`. Opening the panel from the Type menu, the context menu and the Properties panel's Quick Actions, filtering the list by font source and favorites, near matches and images remain; installed fonts not yet loaded are compared too (see Retype installed fonts). +The identify-fonts page has the Retype panel list ten matching fonts ordered by closeness, with five more on request, previews in one of three text sizes and the user's own sample text ([identify fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/identify-fonts-using-retype.html)). Window › Retype shows the Retype panel. Find Matching Fonts (`retype.find`, on `type.retypeFonts`) lists the fonts whose glyphs the selected shapes exactly match, comparing up to 96 loaded fonts with those of the document's live type first, so a matching font past that limit is not listed; Find more font matches adds five. The 96-font limit is VectorCraft's own. The order is VectorCraft's own: by how many shapes each font matches, then by how closely. The sample sizes (Small, Medium, Large) and the 100-character sample text limit are VectorCraft's own too. Each row shows a sample in the font, in the size the panel menu sets and with the text typed in the panel, and a click on a row sets the font on the selected live type. Tested in `crates/engine/src/cmd/retype_fonts_tests.rs` and `crates/ui-egui/src/panels/retype/tests.rs`. The Properties panel's Quick Actions show the panel with type selected (#8778). Opening the panel from the Type menu and the context menu, filtering the list by font source and favorites, near matches and images remain; installed fonts not yet loaded are compared too (see Retype installed fonts). ## Retype tracking (2026-11-19) @@ -3386,7 +3386,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s `bucket_fills_a_region_of_a_selection_that_mixes_a_group_and_paths`, `the_live_paint_bucket_shows_a_bucket_or_a_brush`. Behavior source: [the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html). - The cursor swatch preview is not built. Scores and estimates unchanged. + Cursor Swatch Preview shows the active paint above the pointer between the swatches before and after it (#7265). Scores and estimates unchanged. - **Live Paint Selection cursors:** the pointer changes over a face, over an edge and outside the Live Paint groups ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)). The cursor is the arrow with a filled square where a click selects a face, with a short line From 4092a8b10b61e0040b295bd0ef8634ab3cd2ce97 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:44:15 -0800 Subject: [PATCH 179/264] Docs: gaps.md matches what main ships Lines that called shipped work missing, pending or unconfirmed now say what main has: the key anchor for Align and Distribute (#7769, #8023), artboard colors in exports and print (#4991), update checks (#4138), Touch Type, Snap to Glyph, ruby, kinsoku sets and tate-chu-yoko, the file-font and read-only save regressions passing in #4569 and #6671, and the Wayland cursor and Windows title bar fixes the reporters confirmed (#1645, #1758). The built-in brush library count and list match the twenty libraries in brushlib.rs, and the Preferences count matches the two options still listed under Missing. --- docs/gaps.md | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index fd7e4a6b9f..9130e782f1 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -13,7 +13,7 @@ > Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267). Scores and estimates unchanged. -> **File-font hardening status (2026-11-12, #4569):** G8 implementation and synthetic regressions added; compilation and runtime proof pending. Scores and estimates unchanged. +> **File-font hardening status (2026-11-12, #4569):** G8 implementation and synthetic regressions added; #4569 merged with its CI gate passing. Scores and estimates unchanged. ## Feature submission evidence @@ -172,7 +172,7 @@ stage ([ROADMAP.md](../ROADMAP.md)). **Alpha blockers:** none. Every core workflow passes the [alpha gate](roadmap.md#alpha-gate); G9 is the only partial one, and it blocks beta, not alpha. -**To beta:** G1, G9, G10, G11, G12, the corpus and QA part of G8, the type-core part of G4, macOS pen pressure +**To beta:** G1, G9, G10, G11, G12, the corpus and QA part of G8, the type-core part of G4, native Wayland pen pressure from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall clock with 4–6 agents. ## G1 Interaction fidelity @@ -229,7 +229,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done:** Artboard Options' Show Center Mark and Show Cross Hairs ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/modify-display-settings-of-artboards.html)): per-artboard checkboxes (`artboard.setProps`/`artboard.new` `showCenterMark`, `showCrossHairs`) that the canvas draws as a center cross and lines from the middle of each side through the center; exports and print leave them out. - **Done (#2849):** Artboard Options' video display options ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/set-video-display-options-for-artboards.html)): Show Video Safe Areas (`showVideoSafeAreas`) outlines the action-safe area 3.5% and the title-safe area 5% in from each edge, our choice from [EBU R 95](https://tech.ebu.ch/docs/r/r095.pdf) (the help page gives no numbers), on the canvas only; Video Ruler Pixel Aspect Ratio (`videoRulerPixelAspectRatio`, 0.1–10, default 1) is the width of one video pixel over its height. Both per artboard, one undo step, in the native format only when set. View › Rulers › Show Video Rulers is in G7. - **Done (#3705):** Draw Inside in isolation mode ([isolation mode](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/isolate-objects.html)): with the object drawn into isolated by a double-click, art drawn or pasted inside it takes isolation mode into its clip group, so it can be clicked and isn't dimmed; it used to stay locked and dimmed beside the isolated path, and double-clicks never reached the clip group. -- **Done:** Artboard Options' Show Center Mark and Show Cross Hairs ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/modify-display-settings-of-artboards.html)): per-artboard checkboxes (`artboard.setProps`/`artboard.new` `showCenterMark`, `showCrossHairs`) that the canvas draws as a center cross and lines from the middle of each side through the center; exports and print leave them out. Video safe areas, video rulers and the pixel aspect ratio remain missing. +- **Done:** Artboard Options' Show Center Mark and Show Cross Hairs ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/modify-display-settings-of-artboards.html)): per-artboard checkboxes (`artboard.setProps`/`artboard.new` `showCenterMark`, `showCrossHairs`) that the canvas draws as a center cross and lines from the middle of each side through the center; exports and print leave them out. - **Done:** Document Setup → Edit Artboards applies valid settings, closes the dialog and activates the Artboard tool. Pointer-click tests cover successful handoff, invalid settings, OK, Cancel and Undo in `dialogs/document_setup.rs`. - **Done (#2691):** a double-click on the Line Segment, Arc, Rectangular Grid or Polar Grid tool opens its Tool Options, as the [Rectangular Grid tool](https://helpx.adobe.com/illustrator/using/tool-techniques/rectangular-grid-tool.html) and [Arc tool](https://helpx.adobe.com/illustrator/using/tool-techniques/arc-tool.html) pages (step 3) and the [Tools](https://helpx.adobe.com/illustrator/using/tools.html) page describe: the tool's click dialog without a place to draw (Line Segment adds Fill Line; the grids keep their Default Size and Reference Point). OK draws nothing and sets what the next drag draws with and what a click's dialog opens at; Cancel changes nothing. Editing a grid's rows and columns after it is drawn (the rest of #2691) remains. Broader G1 estimate unchanged. - **Done:** Simplify of part of a path, as the [manual-simplify page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/manually-simplify-paths.html) describes for part of a path picked with Direct Selection: with anchors or segments of a path direct-selected, Object › Path › Simplify (the slider, Auto-Simplify and the dialog) refits only each run of selected segments between its end anchors, which stay where they are with their outer handles; the other anchors and segments stay exactly as they were, a closed path's run may cross its start point, separate runs on one path simplify independently in one undo step, and the runs stay selected (`object.path.simplify` `wholePaths: true` simplifies such paths whole). Tests: `crates/engine/src/tests/simplify_part.rs`, `simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path`. Broader G1 estimate unchanged. @@ -257,9 +257,9 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done (#834):** bezier drag previews no longer freeze: a Pen, Anchor Point or Direct Selection drag gets every position the pointer is seen at, including the one where it comes back into the window after leaving it and a move in the frame it lets go, so the release commits where the pointer let go; a click's jitter stays a click. -- **Missing (noted for reporters, 2026-10-14):** aligning anchor points selected with - Direct Selection to a key anchor (from #1636: they align to their bounds; the current public Align page does - not say how the key anchor is chosen, so this waits for the owner). Inside the estimate below. +- **Done (#7769, #8023):** aligning anchor points selected with + Direct Selection to a key anchor (from #1636): with several anchors selected, a click on one of them without + modifiers makes it the key anchor that Align and Distribute keep in place. Inside the estimate below. - **Missing:** a tool-by-tool, panel-by-panel pass over modifiers, cursors, the Properties panel per context, isolation mode and small behaviours, against the public tool and shortcut documentation. Itemized in [ui-parity.md](ui-parity.md). The Shaper's construction-mode widget and gesture refinements remain. @@ -325,14 +325,14 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi ## G10 Launch and stability on real machines -- **Unconfirmed (2026-10-14):** Tool cursors are painted into the window on Wayland (#1652; not run on Linux, #1645 stays open until confirmed). On Windows the custom title bar's window stays truly borderless, so the pointer lines up with what is drawn on systems where the hidden caption offset it (#1791, #1758; awaiting the reporter's confirmation). +- **Done (2026-10-14):** Tool cursors are painted into the window on Wayland (#1652; the reporter confirmed the size on Hyprland, and #1645 is closed). On Windows the custom title bar's window stays truly borderless, so the pointer lines up with what is drawn on systems where the hidden caption offset it (#1791, #1758; the reporter confirmed it on 0.11.0). - **Done:** RPM required dependencies use 64-bit library capabilities and declare glibc 2.35, libm and libgcc_s (#1275); generated metadata and isolated synthetic-provider checks cover x86_64/aarch64. Real-distribution install/start-up QA is still missing. - **Done (2026-11-04):** a first frame the app is slow to build no longer costs the window its graphics adapter (#5160). The first-frame watchdog gave the frame 20 s from the app's start and then started again without the adapter, so a slow machine (antivirus reading every file, a large font library) ended with no adapter left and no window. A frame counts once its UI pass ends, before it is painted, so the 20 s now run from there; a frame still being built is waited for, with a note in the log (`a_first_frame_that_never_reaches_the_screen_hangs_its_adapter`; checked on Linux with the first frame held 35 s: the window opened with no restart). Estimate unchanged. - **Done (2026-11-04):** a large font library no longer keeps the window from opening (#5483). The menu bar's Type › Font, drawn in the first frame, waited for the scan of every installed font; when that took longer than the 20 s first-frame watchdog (thousands of fonts on a slow disk, or with each file checked by antivirus) the app took the graphics adapter for hung and started again without it until none was left. The menu now lists the fonts already loaded until the scan ends, then all of them (`the_menu_family_list_now_does_not_wait_for_the_scan`; checked on Linux with 3,923 extra font files, each open delayed 8 ms: the window opened in 1.5 s, where it never did before). Estimate unchanged. - **Done (2026-10-29):** the Linux Flatpak on GNOME no longer reconnects to the compositor and logs a warning every 250 ms when arboard has neither data-control nor X11 (267k warnings in 18 h filled the 16 MB log in 3 h): a clipboard that can't be opened is retried with a wait growing to a minute and logged once. Copy and Paste of text with other apps work there through the core Wayland protocol. - **Unconfirmed (2026-11-13):** pictures and SVG on the clipboard of the Flatpak on GNOME. Copy there offers the PNG as `image/png`, the SVG as `image/svg+xml` (with Include SVG Code on) and the text, all from one Copy; Paste takes SVG, then text, then the PNG (blank text, or text that only names a picture, gives way to the PNG), and the Paste menu item is enabled by the types offered. A read takes 64 MiB at most (`clipboard::wayland` tests; not yet run in the Flatpak on a GNOME session). - **Missing:** the app not starting or staying in the background on some Windows 11 machines (#858, #964 fixed - 2026-10-10, #620, #818), slow pointer on a Linux AppImage (#575), macOS paste from other apps (#954), a + 2026-10-10, #620, #818), macOS paste from other apps (#954), a web-free crash/hang reporter, a field record. - **Evidence:** open issues; the never-crash lints and `guard` stop panics, not driver, windowing or packaging failures. @@ -341,7 +341,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi ## G8 Hardening at scale -- **Implementation awaiting runtime proof (#4569):** bind file-font references to owned document blobs, compare candidate face bytes, and reclaim dead live-face slots. Unused blobs do not consume admission; native/PDF/paste report refused resources. Synthetic text, renderer and native/clipboard regressions added; no gap closed before compilation and runtime checks. +- **Done (#4569):** bind file-font references to owned document blobs, compare candidate face bytes, and reclaim dead live-face slots. Unused blobs do not consume admission; native/PDF/paste report refused resources. Synthetic text, renderer and native/clipboard regressions added and passing in #4569's CI gate; no gap closed. - **Done:** PngSuite fetching verifies 175 original PNGs and redistribution notices against a pinned SHA-256/size manifest before publishing; file and total-size budgets, cache verification and no archive extraction (#1729). The real-world corpus and manual QA gaps below remain. @@ -392,8 +392,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi up with the file's size, and blends inside a symbol's art don't count toward a blend whose keys show it. - **Missing:** a corpus of real-world SVG/PDF/EPS files; more Affinity versions and platforms (51 pinned files now, including 28 original Affinity 3.2.3 feature probes; large interacting documents and complex typography - missing); Windows, Linux and browser QA by hand; packaging polish (Homebrew cask #588, Flathub #554, update - checks #615). + missing); Windows, Linux and browser QA by hand; packaging polish (Homebrew cask #588, Flathub #554). - **Impact:** unknown failures on users' files. - **Estimate:** 30–50 h (the corpus and QA part blocks beta). @@ -415,7 +414,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done (#1968):** native saves retain transparency grid visibility without adding an edit or undo step; older files default to hidden. Broader G11 scope and estimates unchanged. - **Done:** Asset Export / raster Art Optimized edges supersample so shapes that meet edge to edge leave no ghost seam (#983, #1037; `assets.export` abutting-rects regression; Asset Export panel thumbs use the same supersample). -- **Done (2026-10-14):** Align and Distribute act on the anchor points selected with Direct Selection: the points of one path align to each other, not to the artboard, and Distribute spaces them (#1641, fixes #1636; aligning to a key anchor is still missing). Delete removes every selected anchor of a closed path (it used to remove the wrong ones), removes objects selected whole along with the selected anchors of others, and keeps the remainder selected so a second Delete removes it (#1674). In isolation mode Direct Selection and Group Selection pick only inside the isolated object (#1666). Escape cancels a Direct Selection drag (#1803, #1743). Escape while typing ends the edit, keeps the type selected and switches to the Selection tool (#1802, #1686, #1656). A filled Pencil path keeps a stroke of None (#1804, part of #1679). In the Pathfinder panel a group selected alone counts its nested shapes, so an expanded stroked object keeps the Shape Modes enabled (#1642, #1635). Object › Expand turns radial, grid and mirror repeats into groups of their instances (#1765, #1756). Select › Same matches type on its characters' fill and stroke (#1746, #1737). Roughen with Smooth keeps turn-backs smooth instead of making cusps that draw as spikes (#1646, #1643). Scribble draws one zig-zag per region, with no lines across holes and notches; convex shapes are unchanged (#1651, #1648). +- **Done (2026-10-14):** Align and Distribute act on the anchor points selected with Direct Selection: the points of one path align to each other, not to the artboard, and Distribute spaces them (#1641, fixes #1636; aligning to a key anchor followed in #7769). Delete removes every selected anchor of a closed path (it used to remove the wrong ones), removes objects selected whole along with the selected anchors of others, and keeps the remainder selected so a second Delete removes it (#1674). In isolation mode Direct Selection and Group Selection pick only inside the isolated object (#1666). Escape cancels a Direct Selection drag (#1803, #1743). Escape while typing ends the edit, keeps the type selected and switches to the Selection tool (#1802, #1686, #1656). A filled Pencil path keeps a stroke of None (#1804, part of #1679). In the Pathfinder panel a group selected alone counts its nested shapes, so an expanded stroked object keeps the Shape Modes enabled (#1642, #1635). Object › Expand turns radial, grid and mirror repeats into groups of their instances (#1765, #1756). Select › Same matches type on its characters' fill and stroke (#1746, #1737). Roughen with Smooth keeps turn-backs smooth instead of making cusps that draw as spikes (#1646, #1643). Scribble draws one zig-zag per region, with no lines across holes and notches; convex shapes are unchanged (#1651, #1648). - **Done:** Divide splits filled paths along open cutting lines and curves (#1307), preserving the frontmost filled appearance, implicit filled closure, holes, unrelated objects and one Undo/Redo; the existing bounded-map fallback remains. @@ -435,7 +434,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi selected with Direct Selection (#1839, #1824); Snap to Grid wins over Snap to Pixel (#1840, #1816 unconfirmed); Redo during a drag keeps the drag (#1856, #1719); a template layer dims its images by Dim Images instead of fading the whole layer (#1864, #1683); a failed save or export is reported in a dialog that names the file and stays until - closed, the document left modified (#1865, #1685). Ordinary File > Save now offers Save As for terminal permission/read-only refusals (#6146), unless another picker is open; recovery errors retain the dialog. Regression execution pending; G11 estimate unchanged. + closed, the document left modified (#1865, #1685). Ordinary File > Save now offers Save As for terminal permission/read-only refusals (#6146), unless another picker is open; recovery errors retain the dialog. Regressions pass in #6671's CI gate; G11 estimate unchanged. - **Done:** the Shape Builder offers the empty areas closed shapes enclose as regions, such as the middle of four circles that touch, and merges them with the regions around them (#1691). - **Done (#2523):** Shape Builder Gap Detection shares Live Paint's spatially indexed gap finder, @@ -502,7 +501,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done:** a paragraph's Auto Leading also sets the Leading the Character panel shows for Auto type, the leading the Alt+↑/↓ nudge steps from and the lines Fill with Placeholder Text counts; estimate unchanged. - **Missing:** CJK vertical - composition (ruby, custom mojikumi sets and the Mojikumi Settings dialog, kinsoku settings #633, manual tate-chu-yoko), Middle Eastern + composition (custom mojikumi sets and the Mojikumi Settings dialog), Middle Eastern - **Done:** Ruby (ふりがな) for live text (`type.ruby`): a reading over a byte range, above or below (right of the column in vertical type), aligned, sized, overhanging or squeezed; saved natively, laid out with line growth, drawn on the canvas and in SVG/PDF (outlines where ruby is present), EPS, EMF/WMF and legacy `.ai` (outlines where ruby is @@ -541,9 +540,9 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi own pixels until a document takes them in; estimate unchanged. - **Done:** spell check (#4936): engine (`text.spelling.check` and `text.spelling.suggest` on craft-proof); custom dictionary and Ignore All (`text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary`, `ignoreAll`); Auto Spell Check (`edit.autoSpellCheck`) with red wavy underlines and canvas context menu suggestions, Ignore All and Add to Dictionary; Edit › Edit Custom Dictionary…; and modal Check Spelling dialog (Edit › Spelling › Check Spelling…, and Spelling › Check Spelling… in the canvas context menu of type, `ui.checkSpelling`) with sentence context, suggestions list, "Change to" edit, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done, Cancel, and keyboard navigation; Language packs for languages other than English, read from the Craft apps' shared font store, with `proof.packs`, `proof.installPack` and `proof.removePack` (a Preferences page to install them and the missing-pack bar remain). Estimate unchanged. - **Missing:** CJK vertical - composition (custom mojikumi sets and the Mojikumi Settings dialog, kinsoku settings #633, manual tate-chu-yoko), Middle Eastern + composition (custom mojikumi sets and the Mojikumi Settings dialog), Middle Eastern features beyond bidi, digit types, Character Direction and Kashidas (a split caret; the Middle Eastern & South Asian composers are done, #4935), - Touch Type, Retype beyond exact matches of available fonts (phase 1 is in, #4934, the Retype panel lists the exactly matching fonts, installed fonts not yet loaded included, and `type.retype` takes near matches within a tolerance and words outlined as one compound path, in installed fonts not yet loaded too; glyphs fused into one contour, near matches in the panel's list and text in images remain), Snap to Glyph; optional preservation of font sizes during group scaling (#1034 enhancement). + Retype beyond exact matches of available fonts (phase 1 is in, #4934, the Retype panel lists the exactly matching fonts, installed fonts not yet loaded included, and `type.retype` takes near matches within a tolerance and words outlined as one compound path, in installed fonts not yet loaded too; glyphs fused into one contour, near matches in the panel's list and text in images remain); optional preservation of font sizes during group scaling (#1034 enhancement). Itemized in [type-parity.md](type-parity.md). - **Impact:** professional typography and Japanese/Chinese publishing. - **Estimate:** 34–47 h (type core 14–19 h blocks beta). @@ -609,8 +608,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Audited (2026-10-30, #394):** every Preferences dialog option but four is read by shipped code, by its field or its key; Highlight Alternate Glyphs (the canvas's render options), Real-time Drawing and Editing (tool previews wait for the commit), Show Tool Tips, Anti-aliased Artwork, Use Precise Cursors and Devices › - Enable Touch Workspace and Touch Gestures included. One of the four, Open Documents As Tabs, acts now (below); - the other three are listed under Missing. + Enable Touch Workspace and Touch Gestures included. Two of the four, Open Documents As Tabs and Hyphenation › Default Language, act now (below); + the other two are listed under Missing. - **Done:** User Interface › Open Documents As Tabs: with the box cleared, each document opened or created afterwards opens in a floating window of its own (G7's Float in Window); documents already open stay where they are. Estimate unchanged. @@ -714,9 +713,9 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Missing:** the rest of the snapping enhancements (29.8.1): forced snapping to the grid, showing guides while snapping, and limiting snapping to the active artboard or to isolated objects; floating-panel parity is unverified (the Control bar's Snapping quick access and View › Snapping submenu are done, see [ui-parity.md](ui-parity.md)). The Smart Guides snapping tolerance and 30.0's Snap to Tangent and Snap to Perpendicular are done. Not yet checked: snapping to the endpoints, midpoints and centers of - rotated objects, and the reworked Snap to Grid and Snap to Pixel feedback. Also missing: artboard colors in exports and print, and + rotated objects, and the reworked Snap to Grid and Snap to Pixel feedback. Artboard colors in exports and print are done (#4991). Also missing: managing artboards from the canvas other than locking and unlocking them from the Artboard tool's right-click - menu (30.0); the Blend panel with ease in/out and separate colour acceleration (30.7). The Dimension tool (28.x) + menu (30.0). The Blend panel's easing (30.7) is partial, see above. The Dimension tool (28.x) is done ([dimensions.md](dimensions.md)). - **Evidence:** Adobe's 30.0 and 30.7 release announcements, see [target-app-parity.md](target-app-parity.md#how-this-was-measured-2026-10-10); snapping: @@ -782,8 +781,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi libraries ([public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html)): Window › Brush Libraries and the Brushes panel's Brush Libraries Menu open each library in a library panel of - its own (fifteen original libraries generated in code: Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive, Bristle Brushes (one - bristle brush for each tip shape), Pattern Borders, Decorative (Leaf Vine, Blossom Chain, Pennant Garland and Lantern String pattern brushes), Scatter Shapes, Stipple (Fine, Dense, Soft and Bold dot textures), Game Trails, Energy Beams, Dry Media (grainy chalk, pencil, crayon and charcoal art brushes), Tech Circuit (Circuit Trace, Bus Lines and Terminal Nodes), Engraving (Fine, Dense, Tapered and Broken Hatching) and Arrows (Solid, Open, Double, Chevron and Dashed Arrow); User Defined; Other Library… reads the brushes of any document VectorCraft opens); a + its own (twenty original libraries generated in code: Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive, Bristle Brushes (one + bristle brush for each tip shape), Paint, Pattern Borders, Decorative (Leaf Vine, Blossom Chain, Pennant Garland and Lantern String pattern brushes), Ornamental, Scatter Shapes, Stipple (Fine, Dense, Soft and Bold dot textures), Game Trails, Energy Beams, Dry Media (grainy chalk, pencil, crayon and charcoal art brushes), Tech Circuit (Circuit Trace, Bus Lines and Terminal Nodes), Engraving (Fine, Dense, Tapered and Broken Hatching), Arrows (Solid, Open, Double, Chevron and Dashed Arrow), Image Brush, Artistic Brushes and Vector Packs; User Defined; Other Library… reads the brushes of any document VectorCraft opens); a click adds a brush to the document's Brushes with the patterns, symbols and other resources its art uses, as one undo step (applied to the selected paths in the same step), dragging one onto a path adds and applies it and From 0d8184648121e5c689561bdeebef55a7a46b11a6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:44:43 -0800 Subject: [PATCH 180/264] Docs: docs/roadmap.md matches what main ships MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Set type row names Justification… (#2771) instead of calling the justification options missing. The Alongside step names the one menu stub left, Effect › 3D and Materials › Materials…, instead of 28. Both M7 rows mark tab leaders done (#1880) and vertical type in progress with Type › Type Orientation (#5027). --- docs/roadmap.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/roadmap.md b/docs/roadmap.md index ff7e13fae7..971ca6eafa 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -158,7 +158,7 @@ Checked 2026-10-10 from the code, tests and open issues; no workflow fails, so V | 2026-10-12 | minor | Desktop PDF spooler shared through craft-print; exact physical sizes, composed copies and Windows 7 fallback retained. Scores and remaining gaps unchanged. | | Draw and edit paths precisely: Pen, Curvature, Direct Selection on anchors and handles, smart guides and snapping, Pathfinder | yes | `crates/tools/src/pen.rs`, `direct.rs`, `guides.rs` and their tests; 10 exact Pathfinder booleans; [ui-parity.md](ui-parity.md). Shape Builder regions on art of thousands of segments fixed (#937's reproduced case; unconfirmed on the reporter's file), Pathfinder covers the same results | 0 | | Paint and style: fills and strokes, global and spot swatches, gradients, Appearance, transparency, graphic styles | yes | M3 done (92 tasks); area scores 92–97% in [target-app-parity.md](target-app-parity.md#feature-areas) | 0 | -| Set type: point and area type, Character and Paragraph styles, threading, outlines | yes | type core 80%; styles, threading, Create Outlines and font matching tested ([type-parity.md](type-parity.md)); justification options missing (not blocking) | 0 | +| Set type: point and area type, Character and Paragraph styles, threading, outlines | yes | type core 80%; styles, threading, Create Outlines and font matching tested ([type-parity.md](type-parity.md)); justification options set per paragraph with Justification… (#2771) | 0 | | Organise layers and artboards and export assets (Export for Screens, SVG, PNG, PDF per artboard) | yes | Layers panel rework, Artboards panel and tool, Export for Screens and Asset Export done; Art Optimized supersample closes ghost borders (#983 / #1037) | 0 | | Print production: CMYK and spot colour, bleed and marks, PDF/X out, separations preview | yes | PDF/X-1a/3/4, presets, marks and bleed, ICC output intent, Separations Preview, Print with PostScript output | 0 | | Exchange files with Illustrator users: open their `.ai`/EPS/PDF, hand back a file they can open | partial (doesn't block alpha) | `.ai`, EPS and PDF open as editable art, but real files can get the wrong layer structure (#951); Save As `.ai` is PDF-compatible with an editing copy of the art (layers, groups, paths, colors, gradients, patterns, images, transparency, opacity masks, clipping, type as text and symbols, with live effects kept only on paths, compound paths and groups that qualify (at most a fill and a stroke, a non-zero fill rule when filled, no large canvas) and whose appearance and effects the art-style writer supports ([file-format-parity.md](file-format-parity.md)), other objects' effects other than geometry effects left out, and live objects written as their art; #868), or legacy version 7, which keeps layers, groups and type as text, one artboard per file, and waits for users' testing. EPS legacy mesh corners, vector opacity masks and raster print-page comparison now preserve editable art under synthetic regressions. This is the beta main-format gap ([gaps.md](gaps.md) G9) | 10–20 (for beta) | @@ -181,7 +181,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule - **Then:** advanced type (G4) and the Illustrator 2026 additions (G13), then 3D (G3), each with a plan in `plan/` before coding. -- **Alongside:** close the 28 stubbed menu items; run `vectorcraft-cli perf` on an idle machine and fix any +- **Alongside:** close the one stubbed menu item (Effect › 3D and Materials › Materials…); run `vectorcraft-cli perf` on an idle machine and fix any budget missed (G15). - **Beta:** G1, G9, G10, G11, G12, the corpus part of G8, type core, macOS pen pressure and the perf budgets (~170–270 h one agent, ~50–80 h with 4–6 agents). @@ -198,9 +198,9 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M4 | Files (native, SVG, PDF, raster, Export for Screens, clipboard interop) | `.ai` import: type takes the installed copy of its font that sets its PDF part's widths (#8087; estimates unchanged); `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths (#8128; estimates unchanged); Production Preflight checks fonts, overflow, links and image resolution with clickable findings and automatic rechecking (VectorCraft addition; estimates unchanged); PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked (#8300; estimates unchanged); PDF import: type filled and stroked by one text-showing operator comes in as one filled and stroked type object (#8015; not for type filled and stroked at less than full opacity, which still comes in as a filled object and a stroked one, as the file composites them; estimates unchanged); PDF import: type filled and stroked by a `TJ` whose kerning starts a new line part way through comes in filled and stroked, a type object for each part, also where it draws a glyph again where it drew one, in an `ActualText` span too, where it stays one replacement type object on the first glyph's line and in its style; a `TJ` over more than 65 lines (the 64 its fill pass finished, kept back, and the open one) stays a filled object and a stroked one for each part (#8543; estimates unchanged); PDF import: type filled and stroked after a page of type filled only (more than 64 lines) comes in as one filled and stroked type object again, with or without a path between, and a `TJ` over more lines than are kept with a glyph kept as an outline still stays a filled object and a stroked one for each part (#8549 follow-up; estimates unchanged); PDF import: stroked type keeps the file's line cap, line join and miter limit (#7741; estimates unchanged); Rename artboards in Export for Screens (#7275); Explicit editing-data import keeps oversized capped-page artboards (#6865; estimates unchanged); Save refusal continuation (#6146): ordinary Save offers Save As; unchanged format keeps options, changed format opens its Save options; cancellation/automation isolation; focused UI regressions passed, native acceptance pending; PDF authored ActualText preserved once in editable import (#6165; first-glyph line/style, bounded input; estimates unchanged); PDF export keeps harakat and zero-advance Noto Arabic dot glyphs in one compatible batch per layout line, with per-glyph vertical offsets (#6309). `crates/pdf/src/tests/realtext.rs` (`mark_text_*`) checks decoded cluster mappings, mixed Arabic/Latin/digits, contour placement against outline export, vertical columns, differing path rotations and PDF/X-1a/3/4. Editable-text import preserves authored ActualText separately (#6165), with cross-line/style layout limits; separately styled or differently rotated clusters and external viewer search/copy remain outside this export-only evidence. `.ai`/EPS type from the text document keeps its paragraphs' tab stops (#6147); `.ai`/EPS type from the text document keeps auto leading per line, its hyphenation options, and may show more of the last lines the file sets in an area frame of its own, when growing the frame by its lines' deepest descent plus 0.05 pt shows them (#6137); ✅ done (M4.14–M4.98 on 2026-10-05): Save As/Save a Copy/Revert/templates, Data Recovery and background save, SVG import and export fidelity (units, text, symbols, filters, SVGZ, Preserve Editing, SVG Options), shared guarded PDF writer and windowed reader ([pdf-backend.md](pdf-backend.md)), PDF import (colours, layers, masks, editable text, security) and export (presets, marks, bleed, ICC and output intent, raster effects, subset fonts, PDF/X-1a, X-3 and X-4, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3), Place and Links, Package, EPS and DXF in and out (EPS legacy mesh corners, vector opacity masks and raster page comparison verified; closed SPLINE flags round-trip and circular paths export as native CIRCLE/ARC, #1299), EMF/WMF, TIFF/BMP/Targa/PSD/GIF/PNG-8 export, Print and print presets, slices, Save for Web, TIFF in Export for Screens and Asset Export, clipboard flavours, File Info; AF.1–AF.4 add Affinity import (native layers, artboards, vectors, text and images from Affinity 1–3 files; the embedded preview only as a warned fallback; AF.4 expands current `.af` fixtures and every-board round-trip validation); EPS Save and Save As keep an opened EPS as EPS with its page frame and complete editable VectorCraft document (2026-10-26; G9 import fidelity unchanged). Left: DWG (use DXF), PSD placement as layers, overprint read back from PDF, Affinity export, polish; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; PDF import: glyphs inside a marked-content span with an empty `ActualText` come in as outlines in their fill and stroke, adding no text (#6971; scores and estimates unchanged); | 3–6 (existing scope; Affinity export unestimated) | | M5 | Performance | 🟡 background render + caches + MT done; text thread overlays index repeated selection lookups, keeping the first lookup and singleton selections direct (#6543); `vectorcraft-cli bench` and `vectorcraft-cli perf` (budget suite); opaque solid-fill knockout paths draw once in hard-edge/supersampled raster export, with analytical-AA compositing unchanged; file format v2 opens 3× faster (50k paths: 722 → 244 ms); raster effects (glows, shadows, blur, feather) no longer force the whole frame single-threaded (filtered offscreen per effect, verified equal to the single-threaded reference); Craquelure/Mosaic Tiles/Stained Glass distance searches optimized with pixel-invariance checks and the `texture_drag_perf` probe (#1257); effect-heavy demos need a clean-machine benchmark; in the web build an edit while the view of a heavy document moves draws only the part it changed into the last frame (#8688); dirty-region rendering, GPU backend spike pending | 15–25 | | M6 | Path operations (Pathfinder, Shape Builder, offset…) | ✅ mostly done (live compound shapes: Make, Alt-click a Shape Mode, member modes, Release, Expand (#4522); single-result Pathfinder names and SVG IDs retained (#1293); Divide open-cutting-path geometry, appearance and history verified (#1307; existing segment cap remains); Simplify preview/counts and rewritten-path component selection verified (#1272; the slider opens at the Auto-Simplify level; a Direct Selection part of a path simplifies on its own); Compound appearance and member fill-rule edits verified (#1197); Boolean precision on almost-horizontal edges fixed and the property tests made deterministic; Shape Builder gap detection, large-offset bug open); Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog | 3–6 | -| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); 🟡 Retype phase 1: `type.retype` turns outlined text that exactly matches an available font back into point text (#4934), keeping even spacing as tracking and making stacked, aligned lines one area type object; Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders, vertical type pending | 45–60 | +| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); 🟡 Retype phase 1: `type.retype` turns outlined text that exactly matches an available font back into point text (#4934), keeping even spacing as tracking and making stacked, aligned lines one area type object; Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders done (#1880); vertical type in progress (Type › Type Orientation, #5027) | 45–60 | | M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box | 2–4 | -| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders, vertical type pending | 45–60 | +| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders done (#1880); vertical type in progress (Type › Type Orientation, #5027) | 45–60 | | M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box; #5179 curved-spine redraw bounds include rotated keys and steps (two focused CPU regressions) | 2–4 | | M9 | Live effects (+ 3D & Materials) | 🟡 2D effects done incl. Effect → Pathfinder, Color Adjustments and Document Raster Effects Settings; PDF export warns when the pixel cap lowers raster-effect resolution; Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor and Sketch › Halftone Pattern, Bas Relief, Charcoal, Conté Crayon, Photocopy, Stamp, Torn Edges and Water Paper done (57/57 Photoshop filters); Revolve with automatic smooth vector shading, default-on circular caps and continuous rims, Extrude & Bevel, Inflate and Rotate with one to ten colored directional lights and four original lighting presets, a ring of overlapping faces broken at one of its own faces (#7023); SVG Filters, remaining raster effects and 3D materials and shadows pending | 81–130 | | M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG ``/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | From 82d4ec4336627df6a4ae241f7c3e27eb6ef68b71 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 19:01:56 -0800 Subject: [PATCH 181/264] Scripts: explicit crop boxes, EPS close-with-save and writer receivers checked per call - document.open with an explicit PDFCROPBOX crop opens on the crop box of a file with editing data; the default keeps the trim box and bleed. - Closing with save changes keeps an EPS document's artboard range, since the EPS file holds the whole document. - The script checker treats a writer receiver captured from an outer scope as able to change before each call, and finds the loop that holds a call with a binary search instead of a scan of every loop. --- crates/engine/src/cmd/fileio/pdfimport.rs | 10 +++- crates/engine/src/script/dom/save_open.rs | 6 +- crates/engine/src/tests/script_save_open.rs | 65 +++++++++++++++++++++ crates/scriptcheck/src/analyze/declared.rs | 40 ++++++++++++- crates/scriptcheck/src/analyze/features.rs | 9 ++- crates/scriptcheck/src/tests.rs | 47 +++++++++++++++ 6 files changed, 170 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/fileio/pdfimport.rs b/crates/engine/src/cmd/fileio/pdfimport.rs index 8ffb3f8133..954a345ae0 100644 --- a/crates/engine/src/cmd/fileio/pdfimport.rs +++ b/crates/engine/src/cmd/fileio/pdfimport.rs @@ -22,6 +22,8 @@ pub struct LoadOptions { pub pages: Option, /// The box each page's artboard (or placed frame) gets. pub crop: CropTo, + /// Whether the options explicitly request the crop box. + pub explicit_crop_box: bool, /// The password of an encrypted PDF. pub password: Option, /// The colour mode the document opens in, its colours converted as Document Color Mode does @@ -67,6 +69,7 @@ impl Default for LoadOptions { Self { pages: None, crop: CropTo::default(), + explicit_crop_box: false, password: None, color_mode: None, grays: Grays::default(), @@ -147,6 +150,7 @@ impl LoadOptions { Ok(Self { pages, crop, + explicit_crop_box: crop == CropTo::Crop && crop_to.or(crop_alias).is_some(), password, color_mode, grays, @@ -173,14 +177,14 @@ impl LoadOptions { } /// The PDF import options: `pages` resolved against the file's page count. A PDF-compatible - /// `.ai`, or a PDF saved with its editing data, asked for its crop box opens on its trim boxes, - /// its editor's artboards, with the bleed round them (its crop box takes the bleed in). + /// `.ai`, or a PDF saved with its editing data, opens on its trim boxes by default, + /// with the bleed around them. An explicit crop-box request uses its crop box. fn import_options(&self, opened: &vectorcraft_pdf::Opened, editor_document: bool) -> Result { let pages = match &self.pages { None => None, Some(range) => Some(parse_range(range, opened.page_count()).map_err(|e| err(format!("pages: {e}")))?), }; - let is_ai = self.crop == CropTo::Crop && opened.has_illustrator_data(); + let is_ai = !self.explicit_crop_box && self.crop == CropTo::Crop && opened.has_illustrator_data(); Ok(ImportOptions { pages, crop: if is_ai { CropTo::Trim } else { self.crop }, diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index 9106158e60..09c438040c 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -939,8 +939,12 @@ const SAVES_SOME_ARTBOARDS: &str = /// Whether the file that saving `st` with its remembered options writes would omit artboards. A /// PDF with `useArtboards: false` holds one page of the art's bounds. A native file, or a `.ai` /// file other than a legacy version 7 one, with `separateArtboards` holds every artboard, and its -/// `range` names only the separate files. +/// `range` names only the separate files. An EPS file embeds the whole document in its main file, +/// so its `artboardRange` never omits an artboard from what reopens. fn picks_artboards(st: &crate::doc_state::DocState) -> bool { + if st.format == "eps" { + return false; + } let options = Value::Object(crate::cmd::fileio::remembered_save_options(st)); if matches!(st.format, "svg" | "svgz") && crate::cmd::fileio::svg_lost_artboards_warning(&st.doc, &options, st.format).is_some() { return true; diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index da96519b6e..68183e8637 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -741,6 +741,34 @@ fn crop_only_options_apply_to_an_editable_pdf() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn explicit_crop_box_opens_the_bleed_outside_an_editable_files_trim_box() { + let base = folder("explicitcropbox"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + for extension in ["ai", "pdf"] { + let file = dir.join(format!("editable.{extension}")); + s.execute("file.new", &json!({"width": 100, "height": 50})).unwrap(); + s.execute( + "file.saveAs", + &json!({"path": file.to_string_lossy(), "format": "ai", "preserveEditing": true, + "bleed": {"useDocument": false, "top": 10, "bottom": 10, "left": 10, "right": 10}}), + ) + .unwrap(); + assert!(vectorcraft_pdf::has_illustrator_data(&std::fs::read(&file).unwrap(), None)); + let path = quoted(&file); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}));")); + let default = s.active().unwrap().doc.artboards[0].rect; + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}), undefined, {{pDFCropToBox: PDFBoxType.PDFTRIMBOX}});")); + let trim = s.active().unwrap().doc.artboards[0].rect; + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}), undefined, {{pDFCropToBox: PDFBoxType.PDFCROPBOX}});")); + let crop = s.active().unwrap().doc.artboards[0].rect; + assert_eq!((default.width(), default.height()), (trim.width(), trim.height()), "{extension}"); + assert!(crop.width() > trim.width() && crop.height() > trim.height(), "{extension}"); + } + let _ = std::fs::remove_dir_all(base); +} + #[test] fn script_document_open_rejects_files_over_the_read_limit() { let base = folder("openreadlimit"); @@ -1046,6 +1074,43 @@ fn closing_with_save_changes_checks_the_artboards_the_file_keeps() { let _ = std::fs::remove_dir_all(base); } +#[test] +fn closing_with_save_changes_keeps_all_eps_artboards_for_subset_ranges() { + let base = folder("closeepsboards"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + for (name, range) in [("single", "2"), ("several", "1-2")] { + let file = dir.join(format!("{name}.eps")); + let path = quoted(&file); + logged( + &mut s, + &base, + &format!( + "Folder.userData; var d = app.documents.add(DocumentColorSpace.RGB, 100, 50);\n\ + vc.run('artboard.new', {{x: 150, y: 0, width: 100, height: 50}});\n\ + vc.run('artboard.new', {{x: 300, y: 0, width: 100, height: 50}});\n\ + vc.run('shape.rectangle', {{x: 10, y: 10, width: 20, height: 20}});\n\ + var o = new EPSSaveOptions(); o.saveMultipleArtboards = true; o.artboardRange = '{range}';\n\ + d.saveAs(new File({path}), o);" + ), + ); + let before = std::fs::read(&file).unwrap(); + let nodes = s.active().unwrap().doc.node_count(); + logged( + &mut s, + &base, + "Folder.userData; vc.run('shape.rectangle', {x: 40, y: 10, width: 5, height: 5}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(s.documents().is_empty(), "{range}"); + assert_ne!(std::fs::read(&file).unwrap(), before, "{range}"); + logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}));")); + assert_eq!(s.active().unwrap().doc.artboards.len(), 3, "{range}"); + assert!(s.active().unwrap().doc.node_count() > nodes, "{range}"); + logged(&mut s, &base, "app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);"); + } + let _ = std::fs::remove_dir_all(base); +} + #[test] fn closing_with_save_changes_refuses_svg_artboard_loss_before_writing() { let base = folder("closesvgboards"); diff --git a/crates/scriptcheck/src/analyze/declared.rs b/crates/scriptcheck/src/analyze/declared.rs index 9079c352ef..03ad43ab10 100644 --- a/crates/scriptcheck/src/analyze/declared.rs +++ b/crates/scriptcheck/src/analyze/declared.rs @@ -22,6 +22,33 @@ const HEADS: &[&str] = &["if", "while", "for", "with", "switch"]; /// brackets that spells a longer one sets [`Declared::unsure`]. const PROPERTY_CHARS: usize = 256; +#[cfg(not(test))] +type LoopSpans = Vec<(usize, usize)>; + +#[cfg(test)] +#[derive(Default)] +pub(super) struct LoopSpans { + spans: Vec<(usize, usize)>, + reads: std::cell::Cell, +} + +#[cfg(test)] +impl std::ops::Deref for LoopSpans { + type Target = Vec<(usize, usize)>; + + fn deref(&self) -> &Self::Target { + self.reads.set(self.reads.get() + 1); + &self.spans + } +} + +#[cfg(test)] +impl std::ops::DerefMut for LoopSpans { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.spans + } +} + /// The names a file's function bodies and its global code declare, read before the analysis. A /// function's `var` statements and the function declarations directly in its body make the names /// they declare the function's own before any statement in it runs, and the function declarations @@ -46,7 +73,7 @@ pub(crate) struct Declared<'s> { pub(super) looped: HashMap<(Option, &'s str), Vec>, /// For each outermost loop, the offsets in the text where it starts and ends (`usize::MAX`: at /// the end of the text). - pub(super) loop_spans: Vec<(usize, usize)>, + pub(super) loop_spans: LoopSpans, /// `looped` or `loop_spans` ran out of room, or loops nest past [`crate::Limits::nesting`]: any /// variable may be assigned in a loop. pub(super) looped_full: bool, @@ -60,6 +87,13 @@ pub(crate) struct Declared<'s> { pub(super) unsure: bool, } +#[cfg(test)] +impl Declared<'_> { + pub(crate) fn loop_span_reads(&self) -> usize { + self.loop_spans.reads.get() + } +} + /// A function body [`Declarations`] is reading: the bracket depth inside it, its entry in /// [`Declared::bodies`], the names it declares so far, and the bracket depth of the `var` statement /// the body is in, which goes on when the body closes, and the names assigned in a loop inside it @@ -169,6 +203,10 @@ pub(crate) fn declarations<'s>(src: &'s str, acc: &mut Acc) -> Declared<'s> { d.settle_looped(body); } let mut out = d.out; + for ids in out.looped.values_mut() { + ids.sort_unstable(); + ids.dedup(); + } out.unsure |= out.rebound.contains(catalog::FOLDER); acc.steps = acc.steps.saturating_add(lexer.steps); out diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 8b6b4c5f1d..48db72caad 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -373,13 +373,18 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { fn writer_bits(&self, receiver: Option>, before: Option>, at: Option) -> u8 { match receiver { Some(r) if !self.unsure && r.kind == T::Ident && !member_mark(before) => { + let Some(bits) = self.writers.get(r.text).copied() else { return 0 }; + if at.is_some() && !self.scopes.is_empty() && !self.declared_in_body(r.text) { + return 0; + } let looped = at.is_some_and(|at| { self.declared.looped_full || self.declared.looped.get(&(self.scopes.last().map(|s| s.start), r.text)).is_some_and(|ids| { - ids.iter().any(|id| self.declared.loop_spans.get(*id).is_some_and(|(start, end)| *start <= at && at < *end)) + let next = self.declared.loop_spans.partition_point(|(start, _)| *start <= at); + next.checked_sub(1).is_some_and(|id| at < self.declared.loop_spans[id].1 && ids.binary_search(&id).is_ok()) }) }); - if looped { 0 } else { self.writers.get(r.text).copied().unwrap_or(0) } + if looped { 0 } else { bits } } _ => 0, } diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index a580c3d311..2991b1c23f 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -790,6 +790,34 @@ fn only_a_whole_var_value_makes_save_as_the_scripts_own() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7, 9, 11, 13, 14, 17][..])); } +#[test] +fn writer_calls_after_many_assignment_loops_have_bounded_work() { + for reinitialize in [false, true] { + let mut src = "var d = {saveAs: function () {}};\n".to_string(); + for _ in 0..512 { + src.push_str("while (n--) { d = next(); }\n"); + } + if reinitialize { + src.push_str("var d = {saveAs: function () {}};\n"); + } + src.push_str("var local = {saveAs: function () {}};\n"); + for _ in 0..2048 { + src.push_str("d.saveAs(f); local.saveAs(f);\n"); + } + let limits = Limits::default(); + let mut acc = report::Acc::new(&limits); + let declared = analyze::declarations(&src, &mut acc); + let before = declared.loop_span_reads(); + analyze::scan(&src, &declared, &[], None, std::rc::Rc::from([]), &analyze::Known::default(), &mut acc); + let reads = declared.loop_span_reads() - before; + if reinitialize { + assert!(reads < 16 * 2048, "{reads} span accesses for 2048 calls on d"); + } else { + assert_eq!(reads, 0); + } + } +} + /// A function body read before the literal that assigns its variable without declaring it may run /// after the literal, so the literal's `saveAs` keeps reporting the write; a body that declares the /// name assigns its own variable. @@ -810,6 +838,25 @@ fn a_function_read_earlier_that_assigns_the_variable_keeps_save_as_writing() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 7][..])); } +#[test] +fn captured_writer_receivers_can_change_before_each_call() { + for method in ["saveAs", "exportFile"] { + for call in [format!("d.{method}(f)"), format!("d['{method}'](f)")] { + for (prefix, suffix) in [("", ""), ("function outer() {\n", "}\nouter();\n")] { + let src = format!( + "{prefix}var d = {{{method}: function () {{}}}};\n\ + function save(f) {{ {call}; }}\n\ + d = app.activeDocument; save(f);\n{suffix}" + ); + let r = report(&src); + let line = if prefix.is_empty() { 2 } else { 3 }; + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[line][..]), "{src}"); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[line][..])], "{src}"); + } + } + } +} + #[test] fn captured_reassignments_keep_save_as_writing_after_a_later_initializer() { let r = report(concat!( From 970b34a7276e4257719dbbb6b138637f1aa30c93 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:04:23 -0500 Subject: [PATCH 182/264] feat(nightly): wire craft-nightly for self-isolated direct launch (#10088) * feat(nightly): wire craft-nightly for self-isolated direct launch * fix(nightly): answer plain version before resolving profile root * test(nightly): retain exact version and saved profile coverage --- Cargo.lock | 9 + Cargo.toml | 2 + apps/vectorcraft/Cargo.toml | 1 + apps/vectorcraft/src/build_flavor.rs | 64 +- apps/vectorcraft/src/launch_profile.rs | 285 +++------ apps/vectorcraft/src/main.rs | 76 +-- apps/vectorcraft/src/profile_root.rs | 783 ++++++------------------ apps/vectorcraft/src/single_instance.rs | 4 +- 8 files changed, 315 insertions(+), 909 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cb674e4ae..4fce3ecad1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1816,6 +1816,14 @@ dependencies = [ "encoding_rs", ] +[[package]] +name = "craft-nightly" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24#1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" +dependencies = [ + "winsafe", +] + [[package]] name = "craft-pages" version = "0.1.0" @@ -8522,6 +8530,7 @@ dependencies = [ "chrono", "clipboard-win", "craft", + "craft-nightly", "eframe", "egui", "egui_extras", diff --git a/Cargo.toml b/Cargo.toml index 7ad3e4cfeb..cc76d129c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,8 @@ craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +# Nightly profile isolation, launch protocol, and security fence. +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } diff --git a/apps/vectorcraft/Cargo.toml b/apps/vectorcraft/Cargo.toml index d17c96eaf7..3ec7da1b75 100644 --- a/apps/vectorcraft/Cargo.toml +++ b/apps/vectorcraft/Cargo.toml @@ -22,6 +22,7 @@ vectorcraft-text = { workspace = true } # frame policy and placement store (so VectorCraft matches the rest on Linux, see #217), printing and # the update client. craft = { workspace = true, features = ["ui", "ui-app", "settings", "automation", "platform", "window", "dialogs", "print", "update"] } +craft-nightly = { workspace = true } eframe = { workspace = true, features = ["clipboard", "default_fonts", "wayland", "x11"] } egui = { workspace = true } egui_extras = { workspace = true } diff --git a/apps/vectorcraft/src/build_flavor.rs b/apps/vectorcraft/src/build_flavor.rs index 9450a48972..93876b5cce 100644 --- a/apps/vectorcraft/src/build_flavor.rs +++ b/apps/vectorcraft/src/build_flavor.rs @@ -1,30 +1,13 @@ //! Build-time channel is distinct from a launch selector. A runtime environment cannot promote a -//! stable build, and a nightly build refuses to start without its profile. -use crate::launch_profile::Profile; -use std::ffi::OsString; +//! stable build, and a nightly build self-isolates into its canonical nightly profile root (or the +//! profile root supplied by ArtCraft Launcher). -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum BuildFlavor { - Stable, - NightlyV1, -} +pub use craft_nightly::BuildFlavor; pub const COMPILED: BuildFlavor = if cfg!(vectorcraft_nightly_v1) { BuildFlavor::NightlyV1 } else { BuildFlavor::Stable }; -pub fn require_profile(flavor: BuildFlavor, profile: &Profile) -> Result<(), String> { - match (flavor, profile.is_nightly()) { - (BuildFlavor::NightlyV1, false) => Err("Open VectorCraft Nightly from ArtCraft Launcher".to_string()), - (BuildFlavor::Stable, true) => Err("This is a stable VectorCraft build; nightly-v1 requires the nightly build".to_string()), - _ => Ok(()), - } -} - -pub fn needs_native_error(flavor: BuildFlavor, desktop_session: bool) -> bool { - desktop_session && flavor == BuildFlavor::NightlyV1 -} - -/// `--version` and `-V` on their own, before any other argument is read. -pub fn version_query(args: &[OsString]) -> bool { +/// An exact plain version query, before resolving any profile or environment paths. +pub fn version_query(args: &[std::ffi::OsString]) -> bool { matches!(args, [arg] if arg == "--version" || arg == "-V") } @@ -37,40 +20,19 @@ pub fn version(flavor: BuildFlavor, stable: &str) -> String { #[cfg(test)] mod tests { - use super::*; + use super::{BuildFlavor, version, version_query}; #[test] - fn only_a_nightly_desktop_refusal_requests_a_native_dialog() { - assert!(needs_native_error(BuildFlavor::NightlyV1, true)); - assert!(!needs_native_error(BuildFlavor::NightlyV1, false)); - assert!(!needs_native_error(BuildFlavor::Stable, true)); - assert!(!needs_native_error(BuildFlavor::Stable, false)); - } - - #[test] - fn nightly_build_without_a_profile_is_refused_before_startup() { - let started = std::cell::Cell::new(false); - let result = require_profile(BuildFlavor::NightlyV1, &Profile::Stable).map(|()| started.set(true)); - assert!(result.unwrap_err().contains("ArtCraft Launcher")); - assert!(!started.get()); - } - - #[test] - fn stable_and_nightly_flavors_accept_only_their_own_profile() { - let nightly = Profile::NightlyV1(std::path::PathBuf::from("already validated root")); - assert!(require_profile(BuildFlavor::Stable, &Profile::Stable).is_ok()); - assert!(require_profile(BuildFlavor::Stable, &nightly).is_err()); - assert!(require_profile(BuildFlavor::NightlyV1, &nightly).is_ok()); - assert!(require_profile(BuildFlavor::NightlyV1, &Profile::Stable).is_err()); - } - - #[test] - fn nightly_version_query_is_unambiguous_and_never_reinterprets_file_arguments() { - assert_eq!(version(BuildFlavor::Stable, "0.24.1"), "0.24.1"); - assert_eq!(version(BuildFlavor::NightlyV1, "0.24.1"), "0.24.1 (nightly-v1)"); + fn plain_version_query_is_exact() { assert!(version_query(&["--version".into()])); assert!(version_query(&["-V".into()])); assert!(!version_query(&["--".into(), "--version".into()])); assert!(!version_query(&[])); } + + #[test] + fn version_labels_nightly_without_changing_stable() { + assert_eq!(version(BuildFlavor::Stable, "0.24.1"), "0.24.1"); + assert_eq!(version(BuildFlavor::NightlyV1, "0.24.1"), "0.24.1 (nightly-v1)"); + } } diff --git a/apps/vectorcraft/src/launch_profile.rs b/apps/vectorcraft/src/launch_profile.rs index 12615dd81d..d986f28d71 100644 --- a/apps/vectorcraft/src/launch_profile.rs +++ b/apps/vectorcraft/src/launch_profile.rs @@ -1,130 +1,28 @@ -//! Launcher-owned nightly-v1 bootstrap. Selected before logging, updates, fonts or saved state. -//! Stable launches retain their original arguments and directory policy. -//! -//! The protocol is `vectorcraft --launch-profile nightly-v1 --profile-root -- [files…]`: the -//! selector and the root are separate tokens, exactly once each, and everything after `--` is a file -//! even when it looks like one of them. The Launcher's version check -//! (`… --version`) is answered before the root is validated or touched. +//! Nightly-v1 bootstrap backed by [`craft_nightly`]. Selected before logging, updates, fonts or +//! saved state. Stable launches retain their original arguments and directory policy; direct +//! nightly launches self-isolate into [`craft_nightly::canonical_profile_root`], while ArtCraft +//! Launcher can supply `--launch-profile nightly-v1 --profile-root -- [args…]`. use std::ffi::OsString; -use std::path::{Component, Path, PathBuf}; -use std::sync::OnceLock; -pub const VERSION: &str = "nightly-v1"; +pub use craft_nightly::NIGHTLY_V1_CONTRACT as VERSION; +use craft_nightly::{BuildFlavor, Launch, Profile, ProfileError, StartupOptions}; -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum Profile { - Stable, - NightlyV1(PathBuf), -} - -impl Profile { - pub fn is_nightly(&self) -> bool { - matches!(self, Self::NightlyV1(_)) - } - - pub fn root(&self) -> Option<&Path> { - match self { - Self::Stable => None, - Self::NightlyV1(root) => Some(root), - } - } -} - -#[derive(Debug, PartialEq, Eq)] -pub struct Launch { - pub profile: Profile, - pub args: Vec, -} - -static PROFILE: OnceLock = OnceLock::new(); +static STABLE: Profile = Profile::Stable; pub fn current() -> &'static Profile { - PROFILE.get().unwrap_or(&Profile::Stable) + craft_nightly::current().unwrap_or(&STABLE) } -pub fn install(profile: Profile) -> Result<(), String> { - PROFILE.set(profile).map_err(|_| "the launch profile was already selected".to_string()) -} - -/// Recognize only the agreed literal selector/root pair before `--`. No filesystem or startup hook -/// runs here. -pub fn parse(args: Vec) -> Result { - let mut selector = None; - let mut root = None; - let mut other = Vec::new(); - let mut files = Vec::new(); - let mut iter = args.iter(); - let mut delimiter = false; - while let Some(arg) = iter.next() { - if arg == "--" { - delimiter = true; - files.extend(iter.cloned()); - break; - } - if arg == "--launch-profile" || arg == "--profile-root" { - let slot = if arg == "--launch-profile" { &mut selector } else { &mut root }; - if slot.is_some() { - return Err("the profile selector and root must each occur exactly once".to_string()); - } - let value = iter.next().filter(|v| !v.is_empty()).ok_or_else(|| "the profile selector/root needs a value".to_string())?; - if value.to_string_lossy().starts_with("--") { - return Err("the profile selector/root needs a value".to_string()); - } - *slot = Some(value.clone()); - } else if arg.to_string_lossy().starts_with("--launch-profile=") || arg.to_string_lossy().starts_with("--profile-root=") { - return Err("the nightly protocol requires separate literal selector/root argument tokens".to_string()); - } else { - other.push(arg.clone()); - } - } - match (selector, root) { - (None, None) => Ok(Launch { profile: Profile::Stable, args }), - (Some(version), Some(root)) if version == VERSION => { - if !delimiter || !other.is_empty() { - return Err("nightly-v1 accepts only its selector/root followed by -- and file names".to_string()); - } - let root = PathBuf::from(root); - if !root.is_absolute() || root.components().any(|c| matches!(c, Component::ParentDir)) { - return Err("the nightly profile root must be absolute and contain no parent traversal".to_string()); - } - Ok(Launch { profile: Profile::NightlyV1(root), args: std::iter::once(OsString::from("--")).chain(files).collect() }) - } - (Some(_), Some(_)) => Err("unsupported launch profile (expected nightly-v1)".to_string()), - _ => Err("--launch-profile and --profile-root must be supplied together".to_string()), - } -} - -/// The Launcher's version check: the selector/root pair followed by exactly `--version` (or `-V`), -/// answered like a plain version query. Only [`parse`]'s lexical checks apply; the root is never -/// validated or touched, and `-- --version` stays a file name. -pub fn version_query(args: &[OsString]) -> bool { - let Some((last, pair)) = args.split_last() else { return false }; - if last != "--version" && last != "-V" { - return false; - } - let lexical = pair.iter().cloned().chain(std::iter::once(OsString::from("--"))).collect(); - matches!(parse(lexical), Ok(Launch { profile: Profile::NightlyV1(_), args }) if args.len() == 1) -} - -/// Validation finishes before the caller's first startup effect. Stable never calls the nightly root -/// validator, so its portable and config resolution stays unchanged. -pub fn prepare(mut launch: Launch, validate: impl FnOnce(&Path) -> Result) -> Result { - if let Profile::NightlyV1(root) = &launch.profile { - launch.profile = Profile::NightlyV1(validate(root)?); - } - Ok(launch) -} - -/// Resolve the selected private root before the caller's first startup effect. -pub fn validate_root(root: &Path, env: impl Fn(&str) -> Option, exe: Option<&Path>) -> Result { - crate::profile_root::validate(root, env, exe, crate::prefs_dir::profile::ensure_writable) +pub fn prepare_launch(flavor: BuildFlavor, args: impl IntoIterator) -> Result { + let spec = crate::profile_root::app_profile_spec(); + craft_nightly::prepare_launch(flavor, &spec, args, &StartupOptions::default()) } /// The arguments a child of this process starts with: a nightly launch hands its profile on, so the -/// child opens the same private profile instead of being refused ("Open VectorCraft Nightly…"), and -/// `--` keeps a file whose name starts with '-' a file. Stable's child arguments are unchanged. -/// Only `single_instance` starts a child, and macOS does not build it. +/// child opens the same private profile, and `--` keeps a file whose name starts with '-' a file. +/// Stable's child arguments are unchanged. Only `single_instance` starts a child, and macOS does +/// not build it. #[cfg(not(target_os = "macos"))] pub fn child_args(files: &[String]) -> Vec { child_args_for(current(), files) @@ -132,21 +30,24 @@ pub fn child_args(files: &[String]) -> Vec { #[cfg(not(target_os = "macos"))] fn child_args_for(profile: &Profile, files: &[String]) -> Vec { - let mut args: Vec = match profile { - Profile::Stable => Vec::new(), - Profile::NightlyV1(root) => { - vec![OsString::from("--launch-profile"), OsString::from(VERSION), OsString::from("--profile-root"), root.clone().into_os_string()] - } - }; - args.push(OsString::from("--")); - args.extend(files.iter().map(OsString::from)); - args + let delimited: Vec = std::iter::once(OsString::from("--")).chain(files.iter().map(OsString::from)).collect(); + match profile { + Profile::Stable => delimited, + Profile::NightlyV1(root) => craft_nightly::launch_arguments(root, &delimited), + } } #[cfg(test)] mod tests { - use super::*; - use std::cell::Cell; + use std::ffi::OsString; + use std::path::PathBuf; + + use craft_nightly::{BuildFlavor, Profile, ProfileError, StartupOptions, canonical_profile_root, parse_startup}; + + use super::VERSION; + #[cfg(not(target_os = "macos"))] + use super::child_args_for; + use crate::profile_root::app_profile_spec; fn args(values: &[&str]) -> Vec { values.iter().map(OsString::from).collect() @@ -156,95 +57,72 @@ mod tests { if cfg!(windows) { r"C:\NightlyData\profiles\vectorcraft" } else { "/nightly-data/profiles/vectorcraft" } } - fn nightly() -> Vec { - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--"]) - } - #[test] - fn stable_arguments_and_directory_policy_are_unchanged() { + fn stable_arguments_are_unchanged_and_nightly_flags_are_refused() { + let spec = app_profile_spec(); for argv in [args(&[]), args(&["--new-instance", "a.svg"]), args(&["--", "--launch-profile", "file.svg"])] { - let launch = prepare(parse(argv.clone()).unwrap(), |_| panic!("stable must never validate a nightly root")).unwrap(); - assert_eq!(launch, Launch { profile: Profile::Stable, args: argv }); + let launch = parse_startup(BuildFlavor::Stable, &spec, argv.clone(), &StartupOptions::default()).unwrap(); + assert_eq!(launch.profile, Profile::Stable); + assert_eq!(launch.passthrough_args, argv); } + + let nightly_flags = args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--"]); + let err = parse_startup(BuildFlavor::Stable, &spec, nightly_flags, &StartupOptions::default()).unwrap_err(); + assert!(matches!(err, ProfileError::NightlyFlagsInStableBuild)); } #[test] - fn exact_version_and_root_are_parsed_without_reinterpreting_file_names() { - let mut argv = nightly(); - argv.extend(args(&["--profile-root", "art with spaces.svg"])); - let launch = parse(argv).unwrap(); + fn nightly_direct_launch_self_isolates_into_canonical_profile_root() { + let spec = app_profile_spec(); + let expected_root = canonical_profile_root("vectorcraft").unwrap(); + + let empty = parse_startup(BuildFlavor::NightlyV1, &spec, Vec::new(), &StartupOptions::default()).unwrap(); + assert_eq!(empty.profile, Profile::NightlyV1(expected_root.clone())); + assert!(empty.passthrough_args.is_empty()); + + let with_args = parse_startup(BuildFlavor::NightlyV1, &spec, args(&["--safe-mode", "art.svg"]), &StartupOptions::default()).unwrap(); + assert_eq!(with_args.profile, Profile::NightlyV1(expected_root)); + assert_eq!(with_args.passthrough_args, args(&["--safe-mode", "art.svg"])); + } + + #[test] + fn explicit_launcher_arguments_preserve_profile_root_and_user_args() { + let spec = app_profile_spec(); + let argv = args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--", "--profile-root", "art with spaces.svg"]); + let launch = parse_startup(BuildFlavor::NightlyV1, &spec, argv, &StartupOptions::default()).unwrap(); assert_eq!(launch.profile, Profile::NightlyV1(PathBuf::from(absolute()))); - assert_eq!(launch.args, args(&["--", "--profile-root", "art with spaces.svg"])); + assert_eq!(launch.passthrough_args, args(&["--profile-root", "art with spaces.svg"])); } #[test] - fn missing_duplicate_unknown_and_conflicting_profile_arguments_are_refused() { - for argv in [ - args(&["--launch-profile", VERSION]), - args(&["--profile-root", absolute()]), - args(&["--launch-profile", "future-v2", "--profile-root", absolute(), "--"]), - args(&["--launch-profile", VERSION, "--launch-profile", VERSION, "--profile-root", absolute(), "--"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--profile-root", absolute(), "--"]), - args(&["--launch-profile", VERSION, "--profile-root", "relative", "--"]), - args(&["--launch-profile", VERSION, "--profile-root", "../escape", "--"]), - args(&["--launch-profile", VERSION, "--profile-root", "", "--"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--new-instance", "--"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute()]), - ] { - assert!(parse(argv.clone()).is_err(), "{argv:?}"); - } - } - - #[test] - fn the_launcher_version_check_is_a_version_query_only_in_its_exact_form() { - let pair = &["--launch-profile", VERSION, "--profile-root", absolute()]; - let reversed = &["--profile-root", absolute(), "--launch-profile", VERSION]; + fn version_queries_are_recognized_plain_and_via_launcher() { + let spec = app_profile_spec(); for flag in ["--version", "-V"] { - for form in [pair, reversed] { - let mut argv = args(form); - argv.push(flag.into()); - assert!(version_query(&argv), "{argv:?}"); + for argv in [ + args(&[flag]), + args(&["--launch-profile", VERSION, "--profile-root", absolute(), flag]), + args(&["--profile-root", absolute(), "--launch-profile", VERSION, flag]), + args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--", flag]), + ] { + let launch = parse_startup(BuildFlavor::NightlyV1, &spec, argv.clone(), &StartupOptions::default()).unwrap(); + assert!(launch.is_version_query(), "{argv:?}"); } } - for argv in [ - args(&["--version"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--", "--version"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--version", "--"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--new-instance", "--version"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--version", "--version"]), - args(&["--version", "--launch-profile", VERSION, "--profile-root", absolute()]), - args(&["--launch-profile", "future-v2", "--profile-root", absolute(), "--version"]), - args(&["--launch-profile", VERSION, "--profile-root", "relative", "--version"]), - args(&["--launch-profile", VERSION, "--version"]), - args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--help"]), - ] { - assert!(!version_query(&argv), "{argv:?}"); - } - // Outside the query the strict protocol still refuses the version flag. - assert!(parse(args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--version"])).is_err()); } #[test] - fn failed_root_validation_never_reaches_startup_or_falls_back_to_stable() { - let reached = Cell::new(false); - let result = prepare(parse(nightly()).unwrap(), |_| Err("read-only or unsafe profile".to_string())).map(|_| reached.set(true)); - assert!(result.is_err()); - assert!(!reached.get()); - } - - #[test] - fn successful_root_validation_keeps_the_persistent_root_not_the_binary_tag() { - let checked = PathBuf::from(absolute()).join("checked"); - let launch = prepare(parse(nightly()).unwrap(), |_| Ok(checked.clone())).unwrap(); - assert_eq!(launch.profile.root(), Some(checked.as_path())); - assert!(launch.profile.is_nightly()); - } - - #[test] - fn a_joined_flag_form_is_refused() { - for joined in [format!("--launch-profile={VERSION}"), format!("--profile-root={}", absolute())] { - let argv = vec![OsString::from(joined), OsString::from("--")]; - assert!(parse(argv).is_err()); + fn version_and_document_arguments_are_not_a_version_only_query() { + let spec = app_profile_spec(); + for flag in ["--version", "-V"] { + for argv in [ + args(&[flag, "art with spaces.svg"]), + args(&["--launch-profile", VERSION, "--profile-root", absolute(), flag, "art with spaces.svg"]), + args(&["--profile-root", absolute(), "--launch-profile", VERSION, flag, "art with spaces.svg"]), + ] { + let launch = parse_startup(BuildFlavor::NightlyV1, &spec, argv, &StartupOptions::default()).unwrap(); + assert!(!launch.is_version_query()); + assert_eq!(launch.passthrough_args, args(&[flag, "art with spaces.svg"])); + } } } @@ -258,6 +136,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] fn a_nightly_child_inherits_the_selected_profile() { + let spec = app_profile_spec(); let root = PathBuf::from(absolute()); let child = child_args_for(&Profile::NightlyV1(root.clone()), &["art.svg".to_string()]); let expected = vec![ @@ -266,12 +145,12 @@ mod tests { OsString::from("--profile-root"), root.into_os_string(), OsString::from("--"), + OsString::from("--"), OsString::from("art.svg"), ]; assert_eq!(child, expected); - // The child's own parse finds the same profile and the file list. - let launch = parse(child).unwrap(); + let launch = parse_startup(BuildFlavor::NightlyV1, &spec, child, &StartupOptions::default()).unwrap(); assert!(launch.profile.is_nightly()); - assert_eq!(launch.args, args(&["--", "art.svg"])); + assert_eq!(launch.passthrough_args, args(&["--", "art.svg"])); } } diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 5a7d3e33ba..601cda01bb 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -384,58 +384,47 @@ fn channel_name() -> &'static str { /// Says why a nightly launch was refused, then exits 2. A window could not have shown it yet: this /// app has no message box of its own before eframe starts (its dialogs are egui windows), so the -/// text goes to standard error, which a Launcher launch records. The desktop-session test still -/// decides whether a daily user would have seen it, for the message's wording. +/// text goes to standard error, which a Launcher launch records. fn report_launch_profile_error(error: &str) { eprintln!("VectorCraft launch profile: {error}"); - let desktop_session = cfg!(windows) - || cfg!(target_os = "macos") - || (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty()))); - if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) { - eprintln!("VectorCraft Nightly: open it from ArtCraft Launcher, which starts it in its own profile"); - } +} + +fn write_nightly_version() { + use std::io::Write as _; + let line = format!("VectorCraft {}\n", build_flavor::version(build_flavor::COMPILED, env!("VECTORCRAFT_BUILT_VERSION"))); + let _ = std::io::stdout().write_all(line.as_bytes()); } /// Selects the immutable launch profile before any startup service or side effect, and returns the /// arguments the rest of `main` reads. `None` means the process ends here (`--version` answered). fn prepare_launch() -> Option> { - // The trusted Launcher protocol is decided before the logger, updates, fonts or any saved state. + // The launch profile is decided before the logger, updates, fonts or any saved state. let argv: Vec<_> = std::env::args_os().skip(1).collect(); - // A nightly answers its version before root validation, process identity, IPC or any window: - // plain `--version`/`-V`, or the Launcher's `--launch-profile nightly-v1 --profile-root - // --version`. A stable build leaves the answer to `read_command_line`, exactly as before. - if build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1 && (build_flavor::version_query(&argv) || launch_profile::version_query(&argv)) - { - use std::io::Write as _; - let line = format!("VectorCraft {}\n", build_flavor::version(build_flavor::COMPILED, env!("VECTORCRAFT_BUILT_VERSION"))); - let _ = std::io::stdout().write_all(line.as_bytes()); + // A plain nightly version query does not even need the OS home/data root to resolve. + if build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1 && build_flavor::version_query(&argv) { + write_nightly_version(); + return None; + } + let early = launch_profile::prepare_launch(build_flavor::COMPILED, argv).unwrap_or_else(|error| { + report_launch_profile_error(&error.to_string()); + std::process::exit(2) + }); + // A launcher version query also exits before process identity, IPC or any window. + // `craft_nightly::prepare_launch` skips root preparation for version queries. + // A stable build leaves the answer to `read_command_line`, exactly as before. + if build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1 && early.is_version_query() { + write_nightly_version(); return None; } - let early = launch_profile::parse(argv) - .and_then(|launch| { - build_flavor::require_profile(build_flavor::COMPILED, &launch.profile)?; - Ok(launch) - }) - .and_then(|launch| { - launch_profile::prepare(launch, |root| { - launch_profile::validate_root(root, |key| std::env::var_os(key), std::env::current_exe().ok().as_deref()) - }) - }) - .unwrap_or_else(|error| { - report_launch_profile_error(&error); - std::process::exit(2) - }); let nightly = early.profile.is_nightly(); let identity = if nightly { vectorcraft_ui_egui::os_window::LaunchIdentity::NightlyV1 } else { vectorcraft_ui_egui::os_window::LaunchIdentity::Stable }; - let install = launch_profile::install(early.profile).and_then(|()| { - // Every data path follows the selected profile from here on: settings, logs, recovery, the - // user's libraries, plug-ins, caches and the single-instance record. - if let Some(root) = launch_profile::current().root() { - prefs_dir::profile::install_data_root(root.to_path_buf())?; - } - vectorcraft_ui_egui::os_window::select_identity(identity) - }); + // Every data path follows the selected profile from here on: settings, logs, recovery, the + // user's libraries, plug-ins, caches and the single-instance record. + let install = launch_profile::current() + .root() + .map_or(Ok(()), |root| prefs_dir::profile::install_data_root(root.to_path_buf())) + .and_then(|()| vectorcraft_ui_egui::os_window::select_identity(identity)); if let Err(error) = install { report_launch_profile_error(&error); std::process::exit(2); @@ -453,11 +442,11 @@ fn prepare_launch() -> Option> { // The window's identity, not the profile, failed: main's own failure status (1). std::process::exit(1); } - Some(early.args) + Some(early.passthrough_args) } /// The arguments the rest of `main` reads: a nightly's profile tokens were consumed by -/// `prepare_launch`, so what is left is `--` and the files to open. A stable launch reads its +/// `prepare_launch`, leaving any user flags and files to open. A stable launch reads its /// arguments exactly as it always did. fn launch_arguments(nightly: bool, arguments: &[std::ffi::OsString]) -> Vec { if nightly { arguments.iter().map(|a| a.to_string_lossy().into_owned()).collect() } else { std::env::args().skip(1).collect() } @@ -520,8 +509,9 @@ fn finish_pending_update(nightly: bool) { } fn main() -> std::process::ExitCode { - // The launch profile first: a nightly build without one is refused here, before the update - // helper, the logger, fonts or any saved state, and `--version` is answered here too. + // The launch profile first: a nightly build self-isolates or uses the Launcher's profile here, + // before the update helper, the logger, fonts or any saved state, and `--version` is answered + // here too. let Some(arguments) = prepare_launch() else { return std::process::ExitCode::SUCCESS }; let nightly = launch_profile::current().is_nightly(); #[cfg(windows)] diff --git a/apps/vectorcraft/src/profile_root.rs b/apps/vectorcraft/src/profile_root.rs index 7f46e77766..d5ae707a17 100644 --- a/apps/vectorcraft/src/profile_root.rs +++ b/apps/vectorcraft/src/profile_root.rs @@ -1,264 +1,17 @@ -//! App-owned nightly profile fences: a profile every one of VectorCraft's data paths is redirected -//! into ([`crate::prefs_dir::profile::install_data_root`]), and that never overlaps stable's folders, a portable -//! copy or an installation. +//! App-owned nightly profile specification for [`craft_nightly`]: describes VectorCraft's stable +//! directories, forbidden environment variables, portable markers, folder-only profile entries, and +//! extra installation/package boundaries so a nightly profile never overlaps stable state. use std::ffi::OsString; -use std::path::{Component, Path, PathBuf}; +use std::path::{Path, PathBuf}; -use crate::prefs_dir::profile::PORTABLE_DATA_DIR; +use craft_nightly::AppProfileSpec; -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -enum Platform { - Windows, - Linux, - Mac, -} +use crate::prefs_dir::profile::{PORTABLE_DATA_DIR, PORTABLE_MARKERS}; -impl Platform { - fn current() -> Result { - match std::env::consts::OS { - "windows" => Ok(Self::Windows), - "linux" => Ok(Self::Linux), - "macos" => Ok(Self::Mac), - other => Err(format!("nightly-v1 is not defined for this operating system ({other})")), - } - } +const STABLE_DIR_NAMES: [&str; 2] = ["VectorCraft", "vectorcraft"]; - fn ignores_case(self) -> bool { - self != Self::Linux - } -} - -fn absolute(path: PathBuf, label: &str) -> Result { - if !path.is_absolute() || path.components().any(|c| matches!(c, Component::ParentDir)) { - return Err(format!("{label} must be absolute and contain no parent traversal")); - } - Ok(path) -} - -fn required_base(env: &impl Fn(&str) -> Option, key: &str) -> Result { - let value = env(key).filter(|v| !v.is_empty()).ok_or_else(|| format!("cannot establish the stable {key} boundary"))?; - absolute(PathBuf::from(value), key) -} - -fn xdg_base(env: &impl Fn(&str) -> Option, key: &str, fallback: &str) -> Result { - match env(key).filter(|v| !v.is_empty()) { - Some(value) => absolute(PathBuf::from(value), key), - None => Ok(required_base(env, "HOME")?.join(fallback)), - } -} - -/// Resolve existing ancestors before creating anything. A dangling link or an inaccessible ancestor -/// is not a missing directory that may be replaced or followed later. -fn canonical_future(path: &Path) -> Result { - let mut parent = path; - let mut missing = Vec::new(); - loop { - match std::fs::symlink_metadata(parent) { - Ok(_) => break, - Err(error) if error.kind() == std::io::ErrorKind::NotFound => { - missing.push(parent.file_name().ok_or_else(|| "the profile root has no existing ancestor".to_string())?.to_os_string()); - parent = parent.parent().ok_or_else(|| "the profile root has no existing ancestor".to_string())?; - } - Err(error) => return Err(format!("cannot inspect the profile boundary: {error}")), - } - } - let mut resolved = std::fs::canonicalize(parent).map_err(|e| format!("cannot resolve the profile boundary: {e}"))?; - for part in missing.into_iter().rev() { - resolved.push(part); - } - Ok(resolved) -} - -/// A stable entry point may be a dangling link once its target is uninstalled. Its own name is still -/// the fence, so only the folder it lives in is resolved: a link that cannot be resolved would refuse -/// every launch, a valid private profile included. -fn canonical_future_entry(path: &Path) -> Result { - let parent = path.parent().ok_or_else(|| "an entry point has no folder".to_string())?; - let name = path.file_name().ok_or_else(|| "an entry point has no name".to_string())?; - Ok(canonical_future(parent)?.join(name)) -} - -fn overlaps(a: &Path, b: &Path, platform: Platform) -> bool { - let parts = |p: &Path| { - p.components() - .map(|c| { - let value = c.as_os_str().to_string_lossy().into_owned(); - if platform.ignores_case() { value.to_lowercase() } else { value } - }) - .collect::>() - }; - let (a, b) = (parts(a), parts(b)); - a.starts_with(&b) || b.starts_with(&a) -} - -fn installation_boundary(platform: Platform, exe: &Path) -> Result { - let parent = exe.parent().ok_or_else(|| "cannot establish the installation boundary".to_string())?; - if platform == Platform::Mac { - // A profile in Resources is still inside the versioned install, not beside MacOS. - if let Some(bundle) = exe.ancestors().find(|p| p.extension().is_some_and(|ext| ext.eq_ignore_ascii_case("app"))) { - return Ok(bundle.to_path_buf()); - } - } - Ok(parent.to_path_buf()) -} - -/// Every folder a stable VectorCraft keeps user state in, on `platform`: the settings folder each -/// platform convention and the portable layout use, the eframe window state, the logs, the recovery -/// copies, the plug-ins, the caches, the install folders and the entry points. A nightly profile that -/// overlapped any of them would read, rewrite or prune stable's own state. -fn forbidden_roots(platform: Platform, env: &impl Fn(&str) -> Option, exe: &Path) -> Result, String> { - let mut roots = match platform { - Platform::Windows => { - // The settings folder (`profile.rs`) and the eframe window state, which eframe puts under - // `%APPDATA%\ai.storyteller.vectorcraft\data` (the window id). - let mut roots = ["APPDATA", "LOCALAPPDATA"] - .into_iter() - .map(|key| required_base(env, key).map(|p| p.join("VectorCraft"))) - .collect::, _>>()?; - roots.push(required_base(env, "APPDATA")?.join("ai.storyteller.vectorcraft")); - // The MSI's default per-user and per-machine folders (install-policy.wxi). A custom - // install folder is not known here; the executable's own folder is fenced below. - roots.push(required_base(env, "LOCALAPPDATA")?.join("Programs").join("ArtCraft").join("VectorCraft")); - for key in ["ProgramW6432", "ProgramFiles", "ProgramFiles(x86)"] { - if let Some(base) = env(key).filter(|v| !v.is_empty()) { - roots.push(absolute(PathBuf::from(base), key)?.join("ArtCraft").join("VectorCraft")); - } - } - roots - } - Platform::Linux => { - let mut roots = - [("XDG_CONFIG_HOME", ".config"), ("XDG_DATA_HOME", ".local/share"), ("XDG_CACHE_HOME", ".cache"), ("XDG_STATE_HOME", ".local/state")] - .into_iter() - .map(|(key, fallback)| xdg_base(env, key, fallback).map(|p| p.join("vectorcraft"))) - .collect::, _>>()?; - // The eframe window state, under the lowercased window id. - roots.push(xdg_base(env, "XDG_DATA_HOME", ".local/share")?.join("ai.storyteller.vectorcraft")); - roots.push(required_base(env, "HOME")?.join(".config").join("VectorCraft")); - // The same folders at their HOME defaults: an XDG override moves this launch's own paths, - // not stable's, which stays where a launch without the override finds it. - for (directory, app) in - [(".config", "vectorcraft"), (".local/share", "vectorcraft"), (".cache", "vectorcraft"), (".local/state", "vectorcraft")] - { - roots.push(required_base(env, "HOME")?.join(directory).join(app)); - } - // The stable Flatpak keeps its data in its own per-app folder. - roots.push(required_base(env, "HOME")?.join(".var/app/ai.storyteller.vectorcraft")); - roots - } - Platform::Mac => { - let home = required_base(env, "HOME")?; - let library = home.join("Library"); - vec![ - library.join("Application Support/VectorCraft"), - library.join("Application Support/ai.storyteller.vectorcraft"), - library.join("Caches/VectorCraft"), - library.join("Caches/ai.storyteller.vectorcraft"), - library.join("Preferences/VectorCraft"), - library.join("Preferences/ai.storyteller.vectorcraft.plist"), - library.join("Saved Application State/ai.storyteller.vectorcraft.savedState"), - home.join("Applications/VectorCraft.app"), - PathBuf::from("/Applications/VectorCraft.app"), - ] - } - }; - roots.push(installation_boundary(platform, exe)?); - let mut fences = roots.into_iter().map(|p| canonical_future(&p)).collect::, _>>()?; - if platform == Platform::Linux { - for entry in ["/usr/bin/vectorcraft", "/usr/local/bin/vectorcraft", "/opt/vectorcraft"] { - fences.push(canonical_future_entry(Path::new(entry))?); - } - } - Ok(fences) -} - -fn private_subdirectory(root: &Path, name: impl AsRef, label: &str) -> Result { - let chosen = canonical_future(&absolute(root.to_path_buf(), "the nightly profile root")?)?; - let target = chosen.join(name); - match std::fs::symlink_metadata(&target) { - Ok(metadata) if !metadata.is_dir() => { - return Err(format!("the nightly {label} must be a directory inside its selected profile")); - } - Ok(_) => {} - Err(error) if error.kind() == std::io::ErrorKind::NotFound => {} - Err(error) => return Err(format!("cannot inspect the nightly {label}: {error}")), - } - let child = canonical_future(&target)?; - if child == chosen || !child.starts_with(&chosen) { - return Err(format!("the nightly {label} must stay inside its selected profile")); - } - Ok(child) -} - -/// Every existing entry directly in the profile (settings, logs, the user's libraries and so on) must -/// resolve inside it, so a link there cannot point Nightly's writes at another app's data. -fn entries_stay_inside(root: &Path) -> Result<(), String> { - let entries = match std::fs::read_dir(root) { - Ok(entries) => entries, - Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()), - Err(error) => return Err(format!("cannot inspect the nightly profile: {error}")), - }; - for entry in entries { - let entry = entry.map_err(|e| format!("cannot inspect the nightly profile: {e}"))?; - let path = entry.path(); - let metadata = std::fs::symlink_metadata(&path).map_err(|e| format!("cannot inspect the nightly profile: {e}"))?; - // Settings and session state are ordinary files, not directories. Keep the existing - // directory-boundary check for folders (including the known folder-only entries). - let folder_only = PROFILE_FOLDERS.iter().any(|name| entry.file_name().eq_ignore_ascii_case(name)); - if metadata.is_file() && !folder_only { - private_regular_file(&path, &metadata)?; - } else { - private_subdirectory(root, entry.file_name(), "profile entry")?; - } - } - Ok(()) -} - -/// Persisted files must have their own ordinary file identity, not an alias to other data. -fn private_regular_file(path: &Path, metadata: &std::fs::Metadata) -> Result<(), String> { - #[cfg(unix)] - { - use std::os::unix::fs::MetadataExt as _; - if metadata.nlink() != 1 { - return Err("the nightly profile file must not be shared".into()); - } - } - #[cfg(all(windows, feature = "wgpu"))] - { - use winsafe::{HFILE, co}; - let (file, _) = HFILE::CreateFile( - path.to_str().ok_or("the nightly profile file path is not textual")?, - co::GENERIC::default(), - Some(co::FILE_SHARE::READ | co::FILE_SHARE::WRITE | co::FILE_SHARE::DELETE), - None, - co::DISPOSITION::OPEN_EXISTING, - co::FILE_ATTRIBUTE::NORMAL, - Some(co::FILE_FLAG::OPEN_REPARSE_POINT), - None, - None, - ) - .map_err(|e| e.to_string())?; - let info = file.GetFileInformationByHandle().map_err(|e| e.to_string())?; - if info.dwFileAttributes.has(co::FILE_ATTRIBUTE::REPARSE_POINT) || info.dwFileAttributes.has(co::FILE_ATTRIBUTE::DIRECTORY) { - return Err("the nightly profile file must not be an alias or directory".into()); - } - if info.nNumberOfLinks != 1 { - return Err("the nightly profile file must not be shared".into()); - } - } - #[cfg(all(windows, not(feature = "wgpu")))] - { - use std::os::windows::fs::MetadataExt as _; - const FILE_ATTRIBUTE_DIRECTORY: u32 = 0x10; - const FILE_ATTRIBUTE_REPARSE_POINT: u32 = 0x400; - if metadata.file_attributes() & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT) != 0 { - return Err("the nightly profile file must not be an alias or directory".into()); - } - } - let _ = (path, metadata); - Ok(()) -} +const FORBIDDEN_ENV_VARS: [&str; 2] = ["VECTORCRAFT_CONFIG_DIR", "VECTORCRAFT_NO_PREFS"]; const PROFILE_FOLDERS: [&str; 18] = [ "Data Recovery", @@ -281,397 +34,207 @@ const PROFILE_FOLDERS: [&str; 18] = [ "Libraries", ]; -/// Recognise the shared portable data namespace in both the supplied and the resolved path. Up to -/// the chosen folder itself, a marker only counts beside a VectorCraft executable, so an unrelated -/// `portable.txt` higher up (in a user folder or at a drive root) does not refuse the profile. -fn is_portable_layout(path: &Path, platform: Platform) -> bool { - path.ancestors().enumerate().any(|(depth, ancestor)| { - crate::prefs_dir::profile::PORTABLE_MARKERS.iter().any(|marker| ancestor.join(marker).is_file()) - && (depth == 0 || ["vectorcraft.exe", "vectorcraft"].iter().any(|exe| ancestor.join(exe).is_file())) - }) || path.components().any(|component| match component { - Component::Normal(name) if platform.ignores_case() => name.to_string_lossy().eq_ignore_ascii_case(PORTABLE_DATA_DIR), - Component::Normal(name) => name == PORTABLE_DATA_DIR, - _ => false, - }) +/// Builds VectorCraft's [`AppProfileSpec`] for [`craft_nightly`]. +pub fn app_profile_spec() -> AppProfileSpec { + AppProfileSpec { + app_id: vectorcraft_ui_egui::os_window::SETTINGS_APP_ID, + display_name: vectorcraft_ui_egui::os_window::APP_NAME, + stable_dir_names: &STABLE_DIR_NAMES, + stable_package_id: vectorcraft_ui_egui::os_window::APP_ID, + nightly_package_id: vectorcraft_ui_egui::os_window::NIGHTLY_PACKAGE_ID, + profile_root_env: None, + forbidden_env_vars: &FORBIDDEN_ENV_VARS, + portable_markers: &PORTABLE_MARKERS, + folder_only_entries: &PROFILE_FOLDERS, + extra_forbidden_roots: extra_forbidden_roots(), + } } -/// The writable hook is the app's own exclusive probe ([`crate::prefs_dir::profile::ensure_writable`]). Keeping -/// it injected lets the boundary tests exercise the real policy without starting the app. -pub fn validate( - root: &Path, - env: impl Fn(&str) -> Option, - exe: Option<&Path>, - writable: impl FnOnce(&Path) -> std::io::Result<()>, -) -> Result { - validate_for(Platform::current()?, root, env, exe, writable) +fn non_empty_abs(env: &impl Fn(&str) -> Option, key: &str) -> Option { + let value = env(key)?; + if value.is_empty() { + return None; + } + let path = PathBuf::from(value); + path.is_absolute().then_some(path) } -fn validate_for( - platform: Platform, - root: &Path, - env: impl Fn(&str) -> Option, - exe: Option<&Path>, - writable: impl FnOnce(&Path) -> std::io::Result<()>, -) -> Result { - absolute(root.to_path_buf(), "the nightly profile root")?; - if env("VECTORCRAFT_CONFIG_DIR").is_some_and(|v| !v.is_empty()) { - return Err("nightly-v1 cannot be combined with VECTORCRAFT_CONFIG_DIR".to_string()); - } - // The app turns preferences off whenever the variable is present, empty value included. - if env("VECTORCRAFT_NO_PREFS").is_some() { - // A run without preferences keeps nothing: its own profile would stay unused and the app - // would log to standard error only, so it is never a nightly launch. - return Err("nightly-v1 cannot inherit VECTORCRAFT_NO_PREFS".to_string()); - } - let nightly_flatpak = vectorcraft_ui_egui::os_window::NIGHTLY_PACKAGE_ID; - if platform != Platform::Windows - && let Some(id) = env("FLATPAK_ID").filter(|value| !value.is_empty()) - && id.to_string_lossy().as_ref() != nightly_flatpak +fn extra_forbidden_roots() -> Vec { + extra_forbidden_roots_with(|key| std::env::var_os(key), std::env::current_exe().ok().as_deref()) +} + +fn extra_forbidden_roots_with(env: impl Fn(&str) -> Option, exe: Option<&Path>) -> Vec { + let mut roots = Vec::new(); + + #[cfg(target_os = "windows")] { - // `packaging/linux/flatpak-bundle.sh` builds VectorCraft Nightly as its own Flatpak - // (`ai.storyteller.vectorcraft.nightly`), whose sandbox is already a private home. Any other - // instance, the stable app's included, would put this profile inside another app's tree. - return Err(format!("nightly-v1 can only run inside its own Flatpak instance ({nightly_flatpak}), not {}", id.to_string_lossy())); + if let Some(local) = non_empty_abs(&env, "LOCALAPPDATA") { + roots.push(local.join("Programs").join("ArtCraft").join("VectorCraft")); + } + for key in ["ProgramW6432", "ProgramFiles", "ProgramFiles(x86)"] { + if let Some(base) = non_empty_abs(&env, key) { + roots.push(base.join("ArtCraft").join("VectorCraft")); + } + } } - let chosen = canonical_future(root)?; - if is_portable_layout(root, platform) || is_portable_layout(&chosen, platform) { - return Err("the nightly root must not use a portable VectorCraft installation or its VectorCraftData settings folder".to_string()); - } - let exe = absolute(exe.ok_or_else(|| "cannot establish the installation boundary".to_string())?.to_path_buf(), "the executable")?; - let forbidden = forbidden_roots(platform, &env, &exe)?; - if forbidden.iter().any(|stable| overlaps(&chosen, stable, platform)) { - return Err("the nightly root must not overlap stable data or an installation".to_string()); - } - // Data Recovery can read, adopt, overwrite and sweep entries: never let its alias leave the - // private profile. - private_subdirectory(&chosen, "Data Recovery", "recovery folder")?; - entries_stay_inside(&chosen)?; - let mut create = std::fs::DirBuilder::new(); - create.recursive(true); - #[cfg(unix)] + + #[cfg(all(unix, not(target_os = "macos")))] { - use std::os::unix::fs::DirBuilderExt as _; - create.mode(0o700); + if let Some(home) = non_empty_abs(&env, "HOME") { + roots.push(home.join(".var").join("app").join(vectorcraft_ui_egui::os_window::APP_ID)); + } + for entry in ["/usr/bin/vectorcraft", "/usr/local/bin/vectorcraft", "/opt/vectorcraft"] { + roots.push(PathBuf::from(entry)); + } } - create.create(&chosen).map_err(|e| format!("cannot create the nightly profile: {e}"))?; - let confirmed = std::fs::canonicalize(&chosen).map_err(|e| format!("cannot resolve the created nightly profile: {e}"))?; - if confirmed != chosen || forbidden.iter().any(|stable| overlaps(&confirmed, stable, platform)) { - return Err("the nightly profile changed while it was being validated".to_string()); + + #[cfg(target_os = "macos")] + { + if let Some(home) = non_empty_abs(&env, "HOME") { + let library = home.join("Library"); + roots.push(library.join("Preferences").join(format!("{}.plist", vectorcraft_ui_egui::os_window::APP_ID))); + roots.push(library.join("Saved Application State").join(format!("{}.savedState", vectorcraft_ui_egui::os_window::APP_ID))); + roots.push(home.join("Applications").join("VectorCraft.app")); + } + roots.push(PathBuf::from("/Applications/VectorCraft.app")); } - private_subdirectory(&confirmed, "Data Recovery", "recovery folder")?; - entries_stay_inside(&confirmed)?; - writable(&confirmed).map_err(|e| format!("the nightly profile is not writable: {e}"))?; - Ok(confirmed) + + if let Some(exe) = exe { + if let Some(parent) = exe.parent() { + roots.push(parent.join(PORTABLE_DATA_DIR)); + } + #[cfg(target_os = "macos")] + if let Some(bundle_parent) = exe.ancestors().find(|p| p.extension().is_some_and(|ext| ext.eq_ignore_ascii_case("app"))).and_then(Path::parent) + { + roots.push(bundle_parent.join(PORTABLE_DATA_DIR)); + } + } + + roots } #[cfg(test)] mod tests { - use super::*; - use std::cell::Cell; - use std::collections::BTreeMap; - use std::sync::atomic::{AtomicU64, Ordering}; + use std::ffi::OsString; + use std::fs; + #[cfg(unix)] + use std::path::PathBuf; - /// An owned fixture tree: a home, a roaming/local app-data pair and an install folder, so the - /// fence can be checked for every platform on any host. - struct Fixture { - root: PathBuf, - env: BTreeMap, - exe: PathBuf, - } + use craft_nightly::validate_and_prepare_root; - impl Fixture { - fn new() -> Self { - static NEXT: AtomicU64 = AtomicU64::new(0); - let root = loop { - let candidate = - std::env::temp_dir().join(format!("vectorcraft-profile-policy-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); - match std::fs::create_dir(&candidate) { - Ok(()) => break std::fs::canonicalize(candidate).unwrap(), - Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue, - Err(error) => panic!("cannot create owned fixture: {error}"), - } - }; - let home = root.join("home"); - let exe = root.join("install/vectorcraft"); - std::fs::create_dir_all(&home).unwrap(); - std::fs::create_dir_all(exe.parent().unwrap()).unwrap(); - std::fs::write(&exe, b"fixture executable, never run").unwrap(); - let env = [("HOME", home), ("APPDATA", root.join("roaming")), ("LOCALAPPDATA", root.join("local"))] - .into_iter() - .map(|(key, value)| (key.into(), value.into_os_string())) - .collect(); - Self { root, env, exe } - } - - fn get(&self, key: &str) -> Option { - self.env.get(key).cloned() - } - - fn home(&self) -> PathBuf { - PathBuf::from(self.get("HOME").unwrap()) - } - - fn check(&self, platform: Platform, root: &Path) -> Result { - self.check_with(platform, root, |_| Ok(())) - } - - fn check_with(&self, platform: Platform, root: &Path, writable: impl FnOnce(&Path) -> std::io::Result<()>) -> Result { - validate_for(platform, root, |key| self.get(key), Some(&self.exe), writable) - } - } - - impl Drop for Fixture { - fn drop(&mut self) { - // Only the directory this fixture created is owned for removal. - std::fs::remove_dir_all(&self.root).unwrap(); - } - } - - const PLATFORMS: [Platform; 3] = [Platform::Windows, Platform::Linux, Platform::Mac]; + use super::{FORBIDDEN_ENV_VARS, PROFILE_FOLDERS, STABLE_DIR_NAMES, app_profile_spec, extra_forbidden_roots_with}; + use crate::prefs_dir::profile::{PORTABLE_DATA_DIR, PORTABLE_MARKERS}; #[test] - fn a_private_profile_is_accepted_on_every_platform() { - let fixture = Fixture::new(); - for platform in PLATFORMS { - let root = fixture.root.join(format!("nightly profiles/{platform:?}/vectorcraft")); - let resolved = fixture.check(platform, &root).unwrap(); - assert!(resolved.is_dir(), "{platform:?}"); - assert_eq!(resolved, std::fs::canonicalize(root).unwrap(), "{platform:?}"); - std::fs::remove_dir_all(fixture.root.join("nightly profiles")).unwrap(); - } + fn spec_preserves_vectorcraft_invariants() { + let spec = app_profile_spec(); + assert_eq!(spec.app_id, "vectorcraft"); + assert_eq!(spec.display_name, "VectorCraft"); + assert_eq!(spec.stable_dir_names, &STABLE_DIR_NAMES); + assert_eq!(spec.stable_package_id, "ai.storyteller.vectorcraft"); + assert_eq!(spec.nightly_package_id, "ai.storyteller.vectorcraft.nightly"); + assert_eq!(spec.profile_root_env, None); + assert_eq!(spec.forbidden_env_vars, &FORBIDDEN_ENV_VARS); + assert_eq!(spec.portable_markers, &PORTABLE_MARKERS); + assert_eq!(spec.folder_only_entries, &PROFILE_FOLDERS); } #[test] - fn stable_settings_folders_are_refused_on_every_platform() { - let fixture = Fixture::new(); - let stable = [ - (Platform::Windows, fixture.get("APPDATA").map(|v| PathBuf::from(v).join("VectorCraft"))), - (Platform::Windows, fixture.get("APPDATA").map(|v| PathBuf::from(v).join("ai.storyteller.vectorcraft"))), - (Platform::Windows, fixture.get("LOCALAPPDATA").map(|v| PathBuf::from(v).join("VectorCraft"))), - (Platform::Windows, fixture.get("LOCALAPPDATA").map(|v| PathBuf::from(v).join("Programs/ArtCraft/VectorCraft"))), - (Platform::Linux, Some(fixture.home().join(".config/vectorcraft"))), - (Platform::Linux, Some(fixture.home().join(".local/share/vectorcraft"))), - (Platform::Linux, Some(fixture.home().join(".local/share/ai.storyteller.vectorcraft"))), - (Platform::Linux, Some(fixture.home().join(".cache/vectorcraft"))), - (Platform::Linux, Some(fixture.home().join(".var/app/ai.storyteller.vectorcraft"))), - (Platform::Mac, Some(fixture.home().join("Library/Application Support/VectorCraft"))), - (Platform::Mac, Some(fixture.home().join("Library/Application Support/ai.storyteller.vectorcraft"))), - (Platform::Mac, Some(fixture.home().join("Library/Preferences/ai.storyteller.vectorcraft.plist"))), - ]; - for (platform, stable) in stable { - let stable = stable.unwrap(); - for candidate in [stable.clone(), stable.join("nested nightly")] { - let probed = Cell::new(false); - let result = fixture.check_with(platform, &candidate, |_| { - probed.set(true); - Ok(()) - }); - assert!(result.is_err(), "{platform:?} accepted {candidate:?}"); - assert!(!probed.get(), "a refused root is rejected before the writable probe"); - } - } - } + fn extra_forbidden_roots_fences_platform_installs_and_portable_data() { + let tmp = tempfile::tempdir().unwrap(); + let home = tmp.path().join("home"); + let exe = tmp.path().join("install/vectorcraft"); + let roots = extra_forbidden_roots_with( + |key| match key { + "HOME" | "LOCALAPPDATA" | "ProgramFiles" => Some(home.clone().into_os_string()), + _ => None, + }, + Some(&exe), + ); + assert!(roots.contains(&tmp.path().join("install").join(PORTABLE_DATA_DIR))); - #[test] - fn the_install_folder_and_the_entry_points_are_refused() { - let fixture = Fixture::new(); - for platform in PLATFORMS { - let install = fixture.exe.parent().unwrap(); - assert!(fixture.check(platform, install).is_err(), "{platform:?}: the install folder"); - assert!(fixture.check(platform, &install.join("NightlyData")).is_err(), "{platform:?}: inside the install"); - } - } - - #[test] - fn an_inherited_config_or_no_prefs_override_is_refused() { - let fixture = Fixture::new(); - let root = fixture.root.join("nightly"); - for (key, value) in [ - ("VECTORCRAFT_CONFIG_DIR", "/elsewhere"), - ("VECTORCRAFT_NO_PREFS", "1"), - // The app turns preferences off on presence, so an empty value is a run too. - ("VECTORCRAFT_NO_PREFS", ""), - ("FLATPAK_ID", "ai.storyteller.vectorcraft"), - ] { - for platform in PLATFORMS { - let result = validate_for( - platform, - &root, - |name| if name == key { Some(value.into()) } else { fixture.get(name) }, - Some(&fixture.exe), - |_| Ok(()), - ); - let refused = result.is_err(); - // A Flatpak instance only keeps the stable app's sockets on native Unix packages. - assert_eq!(refused, !(key == "FLATPAK_ID" && platform == Platform::Windows), "{key} on {platform:?}"); - if refused { - assert!(!root.exists(), "a refused launch creates nothing ({key} on {platform:?})"); - } else if root.exists() { - // The accepted case validated the root, which creates it: start the next one clean. - std::fs::remove_dir_all(&root).expect("remove the accepted launch's root"); - } - } - } - } - - #[test] - fn only_the_nightly_s_own_flatpak_instance_may_carry_a_profile() { - let fixture = Fixture::new(); - let root = fixture.root.join("flatpak profile"); - for (id, accepted) in - [(vectorcraft_ui_egui::os_window::NIGHTLY_PACKAGE_ID, true), ("ai.storyteller.vectorcraft", false), ("io.other.App", false)] + #[cfg(target_os = "windows")] { - let result = validate_for( - Platform::Linux, - &root, - |name| if name == "FLATPAK_ID" { Some(id.into()) } else { fixture.get(name) }, - Some(&fixture.exe), - |_| Ok(()), - ); - assert_eq!(result.is_ok(), accepted, "{id}"); - let _ = std::fs::remove_dir_all(&root); + assert!(roots.contains(&home.join("Programs").join("ArtCraft").join("VectorCraft"))); + assert!(roots.contains(&home.join("ArtCraft").join("VectorCraft"))); + } + #[cfg(all(unix, not(target_os = "macos")))] + { + assert!(roots.contains(&home.join(".var/app/ai.storyteller.vectorcraft"))); + assert!(roots.contains(&PathBuf::from("/usr/bin/vectorcraft"))); + assert!(roots.contains(&PathBuf::from("/usr/local/bin/vectorcraft"))); + assert!(roots.contains(&PathBuf::from("/opt/vectorcraft"))); + } + #[cfg(target_os = "macos")] + { + assert!(roots.contains(&home.join("Library/Preferences/ai.storyteller.vectorcraft.plist"))); + assert!(roots.contains(&home.join("Library/Saved Application State/ai.storyteller.vectorcraft.savedState"))); + assert!(roots.contains(&home.join("Applications/VectorCraft.app"))); + assert!(roots.contains(&PathBuf::from("/Applications/VectorCraft.app"))); } } #[test] - fn a_portable_copy_and_its_data_folder_are_refused() { - let fixture = Fixture::new(); - let portable = fixture.root.join("portable copy"); - let data = portable.join(crate::prefs_dir::profile::PORTABLE_DATA_DIR); - std::fs::create_dir_all(&data).unwrap(); - std::fs::write(portable.join("portable.txt"), b"owned portable fixture").unwrap(); - std::fs::write(data.join("config.toml"), b"stable settings must not change").unwrap(); - for platform in PLATFORMS { - for candidate in [&data, &data.join("nested nightly")] { - let probed = Cell::new(false); - let result = fixture.check_with(platform, candidate, |_| { - probed.set(true); - Ok(()) - }); - assert!(result.is_err(), "{platform:?} accepted {candidate:?}"); - assert!(!probed.get()); - assert!(!data.join("nested nightly").exists()); - assert_eq!(std::fs::read(data.join("config.toml")).unwrap(), b"stable settings must not change"); - } + fn nightly_profile_reopens_after_saving_settings_and_enforces_folder_only_entries() { + let tmp = tempfile::tempdir().unwrap(); + let private = tmp.path().join("nightly-reopen"); + let mut spec = app_profile_spec(); + spec.forbidden_env_vars = &[]; + + let canonical = validate_and_prepare_root(&private, &spec).unwrap(); + assert_eq!(canonical, fs::canonicalize(&private).unwrap()); + + for name in ["config.toml", "instance.json", "Color Settings.json", "app.ron"] { + fs::write(canonical.join(name), b"saved profile data").unwrap(); + } + for name in PROFILE_FOLDERS { + fs::create_dir(canonical.join(name)).unwrap(); + } + assert_eq!(validate_and_prepare_root(&private, &spec).unwrap(), canonical); + for name in ["config.toml", "instance.json", "Color Settings.json", "app.ron"] { + assert_eq!(fs::read(canonical.join(name)).unwrap(), b"saved profile data", "{name} remains intact after reopen"); + } + + for name in PROFILE_FOLDERS { + let path = canonical.join(name); + fs::remove_dir(&path).unwrap(); + fs::write(&path, b"not a directory").unwrap(); + assert!(validate_and_prepare_root(&private, &spec).is_err(), "{name} must stay a directory"); + fs::remove_file(&path).unwrap(); + fs::create_dir(&path).unwrap(); } - // A merely similar name is not the portable settings folder. - let similar = fixture.root.join("VectorCraftData-backup-name/nightly"); - assert!(fixture.check(Platform::Linux, &similar).is_ok()); } #[cfg(unix)] #[test] - fn a_link_inside_the_profile_cannot_redirect_recovery_or_a_library() { - let fixture = Fixture::new(); - let root = fixture.root.join("nightly"); - std::fs::create_dir_all(&root).unwrap(); - let external = fixture.root.join("stable-document"); - std::fs::write(&external, b"stable bytes").unwrap(); + fn symlink_inside_profile_is_refused() { + let tmp = tempfile::tempdir().unwrap(); + let private = tmp.path().join("nightly"); + fs::create_dir_all(&private).unwrap(); + let external = tmp.path().join("stable-document"); + fs::write(&external, b"stable bytes").unwrap(); + + let mut spec = app_profile_spec(); + spec.forbidden_env_vars = &[]; + for name in ["Data Recovery", "Swatches"] { - let alias = root.join(name); + let alias = private.join(name); std::os::unix::fs::symlink(&external, &alias).unwrap(); - assert!(fixture.check(Platform::Linux, &root).is_err(), "{name} alias"); - std::fs::remove_file(&alias).unwrap(); + assert!(validate_and_prepare_root(&private, &spec).is_err(), "{name} alias"); + fs::remove_file(&alias).unwrap(); } - assert_eq!(std::fs::read(&external).unwrap(), b"stable bytes"); - } - - #[cfg(unix)] - #[test] - fn a_dangling_link_or_a_linked_ancestor_is_refused() { - let fixture = Fixture::new(); - let elsewhere = fixture.root.join("elsewhere"); - std::fs::create_dir_all(&elsewhere).unwrap(); - let linked = fixture.root.join("nightly"); - std::os::unix::fs::symlink(&elsewhere, &linked).unwrap(); - // Canonical resolution keeps a link's target: a profile reached through one is fine, but it - // is judged (and named) as its target, so nothing is written under the link. - let resolved = fixture.check(Platform::Linux, &linked).unwrap(); - assert_eq!(resolved, std::fs::canonicalize(&elsewhere).unwrap()); - std::fs::remove_file(&linked).unwrap(); - let dangling = fixture.root.join("dangling/nightly"); - std::fs::create_dir_all(dangling.parent().unwrap()).unwrap(); - std::os::unix::fs::symlink(fixture.root.join("missing"), dangling.parent().unwrap().join("nightly")).unwrap(); - assert!(fixture.check(Platform::Linux, &dangling).is_err()); + assert_eq!(fs::read(&external).unwrap(), b"stable bytes"); } #[test] - fn a_home_settings_folder_is_fenced_even_when_the_xdg_override_moves_elsewhere() { - let fixture = Fixture::new(); - let xdg = fixture.root.join("override"); - std::fs::create_dir_all(&xdg).unwrap(); - let config = fixture.home().join(".config/vectorcraft"); - let data = fixture.home().join(".local/share/vectorcraft"); - for stable in [config.clone(), data.clone()] { - for candidate in [stable.clone(), stable.join("nested nightly")] { - let result = validate_for( - Platform::Linux, - &candidate, - |name| match name { - "XDG_CONFIG_HOME" | "XDG_DATA_HOME" => Some(xdg.clone().into_os_string()), - _ => fixture.get(name), - }, - Some(&fixture.exe), - |_| Ok(()), - ); - assert!(result.is_err(), "accepted {candidate:?} with the XDG folders moved to {xdg:?}"); - } - } - assert!(!config.exists() && !data.exists(), "a refused root creates nothing"); - } - - #[cfg(unix)] - #[test] - fn a_dangling_entry_point_keeps_its_fence_instead_of_refusing_every_launch() { - let fixture = Fixture::new(); - let bin = fixture.root.join("entry/bin"); - std::fs::create_dir_all(&bin).unwrap(); - let entry = bin.join("vectorcraft"); - std::os::unix::fs::symlink(fixture.root.join("uninstalled target"), &entry).unwrap(); - // The shared resolver refuses the dangling link, as a profile root must be. - assert!(canonical_future(&entry).is_err()); - assert_eq!(canonical_future_entry(&entry).unwrap(), std::fs::canonicalize(&bin).unwrap().join("vectorcraft")); - } - - #[test] - fn an_unwritable_profile_is_refused_after_the_probe_and_never_used() { - let fixture = Fixture::new(); - let root = fixture.root.join("nightly"); - let result = fixture.check_with(Platform::Linux, &root, |_| Err(std::io::Error::other("read-only"))); - assert!(result.unwrap_err().contains("not writable")); - } - - #[test] - fn nightly_profile_reopens_after_saving_settings_and_session_state() { - let fixture = Fixture::new(); - for platform in PLATFORMS { - let private = fixture.root.join(format!("nightly-reopen-{platform:?}")); - assert_eq!(fixture.check(platform, &private).unwrap(), private); - for name in ["config.toml", "instance.json", "Color Settings.json", "app.ron"] { - std::fs::write(private.join(name), b"saved profile data").unwrap(); - } - for name in PROFILE_FOLDERS { - std::fs::create_dir(private.join(name)).unwrap(); - } - assert_eq!(fixture.check(platform, &private).unwrap(), private); - assert_eq!(std::fs::read(private.join("config.toml")).unwrap(), b"saved profile data"); - for name in PROFILE_FOLDERS { - let path = private.join(name); - std::fs::remove_dir(&path).unwrap(); - std::fs::write(&path, b"not a directory").unwrap(); - assert!(fixture.check(platform, &private).is_err(), "{name} must stay a directory"); - std::fs::remove_file(&path).unwrap(); - std::fs::create_dir(&path).unwrap(); - } - } - } - - #[test] - fn the_platform_case_rules_are_the_file_systems_ones() { - let fixture = Fixture::new(); - let upper = fixture.root.join("NIGHTLY"); - assert!(fixture.check(Platform::Linux, &upper).is_ok()); - let stable_mac = fixture.home().join("library/application support/vectorcraft"); - assert!(fixture.check(Platform::Mac, &stable_mac).is_err(), "macOS compares folders case-insensitively"); + fn non_empty_abs_ignores_empty_and_relative_values() { + let env = |key: &str| match key { + "EMPTY" => Some(OsString::new()), + "RELATIVE" => Some(OsString::from("relative/path")), + _ => None, + }; + assert!(super::non_empty_abs(&env, "EMPTY").is_none()); + assert!(super::non_empty_abs(&env, "RELATIVE").is_none()); + assert!(super::non_empty_abs(&env, "MISSING").is_none()); } } diff --git a/apps/vectorcraft/src/single_instance.rs b/apps/vectorcraft/src/single_instance.rs index 249309fa87..4dba61d6b4 100644 --- a/apps/vectorcraft/src/single_instance.rs +++ b/apps/vectorcraft/src/single_instance.rs @@ -155,8 +155,8 @@ pub fn launch_with_plug_ins(files: &[String]) -> io::Result<()> { } /// The command [`launch_with_plug_ins`] runs: `exe -- files…`, so a file whose name starts with '-' -/// stays a file. A nightly launch hands its profile on first (`launch_profile::child_args`), or the -/// child would refuse to start without one. +/// stays a file. A nightly launch hands its profile on first (`launch_profile::child_args`), so the +/// child opens the same private profile. fn app_with_plug_ins(exe: &Path, files: &[String]) -> std::process::Command { let mut command = std::process::Command::new(exe); command.args(super::launch_profile::child_args(files)); From 616987fdec1c901900e0d74ba3e0f333a74436f7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 19:20:11 -0800 Subject: [PATCH 183/264] Properties: the Document sections replay whole, header and body The craft-libs pin moves to current craft-libs main, 19805ced1e, which has craft-libs#4359: a MemoView's content keeps the flow start and gap of the Stack around it. Each memoized Document section now shows in its MemoView with its header, so an idle frame replays the header as well as the body. Before that change in craft-libs, the Document section stood 18 pt lower in a MemoView and each later memoized section 5 pt lower again. The pin also moves the craft-web-api dependency of vectorcraft-web, the rev that `cargo xtask pdf-deps` checks, and the winit rev to 0dfcec0eb6, the one craft-libs pins. Cargo.lock takes brotli 9.1.3 for craft-i18n, objc2-core-graphics for craft-appkit and craft-platform, and drops core-graphics2 and block. memoized_sections_land_where_direct_ones_do draws the whole panel with nothing selected and compares where its text lands with the sections in their MemoViews and shown directly. It fails at the old pin. --- Cargo.lock | 211 +++++++++--------- Cargo.toml | 76 +++---- apps/vectorcraft-web/Cargo.toml | 2 +- .../panels/properties/document_sections.rs | 121 +++++++--- xtask/src/pdf_deps.rs | 2 +- 5 files changed, 240 insertions(+), 172 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cb674e4ae..3655542d18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,12 +626,6 @@ dependencies = [ "cpufeatures 0.3.1", ] -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -725,6 +719,17 @@ dependencies = [ "brotli-decompressor 5.0.3", ] +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", + "brotli-decompressor 6.3.2", +] + [[package]] name = "brotli-decompressor" version = "5.0.3" @@ -1184,19 +1189,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" -dependencies = [ - "bitflags 2.13.2", - "block", - "cfg-if", - "core-foundation 0.10.1", - "libc", -] - [[package]] name = "core_detect" version = "1.0.0" @@ -1239,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "crc32fast", "flate2", @@ -1291,18 +1283,19 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "block2 0.6.2", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-core-graphics", "objc2-foundation 0.3.2", ] [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "egui", ] @@ -1388,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "md-5", "rayon", @@ -1397,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "rayon", ] @@ -1451,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "serde", ] @@ -1501,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "serde", "serde_json", @@ -1542,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "gif", ] @@ -1626,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "flate2", ] @@ -1634,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,8 +1640,10 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "chrono", "fixed_decimal", "icu_calendar", @@ -1675,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1830,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "flate2", "serde", @@ -1846,7 +1841,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,12 +1853,12 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "async-channel", "async-io", "async-process", - "core-graphics2", + "craft-appkit", "craft-atomic", "craft-docpath", "craft-host", @@ -1873,6 +1868,8 @@ dependencies = [ "js-sys", "log", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "rfd", "serde", "serde_json", @@ -1889,7 +1886,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1919,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1930,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1944,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1955,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1968,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1987,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2004,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2015,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2036,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2048,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2073,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2088,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2103,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2113,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2137,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2156,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2172,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2210,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2221,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2239,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2260,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2281,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2300,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2332,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "flate2", "serde", @@ -2346,7 +2343,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2353,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2364,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "winsafe", ] @@ -2375,7 +2372,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2404,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,16 +3759,16 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ - "brotli", + "brotli 8.0.4", "hayro-postscript", ] [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3786,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3804,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4792,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4949,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -10067,7 +10064,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=a517b3846ee8457d84ee4975110bfda6797c44dc#a517b3846ee8457d84ee4975110bfda6797c44dc" +source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" dependencies = [ "ahash", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index 7ad3e4cfeb..f32179e124 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,49 +10,49 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -192,13 +192,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } @@ -210,4 +210,4 @@ egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed1817 egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } +winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index ce4d1d3d44..98a00a7ca6 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/panels/properties/document_sections.rs b/crates/ui-egui/src/panels/properties/document_sections.rs index cff44b4f44..ca142a9172 100644 --- a/crates/ui-egui/src/panels/properties/document_sections.rs +++ b/crates/ui-egui/src/panels/properties/document_sections.rs @@ -24,35 +24,27 @@ use crate::panels::transform; /// Appearance fill and stroke, the view's rulers, grids, guides and snapping, the keyboard /// increment and Scale Strokes & Effects, and Quick Actions. /// -/// The body of every section but Appearance shows in a `MemoView` keyed on what it reads, so a -/// frame that changes none of it replays the body. What a body picks comes back through an `Outbox` -/// and runs after its section. +/// Every section but Appearance shows in a `MemoView` keyed on what it reads, header and body together, +/// so a frame that changes none of it replays the whole section. What a section picks comes back +/// through an `Outbox` and runs after it. pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { let lang = crate::i18n::current(); let units = app.session.general_unit(); let unit = Unit::ALL.iter().position(|u| *u == units).unwrap_or(usize::MAX); let artboards = app.session.active().map_or(0, |d| d.doc.artboards.len()); let mut picked_units = Vec::new(); - super::section(tl!("Document")).show(ui, |ui, _| { - let document = DocumentProps { unit, units, artboards, lang, picked: Outbox::new(&mut picked_units) }; - let _ = MemoView::new("properties-document", document, document_body).show(ui); - }); + let document = DocumentProps { unit, units, artboards, lang, picked: Outbox::new(&mut picked_units) }; + memoized("properties-document", document, document_section, ui); if let Some(u) = picked_units.pop() { app.run("document.setUnits", json!({ "units": u.label() })).ok(); } super::section(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui)); - super::section(tl!("Rulers & Grids")).show(ui, |ui, _| { - let _ = MemoView::new("properties-rulers", Language { lang }, rulers_body).show(ui); - }); - super::section(tl!("Guides")).show(ui, |ui, _| { - let _ = MemoView::new("properties-guides", Language { lang }, guides_body).show(ui); - }); + memoized("properties-rulers", Language { lang }, rulers_section, ui); + memoized("properties-guides", Language { lang }, guides_section, ui); let mut snaps = Vec::new(); let (point, grid) = (app.ui.view.snap_to_point, app.ui.view.snap_to_grid); - super::section(tl!("Snap Options")).show(ui, |ui, _| { - let snap = SnapProps { point, grid, lang, picked: Outbox::new(&mut snaps) }; - let _ = MemoView::new("properties-snap", snap, snap_body).show(ui); - }); + let snap = SnapProps { point, grid, lang, picked: Outbox::new(&mut snaps) }; + memoized("properties-snap", snap, snap_section, ui); for command in snaps { app.run(command, json!({})).ok(); } @@ -62,11 +54,9 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { let unit = Unit::ALL.iter().position(|u| *u == general).unwrap_or(usize::MAX); let (increment, scale) = (app.session.prefs.keyboard_increment, app.session.prefs.scale_strokes); let (bare_points, lengths) = (app.session.prefs.numbers_without_units_are_points, crate::canvas::rulers::general_lengths(app)); - super::section(tl!("Preferences")).show(ui, |ui, _| { - let picked = Outbox::new(&mut prefs); - let preferences = PreferencesProps { increment, unit, bare_points, lengths, scale, lang, picked }; - let _ = MemoView::new("properties-preferences", preferences, preferences_body).show(ui); - }); + let picked = Outbox::new(&mut prefs); + let preferences = PreferencesProps { increment, unit, bare_points, lengths, scale, lang, picked }; + memoized("properties-preferences", preferences, preferences_section, ui); for pick in prefs { match pick { PreferencePick::Increment(event) => { @@ -79,9 +69,49 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { PreferencePick::ScaleStrokes(on) => transform::set_pref(app, "scaleStrokes", on), } } - super::section(tl!("Quick Actions")).show(ui, |ui, _| { - let _ = MemoView::new("properties-quick-actions", Language { lang }, quick_actions_body).show(ui); - }); + memoized("properties-quick-actions", Language { lang }, quick_actions_section, ui); +} + +/// Shows `section` in a `MemoView` with `id`, keyed on `props`. Tests can show it directly instead, to compare where +/// the memoized sections land with where direct ones do. +fn memoized(id: &'static str, props: P, section: fn(&mut P, &mut Ui), ui: &mut Ui) { + #[cfg(test)] + if tests::shown_directly() { + let mut props = props; + section(&mut props, ui); + return; + } + let _ = MemoView::new(id, props, section).show(ui); +} + +/// The Document section: its header and [`document_body`]. +fn document_section(p: &mut DocumentProps<'_>, ui: &mut Ui) { + super::section(tl!("Document")).show(ui, |ui, _| document_body(p, ui)); +} + +/// The Rulers & Grids section: its header and [`rulers_body`]. +fn rulers_section(p: &mut Language, ui: &mut Ui) { + super::section(tl!("Rulers & Grids")).show(ui, |ui, _| rulers_body(p, ui)); +} + +/// The Guides section: its header and [`guides_body`]. +fn guides_section(p: &mut Language, ui: &mut Ui) { + super::section(tl!("Guides")).show(ui, |ui, _| guides_body(p, ui)); +} + +/// The Snap Options section: its header and [`snap_body`]. +fn snap_section(p: &mut SnapProps<'_>, ui: &mut Ui) { + super::section(tl!("Snap Options")).show(ui, |ui, _| snap_body(p, ui)); +} + +/// The Preferences section: its header and [`preferences_body`]. +fn preferences_section(p: &mut PreferencesProps<'_>, ui: &mut Ui) { + super::section(tl!("Preferences")).show(ui, |ui, _| preferences_body(p, ui)); +} + +/// The Quick Actions section: its header and [`quick_actions_body`]. +fn quick_actions_section(p: &mut Language, ui: &mut Ui) { + super::section(tl!("Quick Actions")).show(ui, |ui, _| quick_actions_body(p, ui)); } /// What a section that reads only command states reads besides them: the interface language of its labels. @@ -248,6 +278,47 @@ mod tests { SECTION_RUNS.with(std::cell::Cell::get) } + thread_local! { + /// This thread shows the memoized sections directly, outside their `MemoView`s. + static DIRECT: std::cell::Cell = const { std::cell::Cell::new(false) }; + } + + pub(super) fn shown_directly() -> bool { + DIRECT.with(std::cell::Cell::get) + } + + /// The runs of text the whole Properties panel paints with nothing selected, after idle frames that replay the + /// memoized sections, with the sections shown in their `MemoView`s or, with `direct`, directly. + fn panel_texts(direct: bool) -> Vec<(String, egui::Rect)> { + DIRECT.with(|d| d.set(direct)); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let mut panel = Panel::new(app, super::super::show); + panel.frame(); + let before = runs(); + panel.frame(); + panel.frame(); + if !direct { + assert_eq!(runs(), before, "the last frames replay the memoized sections"); + } + let texts = panel.texts(); + DIRECT.with(|d| d.set(false)); + texts + } + + /// Whole sections shown in `MemoView`s, header and body, land where the same sections shown directly do under the + /// app's `SectionRhythm::Spaced` and `QuietHeader::Heads`: the Document section under the panel's heading draws no + /// rule above it, and each later section keeps the stack's gap. + #[test] + fn memoized_sections_land_where_direct_ones_do() { + let direct = panel_texts(true); + for heading in ["Document", "Rulers & Grids", "Guides", "Snap Options", "Preferences", "Quick Actions", "Snap to Point"] { + assert!(direct.iter().any(|(text, _)| text == heading), "the panel shows {heading:?}: {direct:?}"); + } + let memoized = panel_texts(false); + assert_eq!(memoized, direct, "memoized sections land where direct ones do"); + } + #[test] fn canceling_the_units_popup_leaves_the_document_unchanged() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index f4f02f8627..d3e0f6e1df 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "186a229c8da8db5916f8a863dfd894f1879af735"; +const REV: &str = "19805ced1eee99a0667facfc3e02ca909e7df348"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 03dd80a887691a6cafee4e608a4b72dfa1156554 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 19:37:36 -0800 Subject: [PATCH 184/264] Tests: menu and Quick Actions rebuild counts run in a process of their own MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The menus' key (`state_key`, crates/ui-egui/src/menus/model.rs) holds the installed plug-ins' revision and the fonts' generation. Both are the whole process's. In a parallel `cargo test` run, a plug-in that another test installs moves the revision, the menus are rebuilt, and the new catalog makes the window build a new keymap, whose address is also in the key, so the next pass rebuilds them again. `a_key_press_rebuilds_the_menus_once` then counted those rebuilds on its idle frames ("idle frames keep the menus", left 4 to 7, right 3 to 5) in 6 of 6 runs of `cargo test -p vectorcraft-ui-egui --lib -- addons menus i18n`, and `quick_actions_are_listed_again_only_after_a_change`, whose key holds the menus' key, failed in the same way in 2 of 2 runs. In the app these values change only when a plug-in is installed or removed or the fonts change, and the menus list both, so the rebuild is kept. - Both tests run through `testing::in_own_process`, as the tests that load color profiles do, and wait for the installed fonts' scan, whose end moves the fonts' generation, before their first frames. - `a_new_font_rebuilds_the_menus` adds a font and checks that the menus are rebuilt with no input, that Type › Font lists it, and that idle frames after that keep the menus. --- crates/ui-egui/src/menus/tests.rs | 42 +++++++++++++++++-- crates/ui-egui/src/panels/properties/tests.rs | 9 +++- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index b21b2e8ccf..7d27d6be1a 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -164,15 +164,29 @@ fn snapping_menu_clicks_toggle_view_state_and_painted_checkmarks() { assert_eq!(menu.toggled("Pixel Snapping Options…"), None); } -/// A key press builds the menus' states again once: the frames after it, with no press, keep them. -#[test] -fn a_key_press_rebuilds_the_menus_once() { +/// An app with a new document whose installed fonts are cataloged, after the frames that build its first menus and the +/// window's keymap. It runs in a process of its own ([`crate::testing::in_own_process`]): the menus' key holds the +/// installed plug-ins' revision and the fonts' generation, which are the whole process's, so a plug-in that another test +/// installs, or a font it adds, rebuilds this app's menus. `None` in the parent process. +fn settled_app(test: &str) -> Option<(VectorcraftApp, egui::Context)> { + if !crate::testing::in_own_process(test) { + return None; + } let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + // The scan of the installed fonts, which the app starts, changes the fonts' generation when it ends: wait for it. + vectorcraft_text::FontDb::global().family_list(); app.run("file.new", json!({})).unwrap(); let ctx = crate::testing::ui_context(); for _ in 0..3 { app_frame(&mut app, &ctx, vec![]); } + Some((app, ctx)) +} + +/// A key press builds the menus' states again once: the frames after it, with no press, keep them. +#[test] +fn a_key_press_rebuilds_the_menus_once() { + let Some((mut app, ctx)) = settled_app("menus::tests::a_key_press_rebuilds_the_menus_once") else { return }; let before = app.menus.rebuilds; for _ in 0..3 { app_frame(&mut app, &ctx, vec![]); @@ -187,6 +201,28 @@ fn a_key_press_rebuilds_the_menus_once() { assert_eq!(app.menus.rebuilds, before + 1); } +/// A font added to the fonts the whole process shares builds the menus again with no input, Type › Font then lists it, +/// and the idle frames after that keep the menus. +#[test] +fn a_new_font_rebuilds_the_menus() { + const FAMILY: &str = "Menurebuild Sans"; + let Some((mut app, ctx)) = settled_app("menus::tests::a_new_font_rebuilds_the_menus") else { return }; + let lists = + |app: &VectorcraftApp| app.menus.bar.items().into_iter().any(|it| it.command.id == "text.setStyle" && it.command.params["font"] == FAMILY); + assert!(!lists(&app)); + let font = vectorcraft_text::test_fonts::named_copy(false, (FAMILY, "Regular", "Version 1.000", "MenurebuildSans-Regular")); + let before = app.menus.rebuilds; + assert_eq!(vectorcraft_text::FontDb::global().add_font(font.expect("the test font builds")), 1); + app_frame(&mut app, &ctx, vec![]); + assert!(app.menus.rebuilds > before, "the new font rebuilds the menus"); + assert!(lists(&app), "Type › Font lists {FAMILY}"); + let after = app.menus.rebuilds; + for _ in 0..3 { + app_frame(&mut app, &ctx, vec![]); + } + assert_eq!(app.menus.rebuilds, after, "idle frames keep the menus"); +} + #[test] fn help_f1_opens_discover_without_a_document() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index 4a8158364a..ed4147744e 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -1084,10 +1084,17 @@ fn quick_actions_follow_the_selection() { } } -/// The panel lists the Quick Actions once per change of what they depend on, not in every frame. +/// The panel lists the Quick Actions once per change of what they depend on, not in every frame. It runs in a process +/// of its own ([`crate::testing::in_own_process`]): what they depend on holds the menus' key, with the installed +/// plug-ins' revision and the fonts' generation, which are the whole process's. #[test] fn quick_actions_are_listed_again_only_after_a_change() { + if !crate::testing::in_own_process("panels::properties::tests::quick_actions_are_listed_again_only_after_a_change") { + return; + } let mut app = new_app(); + // The scan of the installed fonts, which the app starts, changes the fonts' generation when it ends: wait for it. + vectorcraft_text::FontDb::global().family_list(); rect(&mut app, 10.0, 10.0, 40.0, 40.0); rect(&mut app, 80.0, 10.0, 40.0, 40.0); let ctx = crate::testing::ui_context(); From 80b15ed8d15eaaad0156eed1fc7aba6956855197 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 19:46:29 -0800 Subject: [PATCH 185/264] Swatches: idle frames replay the swatch rows The panel's browser has a row menu, drop rules and a drag payload of its own, and without a version for what they read it ran its rows in every frame. The panel now passes SwatchesPanel::host_version with a version of the document, its revision, its File > Revert count and its newest undo and redo steps, which are what those closures read. The craft-libs pin moves to current main (891f4060c), which has SwatchesPanel::host_version (storytold/craft-libs#4320), with the winit revision that craft-libs revision uses (0dfcec0e). --- Cargo.lock | 211 ++++++++++---------- Cargo.toml | 76 +++---- apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/panels/swatches.rs | 4 + crates/ui-egui/src/panels/swatches/dnd.rs | 10 + crates/ui-egui/src/panels/swatches/tests.rs | 33 +++ xtask/src/pdf_deps.rs | 2 +- 7 files changed, 191 insertions(+), 147 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cb674e4ae..2a52380c8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,12 +626,6 @@ dependencies = [ "cpufeatures 0.3.1", ] -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -725,6 +719,17 @@ dependencies = [ "brotli-decompressor 5.0.3", ] +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", + "brotli-decompressor 6.3.2", +] + [[package]] name = "brotli-decompressor" version = "5.0.3" @@ -1184,19 +1189,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" -dependencies = [ - "bitflags 2.13.2", - "block", - "cfg-if", - "core-foundation 0.10.1", - "libc", -] - [[package]] name = "core_detect" version = "1.0.0" @@ -1239,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "crc32fast", "flate2", @@ -1291,18 +1283,19 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "block2 0.6.2", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-core-graphics", "objc2-foundation 0.3.2", ] [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "egui", ] @@ -1388,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "md-5", "rayon", @@ -1397,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "rayon", ] @@ -1451,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "serde", ] @@ -1501,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "serde", "serde_json", @@ -1542,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "gif", ] @@ -1626,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "flate2", ] @@ -1634,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,8 +1640,10 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "chrono", "fixed_decimal", "icu_calendar", @@ -1675,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "chrono", "craft-codepage", @@ -1819,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-keymap", @@ -1835,7 +1830,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "flate2", "serde", @@ -1846,7 +1841,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1858,12 +1853,12 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "async-channel", "async-io", "async-process", - "core-graphics2", + "craft-appkit", "craft-atomic", "craft-docpath", "craft-host", @@ -1873,6 +1868,8 @@ dependencies = [ "js-sys", "log", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "rfd", "serde", "serde_json", @@ -1889,7 +1886,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1898,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -1922,7 +1919,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1933,7 +1930,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-eps", "flate2", @@ -1947,7 +1944,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "encoding_rs", "flate2", @@ -1958,7 +1955,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "dispatch2", "egui", @@ -1971,7 +1968,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1990,7 +1987,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-atomic", "craft-host", @@ -2007,7 +2004,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "fax", "hayro-ccitt", @@ -2018,7 +2015,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2039,7 +2036,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-keymap", @@ -2051,7 +2048,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2076,7 +2073,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2091,7 +2088,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-atomic", "craft-behavior", @@ -2106,7 +2103,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "serde", "thiserror 2.0.21", @@ -2116,7 +2113,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "serde", "thiserror 2.0.21", @@ -2125,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-keymap", @@ -2140,12 +2137,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2159,7 +2156,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-i18n", @@ -2175,7 +2172,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "accesskit", "craft-behavior", @@ -2213,7 +2210,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2224,7 +2221,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -2242,7 +2239,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -2263,7 +2260,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -2284,7 +2281,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-behavior", "craft-host", @@ -2303,7 +2300,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "base64 0.22.1", "chrono", @@ -2335,7 +2332,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "flate2", "serde", @@ -2346,7 +2343,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2356,7 +2353,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "js-sys", "serde_json", @@ -2367,7 +2364,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "winsafe", ] @@ -2375,7 +2372,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "craft-appkit", "craft-atomic", @@ -2407,7 +2404,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3762,16 +3759,16 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ - "brotli", + "brotli 8.0.4", "hayro-postscript", ] [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3789,7 +3786,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3807,12 +3804,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "flate2", "hayro-ccitt", @@ -4795,7 +4792,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4952,7 +4949,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -10067,7 +10064,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=a517b3846ee8457d84ee4975110bfda6797c44dc#a517b3846ee8457d84ee4975110bfda6797c44dc" +source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" dependencies = [ "ahash", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index 7ad3e4cfeb..0c7e739fb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,49 +10,49 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -192,13 +192,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } @@ -210,4 +210,4 @@ egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed1817 egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } +winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index ce4d1d3d44..0e50690b98 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/panels/swatches.rs b/crates/ui-egui/src/panels/swatches.rs index 515456cad8..ca2b52c605 100644 --- a/crates/ui-egui/src/panels/swatches.rs +++ b/crates/ui-egui/src/panels/swatches.rs @@ -421,6 +421,9 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui) { let lit: Vec = highlighted(&st.doc, &base).into_iter().map(str::to_string).collect(); let doc = Arc::clone(&st.doc); let start = dnd::DragStart::of(st); + // The row menu, the drop rules and the drag payload read the document, its reverts and the drag start alone, so + // the browser's rows replay while this version holds. + let host = start.version(st.revision); let document = st.uid; let reverts = st.reverts; let foot = Footer::of(app, &model, held); @@ -448,6 +451,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui) { .row_items(|key| row_items(shown_app, key)) .takes_drop::(DropPlace::Between, |drag, _| dnd::accepts(drag, document, reverts)) .takes_drop::(DropPlace::Onto, |drag, _| dnd::accepts(drag, document, reverts)) + .host_version(host) .select(SelectMode::Multi) .search(search) .reveal(focus.clone().map(SwatchKey::Swatch)) diff --git a/crates/ui-egui/src/panels/swatches/dnd.rs b/crates/ui-egui/src/panels/swatches/dnd.rs index df967e9700..4b68266bf1 100644 --- a/crates/ui-egui/src/panels/swatches/dnd.rs +++ b/crates/ui-egui/src/panels/swatches/dnd.rs @@ -1,3 +1,4 @@ +use std::hash::{DefaultHasher, Hash, Hasher}; use std::sync::{Arc, Weak}; use super::{Document, Paint, PanelDrag, REGISTRATION, Swatch, Value, VectorcraftApp, json, name_of, swatch_params}; @@ -126,6 +127,15 @@ impl DragStart { DragStart { uid: st.uid, reverts: st.reverts, doc: Arc::clone(&st.doc), steps: steps(st), back } } + /// A version of this start in the document's `revision` ([`DocState::revision`]): it changes with + /// the document, its count of File › Revert and its newest undo and redo steps, which are what the + /// panel's row menu, drop rules and drag payload read. + pub(super) fn version(&self, revision: u64) -> u64 { + let mut h = DefaultHasher::new(); + (self.uid, self.reverts, revision, self.steps).hash(&mut h); + h.finish() + } + /// Rows `names` as this document holds them. fn rows(&self, names: &[String]) -> HeldRows { let rows: Vec<_> = names.iter().map(|n| (n.clone(), HeldRow::of(&self.doc, n))).collect(); diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index f20c725ac0..df72fa25e1 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -1623,3 +1623,36 @@ fn the_swatch_libraries_menu_fits_its_rows_like_a_library_panels_menu() { let panel_menu = panel.rect_role("Swatch Libraries Menu", Role::MENU); assert_eq!(footer_menu.width(), panel_menu.width(), "footer menu {footer_menu:?}, library panel menu {panel_menu:?}"); } + +/// Frames that change nothing replay the swatch rows instead of running them again; deleting a swatch and undoing it +/// each run them, the rows show the change, and the frames after replay them again. +#[test] +fn idle_frames_replay_the_swatch_rows() { + use crate::tests::panel_harness::Panel; + use craft::ui::testing::{MemoRun, last_frame_memo_runs}; + let runs = |panel: &Panel| { + last_frame_memo_runs(panel.ctx()).iter().filter(|(name, _, run)| name.contains("ListProps") && *run == MemoRun::Ran).count() + }; + let idle = |panel: &mut Panel, after: &str| { + panel.frame(); + panel.frame(); + for _ in 0..5 { + panel.frame(); + assert_eq!(runs(panel), 0, "an idle frame {after} replays the swatch rows"); + } + }; + let red = "Red, #ed1c24"; + let mut panel = Panel::new(app(), show); + idle(&mut panel, "of a new document"); + assert!(panel.shows(red), "the rows show Red"); + panel.app().run("swatch.delete", json!({"names": ["Red"]})).unwrap(); + panel.frame(); + assert!(runs(&panel) > 0, "deleting a swatch runs the rows"); + assert!(!panel.shows(red), "and they no longer show it"); + idle(&mut panel, "after a delete"); + panel.app().run("edit.undo", json!({})).unwrap(); + panel.frame(); + assert!(runs(&panel) > 0, "an undo runs the rows"); + assert!(panel.shows(red), "and they show the swatch again"); + idle(&mut panel, "after an undo"); +} diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index f4f02f8627..4d937f436f 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "186a229c8da8db5916f8a863dfd894f1879af735"; +const REV: &str = "891f4060c4aefe2679a65afc9e76bb5ce345de31"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 2be42e79864534c8ac43d52e1adaee13f5b17c17 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 19:52:59 -0800 Subject: [PATCH 186/264] Shape Builder: saved Artwork from earlier versions switches to Color Swatches once Leaving the Shape Builder saved every one of its options, so preferences from earlier versions hold pickColorFrom "artwork" whether or not it was picked, and kept the old default after Color Swatches became the default. The preferences now carry toolSettingsVersion, written as 1 once a tool setting is stored. Applying preferences without it changes a saved Shape Builder pickColorFrom "artwork" to "swatches" and writes the version, so Artwork picked after that is kept at the next launch. A saved "swatches" and preferences without a saved pickColorFrom are unchanged. Docs: docs/mcp.md and the tool options params text. --- crates/engine/src/cmd/prefscmds.rs | 2 + crates/engine/src/prefs.rs | 36 ++++++++++++++++ crates/engine/src/tests/toolsettings.rs | 55 ++++++++++++++++++------- crates/engine/src/tooling.rs | 1 + crates/mcp/src/ui_catalog.rs | 2 +- crates/tools/src/builder.rs | 3 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- docs/mcp.md | 3 +- 8 files changed, 86 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/cmd/prefscmds.rs b/crates/engine/src/cmd/prefscmds.rs index 27d38e158f..8420e67d30 100644 --- a/crates/engine/src/cmd/prefscmds.rs +++ b/crates/engine/src/cmd/prefscmds.rs @@ -725,6 +725,8 @@ impl Session { for e in self.prefs.keep_folders(&mut p) { log::warn!("{e}"); } + // Tool settings saved by an earlier version are updated once. + p.migrate_tool_settings(); // Saved gradient presets get names no built-in preset or other saved one has. for (old, new) in super::gradpresets::rename_clashing_presets(&mut p.gradient_presets) { log::warn!("saved gradient preset {old} is listed as {new}: another preset has its name"); diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 1a7b78a91b..3c2f3e3299 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -438,6 +438,12 @@ pub struct Prefs { /// resetting the preferences keeps them; `tool.setOption` edits them. #[serde(skip_serializing_if = "std::collections::BTreeMap::is_empty")] pub tool_settings: std::collections::BTreeMap>, + /// The version of [`Self::tool_settings`]: [`TOOL_SETTINGS_VERSION`] once this version stores + /// or updates a tool setting, 0 while none is stored and in preferences saved without one. + /// [`Prefs::migrate_tool_settings`] updates older tool settings once. Not a Preferences dialog + /// field: resetting the preferences keeps it. + #[serde(default, skip_serializing_if = "is_zero")] + pub tool_settings_version: u32, /// View → Perspective Grid presets: the user's (the built-in ones aren't stored). A local /// library, not a Preferences dialog field: resetting the preferences keeps it; /// `perspective.presets.*` edit it. @@ -464,7 +470,36 @@ pub const KEY_HOLD_DELAY: f64 = 0.35; /// The range of the Hold Shortcut Delay, in seconds. pub const KEY_HOLD_DELAY_RANGE: (f64, f64) = (0.2, 1.0); +/// The version of the tool settings these preferences write ([`Prefs::tool_settings_version`]). +/// Version 1 makes Color Swatches the Shape Builder's Pick Color From. +pub const TOOL_SETTINGS_VERSION: u32 = 1; + +fn is_zero(v: &u32) -> bool { + *v == 0 +} + impl Prefs { + /// Update tool settings saved by an earlier version to [`TOOL_SETTINGS_VERSION`], once. Before + /// version 1, leaving the Shape Builder saved its `pickColorFrom` whether or not it was + /// changed, so a saved `artwork` becomes `swatches`. Without tool settings, nothing changes; a + /// version newer than this one is kept. + pub fn migrate_tool_settings(&mut self) { + if self.tool_settings_version < 1 + && let Some(saved) = self.tool_settings.get_mut("shapeBuilder") + && saved.get("pickColorFrom").and_then(Value::as_str) == Some("artwork") + { + saved.insert("pickColorFrom".into(), Value::from("swatches")); + } + self.mark_tool_settings_current(); + } + + /// Record that [`Self::tool_settings`], when any is stored, is in this version's form. + pub(crate) fn mark_tool_settings_current(&mut self) { + if !self.tool_settings.is_empty() { + self.tool_settings_version = self.tool_settings_version.max(TOOL_SETTINGS_VERSION); + } + } + /// The `document.open` / place params `p` with `embeddedFonts: false` added when Preferences /// › File Handling › Use fonts embedded in imported PDFs is off and `p` gives no choice of its own. pub fn with_pdf_font_choice(&self, p: &serde_json::Value) -> serde_json::Value { @@ -672,6 +707,7 @@ impl Default for Prefs { use_registration_point_for_symbol: false, show_on_shape_creation: false, tool_settings: Default::default(), + tool_settings_version: 0, perspective_presets: vec![], blend_options: None, perspective_widget: Default::default(), diff --git a/crates/engine/src/tests/toolsettings.rs b/crates/engine/src/tests/toolsettings.rs index 76fda42a5b..db1fc01a30 100644 --- a/crates/engine/src/tests/toolsettings.rs +++ b/crates/engine/src/tests/toolsettings.rs @@ -700,26 +700,53 @@ fn a_parametric_shape_kind_and_its_values_set_together() { } /// The Shape Builder picks colors from the color swatches by default: a fresh session, and saved -/// preferences that hold other Shape Builder options but no `pickColorFrom`, give `swatches`. A -/// saved `artwork` (or `swatches`) is kept. +/// preferences that hold other Shape Builder options but no `pickColorFrom`, give `swatches`. +/// Preferences saved without `toolSettingsVersion` read a saved `artwork` as `swatches` once and +/// are then written with the version, so a later `artwork` is kept. A saved `swatches` is kept. #[test] -fn shape_builder_pick_color_from_defaults_to_swatches_and_keeps_a_saved_choice() { +fn shape_builder_pick_color_from_defaults_to_swatches_and_migrates_a_saved_artwork_once() { let mut s = session(); select(&mut s, "shapeBuilder"); assert_eq!(s.tool_options()["pickColorFrom"], json!("swatches"), "a fresh session"); - for (saved, want) in [ - (json!({"highlightFill": false}), "swatches"), - (json!({"pickColorFrom": "artwork"}), "artwork"), - (json!({"pickColorFrom": "swatches"}), "swatches"), - ] { - let mut prefs = s.prefs.clone(); - prefs.tool_settings.insert("shapeBuilder".into(), saved.as_object().unwrap().clone()); - let saved_text = serde_json::to_string(&prefs).unwrap(); + select(&mut s, "selection"); + assert_eq!(s.prefs.to_json()["toolSettingsVersion"], json!(1), "stored settings are written with the version"); + let load = |version: Option, saved: &Value| { + let mut prefs = Prefs::default().to_json(); + prefs["toolSettings"] = json!({ "shapeBuilder": saved }); + let fields = prefs.as_object_mut().unwrap(); + match version { + Some(v) => fields.insert("toolSettingsVersion".into(), json!(v)), + None => fields.remove("toolSettingsVersion"), + }; let mut next = session(); - next.apply_prefs(serde_json::from_str(&saved_text).unwrap()); + next.apply_prefs(serde_json::from_str(&prefs.to_string()).unwrap()); + next + }; + for (version, saved, want) in [ + (None, json!({"highlightFill": false}), "swatches"), + (None, json!({"pickColorFrom": "artwork"}), "swatches"), + (None, json!({"pickColorFrom": "swatches"}), "swatches"), + (Some(1), json!({"pickColorFrom": "artwork"}), "artwork"), + (Some(1), json!({"pickColorFrom": "swatches"}), "swatches"), + (Some(1), json!({"highlightFill": false}), "swatches"), + ] { + let mut next = load(version, &saved); + assert_eq!(next.prefs.tool_settings_version, 1, "the version is written: {version:?} {saved}"); select(&mut next, "shapeBuilder"); - assert_eq!(next.tool_options()["pickColorFrom"], json!(want), "saved {saved}"); + assert_eq!(next.tool_options()["pickColorFrom"], json!(want), "saved {version:?} {saved}"); select(&mut next, "selection"); - assert_eq!(next.prefs.tool_settings["shapeBuilder"]["pickColorFrom"], json!(want), "stored again: {saved}"); + assert_eq!(next.prefs.tool_settings["shapeBuilder"]["pickColorFrom"], json!(want), "stored again: {version:?} {saved}"); + } + // Artwork picked after the update, or in a session that started without saved settings, is + // kept at the next launch. + for mut next in [load(None, &json!({"pickColorFrom": "artwork"})), session()] { + select(&mut next, "shapeBuilder"); + next.set_tool_option("pickColorFrom", &json!("artwork")); + select(&mut next, "selection"); + let saved_text = serde_json::to_string(&next.prefs).unwrap(); + let mut later = session(); + later.apply_prefs(serde_json::from_str(&saved_text).unwrap()); + select(&mut later, "shapeBuilder"); + assert_eq!(later.tool_options()["pickColorFrom"], json!("artwork"), "picked after the update: {saved_text}"); } } diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 422caab5ec..94f72f6441 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -581,6 +581,7 @@ impl Session { } } } + prefs.mark_tool_settings_current(); } /// Keep the active tool's persistent options for the next time it, or a tool sharing them, is diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index b6f0866d96..e933df1e5f 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1192,7 +1192,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "tool.options", "Tool Options…", "", - "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", + "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept, except that preferences saved by an earlier version read it as swatches once), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", ), ( "ui.colorGuideOptions", diff --git a/crates/tools/src/builder.rs b/crates/tools/src/builder.rs index 42886ec013..7451fd0226 100644 --- a/crates/tools/src/builder.rs +++ b/crates/tools/src/builder.rs @@ -70,7 +70,8 @@ pub struct ShapeBuilderOptions { /// fills the new shape with the current fill, and the Left and Right arrow keys step the current /// fill through the document's color swatches. With Artwork, the shape takes the look of the /// object where the drag starts, else of the one where it ends, else of the front-most selected - /// object. A saved `pickColorFrom` is kept; preferences without one take Color Swatches. + /// object. A saved `pickColorFrom` is kept, except that preferences saved by an earlier version + /// read a saved Artwork as Color Swatches once; preferences without one take Color Swatches. pub swatches: bool, /// Cursor Swatch Preview (`cursorSwatchPreview`, off): with Color Swatches, the current fill /// and the swatches before and after it show as chips above the pointer while no drag is on. diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index e76772d154..a4620e2a5b 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1193,7 +1193,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "tool.options", "Tool Options…", "", - "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", + "{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient|magicWand → the Gradient or Magic Wand panel (window.panel), artboard → Artboard Options of the active artboard (dialog `artboardOptions`, fields index, name, x, y, width, height, showCenterMark, showCrossHairs; OK runs artboard.setProps, and with other artboards selected with the Artboard tool a new width or height goes to each of them too, in its `artboards` list, each resized about the reference point the form used for that size, or about its top-left corner when the size was set in the fields directly), flare → Flare Tool Options (dialog `flareOptions`, fields diameter and pathLength (pt), opacity, brightness, growth, fuzziness, longest, rayFuzziness, largest (%), rays, rings, direction (°), raysOn, ringsOn; OK runs tool.setOption {tool: \"flare\", values}: the next flare dragged out uses them, and a Flare click's dialog, which also has x, y and preview (on initially), previews one there and accepts it as one Undo step; Cancel rolls back the preview; with flares selected, the fields show the first one's settings, `flares` lists them and OK runs shape.editFlare with the settings changed instead, leaving the tool's options), lineSegment|arc|rectangularGrid|polarGrid → that tool's Tool Options, its click dialog without x and y (dialog kind = the tool id, `__toolOptions: true`; lineSegment: length (pt), angle (°), fillLine; arc: lengthX, lengthY (pt), reference (0–8), arcType: open|closed, baseAlong: x|y, slope (−100…100), fillArc; rectangularGrid: width, height (pt, the Default Size), reference (0–8), rows, columns, rowSkew, columnSkew (%), frame, fill; polarGrid: the same with concentric, radial, concentricSkew, radialSkew and compound for rows, columns, the skews and frame; OK runs tool.setOption {tool, values} and draws nothing: the next drag uses them (Fill Line, the arc's type, base, slope and fill, the grids' dividers, skews and switches) and a click's dialog opens at them), circle → Circle Tool Options (dialog `circleOptions`, fields center, radii, diameter (all on), color (red|blue|magenta|green|black|gray; blue), standardAnchors (on) and dragThird (on); OK runs tool.setOption {tool: \"circle\", values}), curvatureCircle → Curvature Circle Tool Options (dialog `curvatureCircleOptions`, fields snapTolerance (screen points, 1–40; 5), snapWithoutGuides, annotateRadius, standardAnchors and constantRadius (all on); OK runs tool.setOption {tool: \"curvatureCircle\", values}), columnGraph|stackedColumnGraph|barGraph|stackedBarGraph|lineGraph|areaGraph|scatterGraph|pieGraph|radarGraph → Graph Type for the selected graph, or for the series picked in it with Group Selection (dialog `graphType`, fields the options graph.setType {} returns under their names, with legend, pieLegend, piePosition, pieSort, firstRowInFront, firstColumnInFront, filledLines and lineWidth held for every type; overrideValues and rightOverrideValues, Override Calculated Values of the left or only value axis and of the right one: while one is on OK sends axisMin, axisMax and ticks, or rightAxisMin, rightAxisMax and rightTicks, filled with the calculated values where the graph has none, and one turned off sends null, null and 0; __page: options|valueAxis|rightAxis|categoryAxis, the page shown, options when the type picked has no such page; OK runs graph.setType, and with nothing changed closes without a step of history; an overridden value axis whose maximum is not more than its minimum is an error and the dialog stays open; an error without a selected graph), typeOnPath|verticalTypeOnPath → Type on a Path Options for the selected type on a path (dialog `command` running type.pathOptions; error `nothing selected` without a selection, and the command's error when no type on a path is selected),symbolSprayer|symbolShifter|symbolScruncher|symbolSizer|symbolSpinner|symbolStainer|symbolScreener|symbolStyler → Symbolism Tools Options (dialog `symbolismOptions`, fields tool (the tool whose options show; the Tool row changes it), diameter (pt), intensity and density (1–10), usePressure, method: userDefined|average|random (not used by the Sprayer and the Shifter), showBrush, sprayScrunch, spraySize, spraySpin, sprayScreen, sprayStain and sprayStyle: average|userDefined (the Symbol Sprayer's), proportional and affectsDensity (the Symbol Sizer's), shared by the eight tools; OK runs tool.setOption {tool, values}, after symbol.setDensity from the density the dialog opened with to the new one when symbol sets are selected and it changed), blend → Blend Options, perspectiveGrid → Perspective Grid Options, eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values}), pencil|paintbrush|smooth|blobBrush|eraser → that tool's Tool Options (dialog `freehandOptions`, fields tool and the options the tool keeps: fidelity (px for pencil, paintbrush and smooth, the same at any zoom; pt for blobBrush), fill, keepSelected (on for pencil and paintbrush, off for blobBrush), mergeOnlySelection (off), closeWithin and editWithin (px, 0 is off), livePreview (pencil, on: off draws a thin line while the stroke is drawn, and the path's fill and stroke on release), size (pt), angle (°, −180–180; 0) and roundness (%, 1–100; 100) of the eraser's tip; OK runs tool.setOption {tool, values}), livePaintSelection → Live Paint Selection Tool Options (dialog `livePaintSelectionOptions`, fields selectFills and selectStrokes (both on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the highlight's width, 1–20 px; 4); OK runs tool.setOption {tool: \"livePaintSelection\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), livePaintBucket → Live Paint Bucket Options (dialog `livePaintBucketOptions`, fields paintFills (on) and paintStrokes (off), cursorSwatchPreview (on: the active fill or stroke shows above the pointer between the color swatches before and after it; Left and Right without modifiers step it through the color swatches whether it is on or off), highlight (on), color (the highlight color, #rrggbb or a layer color's name; #ff2a2a), width (the face highlight's width, 1–20 px; 4; an edge's highlight is half as wide); OK runs tool.setOption {tool: \"livePaintBucket\", values}; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), shapeBuilder → Shape Builder Tool Options (dialog `shapeBuilderOptions`, fields gapDetection (off), gapLength (pt, 0–72; 3), openFilledAsClosed (on), clickStrokeSplitsPath (off), pickColorFrom: artwork|swatches (swatches; a saved artwork is kept, except that preferences saved by an earlier version read it as swatches once), cursorSwatchPreview (off), selection: freeform|straightLine (freeform), highlightFill (on), highlightStroke (on), highlightColor (#rrggbb or a layer color's name; #ff4f4f); OK runs tool.setOption {tool: \"shapeBuilder\", values}; a highlightColor with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing), fillArea → the same Shape Builder Tool Options (Fill Area uses their gapDetection, gapLength and openFilledAsClosed), objectsOnPath → Objects on Path Tool Options (dialog `objectsOnPathOptions`, fields pivot (0–8, row by row from the top left; 4, the center) and rotate (°, −360–360; 0); Reset puts 4 and 0 back; Save runs tool.setOption {tool: \"objectsOnPath\", values}: the objects attached next use them, groups attached before keep theirs)", ), ( "ui.colorGuideOptions", diff --git a/docs/mcp.md b/docs/mcp.md index 5ec8ceafd4..d2c7096762 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -15729,7 +15729,8 @@ as an unfilled path does), `pickColorFrom` (`swatches`, the default: a merged sh the Left and Right arrow keys without Shift, Alt or Cmd/Ctrl step the current fill through the document's color swatches; `artwork`: a merged shape takes the appearance, opacity and blending mode of the front-most selected object under the drag's first point, else of the one under its last point, else of the front-most selected object; a -`pickColorFrom` saved with the preferences is kept, and preferences saved without one take `swatches`), `cursorSwatchPreview` (off; with `swatches`, chips above the +`pickColorFrom` saved with the preferences is kept, except that preferences saved by an earlier version, without +`toolSettingsVersion`, read a saved `artwork` as `swatches` once; preferences saved without one take `swatches`), `cursorSwatchPreview` (off; with `swatches`, chips above the pointer show the current fill and the swatches before and after it), `selection` (`freeform`, the default, or `straightLine`: a drag touches what the line from its first point to the pointer crosses), `highlightFill` (on by default; when it is off, merge mode shades no regions), `gapDetection` (off) with `gapLength` (pt, 0 to 72; 3), `clickStrokeSplitsPath` (In Merge Mode, From 932d579a02a751d2ab35a7023ce85e31d7627d09 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 20:08:36 -0800 Subject: [PATCH 187/264] Swatches: rustfmt the idle replay test --- crates/ui-egui/src/panels/swatches/tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index df72fa25e1..7e17c305a5 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -1630,9 +1630,8 @@ fn the_swatch_libraries_menu_fits_its_rows_like_a_library_panels_menu() { fn idle_frames_replay_the_swatch_rows() { use crate::tests::panel_harness::Panel; use craft::ui::testing::{MemoRun, last_frame_memo_runs}; - let runs = |panel: &Panel| { - last_frame_memo_runs(panel.ctx()).iter().filter(|(name, _, run)| name.contains("ListProps") && *run == MemoRun::Ran).count() - }; + let runs = + |panel: &Panel| last_frame_memo_runs(panel.ctx()).iter().filter(|(name, _, run)| name.contains("ListProps") && *run == MemoRun::Ran).count(); let idle = |panel: &mut Panel, after: &str| { panel.frame(); panel.frame(); From 72825d55a6f5cc1a962d469b1ea1b1793fb7524e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 20:10:22 -0800 Subject: [PATCH 188/264] Dependencies: craft-libs pin to 6a4729d5, current main --- Cargo.lock | 172 ++++++++++++++++---------------- Cargo.toml | 76 +++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 126 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 318a40b796..02efc93f98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-automation", "craft-behavior", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "crc32fast", "flate2", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "rustix 1.1.6", ] @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1328,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-docpath", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "crc32fast", "flate2", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "egui", ] @@ -1381,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "md-5", "rayon", @@ -1390,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-cms", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "rayon", ] @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "blake3", "craft-ecproj-format", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "serde", ] @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-codepage", "encoding_rs", @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "serde", "serde_json", @@ -1535,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1555,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "cap-primitives", "craft-atomic", @@ -1606,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "gif", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "flate2", ] @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-dds", "craft-jpeg", @@ -1697,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "thiserror 2.0.21", ] @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1734,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-host", "craft-i18n", @@ -1749,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-i18n", @@ -1763,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -1781,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1793,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "encoding_rs", "image", @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "chrono", "craft-codepage", @@ -1814,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "uds_windows", "winsafe", @@ -1823,7 +1823,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-keymap", @@ -1839,7 +1839,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "flate2", "serde", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1862,7 +1862,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "async-channel", "async-io", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1904,7 +1904,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1939,7 +1939,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-eps", "flate2", @@ -1953,7 +1953,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "encoding_rs", "flate2", @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "dispatch2", "egui", @@ -1977,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1996,7 +1996,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-atomic", "craft-host", @@ -2013,7 +2013,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "fax", "hayro-ccitt", @@ -2024,7 +2024,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-keymap", @@ -2057,7 +2057,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-atomic", "craft-behavior", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "serde", "thiserror 2.0.21", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "serde", "thiserror 2.0.21", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-keymap", @@ -2146,12 +2146,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2165,7 +2165,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-i18n", @@ -2181,7 +2181,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "accesskit", "craft-behavior", @@ -2219,7 +2219,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2230,7 +2230,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -2248,7 +2248,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -2269,7 +2269,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -2290,7 +2290,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-behavior", "craft-host", @@ -2309,7 +2309,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "base64 0.22.1", "chrono", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "flate2", "serde", @@ -2352,7 +2352,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2362,7 +2362,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "js-sys", "serde_json", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "winsafe", ] @@ -2381,7 +2381,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "craft-appkit", "craft-atomic", @@ -2413,7 +2413,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3768,7 +3768,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3777,7 +3777,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3795,7 +3795,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3813,12 +3813,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "flate2", "hayro-ccitt", @@ -4801,7 +4801,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4958,7 +4958,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=891f4060c4aefe2679a65afc9e76bb5ce345de31#891f4060c4aefe2679a65afc9e76bb5ce345de31" +source = "git+https://github.com/storytold/craft-libs?rev=6a4729d5afaea4470bdfe2e8e4f3474d768d7059#6a4729d5afaea4470bdfe2e8e4f3474d768d7059" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index dc46672d51..f7fc21065d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,51 +10,51 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -194,13 +194,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 0e50690b98..cb731d92aa 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "891f4060c4aefe2679a65afc9e76bb5ce345de31", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 4d937f436f..43f0122072 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "891f4060c4aefe2679a65afc9e76bb5ce345de31"; +const REV: &str = "6a4729d5afaea4470bdfe2e8e4f3474d768d7059"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 7a799a1bc48c16f66957032c21eb01e835e53ddc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 20:21:31 -0800 Subject: [PATCH 189/264] Properties: Document sections below the fold keep their controls A MemoView in a scroll area skips a view that is out of view, so in a Properties panel too short for every Document section, the sections below the fold registered no focus stops or accessibility nodes until the panel scrolled: Tab and a screen reader did not reach Keyboard Increment, Scale Strokes & Effects or Snap to Grid. Each section's MemoView now shows out of view too, as the sections did before they were memoized. sections_below_the_fold_keep_their_controls draws the panel 200 pt high and finds those controls below it. It fails without shown_out_of_view. --- .../panels/properties/document_sections.rs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/properties/document_sections.rs b/crates/ui-egui/src/panels/properties/document_sections.rs index ca142a9172..d702cbf899 100644 --- a/crates/ui-egui/src/panels/properties/document_sections.rs +++ b/crates/ui-egui/src/panels/properties/document_sections.rs @@ -72,7 +72,8 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) { memoized("properties-quick-actions", Language { lang }, quick_actions_section, ui); } -/// Shows `section` in a `MemoView` with `id`, keyed on `props`. Tests can show it directly instead, to compare where +/// Shows `section` in a `MemoView` with `id`, keyed on `props`. A section scrolled out of view still runs or replays, so +/// its controls keep their focus stops and accessibility nodes. Tests can show it directly instead, to compare where /// the memoized sections land with where direct ones do. fn memoized(id: &'static str, props: P, section: fn(&mut P, &mut Ui), ui: &mut Ui) { #[cfg(test)] @@ -81,7 +82,7 @@ fn memoized(id: &'static str, props: P, section: fn(&mut P, &mut U section(&mut props, ui); return; } - let _ = MemoView::new(id, props, section).show(ui); + let _ = MemoView::new(id, props, section).shown_out_of_view().show(ui); } /// The Document section: its header and [`document_body`]. @@ -319,6 +320,22 @@ mod tests { assert_eq!(memoized, direct, "memoized sections land where direct ones do"); } + /// In a panel too short for every section, the sections below the fold still register their controls, so Tab + /// and a screen reader reach them before the panel scrolls. + #[test] + fn sections_below_the_fold_keep_their_controls() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let mut panel = Panel::new(app, super::super::show); + panel.room(egui::vec2(300.0, 200.0)); + panel.frame(); + panel.frame(); + for name in ["Keyboard Increment", "Scale Strokes & Effects", "Snap to Grid"] { + assert!(panel.shows(name), "the panel registers {name:?} below the fold"); + assert!(panel.rect(name).top() > 200.0, "{name:?} is below the fold of a 200 pt panel"); + } + } + #[test] fn canceling_the_units_popup_leaves_the_document_unchanged() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); From ad642cb34cb47e24894c18d699984f9494be0807 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 23:25:07 -0500 Subject: [PATCH 190/264] ci(nightly): enable automated daily schedule (06:30 UTC) and Stage 2 signer dispatch (#9959) * ci(nightly): roll out signing pin, macOS docs layout, and profile reopen fix * ci(nightly): enable automated daily schedule and Stage 2 signer dispatch --- .github/nightly-signing-policy.json | 4 ++- .github/workflows/nightly-dispatch.yml | 4 +-- .github/workflows/nightly.yml | 5 ++-- packaging/nightly-release-tests.py | 34 +++++++++++++++++--------- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/nightly-signing-policy.json b/.github/nightly-signing-policy.json index 6427f339db..55d2a1983c 100644 --- a/.github/nightly-signing-policy.json +++ b/.github/nightly-signing-policy.json @@ -123,7 +123,9 @@ } }, "max_artifact_bytes": 2147483648, - "automatic_signer_actors": [], + "automatic_signer_actors": [ + "github-actions[bot]" + ], "platforms": { "windows-x86_64": { "unsigned_artifact_name": "nightly-unsigned-windows-x86_64", diff --git a/.github/workflows/nightly-dispatch.yml b/.github/workflows/nightly-dispatch.yml index dd4a4a02da..4ef372c40b 100644 --- a/.github/workflows/nightly-dispatch.yml +++ b/.github/workflows/nightly-dispatch.yml @@ -11,9 +11,9 @@ permissions: {} jobs: dispatch: - # SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification. + # Enabled for automated scheduled producer completions on main. if: >- - false && github.repository == 'storytold/vectorcraft' && + github.repository == 'storytold/vectorcraft' && github.event_name == 'workflow_run' runs-on: ubuntu-latest timeout-minutes: 5 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0e963e43e1..c2224a81ba 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,8 +1,9 @@ name: VectorCraft unsigned nightly -# Enabled for supervised manual runs by the reviewed manual actor only; no schedule yet. -# A later explicit opt-in may add a cadence (and turn on nightly-dispatch.yml with it). +# Automated daily nightly builds at 06:30 UTC, plus supervised manual runs by reviewed manual actors. on: + schedule: + - cron: '30 6 * * *' workflow_dispatch: permissions: diff --git a/packaging/nightly-release-tests.py b/packaging/nightly-release-tests.py index 9738b641bd..2729b40282 100755 --- a/packaging/nightly-release-tests.py +++ b/packaging/nightly-release-tests.py @@ -244,15 +244,21 @@ class TrustedSourcePreparation(unittest.TestCase): self.assertTrue(literal_off("${{ false }}")) self.assertTrue(literal_off("false && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')")) - def test_no_nightly_schedule_is_registered(self): - for name, event in (("nightly.yml", "workflow_dispatch"), - ("nightly-sign.yml", "workflow_dispatch")): + def test_nightly_triggers_and_schedule_contract(self): + expected_triggers = { + "nightly.yml": [" schedule:", " workflow_dispatch:"], + "nightly-sign.yml": [" workflow_dispatch:"], + } + for name, expected in expected_triggers.items(): source = (ROOT / ".github/workflows" / name).read_text() events = source.split("\non:\n", 1)[1].split("\npermissions:", 1)[0] triggers = [line for line in events.splitlines() if line.startswith(" ") and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")] with self.subTest(workflow=name): - self.assertEqual(triggers, [f" {event}:"], "schedule/activation needs explicit review") + self.assertEqual(triggers, expected, "workflow triggers must match the reviewed schedule contract") + producer = (ROOT / ".github/workflows/nightly.yml").read_text() + crons = re.findall(r"(?m)^ - cron: '([^']+)'$", producer) + self.assertEqual(crons, ["30 6 * * *"], "scheduled nightly cadence must stay at 06:30 UTC") def test_signer_serialization_contract_is_enforced(self): assert_nightly_serialization((ROOT / ".github/workflows/nightly-sign.yml").read_text()) @@ -387,7 +393,8 @@ class NightlyEnabledCallers(unittest.TestCase): source = (ROOT / ".github/workflows/nightly.yml").read_text() policy = json.loads(INSTALLED_POLICY.read_text()) self.assertEqual(reviewed_manual_actors(source, policy), RELEASE_MANAGERS) - self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule") + self.assertEqual(policy["automatic_signer_actors"], ["github-actions[bot]"], + "scheduled dispatch signs only as github-actions[bot]") def test_an_actor_outside_the_release_managers_is_refused(self): source = (ROOT / ".github/workflows/nightly.yml").read_text() @@ -869,19 +876,24 @@ def dispatch_triggers(source): class NightlyDispatchTransport(unittest.TestCase): - """The scheduled transport stays literally off and can only reach the signer branch.""" + """The scheduled transport keeps its exact context guard and can only reach the signer branch.""" + + EXPECTED_GUARD = "github.repository == 'storytold/vectorcraft' && github.event_name == 'workflow_run'" def setUp(self): self.source = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text() - def test_every_dispatch_job_is_literal_off(self): + def test_dispatch_job_keeps_exact_context_guard(self): jobs = self.source.split("\njobs:\n", 1)[1] headers = re.findall(r"(?m)^ (?![\s#])[^\n]+", jobs) conditions = job_conditions(jobs) - self.assertTrue(headers) - self.assertEqual(len(conditions), len(headers), "every job needs a literal-off condition") - for _, expression in conditions: - self.assertTrue(literal_off(expression), "nightly activation requires reviewed test update") + self.assertEqual(headers, [" dispatch:"]) + self.assertEqual(len(conditions), 1, "dispatch job needs its exact context guard") + indicator, expression = conditions[0] + self.assertEqual(indicator, ">-") + self.assertEqual(" ".join(expression.split()), self.EXPECTED_GUARD, + "dispatch context guard may only change with review") + self.assertFalse(literal_off(expression), "scheduled dispatch transport must be enabled") def test_only_a_completed_scheduled_producer_is_transported(self): self.assertEqual(re.findall(r"(?m)^ workflows: (.+)$", self.source), From d9609ce53ca8085c8013de84779852e2beeef5e7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 20:45:12 -0800 Subject: [PATCH 191/264] Dependencies: pin craft-libs 5190e08ab, current main craft-libs main took eight more pull requests after 19805ced1e (raster 3D, mesh ops, SVG group ancestry, image dimensions, footer bar wrapping). Every craft-libs rev, the craft-web-api line and the rev `cargo xtask pdf-deps` checks move to it. Its egui and winit revs are the ones VectorCraft already pins, and Cargo.lock changes only the craft-libs source lines. --- Cargo.lock | 170 ++++++++++++++++---------------- Cargo.toml | 74 +++++++------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 124 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e38ca2a4f..fbe934ae2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-automation", "craft-behavior", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "crc32fast", "flate2", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "rustix 1.1.6", ] @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1328,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-docpath", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "crc32fast", "flate2", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "egui", ] @@ -1381,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "md-5", "rayon", @@ -1390,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-cms", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "rayon", ] @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "blake3", "craft-ecproj-format", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "serde", ] @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-codepage", "encoding_rs", @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "serde", "serde_json", @@ -1535,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1555,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "cap-primitives", "craft-atomic", @@ -1606,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "gif", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "flate2", ] @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-dds", "craft-jpeg", @@ -1697,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "thiserror 2.0.21", ] @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1734,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-host", "craft-i18n", @@ -1749,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-i18n", @@ -1763,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -1781,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1793,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "encoding_rs", "image", @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "chrono", "craft-codepage", @@ -1822,7 +1822,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-keymap", @@ -1838,7 +1838,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "flate2", "serde", @@ -1849,7 +1849,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1861,7 +1861,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "async-channel", "async-io", @@ -1894,7 +1894,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -1927,7 +1927,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1938,7 +1938,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-eps", "flate2", @@ -1952,7 +1952,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "encoding_rs", "flate2", @@ -1963,7 +1963,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "dispatch2", "egui", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1995,7 +1995,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-atomic", "craft-host", @@ -2012,7 +2012,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "fax", "hayro-ccitt", @@ -2023,7 +2023,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2044,7 +2044,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-keymap", @@ -2056,7 +2056,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2096,7 +2096,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-atomic", "craft-behavior", @@ -2111,7 +2111,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "serde", "thiserror 2.0.21", @@ -2121,7 +2121,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "serde", "thiserror 2.0.21", @@ -2130,7 +2130,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-keymap", @@ -2145,12 +2145,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-i18n", @@ -2180,7 +2180,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "accesskit", "craft-behavior", @@ -2218,7 +2218,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2229,7 +2229,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -2247,7 +2247,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -2268,7 +2268,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -2289,7 +2289,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-behavior", "craft-host", @@ -2308,7 +2308,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "base64 0.22.1", "chrono", @@ -2340,7 +2340,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "flate2", "serde", @@ -2351,7 +2351,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2361,7 +2361,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "js-sys", "serde_json", @@ -2372,7 +2372,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "winsafe", ] @@ -2380,7 +2380,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "craft-appkit", "craft-atomic", @@ -2412,7 +2412,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3767,7 +3767,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3776,7 +3776,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3794,7 +3794,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3812,12 +3812,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "flate2", "hayro-ccitt", @@ -4800,7 +4800,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4957,7 +4957,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=19805ced1eee99a0667facfc3e02ca909e7df348#19805ced1eee99a0667facfc3e02ca909e7df348" +source = "git+https://github.com/storytold/craft-libs?rev=5190e08ab8ef93c0abdfce2790a34cc0c377b3b6#5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 4ec887ba19..0c31608537 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,49 +10,49 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } # Nightly profile isolation, launch protocol, and security fence. craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" } # internal @@ -194,13 +194,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 98a00a7ca6..e72a7f26ed 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "19805ced1eee99a0667facfc3e02ca909e7df348", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index d3e0f6e1df..668abfea2e 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "19805ced1eee99a0667facfc3e02ca909e7df348"; +const REV: &str = "5190e08ab8ef93c0abdfce2790a34cc0c377b3b6"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 32a5fef78df4046086b44083eab0ef7ecea1ea72 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 21:37:32 -0800 Subject: [PATCH 192/264] Layers: a selection change keeps the panel's row order The Layers panel built its row order again on every selection change: each change made a new Tracked for the rows, and the rows reported no order revision, so the panel asked every row for the rows inside it (7 calls for the 6 rows of the new test's document). - LayerRows reports LayerTree::order_revision: a hash of the document, the open rows, Show Layers Only and the isolated node. The selection, the highlighted rows, the current layer and the names are not in it. - refresh_rows writes new rows into the kept Tracked while the document (uid and revert count) stays the same, and makes a new Tracked for another document or after File > Revert. - The craft-libs pin moves from 186a229c8 to aa7e668ec, current craft-libs main, which has craft-libs#4319 (LayerTree::order_revision). The winit rev moves to 0dfcec0eb, as craft-libs pins it; egui stays at 14c39fed1. xtask pdf-deps checks the new rev. craft-nightly keeps the rev main pins it at. Two tests failed on the new craft-libs: - canvas::tests::a_selection_drag_draws_its_marks_in_the_frame_the_pointer_moves: since craft-libs#4143 a frame runs one pass where it ran two, and the bounding box, Live Corners, hollow corners and shape widgets were drawn before the tool host took the frame's pointer event, so the box showed at the old corner. They are now drawn after it, into paint slots kept in their old order. - tests::nativemenu::applying_a_dialog_preview_reads_the_menus: since craft-libs#4350 the closed dialog's angle field gives up the keys one frame sooner, so the menus are sent again without the text-editing gate within the frames the test ran. The test now waits for the gate and counts the read and that send apart. --- Cargo.lock | 211 +++++++++++----------- Cargo.toml | 76 ++++---- apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/canvas.rs | 22 ++- crates/ui-egui/src/panels/layers.rs | 25 ++- crates/ui-egui/src/panels/layers/model.rs | 29 ++- crates/ui-egui/src/panels/layers/tests.rs | 75 ++++++++ crates/ui-egui/src/tests/nativemenu.rs | 18 +- xtask/src/pdf_deps.rs | 2 +- 9 files changed, 295 insertions(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fce3ecad1..9c3989051d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,12 +626,6 @@ dependencies = [ "cpufeatures 0.3.1", ] -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -725,6 +719,17 @@ dependencies = [ "brotli-decompressor 5.0.3", ] +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", + "brotli-decompressor 6.3.2", +] + [[package]] name = "brotli-decompressor" version = "5.0.3" @@ -1184,19 +1189,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" -dependencies = [ - "bitflags 2.13.2", - "block", - "cfg-if", - "core-foundation 0.10.1", - "libc", -] - [[package]] name = "core_detect" version = "1.0.0" @@ -1239,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-automation", "craft-behavior", @@ -1280,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "crc32fast", "flate2", @@ -1291,18 +1283,19 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "block2 0.6.2", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-core-graphics", "objc2-foundation 0.3.2", ] [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "rustix 1.1.6", ] @@ -1310,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1335,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1353,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-docpath", @@ -1371,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "crc32fast", "flate2", @@ -1380,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "egui", ] @@ -1388,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "md-5", "rayon", @@ -1397,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-cms", @@ -1422,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1433,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1443,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "rayon", ] @@ -1451,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1477,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "blake3", "craft-ecproj-format", @@ -1493,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "serde", ] @@ -1501,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1520,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-codepage", "encoding_rs", @@ -1532,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "serde", "serde_json", @@ -1542,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1562,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1581,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1590,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "cap-primitives", "craft-atomic", @@ -1613,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "gif", ] @@ -1626,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "flate2", ] @@ -1634,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1647,8 +1640,10 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "chrono", "fixed_decimal", "icu_calendar", @@ -1675,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-dds", "craft-jpeg", @@ -1702,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1720,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "thiserror 2.0.21", ] @@ -1728,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1739,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-host", "craft-i18n", @@ -1754,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-i18n", @@ -1768,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -1786,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1798,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "encoding_rs", "image", @@ -1809,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "chrono", "craft-codepage", @@ -1827,7 +1822,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-keymap", @@ -1843,7 +1838,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "flate2", "serde", @@ -1854,7 +1849,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1866,12 +1861,12 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "async-channel", "async-io", "async-process", - "core-graphics2", + "craft-appkit", "craft-atomic", "craft-docpath", "craft-host", @@ -1881,6 +1876,8 @@ dependencies = [ "js-sys", "log", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "rfd", "serde", "serde_json", @@ -1897,7 +1894,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1906,7 +1903,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -1930,7 +1927,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1941,7 +1938,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-eps", "flate2", @@ -1955,7 +1952,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "encoding_rs", "flate2", @@ -1966,7 +1963,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "dispatch2", "egui", @@ -1979,7 +1976,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1998,7 +1995,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-atomic", "craft-host", @@ -2015,7 +2012,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "fax", "hayro-ccitt", @@ -2026,7 +2023,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2047,7 +2044,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-keymap", @@ -2059,7 +2056,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2084,7 +2081,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2099,7 +2096,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-atomic", "craft-behavior", @@ -2114,7 +2111,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "serde", "thiserror 2.0.21", @@ -2124,7 +2121,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "serde", "thiserror 2.0.21", @@ -2133,7 +2130,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-keymap", @@ -2148,12 +2145,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2167,7 +2164,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-i18n", @@ -2183,7 +2180,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "accesskit", "craft-behavior", @@ -2221,7 +2218,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2232,7 +2229,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -2250,7 +2247,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -2271,7 +2268,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -2292,7 +2289,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-behavior", "craft-host", @@ -2311,7 +2308,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "base64 0.22.1", "chrono", @@ -2343,7 +2340,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "flate2", "serde", @@ -2354,7 +2351,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2364,7 +2361,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "js-sys", "serde_json", @@ -2375,7 +2372,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "winsafe", ] @@ -2383,7 +2380,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "craft-appkit", "craft-atomic", @@ -2415,7 +2412,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3770,16 +3767,16 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ - "brotli", + "brotli 8.0.4", "hayro-postscript", ] [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3797,7 +3794,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3815,12 +3812,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "flate2", "hayro-ccitt", @@ -4803,7 +4800,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4960,7 +4957,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -10076,7 +10073,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=a517b3846ee8457d84ee4975110bfda6797c44dc#a517b3846ee8457d84ee4975110bfda6797c44dc" +source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" dependencies = [ "ahash", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index cc76d129c5..f7aa86aff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,49 +10,49 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # Nightly profile isolation, launch protocol, and security fence. craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" } # internal @@ -194,13 +194,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } @@ -212,4 +212,4 @@ egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed1817 egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } +winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index ce4d1d3d44..0a3a273fcc 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index f340f3bac2..d4c31c90d0 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -278,8 +278,8 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin pressed } -/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks, the -/// picture last. +/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks and the +/// widgets that take no press, the picture last. fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: Option<&ToolPass>, win: Win, kind: BodyKind) -> Body { let live = kind == BodyKind::Live; let presenting = app.ui.screen_mode == 3; @@ -299,11 +299,12 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O crate::dialogs::simplify_slider::show(app, ui, &space.view); } guides::show(app, ui, space, win, kind); - widgets::show_hollow_corners(app, ui, space, kind); - // The selection's marks paint here, under the widgets and bars, and are drawn after the tool host has taken this + // The hollow corners, the selection's marks and the bounding box with the shape widgets paint here, in that order, + // under the 3D handles and the bars. They take no press, so they are drawn after the tool host has taken this // frame's pointer event, from the document as the event leaves it. + let hollow = PaintSlot::reserve(ui.painter()); let marks = PaintSlot::reserve(ui.painter()); - widgets::show(app, ui, space, win, kind); + let boxes = PaintSlot::reserve(ui.painter()); if !presenting && !revolve_editing(app) { crate::panels::three_d::handles::show(app, ui, space); } @@ -340,8 +341,17 @@ fn show_body(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, pass: O } } let after = PaintSlot::reserve(ui.painter()); + widgets::show_hollow_corners(app, ui, space, kind); + let hollow_shapes = after.take_after(ui.ctx()); + let after = PaintSlot::reserve(ui.painter()); selection::show(app, ui, space, win, kind); - marks.extend(ui.ctx(), after.take_after(ui.ctx())); + let mark_shapes = after.take_after(ui.ctx()); + let after = PaintSlot::reserve(ui.painter()); + widgets::show(app, ui, space, win, kind); + let box_shapes = after.take_after(ui.ctx()); + hollow.extend(ui.ctx(), hollow_shapes); + marks.extend(ui.ctx(), mark_shapes); + boxes.extend(ui.ctx(), box_shapes); drops::show(app, ui, win, kind); raster::picture(app, ui, space, win, kind); out diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 2987d350a8..347a22ae83 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -182,8 +182,9 @@ pub struct LayersUi { /// The selection square clicked last in each open document, by the document's `uid`: where a Shift-click on another /// square starts. pub art_anchors: HashMap, - /// The active document's rows with the [`LayerRows::key`] they were listed at. - rows: Option<(u64, Tracked)>, + /// The active document's rows with the [`LayerRows::key`] they were listed at and the document's `uid` and + /// `reverts`. + rows: Option<(u64, (u64, u64), Tracked)>, } impl Default for LayersUi { @@ -223,7 +224,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { thumbnails.hold(app.session.active().is_some_and(|st| st.interaction.is_some()) || app.session.tool_busy()); let settings = app.ui.layers_panel.settings(); refresh_rows(app); - let (Some(st), Some((_, kept))) = (app.session.active(), &app.ui.layers_ui.rows) else { return }; + let (Some(st), Some((_, _, kept))) = (app.session.active(), &app.ui.layers_ui.rows) else { return }; let tree = DocLayers::of(st, kept); let source = thumbs::LayerThumbs { doc: &st.doc }; let mut panel = LayersPanel::new(kept) @@ -294,13 +295,23 @@ fn unrevealed(app: &mut VectorcraftApp, f: impl FnOnce(&mut VectorcraftApp) - r } -/// Lists the active document's rows again when what they are listed from changed. +/// Lists the active document's rows again when what they are listed from changed. The new rows go into the kept +/// [`Tracked`] while the document is the same, so the panel keeps its display order when the +/// [order revision](LayerRows::order_of) stays; another document, or the same one after File › Revert, gets a new one. fn refresh_rows(app: &mut VectorcraftApp) { let Some(st) = app.session.active() else { return }; let key = LayerRows::key(app, st); - if app.ui.layers_ui.rows.as_ref().is_none_or(|(kept, _)| *kept != key) { - let rows = Tracked::new(LayerRows::new(app, st)); - app.ui.layers_ui.rows = Some((key, rows)); + let doc = (st.uid, st.reverts); + if app.ui.layers_ui.rows.as_ref().is_some_and(|(kept, _, _)| *kept == key) { + return; + } + let new = LayerRows::new(app, st); + match &mut app.ui.layers_ui.rows { + Some((kept, of, rows)) if *of == doc => { + rows.edit(|rows| *rows = new); + *kept = key; + } + slot => *slot = Some((key, doc, Tracked::new(new))), } } diff --git a/crates/ui-egui/src/panels/layers/model.rs b/crates/ui-egui/src/panels/layers/model.rs index c73794b6d0..ecd2d7a954 100644 --- a/crates/ui-egui/src/panels/layers/model.rs +++ b/crates/ui-egui/src/panels/layers/model.rs @@ -202,6 +202,14 @@ pub(super) struct LayerRows { /// In isolation mode, the isolated node: the top row. #[plain_data(assume = "a node id is an integer")] root: Option, + /// What the display order is built from ([`LayerRows::order_of`]). + order: u64, +} + +#[cfg(test)] +thread_local! { + /// How many times [`LayerRows::children`] was asked on this thread. + pub(super) static CHILDREN_CALLS: std::cell::Cell = const { std::cell::Cell::new(0) }; } /// [`LayerRows`] with the editing state of their document, for the panel's host code in one pass. @@ -243,7 +251,9 @@ impl LayerRows { let guide_rows = ruler.iter().enumerate().filter_map(|(i, g)| Some((g.id?, i))).collect(); let blends = st.selection.objects.iter().copied().filter(|id| doc.node(*id).is_some_and(|n| matches!(n.kind, NodeKind::Blend { .. }))); let selected: HashSet = st.selection.objects.iter().copied().collect(); + let root = st.isolation.and_then(|i| isolated_root(doc, i)).map(|(n, ..)| n.id); Self { + order: Self::order_of(doc, &st.layers_open, app.ui.layers_panel.layers_only, root), doc: doc.clone(), opts: app.ui.layers_panel.clone(), xml_id: by_xml_id(app), @@ -258,10 +268,20 @@ impl LayerRows { holding: super::rows::holding(doc, &selected), selected, blends: blends.collect(), - root: st.isolation.and_then(|i| isolated_root(doc, i)).map(|(n, ..)| n.id), + root, } } + /// A hash of everything the display order reads ([`LayerTree::children`] and [`LayerTree::is_open`]): the + /// document, which an edit replaces and a selection change keeps (its ruler guides and an opacity mask being + /// edited are in it), the open rows, Show Layers Only and the isolated node. The selection, the highlighted rows, + /// the current layer, the names and the other Panel Options are not in it. + fn order_of(doc: &Arc, open: &OpenRows, layers_only: bool, root: Option) -> u64 { + let mut hasher = DefaultHasher::new(); + (Arc::as_ptr(doc) as usize, open.generation(), layers_only, root).hash(&mut hasher); + hasher.finish() + } + /// What the rows of `st` are listed from: the document and its revision (which every edit and /// selection change moves), the open rows, isolation mode, the highlighted rows and the current /// layer, the Panel Options, Identify Objects By and the language. @@ -461,6 +481,8 @@ impl LayerTree for LayerRows { /// The top rows are the layers (only the opacity mask's while one is edited), or in isolation /// mode the isolated layer, sublayer, group or object. fn children(&self, parent: Option<&RowId>) -> Vec { + #[cfg(test)] + CHILDREN_CALLS.with(|c| c.set(c.get() + 1)); match parent { None => match self.root { Some(root) => vec![RowId::Node(root)], @@ -491,6 +513,11 @@ impl LayerTree for LayerRows { false } + /// The display order changes only with what [`LayerRows::order_of`] hashes: a selection change keeps it. + fn order_revision(&self) -> Option { + Some(self.order) + } + fn info(&self, id: &RowId) -> LayerInfo { match *id { RowId::Node(id) => match self.doc.node(id) { diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 5eeca21a8e..7492008a2b 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -1352,3 +1352,78 @@ fn idle_frames_walk_no_node_for_the_selection_squares() { } assert!((1..=12).contains(&(visits() - before)), "a new selection walks the tree once: {}", visits() - before); } + +/// A selection change keeps the panel's display order: no row is asked for the rows inside it. Closing a row, Show +/// Layers Only and an edit build the order again, and the rows follow. +#[test] +fn a_selection_change_keeps_the_display_order() { + use crate::tests::panel_harness::Panel; + let calls = || super::model::CHILDREN_CALLS.with(std::cell::Cell::get); + let (mut app, [_, sub, _, b, a, c]) = nested(); + for (id, name) in [(sub, "Sub"), (b, "B"), (a, "A"), (c, "C")] { + name_row(&mut app, id, name); + } + app.session.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + let mut panel = Panel::new(app, show); + panel.frame(); + let before = calls(); + panel.app().session.execute("select.set", &json!({"ids": [a.0]})).unwrap(); + for _ in 0..3 { + panel.frame(); + } + assert_eq!(calls() - before, 0, "a selection change asks no row for its rows"); + assert!(panel.shows("A") && panel.shows("B"), "the rows stay"); + + expand(&mut panel.app(), &json!({"ids": [sub.0], "open": false})).unwrap(); + let before = calls(); + panel.frame(); + panel.frame(); + assert!(calls() > before, "closing a row builds the order again"); + assert!(!panel.shows("A") && panel.shows("Sub") && panel.shows("C"), "the closed sublayer's rows are gone"); + + panel.app().ui.layers_panel.layers_only = true; + panel.frame(); + panel.frame(); + assert!(!panel.shows("C") && panel.shows("Sub"), "Show Layers Only leaves the objects out"); + + panel.app().ui.layers_panel.layers_only = false; + panel.app().session.execute("object.isolate", &json!({"id": sub.0})).unwrap(); + panel.frame(); + panel.frame(); + assert!(panel.shows("Sub") && !panel.shows("C"), "isolation mode lists only the isolated sublayer"); + panel.app().session.execute("object.exitIsolation", &json!({})).unwrap(); + expand(&mut panel.app(), &json!({"ids": [sub.0], "open": true})).unwrap(); + let made = panel.app().session.execute("shape.rectangle", &json!({"x": 200, "y": 200, "width": 10, "height": 10})).unwrap(); + let d = NodeId(made["id"].as_u64().unwrap()); + name_row(&mut panel.app(), d, "D"); + panel.frame(); + panel.frame(); + assert!(panel.shows("D") && panel.shows("C"), "an edit lists the new object"); +} + +/// The order revision stays through a selection change and moves with the document, the open rows, Show Layers Only +/// and isolation mode. +#[test] +fn the_order_revision_follows_what_the_display_order_reads() { + let order = |app: &VectorcraftApp| LayerRows::new(app, app.session.active().unwrap()).order_revision(); + let (mut app, [_, sub, g, b, a, _]) = nested(); + let first = order(&app); + assert!(first.is_some(), "the rows report an order revision"); + app.session.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + assert_eq!(order(&app), first, "a selection change keeps it"); + app.session.execute("object.isolate", &json!({"id": sub.0})).unwrap(); + let isolated = order(&app); + assert_ne!(isolated, first, "isolation mode moves it"); + app.session.execute("object.exitIsolation", &json!({})).unwrap(); + let left = order(&app); + assert_ne!(left, isolated, "leaving isolation mode moves it"); + app.ui.layers_panel.layers_only = true; + assert_ne!(order(&app), left, "Show Layers Only moves it"); + app.ui.layers_panel.layers_only = false; + assert_eq!(order(&app), left, "and turning it off gives it back"); + expand(&mut app, &json!({"ids": [g.0], "open": false})).unwrap(); + let closed = order(&app); + assert_ne!(closed, left, "closing a row moves it"); + name_row(&mut app, a, "A"); + assert_ne!(order(&app), closed, "an edit moves it"); +} diff --git a/crates/ui-egui/src/tests/nativemenu.rs b/crates/ui-egui/src/tests/nativemenu.rs index f1f6bcd09c..1fad419639 100644 --- a/crates/ui-egui/src/tests/nativemenu.rs +++ b/crates/ui-egui/src/tests/nativemenu.rs @@ -355,10 +355,11 @@ fn a_control_port_cancel_of_a_dialog_preview_reads_the_menus() { } /// OK applies the rotation a dialog previews as one undo step: the menus are read then, with Undo -/// naming it, and not for the angles previewed before. +/// naming it, and not for the angles previewed before. Once the dialog's angle field no longer takes +/// the keys, the menus are sent once more without the text-editing gate. #[test] fn applying_a_dialog_preview_reads_the_menus() { - let (m, (read, synced, closed, after)) = undisturbed(|m| { + let (m, (read, synced, applied, closed, after)) = undisturbed(|m| { m.rotate_preview(); let read = m.angles(4); let synced = m.fake.synced(); @@ -367,12 +368,21 @@ fn applying_a_dialog_preview_reads_the_menus() { // gone two frames later. m.frame(vec![]); m.frame(vec![]); + let applied = m.fake.synced(); + // The frame after the field gives up the keys sets the gate. + for _ in 0..4 { + if !m.ctx.egui_wants_keyboard_input() { + break; + } + m.frame(vec![]); + } m.frame(vec![]); - (read, synced, !m.app.session.in_interaction() && !m.app.any_dialog_open(), m.fake.synced()) + (read, synced, applied, !m.app.session.in_interaction() && !m.app.any_dialog_open(), m.fake.synced()) }); assert_eq!(read, 0, "the menus weren't read while the dialog previewed the angles"); assert!(closed); - assert_eq!(after, synced + 1, "the menus were read"); + assert_eq!(applied, synced + 1, "the menus were read"); + assert_eq!(after, synced + 2, "and sent once more when the gate changed"); assert_eq!(find(&m.fake.last(), "edit.undo").label, "Undo Rotate"); } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index f4f02f8627..d69afcd0a8 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "186a229c8da8db5916f8a863dfd894f1879af735"; +const REV: &str = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 1588d43a2d2d7d9d2fdf7578321bf8732d6db5f7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 22:02:45 -0800 Subject: [PATCH 193/264] Nightly: craft-nightly uses the same craft-libs rev as the other crates craft-nightly was still pinned at 1f6c3a21f while every other craft-libs crate moved to aa7e668ec. The newer craft-nightly brings: - craft-libs#4297: profile-root validation requires HOME on Unix and APPDATA and LOCALAPPDATA on Windows, and refuses a configured OS directory that is relative or contains `..` (ProfileError::MissingStableBoundary and InvalidStableBoundary). - craft-libs#4304: a Unix socket (or AF_UNIX socket on Windows) in a profile's single-instance/ folder is accepted when the app lists that folder, and Launch reports whether the launcher's `--` separator was present (passthrough_args_with_launcher_separator). - craft-libs#4309: a Windows test fix only. VectorCraft builds against these without code changes: it does not construct Launch or match ProfileError exhaustively, and its single-instance record is instance.json with a TCP listener. Cargo.lock adds uds_windows (already in the lock) to craft-nightly's dependencies. --- Cargo.lock | 3 ++- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c3989051d..c2892308bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1814,8 +1814,9 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24#1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ + "uds_windows", "winsafe", ] diff --git a/Cargo.toml b/Cargo.toml index f7aa86aff7..8c2995ce63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "aa7e6 craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "1f6c3a21f85ed96f8fd4ddd5a959d4e1edbedb24" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } From e94496b42f6d05068eab6bc934f9f54207aacb88 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 22:16:18 -0800 Subject: [PATCH 194/264] Asset Export: the settings scroll in a short panel With assets in the panel and many format rows, the Export Settings section grew past the top of the panel, so its heading and the first format rows could not be reached. The settings now sit in a scrolling stack that takes at most half the panel's height, as the CSS Properties panel does, and the preset name row, Export and the footer bar stay below it. --- crates/ui-egui/src/panels/asset_export.rs | 25 ++++++++----- .../ui-egui/src/panels/tests_asset_export.rs | 36 +++++++++++++++++++ docs/mcp.md | 4 ++- docs/target-app-parity.md | 1 + 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/panels/asset_export.rs b/crates/ui-egui/src/panels/asset_export.rs index 048d8dcfb0..26828a967d 100644 --- a/crates/ui-egui/src/panels/asset_export.rs +++ b/crates/ui-egui/src/panels/asset_export.rs @@ -34,8 +34,8 @@ use craft::theme::Variant; use craft::theme::variant::Tone; use craft::ui::buttons::{Button, IconButton}; use craft::ui::contract::{ - Bind, CollectionEvent, Entry, Props as _, RowAlign, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, TooltipSpec, clicked, - request_rename, + Bind, CollectionEvent, Entry, Props as _, RowAlign, Scroll, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, TooltipSpec, + clicked, request_rename, }; use craft::ui::dialog::StackDialog as _; use craft::ui::display::{Divider, Shade, Text}; @@ -524,13 +524,22 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let (selection, saving) = (&mut model.selection, &mut model.saving); let (mut export_clicked, mut footer, mut screens) = (false, None, false); // The grid takes the room the settings, Export and the footer bar leave. + // The settings scroll in at most half the panel's height, so a long list of format rows stays reachable. + // The preset name row stays below them, in view when Save As Preset opens it. + let settings_room = ui.available_height() / 2.0; + let settings_id = ui.scope_id().with(("asset-export-settings", uid)); let footed = Stack::new().fill().footer(|ui, _| { - crate::panels::section(tl!("Export Settings")).show(ui, |ui, _| { - let (change, files_each) = settings(ui, st); - (seen.change, seen.files_each) = (change, files_each); - seen.format_3d = format_3d(ui, st, &sel_or_all(&shown_sel, &all)); - seen.save = save_row(ui, saving); - }); + Stack::new().id(settings_id).label(tl!("Export Settings")).fill_width().scroll(Scroll::vertical()).room_height(settings_room).show( + ui, + |ui, _| { + crate::panels::section(tl!("Export Settings")).show(ui, |ui, _| { + let (change, files_each) = settings(ui, st); + (seen.change, seen.files_each) = (change, files_each); + seen.format_3d = format_3d(ui, st, &sel_or_all(&shown_sel, &all)); + }); + }, + ); + seen.save = save_row(ui, saving); Row::new().fill_width().align(RowAlign::End).show(ui, |ui, _| { let label = if shown_sel.is_empty() || shown_sel.len() == all.len() { tl!("Export").to_string() diff --git a/crates/ui-egui/src/panels/tests_asset_export.rs b/crates/ui-egui/src/panels/tests_asset_export.rs index 369006b699..b71ca788a9 100644 --- a/crates/ui-egui/src/panels/tests_asset_export.rs +++ b/crates/ui-egui/src/panels/tests_asset_export.rs @@ -1016,6 +1016,42 @@ fn the_scale_row_fits_the_panel_width() { } } +/// In a short panel with many format rows, the Export Settings heading and the first row stay inside the panel, and +/// the settings scroll above Export and the footer bar. +#[test] +fn the_settings_scroll_inside_a_short_panel() { + use craft::ui::contract::Role; + let (mut app, _, [a, _]) = app(true); + app.run("assets.add", json!({"ids": [a]})).unwrap(); + let mut p = panel(app); + p.room(egui::vec2(300.0, 1600.0)); + p.frame(); + for _ in 0..7 { + p.click("+ Add Scale"); + } + assert_eq!(settings(&p)["formats"].as_array().unwrap().len(), 8); + p.room(egui::vec2(300.0, 280.0)); + p.frame(); + p.frame(); + let heading = p.painted("Export Settings"); + assert!(!heading.is_empty(), "the Export Settings heading is painted"); + for rect in heading { + assert!(rect.top() >= -0.5 && rect.bottom() <= 280.5, "the Export Settings heading at {rect:?} is outside a 280 pt panel"); + } + let scale = p.rect_role("Scale", Role::COMBO_BOX); + assert!(p.in_view("Scale") && scale.top() >= -0.5, "the first format row at {scale:?} is outside the panel"); + let export = p.rect("Export"); + assert!(export.top() >= -0.5 && export.bottom() <= 280.5, "Export at {export:?} is outside a 280 pt panel"); + // The wheel over the settings brings the last row's Add Scale into view, and Export stays where it was. + for _ in 0..20 { + p.scroll_at(scale.center(), -120.0); + p.frame(); + } + let add = p.rect("+ Add Scale"); + assert!(p.in_view("+ Add Scale") && add.bottom() <= 280.5, "Add Scale at {add:?} is not reachable"); + assert_eq!(p.rect("Export"), export, "Export moved while the settings scrolled"); +} + /// The menu adds the selected artwork as one asset or one per object (an object that is an asset already keeps its /// asset), and is off with no artwork selected. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index a9e9d9649a..a7fec3009e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -12490,7 +12490,9 @@ Open Location after Export run these two (sub-folders sort the pictures; `assets folder itself), and its Format Settings… opens Export for Screens on the first row's format settings. `document.exportForScreens {assets: [id…]}` does the same with its own params (the dialog's Assets tab). An asset's crop, and the crop of `export` with `selection: true`, is the bounds the -renderer measures for what the art draws, its effects included. +renderer measures for what the art draws, its effects included. In the panel, Export Settings takes at most half the +panel's height and scrolls on its own, so every format row can be reached in a short panel while Export and the footer +bar stay in place. ```json {"name":"run_command","arguments":{"command":"assets.add","params":{"multiple":true}}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 4df379b998..9469046bc4 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1086,6 +1086,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Batch… over data sets offers None, Save and Close and Folder as the destination, as for a folder source. Save and Close saves the open document over its own file after each data set, so the file keeps only the last data set, unless a recorded Save step that Override Save points into the destination folder first makes each data set's file the document's own. A recorded Save, Save a Copy, Save as Template or export step that writes a file and that the batch does not point into the destination folder (destination None, Override Save or Override Export off, or a copy, template, PDF, EPS, DXF, Save for Web or Save for Office Documents step) also writes the same file for every data set. In either case the dialog shows a warning and `action.batch` returns a `warning`. Unless a recorded Save or Save As step writes a file and makes it the document's own first, `action.batch` refuses Save and Close over the data sets of a document that was never saved, was converted from an older version or was restored by Data Recovery. - Export for Screens: the dialog's Example line shows the path of the file the export writes first, sub-folder included, named as the export names it, for the first chosen artboard, asset, layer or object (`document.exportForScreens`). - Export presets: the Asset Export panel menu lists the export presets of Export for Screens, with Import Preset… and Export Preset…, which read and write `.vcexportpresets` files (`document.exportPresets.import`, `document.exportPresets.export`). An imported preset whose name is taken gets a number. In the panel, a preset applies to the shared export settings (`assets.settings.set {exportPreset}`), and Save Preset… saves them. With Create Sub-folders off, the panel's Export writes every file into the folder itself, mobile and density rows included. + - Export Settings in the Asset Export panel scroll on their own in a short panel. - Export for Screens artboard names can be double-clicked to rename them in grid or list view (#7275). Enter, a click outside the field or switching to Assets commits the name; Escape cancels the edit. The dialog stays open, checked artboards stay selected and the rename is undoable. The typed name goes to the artboard that was double-clicked even when the artboards change order while it is typed; the field closes when its artboard is deleted or another document becomes active. Evidence: `dialogs::tests_screens::double_clicking_an_artboard_name_in_export_for_screens_renames_it`, `dialogs::tests_screens::switching_export_tabs_commits_an_artboard_name`, `dialogs::tests_screens::an_artboard_name_follows_its_artboard_while_it_is_typed` and `dialogs::tests_screens::an_artboard_name_stays_with_its_document`. - Asset Export tile context menus (2026-11-20): Export / Remove operate on the selected assets, with plural labels; Rename edits the clicked tile inline; Select Artwork on Canvas selects its source nodes; collecting selected artwork as one or multiple assets is enabled only with canvas selection. Right-click selects an unselected tile and preserves an existing multi-selection. Export shares the raster/3D path; removal is one undo step without removing art. Headless regressions: `panels::tests_asset_export` (selection, export targets, removal/Undo/Redo, source artwork, rename and collection). This reduces G12; UI parity scores and estimates are unchanged. - Asset Export panel menu: Create Sub-folders (on by default) and Open Location after Export are check items that set the dialog's two checkboxes (`assets.settings.set {subfolders, openLocation}`), and the panel's Export follows them, including a folder per format or item that Export for Screens remembers (3D assets' mesh files go in the folder itself); Format Settings… opens Export for Screens on the first row's format settings ([Asset Export panel](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/collect-and-export-assets-from-asset-export-panel.html)). Tests: `panels::tests_asset_export`. From bc9e7c912426ad63e4d612553acbd94c0204ff29 Mon Sep 17 00:00:00 2001 From: jmverges Date: Mon, 30 Nov 2026 07:06:19 +0000 Subject: [PATCH 195/264] .ai import: a word the page draws from two text objects in a row is their type Where the text document makes the type of every text object that shows, each piece of the page's type is matched with the made type that holds it, and a word of the piece is that type's when its spelling contains the word. The page can draw two text objects as one word: a word and a letter set apart from it (a swash "h" after "Spirit") come out of the page as one piece, "Spirith". Both text objects hold the piece, but neither spells the word, so it was counted as type with no text object, with the note "some of the page's type has no text object in the layers, so it is left out" (a loss, so `convert` wouldn't write over the file), though both text objects come in and draw it. A word still left is now the type of the text objects holding the piece when it is the last word of one of them joined to the first word of another that draws after it along the first one's lines. Each part is a whole word of its text object, so bits of words don't make up a piece, and the two the other way round don't make the word. In our garment files (used locally, never committed) this takes the note off one file of 424 and changes nothing else. Co-Authored-By: Claude Opus 5.5 --- crates/eps/src/import/native/plan.rs | 38 +++++++++++++++++++++++++-- crates/eps/src/import/tests_native.rs | 32 ++++++++++++++++++++++ docs/file-format-parity.md | 1 + 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/crates/eps/src/import/native/plan.rs b/crates/eps/src/import/native/plan.rs index 6d4799721e..487cae27b4 100644 --- a/crates/eps/src/import/native/plan.rs +++ b/crates/eps/src/import/native/plan.rs @@ -338,6 +338,12 @@ fn made_content(infos: &[SlotInfo], made: Vec>, laid: bool) -> Vec< /// it, as far as strokes round type reach) as type the page draws. How many of the page's text /// objects no made type takes, shown or not: none that holds a piece of the object has its words /// ([`spelling`]). Past `MAX_PAIRS` comparisons nothing is marked or counted (`None`). +/// +/// The page can draw two text objects as one word: a word and a letter set apart from it (a swash +/// "h" after "Spirit") come out of the page as one piece, "Spirith", that neither spells. A word +/// left that is the last word of one text object holding the piece joined to the first word of +/// another that holds it and draws after it, along the first one's lines, is theirs +/// ([`joined_by_two`]). fn see_page_type(content: &mut [Content], shown: &[Vec>]) -> Option { let texts = |o: &[Arc]| o.iter().filter_map(|n| if let NodeKind::Text(_) = &n.kind { Some(n.clone()) } else { None }).collect::>(); // Each object's pieces of type, and the words of them that no made type holding it has yet. @@ -348,22 +354,50 @@ fn see_page_type(content: &mut [Content], shown: &[Vec>]) -> Option= 0.5 * r.area().max(1e-9); + // The made type holding each object, in order: where it draws and its words. + let mut holders: Vec> = vec![vec![]; objects.len()]; for c in content { let Content::Made(node, region, seen) = c else { continue }; // Hidden made type has no region: where it draws, shown, is its own box. let Some(drawn) = region.or_else(|| node.visual_bounds()) else { continue }; - let spelled = if let NodeKind::Text(t) = &node.kind { spelling(&t.plain_text()) } else { String::new() }; - for (rects, words, held) in &mut objects { + let (spelled, holder) = match &node.kind { + NodeKind::Text(t) => { + let text = t.plain_text(); + let [a, b, ..] = t.xf.as_coeffs(); + (spelling(&text), Some((drawn.center(), (a, b), word_pieces(&text).map(spelling).filter(|w| !w.is_empty()).collect()))) + } + _ => (String::new(), None), + }; + for ((rects, words, held), by) in objects.iter_mut().zip(&mut holders) { if rects.iter().any(|r| holds(drawn, r)) { *held = true; *seen |= region.is_some(); words.retain(|w| !spelled.contains(w.as_str())); + by.extend(holder.clone()); } } } + for ((_, words, _), by) in objects.iter_mut().zip(&holders) { + words.retain(|w| !joined_by_two(w, by)); + } Some(objects.iter().filter(|(_, words, held)| !held || !words.is_empty()).count()) } +/// A made text object that holds a piece of the page's type: the centre of where it draws, the +/// way its lines run (the first column of its transform) and its words ([`spelling`]). +type Holder = (Point, (f64, f64), Vec); + +/// Is `word` (a [`spelling`]) the last word of one of `by` joined to the first word of another of +/// them that draws after it, along the first one's lines? Each part is a whole word of its text +/// object, so a piece is never made up of bits of words. +fn joined_by_two(word: &str, by: &[Holder]) -> bool { + by.iter().any(|(at, (a, b), first)| { + let Some(head) = first.last().filter(|h| word.len() > h.len() && word.starts_with(h.as_str())) else { return false }; + let tail = &word[head.len()..]; + by.iter().any(|(next, _, second)| (next.x - at.x) * a + (next.y - at.y) * b > 0.0 && second.first().is_some_and(|w| w == tail)) + }) +} + /// What goes into each of `infos`' slots when the file's text document can't make the type of every /// slot that shows: type made from the text document (`made`) where it can, else the page's type that /// the text document puts where the page has it, else the page's type in a copy that a layer's or diff --git a/crates/eps/src/import/tests_native.rs b/crates/eps/src/import/tests_native.rs index 2d8d270cc7..28faccac69 100644 --- a/crates/eps/src/import/tests_native.rs +++ b/crates/eps/src/import/tests_native.rs @@ -8663,3 +8663,35 @@ fn trusted_editing_data_keeps_an_artboard_taller_than_its_pdf_page() { let (_, w, read) = crate::layered_ai(&private(&art), Document::new(12000.0, 14400.0), vec![], false, true, 1.0); assert!(!read, "the uncapped dimension must still match: {w:?}"); } + +/// The page's "2014" drawn as one piece 20 points across the art, and two text objects "20" and +/// "14" anchored at `twenty` and `fourteen`, set in the bundled Source Sans 3 at 14 points (a digit +/// 6.958 points wide) so that where they draw doesn't hang on the fonts installed. +fn word_of_two_text_objects(fourteen: f64, twenty: f64) -> crate::import::Imported { + let stories = [("20\r", 0, (twenty, 8180.0), (0.0, 0.0), 0.0), ("14\r", 0, (fourteen, 8180.0), (0.0, 0.0), 0.0)]; + let doc = text_document(&stories).replacen("/0 (Helvetica)", "/0 (SourceSans3-Regular)", 1); + let art = native_with_text(&layer("Art", true, &(text_object(0) + &text_object(1))), &doc); + let page = "0 1 0 0 setcmykcolor /SourceSans3-Regular findfont 14 scalefont setfont 20 61.5 moveto (2014) show"; + import(&eps(page, &art)).unwrap() +} + +/// The page can draw two text objects as one word: "20" and "14" set one after the other come out +/// of the page as one piece, "2014", that neither spells. The word is the last word of the one +/// joined to the first word of the one after it, so the page's type is theirs and nothing is noted +/// as left out. +#[test] +fn a_word_the_page_draws_from_two_text_objects_in_a_row_is_their_type() { + let r = word_of_two_text_objects(8161.5 + 13.916, 8161.5); + assert_eq!(names(&r.document), ["Art"], "{:?}", r.warnings); + let texts: Vec = text_of(&r.document.layers[0]).iter().map(|t| t.plain_text()).collect(); + assert_eq!(texts, ["20", "14"], "{:?}", r.warnings); + assert!(!r.warnings.iter().any(|w| crate::is_loss(w)), "{:?}", r.warnings); +} + +/// The two text objects the other way round ("14" before "20") don't make the page's "2014": its +/// word keeps the loss note. +#[test] +fn two_text_objects_the_other_way_round_arent_the_word_the_page_draws() { + let r = word_of_two_text_objects(8161.5, 8161.5 + 13.916); + assert!(r.warnings.iter().any(|w| w.contains("some of the page's type has no text object in the layers")), "{:?}", r.warnings); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index a22db526d1..b4c9a92410 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -425,6 +425,7 @@ Stop opacity on translated artboards remains outside this regression coverage. | Date | Change | Summary | |---|---|---| +| 2026-11-30 | minor | `.ai` and EPS import: a word the page draws from two text objects in a row is their type. Where the text document makes the type of every text object that shows, a word of the page's type is the type of the made type holding its piece when that type spells it. The page can draw two text objects as one word: a word and a letter set apart from it (a swash "h" after "Spirit") come out of the page as one piece, "Spirith", that neither spells. It was counted as type with no text object, with the note "some of the page's type has no text object in the layers, so it is left out" (a loss, so `convert` wouldn't write over the file), though both text objects come in and draw it. Now a word left that is the last word of one text object holding the piece joined to the first word of another holding it that draws after it, along the first one's lines, is theirs (`joined_by_two` in `see_page_type`). Each part is a whole word of its text object, and the two the other way round don't make the word. Tests: `a_word_the_page_draws_from_two_text_objects_in_a_row_is_their_type`, `two_text_objects_the_other_way_round_arent_the_word_the_page_draws`. | | 2026-11-27 | minor | `.ai` save: type in a spot ink, a global process colour or Registration keeps its swatch link and its tint. Its fill and stroke in the text document name (key 5 of the paint) an art style of one paint, `0 1 Xd`, whose paint is the colour as a path's fill writes it (`x`, `Xx`, `Xk`, `Xs`), the form `.ai` import reads since the change below; key 0 still holds the process values at the tint. Each style is read back before it is written and kept only when the reader gives the same swatch and tint, so such type no longer counts among the attributes of type left out; a link to a process swatch that isn't global still does. Test `ai_editing::tests::type_in_spot_and_global_colors_reads_back_linked_at_its_tint` | | 2026-11-27 | minor | `.ai` and EPS import: type set in a spot ink or a global process colour keeps its ink. In the text document a character's fill or stroke is a colour (key 0: grey, RGB or CMYK) and the name of an art style (key 5). In users' files (used locally, never committed) that style is one paint (`/SimpleStyle`), always its fill's, for a stroke too; for a spot ink or a global process colour it is `c m y k (name) tint x`, `Xx` or `Xk`, and key 0 keeps only the ink's process values at that tint. Such type came in as that process colour, so it separated onto the process plates, and white type in a white ink onto none. It now takes the style's paint: the colour at its tint, linked to the document's swatch of that name, which the style's colour makes when the art doesn't (after the art's colours, before the header's custom colours). A style whose paint is a process colour or a gradient, one that also sets a stroke's colour or pattern (before or after the fill's) or another fill paint after it, one whose `Xd` doesn't turn on its fill alone, and a paint that names no style of the file, keep the colour of key 0 as before; type filled with a gradient still comes in black. Tests `type_set_in_a_spot_ink_takes_it_from_the_art_style_its_paint_names` in `crates/eps/src/import/tests_native.rs`, `a_run_painted_by_a_swatch_colours_art_style_takes_the_swatch` in `crates/eps/src/import/ate.rs` and `only_a_style_of_one_swatch_colour_holds_it_for_type` in `crates/eps/src/import/ai/style/tests.rs`. Scores and estimates unchanged. | | 2026-11-26 | minor | `.ai` and EPS import: where the text document makes the type of every text object that shows, point type made from it is matched with the page's type where it draws. Made type has no layout when it is matched, and its box was the estimate of type without one (0.55 em a character, running right from its anchor): beside right-aligned type, over half of centered type, across vertical type, and too short for a wide font. The page's type there was counted as type with no text object, with the note "some of the page's type has no text object in the layers, so it is left out" (a loss, so `convert` wouldn't write over the file), and the made type went on to be weighed against the page as type the page may not draw, and could be taken out. The box of made point type that shows now comes from its layout in the fonts the import has; the text object keeps no layout, so the document measures it when it opens, as before. Files where some text object's type isn't made keep the estimate: there the page's pieces where made type draws can belong to text objects stacked on it. The page comparison takes the same box for the layers' type areas (`type_areas` in `compare.rs`): made point type that differs from the page (laid out again, or in another font) counts as type where it draws, whatever its alignment. Counted as art beside the estimate, it could send the file to its PDF part or page, or be noted as art that differs. A file whose layers failed the comparison that way and opened without it now passes it and shows its notes. Tests `right_aligned_and_centered_point_type_takes_the_pages_type_where_it_draws`, `centered_point_type_at_a_heading_s_size_takes_the_pages_type_where_it_draws` and `right_aligned_point_type_that_differs_from_the_page_differs_as_type` in `crates/eps/src/import/tests_native.rs`, and `made_point_type_s_box_is_where_its_alignment_and_orientation_draw_it` in `crates/eps/src/import/native/slots.rs`. Scores and estimates unchanged. | From 07b4332dfc601de36b57d683ff7e5617660d80e4 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:42:16 +0000 Subject: [PATCH 196/264] fix: Step and Repeat fill picks the artboard from the whole selection; rustfmt --- crates/engine/src/cmd/stepandrepeat.rs | 2 +- crates/engine/src/cmd/stepandrepeat/tests.rs | 21 ++++++++++++++++++++ crates/ui-egui/src/dialogs/object_dialogs.rs | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/stepandrepeat.rs b/crates/engine/src/cmd/stepandrepeat.rs index 620f64a9a7..9ba4666598 100644 --- a/crates/engine/src/cmd/stepandrepeat.rs +++ b/crates/engine/src/cmd/stepandrepeat.rs @@ -150,7 +150,7 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result { } let anchor = if fill { let sheet = sheet.or_else(|| { - let c = b.center(); + let c = d.bounds_of(&roots, false).unwrap_or(b).center(); d.artboards.iter().find(|a| a.rect.contains(c)).or_else(|| d.artboards.first()).map(|a| a.rect) }); let sheet = sheet.ok_or_else(|| EngineError::Other("no sheet to fill".into()))?; diff --git a/crates/engine/src/cmd/stepandrepeat/tests.rs b/crates/engine/src/cmd/stepandrepeat/tests.rs index c25953d598..991800d964 100644 --- a/crates/engine/src/cmd/stepandrepeat/tests.rs +++ b/crates/engine/src/cmd/stepandrepeat/tests.rs @@ -155,3 +155,24 @@ fn fractional_gaps_are_exact_except_for_pixel_aligned_objects_which_stay_on_the_ let pitch = gap(true).1; assert!((pitch - pitch.round()).abs() < 1e-9); } + +#[test] +fn fill_picks_the_artboard_of_the_selection_not_of_the_cut_contour() { + let first_x = |sheet: Option| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + s.execute("artboard.new", &json!({"x": 100, "y": 0, "width": 100, "height": 100})).unwrap(); + let art = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 60, "height": 20})).unwrap()["id"].as_u64().unwrap(); + let cut = s.execute("shape.rectangle", &json!({"x": 105, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [art, cut]})).unwrap(); + let mut p = json!({"fill": true, "cutId": cut}); + if let Some(sh) = sheet { + p["sheet"] = sh; + } + let r = s.execute(CMD, &p).unwrap(); + bounds(&s, r["ids"][0].as_u64().unwrap()).0 + }; + let default = first_x(None); + let explicit = first_x(Some(json!({"x": 100, "y": 0, "width": 100, "height": 100}))); + assert!((explicit - default - 100.0).abs() < 1e-9); +} diff --git a/crates/ui-egui/src/dialogs/object_dialogs.rs b/crates/ui-egui/src/dialogs/object_dialogs.rs index 3f3b69da54..ee0867d0dd 100644 --- a/crates/ui-egui/src/dialogs/object_dialogs.rs +++ b/crates/ui-egui/src/dialogs/object_dialogs.rs @@ -4,8 +4,8 @@ use super::path_ops::PathOp; use super::simplify_slider::StripKind; use super::{ blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form, - path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, step_repeat, transform, - transform_each, width_point, + path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, step_repeat, transform, transform_each, + width_point, }; use crate::VectorcraftApp; From 41f2554eae34e71efca8b0fc7642d60b53306aad Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 01:51:18 -0800 Subject: [PATCH 197/264] Info: a click on a readout copies it again inside a measured flyout At the craft-libs pin this branch moves to, a panel shown in a dock flyout runs its body twice in the release frame: first in the container's invisible sizing pass, then in the real run. copy_shown read the release in the sizing pass, where the readout has no area, and cleared the press it had remembered, so the real run saw a release without a press and copied nothing. Info's W, H and other readouts stopped copying (panel_readout_copy: three tests failed with no copy). copy_shown now returns before reading input or the remembered press in a sizing pass. --- crates/ui-egui/src/panels/doc_info.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index e6f7cb6e86..5cb45f666a 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -59,6 +59,12 @@ pub(crate) fn copy_value(ui: &mut Ui, label: &str, value: &str, mono: bool) -> b /// The same guarded full-value copy for an already shown readout. An elided path remains /// static text: selection indices must describe the text actually shown by the framework. pub(crate) fn copy_shown(ui: &mut Ui, shown: &egui::Response, value: &str) -> bool { + // A container's measuring run shows the readout in an invisible sizing pass before the frame's real run, with the + // same id and the same input. It neither copies nor reads or clears the remembered press: clearing it there would + // leave the real run's release without its press. + if ui.is_sizing_pass() { + return false; + } // The click's own position and keys: a move or a key change after the release in the same // frame leaves the pointer and the held keys elsewhere. A frame with more than one release // copies nothing, since the click flags below do not say which release they describe. From bbe091e791f9e500b28ab43e3d1afa46538829a2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 02:13:29 -0800 Subject: [PATCH 198/264] Fields: the wheel steps a focused number field only while the pointer is over it With a number field focused, a wheel notch anywhere in the window stepped that field. In Pattern Options at 220 by 320 points, with Width focused at 10 pt, a notch over Size Tile to Art changed Width to 9 pt. `root_env` now turns on the framework's pointer-scoped field wheel (`RootEnv::pointer_scoped_field_wheel`, storytold/craft-libs#3805). The desktop and web hosts both take their root from it. A notch over the focused field still steps it. Elsewhere the wheel scrolls what is under the pointer, and an unfocused number field under the pointer is not stepped. --- crates/ui-egui/src/app.rs | 3 ++ crates/ui-egui/src/panels/pattern_options.rs | 40 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 84ab44d769..730f2eec08 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -823,6 +823,9 @@ pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32, print root.escape_leaves_fields = true; // A held key repeats its command (Cmd+= keeps zooming in). root.shortcuts_repeat = true; + // The wheel steps a focused number field only while the pointer is over it; elsewhere it scrolls what is under the + // pointer. + root.pointer_scoped_field_wheel = true; root } diff --git a/crates/ui-egui/src/panels/pattern_options.rs b/crates/ui-egui/src/panels/pattern_options.rs index 93e93681f2..e811df4c17 100644 --- a/crates/ui-egui/src/panels/pattern_options.rs +++ b/crates/ui-egui/src/panels/pattern_options.rs @@ -309,4 +309,44 @@ mod tests { assert_eq!(panel.value("Name").as_deref(), Some("Dots")); assert!(panel.app().session.active().unwrap().doc.pattern("Dots").is_some()); } + + /// The tile's width and height of the pattern "Dots". + fn tile_size(panel: &Panel) -> (f64, f64) { + let app = panel.app(); + let tile = &app.session.active().unwrap().doc.pattern("Dots").unwrap().tile; + (tile.width(), tile.height()) + } + + /// With the Width field focused, a wheel notch steps it only while the pointer is over it: over another control, + /// or over the unfocused Height field, the wheel scrolls the panel and the tile keeps its size. + #[test] + fn the_wheel_steps_the_focused_number_field_only_under_the_pointer() { + use craft::ui::contract::Role; + let mut panel = editing_panel(); + panel.room(egui::vec2(220.0, 320.0)); + panel.frame(); + assert_eq!(tile_size(&panel), (10.0, 10.0)); + panel.click_role("Width", Role::SPIN_BUTTON); + assert!(panel.focused("Width"), "the click focuses Width"); + + // One notch at `at`, then the frame after the wheel gesture's gap, which ends the gesture. + let notch = |panel: &mut Panel, at: egui::Pos2| { + panel.scroll_at(at, -30.0); + panel.advance(1.0); + panel.frame(); + }; + + let check = panel.rect("Size Tile to Art").center(); + notch(&mut panel, check); + assert_eq!(tile_size(&panel), (10.0, 10.0), "a notch over Size Tile to Art leaves the focused Width alone"); + assert!(panel.focused("Width"), "Width keeps the focus"); + + let height = panel.rect_role("Height", Role::SPIN_BUTTON).center(); + notch(&mut panel, height); + assert_eq!(tile_size(&panel), (10.0, 10.0), "a notch over the unfocused Height steps neither field"); + + let width = panel.rect_role("Width", Role::SPIN_BUTTON).center(); + notch(&mut panel, width); + assert_eq!(tile_size(&panel), (9.0, 10.0), "a notch over the focused Width steps it"); + } } From 1937db57bf133db58a541f916163aad09b521c52 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 11:32:52 +0100 Subject: [PATCH 199/264] Restore native save dialogs, selected Hand panning and font list space --- apps/vectorcraft/src/main.rs | 6 ++++-- crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/caches.rs | 1 + crates/ui-egui/src/canvas/tests_edge_scroll.rs | 2 ++ crates/ui-egui/src/canvas/tool_adapter.rs | 8 ++++++++ crates/ui-egui/src/font_menu.rs | 2 +- crates/ui-egui/src/panels/character.rs | 2 +- 7 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 601cda01bb..12ac19b08b 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -798,7 +798,7 @@ fn main() -> std::process::ExitCode { }; let (files, file_panels) = file_service(wake, folders); let files = Arc::new(files); - craft::host::Host::builder(AppInfo { + let host = craft::host::Host::builder(AppInfo { id: vectorcraft_ui_egui::os_window::SETTINGS_APP_ID, name: vectorcraft_ui_egui::os_window::name(), version: vectorcraft_ui_egui::os_window::version(), @@ -806,7 +806,8 @@ fn main() -> std::process::ExitCode { .i18n(vectorcraft_ui_egui::i18n::shared()) .settings(Arc::new(settings.clone())) .files(files.clone()) - .install(ctx); + .build(); + host.clone().install(ctx); let mut session = Session::new(); // The profiles loaded before come back before the preferences name any of them. prefs_dir::attach_profile_store(&mut session); @@ -831,6 +832,7 @@ fn main() -> std::process::ExitCode { prefs_dir::attach_proof_setups(&mut session); prefs_dir::attach_script_data(&mut session); let mut app = VectorcraftApp::new(session, services(winit_window.clone())); + app.host = Arc::new(host); app.adopt_context(&cc.egui_ctx); // A nightly is updated by the Launcher: it never checks for a stable release, which // would install this program's own updater over the nightly build. diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 84ab44d769..8ddfe99310 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -139,6 +139,7 @@ impl VectorcraftApp { spelling: Default::default(), text_nodes: Default::default(), momentary: None, + hand: None, selection_box: None, selection_bounds: None, selection_marks: None, diff --git a/crates/ui-egui/src/caches.rs b/crates/ui-egui/src/caches.rs index 7f0ade064e..cdf59a99f8 100644 --- a/crates/ui-egui/src/caches.rs +++ b/crates/ui-egui/src/caches.rs @@ -81,6 +81,7 @@ pub struct CanvasCache { /// The Hand, Zoom and Rotate View tools the Space key and its chords lend the canvas, between /// passes; the tool adapter takes it out for its call and puts it back. pub momentary: Option, + pub hand: Option, /// [`VectorcraftApp::selection_box`] for (document uid, revision, Use Preview Bounds and /// Measure Type by Glyph Bounds). pub selection_box: Option<((u64, u64, vectorcraft_effects::preview::Measure), Option)>, diff --git a/crates/ui-egui/src/canvas/tests_edge_scroll.rs b/crates/ui-egui/src/canvas/tests_edge_scroll.rs index 79c09b3291..167f938861 100644 --- a/crates/ui-egui/src/canvas/tests_edge_scroll.rs +++ b/crates/ui-egui/src/canvas/tests_edge_scroll.rs @@ -127,10 +127,12 @@ fn a_hand_drag_held_near_the_edge_does_not_scroll_on() { let (mut app, ctx, _) = zoomed_in("hand"); let rect = app.canvas_view().unwrap().rect; let start = rect.center(); + let before = center(&app); frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start), button(start, true)]); let edge = pos2(rect.right() - 4.0, start.y); frame(&mut app, &ctx, vec![egui::Event::PointerMoved(edge)]); let c0 = center(&app); + assert!(c0.x < before.x, "dragging the selected Hand right must pan the view"); for _ in 0..3 { frame(&mut app, &ctx, vec![]); } diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index cc62cc3fe6..596c4f4116 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -650,7 +650,15 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too let mut picked = ToolHostResponse::default(); let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) { picked + } else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 { + let options = crate::app::view::navigation(&app.session.prefs); + let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options)); + hand.options = options; + let response = host_run(app, ui, pass, &mut hand); + app.canvas.hand = Some(hand); + response } else { + app.canvas.hand = None; let mut tool = SessionTool::new(app, view_info, ui); let response = host_run_session(&mut tool, ui, pass); drop(tool); diff --git a/crates/ui-egui/src/font_menu.rs b/crates/ui-egui/src/font_menu.rs index bc7d206428..21c19bdd03 100644 --- a/crates/ui-egui/src/font_menu.rs +++ b/crates/ui-egui/src/font_menu.rs @@ -114,7 +114,7 @@ pub(crate) fn family_picker<'a>( .filters(filters) .sets(sets) .scripts(&FontScript::ALL) - .filter_layout(FilterLayout::Chips) + .filter_layout(FilterLayout::Toolbar) } /// What one pass of a picker reads of the app, for a host that has no `app` while it draws (a dialog). diff --git a/crates/ui-egui/src/panels/character.rs b/crates/ui-egui/src/panels/character.rs index bfcb770b7e..9415a7e50f 100644 --- a/crates/ui-egui/src/panels/character.rs +++ b/crates/ui-egui/src/panels/character.rs @@ -1231,7 +1231,7 @@ pub(crate) fn controls(app: &mut VectorcraftApp, ui: &mut Ui, rows: CharacterRow .filters(Bind::bound(&mut app.ui.font_filters)) .sets(&sets) .scripts(&FontScript::ALL) - .filter_layout(FilterLayout::Chips); + .filter_layout(FilterLayout::Toolbar); if let Some(text) = &sample { source = source.preview_text(text); } From 8cc75fd85689ba0d76e9af7c4a7d4b4f16c7bff8 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 11:34:34 +0100 Subject: [PATCH 200/264] Release: VectorCraft v0.25.1 --- Cargo.lock | 120 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fce3ecad1..d08f67fa86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8523,7 +8523,7 @@ dependencies = [ [[package]] name = "vectorcraft" -version = "0.25.0" +version = "0.25.1" dependencies = [ "arboard", "block2 0.6.2", @@ -8567,7 +8567,7 @@ dependencies = [ [[package]] name = "vectorcraft-affinity" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-affinity", "craft-image-codecs", @@ -8578,26 +8578,26 @@ dependencies = [ [[package]] name = "vectorcraft-apischema" -version = "0.25.0" +version = "0.25.1" dependencies = [ "serde_json", ] [[package]] name = "vectorcraft-brush" -version = "0.25.0" +version = "0.25.1" dependencies = [ "kurbo 0.13.1", "serde", "serde_json", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", ] [[package]] name = "vectorcraft-cad" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-dxf", "craft-image-codecs", @@ -8609,14 +8609,14 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", - "vectorcraft-pathops 0.25.0", + "vectorcraft-geom 0.25.1", + "vectorcraft-pathops 0.25.1", "vectorcraft-text", ] [[package]] name = "vectorcraft-cli" -version = "0.25.0" +version = "0.25.1" dependencies = [ "log", "objc2-core-foundation", @@ -8627,7 +8627,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-mcp", "vectorcraft-render", "vectorcraft-svg", @@ -8639,7 +8639,7 @@ dependencies = [ [[package]] name = "vectorcraft-color" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-cms", "craft-color-ui", @@ -8655,7 +8655,7 @@ dependencies = [ [[package]] name = "vectorcraft-doc" -version = "0.25.0" +version = "0.25.1" dependencies = [ "chrono", "craft-image-codecs", @@ -8671,13 +8671,13 @@ dependencies = [ "thiserror 2.0.21", "tiff", "vectorcraft-color", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "zune-jpeg", ] [[package]] name = "vectorcraft-effects" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "craft-svg", @@ -8687,8 +8687,8 @@ dependencies = [ "svgtypes 0.16.1", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.25.0", - "vectorcraft-pathops 0.25.0", + "vectorcraft-geom 0.25.1", + "vectorcraft-pathops 0.25.1", "vectorcraft-plugins", "vectorcraft-text", "vectorcraft-three-d", @@ -8698,7 +8698,7 @@ dependencies = [ [[package]] name = "vectorcraft-engine" -version = "0.25.0" +version = "0.25.1" dependencies = [ "apple-native-keyring-store", "cfb", @@ -8747,10 +8747,10 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-js", "vectorcraft-metafile", - "vectorcraft-pathops 0.25.0", + "vectorcraft-pathops 0.25.1", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -8770,7 +8770,7 @@ dependencies = [ [[package]] name = "vectorcraft-eps" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-eps", "craft-image-codecs", @@ -8791,9 +8791,9 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-effects", "vectorcraft-eps", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-metafile", - "vectorcraft-pathops 0.25.0", + "vectorcraft-pathops 0.25.1", "vectorcraft-pdf", "vectorcraft-render", "vectorcraft-testkit", @@ -8802,7 +8802,7 @@ dependencies = [ [[package]] name = "vectorcraft-format" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-gzip", "craft-vectorcraft-format", @@ -8814,7 +8814,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-brush", "vectorcraft-doc", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-testkit", ] @@ -8830,7 +8830,7 @@ dependencies = [ [[package]] name = "vectorcraft-geom" -version = "0.25.0" +version = "0.25.1" dependencies = [ "kurbo 0.13.1", "proptest", @@ -8841,7 +8841,7 @@ dependencies = [ [[package]] name = "vectorcraft-js" -version = "0.25.0" +version = "0.25.1" dependencies = [ "chrono", "craft-xml", @@ -8852,7 +8852,7 @@ dependencies = [ [[package]] name = "vectorcraft-mcp" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft", "craft-image-codecs", @@ -8864,7 +8864,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-render", "vectorcraft-svg", "vectorcraft-testkit", @@ -8873,7 +8873,7 @@ dependencies = [ [[package]] name = "vectorcraft-metafile" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "craft-metafile", @@ -8883,7 +8883,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-text", ] @@ -8900,19 +8900,19 @@ dependencies = [ [[package]] name = "vectorcraft-pathops" -version = "0.25.0" +version = "0.25.1" dependencies = [ "kurbo 0.13.1", "linesweeper", "proptest", "thiserror 2.0.21", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-testkit", ] [[package]] name = "vectorcraft-pdf" -version = "0.25.0" +version = "0.25.1" dependencies = [ "aes 0.8.4", "chrono", @@ -8941,7 +8941,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-pdf", "vectorcraft-testkit", "vectorcraft-text", @@ -8949,7 +8949,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugin-worker" -version = "0.25.0" +version = "0.25.1" dependencies = [ "js-sys", "vectorcraft-plugins", @@ -8959,7 +8959,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugins" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "craft-vectorcraft-format", @@ -8971,7 +8971,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-js", "vectorcraft-plugins", "wasmi", @@ -8982,7 +8982,7 @@ dependencies = [ [[package]] name = "vectorcraft-render" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-gif", "craft-image-codecs", @@ -9000,7 +9000,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-plugins", "vectorcraft-testkit", "vectorcraft-text", @@ -9013,7 +9013,7 @@ dependencies = [ [[package]] name = "vectorcraft-scriptcheck" -version = "0.25.0" +version = "0.25.1" dependencies = [ "proptest", "unicode-properties", @@ -9021,7 +9021,7 @@ dependencies = [ [[package]] name = "vectorcraft-svg" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-docpath", "craft-image-codecs", @@ -9045,15 +9045,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", - "vectorcraft-pathops 0.25.0", + "vectorcraft-geom 0.25.1", + "vectorcraft-pathops 0.25.1", "vectorcraft-testkit", "vectorcraft-text", ] [[package]] name = "vectorcraft-testkit" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "fax", @@ -9064,14 +9064,14 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-render", "vectorcraft-svg", ] [[package]] name = "vectorcraft-text" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft", "craft-fonts-build", @@ -9089,23 +9089,23 @@ dependencies = [ "unicode-script", "unicode-segmentation", "vectorcraft-doc", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vello_cpu", "write-fonts", ] [[package]] name = "vectorcraft-three-d" -version = "0.25.0" +version = "0.25.1" dependencies = [ "proptest", - "vectorcraft-geom 0.25.0", - "vectorcraft-pathops 0.25.0", + "vectorcraft-geom 0.25.1", + "vectorcraft-pathops 0.25.1", ] [[package]] name = "vectorcraft-thumbnail-handler" -version = "0.25.0" +version = "0.25.1" dependencies = [ "png 0.18.1", "windows", @@ -9114,7 +9114,7 @@ dependencies = [ [[package]] name = "vectorcraft-tools" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "kurbo 0.13.1", @@ -9124,15 +9124,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.25.0", - "vectorcraft-pathops 0.25.0", + "vectorcraft-geom 0.25.1", + "vectorcraft-pathops 0.25.1", "vectorcraft-text", "vectorcraft-tools", ] [[package]] name = "vectorcraft-trace" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft-image-codecs", "image", @@ -9140,12 +9140,12 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.21", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", ] [[package]] name = "vectorcraft-ui-egui" -version = "0.25.0" +version = "0.25.1" dependencies = [ "bytemuck", "chrono", @@ -9169,7 +9169,7 @@ dependencies = [ "vectorcraft-engine", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.25.0", + "vectorcraft-geom 0.25.1", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -9184,7 +9184,7 @@ dependencies = [ [[package]] name = "vectorcraft-web" -version = "0.25.0" +version = "0.25.1" dependencies = [ "craft", "craft-web-api", @@ -10413,7 +10413,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee" [[package]] name = "xtask" -version = "0.25.0" +version = "0.25.1" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index cc76d129c5..ff84f22755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"] default-members = ["crates/*", "apps/vectorcraft", "apps/vectorcraft-cli", "xtask"] [workspace.package] -version = "0.25.0" +version = "0.25.1" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" From dcdbd3cc1b3f7747e63d1ae96d6338905074f4ec Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 02:38:02 -0800 Subject: [PATCH 201/264] CI: declare the files each crate reads in other crates, for test selection Test selection in the shared gate (`select-tests`) runs the tests of the crates a change reaches. A crate that compiles or reads another crate's files lists them under `[package.metadata.craft]` in its Cargo.toml: - vectorcraft-plugins sets `reads-every-member = true`, because `tests/grant_sites.rs` reads the sources of every crate. - vectorcraft-cli, vectorcraft-affinity, vectorcraft-engine, vectorcraft-mcp, vectorcraft-ui-egui and xtask list the files they compile through `#[path]` or read with `include_str!`/`include_bytes!` or from `CARGO_MANIFEST_DIR`. Cargo ignores this table. Only the gate's selection step reads it, and that step fails when a read is missing from it. --- apps/vectorcraft-cli/Cargo.toml | 11 +++++++++++ crates/affinity/Cargo.toml | 4 ++++ crates/engine/Cargo.toml | 11 +++++++++++ crates/mcp/Cargo.toml | 4 ++++ crates/plugins/Cargo.toml | 4 ++++ crates/ui-egui/Cargo.toml | 4 ++++ xtask/Cargo.toml | 4 ++++ 7 files changed, 42 insertions(+) diff --git a/apps/vectorcraft-cli/Cargo.toml b/apps/vectorcraft-cli/Cargo.toml index 376f431903..25cffe599e 100644 --- a/apps/vectorcraft-cli/Cargo.toml +++ b/apps/vectorcraft-cli/Cargo.toml @@ -48,3 +48,14 @@ objc2-core-text = { version = "0.3", default-features = false, features = ["std" tempfile = "3" vectorcraft-testkit = { workspace = true } serde_json = { workspace = true } + +# The files of other crates that this crate compiles or its tests read, for CI's test selection. +[package.metadata.craft] +reads = [ + "apps/vectorcraft/src/mac_fonts.rs", + "apps/vectorcraft/src/prefs_dir.rs", + "apps/vectorcraft/src/profile.rs", + "apps/vectorcraft/src/system_fonts.rs", + "apps/vectorcraft/src/windows_cores.rs", + "crates/plugins/tests/fixtures/desaturate.wasm", +] diff --git a/crates/affinity/Cargo.toml b/crates/affinity/Cargo.toml index 92977884cf..80876c409a 100644 --- a/crates/affinity/Cargo.toml +++ b/crates/affinity/Cargo.toml @@ -24,3 +24,7 @@ craft-image-codecs = { workspace = true } # tests/it's `import_limits`, `outline_limits` and `text` modules need `synth`, also when this crate # is tested without vectorcraft-engine (`cargo xtask ci shard`). vectorcraft-affinity = { path = ".", features = ["synth"] } + +# The files of other crates that this crate's tests compile or read, for CI's test selection. +[package.metadata.craft] +reads = ["xtask/affinity-corpus.sha256", "xtask/src/sha256.rs"] diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 027ae10251..1e74ecb5d2 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -143,3 +143,14 @@ ruzstd = { workspace = true } vectorcraft-js = { workspace = true } # A bundled font's own glyph boxes, for the glyph bounds tests. skrifa = { workspace = true } + +# The files of other crates that this crate compiles or its tests read, for CI's test selection. +[package.metadata.craft] +reads = [ + "crates/affinity/tests/support/corpus.rs", + "crates/affinity/tests/support/text_fixture.rs", + "crates/apischema/src/conformance.rs", + "crates/plugins/tests/fixtures/desaturate.wasm", + "xtask/affinity-corpus.sha256", + "xtask/src/sha256.rs", +] diff --git a/crates/mcp/Cargo.toml b/crates/mcp/Cargo.toml index 8aa221b4a6..b5544b958c 100644 --- a/crates/mcp/Cargo.toml +++ b/crates/mcp/Cargo.toml @@ -33,3 +33,7 @@ craft-image-codecs = { workspace = true } vectorcraft-testkit = { workspace = true } proptest = { workspace = true } socket2 = { workspace = true } + +# The files of other crates that this crate's tests compile, for CI's test selection. +[package.metadata.craft] +reads = ["crates/apischema/src/conformance.rs"] diff --git a/crates/plugins/Cargo.toml b/crates/plugins/Cargo.toml index 621f5e79bc..aecb0bd533 100644 --- a/crates/plugins/Cargo.toml +++ b/crates/plugins/Cargo.toml @@ -44,3 +44,7 @@ vectorcraft-plugins = { path = ".", features = ["test-steady"] } [features] # `vectorcraft_plugins::steady` for other crates' tests (dev-dependencies only). test-steady = [] + +# For CI's test selection: `tests/grant_sites.rs` reads the sources of every crate. +[package.metadata.craft] +reads-every-member = true diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 95487e91c0..d0bb345b44 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -109,3 +109,7 @@ wat = { workspace = true } [build-dependencies] serde_json = { workspace = true } toml = "1" + +# The files of other crates that this crate's tests read, for CI's test selection. +[package.metadata.craft] +reads = ["crates/engine/src/cmd/addons/cutting/banner.rs", "crates/plugins/tests/fixtures/desaturate.wasm"] diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 6d935ae8fd..7a5c83e8b5 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -10,3 +10,7 @@ workspace = true [dependencies] serde_json = { workspace = true } + +# The files of other crates that this crate compiles, for CI's test selection. +[package.metadata.craft] +reads = ["crates/text/build/web_fonts.rs"] From 41ab3908ef1820dbfb27755c673ae482a61abb96 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 01:51:28 -0800 Subject: [PATCH 202/264] Dependencies: craft-libs moves to 2680a3b3f and egui to 07c20531 craft-libs main at 2680a3b3f adds #4364 (its egui pin moves to 07c20531, which VectorCraft's egui lines now match), #4425, #4409, #4414, #4406, #4349, #4393, #4392, #4398, #4415, #4411, #4402, #4400, #4417, #4399, #4407, #4375, #4428 and #4451. winit stays at 0dfcec0e, the rev craft-libs pins. craft-nightly and craft-web-api move with the other craft-libs crates, and xtask pdf-deps checks the new rev. Cargo.lock: epaint_default_fonts now depends on brotli 9.1.3 and brotli-decompressor 6.3.2. --- Cargo.lock | 198 ++++++++++++++++---------------- Cargo.toml | 98 ++++++++-------- apps/vectorcraft-web/Cargo.toml | 2 +- xtask/src/pdf_deps.rs | 2 +- 4 files changed, 152 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2892308bf..a5796f08de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-automation", "craft-behavior", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "crc32fast", "flate2", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "rustix 1.1.6", ] @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1328,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-docpath", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "crc32fast", "flate2", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "egui", ] @@ -1381,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "md-5", "rayon", @@ -1390,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-cms", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "rayon", ] @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "blake3", "craft-ecproj-format", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "serde", ] @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-codepage", "encoding_rs", @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "serde", "serde_json", @@ -1535,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1555,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "cap-primitives", "craft-atomic", @@ -1606,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "gif", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "flate2", ] @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-dds", "craft-jpeg", @@ -1697,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "thiserror 2.0.21", ] @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1734,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-host", "craft-i18n", @@ -1749,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-i18n", @@ -1763,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -1781,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1793,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "encoding_rs", "image", @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "chrono", "craft-codepage", @@ -1814,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "uds_windows", "winsafe", @@ -1823,7 +1823,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-keymap", @@ -1839,7 +1839,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "flate2", "serde", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1862,7 +1862,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "async-channel", "async-io", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1904,7 +1904,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1939,7 +1939,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-eps", "flate2", @@ -1953,7 +1953,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "encoding_rs", "flate2", @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "dispatch2", "egui", @@ -1977,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1996,7 +1996,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-atomic", "craft-host", @@ -2013,7 +2013,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "fax", "hayro-ccitt", @@ -2024,7 +2024,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-keymap", @@ -2057,7 +2057,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-atomic", "craft-behavior", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "serde", "thiserror 2.0.21", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "serde", "thiserror 2.0.21", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-keymap", @@ -2146,12 +2146,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2165,7 +2165,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-i18n", @@ -2181,7 +2181,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "accesskit", "craft-behavior", @@ -2219,7 +2219,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2230,7 +2230,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -2248,7 +2248,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -2269,7 +2269,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -2290,7 +2290,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-behavior", "craft-host", @@ -2309,7 +2309,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "base64 0.22.1", "chrono", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "flate2", "serde", @@ -2352,7 +2352,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2362,7 +2362,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "js-sys", "serde_json", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "winsafe", ] @@ -2381,7 +2381,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "craft-appkit", "craft-atomic", @@ -2413,7 +2413,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2758,7 +2758,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "emath", @@ -2791,7 +2791,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -2826,7 +2826,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit", "ahash", @@ -2845,7 +2845,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -2864,7 +2864,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit_winit", "arboard", @@ -2889,7 +2889,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "egui", @@ -2903,7 +2903,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "egui", @@ -2916,7 +2916,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "dify", "eframe", @@ -2942,7 +2942,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", ] @@ -3023,7 +3023,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -3049,7 +3049,11 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", +] [[package]] name = "equivalent" @@ -3768,7 +3772,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3777,7 +3781,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3795,7 +3799,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3813,12 +3817,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "flate2", "hayro-ccitt", @@ -4801,7 +4805,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4958,7 +4962,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" +source = "git+https://github.com/storytold/craft-libs?rev=2680a3b3fe464c7afa3d260b33a828fa94e12f6d#2680a3b3fe464c7afa3d260b33a828fa94e12f6d" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 8c2995ce63..efe3e3601f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,51 +10,51 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -194,22 +194,22 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 0a3a273fcc..2dedefa32f 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index d69afcd0a8..3e24ddc83c 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b"; +const REV: &str = "2680a3b3fe464c7afa3d260b33a828fa94e12f6d"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 746b8f3dbadba2e81a55c8977c3f49bac792fa52 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:02:25 +0100 Subject: [PATCH 203/264] Count the selected Hand gesture when H is held --- crates/ui-egui/src/canvas/tool_adapter.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 596c4f4116..031e2875b6 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -655,6 +655,9 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options)); hand.options = options; let response = host_run(app, ui, pass, &mut hand); + if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down()) { + crate::shortcuts::note_tool_use(app); + } app.canvas.hand = Some(hand); response } else { From 99e8655ef62e82d76cdb8d9a47a61093392b57f1 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:09:59 +0100 Subject: [PATCH 204/264] Restore the main window on startup and enlarge tool rail icons --- apps/vectorcraft/src/main.rs | 36 +++++++++++++++++++++++++++++++++++- crates/ui-egui/src/theme.rs | 4 ++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 12ac19b08b..3971de013b 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -112,6 +112,36 @@ use prefs::{load_prefs, log_dir, open_store, prefs_enabled}; const DEFAULT_SIZE: [f32; 2] = [1440.0, 900.0]; const MIN_SIZE: [f32; 2] = [800.0, 500.0]; +/// Apply the saved main-window placement before the first frame. On a first launch the +/// framework maximizes the window when its default size would not fit the current screen. +fn restore_main_window(window: &winit::window::Window, store: &Store, wayland: bool) { + use craft::behavior::placement::{Defaults, place}; + use craft::behavior::{Monitor, MonitorKey}; + use winit::dpi::{LogicalSize, PhysicalPosition}; + + let handles: Vec<_> = window.available_monitors().collect(); + let monitors: Vec<_> = handles + .iter() + .map(|monitor| { + let size = monitor.size(); + let size = [size.width, size.height]; + let position = monitor.position(); + Monitor::new(MonitorKey::new(monitor.name().unwrap_or_default(), size), [position.x, position.y], size, monitor.scale_factor() as f32) + }) + .collect(); + let home = window.current_monitor().or_else(|| window.primary_monitor()).and_then(|monitor| handles.iter().position(|m| *m == monitor)); + let defaults = Defaults::new(DEFAULT_SIZE, MIN_SIZE).with_no_position(wayland); + let placement = place(store.get(craft::window::restore::MAIN).as_ref(), &monitors, home, &defaults); + if let Some([x, y]) = placement.position_px { + window.set_outer_position(PhysicalPosition::new(x, y)); + } + let [width, height] = placement.normal.size; + let _ = window.request_inner_size(LogicalSize::new(width, height)); + if placement.maximized { + window.set_maximized(true); + } +} + /// The window, Dock, taskbar and app-switcher icon (`assets/app-icon/`, see its README). macOS gets /// the version with Apple's transparent margin; elsewhere the full-bleed tile. The app ID matches /// `packaging/linux/ai.storyteller.vectorcraft.desktop` so Wayland docks find the launcher icon. @@ -781,9 +811,13 @@ fn main() -> std::process::ExitCode { Box::new(move |cc| { let ctx = &cc.egui_ctx; let winit_window = cc.winit_window().cloned(); + let placement = placement_store(); + if let Some(window) = &winit_window { + restore_main_window(window, &placement, wayland); + } let spec = InstallSpec::new(shell_info, Arc::new(SystemWindows)) .app_id(vectorcraft_ui_egui::os_window::app_id()) - .placement(Arc::new(Mutex::new(placement_store()))) + .placement(Arc::new(Mutex::new(placement))) .frame(decision); let spec = match start_pen(&winit_window) { Some(pen) => spec.pen(pen), diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 1aa688ceb9..374fe2b460 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -166,10 +166,14 @@ const SIZES: &[u8] = br#"{ "size.page.button_side": 16, "size.page.link": 24 }, + "comfortable": { + "size.icon.lg": 26 + }, "compact": { "size.control.md": 26, "size.button": 24, "size.icon.glyph_md": 16, + "size.icon.lg": 24, "size.rail.width": 38, "size.dock.column": 310, "size.bar.column": 14, From f553ddfa67646ffd711f89eb783b88c15aa3b841 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:12:48 -0800 Subject: [PATCH 205/264] xtask: test-lint fails on weak tests in the lines a change touches `cargo xtask test-lint` reads the Rust files changed since a base and fails on tests that a wrong result can pass: `.all()` with no length or emptiness check, only is_ok/is_some/non-empty checks, `assert_eq!(x, x)`, a process test that checks only the exit status, no assertion and no asserting helper, a silent early return on a value from the code under test, `#[ignore]` without a reason, an environment variable that no CI leg sets, `thread::sleep` in test code, and test code that reads Rust source outside the listed source audits. Only hits on changed lines, or in a test with a changed line for the rules about a whole test, fail it; older hits in the same files are counted. The base is --base or TEST_LINT_BASE, the first parent of the checked-out commit in CI (a shallow checkout fetches it), else the merge base with upstream/main or origin/main. `// test-lint: allow ` exempts a line. `--all` lists every hit by crate and rule and does not fail. `cargo xtask ci` runs it after cursors, so it runs in the checks shard. --- docs/development.md | 4 + xtask/src/main.rs | 9 +- xtask/src/test_lint.rs | 2574 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2586 insertions(+), 1 deletion(-) create mode 100644 xtask/src/test_lint.rs diff --git a/docs/development.md b/docs/development.md index 5a1b6efd95..26058129e7 100644 --- a/docs/development.md +++ b/docs/development.md @@ -349,6 +349,10 @@ The app decides which cursors exist; whoever draws them works from the list. For `cargo xtask brands` (part of `cargo xtask ci`) fails when user-visible text names another vendor's products or company: string literals in Rust sources (command labels and params docs, menus, panels, MCP tool definitions), `Cargo.toml` descriptions and packaging files. Comments, test files and `#[cfg(test)]` modules are not checked. Say "the reference app" or name the feature itself. A line that must keep an old name, such as an alias that files or preferences from earlier versions still use, or a name another project defines, such as a shared MIME type, carries a `brand-ok` comment. In the Linux desktop entry, whose comments take whole lines, the comment goes on the `#` line just above it; `MARK_ABOVE` in `xtask/src/brands.rs` lists the files that accept a mark there. +## Test lint + +`cargo xtask test-lint` (part of `cargo xtask ci`) fails on tests that a wrong result can pass, in the lines and tests changed since a base: `assert!(….all(…))` with no length or emptiness check, a test whose only checks are `is_ok`, `is_some` or `!is_empty`, `assert_eq!(x, x)`, a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, `#[ignore]` without a reason, an environment variable that no CI leg sets, `thread::sleep` in test code, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. + ## Tests - `cargo xtask test` runs the workspace's unit and integration tests with diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 08a55df09a..f48f088aa8 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -18,6 +18,7 @@ mod sha256; mod shards; mod stats; mod test262; +mod test_lint; mod ui_commands; mod version; mod web_fonts; @@ -32,6 +33,10 @@ commands: assets check that every icon/image/font/asset is attributed in ASSETS.md brands check that user-visible text (labels, params docs, MCP, docs, packaging) names no other vendor's products cursors warn about Cursor values with no entry in crates/tools/src/cursors.toml (never fails) + test-lint [--base ] [--all] + fail on weak tests (unguarded .all(), only is_ok/is_some checks, no assertion, early + returns, unset env gates, sleeps...) in the lines changed since the base + (xtask/src/test_lint.rs); --all lists every hit by crate and never fails i18n-report list the strings each language's catalog lacks, shown in English (fails only on a broken scan; ci runs it too) ui-commands regenerate crates/mcp/src/ui_catalog.rs from desktop UI_COMMANDS; --check fails on drift @@ -39,7 +44,7 @@ commands: layers enforce the crate dependency layering (plan/architecture.md §3) wasm cargo check --target wasm32-unknown-unknown for the wasm-safe crates, the web app and its plug-in worker test the workspace tests (cargo nextest when installed, else cargo test), then the doctests - ci fmt --check, clippy -D warnings, test, doctests, no-bundled-fonts, pdf-deps, assets, brands, cursors (warnings only), ui-commands --check, layers, wasm (stops at first failure) + ci fmt --check, clippy -D warnings, test, doctests, no-bundled-fonts, pdf-deps, assets, brands, cursors (warnings only), test-lint, ui-commands --check, layers, wasm (stops at first failure) ci shard shard $GATE_SHARD of $GATE_SHARDS of ci (xtask/src/shards.rs): a test shard runs the tests and doctests of its crates, the last shard the other steps ci warm build what every shard builds, without running it (fills the gate's cache); with @@ -74,6 +79,7 @@ fn main() -> ExitCode { Some("assets") => assets::run(&root()), Some("brands") => brands::run(&root()), Some("cursors") => cursors::run(&root()), + Some("test-lint") => test_lint::run(&root(), &rest), Some("i18n-report") => cmd_i18n_report(), Some("ui-commands") => ui_commands::run(&root(), rest.contains(&"--check")), Some("layers") => cmd_layers(), @@ -515,6 +521,7 @@ fn ci_steps() -> Vec { ("assets", Box::new(|| assets::run(&root()))), ("brands", Box::new(|| brands::run(&root()))), ("cursors", Box::new(|| cursors::run(&root()))), + ("test-lint", Box::new(|| test_lint::run(&root(), &[]))), ("i18n-report", Box::new(cmd_ci_i18n_report)), ("ui-commands", Box::new(|| ui_commands::run(&root(), true))), ("layers", Box::new(cmd_layers)), diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs new file mode 100644 index 0000000000..8664403997 --- /dev/null +++ b/xtask/src/test_lint.rs @@ -0,0 +1,2574 @@ +//! `cargo xtask test-lint`: tests that a wrong result can pass, in the tests a change touches. +//! +//! Rules, checked in `#[test]` functions (and `#[tokio::test]`, `#[test_case]`, +//! `#[wasm_bindgen_test]`, and `#[test]` inside `proptest!`): +//! * `all-unguarded`: `assert!(….all(…))` in a test that neither checks a length, emptiness, +//! count, first item or `any` in an assertion's condition or compared operands, nor takes a +//! first item by indexing, unwrapping or a panicking `let … else`: `.all()` is true for an empty +//! collection (negated `.all(…)`, including `== false`, and predicates saying that no item +//! matches, with whole negations or `!=` comparisons joined only by `&&`, are left out). An earlier +//! `assert_eq!`, `debug_assert_eq!` or `prop_assert_eq!` comparing a plain local receiver +//! (optionally borrowed or viewed through `.as_slice()` or `[..]`) with a non-empty array +//! literal or `vec![…]` guards only that receiver. Non-empty array literals and plain local +//! names bound to them in the test, optionally through `.map(…)`, are also left out. Empty arrays +//! still count. A change anywhere in the test counts as a change to the hit; +//! * `only-weak`: every assertion is `is_ok()`, `is_some()`, `!is_empty()` or `len() > 0`, and the +//! test calls no asserting helper; +//! * `self-compare`: `assert_eq!(x, x)` or `assert_ne!(x, x)` on the same expression, when that +//! expression calls nothing with arguments (two calls with arguments check determinism); +//! * `exit-status-only`: a test that runs a process and checks only its exit status, reading no +//! output, with a status check in any condition or compared operand of a standard assertion; +//! * `no-assertion`: no assertion macro, `panic!`, `unwrap_err`, `expect_err` or asserting helper, +//! and no `#[should_panic]`; +//! * `early-return`: a silent bare `return` before the end of the test whose guard tests a value +//! from the code under test. Left out: a return after an assertion in its block, one whose +//! statement or line has a comment or a printed note saying why, and guards on files, fonts, +//! corpora, environment variables, the platform or a child process; +//! * `ignore-without-reason`: `#[ignore]` with no `= "reason"`; +//! * `env-gate-unset`: `env::var("NAME")` in a test where no CI workflow, the shared gate or the +//! file itself sets `NAME`; workflow mapping keys and `NAME=` assignments count, but comments +//! and variable reads do not; +//! * `sleep`: `thread::sleep` in test code; +//! * `reads-source`: test code that reads Rust source (`include_str!` of a `.rs` file, or a walk +//! that keeps files ending in `.rs`), outside the source audits in [`SOURCE_AUDITS`]. +//! +//! Test code is a test file (`tests.rs`, `tests_*.rs`, `*_tests.rs`, a file in a `tests` or +//! `benches` folder, `crates/testkit`), an item under `#[cfg(test)]`, or a test function. +//! +//! An asserting helper is a function or macro in the crate's test code (or in `crates/testkit`) +//! that asserts, panics or calls one that does, or a call whose name starts with `assert`, +//! `check`, `verify`, `ensure` or `expect_`. +//! +//! `// test-lint: allow ` exempts the line it is on and the line below it; for the +//! rules about a whole test it can be on any line from the line above the test attribute to the +//! `fn` line. An allow without a reason exempts nothing. +//! +//! `cargo xtask test-lint` fails on the hits in the lines and tests changed since a base: `--base +//! ` or `TEST_LINT_BASE`; in GitHub Actions the first parent of `HEAD` (a pull request's +//! merge commit is checked out, and a shallow checkout fetches that parent); elsewhere the merge +//! base of `HEAD` and `upstream/main` or `origin/main`. Uncommitted and untracked files count as +//! changed. Hits on unchanged lines are counted but do not fail it. `--all` lists every hit in the +//! workspace by crate and rule, and does not fail. + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; +use std::path::Path; +use std::process::Command; + +/// Test files that read Rust source on purpose: they audit the source tree. +pub const SOURCE_AUDITS: &[&str] = &[ + "crates/plugins/tests/grant_sites.rs", + "crates/ui-egui/src/i18n/tests.rs", + "crates/ui-egui/src/icons.rs", + "crates/eps/src/import/tests_generators.rs", +]; + +/// Variables the shared gate workflow and its setup action set on every leg, besides those named +/// in `.github/workflows/*.yml`. +const SHARED_GATE_ENV: &[&str] = + &["CRAFT_FONTS_DIR", "CRAFT_FONTS_REQUIRED", "GATE_SHARD", "GATE_SHARDS", "NEXTEST_PARTITION", "NEXTEST_ARCHIVE_FILE"]; + +/// Variables the runner, the operating system or cargo set. +const SYSTEM_ENV: &[&str] = &[ + "HOME", + "PATH", + "USER", + "USERNAME", + "LOGNAME", + "TMPDIR", + "TEMP", + "TMP", + "APPDATA", + "LOCALAPPDATA", + "USERPROFILE", + "PROGRAMDATA", + "PROGRAMFILES", + "WINDIR", + "SYSTEMROOT", + "CI", + "LANG", + "SHELL", + "PWD", + "OUT_DIR", +]; +const SYSTEM_ENV_PREFIXES: &[&str] = &["CARGO_", "NEXTEST", "RUST", "GITHUB_", "RUNNER_", "XDG_"]; + +/// Larger source files are refused rather than read. +const MAX_FILE: u64 = 16 << 20; + +/// The marker of an exemption comment. +const ALLOW: &str = "test-lint: allow "; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum Rule { + AllUnguarded, + OnlyWeak, + SelfCompare, + ExitStatusOnly, + NoAssertion, + EarlyReturn, + IgnoreWithoutReason, + EnvGateUnset, + Sleep, + ReadsSource, +} + +impl Rule { + pub const ALL: [Rule; 10] = [ + Rule::AllUnguarded, + Rule::OnlyWeak, + Rule::SelfCompare, + Rule::ExitStatusOnly, + Rule::NoAssertion, + Rule::EarlyReturn, + Rule::IgnoreWithoutReason, + Rule::EnvGateUnset, + Rule::Sleep, + Rule::ReadsSource, + ]; + + pub fn id(self) -> &'static str { + match self { + Rule::AllUnguarded => "all-unguarded", + Rule::OnlyWeak => "only-weak", + Rule::SelfCompare => "self-compare", + Rule::ExitStatusOnly => "exit-status-only", + Rule::NoAssertion => "no-assertion", + Rule::EarlyReturn => "early-return", + Rule::IgnoreWithoutReason => "ignore-without-reason", + Rule::EnvGateUnset => "env-gate-unset", + Rule::Sleep => "sleep", + Rule::ReadsSource => "reads-source", + } + } + + fn advice(self) -> &'static str { + match self { + Rule::AllUnguarded => "also assert the expected length (or that the collection is not empty)", + Rule::OnlyWeak => "assert the value itself (assert_eq! on the result), not only that there is one", + Rule::SelfCompare => "compare with an expected value written out, or with a second, independent computation", + Rule::ExitStatusOnly => "also check the output (stdout, stderr or the files written)", + Rule::NoAssertion => "assert what the code returns or changes", + Rule::EarlyReturn => "assert the condition instead of returning, so a wrong value fails the test", + Rule::IgnoreWithoutReason => "write #[ignore = \"why\"]", + Rule::EnvGateUnset => "set the variable in a CI leg, or make the test run without it", + Rule::Sleep => "wait on a handshake (channel, barrier) or a controllable clock", + Rule::ReadsSource => "test the behavior, or add the file to SOURCE_AUDITS in xtask/src/test_lint.rs if it audits the source tree", + } + } + + fn from_id(id: &str) -> Option { + Rule::ALL.into_iter().find(|r| r.id() == id) + } +} + +/// A rule broken in a file. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Hit { + pub path: String, + /// 1-based: the line of the finding, or of `fn` for a rule about a whole test. + pub line: usize, + pub rule: Rule, + /// The test it is in; empty for test code outside a test function. + pub test: String, + pub note: String, + /// The first and last line of what the hit covers: the test, from its attribute to its closing + /// brace, for a rule about a whole test or `all-unguarded`, through the second operand for + /// `self-compare`, else `line`. This span controls changed-line detection; `all-unguarded` + /// and `self-compare` exemptions still apply only near `line`. + pub first: usize, + pub last: usize, +} + +impl Hit { + fn show(&self) -> String { + let test = if self.test.is_empty() { String::new() } else { format!(" `{}`", self.test) }; + format!("{}:{}: [{}]{test}: {}", self.path, self.line, self.rule.id(), self.note) + } +} + +/// What the rules need beyond the file: asserting helper names by crate and the variables CI sets. +pub struct Ctx { + pub helpers: HashMap>, + pub ci_env: HashSet, +} + +pub fn run(root: &Path, args: &[&str]) -> Result<(), String> { + let opts = Options::parse(args)?; + let repo = crate::repo_files(root)?; + let ci_env = ci_env(root, &repo)?; + let files: Vec = repo.into_iter().filter(|p| is_scanned(p)).collect(); + if opts.all { + let sources = read_all(root, &files)?; + let ctx = Ctx { helpers: asserting_helpers(&sources), ci_env }; + let hits: Vec = sources.iter().flat_map(|(p, s)| lint_file(p, s, &ctx)).collect(); + print!("{}", report(&hits, sources.len())); + return Ok(()); + } + let base = resolve_base(root, opts.base)?; + let changed = changed_lines(root, &base)?; + let changed: BTreeMap>> = changed.into_iter().filter(|(p, _)| is_scanned(p)).collect(); + let crates: BTreeSet = changed.keys().map(|p| crate_of(p)).chain([TESTKIT.to_owned()]).collect(); + let helper_files: Vec = files.iter().filter(|p| crates.contains(&crate_of(p))).cloned().collect(); + let ctx = Ctx { helpers: asserting_helpers(&read_all(root, &helper_files)?), ci_env }; + let present: Vec = changed.keys().filter(|p| root.join(p).is_file()).cloned().collect(); + let (mut counted, mut older) = (vec![], 0usize); + for (path, src) in read_all(root, &present)? { + for hit in lint_file(&path, &src, &ctx) { + if touches(&hit, changed.get(&path).and_then(Option::as_ref)) { + counted.push(hit); + } else { + older += 1; + } + } + } + finish(&counted, older, present.len(), &base) +} + +/// The command line: `--all`, `--base `. +#[derive(Debug, Default, PartialEq)] +struct Options { + all: bool, + base: Option, +} + +impl Options { + fn parse(args: &[&str]) -> Result { + let mut opts = Options::default(); + let mut it = args.iter(); + while let Some(&arg) = it.next() { + match arg { + "--all" if !opts.all => opts.all = true, + "--base" if opts.base.is_none() => match it.next() { + Some(rev) if !rev.is_empty() && !rev.starts_with('-') => opts.base = Some((*rev).to_owned()), + _ => return Err("test-lint: --base takes a revision".into()), + }, + _ => return Err(format!("test-lint: unexpected argument `{arg}` (usage: cargo xtask test-lint [--all] [--base ])")), + } + } + if opts.all && opts.base.is_some() { + return Err("test-lint: --all checks every file and takes no --base".into()); + } + Ok(opts) + } +} + +fn finish(counted: &[Hit], older: usize, files: usize, base: &str) -> Result<(), String> { + let older = if older == 0 { String::new() } else { format!("; {older} hit(s) on unchanged lines of those files are not counted") }; + if counted.is_empty() { + println!("test-lint: no hits in the changed lines of {files} Rust file(s) since {base}{older}"); + return Ok(()); + } + let mut out: Vec = counted.iter().map(Hit::show).collect(); + let rules: BTreeSet = counted.iter().map(|h| h.rule).collect(); + out.extend(rules.iter().map(|r| format!("{}: {}", r.id(), r.advice()))); + Err(format!( + "{} test-lint hit(s) in the lines changed since {base}{older} (exempt a line with `// {ALLOW} `):\n {}", + counted.len(), + out.join("\n ") + )) +} + +/// `--all`: counts by crate and rule, then every hit. +fn report(hits: &[Hit], files: usize) -> String { + let mut by_crate: BTreeMap> = BTreeMap::new(); + for h in hits { + *by_crate.entry(crate_of(&h.path)).or_default().entry(h.rule).or_default() += 1; + } + let mut out = format!("test-lint --all: {} hit(s) in {files} Rust file(s)\n\nby rule:\n", hits.len()); + for rule in Rule::ALL { + out += &format!(" {:<22} {}\n", rule.id(), hits.iter().filter(|h| h.rule == rule).count()); + } + out += "\nby crate:\n"; + for (krate, rules) in &by_crate { + let list: Vec = rules.iter().map(|(r, n)| format!("{} {n}", r.id())).collect(); + out += &format!(" {krate}: {}\n", list.join(", ")); + } + out += "\nhits:\n"; + for h in hits { + out += &format!(" {}\n", h.show()); + } + out +} + +/// Rust files the lint reads. +fn is_scanned(path: &str) -> bool { + path.ends_with(".rs") && ["crates/", "apps/", "xtask/"].iter().any(|d| path.starts_with(d)) +} + +/// `crates/` or `apps/` for a file in one, else its first path component. +fn crate_of(path: &str) -> String { + let parts: Vec<&str> = path.split('/').collect(); + match parts.as_slice() { + [top @ ("crates" | "apps"), name, _, ..] => format!("{top}/{name}"), + [first, ..] => (*first).to_owned(), + [] => String::new(), + } +} + +fn read_all(root: &Path, paths: &[String]) -> Result, String> { + paths + .iter() + .map(|p| { + let full = root.join(p); + let len = std::fs::metadata(&full).map_err(|e| format!("{p}: {e}"))?.len(); + if len > MAX_FILE { + return Err(format!("{p}: {len} bytes, over test-lint's limit of {MAX_FILE}")); + } + Ok((p.clone(), std::fs::read_to_string(&full).map_err(|e| format!("{p}: {e}"))?)) + }) + .collect() +} + +// ---- Git: the base and the changed lines ---- + +fn git(root: &Path, args: &[&str]) -> Result { + let out = Command::new("git").current_dir(root).args(args).output().map_err(|e| format!("git {}: {e}", args.join(" ")))?; + if !out.status.success() { + return Err(format!("git {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim())); + } + Ok(String::from_utf8_lossy(&out.stdout).trim().to_owned()) +} + +fn resolve_base(root: &Path, explicit: Option) -> Result { + if let Some(rev) = explicit.or_else(|| std::env::var("TEST_LINT_BASE").ok().filter(|v| !v.is_empty())) { + return git(root, &["rev-parse", "--verify", "--quiet", &format!("{rev}^{{commit}}")]) + .map_err(|_| format!("test-lint: base `{rev}` is not a commit")); + } + if std::env::var_os("GITHUB_ACTIONS").is_some() { + if let Ok(parent) = git(root, &["rev-parse", "--verify", "--quiet", "HEAD^1^{commit}"]) { + return Ok(parent); + } + let head = git(root, &["rev-parse", "HEAD"])?; + git(root, &["fetch", "--no-tags", "--quiet", "--depth=2", "origin", &head])?; + return git(root, &["rev-parse", "--verify", "--quiet", "HEAD^1^{commit}"]) + .map_err(|_| "test-lint: HEAD has no parent to compare with (set TEST_LINT_BASE)".into()); + } + for main in ["upstream/main", "origin/main"] { + if let Ok(base) = git(root, &["merge-base", "HEAD", main]) { + return Ok(base); + } + } + Err("test-lint: no upstream/main or origin/main to compare with; pass --base or set TEST_LINT_BASE".into()) +} + +/// The changed files since `base` with their changed lines (new numbering); `None` for a file that +/// is new or untracked. A pure deletion marks the lines before and after it, or line 1 at the top +/// of the file. +fn changed_lines(root: &Path, base: &str) -> Result>>, String> { + let diff = git( + root, + &["-c", "core.quotepath=off", "diff", "-U0", "--no-color", "--no-ext-diff", "--src-prefix=a/", "--dst-prefix=b/", base, "--", "*.rs"], + )?; + let mut out = parse_diff(&diff); + for path in git(root, &["-c", "core.quotepath=off", "ls-files", "--others", "--exclude-standard", "--", "*.rs"])?.lines() { + out.insert(path.to_owned(), None); + } + Ok(out) +} + +/// The changed new-side lines in each file. A pure deletion includes its anchor and the following +/// line, or just line 1 when the anchor is 0. +fn parse_diff(diff: &str) -> BTreeMap>> { + let mut out: BTreeMap>> = BTreeMap::new(); + let mut current: Option = None; + // Inside a file's header (from `diff --git` to its first hunk), where `+++ ` names the file. + let (mut header, mut new_file) = (false, false); + for line in diff.lines() { + if line.starts_with("diff --git ") { + (header, new_file) = (true, false); + } else if header && line.starts_with("new file mode") { + new_file = true; + } else if let Some(path) = line.strip_prefix("+++ ").filter(|_| header) { + current = path.strip_prefix("b/").map(str::to_owned); + if let Some(p) = ¤t { + out.insert(p.clone(), if new_file { None } else { Some(BTreeSet::new()) }); + } + } else if let (Some(hunk), Some(path)) = (line.strip_prefix("@@ "), ¤t) { + header = false; + if let (Some((start, count)), Some(Some(lines))) = (hunk_range(hunk), out.get_mut(path)) { + if count == 0 { + lines.extend(start.max(1)..=start.saturating_add(1)); + } else { + lines.extend(start..start + count); + } + } + } + } + out +} + +/// `(start, count)` of the new side of a hunk header's `-a,b +c,d @@`. A pure deletion has count 0 +/// and sits between lines c and c + 1; c = 0 places it before line 1. +fn hunk_range(hunk: &str) -> Option<(usize, usize)> { + let new = hunk.split_whitespace().find(|w| w.starts_with('+'))?.trim_start_matches('+'); + match new.split_once(',') { + Some((s, c)) => Some((s.parse().ok()?, c.parse().ok()?)), + None => Some((new.parse().ok()?, 1)), + } +} + +/// Whether `hit` covers a changed line (`None`: the whole file is new). +fn touches(hit: &Hit, changed: Option<&BTreeSet>) -> bool { + changed.is_none_or(|lines| lines.range(hit.first..=hit.last).next().is_some()) +} + +// ---- What CI sets ---- + +fn ci_env(root: &Path, files: &[String]) -> Result, String> { + let mut names: HashSet = SHARED_GATE_ENV.iter().map(|s| (*s).to_owned()).collect(); + for path in files.iter().filter(|p| p.starts_with(".github/workflows/") && (p.ends_with(".yml") || p.ends_with(".yaml"))) { + let text = std::fs::read_to_string(root.join(path)).map_err(|e| format!("{path}: {e}"))?; + names.extend(upper_words(&text)); + } + Ok(names) +} + +/// Workflow mapping keys and assignments with capitalized environment variable names. +fn upper_words(text: &str) -> impl Iterator + '_ { + text.lines().flat_map(|line| { + let line = workflow_code(line); + let start = line.trim_start().strip_prefix("- ").unwrap_or(line.trim_start()).trim_start(); + let mapping = + start.split_once(':').filter(|(name, rest)| env_assignment_name(name) && (rest.is_empty() || rest.starts_with(char::is_whitespace))); + let assignments = line.match_indices('=').filter_map(move |(at, _)| { + let name = line[..at].rsplit(|c: char| !(c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_')).next().unwrap_or_default(); + let from = at - name.len(); + let boundary = from == 0 || line.as_bytes().get(from - 1).is_some_and(|c| c.is_ascii_whitespace() || matches!(c, b'\'' | b'"' | b';')); + (boundary && env_assignment_name(name) && !line[at + 1..].starts_with(['=', '>'])).then(|| name.to_owned()) + }); + mapping.map(|(name, _)| name.to_owned()).into_iter().chain(assignments) + }) +} + +fn env_assignment_name(name: &str) -> bool { + name.len() > 1 + && name.starts_with(|c: char| c.is_ascii_uppercase()) + && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_') +} + +/// Removes comment text outside quotes from a workflow line. +fn workflow_code(line: &str) -> &str { + let (mut quote, mut escaped) = (None, false); + for (at, c) in line.char_indices() { + if escaped { + escaped = false; + } else if c == '\\' && quote != Some('\'') { + escaped = true; + } else if quote == Some(c) { + quote = None; + } else if quote.is_none() { + match c { + '\'' | '"' => quote = Some(c), + '#' => return &line[..at], + _ => {} + } + } + } + line +} + +fn set_by_system(name: &str) -> bool { + SYSTEM_ENV.contains(&name) || SYSTEM_ENV_PREFIXES.iter().any(|p| name.starts_with(p)) +} + +// ---- Lexing ---- + +fn is_ident(c: u8) -> bool { + c.is_ascii_alphanumeric() || c == b'_' +} + +/// `src` with the text of comments and of string and character literals replaced by spaces (line +/// breaks and quotes kept), at the same byte offsets. +fn mask(src: &str) -> Vec { + mask_with(src, true) +} + +/// [`mask`], keeping comments when `comments` is false. +fn mask_with(src: &str, comments: bool) -> Vec { + mask_parts(src, comments, true) +} + +/// Blanks comments while keeping code and literal contents at the same byte offsets. +fn mask_comments(src: &str) -> Vec { + mask_parts(src, true, false) +} + +/// Blanks the selected comments and literal contents, preserving line breaks and literal quotes. +fn mask_parts(src: &str, comments: bool, literals: bool) -> Vec { + let b = src.as_bytes(); + let mut out = b.to_vec(); + let mut i = 0; + while i < b.len() { + let next = match b[i] { + b'/' if b.get(i + 1) == Some(&b'/') => { + let end = find(b, b"\n", i).unwrap_or(b.len()); + if comments { + blank(&mut out, i, end); + } + end + } + b'/' if b.get(i + 1) == Some(&b'*') => { + let end = block_comment_end(b, i); + if comments { + blank(&mut out, i, end); + } + end + } + b'"' => { + let end = string_end(b, i + 1); + if literals { + blank(&mut out, i + 1, end.saturating_sub(1)); + } + end + } + b'\'' => { + let end = after_char_or_lifetime(src, i); + if literals { + blank(&mut out, i + 1, end.saturating_sub(1).max(i + 1)); + } + end + } + c if c.is_ascii_alphabetic() || c == b'_' => after_ident(b, &mut out, i, literals), + _ => i + 1, + }; + i = next.max(i + 1); + } + out +} + +fn blank(out: &mut [u8], from: usize, to: usize) { + for c in out.iter_mut().take(to).skip(from) { + if *c != b'\n' { + *c = b' '; + } + } +} + +fn block_comment_end(b: &[u8], mut i: usize) -> usize { + let mut nest = 0usize; + while i < b.len() { + if b[i..].starts_with(b"/*") { + nest += 1; + i += 2; + } else if b[i..].starts_with(b"*/") { + nest = nest.saturating_sub(1); + i += 2; + if nest == 0 { + return i; + } + } else { + i += 1; + } + } + b.len() +} + +/// The index after the closing quote of a `"…"` literal whose body starts at `i`. +fn string_end(b: &[u8], mut i: usize) -> usize { + while i < b.len() && b[i] != b'"' { + i += if b[i] == b'\\' { 2 } else { 1 }; + } + (i + 1).min(b.len()) +} + +/// The index after a char literal (`'x'`, `'\n'`, `'\u{…}'`) at `i`, or after the quote of a +/// lifetime or label. +fn after_char_or_lifetime(src: &str, i: usize) -> usize { + let b = src.as_bytes(); + if b.get(i + 1) == Some(&b'\\') { + let close = (i + 3..b.len()).find(|&j| b[j] == b'\'').unwrap_or(b.len()); + return (close + 1).min(b.len()); + } + match src.get(i + 1..).and_then(|s| s.chars().next()) { + Some(c) if b.get(i + 1 + c.len_utf8()) == Some(&b'\'') => i + 2 + c.len_utf8(), + _ => i + 1, + } +} + +/// Skips the identifier at `start`; a raw string prefix (`r`, `br`, `cr`) also skips the raw +/// string after it and blanks its contents when `literals` is true. +fn after_ident(b: &[u8], out: &mut [u8], start: usize, literals: bool) -> usize { + let mut i = start; + while i < b.len() && is_ident(b[i]) { + i += 1; + } + if start > 0 && is_ident(b[start - 1]) { + return i; + } + let hashes = b[i..].iter().take_while(|&&h| h == b'#').count(); + if !matches!(&b[start..i], b"r" | b"br" | b"cr") || b.get(i + hashes) != Some(&b'"') { + return i; + } + let body = i + hashes + 1; + let close: Vec = std::iter::once(b'"').chain(std::iter::repeat_n(b'#', hashes)).collect(); + let end = find(b, &close, body).unwrap_or(b.len()); + if literals { + blank(out, body, end); + } + (end + close.len()).min(b.len()) +} + +fn find(hay: &[u8], needle: &[u8], from: usize) -> Option { + if needle.is_empty() || from >= hay.len() { + return None; + } + hay[from..].windows(needle.len()).position(|w| w == needle).map(|p| p + from) +} + +fn contains(hay: &[u8], needle: &[u8]) -> bool { + find(hay, needle, 0).is_some() +} + +fn skip_ws(b: &[u8], mut i: usize) -> usize { + while i < b.len() && b[i].is_ascii_whitespace() { + i += 1; + } + i +} + +/// Every start of `word` in `b[from..to]` with no identifier character on either side. +fn words(b: &[u8], word: &[u8], from: usize, to: usize) -> Vec { + let mut out = vec![]; + let mut i = from; + while let Some(at) = find(&b[..to.min(b.len())], word, i) { + let before = at.checked_sub(1).and_then(|j| b.get(j)).copied().is_some_and(is_ident); + let after = b.get(at + word.len()).copied().is_some_and(is_ident); + if !before && !after { + out.push(at); + } + i = at + 1; + } + out +} + +/// The index of the bracket closing the one at `open`. +fn matching(m: &[u8], open: usize) -> Option { + let (o, c) = match m.get(open)? { + b'(' => (b'(', b')'), + b'[' => (b'[', b']'), + b'{' => (b'{', b'}'), + _ => return None, + }; + let mut depth = 0usize; + for (j, &ch) in m.iter().enumerate().skip(open) { + if ch == o { + depth += 1; + } else if ch == c { + depth = depth.saturating_sub(1); + if depth == 0 { + return Some(j); + } + } + } + None +} + +/// The ranges of the top-level comma-separated parts of `m[from..to]`. +fn split_args(m: &[u8], from: usize, to: usize) -> Vec<(usize, usize)> { + let (mut out, mut depth, mut start) = (vec![], 0i32, from); + let mut angles = 0usize; + for (j, &ch) in m.iter().enumerate().take(to).skip(from) { + match ch { + b'(' | b'[' | b'{' => depth += 1, + b')' | b']' | b'}' => depth -= 1, + b'<' if angles > 0 || m[from..j].trim_ascii_end().ends_with(b"::") => angles += 1, + b'>' if angles > 0 => angles -= 1, + b',' if depth == 0 && angles == 0 => { + out.push((start, j)); + start = j + 1; + } + _ => {} + } + } + if m[start..to].iter().any(|c| !c.is_ascii_whitespace()) { + out.push((start, to)); + } + out +} + +/// `b` without whitespace. +fn norm(b: &[u8]) -> String { + String::from_utf8_lossy(&b.iter().copied().filter(|c| !c.is_ascii_whitespace()).collect::>()).into_owned() +} + +/// Line starts, to turn byte offsets into 1-based lines. +struct Lines(Vec); + +impl Lines { + fn new(src: &str) -> Lines { + Lines(std::iter::once(0).chain(src.match_indices('\n').map(|(i, _)| i + 1)).collect()) + } + + fn of(&self, pos: usize) -> usize { + self.0.partition_point(|&s| s <= pos) + } +} + +// ---- Tests and calls ---- + +/// A test function: its name, the offsets of its first attribute and `fn`, and its body's braces. +#[derive(Debug)] +struct TestFn { + name: String, + /// The first attribute of the function (`#[should_panic]` can come before `#[test]`). + attr: usize, + fn_at: usize, + open: usize, + close: usize, +} + +fn is_test_attr(path: &[u8]) -> bool { + matches!(path, b"test" | b"wasm_bindgen_test" | b"test_case") || path.ends_with(b"::test") || path.ends_with(b"::test_case") +} + +/// The test functions of masked source `m`. +fn tests_in(m: &[u8]) -> Vec { + let mut out: Vec = vec![]; + let mut i = 0; + while let Some(at) = find(m, b"#[", i) { + i = at + 2; + let start = skip_ws(m, at + 2); + let end = start + m[start..].iter().take_while(|&&c| is_ident(c) || c == b':').count(); + if !is_test_attr(&m[start..end]) || !matches!(m.get(skip_ws(m, end)), Some(b']' | b'(')) { + continue; + } + let Some(t) = fn_after(m, at, end) else { continue }; + if out.iter().any(|o| o.fn_at == t.fn_at) { + continue; + } + i = t.open; + out.push(t); + } + out +} + +/// The function an attribute at `attr` (ending at `from`) belongs to. +fn fn_after(m: &[u8], attr: usize, from: usize) -> Option { + let limit = (from + 800).min(m.len()); + let fn_at = *words(m, b"fn", from, limit).first()?; + if m[from..fn_at].iter().any(|&c| c == b'{' || c == b';') { + return None; + } + let name_start = skip_ws(m, fn_at + 2); + let name_end = name_start + m[name_start..].iter().take_while(|&&c| is_ident(c)).count(); + if name_end == name_start { + return None; + } + let open = name_end + m[name_end..].iter().position(|&c| c == b'{' || c == b';')?; + if m[open] != b'{' { + return None; + } + let close = matching(m, open)?; + // The item starts after the previous item or block opening; comments before it are masked. + let item = m[..attr].iter().rposition(|&c| matches!(c, b';' | b'{' | b'}')).map_or(0, |p| p + 1); + let attr = skip_ws(m, item).min(attr); + Some(TestFn { name: String::from_utf8_lossy(&m[name_start..name_end]).into_owned(), attr, fn_at, open, close }) +} + +/// A macro call in a test: its name, offset and argument ranges. +struct MacroCall { + name: String, + at: usize, + args: Vec<(usize, usize)>, +} + +/// The macro calls (`name!(…)`, `name![…]`, `name!{…}`) in `m[from..to]`. +fn macro_calls(m: &[u8], from: usize, to: usize) -> Vec { + let mut out = vec![]; + let mut i = from; + while let Some(bang) = find(&m[..to], b"!", i) { + i = bang + 1; + let start = (from..bang).rev().take_while(|&j| is_ident(m[j])).last().unwrap_or(bang); + let open = skip_ws(m, bang + 1); + if start == bang || start.checked_sub(1).is_some_and(|j| is_ident(m[j])) || !matches!(m.get(open), Some(b'(' | b'[' | b'{')) { + continue; + } + let Some(close) = matching(m, open).filter(|&c| c < to) else { continue }; + out.push(MacroCall { name: String::from_utf8_lossy(&m[start..bang]).into_owned(), at: start, args: split_args(m, open + 1, close) }); + } + out +} + +fn is_assert_macro(name: &str) -> bool { + ["assert", "debug_assert", "prop_assert"].iter().any(|p| name.starts_with(p)) +} + +const KEYWORDS: &[&str] = &["if", "while", "match", "for", "loop", "return", "fn", "in", "as", "let", "else", "move", "Some", "Ok", "Err"]; + +/// Names that helper detection ignores: too common to tell a helper from the code under test. +const COMMON: &[&str] = &[ + "new", "default", "from", "into", "get", "set", "run", "apply", "build", "make", "open", "load", "save", "parse", "read", "write", "draw", + "render", "len", "clone", "push", "vec", "format", "json", "Box", "Arc", "Vec", "String", "main", +]; + +/// The names called in `m[from..to]`: functions (`name(`, also through a path), methods +/// (`.name(`), including calls with turbofish arguments, and macros (`name!`). +fn calls(m: &[u8], from: usize, to: usize) -> Vec<(String, bool)> { + let m = &m[..to]; + let mut out = vec![]; + let mut i = from; + while i < to { + if !(m[i].is_ascii_alphabetic() || m[i] == b'_') || (i > 0 && is_ident(m[i - 1])) { + i += 1; + continue; + } + let end = i + m[i..to].iter().take_while(|&&c| is_ident(c)).count(); + let bang = m.get(end) == Some(&b'!'); + let after = skip_ws(m, end + usize::from(bang)); + let after = if bang { after } else { skip_turbofish(m, after) }; + if matches!(m.get(after), Some(b'(' | b'[' | b'{')) && (bang || m[after] == b'(') { + let name = String::from_utf8_lossy(&m[i..end]).into_owned(); + let method = i > 0 && m[i - 1] == b'.'; + if !KEYWORDS.contains(&name.as_str()) { + out.push((if bang { format!("{name}!") } else { name }, method)); + } + } + i = end; + } + out +} + +/// Skips optional `::<…>` arguments and the whitespace after them. +fn skip_turbofish(m: &[u8], at: usize) -> usize { + if !m[at..].starts_with(b"::") { + return at; + } + let open = skip_ws(m, at + 2); + if m.get(open) != Some(&b'<') { + return at; + } + let (mut i, mut depth) = (open + 1, 1usize); + while i < m.len() { + match m[i] { + b'<' => depth += 1, + b'>' if m[i - 1] != b'-' => { + depth -= 1; + if depth == 0 { + return skip_ws(m, i + 1); + } + } + b'(' | b'[' | b'{' => i = matching(m, i).unwrap_or(m.len()), + _ => {} + } + i += 1; + } + m.len() +} + +/// Whether `name` (a call in a test) is an asserting helper. +fn is_helper_call(name: &str, method: bool, helpers: &HashSet) -> bool { + let base = name.trim_end_matches('!'); + let named = ["assert", "check", "verify", "ensure", "expect_"].iter().any(|p| base.starts_with(p)); + named || (!method && !COMMON.contains(&base) && helpers.contains(name)) +} + +/// Whether the masked text checks something itself: an assertion, `panic!`, `unwrap_err` or +/// `expect_err`. +fn checks_itself(m: &[u8], from: usize, to: usize) -> bool { + let body = &m[from..to]; + contains(body, b"panic!") + || contains(body, b".unwrap_err()") + || contains(body, b".expect_err(") + || macro_calls(m, from, to).iter().any(|c| is_assert_macro(&c.name)) +} + +/// `tests.rs`, `tests_*.rs`, `*_tests.rs`, files in a `tests` or `benches` folder, and +/// `crates/testkit`. +fn is_test_file(path: &str) -> bool { + let mut parts = path.split('/').rev(); + let file = parts.next().unwrap_or_default(); + file == "tests.rs" + || file.starts_with("tests_") + || file.ends_with("_tests.rs") + || parts.any(|d| d == "tests" || d == "benches") + || path.starts_with("crates/testkit/") +} + +/// The byte ranges of test code in a file: all of a test file, else each item under +/// `#[cfg(test)]` that has a body in the file, and each test function. +fn test_regions(path: &str, m: &[u8], tests: &[TestFn]) -> Vec<(usize, usize)> { + if is_test_file(path) { + return vec![(0, m.len())]; + } + let mut out: Vec<(usize, usize)> = tests.iter().map(|t| (t.attr, t.close)).collect(); + for at in words(m, b"cfg", 0, m.len()) { + let attr = skip_ws(m, at + "cfg".len()); + if !m[..at].ends_with(b"#[") || !m[attr..].starts_with(b"(test)]") { + continue; + } + // The item's body: the first `{` before any `;` (`mod tests;` has none here). + let after = attr + "(test)]".len(); + let Some(open) = m[after..].iter().position(|&c| c == b'{' || c == b';').map(|p| p + after) else { continue }; + if let (b'{', Some(close)) = (m[open], matching(m, open)) { + out.push((at, close)); + } + } + out +} + +fn in_regions(regions: &[(usize, usize)], pos: usize) -> bool { + regions.iter().any(|&(from, to)| from <= pos && pos <= to) +} + +/// A function or macro in test code: its name (`name!` for a macro), whether it checks something +/// itself, and the names it calls. +type Def = (String, bool, Vec); + +/// For each crate of `files` ([`crate_of`]), the names of the functions and macros in its test +/// code, or in `crates/testkit`'s, that assert, panic or call one that does. +pub fn asserting_helpers(files: &[(String, String)]) -> HashMap> { + let mut defs: HashMap> = HashMap::new(); + for (path, src) in files { + let m = mask(src); + let regions = test_regions(path, &m, &tests_in(&m)); + let crate_defs = defs.entry(crate_of(path)).or_default(); + for at in words(&m, b"fn", 0, m.len()).into_iter().chain(words(&m, b"macro_rules", 0, m.len())) { + if in_regions(®ions, at) { + crate_defs.extend(definition(&m, at)); + } + } + } + let testkit = defs.get(TESTKIT).cloned().unwrap_or_default(); + defs.iter().map(|(krate, own)| (krate.clone(), checking(own.iter().chain(if krate == TESTKIT { &[][..] } else { &testkit[..] })))).collect() +} + +/// The crate whose test helpers every crate can call. +const TESTKIT: &str = "crates/testkit"; + +/// The names among `defs` that check something, directly or through another of `defs`. +fn checking<'a>(defs: impl Iterator + Clone) -> HashSet { + let mut known: HashSet = defs.clone().filter(|d| d.1).map(|d| d.0.clone()).collect(); + loop { + let more: Vec = + defs.clone().filter(|d| !known.contains(&d.0) && d.2.iter().any(|c| known.contains(c))).map(|d| d.0.clone()).collect(); + if more.is_empty() { + return known; + } + known.extend(more); + } +} + +/// The `fn` or `macro_rules!` at `at`. +fn definition(m: &[u8], at: usize) -> Option { + let is_macro = m[at..].starts_with(b"macro_rules"); + let mut start = skip_ws(m, at + if is_macro { "macro_rules".len() } else { 2 }); + if is_macro { + start = skip_ws(m, start + usize::from(m.get(start) == Some(&b'!'))); + } + let end = start + m[start..].iter().take_while(|&&c| is_ident(c)).count(); + if end == start { + return None; + } + let open = end + m[end..].iter().position(|&c| c == b'{' || c == b';')?; + if m[open] != b'{' { + return None; + } + let close = matching(m, open)?; + let name = String::from_utf8_lossy(&m[start..end]).into_owned(); + let called = calls(m, open, close).into_iter().filter(|(_, method)| !method).map(|(n, _)| n).collect(); + Some((if is_macro { format!("{name}!") } else { name }, checks_itself(m, open, close), called)) +} + +// ---- The rules ---- + +/// The source, its masked copy and its tests. +struct File<'a> { + path: &'a str, + src: &'a [u8], + m: Vec, + lines: Lines, + tests: Vec, + /// The test code ([`test_regions`]). + regions: Vec<(usize, usize)>, +} + +impl File<'_> { + fn hit(&self, at: usize, rule: Rule, test: &str, note: String) -> Hit { + let line = self.lines.of(at); + Hit { path: self.path.to_owned(), line, rule, test: test.to_owned(), note, first: line, last: line } + } + + fn test_at(&self, pos: usize) -> &str { + self.tests.iter().find(|t| t.open <= pos && pos <= t.close).map_or("", |t| t.name.as_str()) + } + + /// The source of `from..to` without whitespace and comments between tokens; string and + /// character literals keep their text. + fn src_norm(&self, (from, to): (usize, usize)) -> String { + let mut out = Vec::with_capacity(to - from); + let mut in_literal = false; + for i in from..to { + let (s, m) = (self.src[i], self.m[i]); + if m == b'"' || (m == b'\'' && !in_literal && self.m.get(i + 1) == Some(&b' ')) { + in_literal = !in_literal; + } else if m == b'\'' && in_literal { + in_literal = false; + } + if in_literal || (m == s && !s.is_ascii_whitespace()) { + out.push(s); + } + } + String::from_utf8_lossy(&out).into_owned() + } +} + +/// Every hit in one file, exemptions applied. +pub fn lint_file(path: &str, src: &str, ctx: &Ctx) -> Vec { + let m = mask(src); + let tests = tests_in(&m); + let regions = test_regions(path, &m, &tests); + let file = File { path, src: src.as_bytes(), m, lines: Lines::new(src), tests, regions }; + let mut hits: Vec = file.tests.iter().flat_map(|t| test_hits(&file, t, ctx)).collect(); + hits.extend(ignore_hits(&file)); + hits.extend(sleep_hits(&file)); + hits.extend(reads_source_hits(&file)); + let allows = allows(src, &file.m); + hits.retain(|h| { + let first = if h.rule == Rule::AllUnguarded { h.line } else { h.first }; + !allows.iter().any(|&(line, rule)| rule == h.rule && line + 1 >= first && line <= h.line) + }); + hits.sort(); + hits +} + +/// `(line, rule)` of each exemption comment that names a rule and a reason. +/// A marker counts only inside a comment: masked (`m`) there, and kept when only literals are +/// masked. +fn allows(src: &str, m: &[u8]) -> Vec<(usize, Rule)> { + let literals = mask_with(src, false); + let lines = Lines::new(src); + src.match_indices(ALLOW) + .filter(|&(p, _)| m[p] == b' ' && literals[p] == b't') + .filter_map(|(p, _)| { + let rest = src[p + ALLOW.len()..].lines().next()?; + let mut words = rest.split_whitespace(); + let rule = Rule::from_id(words.next()?)?; + words.next().map(|_| (lines.of(p), rule)) + }) + .collect() +} + +/// What the rules read of one test. +struct View<'a> { + file: &'a File<'a>, + t: &'a TestFn, + asserts: Vec, + delegates: bool, + checks: bool, + should_panic: bool, +} + +fn test_hits(file: &File, t: &TestFn, ctx: &Ctx) -> Vec { + let m = &file.m; + let asserts: Vec = macro_calls(m, t.open, t.close).into_iter().filter(|c| is_assert_macro(&c.name)).collect(); + let none = HashSet::new(); + let helpers = ctx.helpers.get(&crate_of(file.path)).unwrap_or(&none); + let delegates = calls(m, t.open, t.close) + .iter() + .any(|(n, method)| n != &t.name && !(n.ends_with('!') && is_assert_macro(n)) && is_helper_call(n, *method, helpers)); + let checks = checks_itself(m, t.open, t.close); + let should_panic = contains(&m[t.attr..t.fn_at], b"should_panic"); + let v = View { file, t, asserts, delegates, checks, should_panic }; + let mut hits = all_unguarded(&v); + hits.extend(self_compare(&v)); + hits.extend(early_returns(&v)); + hits.extend(env_gates(&v, ctx)); + hits.extend([only_weak(&v), exit_status_only(&v), no_assertion(&v)].into_iter().flatten()); + hits +} + +impl View<'_> { + fn hit(&self, at: usize, rule: Rule, note: String) -> Hit { + self.file.hit(at, rule, &self.t.name, note) + } + + /// A hit for the whole test, on its `fn` line. + fn whole(&self, rule: Rule, note: String) -> Hit { + let mut h = self.hit(self.t.fn_at, rule, note); + h.first = self.file.lines.of(self.t.attr); + h.last = self.file.lines.of(self.t.close); + h + } + + fn body(&self) -> &[u8] { + &self.file.m[self.t.open..self.t.close] + } + + /// The masked body with assertion failure-message arguments replaced by spaces. + fn body_without_messages(&self) -> Vec { + let mut body = self.body().to_vec(); + for a in &self.asserts { + for &(from, to) in a.args.iter().skip(guard_arg_count(&a.name)) { + blank(&mut body, from - self.t.open, to - self.t.open); + } + } + body + } + + /// The first argument of an assertion, masked, without whitespace. + fn first_arg(&self, a: &MacroCall) -> String { + a.args.first().map(|&(f, t)| norm(&self.file.m[f..t])).unwrap_or_default() + } +} + +const PLAIN_ASSERTS: &[&str] = &["assert", "debug_assert", "prop_assert"]; + +fn all_unguarded(v: &View) -> Vec { + let mut body = v.body_without_messages(); + strip_all_predicates(&mut body); + let checked = v.asserts.iter().any(|a| { + a.args.iter().take(guard_arg_count(&a.name)).any(|&(from, to)| { + let arg = norm(&body[from - v.t.open..to - v.t.open]); + [".len()", ".is_empty()", ".count()", ".first()", ".any(", ".next()", ".last()"].iter().any(|g| arg.contains(g)) + }) + }); + if checked || first_item_guard(&body) { + return vec![]; + } + v.asserts + .iter() + .filter(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && unguarded_all(&v.first_arg(a), &v.file.m[v.t.open..a.at])) + .map(|a| { + let mut h = v.hit(a.at, Rule::AllUnguarded, format!("{}!(…all(…)) with no length or emptiness check in the test", a.name)); + h.first = v.file.lines.of(v.t.attr); + h.last = v.file.lines.of(v.t.close); + h + }) + .collect() +} + +/// The number of condition or compared operands in a standard assertion macro. +fn guard_arg_count(name: &str) -> usize { + match name { + "assert" | "debug_assert" | "prop_assert" => 1, + "assert_eq" | "assert_ne" | "debug_assert_eq" | "debug_assert_ne" | "prop_assert_eq" | "prop_assert_ne" => 2, + _ => 0, + } +} + +/// Blanks `.all(…)` predicates so their checks do not guard the collection. +fn strip_all_predicates(body: &mut [u8]) { + for at in words(body, b"all", 0, body.len()) { + let method = body[..at].trim_ascii_end().ends_with(b"."); + let open = skip_ws(body, at + 3); + let Some(close) = (method && body.get(open) == Some(&b'(')).then(|| matching(body, open)).flatten() else { continue }; + blank(body, at, close + 1); + } +} + +/// Whether test code accesses a first item in a way that fails on an empty collection. +fn first_item_guard(body: &[u8]) -> bool { + let compact = norm(body); + let unwrapped = [".first().unwrap()", ".first().expect(", ".next().unwrap()", ".next().expect("]; + let indexed = compact.match_indices("[0]").any(|(at, _)| !on_array_literal(&compact[..at + 3])); + indexed || unwrapped.iter().any(|g| compact.contains(g)) || panicking_first_binding(body) +} + +/// Whether a `let Some(…) = ….first() else { panic!(…) }` binding checks for an item. +fn panicking_first_binding(body: &[u8]) -> bool { + words(body, b"let", 0, body.len()).into_iter().any(|at| { + let rest = &body[at + 3..]; + let Some(otherwise) = words(rest, b"else", 0, rest.len()).first().copied() else { return false }; + let binding = norm(&rest[..otherwise]); + let Some(close) = binding.strip_prefix("Some(").and_then(|_| matching(binding.as_bytes(), 4)) else { return false }; + let Some(value) = binding[close + 1..].strip_prefix('=') else { return false }; + let first = value.ends_with(".first()") || value.ends_with(".next()"); + first && !value.contains([';', '{', '}']) && norm(&rest[otherwise + 4..]).starts_with("{panic!(") + }) +} + +/// Whether a (masked, whitespace-free) condition holds an `.all(…)` that an empty collection would +/// pass by mistake. Left out: a negated result, a closure that says no item matches (whole +/// negations or `!=` comparisons joined only by `&&`), and a non-empty array literal or a local +/// name bound to or previously compared equal to one. +fn unguarded_all(cond: &str, body: &[u8]) -> bool { + all_with_polarity(cond, true, body) +} + +/// Tracks negation through boolean operands and comparisons with `false`. +fn all_with_polarity(cond: &str, positive: bool, body: &[u8]) -> bool { + if cond.starts_with('(') && matching(cond.as_bytes(), 0) == Some(cond.len() - 1) { + return all_with_polarity(&cond[1..cond.len() - 1], positive, body); + } + if let Some(at) = boolean_split(cond) { + return all_with_polarity(&cond[..at], positive, body) || all_with_polarity(&cond[at + 2..], positive, body); + } + if let Some(expr) = cond.strip_suffix("==false").or_else(|| cond.strip_prefix("false==")) { + return all_with_polarity(expr, !positive, body); + } + if let Some(expr) = cond.strip_prefix('!') { + return all_with_polarity(expr, !positive, body); + } + positive && positive_all(cond, body) +} + +/// Finds a boolean operator outside parentheses, brackets and braces. +fn boolean_split(cond: &str) -> Option { + let b = cond.as_bytes(); + let mut at = 0; + while at < b.len() { + if b[at..].starts_with(b"&&") || b[at..].starts_with(b"||") { + return Some(at); + } + at = if matches!(b[at], b'(' | b'[' | b'{') { matching(b, at)? + 1 } else { at + 1 }; + } + None +} + +fn positive_all(cond: &str, test_body: &[u8]) -> bool { + cond.match_indices(".all(").any(|(i, _)| { + let rest = &cond[i + ".all(".len()..]; + let arg = &rest[..arg_end(rest)]; + let body = arg.strip_prefix('|').and_then(|r| r.split_once('|')).map_or(arg, |(_, body)| body); + let none_match = not_equal_conjunction(body); + !none_match && !on_array_literal(&cond[..i]) && !on_bound_array(&cond[..i], test_body) && !on_equal_array(&cond[..i], test_body) + }) +} + +/// Whether every boolean operand is a whole negation or `!=` comparison joined only by `&&`. +fn not_equal_conjunction(body: &str) -> bool { + if body.starts_with('(') && matching(body.as_bytes(), 0) == Some(body.len() - 1) { + return not_equal_conjunction(&body[1..body.len() - 1]); + } + if let Some(at) = boolean_split(body) { + return body[at..].starts_with("&&") && not_equal_conjunction(&body[..at]) && not_equal_conjunction(&body[at + 2..]); + } + if whole_negation(body) { + return true; + } + let (mut at, mut comparisons) = (0, 0); + let b = body.as_bytes(); + while at < b.len() { + if b[at..].starts_with(b"!=") { + comparisons += 1; + at += 2; + } else if matches!(b[at], b'=' | b'<' | b'>' | b'&' | b'|') { + return false; + } else if matches!(b[at], b'(' | b'[' | b'{') { + let Some(close) = matching(b, at) else { return false }; + at = close + 1; + } else { + at += 1; + } + } + comparisons == 1 +} + +/// Whether `!` negates the whole operand rather than one side of a binary expression. +fn whole_negation(body: &str) -> bool { + let Some(rest) = body.strip_prefix('!') else { return false }; + let rest = rest.trim_start_matches(['!', '*', '&']); + let b = rest.as_bytes(); + let mut at = 0; + while at < b.len() { + if matches!(b[at], b'=' | b'<' | b'>' | b'&' | b'|' | b'+' | b'-' | b'*' | b'/' | b'%' | b'^') { + return false; + } + at = if matches!(b[at], b'(' | b'[' | b'{') { + let Some(close) = matching(b, at) else { return false }; + close + 1 + } else { + at + 1 + }; + } + !rest.is_empty() +} + +/// Whether an earlier equality assertion compares this plain local receiver with a non-empty literal. +fn on_equal_array(receiver: &str, body: &[u8]) -> bool { + let name = array_receiver(receiver); + if name.is_empty() || name.as_bytes()[0].is_ascii_digit() || !name.bytes().all(is_ident) { + return false; + } + macro_calls(body, 0, body.len()).iter().any(|a| { + if !["assert_eq", "debug_assert_eq", "prop_assert_eq"].contains(&a.name.as_str()) { + return false; + } + let Some(&(lf, lt)) = a.args.first() else { return false }; + let Some(&(rf, rt)) = a.args.get(1) else { return false }; + let (left, right) = (norm(&body[lf..lt]), norm(&body[rf..rt])); + (collection_operand(&left) == name && non_empty_literal(&right)) || (collection_operand(&right) == name && non_empty_literal(&left)) + }) +} + +/// Removes one borrow and a slice view from a compared operand. +fn collection_operand(operand: &str) -> &str { + let operand = operand.strip_prefix('&').unwrap_or(operand); + operand.strip_suffix(".as_slice()").or_else(|| operand.strip_suffix("[..]")).unwrap_or(operand) +} + +/// Whether the whole operand is a non-empty array literal or `vec![…]`. +fn non_empty_literal(operand: &str) -> bool { + let b = operand.strip_prefix("vec!").unwrap_or(operand).as_bytes(); + b.first() == Some(&b'[') && matching(b, 0) == Some(b.len() - 1) && non_empty_array(&b[1..b.len() - 1]) +} + +/// The length of a call's arguments in `rest`, the text after its `(`: up to its closing bracket. +fn arg_end(rest: &str) -> usize { + let mut depth = 0i32; + rest.bytes() + .position(|c| { + depth += match c { + b'(' | b'[' | b'{' => 1, + b')' | b']' | b'}' => -1, + _ => 0, + }; + depth < 0 + }) + .unwrap_or(rest.len()) +} + +/// Whether `receiver` (the text before `.all(`) ends with a non-empty array literal, through `.iter()` or +/// `.into_iter()`. +fn on_array_literal(receiver: &str) -> bool { + let r = array_receiver(receiver); + let b = r.as_bytes(); + if b.last() != Some(&b']') { + return false; + } + let mut depth = 0usize; + for (j, &c) in b.iter().enumerate().rev() { + match c { + b']' => depth += 1, + b'[' => { + depth = depth.saturating_sub(1); + if depth == 0 { + let literal = !j.checked_sub(1).and_then(|k| b.get(k)).is_some_and(|&p| is_ident(p) || matches!(p, b')' | b']' | b'.')); + return literal && non_empty_array(&b[j + 1..b.len() - 1]); + } + } + _ => {} + } + } + false +} + +/// Removes the iterator method from an array receiver. +fn array_receiver(receiver: &str) -> &str { + receiver.strip_suffix(".iter()").or_else(|| receiver.strip_suffix(".into_iter()")).unwrap_or(receiver) +} + +/// Whether a plain local receiver's latest preceding binding initializes a non-empty array. +fn on_bound_array(receiver: &str, body: &[u8]) -> bool { + let name = array_receiver(receiver).as_bytes(); + if name.is_empty() || name[0].is_ascii_digit() || !name.iter().copied().all(is_ident) { + return false; + } + words(body, b"let", 0, body.len()).into_iter().rev().find_map(|at| array_binding(&body[at + 3..], name)).unwrap_or(false) +} + +/// Checks a named binding, allowing `mut` and an array type annotation. +fn array_binding(mut rest: &[u8], name: &[u8]) -> Option { + rest = rest.trim_ascii_start(); + if rest.starts_with(b"mut") && rest.get(3).is_some_and(u8::is_ascii_whitespace) { + rest = rest[3..].trim_ascii_start(); + } + let end = rest.iter().copied().take_while(|&c| is_ident(c)).count(); + if &rest[..end] != name { + return None; + } + rest = rest[end..].trim_ascii_start(); + if let Some(annotation) = rest.strip_prefix(b":") { + let annotation = annotation.trim_ascii_start(); + let close = (annotation.first() == Some(&b'[')).then(|| matching(annotation, 0)).flatten(); + let Some(close) = close else { return Some(false) }; + rest = annotation[close + 1..].trim_ascii_start(); + } + Some(rest.strip_prefix(b"=").is_some_and(array_initializer)) +} + +/// Whether an initializer is a non-empty array literal, optionally followed by one `.map(…)`. +fn array_initializer(rest: &[u8]) -> bool { + let rest = rest.trim_ascii_start(); + let Some(close) = (rest.first() == Some(&b'[')).then(|| matching(rest, 0)).flatten() else { return false }; + if !non_empty_array(&rest[1..close]) { + return false; + } + let tail = rest[close + 1..].trim_ascii_start(); + if tail.starts_with(b";") { + return true; + } + let compact = norm(tail); + if !compact.starts_with(".map(") { + return false; + } + let Some(close) = matching(compact.as_bytes(), 4) else { return false }; + compact[close + 1..].starts_with(';') +} + +/// Whether an array's masked contents have an element and, for repetition, a positive literal count. +fn non_empty_array(contents: &[u8]) -> bool { + let mut at = 0; + while at < contents.len() { + match contents[at] { + b';' => return norm(&contents[at + 1..]).parse::().is_ok_and(|count| count > 0), + b'(' | b'[' | b'{' => { + let Some(close) = matching(contents, at) else { return false }; + at = close + 1; + } + _ => at += 1, + } + } + !contents.trim_ascii().is_empty() +} + +/// Whether an assertion's (masked, whitespace-free) condition only says that there is a value. +fn is_weak(cond: &str) -> bool { + let (negated, expr) = match cond.strip_prefix('!') { + Some(rest) => (true, rest), + None => (false, cond), + }; + let plain = |rest: &str| !["&&", "||", "==", "!=", "<", ">"].iter().any(|op| rest.contains(op)); + let suffix = |s: &str| expr.strip_suffix(s).is_some_and(plain); + if negated { + return suffix(".is_empty()"); + } + suffix(".is_ok()") || suffix(".is_some()") || suffix(".len()>0") || suffix(".len()!=0") || suffix(".len()>=1") +} + +fn only_weak(v: &View) -> Option { + let all_weak = v.asserts.iter().all(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && is_weak(&v.first_arg(a))); + let other = contains(v.body(), b"panic!") || contains(v.body(), b".unwrap_err()") || contains(v.body(), b".expect_err("); + if v.asserts.is_empty() || !all_weak || other || v.delegates || v.should_panic { + return None; + } + Some(v.whole(Rule::OnlyWeak, format!("its {} assertion(s) only check is_ok/is_some/non-empty", v.asserts.len()))) +} + +fn self_compare(v: &View) -> Vec { + v.asserts + .iter() + .filter(|a| a.name.ends_with("_eq") || a.name.ends_with("_ne")) + .filter_map(|a| { + let right = *a.args.get(1)?; + let (l, r) = (v.file.src_norm(*a.args.first()?), v.file.src_norm(right)); + let (l, r) = (l.trim_start_matches('&'), r.trim_start_matches('&')); + let calls_with_args = l.replace("()", "").contains(['(', '!']); + (l == r && !l.is_empty() && !calls_with_args).then(|| { + let mut h = v.hit(a.at, Rule::SelfCompare, format!("{}! compares `{l}` with itself", a.name)); + let end = right.0 + v.file.m[right.0..right.1].trim_ascii_end().len(); + h.last = v.file.lines.of(end.saturating_sub(1)); + h + }) + }) + .collect() +} + +fn exit_status_only(v: &View) -> Option { + let mut body = norm(&v.body_without_messages()).into_bytes(); + let runs = contains(&body, b"Command::new") || contains(&body, b".output()") || contains(&body, b".status()"); + strip_stream_configuration(&mut body); + let reads = + ["stdout", "stderr", "fs::read", "read_to_string", "from_slice", "from_str", "contains("].iter().any(|w| contains(&body, w.as_bytes())); + let status_only = |a: &MacroCall| { + a.args.iter().take(guard_arg_count(&a.name)).any(|&(from, to)| { + let c = norm(&v.file.m[from..to]); + c.contains(".success()") || c.contains(".code()") + }) + }; + if !runs || reads || v.asserts.is_empty() || !v.asserts.iter().all(status_only) || v.delegates { + return None; + } + Some(v.whole(Rule::ExitStatusOnly, "runs a process and checks only its exit status".into())) +} + +/// Blanks stream method names that configure a process with `Stdio` in whitespace-free text. +fn strip_stream_configuration(body: &mut [u8]) { + for stream in ["stdout", "stderr", "stdin"] { + for at in words(body, stream.as_bytes(), 0, body.len()) { + let rest = &body[at + stream.len()..]; + let config = rest.starts_with(b"(Stdio::") || rest.starts_with(b"(std::process::Stdio::"); + if body[..at].ends_with(b".") && config { + blank(body, at, at + stream.len()); + } + } + } +} + +fn no_assertion(v: &View) -> Option { + if v.checks || v.delegates || v.should_panic { + return None; + } + Some(v.whole(Rule::NoAssertion, "no assertion and no asserting helper".into())) +} + +/// Guards that mark a skip for a missing resource or another platform, or a test that runs itself +/// in a child process, matched case-sensitively on the guard without whitespace. +const SKIP_GUARDS: &[&str] = &[ + "in_own_process", + "OWN_PROCESS", + "_TEST_CHILD", + "current_exe()", + "skip_without_craft_fonts", + "CRAFT_FONTS", + "japanese_fonts", + "craft_fonts", + "env::var", + "cfg!(", + "target_os", + "geteuid", + "Command::new", + "File::open", + "fs::read", + "read_dir(", + ".exists()", + "which(", +]; + +/// The same, matched without regard to case. +const SKIP_GUARDS_ANY_CASE: &[&str] = &[ + "installed_family", + "kufi", + "library/fonts", + "default_font(", + "arabic_face", + "arabic_test_face", + "devanagari_test_face", + "joiner_test_faces", + "mark_text(", + "arabic_style", + "has_family", + "variable_font", + "fontdb", + ".face(", + "covers(", + "thai", + "cjk", + "corpus", + "suite_dir", + "json2_file", + "read_fixture", + "samples(", + "pinned(", + "platform()", + "is_mac", + "/system/library", +]; + +fn early_returns(v: &View) -> Vec { + let (m, t) = (&v.file.m, v.t); + words(m, b"return", t.open, t.close) + .into_iter() + .filter_map(|at| { + let end = bare_return_end(m, at + "return".len())?; + let rest_empty = m[end..t.close].iter().all(|c| c.is_ascii_whitespace() || matches!(c, b';' | b'}')); + if rest_empty || nested(m, t.open, at) || skip_guard(v.file, t.open, at, end) { + return None; + } + Some(v.hit(at, Rule::EarlyReturn, "returns early on a value from the code under test".into())) + }) + .collect() +} + +/// The end of a bare `return` (`return;`, `return }`, `return Ok(());`) whose keyword ends at `i`. +fn bare_return_end(m: &[u8], i: usize) -> Option { + let mut j = skip_ws(m, i); + if m[j..].starts_with(b"Ok") { + j += 2; + for c in *b"(())" { + j = skip_ws(m, j); + if m.get(j) != Some(&c) { + return None; + } + j += 1; + } + j = skip_ws(m, j); + } + match m.get(j)? { + b';' => Some(j + 1), + b'}' | b',' => Some(j), + _ => None, + } +} + +/// Whether `pos` is inside a closure or a nested function in the body opened at `open`. +fn nested(m: &[u8], open: usize, pos: usize) -> bool { + let mut stack: Vec = vec![]; + for i in open..pos { + match m[i] { + b'{' => stack.push(i > open && opens_closure_or_fn(m, open, i)), + b'}' => { + stack.pop(); + } + _ => {} + } + } + stack.contains(&true) +} + +fn opens_closure_or_fn(m: &[u8], open: usize, brace: usize) -> bool { + let from = brace.saturating_sub(160).max(open + 1); + let head = &m[from..brace]; + let start = head.iter().rposition(|&c| matches!(c, b';' | b'{' | b'}')).map_or(0, |p| p + 1); + let head = String::from_utf8_lossy(&head[start..]).into_owned(); + let head = head.trim_end(); + let closure = head.ends_with('|') || head.rfind("->").is_some_and(|p| head[..p].trim_end().ends_with('|')); + closure || !words(head.as_bytes(), b"fn", 0, head.len()).is_empty() +} + +/// Whether the return at `at..end` is not a silent skip on a value: the block it ends asserts +/// first; a comment or a printed note from the start of its statement to the end of its line says +/// why it returns; or its guard skips for a resource, a platform or a child process. +fn skip_guard(file: &File, open: usize, at: usize, end: usize) -> bool { + let m = &file.m; + let block = m[open..at].iter().rposition(|&c| c == b'{').map_or(open, |p| p + open); + let stmt = m[open..block].iter().rposition(|&c| c == b';' || c == b'}').map_or(open, |p| p + open); + let line_end = find(m, b"\n", end).unwrap_or(m.len()); + let asserted = macro_calls(m, block, at).iter().any(|c| is_assert_macro(&c.name)); + let printed = macro_calls(m, stmt, at).iter().any(|c| c.name.ends_with("print") || c.name.ends_with("println")); + let commented = (stmt..line_end).any(|i| file.src[i..].starts_with(b"//") && m[i] == b' '); + if asserted || printed || commented { + return true; + } + let guard = norm(&file.src[stmt..end]); + let lower = guard.to_ascii_lowercase(); + let wide = &file.src[stmt.saturating_sub(250).max(open)..end]; + SKIP_GUARDS.iter().any(|g| guard.contains(g)) + || SKIP_GUARDS_ANY_CASE.iter().any(|g| lower.contains(g)) + || (lower.contains("fs::write(") && lower.contains(".is_err()")) + || ["in_own_process", "OWN_PROCESS", "_TEST_CHILD", "current_exe()"].iter().any(|g| contains(wide, g.as_bytes())) + || !words(wide, b"CHILD", 0, wide.len()).is_empty() +} + +fn env_gates(v: &View, ctx: &Ctx) -> Vec { + let (m, src, t) = (&v.file.m, v.file.src, v.t); + let mut out = vec![]; + for at in words(m, b"var", t.open, t.close).into_iter().chain(words(m, b"var_os", t.open, t.close)) { + if !m[..at].ends_with(b"env::") { + continue; + } + let Some(name) = env_name(m, src, at) else { continue }; + if ctx.ci_env.contains(&name) || set_by_system(&name) { + continue; + } + // The whole file is masked and searched only for a name that CI and the system leave unset. + let file = norm(&mask_comments(&String::from_utf8_lossy(src))); + let set_here = file.contains(&format!(".env(\"{name}\"")) + || file.contains(&format!("=\"{name}\";")) + || file.match_indices(&format!("set_var(\"{name}\"")).any(|(at, _)| at == 0 || !is_ident(file.as_bytes()[at - 1])); + if !set_here { + out.push(v.hit(at, Rule::EnvGateUnset, format!("reads {name}, which no CI leg sets"))); + } + } + out +} + +/// The literal name in `env::var("NAME")` whose `var` is at `at`. +fn env_name(m: &[u8], src: &[u8], at: usize) -> Option { + let open = skip_ws(m, at + m[at..].iter().take_while(|&&c| is_ident(c)).count()); + if m.get(open) != Some(&b'(') { + return None; + } + let quote = skip_ws(m, open + 1); + if m.get(quote) != Some(&b'"') { + return None; + } + let end = string_end(src, quote + 1).saturating_sub(1); + let name = std::str::from_utf8(&src[quote + 1..end]).ok()?; + (!name.is_empty() && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_')).then(|| name.to_owned()) +} + +fn ignore_hits(file: &File) -> Vec { + let m = &file.m; + let mut out = vec![]; + for at in words(m, b"ignore", 0, m.len()) { + if !m[..at].ends_with(b"#[") { + continue; + } + let j = skip_ws(m, at + "ignore".len()); + let reason = match m.get(j) { + Some(b'=') => { + let q = skip_ws(m, j + 1); + ignore_reason(&file.src[q..]).is_some_and(|body| body.iter().any(|c| !c.is_ascii_whitespace())) + } + _ => false, + }; + if !reason { + let test = file.tests.iter().find(|t| t.fn_at > at).map_or("", |t| t.name.as_str()); + out.push(file.hit(at - 2, Rule::IgnoreWithoutReason, test, "#[ignore] gives no reason".into())); + } + } + out +} + +/// The body of an ordinary or raw string literal used as an ignore reason. +fn ignore_reason(src: &[u8]) -> Option<&[u8]> { + if src.first() == Some(&b'"') { + return src.get(1..string_end(src, 1).saturating_sub(1)); + } + let raw = src.strip_prefix(b"r")?; + let hashes = raw.iter().take_while(|&&c| c == b'#').count(); + if raw.get(hashes) != Some(&b'"') { + return None; + } + let body = hashes + 2; + let close: Vec = std::iter::once(b'"').chain(std::iter::repeat_n(b'#', hashes)).collect(); + let end = find(src, &close, body)?; + src.get(body..end) +} + +fn sleep_hits(file: &File) -> Vec { + let m = &file.m; + words(m, b"sleep", 0, m.len()) + .into_iter() + .filter(|&at| { + if !in_regions(&file.regions, at) { + return false; + } + let before = m[..at].iter().rposition(|c| !c.is_ascii_whitespace()); + let method = before.is_some_and(|b| m[b] == b'.'); + let definition = m[..at].trim_ascii_end().ends_with(b"fn"); + !method && !definition && m.get(skip_ws(m, at + "sleep".len())) == Some(&b'(') + }) + .map(|at| file.hit(at, Rule::Sleep, file.test_at(at), "sleeps in test code".into())) + .collect() +} + +fn reads_source_hits(file: &File) -> Vec { + if SOURCE_AUDITS.contains(&file.path) { + return vec![]; + } + let m = &file.m; + let mut out = vec![]; + for (word, note) in [(&b"include_str"[..], "includes a .rs file as text"), (&b"ends_with"[..], "keeps files ending in .rs")] { + for at in words(m, word, 0, m.len()).into_iter().filter(|&at| in_regions(&file.regions, at)) { + let open = skip_ws(m, at + word.len() + usize::from(m.get(at + word.len()) == Some(&b'!'))); + let Some(close) = (m.get(open) == Some(&b'(')).then(|| matching(m, open)).flatten() else { continue }; + let arg = norm(&file.src[open + 1..close]); + let rs = if word == b"ends_with" { arg == "\".rs\"" } else { arg.ends_with(".rs\"") }; + if rs { + out.push(file.hit(at, Rule::ReadsSource, file.test_at(at), note.into())); + } + } + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + + fn ctx() -> Ctx { + Ctx { helpers: HashMap::new(), ci_env: ["SET_IN_CI".to_owned()].into_iter().collect() } + } + + /// The rule ids of `src`'s hits, as `(line, rule)`. + fn hits(src: &str) -> Vec<(usize, &'static str)> { + hits_in("crates/x/src/tests.rs", src, &ctx()) + } + + fn hits_in(path: &str, src: &str, ctx: &Ctx) -> Vec<(usize, &'static str)> { + lint_file(path, src, ctx).into_iter().map(|h| (h.line, h.rule.id())).collect() + } + + #[test] + fn all_needs_a_non_empty_guard() { + let bad = "#[test]\nfn t() {\n let xs = f();\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(bad), [(4, "all-unguarded")]); + let good = "#[test]\nfn t() {\n let xs = f();\n assert_eq!(xs.len(), 3);\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(good), []); + let inner = "#[test]\nfn t() {\n assert!(rows().iter().all(|r| r.len() == 3));\n}\n"; + assert_eq!(hits(inner), [(3, "all-unguarded")], "a length inside the predicate is about each item"); + let none = "#[test]\nfn t() {\n assert!(warnings().iter().all(|w| !w.contains(\"lost\")), \"no warning\");\n}\n"; + assert_eq!(hits(none), [], "all(|w| !…) says that no item matches"); + let other = "#[test]\nfn t() {\n assert!(listed().iter().all(|e| e[\"id\"] != id));\n assert!([0, 4, 20].iter().all(|&i| glow[i].a() == 0));\n}\n"; + assert_eq!(hits(other), [], "one != comparison, and an array literal"); + let indexed = "#[test]\nfn t() {\n assert!(rows()[2].iter().all(|r| r.ok && r.n != 0));\n assert!(f().iter().all(|x| x.0 != 1 && x.1 != 2));\n}\n"; + assert_eq!(hits(indexed), [(3, "all-unguarded")]); + let mixed = "#[test]\nfn t() {\n assert!(f().iter().all(|x| x.0 != 1 && x.1 > 2));\n}\n"; + assert_eq!(hits(mixed), [(3, "all-unguarded")]); + } + + #[test] + fn all_equality_guards_match_each_receiver() { + for assertion in ["assert_eq", "debug_assert_eq", "prop_assert_eq"] { + for operand in ["xs", "&xs", "xs.as_slice()", "&xs.as_slice()", "xs[..]", "&xs[..]"] { + for literal in ["[1]", "[1, 2,]", "[1; 2]", "vec![1, 2]", "vec![1; 2]", "[\"[;]\", name]"] { + for (left, right) in [(operand, literal), (literal, operand)] { + let src = format!( + "#[test]\nfn t() {{\n {assertion}!({left}, {right}, \"items\");\n assert!(xs.iter().all(|x| valid(x)));\n assert!(ys.iter().all(|x| valid(x)));\n}}\n" + ); + assert_eq!(hits(&src), [(5, "all-unguarded")], "{assertion}!({left}, {right})"); + let combined = src.replace("valid(x)));\n assert!(ys", "valid(x)) && ys"); + assert_eq!(hits(&combined), [(4, "all-unguarded")], "another receiver in the same condition"); + } + } + } + } + } + + #[test] + fn all_equality_guards_require_non_empty_literals() { + for expected in ["[]", "[1; 0]", "vec![]", "vec![1; 0]", "expected", "items()", "[1].map(f)", "vec![1].clone()"] { + let src = format!("#[test]\nfn t() {{\n assert_eq!(xs, {expected});\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{expected}"); + } + for operand in ["ys", "xs_other", "other.xs", "other::xs", "xs()", "xs.clone()", "xs[1..]", "&&xs"] { + let src = format!("#[test]\nfn t() {{\n assert_eq!({operand}, [1]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{operand}"); + } + } + + #[test] + fn all_equality_guards_require_earlier_compared_operands_in_the_test() { + for assertion in ["assert_ne", "debug_assert_ne", "prop_assert_ne"] { + let src = format!("#[test]\nfn t() {{\n {assertion}!(xs, [1]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{assertion}"); + } + let later = "#[test]\nfn t() {\n assert!(xs.iter().all(|x| valid(x)));\n assert_eq!(xs, [1]);\n}\n"; + assert_eq!(hits(later), [(3, "all-unguarded")]); + let outside = "fn helper() { assert_eq!(xs, [1]); }\n#[test]\nfn t() {\n assert!(xs.iter().all(|x| valid(x)));\n}\n"; + assert_eq!(hits(outside), [(4, "all-unguarded")]); + let message = "#[test]\nfn t() {\n assert_eq!(a, b, \"items {:?} {:?}\", xs, [1]);\n assert!(xs.iter().all(|x| valid(x)));\n}\n"; + assert_eq!(hits(message), [(4, "all-unguarded")]); + } + + #[test] + fn all_skips_conjunctions_of_not_equal_comparisons() { + for predicate in [ + "|(id, _)| id != \"action.batch\" && id != \"flattener.preview\"", + "|x| x.0 != 1 && x.1 != 2", + "|x| x != 1 && x != 2 && x != 3", + "|x| (x != 1) && ((x != 2) && x != 3)", + "|x| value(x) != expected(1, 2) && *x != 3", + ] { + let src = format!("#[test]\nfn t() {{\n assert!(names.iter().all({predicate}));\n}}\n"); + assert_eq!(hits(&src), [], "{predicate}"); + let mixed = src.replace("));\n", ") && ys.iter().all(|y| valid(y)));\n"); + assert_eq!(hits(&mixed), [(3, "all-unguarded")], "another positive predicate beside {predicate}"); + } + } + + #[test] + fn all_reports_conjunctions_with_other_predicates() { + for predicate in [ + "|x| x != 1 && x == 2", + "|x| x != 1 && x < 2", + "|x| x.0 != 1 && x.1 > 2", + "|x| x != 1 && valid(x)", + "|x| valid(x) && x != 1", + "|x| x != 1 || x != 2", + "|x| x != 1 && x != 2 || x != 3", + "|x| x != 1 && (x != 2 || x != 3)", + "|x| (x != 1 && x > 2) && x != 3", + "|x| valid(x != 1) && x != 2", + ] { + let src = format!("#[test]\nfn t() {{\n assert!(names.iter().all({predicate}));\n}}\n"); + assert_eq!(hits(&src), [(3, "all-unguarded")], "{predicate}"); + } + } + + #[test] + fn all_skips_only_whole_negations_and_not_equal_conjunctions() { + for predicate in [ + "|x| !x.contains(\"lost\")", + "|x| !blocked!(x)", + "|x| !(blocked(x) && invalid(x))", + "|x| !a(x) && !b(x)", + "|x| !a(x) && x != 1", + "|x| x != 1 && (!a(x) && !(b(x)))", + ] { + let src = format!("#[test]\nfn t() {{\n assert!(xs.iter().all({predicate}));\n}}\n"); + assert_eq!(hits(&src), [], "{predicate}"); + } + for predicate in [ + "|x| !blocked(x) && valid(x)", + "|x| valid(x) && !blocked(x)", + "|x| !a(x) || b(x)", + "|x| !a(x) == b(x)", + "|x| (!a(x) == b(x)) && x != 1", + "|x| !a(x) && (!b(x) || c(x))", + "|x| !a(x) ^ b(x)", + ] { + let src = format!("#[test]\nfn t() {{\n assert!(xs.iter().all({predicate}));\n}}\n"); + assert_eq!(hits(&src), [(3, "all-unguarded")], "{predicate}"); + } + } + + #[test] + fn all_skips_locally_bound_non_empty_arrays() { + for binding in [ + "let xs = [1, 2];", + "let mut xs = [1, 2];", + "let xs: [u8; 2] = [1, 2];", + "let mut xs: [u8; 2] = [1, 2];", + "let xs = [1; 2];", + "let xs = [[1, 2], [3, 4]];", + "let xs = [\"[\", \";\", \"bad ] brackets [\"].map(|s| s.trim());", + "let xs = [1, 2].map(|x| { let pair = [x, x]; pair });", + "let xs /* items */ : [u8; 2] = [1, 2] . map (|x| x + 1);", + ] { + for method in ["iter", "into_iter"] { + let src = format!("#[test]\nfn t() {{\n {binding}\n assert!(xs.{method}().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{binding} through {method}"); + let mixed = src.replace("valid(x)))", "valid(x)) && ys.iter().all(|y| valid(y)))"); + assert_eq!(hits(&mixed), [(4, "all-unguarded")], "another collection beside {binding}"); + } + } + } + + #[test] + fn all_reports_empty_arrays_and_other_initializers() { + for value in [ + "[]", + "[1; 0]", + "[1; 0].map(|x| x + 1)", + "vec![1, 2]", + "items()", + "items().collect()", + "[1, 2].into_iter().collect()", + "[1, 2].map(|x| x + 1).into_iter().collect()", + "[1, 2].map(|x| x + 1).map(|x| x + 1)", + ] { + for binding in [format!("let xs = {value};"), format!("let mut xs = {value};"), format!("let xs: [u8; 0] = {value};")] { + let src = format!("#[test]\nfn t() {{\n {binding}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{binding}"); + } + } + } + + #[test] + fn all_array_bindings_match_only_plain_preceding_local_names() { + for (binding, receiver) in [ + ("let xs_other = [1, 2];", "xs"), + ("let other_xs = [1, 2];", "xs"), + ("let (xs, ys) = ([1, 2], items());", "xs"), + ("let xs = [1, 2]; let xs = items();", "xs"), + ("let xs = [1, 2];", "other.xs"), + ("let xs = [1, 2];", "other::xs"), + ("let xs = [1, 2];", "xs()"), + ] { + let src = format!("#[test]\nfn t() {{\n {binding}\n assert!({receiver}.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{binding} with {receiver}"); + } + let later = "#[test]\nfn t() {\n assert!(xs.iter().all(|x| valid(x)));\n let xs = [1, 2];\n}\n"; + assert_eq!(hits(later), [(3, "all-unguarded")], "a later binding does not initialize the receiver"); + let outside = "fn helper() { let xs = [1, 2]; }\n#[test]\nfn t() {\n assert!(xs.iter().all(|x| valid(x)));\n}\n"; + assert_eq!(hits(outside), [(4, "all-unguarded")], "a binding outside the test does not count"); + } + + #[test] + fn all_direct_array_literals_must_be_non_empty() { + for method in ["iter", "into_iter"] { + for array in ["[]", "[1; 0]", "[items(); 0]", "[1; 0usize]"] { + let src = format!("#[test]\nfn t() {{\n assert!({array}.{method}().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(3, "all-unguarded")], "{array} through {method}"); + } + for array in ["[1]", "[1, 2]", "[1; 2]", "[[1; 0]]", "[\"[;]\"]"] { + let src = format!("#[test]\nfn t() {{\n assert!({array}.{method}().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{array} through {method}"); + } + } + } + + #[test] + fn all_skips_mapped_arrays_of_named_rectangles() { + for (name, labels, message) in [ + ("chips", "[\"Color (, or Shift+,)\", \"Gradient (. or Shift+.)\", \"None (/)\"]", "one line"), + ("modes", "[\"Draw Normal (Shift+D)\", \"Draw Behind (Shift+D)\", \"Draw Inside (Shift+D)\"]", "side by side"), + ] { + let src = format!( + "#[test]\nfn t() {{\n let {name} = {labels}.map(|label| named_rect(&nodes, label));\n assert!({name}.iter().all(|r| (r.top() - {name}[0].top()).abs() < 0.5), \"{message}: {{{name}:?}}\");\n}}\n" + ); + assert_eq!(hits(&src), [], "{name}"); + let empty = src.replace(labels, "[]"); + assert_eq!(hits(&empty), [(4, "all-unguarded")], "an empty {name} still passes vacuously"); + } + } + + #[test] + fn all_respects_condition_polarity() { + for condition in [ + "!xs.iter().all(|x| *x > 0)", + "!(xs.iter().all(|x| *x > 0))", + "ready() && !xs.iter().all(|x| *x > 0)", + "!xs.iter().all(|x| *x > 0) && ready()", + "xs.iter().all(|x| *x > 0) == false", + "ready() && (xs.iter().all(|x| *x > 0) == false)", + "false == xs.iter().all(|x| *x > 0)", + ] { + let good = format!("#[test]\nfn t() {{\n assert!({condition});\n}}\n"); + assert_eq!(hits(&good), [], "{condition}"); + let bad = format!("#[test]\nfn t() {{\n assert!(({condition}) && ys.iter().all(|y| *y > 0));\n}}\n"); + assert_eq!(hits(&bad), [(3, "all-unguarded")], "a positive operand beside {condition}"); + } + } + + #[test] + fn all_reports_positive_boolean_operands() { + for condition in [ + "xs.iter().all(|x| *x > 0)", + "ready() && xs.iter().all(|x| *x > 0)", + "xs.iter().all(|x| *x > 0) && ready()", + "ready() || xs.iter().all(|x| *x > 0)", + "xs.iter().all(|x| *x > 0) || ready()", + "!!xs.iter().all(|x| *x > 0)", + "!xs.iter().all(|x| *x > 0) == false", + "!(xs.iter().all(|x| *x > 0) == false)", + ] { + let bad = format!("#[test]\nfn t() {{\n assert!({condition});\n}}\n"); + assert_eq!(hits(&bad), [(3, "all-unguarded")], "{condition}"); + let good = bad.replace(" assert!", " assert_eq!(xs.len(), 3);\n assert!"); + assert_eq!(hits(&good), [], "a length check guards {condition}"); + } + } + + #[test] + fn all_guards_use_assertion_operands_and_skip_messages() { + for name in ["assert", "debug_assert", "prop_assert"] { + let good = format!("#[test]\nfn t() {{\n {name}!(xs.len() > 0);\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&good), [], "{name} condition"); + let bad = format!("#[test]\nfn t() {{\n {name}!(ready(), \"length {{}}\", xs.len());\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&bad), [(4, "all-unguarded")], "{name} message"); + } + for name in ["assert_eq", "assert_ne", "debug_assert_eq", "debug_assert_ne", "prop_assert_eq", "prop_assert_ne"] { + for (left, right) in [("xs.len()", "3"), ("3", "xs.len()")] { + let good = format!("#[test]\nfn t() {{\n {name}!({left}, {right});\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&good), [], "{name} operands"); + } + let bad = format!("#[test]\nfn t() {{\n {name}!(a, b, \"length {{}}\", xs.len());\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&bad), [(4, "all-unguarded")], "{name} message"); + } + } + + #[test] + fn all_guards_require_checks_of_collection_properties() { + for expr in ["xs.len()", "xs.is_empty()", "xs.iter().count()", "xs.first()", "xs.iter().any(|x| *x > 0)", "xs.iter().next()", "xs.last()"] { + let bad = format!("#[test]\nfn t() {{\n let _ = {expr};\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&bad), [(4, "all-unguarded")], "unused {expr}"); + let good = format!("#[test]\nfn t() {{\n assert_eq!({expr}, expected);\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&good), [], "checked {expr}"); + } + } + + #[test] + fn all_guards_accept_first_item_access_that_fails_when_empty() { + for expr in ["xs[0]", "xs.first().unwrap()", "xs.first().expect(\"item\")", "xs.iter().next().unwrap()", "xs.iter().next().expect(\"item\")"] + { + let good = format!("#[test]\nfn t() {{\n let _ = {expr};\n assert!(xs.iter().all(|x| *x > 0));\n}}\n"); + assert_eq!(hits(&good), [], "{expr} fails when empty"); + let inner = format!("#[test]\nfn t() {{\n assert!(xs.iter().all(|x| {expr} > 0));\n}}\n"); + assert_eq!(hits(&inner), [(3, "all-unguarded")], "{expr} inside the predicate"); + let message = format!("#[test]\nfn t() {{\n assert!(xs.iter().all(|x| *x > 0), \"item {{:?}}\", {expr});\n}}\n"); + assert_eq!(hits(&message), [(3, "all-unguarded")], "{expr} inside the message"); + } + let literal = "#[test]\nfn t() {\n let _ = [0];\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(literal), [(4, "all-unguarded")], "an array literal does not access an item"); + } + + #[test] + fn all_guards_accept_panicking_first_item_bindings() { + let good = "#[test]\nfn t() {\n let Some(x) = xs.first() else { panic!(\"empty\") };\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(good), []); + let bad = "#[test]\nfn t() {\n let Some(x) = xs.first() else { skip(); };\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(bad), [(4, "all-unguarded")]); + } + + #[test] + fn all_hits_count_changes_anywhere_in_their_test() { + let src = "#[should_panic]\n#[test]\nfn t() {\n let xs = f();\n assert!(xs.iter().all(|x| *x > 0));\n}\nfn other() {}\n"; + let found = lint_file("crates/x/src/tests.rs", src, &ctx()); + assert_eq!(found.len(), 1); + assert_eq!(found[0].line, 5); + let guarded = src.replace(" assert!(xs.iter()", " assert!(!xs.is_empty());\n assert!(xs.iter()"); + assert_eq!(hits(&guarded), [], "the guard prevents the finding before deletion"); + for line in [1, 2, 3, 4, 5, 6] { + assert!(touches(&found[0], Some(&[line].into_iter().collect())), "test line {line}"); + } + assert!(!touches(&found[0], Some(&[7].into_iter().collect())), "another function is outside the test"); + let diff = "diff --git a/crates/x/src/tests.rs b/crates/x/src/tests.rs\n--- a/crates/x/src/tests.rs\n+++ b/crates/x/src/tests.rs\n@@ -5 +4,0 @@\n- assert!(!xs.is_empty());\n"; + let changed = parse_diff(diff); + assert!(touches(&found[0], changed["crates/x/src/tests.rs"].as_ref()), "removing a guard changes the test"); + } + + #[test] + fn all_allow_comments_stay_near_the_finding() { + let distant = "#[test]\nfn t() {\n // test-lint: allow all-unguarded empty input is allowed\n let xs = f();\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(distant), [(5, "all-unguarded")]); + let adjacent = "#[test]\nfn t() {\n let xs = f();\n // test-lint: allow all-unguarded empty input is allowed\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(adjacent), []); + let same = "#[test]\nfn t() {\n assert!(xs.iter().all(|x| *x > 0)); // test-lint: allow all-unguarded empty input is allowed\n}\n"; + assert_eq!(hits(same), []); + } + + #[test] + fn only_weak_checks_are_reported_once_per_test() { + let bad = "#[test]\nfn t() {\n assert!(parse(\"a\").is_ok());\n assert!(!list().is_empty());\n}\n"; + assert_eq!(hits(bad), [(2, "only-weak")]); + let good = "#[test]\nfn t() {\n assert!(parse(\"a\").is_ok());\n assert_eq!(parse(\"a\").unwrap(), 1);\n}\n"; + assert_eq!(hits(good), []); + let refusal = "#[test]\nfn t() {\n assert!(parse(\"\").is_err());\n}\n"; + assert_eq!(hits(refusal), [], "is_err is not on the plan's list"); + let compound = "#[test]\nfn t() {\n assert!(a.is_some() && a == Some(2));\n}\n"; + assert_eq!(hits(compound), []); + } + + #[test] + fn self_compare_needs_the_same_plain_expression() { + let bad = "#[test]\nfn t() {\n let x = f();\n assert_eq!(x.len(), x.len());\n assert_eq!(&x, x);\n}\n"; + assert_eq!(hits(bad), [(4, "self-compare"), (5, "self-compare")]); + let good = "#[test]\nfn t() {\n assert_eq!(write(&doc), write(&doc), \"deterministic\");\n assert_eq!(f(\"a\"), f(\"b\"));\n assert_ne!(\"a b\", \"ab\");\n assert_ne!(x /* one */, x.y);\n assert_ne!(' ', ':');\n}\n"; + assert_eq!(hits(good), [], "literal text, including its spaces, is compared"); + } + + #[test] + fn self_compare_counts_changes_through_the_second_operand() { + let src = "#[test]\nfn t() {\n assert_eq!(\n actual,\n actual,\n \"comparison\"\n );\n}\n"; + let found = lint_file("crates/x/src/tests.rs", src, &ctx()); + assert_eq!(found.len(), 1); + let hit = &found[0]; + assert_eq!(hit.rule, Rule::SelfCompare); + assert_eq!((hit.line, hit.first, hit.last), (3, 3, 5)); + for line in [3, 4, 5] { + assert!(touches(hit, Some(&[line].into_iter().collect())), "changed line {line}"); + } + for line in [2, 6, 7] { + assert!(!touches(hit, Some(&[line].into_iter().collect())), "changed line {line}"); + } + assert_eq!(hits(&src.replacen(" actual,", " expected,", 1)), []); + } + + #[test] + fn self_compare_keeps_exemptions_near_the_macro_opening() { + let src = "#[test]\nfn t() {\n assert_eq!( // MARKER\n actual, // OPERAND\n actual\n );\n}\n"; + let allow = "test-lint: allow self-compare checks the lint"; + assert_eq!(hits(&src.replace("MARKER", allow)), []); + assert_eq!(hits(&src.replace(" assert_eq!", &format!(" // {allow}\n assert_eq!"))), []); + assert_eq!(hits(&src.replace("OPERAND", allow)), [(3, "self-compare")]); + } + + #[test] + fn a_process_test_must_read_its_output() { + let bad = "#[test]\nfn t() {\n let out = Command::new(bin()).arg(\"x\").output().unwrap();\n assert!(out.status.success());\n}\n"; + assert_eq!(hits(bad), [(2, "exit-status-only")]); + let good = "#[test]\nfn t() {\n let out = Command::new(bin()).output().unwrap();\n assert!(out.status.success());\n assert_eq!(out.stdout, b\"ok\\n\");\n}\n"; + assert_eq!(hits(good), []); + } + + #[test] + fn process_status_checks_accept_every_comparison_assertion() { + for name in ["assert_eq", "assert_ne", "debug_assert_eq", "debug_assert_ne", "prop_assert_eq", "prop_assert_ne"] { + let bad = format!( + "#[test]\nfn t() {{\n let out = Command::new(bin()).output().unwrap();\n {name}!(out.status.code(), Some(0), \"{{:?}}\", out.stderr);\n}}\n" + ); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{name}"); + let good = bad.replace("Some(0)", "parse_code(&out.stdout)"); + assert_eq!(hits(&good), [], "{name} reads output in its second operand"); + } + } + + #[test] + fn process_status_checks_accept_either_compared_operand() { + for name in ["assert_eq", "assert_ne", "debug_assert_eq", "debug_assert_ne", "prop_assert_eq", "prop_assert_ne"] { + for (expected, status) in [("Some(0)", "out.status.code()"), ("true", "out.status.success()")] { + let bad = format!( + "#[test]\nfn t() {{\n let out = Command::new(bin()).output().unwrap();\n {name}!({expected}, {status}, \"{{:?}}\", out.stdout);\n}}\n" + ); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{name} with {status} on the right"); + let good = bad.replace(expected, "parse_status(&out.stderr)"); + assert_eq!(hits(&good), [], "{name} reads output in its first operand"); + let message = bad.replace(status, "expected_status"); + assert_eq!(hits(&message), [], "{name} has no status check in its operands"); + } + } + } + + #[test] + fn process_output_in_failure_messages_does_not_count_as_reading() { + for assertion in ["assert!(out.status.success()", "debug_assert!(out.status.success()", "prop_assert!(out.status.success()"] { + let bad = + format!("#[test]\nfn t() {{\n let out = Command::new(bin()).output().unwrap();\n {assertion}, \"{{:?}}\", out.stderr);\n}}\n"); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{assertion}"); + let good = bad.replace("out.status.success()", "out.status.success() && out.stdout == expected"); + assert_eq!(hits(&good), [], "output in the condition of {assertion}"); + } + for assertion in ["assert_eq", "assert_ne"] { + let bad = format!( + "#[test]\nfn t() {{\n let out = Command::new(bin()).output().unwrap();\n {assertion}!(out.status.code(), f::(), \"{{:?}}\", out.stderr);\n}}\n" + ); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{assertion}"); + let good = bad.replace("f::()", "from_slice(&out.stdout)"); + assert_eq!(hits(&good), [], "output in the second operand of {assertion}"); + } + } + + #[test] + fn stream_configuration_does_not_count_as_reading_output() { + for stream in ["stdout", "stderr", "stdin"] { + let bad = format!( + "#[test]\nfn t() {{\n let out = Command::new(bin()).{stream}(Stdio::piped()).output().unwrap();\n assert!(out.status.success());\n}}\n" + ); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{stream} configuration"); + let good = bad.replace(" assert!", " let _ = out.stderr;\n assert!"); + assert_eq!(hits(&good), [], "reading a field after {stream} configuration"); + } + let bad = "#[test]\nfn t() {\n let out = Command::new(bin()).stdout (std::process::Stdio::piped()).output().unwrap();\n assert!(out.status.success());\n}\n"; + assert_eq!(hits(bad), [(2, "exit-status-only")]); + let good = bad.replace("std::process::Stdio::piped()", "output.stdout"); + assert_eq!(hits(&good), [], "a field read in a builder argument counts"); + } + + #[test] + fn output_inspection_counts_outside_failure_messages() { + for read in [ + "out.stdout", + "out.stderr", + "String::from_utf8(out.stdout)", + "fs::read(path)", + "read_to_string(path)", + "from_slice(data)", + "from_str(text)", + "text.contains(needle)", + ] { + let bad = format!( + "#[test]\nfn t() {{\n let out = Command::new(bin()).output().unwrap();\n assert!(out.status.success(), \"{{:?}}\", {read});\n}}\n" + ); + assert_eq!(hits(&bad), [(2, "exit-status-only")], "{read} in a message"); + let good = bad.replace(" assert!", &format!(" let _ = {read};\n assert!")); + assert_eq!(hits(&good), [], "{read} outside a message"); + } + } + + #[test] + fn failure_messages_are_removed_for_every_standard_assertion() { + for name in [ + "assert", + "debug_assert", + "prop_assert", + "assert_eq", + "assert_ne", + "debug_assert_eq", + "debug_assert_ne", + "prop_assert_eq", + "prop_assert_ne", + ] { + let operands = if guard_arg_count(name) == 1 { "true" } else { "left, right" }; + let bad = format!("#[test]\nfn t() {{\n assert!(xs.iter().all(|x| *x > 0));\n {name}!({operands}, \"{{:?}}\", xs[0]);\n}}\n"); + assert_eq!(hits(&bad), [(3, "all-unguarded")], "{name} message"); + let good = bad.replace(" assert!", " let _ = xs[0];\n assert!"); + assert_eq!(hits(&good), [], "access outside the {name} message"); + } + } + + #[test] + fn assertion_arguments_keep_turbofish_groups_and_split_comparisons() { + for operand in ["f::()", "f::>()", "f :: ()"] { + let src = format!("{operand}, expected, message"); + let m = mask(&src); + let args: Vec<&str> = split_args(&m, 0, m.len()).into_iter().map(|(from, to)| src[from..to].trim()).collect(); + assert_eq!(args, [operand, "expected", "message"], "{operand}"); + let comparison = format!("a < b, {operand} > c, message"); + let m = mask(&comparison); + let args: Vec<&str> = split_args(&m, 0, m.len()).into_iter().map(|(from, to)| comparison[from..to].trim()).collect(); + assert_eq!(args, ["a < b", &format!("{operand} > c"), "message"], "comparisons around {operand}"); + } + } + + #[test] + fn a_test_needs_an_assertion_or_an_asserting_helper() { + let bad = "#[test]\nfn t() {\n let d = open(\"x\").unwrap();\n d.save();\n}\n"; + assert_eq!(hits(bad), [(2, "no-assertion")]); + let panics = "fn f() {}\n/// Panics.\n#[should_panic(expected = \"x\")]\n#[test]\nfn p() {\n f();\n}\n"; + assert_eq!(hits(panics), [], "#[should_panic] before #[test]"); + let src = "fn same(a: u8, b: u8) {\n assert_eq!(a, b);\n}\nfn twice(a: u8) {\n same(a, a);\n}\n#[test]\nfn t() {\n twice(f());\n}\n#[test]\n#[should_panic]\nfn p() {\n f();\n}\n#[test]\nfn q() {\n check_round_trip(f());\n}\n"; + let helpers = asserting_helpers(&[("crates/x/tests/it.rs".to_owned(), src.to_owned())]); + assert!(helpers["crates/x"].contains("twice"), "{helpers:?}"); + let ctx = Ctx { helpers, ci_env: HashSet::new() }; + assert_eq!(hits_in("crates/x/tests/it.rs", src, &ctx), []); + assert_eq!(hits_in("crates/y/tests/it.rs", src, &ctx), [(8, "no-assertion")], "another crate's helper does not count"); + let kit = asserting_helpers(&[("crates/testkit/src/lib.rs".to_owned(), src.to_owned()), ("crates/y/src/lib.rs".to_owned(), String::new())]); + assert!(kit["crates/y"].contains("twice"), "testkit helpers count in every crate: {kit:?}"); + assert_eq!(hits_in("crates/x/tests/it.rs", src, &Ctx { helpers: HashMap::new(), ci_env: HashSet::new() }), [(8, "no-assertion")]); + } + + #[test] + fn generic_asserting_calls_count_for_functions_and_methods() { + for call in ["check_round_trip::()", "check_round_trip::>(x)", "value.check::()", "value.check :: >> ()"] { + let src = format!("#[test]\nfn t() {{\n {call};\n}}\n"); + assert_eq!(hits(&src), [], "{call}"); + } + for expression in ["check_round_trip::", "value.check::", "round_trip::()", "value.round_trip::()"] { + let src = format!("#[test]\nfn t() {{\n let _ = {expression};\n}}\n"); + assert_eq!(hits(&src), [(2, "no-assertion")], "{expression}"); + } + } + + #[test] + fn generic_crate_helpers_count_through_other_helpers() { + let defs = "fn same(a: T, b: T) { assert_eq!(a, b); }\nfn twice(a: T) { same::(a, a); }\nfn idle() {}\n"; + let helpers = asserting_helpers(&[("crates/x/tests/helpers.rs".to_owned(), defs.to_owned())]); + assert!(helpers["crates/x"].contains("same")); + assert!(helpers["crates/x"].contains("twice")); + assert!(!helpers["crates/x"].contains("idle")); + let ctx = Ctx { helpers, ci_env: HashSet::new() }; + for call in ["same::(a, b)", "twice::>>(x)"] { + let src = format!("#[test]\nfn t() {{\n {call};\n}}\n"); + assert_eq!(hits_in("crates/x/tests/it.rs", &src, &ctx), [], "{call}"); + assert_eq!(hits_in("crates/y/tests/it.rs", &src, &ctx), [(2, "no-assertion")], "{call} in another crate"); + } + for expression in ["idle::()", "same::", "value.same::()"] { + let src = format!("#[test]\nfn t() {{\n let _ = {expression};\n}}\n"); + assert_eq!(hits_in("crates/x/tests/it.rs", &src, &ctx), [(2, "no-assertion")], "{expression}"); + } + } + + #[test] + fn early_returns_on_values_are_reported_and_resource_skips_are_not() { + let bad = "#[test]\nfn t() {\n let Some(n) = find() else { return };\n assert_eq!(n, 2);\n}\n"; + assert_eq!(hits(bad), [(3, "early-return")]); + let fonts = "#[test]\nfn t() {\n let Some(face) = installed_family(\"Kufi\") else { return; };\n assert_eq!(face.n, 2);\n}\n"; + assert_eq!(hits(fonts), []); + let closure = "#[test]\nfn t() {\n let f = |x: u8| { if x == 0 { return; } g(x) };\n assert_eq!(f(1), ());\n}\n"; + assert_eq!(hits(closure), []); + let last = "#[test]\nfn t() {\n assert_eq!(f(), 1);\n if g() { return; }\n}\n"; + assert_eq!(hits(last), []); + let value = "#[test]\nfn t() -> Result<(), String> {\n if f()? == 0 { return Ok(()); }\n assert_eq!(g(), 1);\n Ok(())\n}\n"; + assert_eq!(hits(value), [(3, "early-return")]); + let checked = "#[test]\nfn t() {\n for _ in 0..9 {\n if g() == 1 {\n assert_eq!(f(), 2);\n return;\n }\n }\n panic!(\"never stable\");\n}\n"; + assert_eq!(hits(checked), [], "a return after an assertion in its block"); + let said = "#[test]\nfn t() {\n if !link(\"a\") {\n eprintln!(\"skipped: no links here\");\n return;\n }\n assert_eq!(f(), 2);\n}\n"; + assert_eq!(hits(said), [], "a return after a printed skip note"); + let commented = "#[test]\nfn t() {\n let Some(w) = width() else { return }; // no wide font here\n assert_eq!(w, 2);\n}\n"; + assert_eq!(hits(commented), [], "a return whose line says why"); + let quiet = "#[test]\nfn t() {\n if !link(\"a\") {\n return;\n }\n assert_eq!(f(), 2);\n}\n"; + assert_eq!(hits(quiet), [(4, "early-return")]); + } + + #[test] + fn ignore_needs_a_reason() { + let bad = "#[test]\n#[ignore]\nfn t() {\n assert_eq!(f(), 1);\n}\n#[ignore = \" \"]\n#[test]\nfn u() {\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(bad), [(2, "ignore-without-reason"), (6, "ignore-without-reason")]); + let good = "#[test]\n#[ignore = \"a benchmark: run with --ignored\"]\nfn t() {\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(good), []); + } + + #[test] + fn ignore_accepts_non_empty_raw_string_reasons() { + for hashes in ["", "#", "##", "########"] { + for reason in ["requires an external service", " service ", r"service \ path"] { + let literal = format!("r{hashes}\"{reason}\"{hashes}"); + let src = format!("#[test]\n#[ignore = {literal}]\nfn t() {{ assert_eq!(f(), 1); }}\n"); + assert_eq!(hits(&src), [], "{literal}"); + } + for reason in ["", " ", "\t\n"] { + let literal = format!("r{hashes}\"{reason}\"{hashes}"); + let src = format!("#[test]\n#[ignore = {literal}]\nfn t() {{ assert_eq!(f(), 1); }}\n"); + assert_eq!(hits(&src), [(2, "ignore-without-reason")], "{literal}"); + } + } + } + + #[test] + fn env_gates_need_a_variable_ci_sets() { + let bad = "#[test]\nfn t() {\n let Ok(dir) = std::env::var(\"MY_SAMPLES\") else { return };\n assert_eq!(count(&dir), 3);\n}\n"; + assert_eq!(hits(bad), [(3, "env-gate-unset")]); + let ci = "#[test]\nfn t() {\n if std::env::var(\"SET_IN_CI\").is_ok() { assert_eq!(f(), 1); }\n assert_eq!(std::env::var(\"CARGO_PKG_NAME\").unwrap(), \"x\");\n}\n"; + assert_eq!(hits(ci), []); + let child = "const CHILD: &str = \"X_TEST_CHILD\";\n#[test]\nfn t() {\n if std::env::var_os(\"X_TEST_CHILD\").is_some() { assert_eq!(f(), 1); }\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(child), []); + } + + #[test] + fn env_gates_ignore_commented_out_setters() { + for setter in ["cmd.env(\"MY_SAMPLES\", dir);", "std::env::set_var(\"MY_SAMPLES\", \"x\");", "const X: &str = \"MY_SAMPLES\";"] { + for comment in [format!("// {setter}"), format!("/* {setter} */"), format!("/* outer /* {setter} */ end */")] { + let src = + format!("{comment}\n#[test]\nfn t() {{\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(dir, expected);\n}}\n"); + assert_eq!(hits(&src), [(4, "env-gate-unset")], "{comment}"); + } + } + } + + #[test] + fn env_gates_keep_code_setters_and_literal_contents() { + for setter in [ + "cmd . env ( \"MY_SAMPLES\", dir);", + "std::env::set_var ( \"MY_SAMPLES\", \"x\");", + "set_var(\"MY_SAMPLES\", \"x\");", + "use std::env::set_var; fn setup() { set_var(\"MY_SAMPLES\", \"x\"); }", + "cmd.set_var(\"MY_SAMPLES\", \"x\");", + "const X: &str = \"MY_SAMPLES\";", + "cmd.env(/* name */ \"MY_SAMPLES\", dir);", + ] { + let src = format!("{setter}\n#[test]\nfn t() {{\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(dir, expected);\n}}\n"); + assert_eq!(hits(&src), [], "{setter}"); + assert_eq!(hits(&src.replacen("MY_SAMPLES", "OTHER_SAMPLES", 1)), [(4, "env-gate-unset")], "{setter}"); + } + let src = "let a = \"https://host/*path*/\"; /* removed */ let b = r#\"// kept /* kept */\"#; // removed\nlet c = '/';"; + let masked = String::from_utf8(mask_comments(src)).unwrap(); + assert!(masked.contains("\"https://host/*path*/\"")); + assert!(masked.contains("r#\"// kept /* kept */\"#")); + assert!(masked.contains("let c = '/';")); + assert!(!masked.contains("removed")); + } + + #[test] + fn env_gates_require_setter_call_boundaries() { + for reader in [ + "read_env(\"MY_SAMPLES\");", + "cmd.read_env(\"MY_SAMPLES\");", + "env(\"MY_SAMPLES\", dir);", + "my_set_var(\"MY_SAMPLES\", \"x\");", + "std::env::my_set_var(\"MY_SAMPLES\", \"x\");", + "cmd.my_set_var(\"MY_SAMPLES\", \"x\");", + ] { + let src = format!("{reader}\n#[test]\nfn t() {{\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(dir, expected);\n}}\n"); + assert_eq!(hits(&src), [(4, "env-gate-unset")], "{reader}"); + } + } + + #[test] + fn sleep_in_test_code_is_reported() { + let bad = "fn wait() {\n std::thread::sleep(Duration::from_millis(5));\n}\n#[test]\nfn t() {\n thread::sleep(D);\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(bad), [(2, "sleep"), (6, "sleep")]); + let good = "fn sleep(d: D) {}\n#[test]\nfn t() {\n run(\"$.sleep(250)\");\n clock.sleep(D);\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(good), []); + let shipped = "pub fn wait() {\n std::thread::sleep(D);\n}\n#[cfg(test)]\nmod tests {}\n"; + assert_eq!(hits_in("crates/x/src/lib.rs", shipped, &ctx()), [], "code before #[cfg(test)] is not test code"); + assert_eq!(hits_in("xtask/src/test_lint.rs", shipped, &ctx()), [], "a name that only starts with test is not a test file"); + let after = "#[cfg(test)]\nmod tests {\n fn w() { thread::sleep(D); }\n}\npub fn later() {\n thread::sleep(D);\n}\n"; + assert_eq!(hits_in("crates/x/src/lib.rs", after, &ctx()), [(3, "sleep")], "code after a #[cfg(test)] module is not test code"); + for test_file in [ + "crates/x/src/tests.rs", + "crates/x/src/tests_wheel.rs", + "crates/x/src/widget_tests.rs", + "crates/x/tests/it/a.rs", + "crates/testkit/src/lib.rs", + ] { + assert_eq!(hits_in(test_file, shipped, &ctx()), [(2, "sleep")], "{test_file}"); + } + } + + #[test] + fn reading_rust_source_is_reported_outside_the_audits() { + let bad = "#[test]\nfn t() {\n let src = include_str!(\"../lib.rs\");\n assert_eq!(src.matches(\"x\").count(), 1);\n}\n"; + assert_eq!(hits(bad), [(3, "reads-source")]); + let walk = "#[test]\nfn t() {\n let n = files().filter(|p| p.ends_with(\".rs\")).count();\n assert_eq!(n, 4);\n}\n"; + assert_eq!(hits(walk), [(3, "reads-source")]); + assert_eq!(hits_in(SOURCE_AUDITS[0], bad, &ctx()), []); + let data = "#[test]\nfn t() {\n let s = include_str!(\"fixtures/a.svg\");\n assert_eq!(s.len(), 4);\n}\n"; + assert_eq!(hits(data), []); + } + + #[test] + fn allow_comments_need_the_rule_and_a_reason() { + let src = "#[test]\nfn t() {\n // test-lint: allow sleep the file clock has a 2 ms step\n thread::sleep(D);\n thread::sleep(D); // test-lint: allow sleep same\n assert_eq!(f(), 1);\n thread::sleep(D); // test-lint: allow sleep\n thread::sleep(D); // test-lint: allow early-return wrong rule\n}\n// test-lint: allow no-assertion a smoke test of the panic-free reader\n#[test]\nfn u() {\n let _ = read(b\"junk\");\n}\n"; + assert_eq!(hits(src), [(7, "sleep"), (8, "sleep")], "an allow covers its own line and the next, and needs a reason"); + let strings = "#[test]\nfn t() {\n let s = \"test-lint: allow sleep in a string\"; thread::sleep(D);\n let r = r#\"test-lint: allow sleep raw\"#; thread::sleep(D);\n /* test-lint: allow sleep a block comment */ thread::sleep(D);\n assert_eq!(s, r);\n}\n"; + assert_eq!(hits(strings), [(3, "sleep"), (4, "sleep")], "a marker in a literal is not an exemption"); + } + + #[test] + fn comments_and_strings_are_not_code() { + let src = "#[test]\nfn t() {\n // assert!(x.iter().all(|y| y))\n let s = \"thread::sleep(d); #[ignore]\";\n let r = r#\"env::var(\"NOPE\")\"#;\n let c = '\"';\n assert_eq!(s, r);\n}\n"; + assert_eq!(hits(src), []); + } + + #[test] + fn tests_are_found_by_their_attributes() { + let src = "#[cfg(test)]\nmod tests {\n #[tokio::test]\n async fn a() {}\n #[test_case(1)]\n fn b(n: u8) {}\n proptest! {\n #[test]\n fn c(x in 0..9u8) {}\n }\n #[test]\n fn d() -> Result<(), String> { Ok(()) }\n fn not_a_test() {}\n}\n"; + let names: Vec = tests_in(&mask(src)).into_iter().map(|t| t.name).collect(); + assert_eq!(names, ["a", "b", "c", "d"]); + } + + #[test] + fn changed_lines_come_from_the_new_side_of_each_hunk() { + let diff = "diff --git a/crates/x/src/a.rs b/crates/x/src/a.rs\nindex 1..2 100644\n--- a/crates/x/src/a.rs\n+++ b/crates/x/src/a.rs\n@@ -3,0 +4,2 @@ fn f() {\n+a\n+b\n@@ -10 +12 @@\n-c\n+d\n@@ -20,2 +21,0 @@\n-e\ndiff --git a/crates/x/src/n.rs b/crates/x/src/n.rs\nnew file mode 100644\n--- /dev/null\n+++ b/crates/x/src/n.rs\n@@ -0,0 +1,3 @@\n"; + let got = parse_diff(diff); + assert_eq!(got.len(), 2); + assert_eq!(got["crates/x/src/a.rs"], Some([4, 5, 12, 21, 22].into_iter().collect())); + assert_eq!(got["crates/x/src/n.rs"], None); + } + + #[test] + fn deleting_the_first_attribute_changes_the_remaining_test() { + let path = "crates/x/src/tests.rs"; + for (prefix, anchor) in [("", 0), ("fn before() {}\n", 1)] { + let src = format!("{prefix}#[test]\nfn t() {{}}\n#[test]\nfn other() {{}}\n"); + let before = src.replacen("#[test]", "#[should_panic]\n#[test]", 1); + assert!(lint_file(path, &before, &ctx()).iter().all(|h| h.test != "t"), "the attribute prevents the finding"); + let found = lint_file(path, &src, &ctx()); + assert_eq!(found.len(), 2); + let old = anchor + 1; + let diff = format!("diff --git a/{path} b/{path}\n--- a/{path}\n+++ b/{path}\n@@ -{old} +{anchor},0 @@\n-#[should_panic]\n"); + let changed = parse_diff(&diff); + let expected = if anchor == 0 { vec![1] } else { vec![anchor, anchor + 1] }; + assert_eq!(changed[path], Some(expected.into_iter().collect())); + assert_eq!(found[0].rule, Rule::NoAssertion); + assert_eq!(found[0].test, "t"); + assert!(touches(&found[0], changed[path].as_ref()), "the deletion changes the remaining test"); + assert!(!touches(&found[1], changed[path].as_ref()), "the following test is unchanged"); + } + } + + #[test] + fn only_hits_on_changed_lines_count() { + let src = "#[test]\nfn old() {\n f();\n}\n#[test]\nfn new() {\n g();\n}\n"; + let found = lint_file("crates/x/src/tests.rs", src, &ctx()); + assert_eq!(found.len(), 2); + let changed: BTreeSet = [7].into_iter().collect(); + let counted: Vec<&str> = found.iter().filter(|h| touches(h, Some(&changed))).map(|h| h.test.as_str()).collect(); + assert_eq!(counted, ["new"]); + assert_eq!(found.iter().filter(|h| touches(h, None)).count(), 2); + assert_eq!(found.iter().filter(|h| touches(h, Some(&BTreeSet::new()))).count(), 0); + } + + #[test] + fn options_reject_unknown_and_repeated_arguments() { + assert_eq!(Options::parse(&[]), Ok(Options::default())); + assert_eq!(Options::parse(&["--base", "abc"]), Ok(Options { all: false, base: Some("abc".into()) })); + assert_eq!(Options::parse(&["--all"]), Ok(Options { all: true, base: None })); + for bad in [&["--base"][..], &["--base", "--all"], &["--all", "--all"], &["--fix"], &["--all", "--base", "x"]] { + assert!(Options::parse(bad).unwrap_err().starts_with("test-lint:"), "{bad:?}"); + } + } + + #[test] + fn workflow_variables_count_as_set() { + let names: Vec = upper_words("env:\n AFFINITY_CORPUS_REQUIRED: 1\n run: X=1 cargo test # A\n").collect(); + assert_eq!(names, ["AFFINITY_CORPUS_REQUIRED"]); + assert!(set_by_system("CARGO_MANIFEST_DIR") && set_by_system("HOME") && !set_by_system("MY_SAMPLES")); + } + + #[test] + fn workflow_mapping_keys_count_without_reads_or_comments() { + let assigned: Vec = upper_words("env:\n MY_SAMPLES: fixtures\n - OTHER_SAMPLES: fixtures\n EMPTY_SAMPLES:\n").collect(); + assert_eq!(assigned, ["MY_SAMPLES", "OTHER_SAMPLES", "EMPTY_SAMPLES"]); + let reads = "# MY_SAMPLES: fixtures\nif: env.MY_SAMPLES != ''\nrun: echo $OTHER_SAMPLES ${EMPTY_SAMPLES}\nvalue: ${{ env.MY_SAMPLES }}\n"; + assert_eq!(upper_words(reads).collect::>(), Vec::::new()); + } + + #[test] + fn workflow_script_assignments_count_without_reads_or_comments() { + for assignment in [ + " MY_SAMPLES=value", + " export MY_SAMPLES=value", + " run: MY_SAMPLES=value cargo test", + " echo \"MY_SAMPLES=value\" >> \"$GITHUB_ENV\"", + " echo 'MY_SAMPLES=value' >> \"$GITHUB_ENV\"", + " MY_SAMPLES=value # OTHER_SAMPLES=value", + " MY_SAMPLES=\"#value\"", + " MY_SAMPLES=", + " - MY_SAMPLES=value", + ] { + assert_eq!(upper_words(assignment).collect::>(), ["MY_SAMPLES"], "{assignment}"); + let commented = format!("# {assignment}"); + assert_eq!(upper_words(&commented).collect::>(), Vec::::new(), "{commented}"); + } + let reads = "env.MY_SAMPLES=value\n${{ env.MY_SAMPLES }}\n$MY_SAMPLES\n${MY_SAMPLES}\nMY_SAMPLES==value\n"; + assert_eq!(upper_words(reads).collect::>(), Vec::::new()); + } + + #[test] + fn workflow_mentions_do_not_suppress_unset_gates() { + let src = "#[test]\nfn t() {\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(f(dir), 3);\n}\n"; + for workflow in ["if: env.MY_SAMPLES != ''", "run: echo $MY_SAMPLES", "# MY_SAMPLES=value"] { + let ctx = Ctx { helpers: HashMap::new(), ci_env: upper_words(workflow).collect() }; + assert_eq!(hits_in("crates/x/src/tests.rs", src, &ctx), [(3, "env-gate-unset")], "{workflow}"); + } + for workflow in ["env:\n MY_SAMPLES: fixtures", "run: |\n export MY_SAMPLES=fixtures", "with:\n env: |\n MY_SAMPLES=fixtures"] { + let ctx = Ctx { helpers: HashMap::new(), ci_env: upper_words(workflow).collect() }; + assert_eq!(hits_in("crates/x/src/tests.rs", src, &ctx), [], "{workflow}"); + } + } +} From 847e407ab69f3fbad7fa11230b1e6997bd0ad8da Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:16:39 +0100 Subject: [PATCH 206/264] Honor pre-refactor window preferences and preserve Hand placement clicks --- apps/vectorcraft/src/main.rs | 15 +++++++++++---- crates/ui-egui/src/canvas/tool_adapter.rs | 4 ++-- crates/ui-egui/src/state.rs | 13 +++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 3971de013b..6ab6778597 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -114,8 +114,8 @@ const MIN_SIZE: [f32; 2] = [800.0, 500.0]; /// Apply the saved main-window placement before the first frame. On a first launch the /// framework maximizes the window when its default size would not fit the current screen. -fn restore_main_window(window: &winit::window::Window, store: &Store, wayland: bool) { - use craft::behavior::placement::{Defaults, place}; +fn restore_main_window(window: &winit::window::Window, store: &Store, legacy: Option, wayland: bool) { + use craft::behavior::placement::{Defaults, Placement, place}; use craft::behavior::{Monitor, MonitorKey}; use winit::dpi::{LogicalSize, PhysicalPosition}; @@ -131,7 +131,14 @@ fn restore_main_window(window: &winit::window::Window, store: &Store, wayland: b .collect(); let home = window.current_monitor().or_else(|| window.primary_monitor()).and_then(|monitor| handles.iter().position(|m| *m == monitor)); let defaults = Defaults::new(DEFAULT_SIZE, MIN_SIZE).with_no_position(wayland); - let placement = place(store.get(craft::window::restore::MAIN).as_ref(), &monitors, home, &defaults); + let saved = store.get(craft::window::restore::MAIN).or_else(|| { + let old = legacy?; + let mut placement = Placement::new(old.size, window.scale_factor() as f32); + placement.position_px = old.pos; + placement.maximized = old.maximized; + placement.repaired() + }); + let placement = place(saved.as_ref(), &monitors, home, &defaults); if let Some([x, y]) = placement.position_px { window.set_outer_position(PhysicalPosition::new(x, y)); } @@ -813,7 +820,7 @@ fn main() -> std::process::ExitCode { let winit_window = cc.winit_window().cloned(); let placement = placement_store(); if let Some(window) = &winit_window { - restore_main_window(window, &placement, wayland); + restore_main_window(window, &placement, settings.lock().get().ui.legacy_window, wayland); } let spec = InstallSpec::new(shell_info, Arc::new(SystemWindows)) .app_id(vectorcraft_ui_egui::os_window::app_id()) diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 031e2875b6..6ebdd54af4 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -650,12 +650,12 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too let mut picked = ToolHostResponse::default(); let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) { picked - } else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 { + } else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 && app.ui.rearrange_placement.is_none() { let options = crate::app::view::navigation(&app.session.prefs); let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options)); hand.options = options; let response = host_run(app, ui, pass, &mut hand); - if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down()) { + if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down() || i.pointer.primary_pressed()) { crate::shortcuts::note_tool_use(app); } app.canvas.hand = Some(hand); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 5ac49daeb9..eeef403f06 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -490,6 +490,15 @@ pub struct ContextSpelling { pub suggestions: Vec, } +/// The main window as saved in the UI preferences through 0.24.1. Positions are desktop pixels. +#[derive(Clone, Copy, Debug, Deserialize)] +pub struct LegacyWindow { + pub pos: Option<[i32; 2]>, + pub size: [f32; 2], + #[serde(default)] + pub maximized: bool, +} + /// Two states are equal when they save the same: the settings store writes only a changed saved form, /// and the panels' session state is no change to save. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -500,6 +509,9 @@ pub struct UiState { /// it is never written back. #[serde(rename = "language", skip_serializing)] pub legacy_language: Option, + /// Used until the shared window store has recorded the main window. + #[serde(rename = "window", skip_serializing)] + pub legacy_window: Option, pub brightness: Brightness, /// The panel arrangement: docks, floating windows, closed panels and where each goes back. One /// `Arc` the dock area keeps across frames; writers change it through `Arc::make_mut`. @@ -1448,6 +1460,7 @@ impl Default for UiState { fn default() -> Self { Self { legacy_language: None, + legacy_window: None, brightness: Brightness::MediumDark, dock_workspace: std::sync::Arc::new(crate::panel_docking::default_workspace(&[])), tools_last_used: Default::default(), From f677523787f00ad35282422242e369c860aeb6c0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:23:37 -0800 Subject: [PATCH 207/264] Menus: the keymap test counts only runs the catalogs held still through A font, plug-in, script or proof setup change from a test running alongside rebuilds the menus, so the test now holds the fonts and plug-ins steady and runs again on a new app, at most 20 times, until the catalogs held still, as the Selection move test in canvas/tests.rs does. --- crates/ui-egui/src/menus/model.rs | 70 +++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 3095b74794..ced219084f 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -743,7 +743,9 @@ mod tests { /// A new window keymap with nothing else changed (the framework builds the first one after the first frame's /// menus) sets the panel rows' shortcuts from it, in the bar and in the laid-out bar, without building the menus - /// again. + /// again. The menus are also built again when a process-wide catalog changes, so the fonts and plug-ins are held + /// steady against tests running alongside, and the steps run again on a new app, at most 20 times, until the + /// other catalogs held still through them. #[test] fn a_new_keymap_alone_sets_the_shortcuts_without_a_rebuild() { fn clear(nodes: &mut [Node]) { @@ -761,28 +763,52 @@ mod tests { .filter(|it| it.command.id == "window.panel" && it.command.params["toggle"] == true && it.shortcut.is_some()) .count() } - let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); - app.run("file.new", json!({})).unwrap(); - let ctx = crate::testing::ui_context(); - for _ in 0..2 { - crate::testing::app_frame(&mut app, &ctx, egui::RawInput::default()); - } - let shown = panel_chords(&app.menus.bar); + let fonts = vectorcraft_text::FontDb::global(); + let _steady = (vectorcraft_text::test_fonts::steady_fonts(fonts), vectorcraft_plugins::steady::steady_plugins()); + let catalogs = || { + ( + crate::menus::plugin_revision(), + fonts.generation(), + fonts.installed_fonts_ready(), + crate::scripts_menu::revision(), + crate::dialogs::proof_setup::saved_revision(), + ) + }; + let run = || { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({})).unwrap(); + let ctx = crate::testing::ui_context(); + for _ in 0..2 { + crate::testing::app_frame(&mut app, &ctx, egui::RawInput::default()); + } + let shown = panel_chords(&app.menus.bar); + // The menus as a refresh before the window's keymap leaves them. + app.menus.keymap = None; + for menu in &mut app.menus.bar.menus { + clear(&mut menu.children); + } + app.menus.laid.edit(|laid| laid.menus.iter_mut().for_each(|menu| clear(&mut menu.children))); + let (rebuilds, refreshes) = (app.menus.rebuilds, app.menus.shortcut_refreshes); + refresh(&mut app, &ctx); + let first = (app.menus.rebuilds - rebuilds, app.menus.shortcut_refreshes - refreshes); + let chords = (panel_chords(&app.menus.bar), panel_chords(&app.menus.laid)); + refresh(&mut app, &ctx); + let second = (app.menus.rebuilds - rebuilds, app.menus.shortcut_refreshes - refreshes); + (shown, first, chords, second) + }; + let (shown, first, chords, second) = (0..20) + .find_map(|_| { + let before = catalogs(); + let out = run(); + (catalogs() == before).then_some(out) + }) + .unwrap_or_else(|| panic!("tests running alongside kept changing the font and plug-in catalogs")); assert!(shown > 0, "the panel rows show their shortcuts' chords"); - // The menus as a refresh before the window's keymap leaves them. - app.menus.keymap = None; - for menu in &mut app.menus.bar.menus { - clear(&mut menu.children); - } - app.menus.laid.edit(|laid| laid.menus.iter_mut().for_each(|menu| clear(&mut menu.children))); - let (rebuilds, refreshes) = (app.menus.rebuilds, app.menus.shortcut_refreshes); - refresh(&mut app, &ctx); - assert_eq!(app.menus.rebuilds, rebuilds, "a new keymap alone does not build the menus again"); - assert_eq!(app.menus.shortcut_refreshes, refreshes + 1, "the new keymap sets the shortcuts"); - assert_eq!(panel_chords(&app.menus.bar), shown, "the panel rows show their chords again"); - assert_eq!(panel_chords(&app.menus.laid), shown, "the laid-out bar shows them too"); - refresh(&mut app, &ctx); - assert_eq!((app.menus.rebuilds, app.menus.shortcut_refreshes), (rebuilds, refreshes + 1), "the same keymap sets nothing again"); + assert_eq!(first.0, 0, "a new keymap alone does not build the menus again"); + assert_eq!(first.1, 1, "the new keymap sets the shortcuts"); + assert_eq!(chords.0, shown, "the panel rows show their chords again"); + assert_eq!(chords.1, shown, "the laid-out bar shows them too"); + assert_eq!(second, (0, 1), "the same keymap sets nothing again"); } /// A rebuild runs the check of a command that many rows share once: Effect's dialogs, Window's panels, the From 04ced9bee734f216ee55ac13316932b5e501184c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:33:26 -0800 Subject: [PATCH 208/264] Performance: the check of a moved selection reads the objects at their places After a move, the check that a view can move the selection's marks instead of building them again looked each moved object up by id three times: the object, its parent's id and the parent. With 10,000 objects selected that was 30,000 lookups after the edit. The check now keeps each object's place from the transform and reads the object and its parent there, so the move looks each object up once, as before. --- crates/engine/src/cmd/object/transform.rs | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index c3ce0107f0..4212588f1b 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -200,7 +200,7 @@ fn apply_transform_moving_guides( // A move of whole objects, not of copies (which `reindex` covers): the document before it, // and the moved objects as the transform left them, for [`moved_by`] to check after the edit. let from = (objects && !areas && !reindex && c[..4] == [1.0, 0.0, 0.0, 1.0]).then(|| s.doc().map(|st| st.doc.clone())).transpose()?; - let mut held: Vec<(NodeId, Arc)> = vec![]; + let mut held: Vec<(Vec, Arc)> = vec![]; let targets = s.edit(label, |d, sel| { let mut targets = match &kept { // The document becomes the snapshot with the kept copies, untransformed, and the @@ -240,7 +240,7 @@ fn apply_transform_moving_guides( } // Holding them makes any later change to them copy them first, which `moved_by` sees. if from.is_some() { - held = targets.iter().filter_map(|id| Some((*id, node_arc(d, paths.get(id)?)?))).collect(); + held = targets.iter().filter_map(|id| paths.get(id)).filter_map(|p| Some((p.clone(), node_arc(d, p)?))).collect(); } if objects { // The transforms above leave every object at its place, so `paths` still holds them. @@ -294,20 +294,22 @@ fn node_arc(d: &Document, path: &[usize]) -> Option> { } /// The [`crate::Moved`] of a move by `by` that took `from` to the document of `st`, given the moved -/// objects as the transform left them (`held`). `None` unless every moved object is still that -/// node, none is a member of a blend (whose spine follows its members), and every object the -/// selection shows, the key object and the key anchor's object included, is a moved object or -/// inside one. A pass after the transform that changes a moved object, such as the one that snaps -/// moved pixel-aligned objects to the pixel grid again ([`super::pixelgrid::refresh`]), copies it -/// first, so it is no longer that node. -fn moved_by(from: &Arc, st: &crate::DocState, held: &[(NodeId, Arc)], by: Vec2) -> Option { +/// objects as the transform left them (`held`, each with its index path). `None` unless every moved +/// object is still that node at its path, none is a member of a blend (whose spine follows its +/// members), and every object the selection shows, the key object and the key anchor's object +/// included, is a moved object or inside one. A pass after the transform that changes a moved +/// object, such as the one that snaps moved pixel-aligned objects to the pixel grid again +/// ([`super::pixelgrid::refresh`]), copies it first, so it is no longer that node. The checks read +/// the nodes at their paths and look nothing up by id. +fn moved_by(from: &Arc, st: &crate::DocState, held: &[(Vec, Arc)], by: Vec2) -> Option { let d = &st.doc; - let unchanged = |(id, n): &(NodeId, Arc)| d.node(*id).is_some_and(|now| std::ptr::eq(now, Arc::as_ptr(n))); + let unchanged = |(p, n): &(Vec, Arc)| d.node_at(p).is_some_and(|now| std::ptr::eq(now, Arc::as_ptr(n))); if held.is_empty() || !held.iter().all(unchanged) { return None; } - let in_blend = |id: NodeId| d.parent_of(id).and_then(|p| d.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Blend { .. })); - if held.iter().any(|(id, _)| in_blend(*id)) { + // The node at each path is the moved object, so its parent is the node one level up. + let in_blend = |p: &[usize]| p.split_last().and_then(|(_, up)| d.node_at(up)).is_some_and(|parent| matches!(parent.kind, NodeKind::Blend { .. })); + if held.iter().any(|(p, _)| in_blend(p)) { return None; } let mut moved = std::collections::HashSet::new(); From f4c911d4d34f9b10071fd050dbc14ab665a61fb9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:36:01 -0800 Subject: [PATCH 209/264] Scripts: open options with an importer, null export options and close checks for files that keep every artboard - document.open refuses page, cropTo, pages and crop when a named importer reads the file (linkPages still uses the built-in reader). - exportFile with explicit null options throws a TypeError for GIF, PNG8 and TIFF too. - close(SaveOptions.SAVECHANGES) saves a modern .ai or .ait file and an SVG file with Preserve Editing whatever range was remembered; a range the save refuses still refuses. - The script checker keeps a try statement's catch and finally, and an else after a nested do-while, inside the loop body; a line break after a label does not start a new statement; a this assignment in a function that hides a global clears the global's saved methods; and holder.d['saveAs'] = ... no longer counts as a write to d. - docs/mcp.md describes which files keep every artboard on close. --- crates/engine/src/cmd/fileio.rs | 2 +- crates/engine/src/cmd/fileio/load.rs | 13 +++++- crates/engine/src/cmd/fileio/svg.rs | 9 +++- crates/engine/src/script/dom/save_open.rs | 31 ++++++++++--- crates/engine/src/tests/script_save_open.rs | 39 ++++++++++++++++ crates/engine/tests/plugin_import.rs | 27 +++++++++++ crates/scriptcheck/src/analyze.rs | 19 +++++++- crates/scriptcheck/src/analyze/declared.rs | 33 +++++++++++--- crates/scriptcheck/src/analyze/features.rs | 11 ++--- crates/scriptcheck/src/tests.rs | 50 +++++++++++++++++++++ docs/mcp.md | 7 ++- 11 files changed, 215 insertions(+), 26 deletions(-) diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 21424f7bdc..38654bb8ba 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -125,7 +125,7 @@ pub use screens::{ builtin_presets as screen_export_builtin_presets, first_file as screen_first_file, preset_list as screen_export_preset_list, preset_rows as screen_preset_rows, }; -pub(crate) use svg::lost_artboards_warning as svg_lost_artboards_warning; +pub(crate) use svg::{lost_artboards_warning as svg_lost_artboards_warning, preserves_editing as svg_preserves_editing}; /// Does a save in `format` (a format id) with options `p` write a legacy version 7 `.ai` file, /// which holds the artboards its own options pick? An unknown version counts as one. diff --git a/crates/engine/src/cmd/fileio/load.rs b/crates/engine/src/cmd/fileio/load.rs index e426bd5a23..cce50485dd 100644 --- a/crates/engine/src/cmd/fileio/load.rs +++ b/crates/engine/src/cmd/fileio/load.rs @@ -1096,8 +1096,17 @@ pub(super) fn open(s: &mut Session, p: &Value) -> Result { source(p, "document.open")? } }; - if crate::file_access::in_script_command() && ["page", "cropTo"].iter().any(|k| p.get(*k).is_some_and(|v| !v.is_null())) { - let pdf = detect(src.name, &src.bytes).is_some_and(|f| matches!(f.id, "pdf" | "ai" | "ait")) && !vectorcraft_pdf::is_postscript(&src.bytes); + let given = |keys: &[&str]| keys.iter().any(|k| p.get(*k).is_some_and(|v| !v.is_null())); + let (options, aliases) = (given(&["page", "cropTo"]), given(&["pages", "crop"])); + if crate::file_access::in_script_command() && (options || aliases) { + // An importer plug-in receives only the params, so it cannot apply the pages or the crop + // box; `linkPages` reads the file with the built-in reader before any importer. + let link_pages = p.get("linkPages").and_then(Value::as_bool) == Some(true); + let built_in = link_pages || super::importer::pick(src.name, &src.bytes, p)?.is_none(); + let pdf = built_in + && (!options + || (detect(src.name, &src.bytes).is_some_and(|f| matches!(f.id, "pdf" | "ai" | "ait")) + && !vectorcraft_pdf::is_postscript(&src.bytes))); if !pdf { return Err(bad("document.open", "PDF open options require a PDF file")); } diff --git a/crates/engine/src/cmd/fileio/svg.rs b/crates/engine/src/cmd/fileio/svg.rs index e5ecc858dc..ac66cb8e65 100644 --- a/crates/engine/src/cmd/fileio/svg.rs +++ b/crates/engine/src/cmd/fileio/svg.rs @@ -174,12 +174,17 @@ pub(super) fn drawn<'a>(doc: &'a Document, p: &Value) -> Option Option { let n = doc.artboards.len(); - let preserved = plan(doc, p).is_ok_and(|(opts, ..)| opts.preserve_editing); - (n > 1 && !preserved).then(|| { + (n > 1 && !preserves_editing(doc, p)).then(|| { format!("{label} keeps 1 of the document's {n} artboards: the file reopens with one. Turn on Preserve Editing Capabilities to keep them all.") }) } +/// Whether a save of `doc` as SVG with options `p` (flat or nested in `svg`) embeds the native +/// document (Preserve Editing Capabilities), which keeps every artboard. +pub(crate) fn preserves_editing(doc: &Document, p: &Value) -> bool { + plan(doc, p).is_ok_and(|(opts, ..)| opts.preserve_editing) +} + /// The native document Preserve Editing embeds: `doc`, without an Export for Screens `folder` /// outside the read roots of the request being served (the open document keeps it). fn native_attachment(doc: &Document) -> Vec { diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index 09c438040c..060454798a 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -767,6 +767,7 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer { }, Some(o) => match kind.options { Some(class) => options_params(class, o)?, + None if matches!(o, Data::Null) => return Err(HostError::Type("the options must be an object".into())), None => return Err(HostError::Error(format!("options for {} are not available yet", kind.format))), }, }; @@ -946,21 +947,37 @@ fn picks_artboards(st: &crate::doc_state::DocState) -> bool { return false; } let options = Value::Object(crate::cmd::fileio::remembered_save_options(st)); - if matches!(st.format, "svg" | "svgz") && crate::cmd::fileio::svg_lost_artboards_warning(&st.doc, &options, st.format).is_some() { + let svg = matches!(st.format, "svg" | "svgz"); + if svg && crate::cmd::fileio::svg_lost_artboards_warning(&st.doc, &options, st.format).is_some() { return true; } if st.format == "pdf" && options.get("useArtboards") == Some(&Value::Bool(false)) { return true; } - if matches!(st.format, "vectorcraft" | "template" | "ai" | "ait") - && options.get("separateArtboards") == Some(&Value::Bool(true)) - && !crate::cmd::fileio::saves_legacy_ai(st.format, &options) - { + let legacy = crate::cmd::fileio::saves_legacy_ai(st.format, &options); + if matches!(st.format, "vectorcraft" | "template" | "ai" | "ait") && options.get("separateArtboards") == Some(&Value::Bool(true)) && !legacy { return false; } let count = st.doc.artboards.len(); - let pick = serde_json::from_value::(options); - match pick.map_err(|e| e.to_string()).and_then(|p| p.resolve(count)) { + // A `.ai` file other than a legacy one saves with `range` "all" (a `range` that isn't text is + // left for the save to refuse). + let modern_ai = matches!(st.format, "ai" | "ait") && !legacy; + let mut effective = options.clone(); + if let (true, Value::Object(o)) = (modern_ai, &mut effective) + && o.get("range").is_none_or(|r| r.is_string() || r.is_null()) + { + o.insert("range".into(), json!("all")); + } + let resolved = serde_json::from_value::(effective).map_err(|e| e.to_string()).and_then(|p| p.resolve(count)); + // Such a `.ai` file, and an SVG file that carries the native document, keep every artboard; + // a pick the save refuses still refuses (an SVG save with `useArtboards: false` reads no pick). + if modern_ai { + return resolved.is_err(); + } + if svg && crate::cmd::fileio::svg_preserves_editing(&st.doc, &options) { + return options.get("useArtboards") != Some(&Value::Bool(false)) && resolved.is_err(); + } + match resolved { Ok(None) => false, Ok(Some(indices)) => (0..count).any(|i| !indices.contains(&i)), Err(_) => true, diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 68183e8637..064ff3c15a 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -763,6 +763,10 @@ fn explicit_crop_box_opens_the_bleed_outside_an_editable_files_trim_box() { let trim = s.active().unwrap().doc.artboards[0].rect; logged(&mut s, &base, &format!("Folder.userData; app.open(new File({path}), undefined, {{pDFCropToBox: PDFBoxType.PDFCROPBOX}});")); let crop = s.active().unwrap().doc.artboards[0].rect; + // Without the embedded document and without a crop box, the file opens at its trim box too. + s.execute("document.open", &json!({"path": file.to_string_lossy(), "editingData": false})).unwrap(); + let implicit = s.active().unwrap().doc.artboards[0].rect; + assert_eq!((implicit.width(), implicit.height()), (trim.width(), trim.height()), "{extension}"); assert_eq!((default.width(), default.height()), (trim.width(), trim.height()), "{extension}"); assert!(crop.width() > trim.width() && crop.height() > trim.height(), "{extension}"); } @@ -845,6 +849,9 @@ fn explicit_null_options_do_not_save_export_open_or_close() { for call in [ format!("app.activeDocument.saveAs({f}, null);"), format!("app.activeDocument.exportFile({f}, ExportType.SVG, null);"), + format!("app.activeDocument.exportFile({f}, ExportType.GIF, null);"), + format!("app.activeDocument.exportFile({f}, ExportType.PNG8, null);"), + format!("app.activeDocument.exportFile({f}, ExportType.TIFF, null);"), format!("app.open({f}, null);"), format!("app.open({f}, undefined, null);"), "app.activeDocument.close(null);".into(), @@ -1074,6 +1081,38 @@ fn closing_with_save_changes_checks_the_artboards_the_file_keeps() { let _ = std::fs::remove_dir_all(base); } +/// A `.ai` file saved without separate artboard files, and an SVG file that carries the native +/// document, keep every artboard whatever `range` names, so `close(SaveOptions.SAVECHANGES)` saves +/// them; a `range` the save refuses still refuses. +#[test] +fn closing_with_save_changes_saves_files_that_keep_every_artboard() { + let base = folder("closekeepall"); + let dir = { + let mut s = session(&base); + data_folder(&mut s, &base) + }; + for (name, options) in [("whole.ai", json!({"range": "2"})), ("native.svg", json!({"preserveEditing": true, "range": "1"}))] { + let mut s = session(&base); + data_folder(&mut s, &base); + let file = dir.join(name); + s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap(); + let mut save = options.clone(); + save["path"] = json!(file.to_string_lossy()); + s.execute("document.save", &save).unwrap(); + let before = std::fs::read(&file).unwrap(); + logged( + &mut s, + &base, + "Folder.userData; vc.run('shape.rectangle', {x: 10, y: 10, width: 5, height: 5}); app.activeDocument.close(SaveOptions.SAVECHANGES);", + ); + assert!(s.documents().is_empty(), "{name}"); + assert_ne!(std::fs::read(&file).unwrap(), before, "{name}"); + s.execute("document.open", &json!({"path": file.to_string_lossy()})).unwrap(); + assert_eq!(s.active().unwrap().doc.artboards.len(), 2, "{name} keeps both artboards"); + } + let _ = std::fs::remove_dir_all(base); +} + #[test] fn closing_with_save_changes_keeps_all_eps_artboards_for_subset_ranges() { let base = folder("closeepsboards"); diff --git a/crates/engine/tests/plugin_import.rs b/crates/engine/tests/plugin_import.rs index 1327e57208..9f77d86ec4 100644 --- a/crates/engine/tests/plugin_import.rs +++ b/crates/engine/tests/plugin_import.rs @@ -121,6 +121,33 @@ fn scripted_open_converts_importer_output_to_the_requested_color_space() { let _ = std::fs::remove_dir_all(dir); } +/// A script's PDF open options are refused for a file the named importer reads, which is given +/// only the params, even when the file's extension is a PDF one. +#[test] +fn scripted_pdf_open_options_are_refused_for_an_importer() { + let mut s = Session::new(); + install(&mut s, &tpl::returning(&tpl::importer("test.scriptpdfoptions", r#"["ai"]"#, "{}"), RECT)); + let dir = tmp_dir("scriptpdfoptions"); + s.attach_script_data(dir.join("settings/Script Data")); + let file = dir.join("x.ai"); + std::fs::write(&file, b"importer input").unwrap(); + let script = dir.join("main.jsx"); + let path = serde_json::to_string(&file.to_string_lossy()).unwrap(); + for option in ["page: 1", "cropTo: 'media'", "pages: '1'", "crop: 'media'"] { + std::fs::write( + &script, + format!("Folder.userData; vc.run('document.open', {{path: {path}, importer: 'plugin.test.scriptpdfoptions', {option}}});"), + ) + .unwrap(); + let count = s.documents().len(); + let out = s.execute("script.run", &json!({"path": script.to_string_lossy()})); + let text = format!("{out:?}"); + assert!(text.contains("PDF open options require a PDF file"), "{option}: {text}"); + assert_eq!(s.documents().len(), count, "{option}"); + } + let _ = std::fs::remove_dir_all(dir); +} + #[test] fn an_importer_adds_a_read_only_format_while_it_is_installed() { let mut s = Session::new(); diff --git a/crates/scriptcheck/src/analyze.rs b/crates/scriptcheck/src/analyze.rs index a66b20ef06..a88d7fd04e 100644 --- a/crates/scriptcheck/src/analyze.rs +++ b/crates/scriptcheck/src/analyze.rs @@ -619,6 +619,8 @@ struct Analyzer<'s, 'a, 'l> { file: Option<&'a str>, /// The four significant tokens before this one, the latest first. h: [Option>; 4], + /// The significant token before the four of [`Self::h`]. + h4: Option>, brackets: Brackets, /// Nesting too deep to follow was reported: it is reported once. deep: bool, @@ -723,6 +725,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { acc, file, h: [None; 4], + h4: None, brackets: Brackets::default(), deep: false, active: None, @@ -853,6 +856,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.features(&t); self.newer(&t); self.module_check(&t); + self.h4 = self.h[3]; self.h = [Some(t), self.h[0], self.h[1], self.h[2]]; } @@ -1401,7 +1405,9 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { let body = self.scopes.last().map_or(0, |s| s.depth); let starts = before.is_none() || [";", "{", "}"].iter().any(|p| is(before, p)) - || (declaration.is_some_and(|d| d.nl) && !is(before, ")") && !word(before, "else") && !word(before, "do")); + // A line break after a label's `:` does not end the statement the label may be + // the body of (`if (c) l:` before the line). + || (declaration.is_some_and(|d| d.nl) && !is(before, ")") && !is(before, ":") && !word(before, "else") && !word(before, "do")); let whole = word(declaration, "var") && starts && depth.checked_sub(1) == Some(body); if self.objects.len() < self.acc.limits.nesting { self.objects.push(ObjectValue { name: a.name, depth, bits: 0, whole, value: None }); @@ -1483,6 +1489,16 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { } } + /// The global variable `name` is assigned as a property of `this`: as [`Self::reassigned_later`], + /// and when a function body's own variable hides it, the global's methods saved for the body's + /// end are no longer known either. + pub(super) fn reassigned_global(&mut self, name: &str) { + self.reassigned_later(name); + if let Some(saved) = self.scopes.iter_mut().find_map(|s| s.saved.get_mut(name)) { + saved.writer = 0; + } + } + /// Whether `name` is declared in the innermost function body (`var name`, `function /// name`, a parameter). fn declared_in_body(&self, name: &str) -> bool { @@ -1736,6 +1752,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { self.var_depth = None; self.conds.clear(); self.h = [None; 4]; + self.h4 = None; self.acc.steps = self.acc.steps.saturating_add(1); let d = directives::parse(t.text); let Some(name) = d.known else { diff --git a/crates/scriptcheck/src/analyze/declared.rs b/crates/scriptcheck/src/analyze/declared.rs index 03ad43ab10..ca4ac99823 100644 --- a/crates/scriptcheck/src/analyze/declared.rs +++ b/crates/scriptcheck/src/analyze/declared.rs @@ -163,6 +163,9 @@ enum Stage { Head, /// The parentheses after the `while` of a `do` loop. DoHead, + /// The `)` of a `do` loop's `while` was read: the loop ends with the `;` after it, or before the + /// next token. + DoEnd, /// The body's first token is next. Start, /// A body in braces. @@ -170,7 +173,7 @@ enum Stage { /// A body that is one statement without braces. Statement, /// The statement of a body without braces has reached its end: the loop ends at the next token, - /// unless it is `else`, which goes on with the statement. + /// unless it is `else`, `catch` or `finally`, which go on with the statement. Tail, } @@ -274,7 +277,7 @@ impl<'s> Declarations<'s, '_, '_> { /// at it, and `for`, `while` and `do` start a loop. Past [`crate::Limits::nesting`] loops, any /// variable may be assigned in one ([`Declared::looped_full`]). fn loop_start(&mut self, t: &Sig<'s>) { - let [h0, ..] = self.h; + let [h0, h1, ..] = self.h; let depth = self.depth(); while let Some(l) = self.loops.last_mut() { let after_head = std::mem::take(&mut l.after_head); @@ -288,14 +291,19 @@ impl<'s> Declarations<'s, '_, '_> { // don't go on with it, as in [`Analyzer::token`], and it does not follow the // parentheses of an `if` or another statement that the body goes on with. Stage::Statement - if t.nl && depth == l.depth && !goes_on_after(h0) && !goes_on_with(t) && !after_head && !word(h0, "else") && !word(h0, "do") => + if t.nl + && depth == l.depth + && !goes_on_after(h0) + && !goes_on_with(t) + && !after_head + && !["else", "do", "catch", "finally"].iter().any(|w| word(h0, w) && !member_mark(h1)) => { l.stage = Stage::Tail; } Stage::Statement => { if depth == l.depth { if t.is("{") { - l.block = t.stmt || after_head || word(h0, "else"); + l.block = t.stmt || after_head || word(h0, "else") || (word(h0, "finally") && !member_mark(h1)); } else if HEADS.iter().any(|w| t.word(w)) && !member_mark(h0) { l.head = true; } @@ -310,7 +318,14 @@ impl<'s> Declarations<'s, '_, '_> { l.stage = Stage::Statement; break; } - Stage::Tail => { + // The `catch` and `finally` of a `try` statement that is the body go on with it. + Stage::Tail if t.word("catch") || t.word("finally") => { + l.stage = Stage::Statement; + l.head = t.word("catch"); + break; + } + Stage::DoEnd if t.is(";") && depth == l.depth => break, + Stage::Tail | Stage::DoEnd => { self.pop_loop(t.start); // A body of one statement that is this loop ends with it. if let Some(outer) = self.loops.last_mut() @@ -366,7 +381,13 @@ impl<'s> Declarations<'s, '_, '_> { } false } - Stage::DoHead => t.is(")") && depth == l.depth, + Stage::DoHead => { + if t.is(")") && depth == l.depth { + l.stage = Stage::DoEnd; + } + false + } + Stage::DoEnd => t.is(";") && depth == l.depth, Stage::Block => { if t.is("}") && depth == l.depth && l.do_loop { l.stage = Stage::Tail; diff --git a/crates/scriptcheck/src/analyze/features.rs b/crates/scriptcheck/src/analyze/features.rs index 48db72caad..ac0e69b52f 100644 --- a/crates/scriptcheck/src/analyze/features.rs +++ b/crates/scriptcheck/src/analyze/features.rs @@ -403,15 +403,16 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { // function called without a receiver (ECMA-262 3rd edition, sections 10.2.1 and 10.2.3), so the // global variable of that name may get another value. if changes { - let global = if is(h1, ".") && word(h2, "this") { + // `this`, not a property named `this` (`holder.this.d`). + let global = if is(h1, ".") && word(h2, "this") && !member_mark(h3) { h0.filter(|s| s.kind == T::Ident).map(|s| s.text.to_string()) - } else if is(h0, "]") && is(h2, "[") && word(h3, "this") { + } else if is(h0, "]") && is(h2, "[") && word(h3, "this") && !member_mark(self.h4) { h1.filter(|s| s.kind == T::Str).map(|s| unquote(s.text, 64)) } else { None }; if let Some(name) = global { - self.reassigned_later(&name); + self.reassigned_global(&name); } } let writer = |s: Option>, before: Option>| s.filter(|s| self.writer_bits(Some(*s), before, None) != 0).map(|s| s.text); @@ -431,8 +432,8 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> { // `local['name' + k]`. writer(h2, h3).filter(|_| !t.is("]")) } else if is(h0, "]") && is(h2, "[") && changes && h1.is_some_and(|m| catalog::DOM_FILE_WRITES.contains(&unquote(m.text, 32).as_str())) { - // `local['saveAs'] = …` - writer(h3, None) + // `local['saveAs'] = …`, not `other.local['saveAs'] = …`. + writer(h3, self.h4) } else { None }; diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 2991b1c23f..ca87f3d384 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -761,6 +761,56 @@ fn an_own_save_as_reassigned_later_in_a_loop_writes_a_file() { assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 5, 8][..])); } +/// The `catch` and `finally` of a `try` body, and an `else` after a `do` loop inside a body without +/// braces, are in the loop; a statement after the whole loop is not. +#[test] +fn try_clauses_and_else_after_a_nested_do_loop_are_in_the_loop() { + let r = report(concat!( + "var f = new File(p);\n", + "var d = {saveAs: function () {}}; var e = {saveAs: function () {}}; var g = {saveAs: function () {}};\n", + "var h = {saveAs: function () {}};\n", + "while (i++ < 2) try { d.saveAs(f); } finally { d = app.activeDocument; }\n", + "while (i++ < 2)\n", + " if (i === 2) do e.saveAs(f); while (false);\n", + " else e = app.activeDocument;\n", + "while (n--) do g.saveAs(f); while (false);\n", + "g = app.activeDocument;\n", + "while (n--) h.saveAs(f), holder.finally\n", + "h = app.activeDocument;\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[4, 6][..])); +} + +/// A literal after a label's line break may not run, a `this` assignment in a function whose own +/// variable hides the global one changes the global, and a property `d` of another object is not +/// the variable `d`. +#[test] +fn labels_hidden_globals_and_other_objects_keep_writes_known() { + let r = report(concat!( + "var f = new File(p);\n", + "var a = app.activeDocument;\n", + "if (no) l:\n", + "var a = {saveAs: function () {}};\n", + "a.saveAs(f);\n", + "var b = {saveAs: function () {}};\n", + "function change() { var b; this.b = app.activeDocument; }\n", + "change(); b.saveAs(f);\n", + "var c = {saveAs: function () {}};\n", + "function keep() { var c; c = 1; }\n", + "keep(); c.saveAs(f);\n", + "var d = {saveAs: function () {}};\n", + "holder.d['saveAs'] = 1;\n", + "d.saveAs(f);\n", + "var e = {saveAs: function () {}};\n", + "e['saveAs'] = app.activeDocument.saveAs;\n", + "e.saveAs(f);\n", + "var g = {saveAs: function () {}};\n", + "function other() { var g; holder.this.g = app.activeDocument; holder.this['g'] = 1; }\n", + "other(); g.saveAs(f);\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[5, 8, 17][..])); +} + /// Only a `var` statement directly in a function body or the global code that gives its first name /// the literal as its whole value makes the literal's `saveAs` the script's own, from the end of the /// statement. A literal given in a branch, one the value goes on from, one given by an assignment diff --git a/docs/mcp.md b/docs/mcp.md index b2678c4f1d..d4cb072175 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3169,8 +3169,11 @@ through `$`: and leaves the document open when the document has no file (a converted or recovered document included) or when the save would omit artboards. These refusals occur before writing any files. An SVG or SVGZ save of several artboards requires Preserve Editing Capabilities to close with `SaveOptions.SAVECHANGES`. A PDF last saved with - `useArtboards: false` omits artboards; a native or `.ai` file (other than a version 7 `.ai` file) saved with - `separateArtboards` keeps every artboard whatever its range names. + `useArtboards: false` omits artboards; a native file saved with `separateArtboards` and a `.ai` or `.ait` file other + than a version 7 `.ai` file keep every artboard whatever their range names. An SVG file saved with Preserve + Editing Capabilities carries the native document with every artboard, so `close(SaveOptions.SAVECHANGES)` does not + refuse it for omitted artboards. The SVG drawing still shows one artboard, or the art bounds with + `useArtboards: false`, and the SVG save still refuses a range that selects several artboards. `SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot show the prompt. A bad value throws an error before anything is written. The warnings of the save or export that `saveAs`, `exportFile`, `app.open` and `close` run go to the console, each after the method's name From 39ab91529711d50ed81194abcc5b335c0aba7941 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:39:10 -0800 Subject: [PATCH 210/264] =?UTF-8?q?Tests:=20Expand=E2=80=A6=20keeps=20the?= =?UTF-8?q?=20general=20tooltip=20with=20nothing=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The walk-count test now checks that Object › Expand…, dimmed with nothing selected, shows the general reason as its tooltip, as on main, instead of only checking that the tooltip is not the appearance one. --- crates/ui-egui/src/menus/model.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 37de6908c2..31f20688fc 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -736,6 +736,8 @@ mod tests { assert_eq!(tooltip(&app).as_deref(), Some(crate::dialogs::expand::appearance_first())); app.run("select.none", json!({})).unwrap(); assert_eq!(walks(&mut app), 0, "nothing selected"); - assert_ne!(tooltip(&app).as_deref(), Some(crate::dialogs::expand::appearance_first())); + // Dimmed with nothing selected, the row keeps the general reason as its tooltip, as before. + let tip = tooltip(&app); + assert!(tip.as_deref().is_some_and(|t| t != crate::dialogs::expand::appearance_first()), "{tip:?}"); } } From 8c7ddea00a26c2031792ac3046252a834a22e53e Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:46:11 +0100 Subject: [PATCH 211/264] Finish Hand panning before switching to a pen eraser --- crates/ui-egui/src/canvas/tests.rs | 19 +++++++++++++++++++ crates/ui-egui/src/canvas/tool_adapter.rs | 1 + 2 files changed, 20 insertions(+) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index b91f6d504b..d441c59316 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -4874,6 +4874,25 @@ fn a_flip_during_a_press_waits_for_the_release() { assert_eq!(app.session.tool_id(), "eraser", "the frame after the release"); } +/// A selected Hand tracks its drag in the framework, outside the document tool's grab. +#[test] +fn turning_the_pen_during_a_hand_drag_waits_for_release() { + let (mut app, stylus, ctx) = pen_app(); + app.select_tool("hand"); + let at = app.canvas_view().unwrap().rect.center(); + let to = at + egui::vec2(30.0, 20.0); + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + stylus.set(tip(0.5)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), button(at, true)]); + stylus.set(eraser_end(0.5)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(to)]); + assert_eq!(app.session.tool_id(), "hand"); + frame(&mut app, &ctx, vec![button(to, false)]); + assert_eq!(app.session.tool_id(), "hand"); + frame(&mut app, &ctx, vec![]); + assert_eq!(app.session.tool_id(), "eraser"); +} + /// #764: a tool chosen while the eraser end stands in (the toolbar and shortcuts call /// `select_tool`; menus and MCP run `tool.select`) stays when the tip comes back. #[test] diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index 6ebdd54af4..cc2750f2a4 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -629,6 +629,7 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too // the release, and a pointer over another window for the pointer to come in. if ui.ctx().current_pass_index() == 0 && app.canvas.grab.is_none() + && !ToolHost::in_gesture(ui.ctx(), pass.id) && ui.input(|i| i.pointer.has_pointer()) && crate::stylus::sync_eraser_tool(app) { From 891909a9d5460d8a3ecce672dafef9f207c85ece Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 12:48:10 +0100 Subject: [PATCH 212/264] Keep all drawing modes inside the double-column toolbar --- crates/ui-egui/src/toolbar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 618bace39b..e80ed26a77 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -823,7 +823,7 @@ fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { None => button, }; // Small in two columns, where the three sit side by side in the rail's width. - let button = if two { button.size(ControlSize::Sm) } else { button }; + let button = if two { button.size(ControlSize::Sm).glyphs(craft::ui::style::GlyphRole::Tool) } else { button }; button.show(ui).clicked() }; let mut run = None; From 98e5003ec31d4db5dca005a809cb9b5b12a367a6 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:21:47 +0100 Subject: [PATCH 213/264] Commit hovered font rows and avoid native clock calls in web character controls --- crates/ui-egui/src/panels/character.rs | 28 +++++++++++++++----------- crates/ui-egui/src/tests/font_menu.rs | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/panels/character.rs b/crates/ui-egui/src/panels/character.rs index 9415a7e50f..677eec516a 100644 --- a/crates/ui-egui/src/panels/character.rs +++ b/crates/ui-egui/src/panels/character.rs @@ -6,7 +6,6 @@ use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; use std::sync::{Arc, Mutex, Weak}; -use std::time::SystemTime; // PLAN: assumed the framework paths below (craft::text::ui re-exports, craft_ui widgets and runtime, craft::font_manager). use craft::behavior::EditEvent; @@ -47,12 +46,15 @@ use crate::font_menu; /// attributes of the paragraph the selection starts in (else of the first paragraph). /// Font/paragraph controls and named-style capture use this; dimensional fields use `shared_effective`. pub(crate) fn text_style(app: &VectorcraftApp) -> Option<(CharStyle, vectorcraft_doc::ParaStyle)> { + let state = app.session.active()?; + // Hover changes the canvas, but the picker compares its next row click against the committed font. + let doc = state.interaction.as_ref().filter(|_| app.font_preview_owner.is_some()).map_or(&state.doc, |preview| &preview.doc); if let Some((id, a, b)) = text_editing(app) - && let Some(NodeKind::Text(t)) = app.session.active().and_then(|d| d.doc.node(id)).map(|n| &n.kind) + && let Some(NodeKind::Text(t)) = doc.node(id).map(|n| &n.kind) { return Some((vectorcraft_text::edit::insertion_style(&t.runs, a, b), t.para_at(t.paragraphs_in(a, a).start).clone())); } - let t = first_selected_text(app)?; + let NodeKind::Text(t) = &first_selected_text_node_in(state, doc)?.kind else { return None }; Some((t.first_style(), t.para_at(0).clone())) } @@ -68,7 +70,11 @@ pub(crate) fn first_selected_text(app: &VectorcraftApp) -> Option<&vectorcraft_d /// their descendants, in selection order, then paint order within each selected object. pub(crate) fn first_selected_text_node(app: &VectorcraftApp) -> Option<&vectorcraft_doc::Node> { let st = app.session.active()?; - for node in st.selection.objects.iter().filter_map(|id| st.doc.node(*id)) { + first_selected_text_node_in(st, &st.doc) +} + +fn first_selected_text_node_in<'a>(state: &DocState, doc: &'a vectorcraft_doc::Document) -> Option<&'a vectorcraft_doc::Node> { + for node in state.selection.objects.iter().filter_map(|id| doc.node(*id)) { let mut text = None; node.walk(&mut |n| { if text.is_none() && matches!(n.kind, NodeKind::Text(_)) { @@ -1219,16 +1225,14 @@ pub(crate) fn controls(app: &mut VectorcraftApp, ui: &mut Ui, rows: CharacterRow let languages: Option> = rows.contains(CharacterRows::STYLE_TOGGLES).then(|| LANGUAGES.iter().map(|(name, _, _)| (name.to_string(), name.to_string())).collect()); let catalog = vectorcraft_text::FontDb::global().catalog(); - let before = font_menu::picker_settings(app); - let mut settings = before.clone(); - let document = font_menu::document_family_set(app); - let recent = font_menu::recently_added_set(app, SystemTime::now()); - let sets = font_menu::family_sets(Some(&document[..]), &recent[..]); + let mut hold = font_menu::hold(app); + let before = hold.settings.clone(); + let sets = font_menu::family_sets(hold.document.as_deref(), &hold.recently_added); let sample = font_menu::sample_text(app); let unit = type_unit(app); let mut source = FontPickerSource::new(catalog) - .settings(Bind::bound(&mut settings)) - .filters(Bind::bound(&mut app.ui.font_filters)) + .settings(Bind::bound(&mut hold.settings)) + .filters(Bind::bound(&mut hold.filters)) .sets(&sets) .scripts(&FontScript::ALL) .filter_layout(FilterLayout::Toolbar); @@ -1248,7 +1252,7 @@ pub(crate) fn controls(app: &mut VectorcraftApp, ui: &mut Ui, rows: CharacterRow controls = controls.axes(FaceAxes::new(axes, instances).italic(face_of(¤t.font_style).2)); } let out = controls.show(ui); - font_menu::store_picker_settings(app, &before, settings); + hold.store(app, &before); let CharacterControlsOutput { picker, preview_family, edits, .. } = out; if let Some(owner) = picker { font_menu::apply_preview(app, owner, preview_family); diff --git a/crates/ui-egui/src/tests/font_menu.rs b/crates/ui-egui/src/tests/font_menu.rs index 9a6ce5421c..9a4b7323db 100644 --- a/crates/ui-egui/src/tests/font_menu.rs +++ b/crates/ui-egui/src/tests/font_menu.rs @@ -86,6 +86,7 @@ fn preview_changes_the_text_live_and_only_a_choice_is_a_step() { let before = steps(&app); apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into())); assert_eq!(font_of(&app, id), "Source Serif 4", "previewed on the text"); + assert_eq!(crate::panels::character::values(&mut app).family.as_deref(), Some("Inter"), "the picker must still be able to commit the previewed row"); apply_preview(&mut app, owner(), Preview::Shows("Source Sans 3".into())); assert_eq!(font_of(&app, id), "Source Sans 3"); apply_preview(&mut app, owner(), Preview::Ended); From aeae489395db6947f4e99b072bed996f6f96c709 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:25:54 +0100 Subject: [PATCH 214/264] Bound text-object joins within the import comparison budget --- crates/eps/src/import/native/plan.rs | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/crates/eps/src/import/native/plan.rs b/crates/eps/src/import/native/plan.rs index 487cae27b4..e4eec8cdc5 100644 --- a/crates/eps/src/import/native/plan.rs +++ b/crates/eps/src/import/native/plan.rs @@ -350,35 +350,45 @@ fn see_page_type(content: &mut [Content], shown: &[Vec>]) -> Option, Vec, bool)> = shown.iter().map(|o| (texts(o).iter().filter_map(|n| n.visual_bounds()).collect(), object_words(o), false)).collect(); let pieces: usize = objects.iter().map(|o| o.0.len()).sum(); - if content.len().saturating_mul(pieces) > MAX_PAIRS { - return None; - } + let mut budget = MAX_PAIRS.checked_sub(content.len().checked_mul(pieces)?)?; let holds = |drawn: Rect, r: &Rect| drawn.inflate(OUTLINE_REACH, OUTLINE_REACH).intersect(*r).area() >= 0.5 * r.area().max(1e-9); // The made type holding each object, in order: where it draws and its words. - let mut holders: Vec> = vec![vec![]; objects.len()]; - for c in content { - let Content::Made(node, region, seen) = c else { continue }; + let mut holders: Vec>> = vec![vec![]; objects.len()]; + let mut seen_slots = Vec::new(); + for (slot, c) in content.iter().enumerate() { + let Content::Made(node, region, _) = c else { continue }; // Hidden made type has no region: where it draws, shown, is its own box. let Some(drawn) = region.or_else(|| node.visual_bounds()) else { continue }; let (spelled, holder) = match &node.kind { NodeKind::Text(t) => { let text = t.plain_text(); let [a, b, ..] = t.xf.as_coeffs(); - (spelling(&text), Some((drawn.center(), (a, b), word_pieces(&text).map(spelling).filter(|w| !w.is_empty()).collect()))) + (spelling(&text), Some(Arc::new((drawn.center(), (a, b), word_pieces(&text).map(spelling).filter(|w| !w.is_empty()).collect())))) } _ => (String::new(), None), }; for ((rects, words, held), by) in objects.iter_mut().zip(&mut holders) { if rects.iter().any(|r| holds(drawn, r)) { *held = true; - *seen |= region.is_some(); + if region.is_some() && seen_slots.last() != Some(&slot) { + seen_slots.push(slot); + } words.retain(|w| !spelled.contains(w.as_str())); by.extend(holder.clone()); } } } for ((_, words, _), by) in objects.iter_mut().zip(&holders) { - words.retain(|w| !joined_by_two(w, by)); + if !words.is_empty() && !by.is_empty() { + // Each unmatched word can visit every ordered pair of holders, plus the first-holder scan. + budget = budget.checked_sub(words.len().checked_mul(by.len())?.checked_mul(by.len().checked_add(1)?)?)?; + words.retain(|w| !joined_by_two(w, by)); + } + } + for slot in seen_slots { + if let Content::Made(_, _, seen) = &mut content[slot] { + *seen = true; + } } Some(objects.iter().filter(|(_, words, held)| !held || !words.is_empty()).count()) } @@ -390,11 +400,11 @@ type Holder = (Point, (f64, f64), Vec); /// Is `word` (a [`spelling`]) the last word of one of `by` joined to the first word of another of /// them that draws after it, along the first one's lines? Each part is a whole word of its text /// object, so a piece is never made up of bits of words. -fn joined_by_two(word: &str, by: &[Holder]) -> bool { - by.iter().any(|(at, (a, b), first)| { +fn joined_by_two(word: &str, by: &[Arc]) -> bool { + by.iter().map(Arc::as_ref).any(|(at, (a, b), first)| { let Some(head) = first.last().filter(|h| word.len() > h.len() && word.starts_with(h.as_str())) else { return false }; let tail = &word[head.len()..]; - by.iter().any(|(next, _, second)| (next.x - at.x) * a + (next.y - at.y) * b > 0.0 && second.first().is_some_and(|w| w == tail)) + by.iter().map(Arc::as_ref).any(|(next, _, second)| (next.x - at.x) * a + (next.y - at.y) * b > 0.0 && second.first().is_some_and(|w| w == tail)) }) } From 80ceb782aafa0e8f5c65e9e483c79e58051ac71a Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:27:12 +0100 Subject: [PATCH 215/264] Measure copied art from the active source artboard for Paste in Place --- crates/engine/src/cmd/edit.rs | 11 +++++++++-- crates/engine/src/command_sets.rs | 8 ++++++-- crates/ui-egui/src/app/commands.rs | 3 ++- crates/ui-egui/src/canvas/tests.rs | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 4fc1b83c29..84f28ab942 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -162,7 +162,7 @@ pub fn specs() -> Vec { "Cut", ["Edit"], Some("Cmd+X"), - "{selectedArtboards?: [n…], art?: bool, lockedAndHidden?: bool (the Artboard tool chosen, as artboard.cut)} (as edit.copy) removes the objects it copies, in one undo step: a compound-path member selected on its own leaves the compound's other members in the compound (selected ruler guides go too; the Artboard tool chosen, or selectedArtboards given: artboard.cut); refused while an object of a symbol instance's art is selected", + "{artboard?: index (the source artboard for copied objects), selectedArtboards?: [n…], art?: bool, lockedAndHidden?: bool (the Artboard tool chosen, as artboard.cut)} (as edit.copy) removes the objects it copies, in one undo step: a compound-path member selected on its own leaves the compound's other members in the compound (selected ruler guides go too; the Artboard tool chosen, or selectedArtboards given: artboard.cut); refused while an object of a symbol instance's art is selected", has_selection_guides_or_artboard_tool, cut ), @@ -171,7 +171,7 @@ pub fn specs() -> Vec { "Copy", ["Edit"], Some("Cmd+C"), - "{selectedArtboards?: [n…] (the artboards the Artboard tool had selected, which the journal records for a replay; it runs artboard.copy with any tool chosen), art?: bool (default: the Artboard tool's moveArt option; the journal records it beside selectedArtboards), lockedAndHidden?: bool (the Artboard tool chosen, as artboard.copy)} the selection with what it uses (a compound-path member selected on its own, whole or in part, with Direct or Group Selection, is copied as an ordinary path with the compound's paint, transparency, opacity mask, fill rule and graphic style link (while it has that style's look), a gradient keeping the compound's fit; the compound is copied when it is selected, or when every member is selected whole outside isolation mode), and the selected ruler guides (pasted on the layer new art goes to, moved as the objects are; alone, where they were); the Artboard tool chosen: artboard.copy; with an object of a symbol instance's art selected, the instance is copied whole → {copied, guides}", + "{artboard?: index (the source artboard for copied objects; without it, the artboard containing the selection center), selectedArtboards?: [n…] (the artboards the Artboard tool had selected, which the journal records for a replay; it runs artboard.copy with any tool chosen), art?: bool (default: the Artboard tool's moveArt option; the journal records it beside selectedArtboards), lockedAndHidden?: bool (the Artboard tool chosen, as artboard.copy)} the selection with what it uses (a compound-path member selected on its own, whole or in part, with Direct or Group Selection, is copied as an ordinary path with the compound's paint, transparency, opacity mask, fill rule and graphic style link (while it has that style's look), a gradient keeping the compound's fit; the compound is copied when it is selected, or when every member is selected whole outside isolation mode), and the selected ruler guides (pasted on the layer new art goes to, moved as the objects are; alone, where they were); the Artboard tool chosen: artboard.copy; with an object of a symbol instance's art selected, the instance is copied whole → {copied, guides}", has_selection_guides_or_artboard_tool, copy ), @@ -1163,6 +1163,13 @@ fn copy(s: &mut Session, p: &Value) -> Result { }); clip.source_artboard = board.map(|a| a.rect); } + if let Some(value) = p.get("artboard") { + let board = value + .as_u64() + .and_then(|v| st.doc.artboards.get(index(v))) + .ok_or_else(|| bad("edit.copy", "`artboard` must be the index of an artboard of the document"))?; + clip.source_artboard = Some(board.rect); + } clip.guides = guides; s.clipboard = clip; Ok(json!({ "copied": s.clipboard.nodes.len(), "guides": s.clipboard.guides.len() })) diff --git a/crates/engine/src/command_sets.rs b/crates/engine/src/command_sets.rs index 1346dc40c5..893c4f78e9 100644 --- a/crates/engine/src/command_sets.rs +++ b/crates/engine/src/command_sets.rs @@ -5,7 +5,9 @@ use super::{NodeId, Value, cmd, find_command}; /// Objects and Distribute Spacing with Align to Artboard distribute objects across it, All on /// Active Artboard selects on it, and Edit Symbol from the Symbols panel centers the symbol's art /// on it. A `command.batch` given `artboard` passes it on to each of their steps that names none. -pub const ON_ACTIVE_ARTBOARD: [&str; 8] = [ +pub const ON_ACTIVE_ARTBOARD: [&str; 10] = [ + "edit.copy", + "edit.cut", "edit.pasteInPlace", "edit.pasteInFront", "edit.pasteInBack", @@ -35,7 +37,9 @@ pub const DRAWS_SHAPE: [&str; 5] = ["shape.rectangle", "shape.ellipse", "shape.p /// Artboard tool had selected for its commands and for Paste in Place, in Front and in Back; the artboards and art Cut and Copy took with that /// tool chosen; the view's center the app passes to Edit Symbol); an action leaves them out /// ([`Session::journal_for_action`]). -const REPLAY_ONLY: [(&str, &str); 35] = [ +const REPLAY_ONLY: [(&str, &str); 37] = [ + ("edit.copy", "artboard"), + ("edit.cut", "artboard"), ("file.new", "created"), ("edit.newDocumentFromState", "created"), ("document.save", "modified"), diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index b7ff421414..1452288749 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -129,11 +129,12 @@ impl VectorcraftApp { /// document without artboards they get neither. fn add_active_artboard(&self, id: &str, params: &mut Value) { let paste = matches!(id, "edit.pasteInPlace" | "edit.pasteInFront" | "edit.pasteInBack"); + let clipboard_command = paste || matches!(id, "edit.copy" | "edit.cut"); if (vectorcraft_engine::ON_ACTIVE_ARTBOARD.contains(&id) || id == "command.batch") && params.get("artboard").is_none() && !(paste && params.get("artboards").is_some()) && self.view().is_some() - && let Some(n) = self.session.active().map(|d| d.doc.artboards.len()).filter(|n| *n > 0 || !paste) + && let Some(n) = self.session.active().map(|d| d.doc.artboards.len()).filter(|n| *n > 0 || !clipboard_command) && let Some(p) = params.as_object_mut() { let picked = panels::artboards::picked(self, n); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d441c59316..e8b26555e2 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -426,6 +426,23 @@ fn a_click_activates_its_artboard_and_paste_in_place_goes_onto_it() { assert_eq!((b.x0, b.y0), (boards[2].x0 + 10.0, boards[2].y0 + 15.0)); } +/// Copy uses the active board as its origin even when selected art lies on a different board. +#[test] +fn copy_and_paste_use_the_active_source_and_destination_artboards() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 100, "artboards": 3})).unwrap(); + let boards: Vec<_> = app.session.active().unwrap().doc.artboards.iter().map(|a| a.rect).collect(); + let origin = Point::new(boards[1].x0 + 10.0, boards[1].y0 + 15.0); + app.run("shape.rectangle", json!({"x": origin.x, "y": origin.y, "width": 20, "height": 20})).unwrap(); + app.views[0].artboard = 0; + app.run("edit.copy", json!({})).unwrap(); + app.views[0].artboard = 2; + let pasted = app.run("edit.pasteInPlace", json!({})).unwrap(); + let id = vectorcraft_doc::NodeId(pasted["ids"][0].as_u64().unwrap()); + let bounds = app.session.active().unwrap().doc.bounds_of(&[id], false).unwrap(); + assert_eq!(bounds.origin(), origin + (boards[2].origin() - boards[0].origin())); +} + /// A Shift-click with the Selection tool on an empty spot inside an artboard makes it the active /// one and keeps the selection, and Align to Artboard then aligns the objects to it unless the /// call names another artboard. From dc5958913555e422e649d5662320cfa0ef5ee175 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:39:42 +0100 Subject: [PATCH 216/264] Format the import budget check --- crates/eps/src/import/native/plan.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/eps/src/import/native/plan.rs b/crates/eps/src/import/native/plan.rs index e4eec8cdc5..a23e8ea324 100644 --- a/crates/eps/src/import/native/plan.rs +++ b/crates/eps/src/import/native/plan.rs @@ -404,7 +404,9 @@ fn joined_by_two(word: &str, by: &[Arc]) -> bool { by.iter().map(Arc::as_ref).any(|(at, (a, b), first)| { let Some(head) = first.last().filter(|h| word.len() > h.len() && word.starts_with(h.as_str())) else { return false }; let tail = &word[head.len()..]; - by.iter().map(Arc::as_ref).any(|(next, _, second)| (next.x - at.x) * a + (next.y - at.y) * b > 0.0 && second.first().is_some_and(|w| w == tail)) + by.iter() + .map(Arc::as_ref) + .any(|(next, _, second)| (next.x - at.x) * a + (next.y - at.y) * b > 0.0 && second.first().is_some_and(|w| w == tail)) }) } From 274983176d72baf531faa284ebcd47ac10609ff3 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:39:47 +0100 Subject: [PATCH 217/264] Format the font preview regression test --- crates/ui-egui/src/tests/font_menu.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tests/font_menu.rs b/crates/ui-egui/src/tests/font_menu.rs index 9a4b7323db..28d573d09b 100644 --- a/crates/ui-egui/src/tests/font_menu.rs +++ b/crates/ui-egui/src/tests/font_menu.rs @@ -86,7 +86,11 @@ fn preview_changes_the_text_live_and_only_a_choice_is_a_step() { let before = steps(&app); apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into())); assert_eq!(font_of(&app, id), "Source Serif 4", "previewed on the text"); - assert_eq!(crate::panels::character::values(&mut app).family.as_deref(), Some("Inter"), "the picker must still be able to commit the previewed row"); + assert_eq!( + crate::panels::character::values(&mut app).family.as_deref(), + Some("Inter"), + "the picker must still be able to commit the previewed row" + ); apply_preview(&mut app, owner(), Preview::Shows("Source Sans 3".into())); assert_eq!(font_of(&app, id), "Source Sans 3"); apply_preview(&mut app, owner(), Preview::Ended); From 25756e1b8d38fc93ef8b6c5989253b4a00fc4fd3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 04:43:33 -0800 Subject: [PATCH 218/264] xtask: test-lint fails on four rules; all-unguarded skips collections that cannot be empty Replayed over the last 300 merges of main, all-unguarded failed good pull requests on collections that cannot be empty. It now leaves out: - plain locals bound to an array type of a positive length, to a non-empty array literal or vec![...], or to a literal range followed only by methods that keep an item (map, iter, rev, collect into a known collection ...); counts may be consts of the file - locals filled by a push or insert on every pass of a loop over such a source - fields and const or static items the file declares only as arrays of a positive length - collections compared with a non-empty literal through such methods, directly or through a local built from them, and assertions on a local bound to a count or length - .windows(k) and .chunks_exact(k) when the collection has k items Later code that may remove items or replace the collection cancels the exemption. Only only-weak, self-compare, ignore-without-reason and sleep fail the check now. The other rules list their hits on changed lines without failing. On the same 300 merges, 1 would fail (an only-weak test), and the 3 all-unguarded hits are tests an empty result passes. On main at 07037afda8, all-unguarded lists 392 hits instead of 433. --- docs/development.md | 2 +- xtask/src/main.rs | 7 +- xtask/src/test_lint.rs | 1164 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 1065 insertions(+), 108 deletions(-) diff --git a/docs/development.md b/docs/development.md index 26058129e7..cfd02bacc8 100644 --- a/docs/development.md +++ b/docs/development.md @@ -351,7 +351,7 @@ The app decides which cursors exist; whoever draws them works from the list. For ## Test lint -`cargo xtask test-lint` (part of `cargo xtask ci`) fails on tests that a wrong result can pass, in the lines and tests changed since a base: `assert!(….all(…))` with no length or emptiness check, a test whose only checks are `is_ok`, `is_some` or `!is_empty`, `assert_eq!(x, x)`, a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, `#[ignore]` without a reason, an environment variable that no CI leg sets, `thread::sleep` in test code, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. +`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on a test whose only checks are `is_ok`, `is_some` or `!is_empty` (`only-weak`), `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. ## Tests diff --git a/xtask/src/main.rs b/xtask/src/main.rs index f48f088aa8..addf9cb7e1 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -34,9 +34,10 @@ commands: brands check that user-visible text (labels, params docs, MCP, docs, packaging) names no other vendor's products cursors warn about Cursor values with no entry in crates/tools/src/cursors.toml (never fails) test-lint [--base ] [--all] - fail on weak tests (unguarded .all(), only is_ok/is_some checks, no assertion, early - returns, unset env gates, sleeps...) in the lines changed since the base - (xtask/src/test_lint.rs); --all lists every hit by crate and never fails + weak tests in the lines changed since the base: fail on only is_ok/is_some checks, + self-compares, reasonless #[ignore] and sleeps; list unguarded .all(), no assertion, + early returns, unset env gates... (xtask/src/test_lint.rs); --all lists every hit + by crate and never fails i18n-report list the strings each language's catalog lacks, shown in English (fails only on a broken scan; ci runs it too) ui-commands regenerate crates/mcp/src/ui_catalog.rs from desktop UI_COMMANDS; --check fails on drift diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index 8664403997..60363000fd 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -9,9 +9,15 @@ //! matches, with whole negations or `!=` comparisons joined only by `&&`, are left out). An earlier //! `assert_eq!`, `debug_assert_eq!` or `prop_assert_eq!` comparing a plain local receiver //! (optionally borrowed or viewed through `.as_slice()` or `[..]`) with a non-empty array -//! literal or `vec![…]` guards only that receiver. Non-empty array literals and plain local -//! names bound to them in the test, optionally through `.map(…)`, are also left out. Empty arrays -//! still count. A change anywhere in the test counts as a change to the hit; +//! literal or `vec![…]` guards only that receiver, and so does an assertion on a local bound to a +//! count, length or emptiness check. Collections that cannot be empty are also left out: +//! non-empty array literals; plain locals of the test bound to an array type of a positive length, +//! to a non-empty array literal or `vec![…]` or a literal range (lengths and repetition counts may +//! be `const`s of the file) followed only by methods that keep an item (`map`, `iter`, `rev`, +//! `collect` …), or filled by a `push` or `insert` on every pass of a loop over one, unless later +//! code may shrink or replace them; and fields the file declares only as arrays of a positive +//! length. `.windows(k)` and `.chunks_exact(k)` need `k` items. Empty arrays still count. A change +//! anywhere in the test counts as a change to the hit; //! * `only-weak`: every assertion is `is_ok()`, `is_some()`, `!is_empty()` or `len() > 0`, and the //! test calls no asserting helper; //! * `self-compare`: `assert_eq!(x, x)` or `assert_ne!(x, x)` on the same expression, when that @@ -50,6 +56,7 @@ //! changed. Hits on unchanged lines are counted but do not fail it. `--all` lists every hit in the //! workspace by crate and rule, and does not fail. +use std::cell::OnceCell; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::path::Path; use std::process::Command; @@ -156,6 +163,11 @@ impl Rule { } } + /// Whether a hit on a changed line fails the command. The other rules only report. + pub fn fails(self) -> bool { + matches!(self, Rule::OnlyWeak | Rule::SelfCompare | Rule::IgnoreWithoutReason | Rule::Sleep) + } + fn from_id(id: &str) -> Option { Rule::ALL.into_iter().find(|r| r.id() == id) } @@ -254,20 +266,33 @@ impl Options { fn finish(counted: &[Hit], older: usize, files: usize, base: &str) -> Result<(), String> { let older = if older == 0 { String::new() } else { format!("; {older} hit(s) on unchanged lines of those files are not counted") }; - if counted.is_empty() { - println!("test-lint: no hits in the changed lines of {files} Rust file(s) since {base}{older}"); + let (failing, reported): (Vec<&Hit>, Vec<&Hit>) = counted.iter().partition(|h| h.rule.fails()); + if !reported.is_empty() { + println!( + "test-lint: {} hit(s) of report-only rules in the lines changed since {base} (they do not fail the check):\n {}", + reported.len(), + listing(&reported).join("\n ") + ); + } + if failing.is_empty() { + println!("test-lint: no failing hits in the changed lines of {files} Rust file(s) since {base}{older}"); return Ok(()); } - let mut out: Vec = counted.iter().map(Hit::show).collect(); - let rules: BTreeSet = counted.iter().map(|h| h.rule).collect(); - out.extend(rules.iter().map(|r| format!("{}: {}", r.id(), r.advice()))); Err(format!( "{} test-lint hit(s) in the lines changed since {base}{older} (exempt a line with `// {ALLOW} `):\n {}", - counted.len(), - out.join("\n ") + failing.len(), + listing(&failing).join("\n ") )) } +/// Each hit, then the advice for each rule they break. +fn listing(hits: &[&Hit]) -> Vec { + let mut out: Vec = hits.iter().map(|h| h.show()).collect(); + let rules: BTreeSet = hits.iter().map(|h| h.rule).collect(); + out.extend(rules.iter().map(|r| format!("{}: {}", r.id(), r.advice()))); + out +} + /// `--all`: counts by crate and rule, then every hit. fn report(hits: &[Hit], files: usize) -> String { let mut by_crate: BTreeMap> = BTreeMap::new(); @@ -1113,21 +1138,26 @@ impl View<'_> { const PLAIN_ASSERTS: &[&str] = &["assert", "debug_assert", "prop_assert"]; +/// Calls whose result says how many items a collection has. +const SIZE_CHECKS: &[&str] = &[".len()", ".is_empty()", ".count()", ".first()", ".any(", ".next()", ".last()"]; + fn all_unguarded(v: &View) -> Vec { let mut body = v.body_without_messages(); strip_all_predicates(&mut body); + let locals = bindings(&body); let checked = v.asserts.iter().any(|a| { a.args.iter().take(guard_arg_count(&a.name)).any(|&(from, to)| { - let arg = norm(&body[from - v.t.open..to - v.t.open]); - [".len()", ".is_empty()", ".count()", ".first()", ".any(", ".next()", ".last()"].iter().any(|g| arg.contains(g)) + let (from, to) = (from - v.t.open, to - v.t.open); + SIZE_CHECKS.iter().any(|g| norm(&body[from..to]).contains(g)) || reads_counted_local(&body, &locals, from, to) }) }); - if checked || first_item_guard(&body) { + let sizes = Sizes { file: &v.file.m, consts: OnceCell::new() }; + if checked || first_item_guard(&body, &sizes) { return vec![]; } v.asserts .iter() - .filter(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && unguarded_all(&v.first_arg(a), &v.file.m[v.t.open..a.at])) + .filter(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && unguarded_all(&v.first_arg(a), &v.file.m[v.t.open..a.at], &sizes)) .map(|a| { let mut h = v.hit(a.at, Rule::AllUnguarded, format!("{}!(…all(…)) with no length or emptiness check in the test", a.name)); h.first = v.file.lines.of(v.t.attr); @@ -1157,10 +1187,10 @@ fn strip_all_predicates(body: &mut [u8]) { } /// Whether test code accesses a first item in a way that fails on an empty collection. -fn first_item_guard(body: &[u8]) -> bool { +fn first_item_guard(body: &[u8], sizes: &Sizes) -> bool { let compact = norm(body); let unwrapped = [".first().unwrap()", ".first().expect(", ".next().unwrap()", ".next().expect("]; - let indexed = compact.match_indices("[0]").any(|(at, _)| !on_array_literal(&compact[..at + 3])); + let indexed = compact.match_indices("[0]").any(|(at, _)| array_literal_len(&compact[..at + 3], sizes).is_none_or(|n| n == 0)); indexed || unwrapped.iter().any(|g| compact.contains(g)) || panicking_first_binding(body) } @@ -1179,27 +1209,27 @@ fn panicking_first_binding(body: &[u8]) -> bool { /// Whether a (masked, whitespace-free) condition holds an `.all(…)` that an empty collection would /// pass by mistake. Left out: a negated result, a closure that says no item matches (whole -/// negations or `!=` comparisons joined only by `&&`), and a non-empty array literal or a local -/// name bound to or previously compared equal to one. -fn unguarded_all(cond: &str, body: &[u8]) -> bool { - all_with_polarity(cond, true, body) +/// negations or `!=` comparisons joined only by `&&`), and a collection the test shows cannot be +/// empty ([`least_items`]). +fn unguarded_all(cond: &str, body: &[u8], sizes: &Sizes) -> bool { + all_with_polarity(cond, true, body, sizes) } /// Tracks negation through boolean operands and comparisons with `false`. -fn all_with_polarity(cond: &str, positive: bool, body: &[u8]) -> bool { +fn all_with_polarity(cond: &str, positive: bool, body: &[u8], sizes: &Sizes) -> bool { if cond.starts_with('(') && matching(cond.as_bytes(), 0) == Some(cond.len() - 1) { - return all_with_polarity(&cond[1..cond.len() - 1], positive, body); + return all_with_polarity(&cond[1..cond.len() - 1], positive, body, sizes); } if let Some(at) = boolean_split(cond) { - return all_with_polarity(&cond[..at], positive, body) || all_with_polarity(&cond[at + 2..], positive, body); + return all_with_polarity(&cond[..at], positive, body, sizes) || all_with_polarity(&cond[at + 2..], positive, body, sizes); } if let Some(expr) = cond.strip_suffix("==false").or_else(|| cond.strip_prefix("false==")) { - return all_with_polarity(expr, !positive, body); + return all_with_polarity(expr, !positive, body, sizes); } if let Some(expr) = cond.strip_prefix('!') { - return all_with_polarity(expr, !positive, body); + return all_with_polarity(expr, !positive, body, sizes); } - positive && positive_all(cond, body) + positive && positive_all(cond, body, sizes) } /// Finds a boolean operator outside parentheses, brackets and braces. @@ -1215,13 +1245,14 @@ fn boolean_split(cond: &str) -> Option { None } -fn positive_all(cond: &str, test_body: &[u8]) -> bool { +fn positive_all(cond: &str, test_body: &[u8], sizes: &Sizes) -> bool { cond.match_indices(".all(").any(|(i, _)| { let rest = &cond[i + ".all(".len()..]; let arg = &rest[..arg_end(rest)]; let body = arg.strip_prefix('|').and_then(|r| r.split_once('|')).map_or(arg, |(_, body)| body); let none_match = not_equal_conjunction(body); - !none_match && !on_array_literal(&cond[..i]) && !on_bound_array(&cond[..i], test_body) && !on_equal_array(&cond[..i], test_body) + let (receiver, need) = receiver_need(&cond[..i], sizes); + !none_match && least_items(receiver, test_body, sizes) < need }) } @@ -1274,33 +1305,217 @@ fn whole_negation(body: &str) -> bool { !rest.is_empty() } -/// Whether an earlier equality assertion compares this plain local receiver with a non-empty literal. -fn on_equal_array(receiver: &str, body: &[u8]) -> bool { - let name = array_receiver(receiver); - if name.is_empty() || name.as_bytes()[0].is_ascii_digit() || !name.bytes().all(is_ident) { - return false; - } - macro_calls(body, 0, body.len()).iter().any(|a| { - if !["assert_eq", "debug_assert_eq", "prop_assert_eq"].contains(&a.name.as_str()) { - return false; +/// The fewest items the test shows `receiver` (the text before `.all(`, without its iterator +/// method) to have: a non-empty array literal, a plain local bound to one or to a sized +/// initializer ([`expr_len`]) or filled by a loop ([`loop_fill_len`]), a plain local an earlier +/// equality assertion compares with a non-empty literal, or a field the file declares as an +/// array of a positive length. 0 when the test does not show it. +fn least_items(receiver: &str, body: &[u8], sizes: &Sizes) -> usize { + let literal = array_literal_len(receiver, sizes).unwrap_or(0); + let derived = derived_locals(receiver, body).iter().map(|(d, from)| equal_len(d, body, sizes, Some(*from))).max().unwrap_or(0); + literal + .max(bound_len(receiver, body, sizes)) + .max(equal_len(receiver, body, sizes, None)) + .max(derived) + .max(field_len(receiver, sizes)) + .max(if binds(body, array_receiver(receiver).as_bytes()) { 0 } else { item_len(receiver, sizes) }) +} + +/// Whether `body` has a `let` binding of `name`. +fn binds(body: &[u8], name: &[u8]) -> bool { + words(body, b"let", 0, body.len()).into_iter().any(|at| { + let mut start = skip_ws(body, at + 3); + if body[start..].starts_with(b"mut") && body.get(start + 3).is_some_and(u8::is_ascii_whitespace) { + start = skip_ws(body, start + 3); } - let Some(&(lf, lt)) = a.args.first() else { return false }; - let Some(&(rf, rt)) = a.args.get(1) else { return false }; - let (left, right) = (norm(&body[lf..lt]), norm(&body[rf..rt])); - (collection_operand(&left) == name && non_empty_literal(&right)) || (collection_operand(&right) == name && non_empty_literal(&left)) + body[start..].starts_with(name) && !body.get(start + name.len()).copied().is_some_and(is_ident) }) } +/// Methods that give at least one item for each distinct item they are given, and none from none, +/// with `collect` restricted to known collection targets. +const KEEPING: &[&str] = &["map", "iter", "into_iter", "cloned", "copied", "enumerate", "rev", "collect", "to_vec", "to_owned", "clone"]; + +/// Whether a normalized type names a collection that keeps an item of a non-empty iterator. +fn known_collection(ty: &str) -> bool { + let (name, args) = ty.split_once('<').map_or((ty, None), |(name, args)| (name, args.strip_suffix('>'))); + match name { + "Vec" | "std::vec::Vec" | "String" | "std::string::String" => true, + "Box" | "std::boxed::Box" => args.is_some_and(|args| { + args.starts_with('[') && matching(args.as_bytes(), 0) == Some(args.len() - 1) && !has_top_level(&args.as_bytes()[1..args.len() - 1], b';') + }), + _ => matches!( + name.strip_prefix("std::collections::").unwrap_or(name), + "VecDeque" | "HashSet" | "BTreeSet" | "HashMap" | "BTreeMap" | "BinaryHeap" | "LinkedList" + ), + } +} + +/// `operand` (masked, whitespace-free) without trailing calls of [`KEEPING`] methods: the +/// collection a compared or bound value was built from. Only the final call may use an +/// inferred `collect` target, when the caller knows it is a collection. +fn keeping_base(operand: &str, inferred_collect: bool) -> &str { + let mut op = operand; + while op.ends_with(')') { + let b = op.as_bytes(); + let mut depth = 0usize; + let Some(open) = (0..b.len()).rev().find(|&i| { + match b[i] { + b')' | b']' | b'}' => depth += 1, + b'(' | b'[' | b'{' => depth = depth.saturating_sub(1), + _ => {} + } + depth == 0 + }) else { + break; + }; + let mut head = &op[..open]; + let mut target = None; + if head.ends_with('>') { + let Some(turbofish) = head.rfind("::<") else { break }; + target = Some(&head[turbofish + 3..head.len() - 1]); + head = &head[..turbofish]; + } + let Some((rest, method)) = head.rsplit_once('.') else { break }; + if !KEEPING.contains(&method) || (method == "collect" && !target.map_or(inferred_collect && op.len() == operand.len(), known_collection)) { + break; + } + op = rest; + } + op +} + +/// Plain locals of the test bound (`let name = …;`, latest binding) to `receiver` through +/// [`KEEPING`] methods only, so they have no more distinct items than it, when no later code may +/// shrink or replace `receiver` ([`may_shrink`]), paired with the end of each binding. +fn derived_locals(receiver: &str, body: &[u8]) -> Vec<(String, usize)> { + let name = array_receiver(receiver); + if !plain_local(name) { + return vec![]; + } + let mut latest: HashMap = HashMap::new(); + for at in words(body, b"let", 0, body.len()) { + let mut start = skip_ws(body, at + 3); + if body[start..].starts_with(b"mut") && body.get(start + 3).is_some_and(u8::is_ascii_whitespace) { + start = skip_ws(body, start + 3); + } + let end = start + body[start..].iter().copied().take_while(|&c| is_ident(c)).count(); + if end == start || body[start].is_ascii_digit() { + continue; + } + let stop = statement_end(body, end); + let stmt = norm(&body[end..stop]); + let (annotation, from) = stmt.split_once('=').unwrap_or(("", "")); + let inferred_collect = annotation.strip_prefix(':').is_some_and(known_collection); + let base = keeping_base(from, inferred_collect); + let derived = base != from && collection_operand(base) == name && !may_shrink(body, name.as_bytes(), stop); + latest.insert(String::from_utf8_lossy(&body[start..end]).into_owned(), (derived, stop)); + } + latest.into_iter().filter(|&(_, (derived, _))| derived).map(|(n, (_, stop))| (n, stop)).collect() +} + +/// The length a `const` or `static` item of the file declares for a plain name +/// (`const NAME: [T; N]`), taking the smallest length across all declarations of that name, +/// or 0 when any declaration has an unknown or non-array type. +fn item_len(receiver: &str, sizes: &Sizes) -> usize { + let name = array_receiver(receiver); + if !plain_local(name) { + return 0; + } + let file = sizes.file; + let mut len = None; + for at in words(file, name.as_bytes(), 0, file.len()) { + let before = file[..at].trim_ascii_end(); + let before = before.strip_suffix(b"mut").map_or(before, |b| b.trim_ascii_end()); + let keyword = |w: &[u8]| before.ends_with(w) && !before.len().checked_sub(w.len() + 1).is_some_and(|j| is_ident(before[j])); + if !keyword(b"const") && !keyword(b"static") { + continue; + } + let colon = skip_ws(file, at + name.len()); + let ty = skip_ws(file, colon + 1); + if file.get(colon) != Some(&b':') || file.get(ty) != Some(&b'[') { + return 0; + } + let Some(close) = matching(file, ty) else { return 0 }; + let count = repeat_count(&file[ty + 1..close], sizes).unwrap_or(0); + len = Some(len.map_or(count, |n: usize| n.min(count))); + } + len.unwrap_or(0) +} + +/// The receiver without its iterator method and the items it needs for `.all(…)` to see one: +/// `.windows(k)` and `.chunks_exact(k)` need `k`, anything else one. An unknown `k` needs more +/// than any collection has. +fn receiver_need<'a>(receiver: &'a str, sizes: &Sizes) -> (&'a str, usize) { + let r = array_receiver(receiver); + for (method, exact) in [(".windows(", true), (".chunks_exact(", true), (".chunks(", false)] { + let Some(at) = r.rfind(method) else { continue }; + let open = at + method.len() - 1; + if matching(r.as_bytes(), open) != Some(r.len() - 1) { + continue; + } + let need = match sizes.count(&r[open + 1..r.len() - 1]) { + Some(k) if k > 0 => { + if exact { + k + } else { + 1 + } + } + _ => usize::MAX, + }; + return (array_receiver(&r[..at]), need); + } + (r, 1) +} + +/// The length of the non-empty literal an earlier equality assertion compares this plain local +/// receiver with, or 0. For a derived local, its binding must reach the assertion unchanged. +fn equal_len(receiver: &str, body: &[u8], sizes: &Sizes, binding: Option) -> usize { + let name = array_receiver(receiver); + if !plain_local(name) { + return 0; + } + let lens = macro_calls(body, 0, body.len()).into_iter().filter_map(|a| { + if !["assert_eq", "debug_assert_eq", "prop_assert_eq"].contains(&a.name.as_str()) { + return None; + } + let &(lf, lt) = a.args.first()?; + let &(rf, rt) = a.args.get(1)?; + if binding.is_some_and(|from| lf < from || may_change(&body[..lf], name.as_bytes(), from, false)) { + return None; + } + let end = a.args.last().map_or(rt, |&(_, to)| to); + if may_shrink(body, name.as_bytes(), end) { + return None; + } + let (left, right) = (norm(&body[lf..lt]), norm(&body[rf..rt])); + if collection_operand(keeping_base(&left, true)) == name { + Some(literal_len(&right, sizes)) + } else if collection_operand(keeping_base(&right, true)) == name { + Some(literal_len(&left, sizes)) + } else { + None + } + }); + lens.max().unwrap_or(0) +} + +/// Whether `name` is a plain local name: an identifier that does not start with a digit. +fn plain_local(name: &str) -> bool { + !name.is_empty() && !name.as_bytes()[0].is_ascii_digit() && name.bytes().all(is_ident) +} + /// Removes one borrow and a slice view from a compared operand. fn collection_operand(operand: &str) -> &str { let operand = operand.strip_prefix('&').unwrap_or(operand); operand.strip_suffix(".as_slice()").or_else(|| operand.strip_suffix("[..]")).unwrap_or(operand) } -/// Whether the whole operand is a non-empty array literal or `vec![…]`. -fn non_empty_literal(operand: &str) -> bool { +/// The length of an operand that is wholly an array literal or `vec![…]`, else 0. +fn literal_len(operand: &str, sizes: &Sizes) -> usize { let b = operand.strip_prefix("vec!").unwrap_or(operand).as_bytes(); - b.first() == Some(&b'[') && matching(b, 0) == Some(b.len() - 1) && non_empty_array(&b[1..b.len() - 1]) + if b.first() == Some(&b'[') && matching(b, 0) == Some(b.len() - 1) { array_len(&b[1..b.len() - 1], sizes) } else { 0 } } /// The length of a call's arguments in `rest`, the text after its `(`: up to its closing bracket. @@ -1318,13 +1533,13 @@ fn arg_end(rest: &str) -> usize { .unwrap_or(rest.len()) } -/// Whether `receiver` (the text before `.all(`) ends with a non-empty array literal, through `.iter()` or -/// `.into_iter()`. -fn on_array_literal(receiver: &str) -> bool { +/// The length of the array literal `receiver` (the text before `.all(`) ends with, through +/// `.iter()` or `.into_iter()`, or `None` when it does not end with one. +fn array_literal_len(receiver: &str, sizes: &Sizes) -> Option { let r = array_receiver(receiver); let b = r.as_bytes(); if b.last() != Some(&b']') { - return false; + return None; } let mut depth = 0usize; for (j, &c) in b.iter().enumerate().rev() { @@ -1334,13 +1549,13 @@ fn on_array_literal(receiver: &str) -> bool { depth = depth.saturating_sub(1); if depth == 0 { let literal = !j.checked_sub(1).and_then(|k| b.get(k)).is_some_and(|&p| is_ident(p) || matches!(p, b')' | b']' | b'.')); - return literal && non_empty_array(&b[j + 1..b.len() - 1]); + return literal.then(|| array_len(&b[j + 1..b.len() - 1], sizes)); } } _ => {} } } - false + None } /// Removes the iterator method from an array receiver. @@ -1348,68 +1563,455 @@ fn array_receiver(receiver: &str) -> &str { receiver.strip_suffix(".iter()").or_else(|| receiver.strip_suffix(".into_iter()")).unwrap_or(receiver) } -/// Whether a plain local receiver's latest preceding binding initializes a non-empty array. -fn on_bound_array(receiver: &str, body: &[u8]) -> bool { - let name = array_receiver(receiver).as_bytes(); - if name.is_empty() || name[0].is_ascii_digit() || !name.iter().copied().all(is_ident) { - return false; +/// The fewest items a plain local receiver has after its latest preceding binding: from the +/// binding ([`array_binding`]) or a loop that fills it ([`loop_fill_len`]), and 0 when a later +/// statement may shrink or replace it ([`may_shrink`]). +fn bound_len(receiver: &str, body: &[u8], sizes: &Sizes) -> usize { + let name = array_receiver(receiver); + if !plain_local(name) { + return 0; } - words(body, b"let", 0, body.len()).into_iter().rev().find_map(|at| array_binding(&body[at + 3..], name)).unwrap_or(false) + let name = name.as_bytes(); + let Some((len, end)) = words(body, b"let", 0, body.len()).into_iter().rev().find_map(|at| array_binding(body, at, name, sizes)) else { + return 0; + }; + if may_shrink(body, name, end) { + return 0; + } + len.max(loop_fill_len(body, name, end, sizes)) } -/// Checks a named binding, allowing `mut` and an array type annotation. -fn array_binding(mut rest: &[u8], name: &[u8]) -> Option { - rest = rest.trim_ascii_start(); - if rest.starts_with(b"mut") && rest.get(3).is_some_and(u8::is_ascii_whitespace) { - rest = rest[3..].trim_ascii_start(); +/// For a `let` at `at` that binds `name` (allowing `mut`): the fewest items its array type +/// annotation gives (which decides when there is one), else its initializer gives ([`expr_len`]), +/// and where the statement ends. `None` for a binding of another name. +fn array_binding(body: &[u8], at: usize, name: &[u8], sizes: &Sizes) -> Option<(usize, usize)> { + let mut at = skip_ws(body, at + 3); + if body[at..].starts_with(b"mut") && body.get(at + 3).is_some_and(u8::is_ascii_whitespace) { + at = skip_ws(body, at + 3); } - let end = rest.iter().copied().take_while(|&c| is_ident(c)).count(); - if &rest[..end] != name { + let end = at + body[at..].iter().copied().take_while(|&c| is_ident(c)).count(); + if &body[at..end] != name { return None; } - rest = rest[end..].trim_ascii_start(); - if let Some(annotation) = rest.strip_prefix(b":") { - let annotation = annotation.trim_ascii_start(); - let close = (annotation.first() == Some(&b'[')).then(|| matching(annotation, 0)).flatten(); - let Some(close) = close else { return Some(false) }; - rest = annotation[close + 1..].trim_ascii_start(); + let stop = statement_end(body, end); + let stmt = &body[end..stop]; + let eq = (0..stmt.len()).find(|&i| { + stmt[i] == b'=' + && !matches!(stmt.get(i + 1), Some(b'=' | b'>')) + && !matches!(i.checked_sub(1).map(|j| stmt[j]), Some(b'=' | b'!' | b'<' | b'>')) + }); + let (annotation, init) = match eq { + Some(eq) => (&stmt[..eq], Some(&stmt[eq + 1..])), + None => (stmt, None), + }; + let annotation = norm(annotation); + if let Some(ty) = annotation.strip_prefix(':') + && ty.starts_with('[') + && matching(ty.as_bytes(), 0) == Some(ty.len() - 1) + { + return Some((repeat_count(&ty.as_bytes()[1..ty.len() - 1], sizes).unwrap_or(0), stop)); } - Some(rest.strip_prefix(b"=").is_some_and(array_initializer)) + Some((init.map_or(0, |init| expr_len(&norm(init), sizes, annotation.strip_prefix(':').unwrap_or(""))), stop)) } -/// Whether an initializer is a non-empty array literal, optionally followed by one `.map(…)`. -fn array_initializer(rest: &[u8]) -> bool { - let rest = rest.trim_ascii_start(); - let Some(close) = (rest.first() == Some(&b'[')).then(|| matching(rest, 0)).flatten() else { return false }; - if !non_empty_array(&rest[1..close]) { - return false; - } - let tail = rest[close + 1..].trim_ascii_start(); - if tail.starts_with(b";") { - return true; - } - let compact = norm(tail); - if !compact.starts_with(".map(") { - return false; - } - let Some(close) = matching(compact.as_bytes(), 4) else { return false }; - compact[close + 1..].starts_with(';') -} - -/// Whether an array's masked contents have an element and, for repetition, a positive literal count. -fn non_empty_array(contents: &[u8]) -> bool { - let mut at = 0; - while at < contents.len() { - match contents[at] { - b';' => return norm(&contents[at + 1..]).parse::().is_ok_and(|count| count > 0), - b'(' | b'[' | b'{' => { - let Some(close) = matching(contents, at) else { return false }; - at = close + 1; - } +/// The index of the `;` that ends the statement starting at `from`, outside brackets, or the +/// end of `body`. +fn statement_end(body: &[u8], from: usize) -> usize { + let mut at = from; + while at < body.len() { + match body[at] { + b';' => return at, + b'(' | b'[' | b'{' => match matching(body, at) { + Some(close) => at = close + 1, + None => return body.len(), + }, _ => at += 1, } } - !contents.trim_ascii().is_empty() + body.len() +} + +/// The fewest items a (masked, whitespace-free) expression yields: an array literal or `vec![…]`, +/// a literal range, either followed only by methods that keep at least one item of a non-empty +/// input (`map`, `iter`, `into_iter`, `cloned`, `copied`, `enumerate`, `rev`, `chain`, `to_vec`, +/// `to_owned`, `clone`, and `collect` into a known collection or `step_by`, after which at least +/// one is known). Only a final `collect` without a turbofish can use the binding's type. 0 for +/// anything else. +fn expr_len(e: &str, sizes: &Sizes, binding_type: &str) -> usize { + let e = e.strip_prefix("vec!").unwrap_or(e); + let b = e.as_bytes(); + let (mut n, mut rest) = match b.first() { + Some(b'[') => { + let Some(close) = matching(b, 0) else { return 0 }; + (array_len(&b[1..close], sizes), &e[close + 1..]) + } + Some(b'(') => { + let Some(close) = matching(b, 0) else { return 0 }; + (range_len(&e[1..close], sizes), &e[close + 1..]) + } + _ => return range_len(e, sizes), + }; + while !rest.is_empty() { + let Some(tail) = rest.strip_prefix('.') else { return 0 }; + let end = tail.bytes().take_while(|&c| is_ident(c)).count(); + let method = &tail[..end]; + let mut open = end; + if tail[open..].starts_with("::<") { + let mut depth = 0usize; + let Some(close) = tail[open + 2..].bytes().position(|c| { + depth = match c { + b'<' => depth + 1, + b'>' => depth.saturating_sub(1), + _ => depth, + }; + depth == 0 + }) else { + return 0; + }; + open += 2 + close + 1; + } + if tail.as_bytes().get(open) != Some(&b'(') { + return 0; + } + let Some(close) = matching(tail.as_bytes(), open) else { return 0 }; + match method { + "map" | "iter" | "into_iter" | "cloned" | "copied" | "enumerate" | "rev" | "chain" | "to_vec" | "to_owned" | "clone" => {} + "collect" => { + let target = if open > end { + &tail[end + 3..open - 1] + } else if close + 1 == tail.len() { + binding_type + } else { + "" + }; + if !known_collection(target) { + return 0; + } + n = n.min(1); + } + "step_by" => n = n.min(1), + _ => return 0, + } + rest = &tail[close + 1..]; + } + n +} + +/// The number of items in a range of integer literals or constants (`a..b`, `a..=b`); 0 for +/// anything else, an open range included. +fn range_len(e: &str, sizes: &Sizes) -> usize { + let (lo, hi, inclusive) = match e.split_once("..=") { + Some((lo, hi)) => (lo, hi, true), + None => match e.split_once("..") { + Some((lo, hi)) => (lo, hi, false), + None => return 0, + }, + }; + let value = |t: &str| match t.strip_prefix('-') { + Some(t) => sizes.count(t).and_then(|v| i128::try_from(v).ok()).map(|v| -v), + None => sizes.count(t).and_then(|v| i128::try_from(v).ok()), + }; + let (Some(lo), Some(hi)) = (value(lo), value(hi)) else { return 0 }; + let len = hi - lo + i128::from(inclusive); + usize::try_from(len).unwrap_or(0) +} + +/// The number of items in an array literal's masked contents: the count of a repetition, or the +/// elements of a list. +fn array_len(contents: &[u8], sizes: &Sizes) -> usize { + if let Some(count) = repeat_count(contents, sizes) { + return count; + } + if has_top_level(contents, b';') { + return 0; + } + split_args(contents, 0, contents.len()).len() +} + +/// The count of a repetition `[x; N]` (a literal or a `const` of the file), from its masked +/// contents; `None` when they are not a repetition, `Some(0)` when the count is not known. +fn repeat_count(contents: &[u8], sizes: &Sizes) -> Option { + let mut at = 0; + while at < contents.len() { + match contents[at] { + b';' => return Some(sizes.count(&norm(&contents[at + 1..])).unwrap_or(0)), + b'(' | b'[' | b'{' => at = matching(contents, at)? + 1, + _ => at += 1, + } + } + None +} + +/// Whether `c` occurs in `b` outside brackets. +fn has_top_level(b: &[u8], c: u8) -> bool { + let mut at = 0; + while at < b.len() { + match b[at] { + x if x == c => return true, + b'(' | b'[' | b'{' => match matching(b, at) { + Some(close) => at = close + 1, + None => return true, + }, + _ => at += 1, + } + } + false +} + +/// The fewest items a `for` loop after `from`, in the same block, adds to `name`: a loop over a +/// sized source ([`expr_len`]) whose own block (not a nested one) pushes or inserts into `name` +/// on every pass, with no `break`, `continue`, `return` or `?` in the loop. 0 when there is none. +fn loop_fill_len(body: &[u8], name: &[u8], from: usize, sizes: &Sizes) -> usize { + let mut best = 0; + for at in words(body, b"for", from, body.len()) { + if block_depth(&body[from..at]) != Some(0) { + continue; + } + let Some(&in_at) = words(body, b"in", at + 3, body.len()).first() else { continue }; + let Some(open) = (in_at + 2..body.len()).find(|&i| body[i] == b'{' && !has_open_bracket(&body[in_at + 2..i])) else { continue }; + let Some(close) = matching(body, open) else { continue }; + let source = expr_len(&norm(&body[in_at + 2..open]), sizes, ""); + let block = &body[open + 1..close]; + let exits = [&b"break"[..], b"continue", b"return"].iter().any(|w| !words(block, w, 0, block.len()).is_empty()) || contains(block, b"?"); + if source == 0 || exits { + continue; + } + let pushes = words(block, name, 0, block.len()).into_iter().any(|p| { + let before = block[..p].trim_ascii_end(); + let statement = matches!(before.last(), None | Some(b';' | b'{' | b'}')); + let call = norm(&block[p + name.len()..block.len().min(p + name.len() + 16)]); + statement && block_depth(&block[..p]) == Some(0) && [".push(", ".push_back(", ".insert("].iter().any(|m| call.starts_with(m)) + }); + if pushes { + best = best.max(source); + } + } + best +} + +/// The brace depth at the end of `b`, or `None` when it closes a block it did not open. +fn block_depth(b: &[u8]) -> Option { + let mut depth = 0usize; + for &c in b { + match c { + b'{' => depth += 1, + b'}' => depth = depth.checked_sub(1)?, + _ => {} + } + } + Some(depth) +} + +/// Whether `b` leaves a `(` or `[` open. +fn has_open_bracket(b: &[u8]) -> bool { + let mut depth = 0i32; + for &c in b { + match c { + b'(' | b'[' => depth += 1, + b')' | b']' => depth -= 1, + _ => {} + } + } + depth > 0 +} + +/// Whether code after `from` may remove items from `name` or replace it. +fn may_shrink(body: &[u8], name: &[u8], from: usize) -> bool { + may_change(body, name, from, true) +} + +/// Whether code after `from` may change the item count of `name`: an unknown method call, +/// an assignment, or a `&mut` borrow. Growth is harmless only for the source collection. +fn may_change(body: &[u8], name: &[u8], from: usize, allow_growth: bool) -> bool { + const PRESERVING: &[&str] = &[ + "iter", + "iter_mut", + "into_iter", + "len", + "is_empty", + "contains", + "get", + "get_mut", + "first", + "last", + "first_mut", + "last_mut", + "as_slice", + "as_ref", + "clone", + "to_vec", + "to_owned", + "windows", + "chunks", + "chunks_exact", + "sort", + "sort_by", + "sort_by_key", + "sort_unstable", + "sort_unstable_by", + "sort_unstable_by_key", + "reverse", + "binary_search", + "binary_search_by", + "binary_search_by_key", + "starts_with", + "ends_with", + "map", + "concat", + "join", + "keys", + "values", + ]; + const ADDING: &[&str] = &["push", "push_back", "push_front", "insert", "extend"]; + words(body, name, from, body.len()).into_iter().any(|p| { + let after = &body[skip_ws(body, p + name.len())..]; + let assigned = (after.starts_with(b"=") && !after.starts_with(b"==") && !after.starts_with(b"=>")) + || ["+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="].iter().any(|op| after.starts_with(op.as_bytes())); + let before = body[from..p].trim_ascii_end(); + let borrowed = before.strip_suffix(b"mut").is_some_and(|b| b.trim_ascii_end().ends_with(b"&")); + let called = if after.first() == Some(&b'.') { + let start = skip_ws(after, 1); + let end = start + after[start..].iter().copied().take_while(|&c| is_ident(c)).count(); + let rest = &after[skip_ws(after, end)..]; + let method = &after[start..end]; + (rest.starts_with(b"(") || rest.starts_with(b"::<")) + && !PRESERVING.iter().any(|m| method == m.as_bytes()) + && !(allow_growth && ADDING.iter().any(|m| method == m.as_bytes())) + } else { + false + }; + assigned || borrowed || called + }) +} + +/// The length of a field the file declares as an array of a positive length (`name: [T; N]`), +/// for a receiver `….name`. 0 when any other `name:` in the file may start a type: anything but +/// an array, a lowercase name that is not a path or a primitive type (a value in a struct +/// expression), or a literal. +fn field_len(receiver: &str, sizes: &Sizes) -> usize { + let Some((owner, field)) = receiver.rsplit_once('.') else { return 0 }; + if owner.is_empty() || !plain_local(field) { + return 0; + } + const PRIMITIVE: &[&str] = &[ + "u8", "u16", "u32", "u64", "u128", "usize", "i8", "i16", "i32", "i64", "i128", "isize", "f32", "f64", "bool", "char", "str", "dyn", "impl", + "fn", "mut", "crate", "self", "super", + ]; + let file = sizes.file; + let mut least: Option = None; + for at in words(file, field.as_bytes(), 0, file.len()) { + let colon = skip_ws(file, at + field.len()); + if file.get(colon) != Some(&b':') || file.get(colon + 1) == Some(&b':') || at.checked_sub(1).is_some_and(|j| file[j] == b':') { + continue; + } + let ty = skip_ws(file, colon + 1); + let word_end = ty + file[ty..].iter().copied().take_while(|&c| is_ident(c)).count(); + let word = &file[ty..word_end]; + let value = match file.get(ty) { + Some(b'[') => false, + Some(c) if c.is_ascii_digit() || matches!(c, b'"' | b'\'' | b'-') => true, + Some(c) if c.is_ascii_lowercase() || *c == b'_' => { + let path = file[skip_ws(file, word_end)..].starts_with(b"::"); + !path && !PRIMITIVE.iter().any(|p| p.as_bytes() == word) + } + _ => return 0, + }; + if value { + continue; + } + let Some(close) = matching(file, ty) else { return 0 }; + match repeat_count(&file[ty + 1..close], sizes) { + Some(n) if n > 0 => least = Some(least.map_or(n, |l| l.min(n))), + Some(_) => return 0, + None => {} + } + } + least.unwrap_or(0) +} + +/// What the rules know about collection sizes in one masked file: its `const` counts, read on first use. +struct Sizes<'a> { + file: &'a [u8], + consts: OnceCell>, +} + +impl Sizes<'_> { + /// An unsigned integer literal (with `_` and an integer suffix allowed) or a `const` of the + /// file whose value is one. + fn count(&self, text: &str) -> Option { + int_literal(text).or_else(|| self.consts.get_or_init(|| file_consts(self.file)).get(text).copied()) + } +} + +fn int_literal(text: &str) -> Option { + let digits = text.bytes().take_while(|c| c.is_ascii_digit() || *c == b'_').count(); + let suffix = &text[digits..]; + let suffixes = ["", "u8", "u16", "u32", "u64", "u128", "usize", "i8", "i16", "i32", "i64", "i128", "isize"]; + if digits == 0 || !text.as_bytes()[0].is_ascii_digit() || !suffixes.contains(&suffix) { + return None; + } + text[..digits].replace('_', "").parse().ok() +} + +/// `const NAME: T = ;` in a masked file; a name declared more than once keeps +/// its smallest value, and 0 when one of its values is not a literal. +fn file_consts(file: &[u8]) -> HashMap { + let mut out: HashMap = HashMap::new(); + for at in words(file, b"const", 0, file.len()) { + let start = skip_ws(file, at + 5); + let end = start + file[start..].iter().copied().take_while(|&c| is_ident(c)).count(); + if end == start || skip_ws(file, end) >= file.len() || file[skip_ws(file, end)] != b':' { + continue; + } + let stop = statement_end(file, end); + let stmt = norm(&file[end..stop]); + let Some((_, value)) = stmt.split_once('=') else { continue }; + let value = int_literal(value).unwrap_or(0); + let name = String::from_utf8_lossy(&file[start..end]).into_owned(); + let slot = out.entry(name).or_insert(value); + *slot = (*slot).min(value); + } + out +} + +/// A `let` of a plain name: the name, where the statement ends, and whether it binds an expression +/// that checks a size ([`SIZE_CHECKS`]). +struct Binding { + name: Vec, + end: usize, + counts: bool, +} + +/// Every `let` of a plain name in `body`, in order. +fn bindings(body: &[u8]) -> Vec { + words(body, b"let", 0, body.len()) + .into_iter() + .filter_map(|at| { + let mut start = skip_ws(body, at + 3); + if body[start..].starts_with(b"mut") && body.get(start + 3).is_some_and(u8::is_ascii_whitespace) { + start = skip_ws(body, start + 3); + } + let end = start + body[start..].iter().copied().take_while(|&c| is_ident(c)).count(); + if end == start || body[start].is_ascii_digit() { + return None; + } + let stop = statement_end(body, end); + let stmt = norm(&body[end..stop]); + let counts = stmt.split_once('=').is_some_and(|(_, init)| SIZE_CHECKS.iter().any(|g| init.contains(g))); + Some(Binding { name: body[start..end].to_vec(), end: stop, counts }) + }) + .collect() +} + +/// Whether `body[from..to]` (an assertion operand) reads a local whose binding reaching that +/// point checks a size and was not assigned since. +fn reads_counted_local(body: &[u8], all: &[Binding], from: usize, to: usize) -> bool { + all.iter().filter(|b| b.counts && b.name != b"_").any(|b| { + words(body, &b.name, from, to).into_iter().any(|p| { + let reaching = all.iter().rfind(|o| o.name == b.name && o.end <= p); + reaching.is_some_and(|r| r.counts && !may_shrink(&body[..p], &r.name, r.end)) + }) + }) } /// Whether an assertion's (masked, whitespace-free) condition only says that there is a value. @@ -1803,7 +2405,7 @@ mod tests { let src = format!("#[test]\nfn t() {{\n assert_eq!(xs, {expected});\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); assert_eq!(hits(&src), [(4, "all-unguarded")], "{expected}"); } - for operand in ["ys", "xs_other", "other.xs", "other::xs", "xs()", "xs.clone()", "xs[1..]", "&&xs"] { + for operand in ["ys", "xs_other", "other.xs", "other::xs", "xs()", "xs.filter(f)", "xs.iter().filter(f).collect()", "xs[1..]", "&&xs"] { let src = format!("#[test]\nfn t() {{\n assert_eq!({operand}, [1]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); assert_eq!(hits(&src), [(4, "all-unguarded")], "{operand}"); } @@ -1913,12 +2515,23 @@ mod tests { "[]", "[1; 0]", "[1; 0].map(|x| x + 1)", - "vec![1, 2]", + "vec![]", + "vec![1; 0]", + "vec![1; n]", "items()", "items().collect()", + "items().collect::>()", + "(0..0).collect::>()", + "(3..1).collect::>()", + "(0..n).collect::>()", + "(0..).take(3).collect::>()", + "[1, 2].iter().filter(|x| keep(x)).collect::>()", + "[1, 2].into_iter().zip(ys).collect::>()", + "[None::].into_iter().collect::>>()", + "[Err::(error())].into_iter().collect::, E>>()", "[1, 2].into_iter().collect()", - "[1, 2].map(|x| x + 1).into_iter().collect()", - "[1, 2].map(|x| x + 1).map(|x| x + 1)", + "[1, 2].into_iter().collect::()", + "[1, 2].into_iter().collect::>()", ] { for binding in [format!("let xs = {value};"), format!("let mut xs = {value};"), format!("let xs: [u8; 0] = {value};")] { let src = format!("#[test]\nfn t() {{\n {binding}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); @@ -1976,6 +2589,333 @@ mod tests { } } + #[test] + fn all_skips_bindings_with_sized_initializers() { + let consts = "const N: usize = 3;\nconst NONE: usize = 0;\n"; + for binding in [ + "let xs = vec![1, 2];", + "let mut xs = vec![[1, 2]; 2];", + "let xs: Vec<_> = [1, 2].into_iter().collect();", + "let xs = [1, 2].map(|x| x + 1).map(|x| x + 1);", + "let xs: Vec = [1, 2].iter().copied().rev().collect();", + "let xs: Vec = (0..40u8).map(|n| px(n)).collect();", + "let xs = (1..=3).collect::>();", + "let xs = (-2..1).step_by(2).collect::>();", + "let xs: Vec<_> = (0..N).collect();", + "let xs: Vec<_> = [1, 2].into_iter().collect::>().into_iter().collect();", + "let xs = [0.0; N];", + "let xs: [u8; 3] = items();", + "let xs: [u8; N] = items();", + ] { + let src = format!("{consts}#[test]\nfn t() {{\n {binding}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{binding}"); + let cleared = src.replace("\n assert!", "\n xs.clear();\n assert!"); + assert_eq!(hits(&cleared), [(7, "all-unguarded")], "{binding} then cleared"); + } + for binding in [ + "let xs = (0..NONE).collect::>();", + "let xs = [0.0; NONE];", + "let xs: [u8; NONE] = [1];", + "let xs = (0..M).collect::>();", + "let xs = [None::].into_iter().collect::>>();", + "let xs = [Err::(error())].into_iter().collect::, E>>();", + "let xs: Option> = [1].into_iter().collect();", + "let xs: Result, E> = [1].into_iter().collect();", + "let xs = [1, 2].into_iter().collect();", + "let xs: Items = [1, 2].into_iter().collect();", + "let xs: Vec<_> = [1, 2].into_iter().collect().clone();", + "let xs: Vec<_> = [1, 2].into_iter().collect().into_iter().collect();", + "let xs: Vec<_> = [None::].into_iter().collect::>>().into_iter().collect();", + "let xs: Vec<_> = [1, 2].into_iter().collect::();", + ] { + let src = format!("{consts}#[test]\nfn t() {{\n {binding}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(6, "all-unguarded")], "{binding}"); + } + for later in [ + "xs.retain(|x| keep(x));", + "xs = items();", + "take(&mut xs);", + "xs.truncate(0);", + "xs.pop();", + "xs.resize(0, 0);", + "xs.resize_with(0, f);", + "xs.pop_front();", + "xs.pop_back();", + "xs.unknown_method_that_may_shrink();", + "xs . unknown::();", + ] { + let src = format!("#[test]\nfn t() {{\n let mut xs = vec![1, 2];\n {later}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(5, "all-unguarded")], "{later}"); + } + for op in ["+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="] { + let src = + format!("#[test]\nfn t() {{\n let mut xs = vec![1, 2];\n xs {op} other;\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(5, "all-unguarded")], "{op}"); + } + for later in [ + "xs[0] = 5; use_it(&xs);", + "xs[1] = 5; use_it(&xs);", + "use_it(&xs);", + "use_it(xs);", + "use_it(xs == other);", + "match other { xs => use_it(xs), _ => () };", + "xs.push(3); xs.push_back(4); xs.push_front(5); xs.insert(0, 6); xs.extend(other);", + "xs.sort(); xs.sort_by(f); xs.sort_by_key(f); xs.sort_unstable(); xs.reverse();", + "use_it(xs.iter()); use_it(xs.iter_mut()); use_it(xs.into_iter());", + "use_it(xs.len()); use_it(xs.is_empty()); use_it(xs.contains(&1));", + "use_it(xs.get(0)); use_it(xs.get_mut(0)); use_it(xs.first()); use_it(xs.last());", + "use_it(xs.first_mut()); use_it(xs.last_mut()); use_it(xs.as_slice()); use_it(xs.as_ref());", + "use_it(xs.clone()); use_it(xs.to_vec()); use_it(xs.windows(2)); use_it(xs.chunks(2));", + "use_it(xs.binary_search(&1)); use_it(xs.starts_with(&[1])); use_it(xs.ends_with(&[2]));", + "use_it(xs.map(f)); use_it(xs.concat()); use_it(xs.join(sep)); use_it(xs.keys()); use_it(xs.values());", + ] { + let src = format!("#[test]\nfn t() {{\n let mut xs = vec![1, 2];\n {later}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{later}"); + } + } + + #[test] + fn all_collects_require_known_collection_targets() { + for target in [ + "Vec<_>", + "std::vec::Vec<_>", + "VecDeque<_>", + "std::collections::VecDeque<_>", + "HashSet<_>", + "std::collections::HashSet<_>", + "BTreeSet<_>", + "std::collections::BTreeSet<_>", + "HashMap<_, _>", + "std::collections::HashMap<_, _>", + "BTreeMap<_, _>", + "std::collections::BTreeMap<_, _>", + "BinaryHeap<_>", + "std::collections::BinaryHeap<_>", + "LinkedList<_>", + "std::collections::LinkedList<_>", + "String", + "std::string::String", + "Box<[_]>", + "std::boxed::Box<[_]>", + ] { + let source = if target.contains("Map") { "[(1, 2)]" } else { "['a', 'b']" }; + for binding in [ + format!("let xs = {source}.into_iter().collect::<{target}>();"), + format!("let xs: {target} = {source}.into_iter().collect();"), + format!("let xs = {source}.into_iter().collect::<{target}>().into_iter().collect::>();"), + ] { + let src = format!("#[test]\nfn t() {{\n {binding}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{binding}"); + } + } + } + + #[test] + fn all_skips_collections_every_pass_of_a_sized_loop_fills() { + for (source, fill) in [ + ("[1, 2, 3]", "xs.push(i);"), + ("0..3", "xs.push(i);"), + ("[[0, 1], [1, 0]]", "let s = Fill { a: 1 }.span(i);\n xs.push(s);"), + ("[1, 2].iter().enumerate()", "for j in items() { use_it(j); }\n xs.insert(i);"), + ] { + let src = format!( + "#[test]\nfn t() {{\n let mut xs = vec![];\n for i in {source} {{\n {fill}\n }}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n" + ); + let line = src.lines().position(|l| l.contains("assert!")).map_or(0, |p| p + 1); + assert_eq!(hits(&src), [], "{source}: {fill}"); + let after = src.replace("\n assert!", "\n xs.clear();\n assert!"); + assert_eq!(hits(&after), [(line + 1, "all-unguarded")], "{source} then cleared"); + } + for (source, fill) in [ + ("items()", "xs.push(i);"), + ("0..0", "xs.push(i);"), + ("0..n", "xs.push(i);"), + ("[1, 2]", "if keep(i) { xs.push(i); }"), + ("[1, 2]", "if !keep(i) { continue; }\n xs.push(i);"), + ("[1, 2]", "let v = get(i)?;\n xs.push(v);"), + ("[1, 2]", "ys.iter().for_each(|y| xs.push(*y));"), + ("[1, 2]", "ys.push(i);"), + ("[1, 2]", "let mut xs = vec![];\n xs.push(i);"), + ("[1, 2].iter().filter(|x| keep(x))", "xs.push(i);"), + ] { + let src = format!( + "#[test]\nfn t() {{\n let mut xs = vec![];\n for i in {source} {{\n {fill}\n }}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n" + ); + let line = src.lines().position(|l| l.contains("assert!")).map_or(0, |p| p + 1); + assert_eq!(hits(&src), [(line, "all-unguarded")], "{source}: {fill}"); + } + let nested = "#[test]\nfn t() {\n let mut xs = vec![];\n if ready() {\n for i in [1, 2] {\n xs.push(i);\n }\n }\n assert!(xs.iter().all(|x| valid(x)));\n}\n"; + assert_eq!(hits(nested), [(9, "all-unguarded")], "a loop that may not run"); + } + + #[test] + fn all_skips_fields_the_file_declares_as_arrays() { + let test = "#[test]\nfn t() {\n let c = parse();\n assert!(c.rgb.iter().all(|v| (0.0..=1.0).contains(v)));\n}\n"; + for decl in [ + "struct C { rgb: [f32; 3] }\n", + "const N: usize = 3;\nstruct C { pub rgb: [f32; N], alpha: Option }\n", + "struct C { rgb: [f32; 3] }\nfn c() -> C { C { rgb: rgb_of(\"x\"), alpha: 1 } }\n", + ] { + let src = format!("{decl}{test}"); + let line = src.lines().position(|l| l.contains("assert!")).map_or(0, |p| p + 1); + assert_eq!(hits(&src), [], "{decl}"); + let other = format!("{decl}struct D {{ rgb: Vec }}\n{test}"); + assert_eq!(hits(&other), [(line + 1, "all-unguarded")], "another struct's rgb can be empty"); + } + for decl in + ["struct C { rgb: [f32; 0] }\n", "struct C { rgb: &'static [f32] }\n", "struct C { rgb: [f32; LEN] }\n", "struct C { other: [f32; 3] }\n"] + { + let src = format!("{decl}{test}"); + assert_eq!(hits(&src), [(5, "all-unguarded")], "{decl}"); + } + for other in ["std::vec::Vec", "Pixels", "u8", "(f32, f32)", "T"] { + let src = format!("struct C {{ rgb: [f32; 3] }}\nstruct D {{ rgb: {other} }}\n{test}"); + assert_eq!(hits(&src), [(6, "all-unguarded")], "another struct's rgb is {other}"); + } + let local = "struct C { rgb: [f32; 3] }\n#[test]\nfn t() {\n let rgb = parse();\n assert!(rgb.iter().all(|v| valid(v)));\n}\n"; + assert_eq!(hits(local), [(5, "all-unguarded")], "a local name is not the field"); + } + + #[test] + fn all_equality_guards_follow_methods_that_keep_items() { + for operand in [ + "xs.clone()", + "xs.iter().map(|l| l.0).collect()", + "xs.iter().copied().collect::>().into_iter().collect()", + "xs.iter().map(|l| l.0).collect::>()", + "&xs.iter().copied().rev().collect::>()", + ] { + let src = format!("#[test]\nfn t() {{\n assert_eq!({operand}, vec![0, 7]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{operand}"); + let cleared = src.replace("\n assert!", "\n xs.clear();\n assert!"); + assert_eq!(hits(&cleared), [(5, "all-unguarded")], "{operand} then cleared"); + } + for (binding, compared) in [ + ("let ids: Vec<&str> = xs.iter().map(|l| l.id()).collect();", "assert_eq!(ids, [\"a\", \"b\"]);"), + ("let ids = xs.iter().cloned().collect::>();", "assert_eq!([\"a\"], ids);"), + ("let ids = xs.iter().copied().collect::>();", "assert_eq!(ids, [1]);"), + ("let ids: Vec<_> = xs.iter().copied().collect::>().into_iter().collect();", "assert_eq!(ids, [1]);"), + ] { + let src = format!("#[test]\nfn t() {{\n {binding}\n {compared}\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [], "{binding}"); + let filtered = src.replace(binding, &binding.replace(".iter()", ".iter().filter(|x| keep(x))")); + assert_eq!(hits(&filtered), [(5, "all-unguarded")], "{binding} through a filter"); + let rebound = src.replace(&format!(" {compared}\n"), &format!(" let ids = other();\n {compared}\n")); + assert_eq!(hits(&rebound), [(6, "all-unguarded")], "{binding} then bound again"); + for change in ["ids = vec![1];", "ids.clear();", "reset(&mut ids);", "ids.push(1);"] { + let reassigned = + src.replace("let ids", "let mut ids").replace(&format!(" {compared}\n"), &format!(" {change}\n {compared}\n")); + assert_eq!(hits(&reassigned), [(6, "all-unguarded")], "{binding} then {change}"); + } + let cleared = src.replace("\n assert!", "\n xs.clear();\n assert!"); + assert_eq!(hits(&cleared), [(6, "all-unguarded")], "{binding} then the source cleared"); + } + } + + #[test] + fn all_equality_guards_stop_at_other_collect_targets() { + for operand in [ + "xs.iter().copied().collect().into_iter().collect::>()", + "xs.iter().copied().collect().into_iter().collect()", + "xs.iter().copied().collect().clone()", + ] { + for compared in [format!("{operand}, [vec![]]"), format!("[vec![]], {operand}")] { + let src = format!("#[test]\nfn t() {{\n assert_eq!({compared});\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&src), [(4, "all-unguarded")], "{compared}"); + } + } + for binding in [ + "let ids: Option> = xs.iter().copied().collect();", + "let ids: Result, E> = xs.iter().copied().collect();", + "let ids: Items = xs.iter().copied().collect();", + "let ids = xs.iter().copied().collect();", + "let ids: Vec<_> = xs.iter().copied().collect().into_iter().collect();", + "let ids: Vec<_> = xs.iter().copied().collect().into_iter().collect::>();", + "let ids: Vec<_> = xs.iter().copied().collect().clone();", + ] { + let src = format!( + "#[test]\nfn t() {{\n {binding}\n assert_eq!(ids.into_iter().collect::>(), [vec![]]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n" + ); + assert_eq!(hits(&src), [(5, "all-unguarded")], "{binding}"); + } + for target in ["Option>", "Result, E>", "Items"] { + let operand = format!("xs.iter().copied().collect::<{target}>().iter().collect::>()"); + let direct = format!("#[test]\nfn t() {{\n assert_eq!({operand}, [vec![]]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n"); + assert_eq!(hits(&direct), [(4, "all-unguarded")], "{target} compared directly"); + let derived = format!( + "#[test]\nfn t() {{\n let ids = {operand};\n assert_eq!(ids, [vec![]]);\n assert!(xs.iter().all(|x| valid(x)));\n}}\n" + ); + assert_eq!(hits(&derived), [(5, "all-unguarded")], "{target} through a local"); + } + } + + #[test] + fn all_skips_const_and_static_arrays_of_the_file() { + let test = "#[test]\nfn t() {\n assert!(NAMES.iter().all(|n| valid(n)));\n}\n"; + for decl in [ + "const NAMES: [&str; 2] = [\"a\", \"b\"];\n", + "static NAMES: [u8; N] = [0; N];\nconst N: usize = 4;\n", + "pub(crate) static mut NAMES: [u8; 1] = [0];\n", + ] { + let src = format!("{decl}{test}"); + assert_eq!(hits(&src), [], "{decl}"); + } + for decl in ["const NAMES: [&str; 0] = [];\n", "const NAMES: &[&str] = &[\"a\"];\n", "fn my_const() {}\nlet NAMES: [u8; 2] = f();\n", ""] { + let src = format!("{decl}{test}"); + let line = src.lines().position(|l| l.contains("assert!")).map_or(0, |p| p + 1); + assert_eq!(hits(&src), [(line, "all-unguarded")], "{decl}"); + } + let shadowed = "const NAMES: [&str; 2] = [\"a\", \"b\"];\n#[test]\nfn t() {\n let NAMES = items();\n assert!(NAMES.iter().all(|n| valid(n)));\n}\n"; + assert_eq!(hits(shadowed), [(5, "all-unguarded")], "a local of the same name"); + for (other_type, other_value, found) in [("[u8; 0]", "[]", true), ("&[u8]", "&[]", true), ("[u8; 3]", "[0; 3]", false)] { + for (first_type, first_value, second_type, second_value) in + [("[u8; 2]", "[0; 2]", other_type, other_value), (other_type, other_value, "[u8; 2]", "[0; 2]")] + { + let src = format!( + "mod a {{ const CASES: {first_type} = {first_value}; }}\nmod b {{\nconst CASES: {second_type} = {second_value};\n#[test]\nfn t() {{\n assert!(CASES.iter().all(|n| valid(n)));\n}}\n}}\n" + ); + let want: &[(usize, &str)] = if found { &[(6, "all-unguarded")] } else { &[] }; + assert_eq!(hits(&src), want, "{first_type} and {second_type}"); + } + } + } + + #[test] + fn all_windows_need_as_many_items_as_their_size() { + for (array, method, found) in [ + ("[a, b, c, d]", "windows(2)", false), + ("[a, b]", "windows(2)", false), + ("[a]", "windows(2)", true), + ("[a, b]", "windows(k)", true), + ("[a]", "chunks(3)", false), + ("[a, b]", "chunks_exact(3)", true), + ("[a, b, c]", "chunks_exact(3)", false), + ] { + let src = + format!("#[test]\nfn t() {{\n let xs = {array}.map(|s| node(s));\n assert!(xs.{method}.all(|w| w[0].y == w[1].y));\n}}\n"); + let want: &[(usize, &str)] = if found { &[(4, "all-unguarded")] } else { &[] }; + assert_eq!(hits(&src), want, "{array}.{method}"); + } + } + + #[test] + fn all_guards_accept_asserted_locals_that_count() { + let src = "#[test]\nfn t() {\n let row = cards.iter().filter(|c| first_row(c)).count();\n assert_eq!(row, 4, \"four cards\");\n assert!(cards.iter().all(|c| c.x < 10));\n}\n"; + assert_eq!(hits(src), []); + let summed = src.replace(".count()", ".map(|c| c.w).sum::()"); + assert_eq!(hits(&summed), [(5, "all-unguarded")], "a sum does not count items"); + let message = src.replace("assert_eq!(row, 4, \"four cards\")", "assert_eq!(a, b, \"{}\", row)"); + assert_eq!(hits(&message), [(5, "all-unguarded")], "a count in a failure message checks nothing"); + let unused = src.replace(" assert_eq!(row, 4, \"four cards\");\n", ""); + assert_eq!(hits(&unused), [(4, "all-unguarded")], "a count no assertion reads checks nothing"); + for change in ["let row = 4;", "row = 4;", "reset(&mut row);"] { + let changed = src.replace(" assert_eq!(row", &format!(" {change}\n assert_eq!(row")); + assert_eq!(hits(&changed), [(6, "all-unguarded")], "{change} before the assertion"); + } + let later = src.replace(" assert_eq!(row, 4, \"four cards\");\n", " assert_eq!(row, 4);\n let row = 4;\n"); + assert_eq!(hits(&later), [], "the count reaches the assertion before it is bound again"); + } + #[test] fn all_respects_condition_polarity() { for condition in [ @@ -2513,6 +3453,22 @@ mod tests { assert_eq!(found.iter().filter(|h| touches(h, Some(&BTreeSet::new()))).count(), 0); } + #[test] + fn only_failing_rules_fail_the_check() { + let failing: Vec<&str> = Rule::ALL.into_iter().filter(|r| r.fails()).map(Rule::id).collect(); + assert_eq!(failing, ["only-weak", "self-compare", "ignore-without-reason", "sleep"]); + let weak = "#[test]\nfn weak() {\n assert!(f().is_ok());\n}\n"; + let unguarded = "#[test]\nfn all() {\n assert!(f().iter().all(|x| valid(x)));\n}\n"; + let hits_of = |src: &str| lint_file("crates/x/src/tests.rs", src, &ctx()); + assert_eq!(finish(&hits_of(unguarded), 0, 1, "base"), Ok(()), "all-unguarded only reports"); + let both = hits_of(&format!("{weak}{unguarded}")); + assert_eq!(both.len(), 2); + let Err(message) = finish(&both, 0, 1, "base") else { panic!("only-weak fails the check") }; + assert!(message.starts_with("1 test-lint hit(s)"), "{message}"); + assert!(message.contains("[only-weak] `weak`") && !message.contains("[all-unguarded]"), "{message}"); + assert_eq!(finish(&[], 3, 1, "base"), Ok(())); + } + #[test] fn options_reject_unknown_and_repeated_arguments() { assert_eq!(Options::parse(&[]), Ok(Options::default())); From 8df3fd17ac54c05e22c870be04d72891723bd2b7 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:53:24 +0100 Subject: [PATCH 219/264] Restore white artboards in Outline and the selection arrow over selected art --- crates/tools/src/cursor.rs | 2 ++ crates/tools/src/select.rs | 6 +++--- crates/tools/src/select/tests.rs | 18 +++++++++--------- crates/ui-egui/src/canvas/artboards.rs | 4 ++-- crates/ui-egui/src/canvas/artboards/tests.rs | 4 ++-- crates/ui-egui/src/cursors.rs | 2 ++ 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/crates/tools/src/cursor.rs b/crates/tools/src/cursor.rs index 0f654340fe..657287124c 100644 --- a/crates/tools/src/cursor.rs +++ b/crates/tools/src/cursor.rs @@ -17,6 +17,8 @@ pub enum Cursor { GroupSelection, /// Alt-dragging a copy with the Selection or Direct Selection tool: a double arrowhead. SelectionCopy, + /// The Selection arrow over movable artwork. + SelectionMove, Move, Crosshair, ResizeH, diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 4e3f2c16f9..1d7bd558e0 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -1552,7 +1552,7 @@ impl Tool for SelectionTool { // take the pointer too (on a thin box the centre lies within a handle's reach), and with // Cmd/Ctrl held the press selects the object behind instead. if near_selected && !m.cmd && hit_center(cx, p, cx.point_tol()).is_some() { - return Cursor::Move; + return Cursor::SelectionMove; } // View → Snap to Point: over an anchor a press would grab the object by, the arrow turns // hollow. @@ -1560,11 +1560,11 @@ impl Tool for SelectionTool { return Cursor::ArrowHollow; } if selected_source_hit(cx, p).is_some() { - return Cursor::Move; + return Cursor::SelectionMove; } if let Some(h) = hit_test(cx.doc, p, cx.selection_hit_options()) { if selected_under(cx, &h, h.top_object(cx.isolation)).is_some() || m.alt { - return Cursor::Move; + return Cursor::SelectionMove; } return Cursor::Arrow; } diff --git a/crates/tools/src/select/tests.rs b/crates/tools/src/select/tests.rs index 45bc30b47e..0ebda2c719 100644 --- a/crates/tools/src/select/tests.rs +++ b/crates/tools/src/select/tests.rs @@ -17,7 +17,7 @@ fn a_press_on_a_selected_shaper_source_moves_it_while_a_mask_is_edited() { let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) }; for x in [75.0, 125.0] { let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, Point::new(x, 350.0), Mods::default()), Cursor::Move, "at {x}"); + assert_eq!(t.cursor(&c, Point::new(x, 350.0), Mods::default()), Cursor::SelectionMove, "at {x}"); let down = t.pointer(&c, &ev(PointerKind::Down, x, 350.0)); assert!(!down.iter().any(|a| matches!(a, Action::Exec(c, _) if c == "select.set")), "at {x}: {down:?}"); let drag = t.pointer(&c, &ev(PointerKind::Drag, x + 20.0, 350.0)); @@ -45,7 +45,7 @@ fn a_selected_shaper_source_moves_after_other_objects_and_behind_front_art() { s.set([rect, ids[1]]); let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) }; let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::Move); + assert_eq!(t.cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::SelectionMove); let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 350.0)); assert!(!down.iter().any(|a| matches!(a, Action::Exec(c, _) if c == "select.set")), "{down:?}"); let drag = t.pointer(&c, &ev(PointerKind::Drag, 145.0, 350.0)); @@ -55,7 +55,7 @@ fn a_selected_shaper_source_moves_after_other_objects_and_behind_front_art() { d.insert(Some(layer), 2, Node::path(front, square, Appearance::default_art())).unwrap(); s.set([ids[1]]); let c = ToolContext { isolation: Some(layer), ..cx(&d, &s, &p) }; - assert_ne!(SelectionTool::default().cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::Move); + assert_ne!(SelectionTool::default().cursor(&c, Point::new(125.0, 350.0), Mods::default()), Cursor::SelectionMove); let down = SelectionTool::default().pointer(&c, &ev(PointerKind::Down, 125.0, 350.0)); assert!(down.iter().any(|a| matches!(a, Action::Exec(c, v) if c == "select.set" && v["ids"] == json!([front.0]))), "{down:?}"); } @@ -1042,7 +1042,7 @@ fn hidden_box_handles_take_no_press_while_anchors_are_selected() { s.anchors.entry(id).or_default().insert((0, 1)); let c = cx(&d, &s, &p); let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, top_middle, Mods::default()), Cursor::Move); + assert_eq!(t.cursor(&c, top_middle, Mods::default()), Cursor::SelectionMove); let down = t.pointer(&c, &ev(PointerKind::Down, 150.0, 100.0)); assert!(!down.contains(&Action::Begin("Scale".into())), "{down:?}"); assert!(!crate::select::bbox_handle_at(&c, top_middle)); @@ -3006,9 +3006,9 @@ fn a_press_on_the_centre_point_moves_an_unfilled_shape() { let c = ToolContext { path_only: true, ..cx(&d, &s, &p) }; let centre = Point::new(150.0, 150.0); let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, centre, Mods::default()), Cursor::Move); + assert_eq!(t.cursor(&c, centre, Mods::default()), Cursor::SelectionMove); // Cmd/Ctrl selects the object behind, not the centre point, so the pointer says neither. - assert_ne!(t.cursor(&c, centre, Mods { cmd: true, ..Mods::default() }), Cursor::Move); + assert_ne!(t.cursor(&c, centre, Mods { cmd: true, ..Mods::default() }), Cursor::SelectionMove); assert!(t.pointer(&c, &ev(PointerKind::Down, centre.x, centre.y)).is_empty()); let a = t.pointer(&c, &ev(PointerKind::Drag, 170.0, 160.0)); assert_eq!(a.first(), Some(&Action::Begin("Move".into())), "{a:?}"); @@ -3102,7 +3102,7 @@ fn a_ruler_guide_under_the_centre_point_keeps_the_pointer() { assert!(hit_center(&c, centre, c.point_tol()).is_some()); let mut t = SelectionTool::default(); let cursor = t.cursor(&c, centre, Mods::default()); - assert_ne!(cursor, Cursor::Move, "the guide's cursor, not the move arrow"); + assert_ne!(cursor, Cursor::SelectionMove, "the guide's cursor, not the move arrow"); let down = t.pointer(&c, &ev(PointerKind::Down, centre.x, centre.y)); let drag = t.pointer(&c, &ev(PointerKind::Drag, 170.0, 150.0)); assert!(drag.iter().any(|a| matches!(a, Action::Preview(cmd, _) if cmd == "guide.move")), "the guide drags: {down:?} {drag:?}"); @@ -3177,7 +3177,7 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() { s.set(picked.iter().copied()); let c = cx(&d, &s, &p); let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "{picked:?}"); + assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::SelectionMove, "{picked:?}"); let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0)); assert!(!is_select(&down), "{picked:?}: {down:?}"); let drag = t.pointer(&c, &ev(PointerKind::Drag, 145.0, 125.0)); @@ -3218,7 +3218,7 @@ fn a_press_on_a_selected_member_of_a_group_moves_the_selected_members() { s.anchors.insert(a, [(0, 0), (0, 1), (0, 2), (0, 3)].into_iter().collect()); let c = cx(&d, &s, &p); let mut t = SelectionTool::default(); - assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::Move, "every anchor"); + assert_eq!(t.cursor(&c, Point::new(125.0, 125.0), Mods::default()), Cursor::SelectionMove, "every anchor"); let down = t.pointer(&c, &ev(PointerKind::Down, 125.0, 125.0)); assert!(!is_select(&down), "every anchor: {down:?}"); } diff --git a/crates/ui-egui/src/canvas/artboards.rs b/crates/ui-egui/src/canvas/artboards.rs index 605e7108d2..a6181ea805 100644 --- a/crates/ui-egui/src/canvas/artboards.rs +++ b/crates/ui-egui/src/canvas/artboards.rs @@ -31,7 +31,7 @@ pub(super) fn checker_of(setup: &vectorcraft_doc::DocSetup) -> Checker { } /// The page frames of document `st` seen through `view`: one per artboard, named "01 - name" with the -/// Artboard tool or several boards, filled with its paper or the transparency grid (nothing in Outline). +/// Artboard tool or several boards, filled with its paper or the transparency grid (white in Outline). /// Empty while the artboards are hidden. pub(super) fn frames(app: &VectorcraftApp, st: &vectorcraft_engine::DocState, view: &View, outline: bool) -> Vec { if !shows_artboards(app) { @@ -51,7 +51,7 @@ pub(super) fn frames(app: &VectorcraftApp, st: &vectorcraft_engine::DocState, vi frame = frame.name(format!("{:02} - {}", i + 1, ab.name)); } if outline { - frame + frame.fill(DataColor::new(Color32::WHITE)) } else if grid { frame.checker(checker_of(setup)) } else { diff --git a/crates/ui-egui/src/canvas/artboards/tests.rs b/crates/ui-egui/src/canvas/artboards/tests.rs index 742e798e63..662f46db4a 100644 --- a/crates/ui-egui/src/canvas/artboards/tests.rs +++ b/crates/ui-egui/src/canvas/artboards/tests.rs @@ -47,13 +47,13 @@ fn shift_clicking_a_name_toggles_selection_and_a_plain_click_activates() { } #[test] -fn outline_has_a_white_canvas_line_edges_and_no_paper() { +fn outline_has_white_artboards_on_a_white_canvas_with_line_edges() { let _view = crate::testing::DefaultProofView::new(); let app = app_with(2); let st = app.session.active().unwrap(); assert_eq!(pasteboard_color(&app, st, true), PasteboardColor::Custom(DataColor::new(Color32::WHITE))); assert_eq!(border(true), PageBorder::Line); - assert!(frames_of(&app, true).iter().all(|f| f.fill.is_none())); + assert!(frames_of(&app, true).iter().all(|f| f.fill == Some(PageFill::Color(DataColor::new(Color32::WHITE))))); assert_eq!(pasteboard_color(&app, st, false), PasteboardColor::Default); assert_eq!(border(false), PageBorder::DropShadow); assert!(frames_of(&app, false).iter().all(|f| f.fill.is_some())); diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rs index 2f9c594ab7..e97016dff1 100644 --- a/crates/ui-egui/src/cursors.rs +++ b/crates/ui-egui/src/cursors.rs @@ -89,6 +89,7 @@ pub fn tool_cursor(c: Cursor) -> cb::Cursor { Cursor::DirectAnchorSelected => tool("cursor-direct-anchor-selected", TIP, None), Cursor::ReshapeSegment => tool("cursor-reshape-segment", TIP, None), Cursor::GroupSelection => badged(CursorBadge::Add), + Cursor::SelectionMove => badged(CursorBadge::Move), Cursor::SelectionCopy => badged(CursorBadge::Copy), Cursor::Move => system(CursorIcon::Move), Cursor::Crosshair => PaintedCursor::Crosshair.into(), @@ -207,6 +208,7 @@ const GLYPHS: [Cursor; 99] = [ Cursor::ReshapeSegment, Cursor::GroupSelection, Cursor::SelectionCopy, + Cursor::SelectionMove, Cursor::Move, Cursor::Crosshair, Cursor::ResizeH, From b06d1d9af3ca832f61ce4ca65bae5e838442da76 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 13:59:34 +0100 Subject: [PATCH 220/264] Preview plug-in parameter edits from the visible dialog controls --- crates/ui-egui/src/app.rs | 6 ++++++ crates/ui-egui/src/dialogs/plugin.rs | 18 ++++++++++++++---- crates/ui-egui/src/tests/plugins.rs | 22 +++++++++++++++++++++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 8ddfe99310..65b6916d55 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -717,7 +717,13 @@ impl VectorcraftApp { export_progress::show(self, ui); // After every window this pass may open, and before the palette's field takes the keyboard. panel_docking::close_overlays_for_modal(self, &ctx); + let drawn_document = self.session.active().map(|st| (st.uid, st.revision)); dialogs::host::pump(self, &ctx); + // The canvas has already painted. A dialog can apply or roll back its preview + // on the final input frame, with no further mouse movement to wake the window. + if self.session.active().map(|st| (st.uid, st.revision)) != drawn_document { + ctx.request_repaint(); + } prefs_dialog::show(self, ui); crate::shortcut_editor::show(self, ui); credits::open_taken_link(self); diff --git a/crates/ui-egui/src/dialogs/plugin.rs b/crates/ui-egui/src/dialogs/plugin.rs index 8b6606e068..d7fb438d2c 100644 --- a/crates/ui-egui/src/dialogs/plugin.rs +++ b/crates/ui-egui/src/dialogs/plugin.rs @@ -42,7 +42,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; use craft::menu::Node; -use craft::ui::contract::Show as _; +use craft::ui::contract::{Bind, Show as _}; use craft::ui::dialog::{DialogId, DialogResult, DialogStack, Prompt, StackDialog, dialog_id}; use craft::ui::display::{Shade, Text}; use craft::ui::patterns::form_dialogs::{DialogFields, HostedParamDialog, Param, ParamDialog}; @@ -548,7 +548,13 @@ pub(super) fn heading(plugin: &str, command: Option<&str>, gone: &str) -> String /// The builder of a hosted plug-in dialog over its values: the rows of `all` whose parameter is /// shown for the values (`m.visible`), after the description. The rows are made again in the UI /// language when it changes while the dialog is open; the field values stay as they are. -fn build(key: &'static str, m: Manifest, all: Arc<[Param]>, look: Look) -> impl for<'b> Fn(&'b mut DialogFields) -> ParamDialog<'b> + Send + 'static { +fn build( + key: &'static str, + m: Manifest, + all: Arc<[Param]>, + look: Look, + canvas: Option, +) -> impl for<'b> Fn(&'b mut DialogFields) -> ParamDialog<'b> + Send + 'static { let rows_in = std::sync::Mutex::new((lang(), all)); move |fields| { let all = { @@ -564,7 +570,10 @@ fn build(key: &'static str, m: Manifest, all: Arc<[Param]>, look: Look) -> impl rows.push(Param::read_only_text("description", "", look.description.clone()).full_width()); } rows.extend(all.iter().filter(|p| shown.contains(p.key.as_str())).cloned()); - let mut dialog = ParamDialog::new(key, look.heading(), Cow::Owned(rows)).previews(look.previews); + let mut dialog = ParamDialog::new(key, look.heading(), Cow::Owned(rows)).previews(look.previews).values(Bind::bound(fields)); + if let Some(canvas) = canvas.filter(|_| look.previews) { + dialog = dialog.canvas(canvas); + } if let Some(ok) = look.ok { dialog = dialog.ok_label(ok.into()); } @@ -592,7 +601,8 @@ fn open_hosted( close_open(app); let all: Arc<[Param]> = form::plugin_params(&m, &values).into(); let fields = form::fields_of(&all, &values); - let dialog = HostedParamDialog::new(&ctx, key, fields, build(key, m, Arc::clone(&all), look)).instance(instance.to_string()); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); + let dialog = HostedParamDialog::new(&ctx, key, fields, build(key, m, Arc::clone(&all), look, canvas)).instance(instance.to_string()); let id = dialogs.with(|host| host.open(dialog)); Ok((id, all)) } diff --git a/crates/ui-egui/src/tests/plugins.rs b/crates/ui-egui/src/tests/plugins.rs index ff7c9e71ee..c2a72c626d 100644 --- a/crates/ui-egui/src/tests/plugins.rs +++ b/crates/ui-egui/src/tests/plugins.rs @@ -181,7 +181,9 @@ fn plugins_are_listed_in_the_object_and_effect_menus() { #[test] fn filter_dialog_previews_and_commits_one_undo_step() { - let mut h = window(app()); + let mut app = app(); + app.canvas.worker_started = true; // Canvas uploads finish within the frame being asserted. + let mut h = window(app); h.state_mut().run("plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(DESATURATE)})).unwrap(); let id = red_rect(h.state_mut()); let undo = h.state().session.doc().unwrap().history.undo.len(); @@ -189,12 +191,30 @@ fn filter_dialog_previews_and_commits_one_undo_step() { step(&mut h); assert!(top(h.state()).is_some(), "dialog open"); assert_eq!(fields(h.state())["amount"], json!(100.0)); + // A click in the visible slider must reach the same values the live preview reads. + use egui_kittest::kittest::Queryable as _; + let at = h.get_by_role(egui::accesskit::Role::Dialog).get_by_role(egui::accesskit::Role::Slider).rect().center(); + h.input_mut().events.push(egui::Event::PointerMoved(at)); + for pressed in [true, false] { + h.input_mut().events.push(egui::Event::PointerButton { + pos: at, + button: egui::PointerButton::Primary, + pressed, + modifiers: Default::default(), + }); + step(&mut h); + } + assert!(fields(h.state())["amount"].as_f64().is_some_and(|amount| amount > 0.0 && amount < 100.0)); // Agents set fields like `ui.dialog.set` does; the frame previews them. set_field(&mut h, "amount", json!(50)).unwrap(); step(&mut h); assert!(h.state().session.in_interaction(), "previewing"); let [r, g, _] = fill_rgb(h.state(), id); assert!(r < 1.0 && g > 0.0, "half desaturated on the canvas: {r} {g}"); + step(&mut h); + let (shown, _) = h.state().canvas.shown.as_ref().expect("a rendered canvas frame"); + let shown_fill = shown.node(id).unwrap().appearance.fill_paint().color().unwrap().to_rgb_uncalibrated(); + assert_eq!(shown_fill, fill_rgb(h.state(), id), "the canvas showed the preview before OK"); answer(&mut h, true); assert!(top(h.state()).is_none()); let st = h.state().session.doc().unwrap(); From 7c8d4ea5a78faac1cdbfc51d51248d5b9693fe5a Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:08:52 +0100 Subject: [PATCH 221/264] Keep large PDF previews and confirmed page imports off the desktop UI thread --- crates/ui-egui/src/dialogs/import_pdf.rs | 69 ++++++++++++++++--- .../ui-egui/src/dialogs/tests_import_pdf.rs | 14 ++++ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/import_pdf.rs b/crates/ui-egui/src/dialogs/import_pdf.rs index f539897c25..8bf7e37874 100644 --- a/crates/ui-egui/src/dialogs/import_pdf.rs +++ b/crates/ui-egui/src/dialogs/import_pdf.rs @@ -114,11 +114,19 @@ pub(super) fn render_preview( app: &mut VectorcraftApp, ctx: &egui::Context, doc: &vectorcraft_engine::doc::Document, +) -> Option> { + render_page_preview(&mut app.canvas.renderer, ctx.pixels_per_point(), doc) +} + +fn render_page_preview( + renderer: &mut vectorcraft_render::Renderer, + pixels_per_point: f32, + doc: &vectorcraft_engine::doc::Document, ) -> Option> { let region = doc.artboards.first()?.rect; - let px = PREVIEW_PX * ctx.pixels_per_point() as f64; + let px = PREVIEW_PX * pixels_per_point as f64; let scale = px / region.width().max(region.height()).max(1.0); - let img = app.canvas.renderer.render_region(doc, region, scale, true); + let img = renderer.render_region(doc, region, scale, true); Some(Arc::new(crate::canvas::color_image(&img))) } @@ -286,6 +294,8 @@ pub(super) struct ImportPdfDialog { /// The preview shown for a (page, crop, text) revision; `None` for a page that could not be read, which is /// not asked for again. preview: Option<(Revision, Option>)>, + /// One preview at a time. Page changes coalesce while the worker finishes. + pending_preview: Option<(Revision, std::sync::mpsc::Receiver>>)>, /// Why the last password did not open the file. password_error: Option, /// The OK the pump has not answered. @@ -294,7 +304,7 @@ pub(super) struct ImportPdfDialog { impl ImportPdfDialog { fn new(s: State) -> Self { - ImportPdfDialog { id: dialog_id(KIND), s, preview: None, password_error: None, held: HeldAnswer::new() } + ImportPdfDialog { id: dialog_id(KIND), s, preview: None, pending_preview: None, password_error: None, held: HeldAnswer::new() } } /// The preview to render next: the revision of the shown page, crop and text, when the stored one differs. @@ -700,7 +710,14 @@ fn confirm(app: &mut VectorcraftApp, s: &State) -> Result<(), String> { if s.links_on() { p["linkPages"] = json!(true); } - io::open_document(app, &s.name, &s.file.bytes, s.path.clone(), &p).map(|_| ()) + if crate::opening::available() + && let Some(path) = s.path.as_deref() + { + crate::opening::start_with(app, path, s.file.bytes.clone(), p); + Ok(()) + } else { + io::open_document(app, &s.name, &s.file.bytes, s.path.clone(), &p).map(|_| ()) + } }; // Asked only for the password, the dialog showed no Text choice to keep; the choice for a `.ai` // or `.ait` file is not kept for PDFs. @@ -711,10 +728,10 @@ fn confirm(app: &mut VectorcraftApp, s: &State) -> Result<(), String> { } /// The preview of the page and boxes `s` shows; `None` for a page that can't be read. -fn preview_image(app: &mut VectorcraftApp, ctx: &egui::Context, s: &State) -> Option> { +fn preview_image(renderer: &mut vectorcraft_render::Renderer, pixels_per_point: f32, s: &State) -> Option> { let opts = fileio::LoadOptions { crop: s.crop, password: s.password(), text_as: s.preview_text_as(), ..Default::default() }; let (doc, _) = fileio::page_document(&s.file.bytes, s.page().saturating_sub(1), &opts).ok()?; - render_preview(app, ctx, &doc) + render_page_preview(renderer, pixels_per_point, &doc) } /// The host pump: judges the OK the dialog holds (opening or placing the file; a refusal keeps the dialog open with @@ -730,10 +747,44 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { dialog.answer_ok(answer); } }); + return; } - let wanted = dialogs.with(|host| host.get::().and_then(|d| Some((d.wanted_preview()?, d.s.clone())))); - if let Some((revision, s)) = wanted { - let image = preview_image(app, ctx, &s); + let wanted = dialogs.with(|host| { + let dialog = host.get_mut::()?; + if let Some((revision, pending)) = &dialog.pending_preview { + let image = match pending.try_recv() { + Ok(image) => image, + Err(std::sync::mpsc::TryRecvError::Disconnected) => None, + Err(std::sync::mpsc::TryRecvError::Empty) => return None, + }; + if dialog.wanted_preview() == Some(*revision) { + dialog.set_preview(*revision, image); + } + dialog.pending_preview = None; + } + Some((dialog.wanted_preview()?, dialog.s.clone())) + }); + let Some((revision, state)) = wanted else { return }; + let pixels_per_point = ctx.pixels_per_point(); + if crate::opening::available() { + let (sender, pending) = std::sync::mpsc::channel(); + dialogs.with(|host| { + if let Some(dialog) = host.get_mut::() { + dialog.pending_preview = Some((revision, pending)); + } + }); + let wake = ctx.clone(); + let scope = vectorcraft_engine::file_access::ScopeHandle::capture(); + app.jobs().spawn( + "vectorcraft-pdf-preview", + Box::new(move || { + let image = scope.run(|| preview_image(&mut vectorcraft_render::Renderer::new(), pixels_per_point, &state)); + let _ = sender.send(image); + wake.request_repaint(); + }), + ); + } else { + let image = preview_image(&mut app.canvas.renderer, pixels_per_point, &state); dialogs.with(|host| { if let Some(dialog) = host.get_mut::() { dialog.set_preview(revision, image); diff --git a/crates/ui-egui/src/dialogs/tests_import_pdf.rs b/crates/ui-egui/src/dialogs/tests_import_pdf.rs index 3b96687a49..c9383d0f44 100644 --- a/crates/ui-egui/src/dialogs/tests_import_pdf.rs +++ b/crates/ui-egui/src/dialogs/tests_import_pdf.rs @@ -117,6 +117,20 @@ fn pdf_page_footer_ok_opens_the_chosen_range() { assert_eq!(artboard_widths(h.state()), [200.0, 300.0]); } +#[test] +fn confirming_a_desktop_pdf_import_queues_the_read_and_closes_the_dialog() { + crate::opening::tests::with_threads(|| { + let mut app = app(); + io::open_bytes(&mut app, "three.pdf", &three_pages(), Some("three.pdf".into())).unwrap(); + set(&mut app, "allPages", json!(false)); + set(&mut app, "range", json!("2-3")); + confirm(&mut app).unwrap(); + assert!(!is_open(&app)); + assert_eq!(app.opening.pending.len(), 1); + assert_eq!(app.opening.pending[0].path, "three.pdf"); + }); +} + #[test] fn opening_a_multi_page_pdf_asks_for_the_pages() { let mut app = app(); From 747593d0dd6524ed3789940a590ed9e5d8039cfd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:10:17 -0800 Subject: [PATCH 222/264] xtask: test-lint reads quoted paths, test_case tests and literal setters correctly - Changed mode decodes `+++` labels (the tab after a path with a space, C-quoted paths), and the file inventories read `git ls-files -z`, so files with spaces, quotes or non-ASCII names are linted. - `#[test_case(1; "one")]` arguments and other attributes no longer end the item before its `fn`, and an inner `#![...]` attribute before the first test is not part of that test's span. - A helper name counts as asserting only when every function of that name in the crate's test code asserts. - `.stdout(file)` and other stream builder calls count as configuration whatever their argument, so `exit-status-only` still reports. - A `return` inside `async { ... }` or `async move { ... }` ends the future, not the test, for `early-return`. - `env-gate-unset` looks for setters in code only, not in string literals, ignores `echo` and `printf` output that is not written to `$GITHUB_ENV`, and its span reaches the variable name on a later line. - `sleep` reports `thread::sleep`, or a bare `sleep(...)` only where the file imports `thread::sleep`. - `reads-source` checks raw string paths in `include_str!` and `ends_with`. - A test pins that a collection changed after its `assert_eq!` loses that guard for `all-unguarded`. --- xtask/src/main.rs | 4 +- xtask/src/test_lint.rs | 288 +++++++++++++++++++++++++++++++++++------ 2 files changed, 247 insertions(+), 45 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index addf9cb7e1..3a0c854486 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -125,13 +125,13 @@ pub fn root() -> PathBuf { pub fn repo_files(root: &Path) -> Result, String> { let out = Command::new("git") .current_dir(root) - .args(["ls-files", "--cached", "--others", "--exclude-standard"]) + .args(["ls-files", "-z", "--cached", "--others", "--exclude-standard"]) .output() .map_err(|e| format!("git ls-files: {e}"))?; if !out.status.success() { return Err(format!("git ls-files failed: {}", String::from_utf8_lossy(&out.stderr).trim())); } - Ok(String::from_utf8_lossy(&out.stdout).lines().filter(|l| root.join(l).exists()).map(str::to_owned).collect()) + Ok(String::from_utf8_lossy(&out.stdout).split('\0').filter(|l| !l.is_empty() && root.join(l).exists()).map(str::to_owned).collect()) } /// A `cargo` command (the one running xtask, else `cargo` on the PATH) run in the workspace root. diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index 60363000fd..a0e8f8040a 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -32,9 +32,10 @@ //! corpora, environment variables, the platform or a child process; //! * `ignore-without-reason`: `#[ignore]` with no `= "reason"`; //! * `env-gate-unset`: `env::var("NAME")` in a test where no CI workflow, the shared gate or the -//! file itself sets `NAME`; workflow mapping keys and `NAME=` assignments count, but comments -//! and variable reads do not; -//! * `sleep`: `thread::sleep` in test code; +//! file's code sets `NAME`; workflow mapping keys and `NAME=` assignments count, but comments, +//! string literals, `echo` or `printf` output that is not written to `$GITHUB_ENV`, and variable +//! reads do not; +//! * `sleep`: `thread::sleep` in test code, or a bare `sleep(…)` in a file that imports it; //! * `reads-source`: test code that reads Rust source (`include_str!` of a `.rs` file, or a walk //! that keeps files ending in `.rs`), outside the source audits in [`SOURCE_AUDITS`]. //! @@ -42,8 +43,8 @@ //! `benches` folder, `crates/testkit`), an item under `#[cfg(test)]`, or a test function. //! //! An asserting helper is a function or macro in the crate's test code (or in `crates/testkit`) -//! that asserts, panics or calls one that does, or a call whose name starts with `assert`, -//! `check`, `verify`, `ensure` or `expect_`. +//! that asserts, panics or calls one that does (every one of that name, when there are several), +//! or a call whose name starts with `assert`, `check`, `verify`, `ensure` or `expect_`. //! //! `// test-lint: allow ` exempts the line it is on and the line below it; for the //! rules about a whole test it can be on any line from the line above the test attribute to the @@ -185,8 +186,9 @@ pub struct Hit { pub note: String, /// The first and last line of what the hit covers: the test, from its attribute to its closing /// brace, for a rule about a whole test or `all-unguarded`, through the second operand for - /// `self-compare`, else `line`. This span controls changed-line detection; `all-unguarded` - /// and `self-compare` exemptions still apply only near `line`. + /// `self-compare`, through the variable's name for `env-gate-unset`, else `line`. This span + /// controls changed-line detection; `all-unguarded` and `self-compare` exemptions still apply + /// only near `line`. pub first: usize, pub last: usize, } @@ -385,7 +387,7 @@ fn changed_lines(root: &Path, base: &str) -> Result BTreeMap>> { } else if header && line.starts_with("new file mode") { new_file = true; } else if let Some(path) = line.strip_prefix("+++ ").filter(|_| header) { - current = path.strip_prefix("b/").map(str::to_owned); + current = patch_path(path).and_then(|p| p.strip_prefix("b/").map(str::to_owned)); if let Some(p) = ¤t { out.insert(p.clone(), if new_file { None } else { Some(BTreeSet::new()) }); } @@ -422,6 +424,41 @@ fn parse_diff(diff: &str) -> BTreeMap>> { out } +/// The path in a `+++ ` label: git ends a label that contains a space with a tab, and writes a +/// path with a quote, a backslash or a control character as a C-style quoted string. +fn patch_path(label: &str) -> Option { + let label = label.strip_suffix('\t').unwrap_or(label); + let Some(quoted) = label.strip_prefix('"') else { return Some(label.to_owned()) }; + let body = quoted.strip_suffix('"')?.as_bytes(); + let (mut out, mut i) = (Vec::with_capacity(body.len()), 0); + while i < body.len() { + if body[i] != b'\\' { + out.push(body[i]); + i += 1; + continue; + } + let c = *body.get(i + 1)?; + let octal = body.get(i + 1..i + 4).filter(|d| d.iter().all(|c| (b'0'..=b'7').contains(c))); + if let Some(digits) = octal { + out.push(digits.iter().fold(0u8, |n, d| n.wrapping_mul(8).wrapping_add(d - b'0'))); + i += 4; + continue; + } + out.push(match c { + b'a' => 7, + b'b' => 8, + b't' => b'\t', + b'n' => b'\n', + b'v' => 11, + b'f' => 12, + b'r' => b'\r', + other => other, + }); + i += 2; + } + String::from_utf8(out).ok() +} + /// `(start, count)` of the new side of a hunk header's `-a,b +c,d @@`. A pure deletion has count 0 /// and sits between lines c and c + 1; c = 0 places it before line 1. fn hunk_range(hunk: &str) -> Option<(usize, usize)> { @@ -459,12 +496,20 @@ fn upper_words(text: &str) -> impl Iterator + '_ { let name = line[..at].rsplit(|c: char| !(c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_')).next().unwrap_or_default(); let from = at - name.len(); let boundary = from == 0 || line.as_bytes().get(from - 1).is_some_and(|c| c.is_ascii_whitespace() || matches!(c, b'\'' | b'"' | b';')); - (boundary && env_assignment_name(name) && !line[at + 1..].starts_with(['=', '>'])).then(|| name.to_owned()) + (boundary && env_assignment_name(name) && !line[at + 1..].starts_with(['=', '>']) && !printed(line, from)).then(|| name.to_owned()) }); mapping.map(|(name, _)| name.to_owned()).into_iter().chain(assignments) }) } +/// Whether the text at `from` is an argument of `echo` or `printf` in its shell command, on a line +/// that does not write to `$GITHUB_ENV`. +fn printed(line: &str, from: usize) -> bool { + let command = line[..from].rsplit([';', '&', '|']).next().unwrap_or_default().as_bytes(); + let prints = ["echo", "printf"].iter().any(|w| !words(command, w.as_bytes(), 0, command.len()).is_empty()); + prints && !line.contains("GITHUB_ENV") +} + fn env_assignment_name(name: &str) -> bool { name.len() > 1 && name.starts_with(|c: char| c.is_ascii_uppercase()) @@ -513,11 +558,6 @@ fn mask_with(src: &str, comments: bool) -> Vec { mask_parts(src, comments, true) } -/// Blanks comments while keeping code and literal contents at the same byte offsets. -fn mask_comments(src: &str) -> Vec { - mask_parts(src, true, false) -} - /// Blanks the selected comments and literal contents, preserving line breaks and literal quotes. fn mask_parts(src: &str, comments: bool, literals: bool) -> Vec { let b = src.as_bytes(); @@ -769,6 +809,11 @@ fn tests_in(m: &[u8]) -> Vec { /// The function an attribute at `attr` (ending at `from`) belongs to. fn fn_after(m: &[u8], attr: usize, from: usize) -> Option { + // The attribute's arguments, and the attributes after it, can hold `;` (`#[test_case(1; "one")]`). + let mut from = from.max(matching(m, attr + 1)? + 1); + while m[skip_ws(m, from)..].starts_with(b"#[") { + from = matching(m, skip_ws(m, from) + 1)? + 1; + } let limit = (from + 800).min(m.len()); let fn_at = *words(m, b"fn", from, limit).first()?; if m[from..fn_at].iter().any(|&c| c == b'{' || c == b';') { @@ -785,7 +830,11 @@ fn fn_after(m: &[u8], attr: usize, from: usize) -> Option { } let close = matching(m, open)?; // The item starts after the previous item or block opening; comments before it are masked. - let item = m[..attr].iter().rposition(|&c| matches!(c, b';' | b'{' | b'}')).map_or(0, |p| p + 1); + // Inner attributes (`#![…]`) there belong to the enclosing module or crate. + let mut item = m[..attr].iter().rposition(|&c| matches!(c, b';' | b'{' | b'}')).map_or(0, |p| p + 1); + while m[skip_ws(m, item)..].starts_with(b"#![") && skip_ws(m, item) < attr { + item = matching(m, skip_ws(m, item) + 2)? + 1; + } let attr = skip_ws(m, item).min(attr); Some(TestFn { name: String::from_utf8_lossy(&m[name_start..name_end]).into_owned(), attr, fn_at, open, close }) } @@ -960,12 +1009,22 @@ pub fn asserting_helpers(files: &[(String, String)]) -> HashMap(defs: impl Iterator + Clone) -> HashSet { - let mut known: HashSet = defs.clone().filter(|d| d.1).map(|d| d.0.clone()).collect(); + let mut by_name: HashMap<&str, Vec<&Def>> = HashMap::new(); + for d in defs { + by_name.entry(d.0.as_str()).or_default().push(d); + } + let mut known: HashSet = HashSet::new(); loop { - let more: Vec = - defs.clone().filter(|d| !known.contains(&d.0) && d.2.iter().any(|c| known.contains(c))).map(|d| d.0.clone()).collect(); + let checks = |d: &Def| d.1 || d.2.iter().any(|c| known.contains(c)); + let more: Vec = by_name + .iter() + .filter(|(name, same)| !known.contains(**name) && same.iter().all(|d| checks(d))) + .map(|(name, _)| (*name).to_owned()) + .collect(); if more.is_empty() { return known; } @@ -2074,13 +2133,12 @@ fn exit_status_only(v: &View) -> Option { Some(v.whole(Rule::ExitStatusOnly, "runs a process and checks only its exit status".into())) } -/// Blanks stream method names that configure a process with `Stdio` in whitespace-free text. +/// Blanks the names of builder calls that set a process's streams (`.stdout(…)`, whatever the +/// argument) in whitespace-free text. Reads of the output fields (`out.stdout`) stay. fn strip_stream_configuration(body: &mut [u8]) { for stream in ["stdout", "stderr", "stdin"] { for at in words(body, stream.as_bytes(), 0, body.len()) { - let rest = &body[at + stream.len()..]; - let config = rest.starts_with(b"(Stdio::") || rest.starts_with(b"(std::process::Stdio::"); - if body[..at].ends_with(b".") && config { + if body[..at].ends_with(b".") && body[at + stream.len()..].starts_with(b"(") { blank(body, at, at + stream.len()); } } @@ -2205,7 +2263,9 @@ fn opens_closure_or_fn(m: &[u8], open: usize, brace: usize) -> bool { let head = String::from_utf8_lossy(&head[start..]).into_owned(); let head = head.trim_end(); let closure = head.ends_with('|') || head.rfind("->").is_some_and(|p| head[..p].trim_end().ends_with('|')); - closure || !words(head.as_bytes(), b"fn", 0, head.len()).is_empty() + let block = head.strip_suffix("move").unwrap_or(head).trim_end(); + let future = block.ends_with("async") && !block[..block.len() - "async".len()].ends_with(|c: char| c.is_ascii_alphanumeric() || c == '_'); + closure || future || !words(head.as_bytes(), b"fn", 0, head.len()).is_empty() } /// Whether the return at `at..end` is not a silent skip on a value: the block it ends asserts @@ -2239,24 +2299,50 @@ fn env_gates(v: &View, ctx: &Ctx) -> Vec { if !m[..at].ends_with(b"env::") { continue; } - let Some(name) = env_name(m, src, at) else { continue }; + let Some((name, end)) = env_name(m, src, at) else { continue }; if ctx.ci_env.contains(&name) || set_by_system(&name) { continue; } - // The whole file is masked and searched only for a name that CI and the system leave unset. - let file = norm(&mask_comments(&String::from_utf8_lossy(src))); - let set_here = file.contains(&format!(".env(\"{name}\"")) - || file.contains(&format!("=\"{name}\";")) - || file.match_indices(&format!("set_var(\"{name}\"")).any(|(at, _)| at == 0 || !is_ident(file.as_bytes()[at - 1])); - if !set_here { - out.push(v.hit(at, Rule::EnvGateUnset, format!("reads {name}, which no CI leg sets"))); + if !set_in_file(m, src, &name) { + // The hit sits on `var`; its span reaches the name, which can be on a later line. + let mut hit = v.hit(at, Rule::EnvGateUnset, format!("reads {name}, which no CI leg sets")); + hit.last = v.file.lines.of(end); + out.push(hit); } } out } -/// The literal name in `env::var("NAME")` whose `var` is at `at`. -fn env_name(m: &[u8], src: &[u8], at: usize) -> Option { +/// Whether the file's code (masked `m`, outside comments and literals) sets `name`: `.env("NAME", …)`, +/// `set_var("NAME", …)`, or a constant `= "NAME";`. The name is read from the source. +fn set_in_file(m: &[u8], src: &[u8], name: &str) -> bool { + let call = |word: &[u8], method: bool| { + words(m, word, 0, m.len()).into_iter().any(|at| { + let dot = m[..at].trim_ascii_end().ends_with(b"."); + (dot || !method) && env_name(m, src, at).is_some_and(|(n, _)| n == name) + }) + }; + let constant = find_all(src, name.as_bytes()).any(|p| { + let (open, close) = (p.wrapping_sub(1), p + name.len()); + let (Some(b'"'), Some(b'"')) = (m.get(open), m.get(close)) else { return false }; + m[..open].trim_ascii_end().ends_with(b"=") && m.get(skip_ws(m, close + 1)) == Some(&b';') + }); + call(b"env", true) || call(b"set_var", false) || constant +} + +/// Every start of `needle` in `hay`. +fn find_all<'a>(hay: &'a [u8], needle: &'a [u8]) -> impl Iterator + 'a { + let mut from = 0; + std::iter::from_fn(move || { + let at = find(hay, needle, from)?; + from = at + 1; + Some(at) + }) +} + +/// The literal name in `env::var("NAME")` whose `var` is at `at`, and the offset of its closing +/// quote. +fn env_name(m: &[u8], src: &[u8], at: usize) -> Option<(String, usize)> { let open = skip_ws(m, at + m[at..].iter().take_while(|&&c| is_ident(c)).count()); if m.get(open) != Some(&b'(') { return None; @@ -2267,7 +2353,7 @@ fn env_name(m: &[u8], src: &[u8], at: usize) -> Option { } let end = string_end(src, quote + 1).saturating_sub(1); let name = std::str::from_utf8(&src[quote + 1..end]).ok()?; - (!name.is_empty() && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_')).then(|| name.to_owned()) + (!name.is_empty() && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_')).then(|| (name.to_owned(), end)) } fn ignore_hits(file: &File) -> Vec { @@ -2311,16 +2397,24 @@ fn ignore_reason(src: &[u8]) -> Option<&[u8]> { fn sleep_hits(file: &File) -> Vec { let m = &file.m; + // A bare `sleep(…)` counts only where a `use` brings in `thread::sleep`. + let imported = words(m, b"use", 0, m.len()).into_iter().any(|u| { + let item = norm(&m[u..statement_end(m, u)]); + item.contains("thread::sleep") + || item.split_once("thread::{").is_some_and(|(_, list)| !words(list.as_bytes(), b"sleep", 0, list.len()).is_empty()) + }); words(m, b"sleep", 0, m.len()) .into_iter() .filter(|&at| { - if !in_regions(&file.regions, at) { + if !in_regions(&file.regions, at) || m.get(skip_ws(m, at + "sleep".len())) != Some(&b'(') { return false; } - let before = m[..at].iter().rposition(|c| !c.is_ascii_whitespace()); - let method = before.is_some_and(|b| m[b] == b'.'); - let definition = m[..at].trim_ascii_end().ends_with(b"fn"); - !method && !definition && m.get(skip_ws(m, at + "sleep".len())) == Some(&b'(') + let before = m[..at].trim_ascii_end(); + let path = before.strip_suffix(b"::").map(<[u8]>::trim_ascii_end); + match path { + Some(p) => p.ends_with(b"thread") && !p.ends_with(b"_thread"), + None => imported && !before.ends_with(b".") && !before.ends_with(b"fn"), + } }) .map(|at| file.hit(at, Rule::Sleep, file.test_at(at), "sleeps in test code".into())) .collect() @@ -2337,7 +2431,10 @@ fn reads_source_hits(file: &File) -> Vec { let open = skip_ws(m, at + word.len() + usize::from(m.get(at + word.len()) == Some(&b'!'))); let Some(close) = (m.get(open) == Some(&b'(')).then(|| matching(m, open)).flatten() else { continue }; let arg = norm(&file.src[open + 1..close]); - let rs = if word == b"ends_with" { arg == "\".rs\"" } else { arg.ends_with(".rs\"") }; + // An ordinary or raw string literal: `".rs"`, `r".rs"`, `r#"…/lib.rs"#`. + let raw = arg.strip_prefix('r').map(|a| a.trim_matches('#')).filter(|a| a.starts_with('"')); + let literal = raw.unwrap_or(&arg); + let rs = if word == b"ends_with" { literal == "\".rs\"" } else { arg.trim_end_matches('#').ends_with(".rs\"") }; if rs { out.push(file.hit(at, Rule::ReadsSource, file.test_at(at), note.into())); } @@ -3335,7 +3432,7 @@ mod tests { assert_eq!(hits(&src.replacen("MY_SAMPLES", "OTHER_SAMPLES", 1)), [(4, "env-gate-unset")], "{setter}"); } let src = "let a = \"https://host/*path*/\"; /* removed */ let b = r#\"// kept /* kept */\"#; // removed\nlet c = '/';"; - let masked = String::from_utf8(mask_comments(src)).unwrap(); + let masked = String::from_utf8(mask_parts(src, true, false)).unwrap(); assert!(masked.contains("\"https://host/*path*/\"")); assert!(masked.contains("r#\"// kept /* kept */\"#")); assert!(masked.contains("let c = '/';")); @@ -3527,4 +3624,109 @@ mod tests { assert_eq!(hits_in("crates/x/src/tests.rs", src, &ctx), [], "{workflow}"); } } + + #[test] + fn printed_workflow_assignments_do_not_count() { + for line in + ["run: echo \"MY_SAMPLES=fixtures\"", " echo MY_SAMPLES=fixtures", " printf 'MY_SAMPLES=x\\n'", " true && echo \"MY_SAMPLES=x\""] + { + assert_eq!(upper_words(line).collect::>(), Vec::::new(), "{line}"); + } + for line in [" echo hi; MY_SAMPLES=x cargo test", " printf 'MY_SAMPLES=x\\n' >> \"$GITHUB_ENV\""] { + assert_eq!(upper_words(line).collect::>(), ["MY_SAMPLES"], "{line}"); + } + } + + #[test] + fn patch_labels_are_decoded_before_filtering() { + let diff = "diff --git a/crates/x/tests/two words.rs b/crates/x/tests/two words.rs\n--- a/crates/x/tests/two words.rs\t\n+++ b/crates/x/tests/two words.rs\t\n@@ -1 +1 @@\n-a\n+b\ndiff --git \"a/crates/x/tests/q\\\"t.rs\" \"b/crates/x/tests/q\\\"t.rs\"\n--- \"a/crates/x/tests/q\\\"t.rs\"\n+++ \"b/crates/x/tests/q\\\"t.rs\"\n@@ -2 +2 @@\n-a\n+b\ndiff --git \"a/crates/x/tests/caf\\303\\251.rs\" \"b/crates/x/tests/caf\\303\\251.rs\"\n--- \"a/crates/x/tests/caf\\303\\251.rs\"\n+++ \"b/crates/x/tests/caf\\303\\251.rs\"\n@@ -3 +3 @@\n-a\n+b\n"; + let got = parse_diff(diff); + assert_eq!(got.get("crates/x/tests/two words.rs"), Some(&Some([1].into_iter().collect())), "{got:?}"); + assert_eq!(got.get("crates/x/tests/q\"t.rs"), Some(&Some([2].into_iter().collect())), "{got:?}"); + assert_eq!(got.get("crates/x/tests/caf\u{e9}.rs"), Some(&Some([3].into_iter().collect())), "{got:?}"); + assert!(got.keys().all(|p| is_scanned(p)), "{got:?}"); + } + + #[test] + fn test_case_arguments_and_inner_attributes_do_not_hide_tests() { + let cases = "#[test_case(1; \"one\")]\n#[test_case(2; \"two\")]\nfn t(n: u8) {}\n"; + assert_eq!(hits(cases), [(3, "no-assertion")]); + let inner = "#![allow(dead_code)]\n\n#[should_panic]\n#[test]\nfn t() {\n f();\n}\n#[test]\nfn u() {\n g();\n}\n"; + let found = lint_file("crates/x/src/tests.rs", &inner.replace("#[should_panic]\n", ""), &ctx()); + assert_eq!(found.iter().map(|h| (h.first, h.last)).collect::>(), [(3, 6), (7, 10)], "{found:?}"); + assert_eq!(hits(inner), [(9, "no-assertion")], "#[should_panic] before #[test] still belongs to the test"); + } + + #[test] + fn helpers_with_a_shared_name_count_only_when_each_asserts() { + let src = "mod a {\n pub fn exercise() { assert_eq!(f(), 1); }\n}\nmod b {\n pub fn exercise() { f(); }\n}\n#[test]\nfn t() {\n b::exercise();\n}\n"; + let helpers = asserting_helpers(&[("crates/x/tests/it.rs".to_owned(), src.to_owned())]); + assert!(!helpers["crates/x"].contains("exercise"), "{helpers:?}"); + assert_eq!(hits_in("crates/x/tests/it.rs", src, &Ctx { helpers, ci_env: HashSet::new() }), [(8, "no-assertion")]); + let both = src.replace("{ f(); }", "{ assert!(f()); }"); + let helpers = asserting_helpers(&[("crates/x/tests/it.rs".to_owned(), both.clone())]); + assert_eq!(hits_in("crates/x/tests/it.rs", &both, &Ctx { helpers, ci_env: HashSet::new() }), []); + } + + #[test] + fn a_changed_collection_loses_its_equality_guard() { + let src = "#[test]\nfn t() {\n let mut xs = f();\n assert_eq!(xs, vec![1]);\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(src), []); + for change in ["xs.clear();", "xs.retain(|x| *x > 5);", "xs = vec![];"] { + let changed = src.replace("\n assert!", &format!("\n {change}\n assert!")); + assert_eq!(hits(&changed), [(6, "all-unguarded")], "{change}"); + } + } + + #[test] + fn stream_redirection_to_any_target_is_configuration() { + let bad = "#[test]\nfn t() {\n let status = Command::new(bin()).stdout(file).stderr(log.try_clone().unwrap()).status().unwrap();\n assert!(status.success());\n}\n"; + assert_eq!(hits(bad), [(2, "exit-status-only")]); + let good = bad.replace(" assert!", " assert_eq!(fs::read(path).unwrap(), b\"ok\");\n assert!"); + assert_eq!(hits(&good), []); + } + + #[test] + fn async_blocks_end_their_own_returns() { + let src = "#[test]\nfn t() {\n block_on(async { if missing() { return; } work().await; });\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(src), []); + assert_eq!(hits(&src.replace("async {", "async move {")), []); + let own = "#[tokio::test]\nasync fn t() {\n if missing() { return; }\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(own), [(3, "early-return")], "a return from the test's own body"); + } + + #[test] + fn env_setters_in_literals_do_not_count_and_spans_reach_the_name() { + let src = "#[test]\nfn t() {\n let _example = r#\"cmd.env(\"MY_SAMPLES\", dir)\"#;\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(f(dir), 3);\n}\n"; + assert_eq!(hits(src), [(4, "env-gate-unset")]); + let constant = "const X: &str = r#\"= \"MY_SAMPLES\";\"#;\n#[test]\nfn t() {\n let dir = std::env::var(\"MY_SAMPLES\");\n assert_eq!(f(dir), 3);\n}\n"; + assert_eq!(hits(constant), [(4, "env-gate-unset")]); + let multiline = "#[test]\nfn t() {\n let dir = std::env::var(\n \"MY_SAMPLES\",\n );\n assert_eq!(f(dir), 3);\n}\n"; + let found = lint_file("crates/x/src/tests.rs", multiline, &ctx()); + assert_eq!(found.iter().map(|h| (h.rule, h.line, h.first, h.last)).collect::>(), [(Rule::EnvGateUnset, 3, 3, 4)]); + assert!(touches(&found[0], Some(&[4].into_iter().collect())), "a change to the name alone"); + } + + #[test] + fn sleep_needs_the_thread_function() { + let local = "fn sleep() -> u8 { 42 }\n#[test]\nfn t() {\n assert_eq!(sleep(), 42);\n}\n"; + assert_eq!(hits(local), []); + for import in ["use std::thread::sleep;", "use std::thread::{self, sleep};"] { + let src = format!("{import}\n#[test]\nfn t() {{\n sleep(D);\n assert_eq!(f(), 42);\n}}\n"); + assert_eq!(hits(&src), [(4, "sleep")], "{import}"); + } + assert_eq!(hits("#[test]\nfn t() {\n std :: thread :: sleep(D);\n assert_eq!(f(), 1);\n}\n"), [(3, "sleep")]); + } + + #[test] + fn raw_include_str_paths_are_checked() { + for literal in ["r\"../lib.rs\"", "r#\"../lib.rs\"#", "r##\"../lib.rs\"##"] { + let src = format!("#[test]\nfn t() {{\n let src = include_str!({literal});\n assert_eq!(src.len(), 1);\n}}\n"); + assert_eq!(hits(&src), [(3, "reads-source")], "{literal}"); + assert_eq!(hits(&src.replace(".rs", ".svg")), [], "{literal} with a fixture"); + assert_eq!(hits_in(SOURCE_AUDITS[0], &src, &ctx()), [], "{literal} in an audit"); + } + let walk = "#[test]\nfn t() {\n let n = files().filter(|p| p.ends_with(r#\".rs\"#)).count();\n assert_eq!(n, 4);\n}\n"; + assert_eq!(hits(walk), [(3, "reads-source")]); + } } From b851ac2c8d118022643616ecbd3240c91520664d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:16:23 -0800 Subject: [PATCH 223/264] CI: drop the cache prune watcher job; cache-prune.yml prunes after each run ci.yml's `cache prune` job held a runner beside the whole gate on every main push and nightly run, only to delete the rolling entry that the `cache warm` leg replaced. cache-prune.yml already runs that prune once every CI attempt on main ends, and the warm leg is the last job to finish, so the old entry now goes a few seconds after the save instead of during it. The nightly cold run's `cold cache clear` job stays. Its script used the `cache prune` job to tell "Re-run all jobs" from a re-run of failed jobs. It now looks for `gate / select legs` instead, which only "Re-run all jobs" lists once the warm leg has succeeded, and it waits 5 minutes for that job to appear before it treats the warm leg as finished in an earlier attempt. --- .github/workflows/cache-prune.yml | 11 +++++---- .github/workflows/ci.yml | 30 ++----------------------- scripts/ci-clear-rolling-cache-tests.py | 24 +++++++++++++------- scripts/ci-clear-rolling-cache.py | 23 ++++++++++++------- 4 files changed, 38 insertions(+), 50 deletions(-) diff --git a/.github/workflows/cache-prune.yml b/.github/workflows/cache-prune.yml index a79f1ed907..c1b1e73ae3 100644 --- a/.github/workflows/cache-prune.yml +++ b/.github/workflows/cache-prune.yml @@ -1,11 +1,10 @@ name: Cache prune -# A pass of the cache prune after every CI attempt on main. ci.yml's `cache prune` job prunes while -# a run's jobs save their entries, but "Re-run failed jobs" re-runs only the failed jobs: a re-run -# `cache warm` leg saves a new entry, and the prune job, which succeeded in the first attempt, does -# not run again. The entry it replaced would stay until the next main run, and with it the cache -# would be over its 10 GB budget, where GitHub evicts entries a run still needs. This runs once -# after every attempt, re-runs and canceled runs included (craft-common-actions actions/cache-prune). +# Keeps one rolling gate entry on main, so the repository stays within its 10 GB Actions cache +# budget, where GitHub evicts entries a run still needs. Each main CI attempt's `cache warm` leg +# saves a new rolling entry; this deletes the entry it replaced once the attempt ends. It runs once +# after every attempt, re-runs of failed jobs and canceled runs included (craft-common-actions +# actions/cache-prune). on: workflow_run: workflows: [CI] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0954b5c35c..9937d6165c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,8 +50,8 @@ jobs: # The dependency cache also keeps the compiled workspace crates and test executables, so a # pull request's shards rebuild only the crates its changes reach. Each main run's `cache # warm` leg saves a rolling entry of its own, every leg restores the newest one, and - # `cache-prune` below deletes the one it replaced. The nightly run restores nothing and - # builds everything from source. + # cache-prune.yml deletes the one it replaced after each attempt. The nightly run restores + # nothing and builds everything from source. cache-workspace-crates: true cold-build: ${{ github.event_name == 'schedule' }} packages: >- @@ -59,32 +59,6 @@ jobs: libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev mesa-vulkan-drivers libgl1-mesa-dev - # Keeps one rolling gate entry on main, so the repository stays within its 10 GB Actions cache - # budget. It runs beside the gate and prunes each time the `cache warm` leg finishes saving. A - # failed prune warns instead of failing the run, and cache-prune.yml prunes again after every - # attempt, re-runs of failed jobs included. `watch-minutes` is longer than the gate's - # `timeout-minutes`, so the watch outlasts a cold `cache warm` leg. - cache-prune: - name: cache prune - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - runs-on: ubuntu-24.04 - timeout-minutes: 170 - permissions: - actions: write - steps: - - name: Harden runner - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 - with: - egress-policy: audit - - name: Prune replaced cache entries - uses: storytold/craft-common-actions/actions/cache-prune@main - continue-on-error: true - with: - watch: true - watch-minutes: 160 - saving-jobs: | - ^gate( / cache warm \(.*\))?$ - # The nightly cold run never restores the rolling crates entry, so the old entry is only overlap # while the cold run saves its own: two entries of about 4.6 GB, which with the others go over the # 10 GB cache limit and get the corpus, SonarCloud and Windows ARM64 entries evicted. This deletes diff --git a/scripts/ci-clear-rolling-cache-tests.py b/scripts/ci-clear-rolling-cache-tests.py index a284579d16..250fd92b1c 100644 --- a/scripts/ci-clear-rolling-cache-tests.py +++ b/scripts/ci-clear-rolling-cache-tests.py @@ -129,18 +129,26 @@ class Jobs(unittest.TestCase): jobs = [{"name": "gate / test 1/5 (ubuntu-24.04)"}, {"name": "gate / build (${{ matrix.os }})"}, {"name": WARM}] self.assertEqual(clear.warm_job(jobs), jobs[2]) - def test_a_rerun_of_this_job_alone_skips_a_leg_that_succeeded(self): - self.assertTrue(clear.not_in_attempt(ME, {1: earlier("success")})) - self.assertTrue(clear.not_in_attempt(ME, {1: earlier("success"), 2: [{"name": "cold cache clear"}]})) - self.assertTrue(clear.not_in_attempt(ME, {1: earlier("failure"), 2: [{"name": "cold cache clear"}], 3: earlier("success")})) + def test_a_rerun_of_failed_jobs_skips_a_leg_that_succeeded(self): + grace = clear.RERUN_GRACE_SECONDS + failed_shard = [{"name": "gate / test 3/6 (ubuntu-24.04)", "status": "in_progress"}] + self.assertTrue(clear.not_in_attempt(ME, {1: earlier("success")}, grace)) + self.assertTrue(clear.not_in_attempt(ME + failed_shard, {1: earlier("success")}, grace)) + self.assertTrue(clear.not_in_attempt(ME, {1: earlier("success"), 2: [{"name": "cold cache clear"}]}, grace)) + self.assertTrue(clear.not_in_attempt(ME, {1: earlier("failure"), 2: [{"name": "cold cache clear"}], 3: earlier("success")}, grace)) + + def test_an_attempt_is_watched_for_the_grace_period_first(self): + self.assertFalse(clear.not_in_attempt(ME, {1: earlier("success")}, clear.RERUN_GRACE_SECONDS - 1)) def test_a_leg_that_did_not_succeed_is_waited_for(self): - self.assertFalse(clear.not_in_attempt(ME, {1: earlier("cancelled")})) - self.assertFalse(clear.not_in_attempt(ME, {})) - self.assertFalse(clear.not_in_attempt(ME, {1: earlier("success"), 2: earlier("failure")})) + grace = clear.RERUN_GRACE_SECONDS + self.assertFalse(clear.not_in_attempt(ME, {1: earlier("cancelled")}, grace)) + self.assertFalse(clear.not_in_attempt(ME, {}, grace)) + self.assertFalse(clear.not_in_attempt(ME, {1: earlier("success"), 2: earlier("failure")}, grace)) def test_a_rerun_of_all_jobs_is_waited_for(self): - self.assertFalse(clear.not_in_attempt(ME + [{"name": "cache prune", "status": "in_progress"}], {1: earlier("success")})) + select = [{"name": "gate / select legs", "status": "queued"}] + self.assertFalse(clear.not_in_attempt(ME + select, {1: earlier("success")}, clear.GIVE_UP_SECONDS)) def test_a_failed_select_or_build_stops_the_wait(self): done = lambda n, c: {"name": n, "status": "completed", "conclusion": c} diff --git a/scripts/ci-clear-rolling-cache.py b/scripts/ci-clear-rolling-cache.py index 3b913d68f7..e285fef70b 100644 --- a/scripts/ci-clear-rolling-cache.py +++ b/scripts/ci-clear-rolling-cache.py @@ -18,9 +18,10 @@ were deleted leaves no rolling entry, so the next run starts cold, and this exit in a later post step does not count once the save step has succeeded. This also exits 1 when the leg has not started START_SECONDS after this script started, and when the leg has not reached its save, or its save has not finished, GIVE_UP_SECONDS after the leg started. An absent warm leg is treated as finished only -when the most recent earlier attempt that lists it reports success and the current attempt lists -no `cache prune` job, which runs from the start of "Re-run all jobs". Otherwise this keeps polling -because reusable-workflow dependencies may still be scheduling it. +when the most recent earlier attempt that lists it reports success and the current attempt still +lists no `gate / select legs` job RERUN_GRACE_SECONDS after this script started: "Re-run all +jobs" lists that job from its start, and "Re-run failed jobs" after a successful leg does not. +Otherwise this keeps polling because reusable-workflow dependencies may still be scheduling it. """ from datetime import datetime, timezone @@ -36,7 +37,12 @@ WARM_JOB = re.compile(r'^gate / cache warm \(') # The jobs the gate's legs need (craft-common-actions .github/workflows/gate.yml): when one of # them fails or is canceled, the legs are skipped and no warm leg is listed. NEEDED_JOBS = re.compile(r'^gate / (select legs$|build \()') -PRUNE_JOB = 'cache prune' +# The gate's first job. "Re-run all jobs" lists it; "Re-run failed jobs" lists it only when it +# failed, and then no warm leg succeeded before. +SELECT_JOB = 'gate / select legs' +# How long an attempt that does not list SELECT_JOB is watched before the warm leg counts as +# finished in an earlier attempt. +RERUN_GRACE_SECONDS = 5 * 60 ROLLING = '-gate-crates-' # The gate-setup action's post step, which saves the dependency cache (craft-common-actions # actions/gate-setup, under the gate's `Setup` step). @@ -135,9 +141,10 @@ def legs_stopped(jobs): return any(NEEDED_JOBS.match(j['name']) and j['status'] == 'completed' and j.get('conclusion') in STOPPED for j in jobs) -def not_in_attempt(jobs, earlier_jobs): - """True when no prune job is listed and the most recent earlier warm leg succeeded.""" - if any(j['name'] == PRUNE_JOB for j in jobs): +def not_in_attempt(jobs, earlier_jobs, waited): + """True when SELECT_JOB is not listed `waited` seconds after this script started, at least + RERUN_GRACE_SECONDS, and the most recent earlier warm leg succeeded.""" + if waited < RERUN_GRACE_SECONDS or any(j['name'] == SELECT_JOB for j in jobs): return False for attempt in sorted(earlier_jobs, reverse=True): job = warm_job(earlier_jobs[attempt]) @@ -185,7 +192,7 @@ def main(): earlier_jobs[earlier] = previous.get('jobs', []) if warm_job(earlier_jobs[earlier]) is not None: break - if not_in_attempt(jobs.get('jobs', []), earlier_jobs): + if not_in_attempt(jobs.get('jobs', []), earlier_jobs, (datetime.now(timezone.utc) - began).total_seconds()): print('the cache warm leg is not part of this attempt (it succeeded in an earlier one); nothing deleted') return if legs_stopped(jobs.get('jobs', [])): From 3575fa6d2b4ecd77d8337169a9b6cd51c51ff280 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:18:14 +0100 Subject: [PATCH 224/264] Leave the artwork visible while previewing a transform --- crates/ui-egui/src/dialogs/transform.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/ui-egui/src/dialogs/transform.rs b/crates/ui-egui/src/dialogs/transform.rs index 7437183918..d0618d050a 100644 --- a/crates/ui-egui/src/dialogs/transform.rs +++ b/crates/ui-egui/src/dialogs/transform.rs @@ -150,11 +150,16 @@ pub(crate) fn open(app: &mut VectorcraftApp, kind: Kind, tool: &Value) { let document = app.session.active().map(|doc| (doc.uid, doc.reverts)); let rows = rows(app, kind, &opening); let fields = fields_of(&rows, &opening); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); let dialog = HostedParamDialog::new(&ctx, kind.command(), fields, move |f| { if kind == Kind::Move { link_distance_and_angle(f); } let dialog = ParamDialog::new(kind.command(), kind.title(), rows.clone()).previews(true).values(Bind::bound(f)); + let dialog = match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + }; if kind == Kind::Move { dialog.remember(MOVE_KEY) } else { dialog } }); // A dialog this one replaces leaves its preview behind otherwise. From 28f33ca04c29a0e6c75d256ad873099ff3ce9e0b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:20:08 -0800 Subject: [PATCH 225/264] xtask: test-lint scopes bindings, spans ignore reasons and names its failing rules - The module docs and docs/development.md name the four rules that fail the check, and describe `only-weak` and `self-compare` by what they match (`len() > 0`, `assert_ne!`). - The changed-lines diff passes `--inter-hunk-context=0`, so a clone's `diff.interHunkContext` cannot mark unchanged lines between two edits. - Single-letter workflow variables count as set. - Test names with non-ASCII letters are read whole. - An allow in a block comment needs a reason before `*/`. - `all-unguarded` uses only a binding still in scope at the assertion, treats a `const` declared with different values as unknown, and drops a counted local once its collection may shrink or be replaced. - `only-weak` ignores `unwrap_err`, `expect_err` and `panic!` in failure messages. - `self-compare` leaves out operands that call a method returning the next value each time (`next`, `pop_front`, `recv` and others). - An `ignore-without-reason` span reaches the attribute's `]`, so a change to a reason on the next line counts. --- docs/development.md | 2 +- xtask/src/test_lint.rs | 174 +++++++++++++++++++++++++++++++++++------ 2 files changed, 149 insertions(+), 27 deletions(-) diff --git a/docs/development.md b/docs/development.md index cfd02bacc8..efb554b561 100644 --- a/docs/development.md +++ b/docs/development.md @@ -351,7 +351,7 @@ The app decides which cursors exist; whoever draws them works from the list. For ## Test lint -`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on a test whose only checks are `is_ok`, `is_some` or `!is_empty` (`only-weak`), `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. +`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on a test whose only checks are that a value exists or a collection is not empty (`is_ok`, `is_some`, `!is_empty`, `len() > 0`: `only-weak`), an `assert_eq!` or `assert_ne!` of an expression with itself, such as `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. ## Tests diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index a0e8f8040a..f442c9681d 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -21,7 +21,8 @@ //! * `only-weak`: every assertion is `is_ok()`, `is_some()`, `!is_empty()` or `len() > 0`, and the //! test calls no asserting helper; //! * `self-compare`: `assert_eq!(x, x)` or `assert_ne!(x, x)` on the same expression, when that -//! expression calls nothing with arguments (two calls with arguments check determinism); +//! expression calls nothing with arguments (two calls with arguments check determinism) and no +//! method that returns the next value each time ([`ADVANCING`], such as `next`); //! * `exit-status-only`: a test that runs a process and checks only its exit status, reading no //! output, with a status check in any condition or compared operand of a standard assertion; //! * `no-assertion`: no assertion macro, `panic!`, `unwrap_err`, `expect_err` or asserting helper, @@ -50,8 +51,9 @@ //! rules about a whole test it can be on any line from the line above the test attribute to the //! `fn` line. An allow without a reason exempts nothing. //! -//! `cargo xtask test-lint` fails on the hits in the lines and tests changed since a base: `--base -//! ` or `TEST_LINT_BASE`; in GitHub Actions the first parent of `HEAD` (a pull request's +//! `cargo xtask test-lint` fails on hits of `only-weak`, `self-compare`, `ignore-without-reason` +//! and `sleep` in the lines and tests changed since a base, and lists the other rules' hits there +//! without failing. The base is `--base ` or `TEST_LINT_BASE`; in GitHub Actions the first parent of `HEAD` (a pull request's //! merge commit is checked out, and a shallow checkout fetches that parent); elsewhere the merge //! base of `HEAD` and `upstream/main` or `origin/main`. Uncommitted and untracked files count as //! changed. Hits on unchanged lines are counted but do not fail it. `--all` lists every hit in the @@ -186,7 +188,8 @@ pub struct Hit { pub note: String, /// The first and last line of what the hit covers: the test, from its attribute to its closing /// brace, for a rule about a whole test or `all-unguarded`, through the second operand for - /// `self-compare`, through the variable's name for `env-gate-unset`, else `line`. This span + /// `self-compare`, through the variable's name for `env-gate-unset`, through the attribute's + /// `]` for `ignore-without-reason`, else `line`. This span /// controls changed-line detection; `all-unguarded` and `self-compare` exemptions still apply /// only near `line`. pub first: usize, @@ -384,7 +387,20 @@ fn resolve_base(root: &Path, explicit: Option) -> Result fn changed_lines(root: &Path, base: &str) -> Result>>, String> { let diff = git( root, - &["-c", "core.quotepath=off", "diff", "-U0", "--no-color", "--no-ext-diff", "--src-prefix=a/", "--dst-prefix=b/", base, "--", "*.rs"], + &[ + "-c", + "core.quotepath=off", + "diff", + "-U0", + "--inter-hunk-context=0", + "--no-color", + "--no-ext-diff", + "--src-prefix=a/", + "--dst-prefix=b/", + base, + "--", + "*.rs", + ], )?; let mut out = parse_diff(&diff); for path in git(root, &["ls-files", "-z", "--others", "--exclude-standard", "--", "*.rs"])?.split('\0').filter(|p| !p.is_empty()) { @@ -511,9 +527,7 @@ fn printed(line: &str, from: usize) -> bool { } fn env_assignment_name(name: &str) -> bool { - name.len() > 1 - && name.starts_with(|c: char| c.is_ascii_uppercase()) - && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_') + name.starts_with(|c: char| c.is_ascii_uppercase()) && name.bytes().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_') } /// Removes comment text outside quotes from a workflow line. @@ -820,7 +834,8 @@ fn fn_after(m: &[u8], attr: usize, from: usize) -> Option { return None; } let name_start = skip_ws(m, fn_at + 2); - let name_end = name_start + m[name_start..].iter().take_while(|&&c| is_ident(c)).count(); + // Identifiers may hold non-ASCII letters (`échec`); their UTF-8 bytes are all 0x80 or above. + let name_end = name_start + m[name_start..].iter().take_while(|&&c| is_ident(c) || c >= 0x80).count(); if name_end == name_start { return None; } @@ -1124,7 +1139,8 @@ fn allows(src: &str, m: &[u8]) -> Vec<(usize, Rule)> { src.match_indices(ALLOW) .filter(|&(p, _)| m[p] == b' ' && literals[p] == b't') .filter_map(|(p, _)| { - let rest = src[p + ALLOW.len()..].lines().next()?; + // The reason ends with the line, or with the block comment that holds the marker. + let rest = src[p + ALLOW.len()..].lines().next()?.split("*/").next()?; let mut words = rest.split_whitespace(); let rule = Rule::from_id(words.next()?)?; words.next().map(|_| (lines.of(p), rule)) @@ -1622,7 +1638,7 @@ fn array_receiver(receiver: &str) -> &str { receiver.strip_suffix(".iter()").or_else(|| receiver.strip_suffix(".into_iter()")).unwrap_or(receiver) } -/// The fewest items a plain local receiver has after its latest preceding binding: from the +/// The fewest items a plain local receiver has after its latest preceding binding still in scope: from the /// binding ([`array_binding`]) or a loop that fills it ([`loop_fill_len`]), and 0 when a later /// statement may shrink or replace it ([`may_shrink`]). fn bound_len(receiver: &str, body: &[u8], sizes: &Sizes) -> usize { @@ -1631,7 +1647,8 @@ fn bound_len(receiver: &str, body: &[u8], sizes: &Sizes) -> usize { return 0; } let name = name.as_bytes(); - let Some((len, end)) = words(body, b"let", 0, body.len()).into_iter().rev().find_map(|at| array_binding(body, at, name, sizes)) else { + let mut in_scope = words(body, b"let", 0, body.len()).into_iter().rev().filter(|&at| open_at_end(body, at)); + let Some((len, end)) = in_scope.find_map(|at| array_binding(body, at, name, sizes)) else { return 0; }; if may_shrink(body, name, end) { @@ -1640,6 +1657,21 @@ fn bound_len(receiver: &str, body: &[u8], sizes: &Sizes) -> usize { len.max(loop_fill_len(body, name, end, sizes)) } +/// Whether the block holding offset `at` of `body` is still open at the end of `body`: a binding +/// there is still in scope. +fn open_at_end(body: &[u8], at: usize) -> bool { + let mut depth = 0usize; + for &c in &body[at..] { + match c { + b'{' => depth += 1, + b'}' if depth == 0 => return false, + b'}' => depth -= 1, + _ => {} + } + } + true +} + /// For a `let` at `at` that binds `name` (allowing `mut`): the fewest items its array type /// annotation gives (which decides when there is one), else its initializer gives ([`expr_len`]), /// and where the statement ends. `None` for a binding of another name. @@ -2012,10 +2044,11 @@ fn int_literal(text: &str) -> Option { text[..digits].replace('_', "").parse().ok() } -/// `const NAME: T = ;` in a masked file; a name declared more than once keeps -/// its smallest value, and 0 when one of its values is not a literal. +/// `const NAME: T = ;` in a masked file. A name declared more than once with +/// different values, or with a value that is not a literal, is left out (its value is unknown). fn file_consts(file: &[u8]) -> HashMap { - let mut out: HashMap = HashMap::new(); + // `None` for a name declared with a value that is not a literal or with different values. + let mut out: HashMap> = HashMap::new(); for at in words(file, b"const", 0, file.len()) { let start = skip_ws(file, at + 5); let end = start + file[start..].iter().copied().take_while(|&c| is_ident(c)).count(); @@ -2025,12 +2058,14 @@ fn file_consts(file: &[u8]) -> HashMap { let stop = statement_end(file, end); let stmt = norm(&file[end..stop]); let Some((_, value)) = stmt.split_once('=') else { continue }; - let value = int_literal(value).unwrap_or(0); + let value = int_literal(value); let name = String::from_utf8_lossy(&file[start..end]).into_owned(); let slot = out.entry(name).or_insert(value); - *slot = (*slot).min(value); + if *slot != value { + *slot = None; + } } - out + out.into_iter().filter_map(|(name, value)| Some((name, value?))).collect() } /// A `let` of a plain name: the name, where the statement ends, and whether it binds an expression @@ -2039,6 +2074,8 @@ struct Binding { name: Vec, end: usize, counts: bool, + /// The local whose method the initializer calls (`xs` in `let n = xs.len()`). + source: Option>, } /// Every `let` of a plain name in `body`, in order. @@ -2056,19 +2093,24 @@ fn bindings(body: &[u8]) -> Vec { } let stop = statement_end(body, end); let stmt = norm(&body[end..stop]); - let counts = stmt.split_once('=').is_some_and(|(_, init)| SIZE_CHECKS.iter().any(|g| init.contains(g))); - Some(Binding { name: body[start..end].to_vec(), end: stop, counts }) + let init = stmt.split_once('=').map_or("", |(_, init)| init); + let counts = SIZE_CHECKS.iter().any(|g| init.contains(g)); + let ident = init.bytes().take_while(|&c| is_ident(c)).count(); + let source = (ident > 0 && init[ident..].starts_with('.')).then(|| init.as_bytes()[..ident].to_vec()); + Some(Binding { name: body[start..end].to_vec(), end: stop, counts, source }) }) .collect() } /// Whether `body[from..to]` (an assertion operand) reads a local whose binding reaching that -/// point checks a size and was not assigned since. +/// point checks a size and was not assigned since, of a collection that no later code may shrink +/// or replace. fn reads_counted_local(body: &[u8], all: &[Binding], from: usize, to: usize) -> bool { all.iter().filter(|b| b.counts && b.name != b"_").any(|b| { words(body, &b.name, from, to).into_iter().any(|p| { let reaching = all.iter().rfind(|o| o.name == b.name && o.end <= p); - reaching.is_some_and(|r| r.counts && !may_shrink(&body[..p], &r.name, r.end)) + reaching + .is_some_and(|r| r.counts && !may_shrink(&body[..p], &r.name, r.end) && r.source.as_ref().is_none_or(|s| !may_shrink(body, s, r.end))) }) }) } @@ -2089,13 +2131,20 @@ fn is_weak(cond: &str) -> bool { fn only_weak(v: &View) -> Option { let all_weak = v.asserts.iter().all(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && is_weak(&v.first_arg(a))); - let other = contains(v.body(), b"panic!") || contains(v.body(), b".unwrap_err()") || contains(v.body(), b".expect_err("); + // Failure messages run only after an assertion has failed, so a check there does not count. + let body = v.body_without_messages(); + let other = contains(&body, b"panic!") || contains(&body, b".unwrap_err()") || contains(&body, b".expect_err("); if v.asserts.is_empty() || !all_weak || other || v.delegates || v.should_panic { return None; } Some(v.whole(Rule::OnlyWeak, format!("its {} assertion(s) only check is_ok/is_some/non-empty", v.asserts.len()))) } +/// Methods that return the next value of something each time (`assert_ne!(it.next(), it.next())` +/// compares two items). +const ADVANCING: &[&str] = + &["next", "next_back", "pop", "pop_front", "pop_back", "recv", "try_recv", "read_line", "take", "tick", "step", "advance", "now", "elapsed"]; + fn self_compare(v: &View) -> Vec { v.asserts .iter() @@ -2105,7 +2154,8 @@ fn self_compare(v: &View) -> Vec { let (l, r) = (v.file.src_norm(*a.args.first()?), v.file.src_norm(right)); let (l, r) = (l.trim_start_matches('&'), r.trim_start_matches('&')); let calls_with_args = l.replace("()", "").contains(['(', '!']); - (l == r && !l.is_empty() && !calls_with_args).then(|| { + let advances = ADVANCING.iter().any(|m| l.contains(&format!(".{m}()"))); + (l == r && !l.is_empty() && !calls_with_args && !advances).then(|| { let mut h = v.hit(a.at, Rule::SelfCompare, format!("{}! compares `{l}` with itself", a.name)); let end = right.0 + v.file.m[right.0..right.1].trim_ascii_end().len(); h.last = v.file.lines.of(end.saturating_sub(1)); @@ -2373,7 +2423,10 @@ fn ignore_hits(file: &File) -> Vec { }; if !reason { let test = file.tests.iter().find(|t| t.fn_at > at).map_or("", |t| t.name.as_str()); - out.push(file.hit(at - 2, Rule::IgnoreWithoutReason, test, "#[ignore] gives no reason".into())); + // The hit sits on `#[ignore`; its span reaches the attribute's `]`, past a reason on a later line. + let mut hit = file.hit(at - 2, Rule::IgnoreWithoutReason, test, "#[ignore] gives no reason".into()); + hit.last = matching(m, at - 1).map_or(hit.line, |close| file.lines.of(close)); + out.push(hit); } } out @@ -3579,7 +3632,7 @@ mod tests { #[test] fn workflow_variables_count_as_set() { let names: Vec = upper_words("env:\n AFFINITY_CORPUS_REQUIRED: 1\n run: X=1 cargo test # A\n").collect(); - assert_eq!(names, ["AFFINITY_CORPUS_REQUIRED"]); + assert_eq!(names, ["AFFINITY_CORPUS_REQUIRED", "X"]); assert!(set_by_system("CARGO_MANIFEST_DIR") && set_by_system("HOME") && !set_by_system("MY_SAMPLES")); } @@ -3729,4 +3782,73 @@ mod tests { let walk = "#[test]\nfn t() {\n let n = files().filter(|p| p.ends_with(r#\".rs\"#)).count();\n assert_eq!(n, 4);\n}\n"; assert_eq!(hits(walk), [(3, "reads-source")]); } + + #[test] + fn single_letter_variables_set_in_ci_count() { + let src = "#[test]\nfn t() {\n let dir = std::env::var(\"X\");\n assert_eq!(f(dir), 3);\n}\n"; + assert_eq!(hits(src), [(3, "env-gate-unset")]); + let ctx = Ctx { helpers: HashMap::new(), ci_env: upper_words("env:\n X: 1\n").collect() }; + assert_eq!(hits_in("crates/x/src/tests.rs", src, &ctx), []); + } + + #[test] + fn tests_with_non_ascii_names_are_checked() { + let src = "#[test]\nfn échec() {\n assert!(f().is_ok());\n}\n"; + assert_eq!(lint_file("crates/x/src/tests.rs", src, &ctx()).iter().map(|h| (h.line, h.test.as_str())).collect::>(), [(2, "échec")]); + } + + #[test] + fn block_comment_allows_need_a_reason_before_the_closing_delimiter() { + let bare = "#[test]\nfn t() {\n thread::sleep(D); /* test-lint: allow sleep */\n assert_eq!(f(), 1);\n}\n"; + assert_eq!(hits(bare), [(3, "sleep")]); + assert_eq!(hits(&bare.replace("sleep */", "sleep the clock has a 2 ms step */")), []); + } + + #[test] + fn bindings_out_of_scope_do_not_guard_all() { + let src = "#[test]\nfn t() {\n let xs: Vec = vec![];\n {\n let xs = vec![1];\n use_it(&xs);\n }\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(src), [(8, "all-unguarded")]); + let inside = "#[test]\nfn t() {\n let xs: Vec = vec![];\n {\n let xs = vec![1];\n assert!(xs.iter().all(|x| *x > 0));\n }\n use_it(&xs);\n}\n"; + assert_eq!(hits(inside), []); + } + + #[test] + fn constants_with_several_values_are_unknown() { + let src = "mod a { const START: usize = 0; }\nmod b {\nconst START: usize = 2;\nconst END: usize = 2;\n#[test]\nfn t() {\n let xs: Vec = (START..END).collect();\n assert!(xs.iter().all(|x| *x > 0));\n}\n}\n"; + assert_eq!(hits(src), [(8, "all-unguarded")]); + assert_eq!(hits(&src.replace("mod a { const START: usize = 0; }\n", "").replace("END: usize = 2", "END: usize = 4")), []); + } + + #[test] + fn a_count_stops_guarding_when_its_collection_changes() { + let src = + "#[test]\nfn t() {\n let mut xs = f();\n let n = xs.len();\n assert_eq!(n, 1);\n assert!(xs.iter().all(|x| *x > 0));\n}\n"; + assert_eq!(hits(src), []); + let cleared = src.replace(" assert_eq!(n, 1);", " xs.clear();\n assert_eq!(n, 1);"); + assert_eq!(hits(&cleared), [(7, "all-unguarded")]); + } + + #[test] + fn checks_in_failure_messages_do_not_end_only_weak() { + let src = "#[test]\nfn t() {\n assert!(parse(input).is_ok(), \"{:?}\", probe().unwrap_err());\n}\n"; + assert_eq!(hits(src), [(2, "only-weak")]); + assert_eq!(hits(&src.replace(" assert!", " let _ = probe().unwrap_err();\n assert!")), []); + } + + #[test] + fn advancing_calls_are_not_self_comparisons() { + for operand in ["it.next()", "q.pop_front()", "rx.recv()"] { + let src = format!("#[test]\nfn t() {{\n assert_ne!({operand}, {operand});\n}}\n"); + assert_eq!(hits(&src), [], "{operand}"); + } + assert_eq!(hits("#[test]\nfn t() {\n assert_eq!(x.len(), x.len());\n}\n"), [(3, "self-compare")]); + } + + #[test] + fn ignore_spans_reach_a_reason_on_the_next_line() { + let src = "#[test]\n#[ignore =\n \"\"]\nfn t() {\n assert_eq!(f(), 1);\n}\n"; + let found = lint_file("crates/x/src/tests.rs", src, &ctx()); + assert_eq!(found.iter().map(|h| (h.rule, h.line, h.first, h.last)).collect::>(), [(Rule::IgnoreWithoutReason, 2, 2, 3)]); + assert!(touches(&found[0], Some(&[3].into_iter().collect())), "a change to the reason alone"); + } } From e7a2662ee1e1c85f5b3b7695f8c401fcbf6d6a51 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:21:56 +0100 Subject: [PATCH 226/264] Count the selected-art pointer in the cursor catalog --- crates/ui-egui/src/cursors.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rs index e97016dff1..6af53f1028 100644 --- a/crates/ui-egui/src/cursors.rs +++ b/crates/ui-egui/src/cursors.rs @@ -71,7 +71,7 @@ fn badged(badge: CursorBadge) -> cb::Cursor { PaintedCursor::badged(CursorIcon::Default, badge).into() } -/// The rotate pointer beside a box, at `octant` from the box's centre (0 up, clockwise in 45° steps). +/// The rotate pointer beside a box, at `octant` from the box's centre (0 up, clockwise in 45° steps). /// Its arc bends round the corner it is at, so it opens toward the centre: opposite the octant. fn turn_toward(octant: u8) -> cb::Cursor { let angle = f32::from(octant % 8) * std::f32::consts::FRAC_PI_4; @@ -196,7 +196,7 @@ pub(crate) fn request_busy(app: &crate::VectorcraftApp, ctx: &egui::Context) { /// Every cursor with a look: its own, or the one it borrows. #[cfg(test)] -const GLYPHS: [Cursor; 99] = [ +const GLYPHS: [Cursor; 100] = [ Cursor::Hand, Cursor::HandGrab, Cursor::ZoomIn, From 42187cdbdf45d9d5bc7a75a554964e9b0611dda6 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:22:21 +0100 Subject: [PATCH 227/264] Exercise playback using the active source artboard at copy time --- crates/ui-egui/src/panels/actions/tests_playback.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/panels/actions/tests_playback.rs b/crates/ui-egui/src/panels/actions/tests_playback.rs index f566eb22fc..d81c005ef1 100644 --- a/crates/ui-egui/src/panels/actions/tests_playback.rs +++ b/crates/ui-egui/src/panels/actions/tests_playback.rs @@ -89,7 +89,9 @@ fn actions_play_on_the_artboard_active_when_they_play() { app.ui.actions.push(Action { set, ..Action::new(name, steps) }).unwrap(); set_actions(app, 0).len() - 1 }; + app.view_mut().unwrap().artboard = 1; app.run("edit.copy", json!({})).unwrap(); + app.view_mut().unwrap().artboard = 0; let align = record(&mut app, "Align Left", "object.align", json!({"horizontal": "left", "to": "artboard"})); assert_eq!(bounds(&app, &[rect]).x0, boards[0].x0, "aligned to artboard 0 while recording"); let paste = record(&mut app, "Paste in Place", "edit.pasteInPlace", json!({})); From 7aee17deaaf7f00cd078ffff57cfde8299258b82 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:25:15 -0800 Subject: [PATCH 228/264] Tests: the 3D face-limit and gray-level smoothing tests check the same cases with small inputs The two Extrude & Bevel tests of the faces an object's solids keep together built members and strokes from 16,384-corner polygons until they passed MAX_OBJECT_FACES. They took 230 s and 23.5 s on CI. The solids code now reads the limit through object_face_limit(), which tests can lower on their own thread (OBJECT_FACE_LIMIT), and both tests build 64-corner polygons against a limit of exactly three members' or three strokes' faces. The limit is now met exactly, so the tests also check that a solid at the limit still draws. Outside the crate's own tests, object_face_limit() is MAX_OBJECT_FACES. The smoothing test of every pair of gray levels ran the filter on 262,144 one-pixel-pair images, and each pass along a column started two threads. It now puts every pair in one 2-pixel-wide image and one 2-pixel-high image, so it checks the same 65,536 pairs in four passes. --- crates/effects/src/solids.rs | 37 +++++++++++++++++++------- crates/effects/src/solids/tests.rs | 34 ++++++++++++++++++----- crates/effects/src/solids/wireframe.rs | 6 ++--- crates/trace/src/smooth.rs | 30 +++++++++++++++------ 4 files changed, 80 insertions(+), 27 deletions(-) diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index ef1608a5d9..83bb1ca9f7 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -600,9 +600,9 @@ fn check_solids(id: &str, p: &Value, shapes: &[Profile]) -> Result<(), String> { } let (parts, bounds) = solid_parts(shapes, b); if !cast { - return built_solids(id, p, &parts, bounds, MAX_OBJECT_FACES).try_for_each(|r| r.map(|_| ())); + return built_solids(id, p, &parts, bounds, object_face_limit()).try_for_each(|r| r.map(|_| ())); } - let built = built_solids_cast(id, p, &parts, bounds, MAX_OBJECT_FACES, true, false, None) + let built = built_solids_cast(id, p, &parts, bounds, object_face_limit(), true, false, None) .map(|r| r.map(|solid| solid.and_then(|(_, faces)| faces))) .collect::, String>>()?; cast_built(id, p, shapes, built).map(|_| ()) @@ -1025,13 +1025,30 @@ thread_local! { /// [`built_solids`] have built on this thread, for the tests. The solids built to cast a shadow /// ([`cast_shadow`]) count too. static SOLID_GEOMETRY_BUILT: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// The limit [`object_face_limit`] gives on this thread: [`MAX_OBJECT_FACES`] unless a test sets + /// a lower one, so that a test of the limit builds small solids. + pub(crate) static OBJECT_FACE_LIMIT: std::cell::Cell = const { std::cell::Cell::new(MAX_OBJECT_FACES) }; +} + +/// Most faces the Extrude & Bevel or Inflate solids of one effect on one object keep together: +/// [`MAX_OBJECT_FACES`]. +#[cfg(not(test))] +fn object_face_limit() -> usize { + MAX_OBJECT_FACES +} + +/// Most faces the Extrude & Bevel or Inflate solids of one effect on one object keep together: +/// [`MAX_OBJECT_FACES`], or the lower limit a test set in [`OBJECT_FACE_LIMIT`]. +#[cfg(test)] +fn object_face_limit() -> usize { + OBJECT_FACE_LIMIT.with(std::cell::Cell::get) } /// The solids Extrude & Bevel (Classic included) or Inflate `id` with parameters `p` builds from /// `parts` ([`solid_parts`]) about `bounds`, one result for each part in order, each built only as /// the iterator reaches it. A stroke's solid past its own limits is `None` (left out of the art, its /// faces not counted); a fill's is an error. The faces of the solids kept count together: once they -/// pass `limit` ([`MAX_OBJECT_FACES`] for the art) the result is an error, and +/// pass `limit` ([`object_face_limit`] for the art) the result is an error, and /// no later part is built. An error ends the iterator. fn built_solids<'a>( id: &'a str, @@ -1211,7 +1228,7 @@ fn rects_overlap(a: Rect, b: Rect) -> bool { /// How many faces [`cut_stroke_faces`] may add to solids painted by `items` that hold `faces` faces /// and whose paint copies take `paint_bytes` so far: as many as keep the faces within -/// [`MAX_OBJECT_FACES`] and the copies within the allowance, each added face counted as +/// [`object_face_limit`] and the copies within the allowance, each added face counted as /// [`MAX_FACET_COPIES`] copies of the costliest stroke's paint. fn cut_room<'a>(items: impl Iterator, faces: usize, paint_bytes: usize) -> usize { let per_face = items @@ -1225,7 +1242,7 @@ fn cut_room<'a>(items: impl Iterator, faces: usize, p .unwrap_or(0) .max(1); let affordable = crate::revolve::MAX_PAINT_COPIES.saturating_sub(paint_bytes) / per_face; - MAX_OBJECT_FACES.saturating_sub(faces).min(affordable) + object_face_limit().saturating_sub(faces).min(affordable) } /// In `solids`, each solid's part ([`Paints`]), its shape's index and its faces, cut each face of a @@ -2403,7 +2420,7 @@ fn surfaces_with( let map_art = MapArt::of(doc, &fx.id, &p).filter(|_| fx.id == CLASSIC_EXTRUDE); let mut layouts: Vec = vec![]; let mut surfaces_before = 0usize; - let made = built_solids_cast(&fx.id, &p, &parts, bounds, MAX_OBJECT_FACES, cast, membrane, carrier); + let made = built_solids_cast(&fx.id, &p, &parts, bounds, object_face_limit(), cast, membrane, carrier); for (k, ((item, opacity, area, rule, scopes, member), f)) in parts.iter().zip(made).enumerate() { let item: &AppearanceItem = item; let layout = map_art.as_ref().map(|_| { @@ -2471,7 +2488,7 @@ fn surfaces_with( if solids.iter().any(|s| ordered(s.4)) { // A stroke face that passes through a fill wall or another stroke's face is cut where it // does. The pieces count against the limits as the faces did: cutting stops before the - // faces pass MAX_OBJECT_FACES or their paint copies pass the allowance, so an effect that + // faces pass object_face_limit() or their paint copies pass the allowance, so an effect that // draws uncut still draws. let counts: Vec = solids.iter().map(|(.., f, _)| f.len()).collect(); let room = cut_room(solids.iter().map(|(item, ..)| *item), counts.iter().sum(), paint_bytes); @@ -2940,7 +2957,7 @@ fn frame_of(doc: Option<&Document>, n: &Node, item: Option, pick: &Pick<' // their handles. A stroke left out places none of its own. When a fill's solid can't be // built, or the solids together pass the limit, the art draws its source and no piece // places a handle. - let built: Vec = built_solids_cast(INFLATE, &p, &parts, bounds, MAX_OBJECT_FACES, false, true, None) + let built: Vec = built_solids_cast(INFLATE, &p, &parts, bounds, object_face_limit(), false, true, None) .collect::, String>>() .map(|solids| solids.into_iter().flatten().flat_map(|(f, _)| f).collect()) .unwrap_or_default(); @@ -3065,7 +3082,7 @@ pub fn map_surfaces_at(doc: Option<&Document>, n: &Node, item: Option, in let surfaces = vectorcraft_three_d::extrude_surfaces(area, *rule, bounds, options).unwrap_or_default(); let facets = vectorcraft_three_d::extrude(area, *rule, bounds, options, view).unwrap_or_default(); kept = kept.saturating_add(facets.len()); - if kept > MAX_OBJECT_FACES { + if kept > object_face_limit() { return None; } listed(&surfaces, &facets, &mut out); @@ -3309,7 +3326,7 @@ fn meshes_for(fx: &Effect, shapes: &[Profile], total: &mut usize, limit: usize) Err(e) => return Err(e), }; kept = kept.saturating_add(solid.facets.len()); - if kept > MAX_OBJECT_FACES { + if kept > object_face_limit() { return Err(vectorcraft_three_d::TOO_COMPLEX_SOLID.to_string()); } match solid.mesh() { diff --git a/crates/effects/src/solids/tests.rs b/crates/effects/src/solids/tests.rs index 49c301dd75..504fe1d777 100644 --- a/crates/effects/src/solids/tests.rs +++ b/crates/effects/src/solids/tests.rs @@ -1642,17 +1642,36 @@ fn polygon_node(id: u64, corners: usize) -> Node { Node::path(NodeId(id), path, Appearance::basic(Paint::solid(RED), Paint::None, 0.0)) } +/// Sets the faces the solids of one object keep together ([`OBJECT_FACE_LIMIT`]) to a lower limit +/// on this thread, and sets [`MAX_OBJECT_FACES`] again when dropped, so that a test of the limit +/// builds small solids. +struct FaceLimit(usize); + +impl FaceLimit { + fn set(limit: usize) -> Self { + Self(OBJECT_FACE_LIMIT.with(|l| l.replace(limit))) + } +} + +impl Drop for FaceLimit { + fn drop(&mut self) { + OBJECT_FACE_LIMIT.with(|l| l.set(self.0)); + } +} + /// A group whose members' solids each fit, but not all of them together, draws its source art, and /// the commands that check the effect report the error, as do its mesh and its wireframe; one -/// member fewer, within the limit, draws. +/// member fewer, exactly at the limit, draws. The limit is lowered to three members' faces. #[test] fn a_groups_solids_together_past_the_limit_draw_the_source() { - let member = polygon_node(1, 16_384); + let member = polygon_node(1, 64); let mut alone = member.clone(); alone.appearance.effects.push(fx(EXTRUDE, json!({}))); let [Ok(Some(each))] = solid_faces(EXTRUDE, &alone, MAX_OBJECT_FACES)[..] else { panic!("one solid") }; + let limit = 3 * each; + let _limit = FaceLimit::set(limit); // Members stacked in one place each build the same solid. - let fits = MAX_OBJECT_FACES / each; + let fits = limit / each; let group = |count: usize| { let members = (0..count) .map(|k| { @@ -1703,16 +1722,19 @@ fn an_inflate_frame_places_no_handle_when_a_fill_is_past_the_limits() { } /// A fill and strokes whose solids each fit, but not all of them together, draw the source art, -/// and the strokes after the one past the limit are not left out to make room. +/// and the strokes after the one past the limit are not left out to make room. The limit is +/// lowered to the fill's faces and three strokes'. #[test] fn a_fill_and_strokes_together_past_the_limit_draw_the_source() { - let mut n = polygon_node(1, 16_384); + let mut n = polygon_node(1, 64); n.appearance.effects.push(fx(EXTRUDE, json!({}))); let stroke = AppearanceItem::Stroke(StrokeLayer::new(Paint::solid(BLUE), 20.0)); n.appearance.items.push(stroke.clone()); // Strokes alike each build the same solid. let [Ok(Some(fill)), Ok(Some(each))] = solid_faces(EXTRUDE, &n, MAX_OBJECT_FACES)[..] else { panic!("a fill's solid and a stroke's") }; - let fits = (MAX_OBJECT_FACES - fill) / each; + let limit = fill + 3 * each; + let _limit = FaceLimit::set(limit); + let fits = (limit - fill) / each; assert!(fits >= 2, "{fill} + {fits} × {each}"); n.appearance.items.extend(std::iter::repeat_n(stroke, fits - 1)); assert!(validate_solid(&n, EXTRUDE, &json!({})).is_ok(), "{fill} + {fits} × {each}"); diff --git a/crates/effects/src/solids/wireframe.rs b/crates/effects/src/solids/wireframe.rs index 65ac8b0f7e..409a5c1dc3 100644 --- a/crates/effects/src/solids/wireframe.rs +++ b/crates/effects/src/solids/wireframe.rs @@ -12,8 +12,8 @@ use vectorcraft_three_d::Facet; use super::{ CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, INFLATE, Profile, ROTATE, built_solids, facets, geometry, has_solid, is_container, is_plane, - is_three_d, label_of, members, object_profile, region, reshape_members, resolve, resolve_for, solid, solid_paint_sources, solid_parts, - union_bounds, + is_three_d, label_of, members, object_face_limit, object_profile, region, reshape_members, resolve, resolve_for, solid, solid_paint_sources, + solid_parts, union_bounds, }; use crate::{GeomContext, is_geometry}; @@ -258,7 +258,7 @@ pub(crate) fn facet_paths(fx: &Effect, shapes: &[Profile]) -> Result = (0..=255u8).flat_map(|p| (0..=255u8).map(move |q| (p, q))).collect(); + let n = pairs.len(); + // The pair of pixel `i` in the output of the pass along rows (`true`) or columns. + let pair_of = |along_rows: bool, i: usize| pairs.get(if along_rows { i / 2 } else { i % n }).copied(); + let first_difference = |along_rows: bool, fast: &[u8], slow: &[u8]| { + if fast.len() != slow.len() { + return Some(format!("lengths {} and {}", fast.len(), slow.len())); } + fast.chunks(4).zip(slow.chunks(4)).position(|(a, b)| a != b).map(|i| format!("pair {:?}", pair_of(along_rows, i))) + }; + // Gray, and a mixed pair: the two pixels made from levels `p` and `q`. + type Kind = fn(u8, u8) -> [[u8; 4]; 2]; + let kinds: [Kind; 2] = [|p, q| [[p, p, p, 255], [q, q, q, 255]], |p, q| [[p, q, p ^ q, 255], [q, p, q ^ 0x5a, 255]]]; + for (k, kind) in kinds.into_iter().enumerate() { + let rows: Vec = pairs.iter().flat_map(|&(p, q)| kind(p, q).into_iter().flatten()).collect(); + let columns: Vec = (0..2).flat_map(|side| pairs.iter().flat_map(move |&(p, q)| kind(p, q)[side])).collect(); + let fast = pass(&rows, 2, n, true, &weights); + assert_eq!(first_difference(true, &fast, &reference(&rows, 2, n, true)), None, "kind {k}, along rows"); + let fast = pass(&columns, n, 2, false, &weights); + assert_eq!(first_difference(false, &fast, &reference(&columns, n, 2, false)), None, "kind {k}, along columns"); } } From 0e9b1e8dd162852519d6c4a30fa41aa118fd8eba Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:28:10 +0100 Subject: [PATCH 229/264] Preserve the degree symbol in the cursor documentation --- crates/ui-egui/src/cursors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rs index 6af53f1028..b120d35c4a 100644 --- a/crates/ui-egui/src/cursors.rs +++ b/crates/ui-egui/src/cursors.rs @@ -71,7 +71,7 @@ fn badged(badge: CursorBadge) -> cb::Cursor { PaintedCursor::badged(CursorIcon::Default, badge).into() } -/// The rotate pointer beside a box, at `octant` from the box's centre (0 up, clockwise in 45° steps). +/// The rotate pointer beside a box, at `octant` from the box's centre (0 up, clockwise in 45° steps). /// Its arc bends round the corner it is at, so it opens toward the centre: opposite the octant. fn turn_toward(octant: u8) -> cb::Cursor { let angle = f32::from(octant % 8) * std::f32::consts::FRAC_PI_4; From 13b9e22c4c8881cfad9aa1c832b09d70eddac71d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:29:35 -0800 Subject: [PATCH 230/264] Tests: merge two duplicate engine tests, keeping every assertion Two engine tests ran the same inputs as another test and checked them again with a tighter bound or a second check. - commands_that_do_not_wait_for_a_tool_edit_change_no_document ran every junk case of every non-waiting command on the Single and Multi fixtures, which every_command_with_junk_params also runs. The junk sweep now compares tool_edit_state before and after each of those calls as well as its own panic, interaction and invariant checks. The tool-edit test keeps only the cases that turn each option on and off (option_cases), which the junk sweep does not send. - turned_colored_inflate_facets_and_seams_cover_their_edges_once drew the same turned Inflate in the same solid fill as one case of colored_light_surfaces_match_supersampling_at_internal_facet_edges. That case now carries its bound (at most one RGB channel more than 3 levels off, by no more than 4) and the separate test is removed. Each merged test fails on a fault that only the removed check caught before: document.info bumping the revision on a non-object params value fails every_command_with_junk_params ("document.info "str" [Multi]"), and solid_surface drawing every facet as a fill and a seam stroke fails the supersampling test (2 channels off, at most 5). docs/target-app-parity.md and waits_for_tool_edit's doc comment name the tests that now hold these checks. --- crates/engine/src/command_sets.rs | 4 +- crates/engine/tests/command_sweep.rs | 60 +++++++++++++------ crates/engine/tests/it/three_d_light_color.rs | 35 +++-------- docs/target-app-parity.md | 2 +- 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/crates/engine/src/command_sets.rs b/crates/engine/src/command_sets.rs index 1346dc40c5..3c7db76afe 100644 --- a/crates/engine/src/command_sets.rs +++ b/crates/engine/src/command_sets.rs @@ -118,8 +118,8 @@ const WAIT_FOR_TOOL_EDIT: &[&str] = &[ /// Does command `id`, run on its own, first apply the edit the active tool is computing on /// another thread and the input held for it ([`Session::finish_tool_edit`])? Every command that /// can edit, select, save or give a document a new revision does; queries that only read do not -/// (`commands_that_do_not_wait_for_a_tool_edit_change_no_document` in the command sweep checks -/// them). A frontend that adds params from +/// (`every_command_with_junk_params` and `commands_that_do_not_wait_for_a_tool_edit_change_no_document` +/// in the command sweep check them). A frontend that adds params from /// its own state (the active artboard) applies them first itself. pub fn waits_for_tool_edit(id: &str) -> bool { find_command(id).is_some_and(|spec| spec.journal || WAIT_FOR_TOOL_EDIT.contains(&id)) diff --git a/crates/engine/tests/command_sweep.rs b/crates/engine/tests/command_sweep.rs index 67d9b82f76..0fdb272343 100644 --- a/crates/engine/tests/command_sweep.rs +++ b/crates/engine/tests/command_sweep.rs @@ -30,17 +30,27 @@ fn no_panic(r: Result) -> Result Option { + probe_and_compare(fx, id, params, false).0 +} + +/// Run one call as [`probe`] does, returning its failure description, and with `compare`, also +/// `id params [fixture]` when the call changed the session's [`tool_edit_state`], panic or not. +fn probe_and_compare(fx: Fixture, id: &str, params: &Value, compare: bool) -> (Option, Option) { let mut s = fx.session(); + let before = compare.then(|| tool_edit_state(&s)); let r = catch_quiet(|| no_panic(s.execute(id, params))); - match r { + let changed = before.filter(|b| tool_edit_state(&s) != *b).map(|_| format!("{id} {params} [{fx:?}]")); + let failure = match r { Err(msg) => Some(format!("PANIC {id} {params} [{fx:?}]: {msg}")), Ok(_) => { if s.in_interaction() { - return Some(format!("{id} {params} [{fx:?}]: left an interaction open")); + Some(format!("{id} {params} [{fx:?}]: left an interaction open")) + } else { + check_session(&s).err().map(|e| format!("{id} {params} [{fx:?}]: {e}")) } - check_session(&s).err().map(|e| format!("{id} {params} [{fx:?}]: {e}")) } - } + }; + (failure, changed) } #[test] @@ -223,31 +233,43 @@ fn junk_cases(c: &vectorcraft_engine::CommandSpec, path: &str) -> Vec { cases } +/// Every command with every junk case in every fixture: no panic, no interaction left open and no +/// broken invariant ([`probe`]). In `Single` and `Multi`, every command that runs at once while the +/// active tool computes an edit on another thread (it does not `waits_for_tool_edit`) also leaves +/// the documents' revisions and selections, the active document and the current paint as they were +/// ([`tool_edit_state`]), as `commands_that_do_not_wait_for_a_tool_edit_change_no_document` checks +/// for the cases that turn each option on and off. #[test] fn every_command_with_junk_params() { let dir = vectorcraft_testkit::TempDir::new("sweep"); let path = safe_path(&dir); let mut failures = vec![]; + let mut changed = vec![]; let mut calls = 0usize; for fx in Fixture::ALL { for c in command_specs() { + let compare = matches!(fx, Fixture::Single | Fixture::Multi) && !vectorcraft_engine::waits_for_tool_edit(c.id); let cases = junk_cases(c, &path); for p in &cases { calls += 1; - if let Some(f) = probe(fx, c.id, p) { - failures.push(f); - } + let (failure, change) = probe_and_compare(fx, c.id, p, compare); + failures.extend(failure); + changed.extend(change); } } } assert!(calls > 5_000, "only {calls} calls"); failures.sort(); failures.dedup(); + changed.sort(); + changed.dedup_by(|a, b| a.split(' ').next() == b.split(' ').next()); assert!( - failures.is_empty(), - "{} failures (of {calls} calls):\n{}", + failures.is_empty() && changed.is_empty(), + "{} failures (of {calls} calls):\n{}\n{} commands change a document without waiting for a tool edit:\n{}", failures.len(), - failures.iter().take(60).cloned().collect::>().join("\n") + failures.iter().take(60).cloned().collect::>().join("\n"), + changed.len(), + changed.join("\n") ); } @@ -262,10 +284,11 @@ fn tool_edit_state(s: &Session) -> ToolEditState { (docs, s.active_index(), s.paint.clone()) } -/// The params the tool-edit sweep sends `c`: junk params, then each documented key turned on and -/// off, with a string under a file or folder key replaced by a location inside `path`'s folder. -fn tool_edit_cases(c: &vectorcraft_engine::CommandSpec, path: &str) -> Vec { - let mut cases = junk_cases(c, path); +/// The params the tool-edit sweep sends `c` beyond its junk cases, which the junk sweep checks: +/// each documented key turned on and off, with a string under a file or folder key replaced by a +/// location inside `path`'s folder. +fn option_cases(c: &vectorcraft_engine::CommandSpec, path: &str) -> Vec { + let mut cases = vec![]; for k in command_param_keys(c) { for v in [json!(true), json!(false), json!(1), json!("on")] { cases.push(json!({ k.as_str(): safe_value_for_command(c, &k, &v, path) })); @@ -333,7 +356,7 @@ fn sweep_cases_name_files_only_inside_the_temp_folder() { } } let mut cases = junk_params_for_command(c, &path); - cases.extend(tool_edit_cases(c, &path)); + cases.extend(option_cases(c, &path)); cases.extend(serializable_cases(c, &path)); for p in &cases { let Some(o) = p.as_object() else { continue }; @@ -485,8 +508,9 @@ fn sweep_cases_send_the_file_keys_of_the_command_catalog() { /// Every command that runs at once while the active tool computes an edit on another thread (a /// Shape Builder merge), rather than applying the edit first (`waits_for_tool_edit`), leaves the /// documents' revisions and selections, the active document and the current paint as they were, -/// with `{}`, junk params and params that turn its options on and off: the edit, computed for the -/// document as it was, still applies after it. +/// with params that turn its options on and off ([`option_cases`]; `every_command_with_junk_params` +/// checks the same with the junk cases): the edit, computed for the document as it was, still +/// applies after it. #[test] fn commands_that_do_not_wait_for_a_tool_edit_change_no_document() { let dir = vectorcraft_testkit::TempDir::new("sweep"); @@ -494,7 +518,7 @@ fn commands_that_do_not_wait_for_a_tool_edit_change_no_document() { let mut failures = vec![]; for fx in [Fixture::Single, Fixture::Multi] { for c in command_specs().iter().filter(|c| !vectorcraft_engine::waits_for_tool_edit(c.id)) { - let cases = tool_edit_cases(c, &path); + let cases = option_cases(c, &path); for p in &cases { let mut s = fx.session(); let before = tool_edit_state(&s); diff --git a/crates/engine/tests/it/three_d_light_color.rs b/crates/engine/tests/it/three_d_light_color.rs index be06539537..0a6e438a75 100644 --- a/crates/engine/tests/it/three_d_light_color.rs +++ b/crates/engine/tests/it/three_d_light_color.rs @@ -533,7 +533,8 @@ fn seams_against_supersampled(d: &Document, image: &vectorcraft_render::Rendered /// opacity once over the surface. Inflate seen straight on, one layer of facets, has no alpha off, and /// in opaque fills no RGB channel more than 3 levels off. Inflate turned so facets narrow to slivers /// at the edges, and Revolve with a cap over its body, draw facets over other facets, and have no -/// alpha off. +/// alpha off. In the turned Inflate's opaque solid fill, each facet and its seam cover an edge pixel +/// once together, so at most one RGB channel is more than 3 levels off, by no more than 4. #[test] fn colored_light_surfaces_match_supersampling_at_internal_facet_edges() { let lights = json!([ @@ -556,20 +557,21 @@ fn colored_light_surfaces_match_supersampling_at_internal_facet_edges() { let (mut s, _) = setup("threeD.inflate"); let change = json!({"index":0,"item":null,"params":{"ambient":10,"lights":lights,"rotationX":rotation.0,"rotationY":rotation.1}}); s.execute("effect.setParams", &change).unwrap(); - cases.push((format!("inflate {rotation:?}"), s, fills([100, 150], [200, 150]), rotation == (0, 0))); + cases.push((format!("inflate {rotation:?}"), s, fills([100, 150], [200, 150]), rotation == (0, 0), rotation == (50, 35))); } let (mut s, _) = capped_profile(); s.execute("effect.setParams", &json!({"index":0,"item":null,"params":{"ambient":10,"lights":lights}})).unwrap(); - cases.push(("revolve".into(), s, fills([80, 200], [240, 200]), false)); + cases.push(("revolve".into(), s, fills([80, 200], [240, 200]), false, false)); let mut failures = vec![]; - for (name, mut s, fills, one_layer) in cases { + for (name, mut s, fills, one_layer, turned) in cases { for fill in fills { s.execute("paint.setFill", &fill).unwrap(); let image = render(doc(&s)); let (measured, color, max, holes, worst) = seams_against_supersampled(doc(&s), &image); assert!(measured > 2_000, "{name} {fill}: {measured} pixels inside"); let opaque = !fill.to_string().contains("opacity"); - if holes > 0 || (one_layer && opaque && color > 0) { + let edges_once = turned && fill.get("color").is_some(); + if holes > 0 || (one_layer && opaque && color > 0) || (edges_once && (color > 1 || max > 4)) { failures.push(format!( "{name} {fill}: of {measured} pixels, {color} channels off by more than 3 (at most {max}), {holes} alphas off: {worst:?}" )); @@ -579,29 +581,6 @@ fn colored_light_surfaces_match_supersampling_at_internal_facet_edges() { assert!(failures.is_empty(), "{failures:#?}"); } -/// Inflate turned so its facets narrow to slivers at the edges, in an opaque solid fill under two -/// colored lights, against 3x averaged down ([`seams_against_supersampled`]): each facet and its -/// seam cover an edge pixel once together, so at most one RGB channel is more than 3 levels off, by -/// no more than 4, and no alpha is off. -#[test] -fn turned_colored_inflate_facets_and_seams_cover_their_edges_once() { - let lights = json!([ - {"color":"#ff0000","rotation":135,"height":35,"intensity":70}, - {"color":"#0000ff","rotation":-35,"height":25,"intensity":65} - ]); - let (mut s, _) = setup("threeD.inflate"); - let change = json!({"index":0,"item":null,"params":{"ambient":10,"lights":lights,"rotationX":50,"rotationY":35}}); - s.execute("effect.setParams", &change).unwrap(); - s.execute("paint.setFill", &json!({"color":"#ffcc66"})).unwrap(); - let image = render(doc(&s)); - let (measured, color, max, holes, worst) = seams_against_supersampled(doc(&s), &image); - assert!(measured > 2_000, "{measured} pixels inside"); - assert!( - holes == 0 && color <= 1 && max <= 4, - "of {measured} pixels, {color} channels off by more than 3 (at most {max}), {holes} alphas off: {worst:?}" - ); -} - /// The closed facet edges of colored-light surfaces survive SVG and PDF, read back and drawn at /// 1:1, and Expand Appearance: inside the art, every pixel stays opaque and within 6 levels of the /// live art. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 4df379b998..b62372f326 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2896,7 +2896,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Evidence for the shared light Color: geometry tests in `tests_lighting`, effect paint tests, command/save/undo/expand and SVG/PDF checks in `three_d_light_color`, and headless picker/reset/preview tests in `tests_revolve`. Revolve keeps smooth colored vector ramps and continuous flat-lit caps. Inflate geometry tests check spherical lighting, shared vertex/edge continuity, concave cell coverage, puffed backs at perspective and legacy single-light/list equivalence; rendered command/export regressions cover smooth shading and editable expansion. Four legacy white-light PNGs matched main byte for byte when this was measured (2026-10-17); since every 3D seam took round joins (2026-11-12), white-light output is expected to differ from them at facet corners ([Seams](three-d.md#seams)); the four scenes were not exported again to measure it; [release measurements](3d-lighting-performance.md) record the colored solid-fill batch and the remaining source-gradient cost. Colored Inflate's facets lie over an underlay of themselves under one clip, so their shared edges show neither the black channel backdrop nor the background ([Seams](three-d.md#seams)); `three_d_light_color::colored_light_surfaces_match_supersampling_at_internal_facet_edges` compares 1:1 with 3x averaged down, and `colored_light_seams_stay_closed_in_svg_pdf_and_expansion` checks SVG, PDF and Expand Appearance. Colored Revolve's faces lie over an underlay of themselves the same way, run by run in a group and with mapped graphics kept after their faces; `colored_revolve_faces_leave_no_alpha_holes_at_one_to_one` checks that no pixel inside the art lets the background through at 1:1 where 3x averaged down is opaque, live, read back from SVG and PDF, and expanded. -Colored Inflate's composited facets that are simple polygons are each one filled path of the facet and its round seam, so a facet edge pixel is covered once instead of by a fill and then a same-color stroke ([Seams](three-d.md#seams)); `three_d_light_color::turned_colored_inflate_facets_and_seams_cover_their_edges_once` bounds the turned (X 50°, Y 35°) solid fill against 3x averaged down, and `lighting::tests::seamed_fill_covers_a_polygon_and_its_seam_once` checks the path's coverage and the facets that keep a fill and a stroke. +Colored Inflate's composited facets that are simple polygons are each one filled path of the facet and its round seam, so a facet edge pixel is covered once instead of by a fill and then a same-color stroke ([Seams](three-d.md#seams)); `three_d_light_color::colored_light_surfaces_match_supersampling_at_internal_facet_edges` bounds the turned (X 50°, Y 35°) solid fill against 3x averaged down, and `lighting::tests::seamed_fill_covers_a_polygon_and_its_seam_once` checks the path's coverage and the facets that keep a fill and a stroke. ## Eyedropper character dimensions (2026-11-11) From 3fe7b276016f6b31f7d13923e4477f2385e55817 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:38:21 +0100 Subject: [PATCH 231/264] Wait for the plug-in dialog to settle before clicking its slider --- crates/ui-egui/src/tests/plugins.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tests/plugins.rs b/crates/ui-egui/src/tests/plugins.rs index c2a72c626d..6dc9853a2a 100644 --- a/crates/ui-egui/src/tests/plugins.rs +++ b/crates/ui-egui/src/tests/plugins.rs @@ -193,8 +193,13 @@ fn filter_dialog_previews_and_commits_one_undo_step() { assert_eq!(fields(h.state())["amount"], json!(100.0)); // A click in the visible slider must reach the same values the live preview reads. use egui_kittest::kittest::Queryable as _; + // Let the modal finish its opening placement before reading a widget's screen bounds. + for _ in 0..3 { + step(&mut h); + } let at = h.get_by_role(egui::accesskit::Role::Dialog).get_by_role(egui::accesskit::Role::Slider).rect().center(); h.input_mut().events.push(egui::Event::PointerMoved(at)); + step(&mut h); for pressed in [true, false] { h.input_mut().events.push(egui::Event::PointerButton { pos: at, @@ -204,7 +209,8 @@ fn filter_dialog_previews_and_commits_one_undo_step() { }); step(&mut h); } - assert!(fields(h.state())["amount"].as_f64().is_some_and(|amount| amount > 0.0 && amount < 100.0)); + let clicked = fields(h.state()); + assert!(clicked["amount"].as_f64().is_some_and(|amount| amount > 0.0 && amount < 100.0), "slider at {at:?}: {clicked}"); // Agents set fields like `ui.dialog.set` does; the frame previews them. set_field(&mut h, "amount", json!(50)).unwrap(); step(&mut h); From ebb84ec16c32313c4590d18e3d8b867b56977c81 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:40:53 -0800 Subject: [PATCH 232/264] xtask: test-lint reports only-weak hits instead of failing on them Replayed over the last 300 merges to main, only-weak would have failed 3 merges on 4 hits, and all 4 were tests where an is_ok or is_some check is the behavior under test (a lease or start file that can be taken again, a never-panic property test, a label found by a search with the row's position in its predicate). Of the 39 only-weak hits in the whole workspace, most are the same kinds: registry and label lookups, still-imports and never-panic tests. only-weak now lists its hits without failing, like all-unguarded. The check fails on self-compare, ignore-without-reason and sleep. With this change the replay fails 0 of 272 merges that change Rust files. --- docs/development.md | 2 +- xtask/src/main.rs | 4 ++-- xtask/src/test_lint.rs | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/development.md b/docs/development.md index efb554b561..604c363dba 100644 --- a/docs/development.md +++ b/docs/development.md @@ -351,7 +351,7 @@ The app decides which cursors exist; whoever draws them works from the list. For ## Test lint -`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on a test whose only checks are that a value exists or a collection is not empty (`is_ok`, `is_some`, `!is_empty`, `len() > 0`: `only-weak`), an `assert_eq!` or `assert_ne!` of an expression with itself, such as `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. +`cargo xtask test-lint` (part of `cargo xtask ci`) checks tests that a wrong result can pass, in the lines and tests changed since a base. It fails on an `assert_eq!` or `assert_ne!` of an expression with itself, such as `assert_eq!(x, x)` (`self-compare`), `#[ignore]` without a reason (`ignore-without-reason`) and `thread::sleep` in test code (`sleep`). It lists the hits of the other rules without failing: a test whose only checks are that a value exists or a collection is not empty (`is_ok`, `is_some`, `!is_empty`, `len() > 0`: `only-weak`), `assert!(….all(…))` on a collection the test does not show to be non-empty (`all-unguarded`), a process test that checks only the exit status, a test with no assertion and no asserting helper, a silent early `return` on a value from the code under test, an environment variable that no CI leg sets, and test code that reads Rust source outside the audits listed in `SOURCE_AUDITS`. The base is `--base ` or `TEST_LINT_BASE`; in CI it is the first parent of the checked-out commit, and elsewhere the merge base with `upstream/main` or `origin/main`. Hits on unchanged lines are counted but do not fail it. A `// test-lint: allow ` comment exempts its own line and the line below it; `xtask/src/test_lint.rs` lists the rules and their ids. `cargo xtask test-lint --all` lists every hit in the workspace by crate and rule, and does not fail. ## Tests diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 3a0c854486..6f4347e952 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -34,8 +34,8 @@ commands: brands check that user-visible text (labels, params docs, MCP, docs, packaging) names no other vendor's products cursors warn about Cursor values with no entry in crates/tools/src/cursors.toml (never fails) test-lint [--base ] [--all] - weak tests in the lines changed since the base: fail on only is_ok/is_some checks, - self-compares, reasonless #[ignore] and sleeps; list unguarded .all(), no assertion, + weak tests in the lines changed since the base: fail on self-compares, reasonless + #[ignore] and sleeps; list only is_ok/is_some checks, unguarded .all(), no assertion, early returns, unset env gates... (xtask/src/test_lint.rs); --all lists every hit by crate and never fails i18n-report list the strings each language's catalog lacks, shown in English (fails only on a diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index f442c9681d..45ae3566d3 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -51,9 +51,8 @@ //! rules about a whole test it can be on any line from the line above the test attribute to the //! `fn` line. An allow without a reason exempts nothing. //! -//! `cargo xtask test-lint` fails on hits of `only-weak`, `self-compare`, `ignore-without-reason` -//! and `sleep` in the lines and tests changed since a base, and lists the other rules' hits there -//! without failing. The base is `--base ` or `TEST_LINT_BASE`; in GitHub Actions the first parent of `HEAD` (a pull request's +//! `cargo xtask test-lint` fails on hits of `self-compare`, `ignore-without-reason` and `sleep` in +//! the lines and tests changed since a base, and lists the other rules' hits there without failing. The base is `--base ` or `TEST_LINT_BASE`; in GitHub Actions the first parent of `HEAD` (a pull request's //! merge commit is checked out, and a shallow checkout fetches that parent); elsewhere the merge //! base of `HEAD` and `upstream/main` or `origin/main`. Uncommitted and untracked files count as //! changed. Hits on unchanged lines are counted but do not fail it. `--all` lists every hit in the @@ -168,7 +167,7 @@ impl Rule { /// Whether a hit on a changed line fails the command. The other rules only report. pub fn fails(self) -> bool { - matches!(self, Rule::OnlyWeak | Rule::SelfCompare | Rule::IgnoreWithoutReason | Rule::Sleep) + matches!(self, Rule::SelfCompare | Rule::IgnoreWithoutReason | Rule::Sleep) } fn from_id(id: &str) -> Option { @@ -3606,16 +3605,19 @@ mod tests { #[test] fn only_failing_rules_fail_the_check() { let failing: Vec<&str> = Rule::ALL.into_iter().filter(|r| r.fails()).map(Rule::id).collect(); - assert_eq!(failing, ["only-weak", "self-compare", "ignore-without-reason", "sleep"]); + assert_eq!(failing, ["self-compare", "ignore-without-reason", "sleep"]); let weak = "#[test]\nfn weak() {\n assert!(f().is_ok());\n}\n"; let unguarded = "#[test]\nfn all() {\n assert!(f().iter().all(|x| valid(x)));\n}\n"; + let skipped = "#[test]\n#[ignore]\nfn skipped() {\n assert_eq!(f(), 1);\n}\n"; let hits_of = |src: &str| lint_file("crates/x/src/tests.rs", src, &ctx()); assert_eq!(finish(&hits_of(unguarded), 0, 1, "base"), Ok(()), "all-unguarded only reports"); - let both = hits_of(&format!("{weak}{unguarded}")); - assert_eq!(both.len(), 2); - let Err(message) = finish(&both, 0, 1, "base") else { panic!("only-weak fails the check") }; + assert_eq!(finish(&hits_of(weak), 0, 1, "base"), Ok(()), "only-weak only reports"); + let all = hits_of(&format!("{weak}{unguarded}{skipped}")); + assert_eq!(all.len(), 3); + let Err(message) = finish(&all, 0, 1, "base") else { panic!("ignore-without-reason fails the check") }; assert!(message.starts_with("1 test-lint hit(s)"), "{message}"); - assert!(message.contains("[only-weak] `weak`") && !message.contains("[all-unguarded]"), "{message}"); + assert!(message.contains("[ignore-without-reason] `skipped`"), "{message}"); + assert!(!message.contains("[only-weak]") && !message.contains("[all-unguarded]"), "{message}"); assert_eq!(finish(&[], 3, 1, "base"), Ok(())); } From fbcc1627c41afd7391e668d42f3ec3a943351545 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:46:34 -0800 Subject: [PATCH 233/264] xtask: test-lint counts items under cfg(all(test, ...)) as test code test_regions matched only the exact `#[cfg(test)]`, so helpers in a module under `#[cfg(all(test, windows))]` or `#[cfg(all(test, not(target_arch = "wasm32")))]` (as in apps/vectorcraft-web/src/file_drops.rs) were not test code: a sleep in such a helper passed the check, and its asserting helpers were not found. A cfg predicate now counts when it is `test` or an `all(...)` with such a predicate among its arguments, at any depth and with any spacing. `any(test, ...)`, `not(test)` and `feature = "test"` do not count. --- xtask/src/test_lint.rs | 53 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index 45ae3566d3..bfa4f4728c 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -41,7 +41,8 @@ //! that keeps files ending in `.rs`), outside the source audits in [`SOURCE_AUDITS`]. //! //! Test code is a test file (`tests.rs`, `tests_*.rs`, `*_tests.rs`, a file in a `tests` or -//! `benches` folder, `crates/testkit`), an item under `#[cfg(test)]`, or a test function. +//! `benches` folder, `crates/testkit`), an item under `#[cfg(test)]` or `#[cfg(all(test, …))]`, +//! or a test function. //! //! An asserting helper is a function or macro in the crate's test code (or in `crates/testkit`) //! that asserts, panics or calls one that does (every one of that name, when there are several), @@ -972,20 +973,52 @@ fn is_test_file(path: &str) -> bool { || path.starts_with("crates/testkit/") } -/// The byte ranges of test code in a file: all of a test file, else each item under -/// `#[cfg(test)]` that has a body in the file, and each test function. +/// Whether a `cfg` predicate holds only in test builds: `test`, or an `all(…)` with such a +/// predicate among its arguments. +fn cfg_requires_test(pred: &[u8]) -> bool { + let pred: Vec = pred.iter().copied().filter(|c| !c.is_ascii_whitespace()).collect(); + if pred == b"test" { + return true; + } + let Some(args) = pred.strip_prefix(b"all(").and_then(|a| a.strip_suffix(b")")) else { return false }; + let mut depth = 0usize; + let mut start = 0; + for (i, &c) in args.iter().enumerate() { + match c { + b'(' => depth += 1, + b')' => depth = depth.saturating_sub(1), + b',' if depth == 0 => { + if cfg_requires_test(&args[start..i]) { + return true; + } + start = i + 1; + } + _ => {} + } + } + cfg_requires_test(&args[start..]) +} + +/// The byte ranges of test code in a file: all of a test file, else each item under a `#[cfg(…)]` +/// that holds only in test builds ([`cfg_requires_test`]) and has a body in the file, and each +/// test function. fn test_regions(path: &str, m: &[u8], tests: &[TestFn]) -> Vec<(usize, usize)> { if is_test_file(path) { return vec![(0, m.len())]; } let mut out: Vec<(usize, usize)> = tests.iter().map(|t| (t.attr, t.close)).collect(); for at in words(m, b"cfg", 0, m.len()) { - let attr = skip_ws(m, at + "cfg".len()); - if !m[..at].ends_with(b"#[") || !m[attr..].starts_with(b"(test)]") { + let open = skip_ws(m, at + "cfg".len()); + if !m[..at].ends_with(b"#[") || m.get(open) != Some(&b'(') { + continue; + } + let Some(close) = matching(m, open) else { continue }; + let end = skip_ws(m, close + 1); + if m.get(end) != Some(&b']') || !cfg_requires_test(&m[open + 1..close]) { continue; } // The item's body: the first `{` before any `;` (`mod tests;` has none here). - let after = attr + "(test)]".len(); + let after = end + 1; let Some(open) = m[after..].iter().position(|&c| c == b'{' || c == b';').map(|p| p + after) else { continue }; if let (b'{', Some(close)) = (m[open], matching(m, open)) { out.push((at, close)); @@ -3517,6 +3550,14 @@ mod tests { assert_eq!(hits_in("xtask/src/test_lint.rs", shipped, &ctx()), [], "a name that only starts with test is not a test file"); let after = "#[cfg(test)]\nmod tests {\n fn w() { thread::sleep(D); }\n}\npub fn later() {\n thread::sleep(D);\n}\n"; assert_eq!(hits_in("crates/x/src/lib.rs", after, &ctx()), [(3, "sleep")], "code after a #[cfg(test)] module is not test code"); + for gate in ["all(test, windows)", "all( test , not(target_arch = \"wasm32\") )", "all(feature = \"x\", all(unix, test))"] { + let gated = format!("#[cfg({gate})]\nmod tests {{\n fn w() {{ thread::sleep(D); }}\n}}\n"); + assert_eq!(hits_in("crates/x/src/lib.rs", &gated, &ctx()), [(3, "sleep")], "{gate} holds only in tests"); + } + for gate in ["any(test, feature = \"x\")", "not(test)", "all(unix, not(test))", "feature = \"test\""] { + let gated = format!("#[cfg({gate})]\nmod helpers {{\n fn w() {{ thread::sleep(D); }}\n}}\n"); + assert_eq!(hits_in("crates/x/src/lib.rs", &gated, &ctx()), [], "{gate} also holds outside tests"); + } for test_file in [ "crates/x/src/tests.rs", "crates/x/src/tests_wheel.rs", From 99a5b6cdc4215109818dee527577c63d8a838533 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 14:54:47 +0100 Subject: [PATCH 234/264] Describe the selected-art pointer in the cursor reference --- crates/tools/src/cursors.toml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/tools/src/cursors.toml b/crates/tools/src/cursors.toml index 0b19e3e4c0..fd528eaeef 100644 --- a/crates/tools/src/cursors.toml +++ b/crates/tools/src/cursors.toml @@ -129,11 +129,20 @@ shown_when = [ hotspot = "The arrow's tip." look = "Arrow with a small x badge (nothing to select)." +[[cursor]] +id = "SelectionMove" +group = "Selection" +shown_when = [ + "The Selection tool over a selected object, its movable source artwork, or its visible centre point.", + "The Selection tool over artwork while Alt is held, before the copy drag begins.", +] +hotspot = "The arrow's tip." +look = "The Selection arrow with a small move badge." + [[cursor]] id = "Move" group = "Selection" shown_when = [ - "The Selection tool over a selected object, or over any object with Alt held (once an Alt-drag starts, SelectionCopy shows).", "The shape tools over a selected object's centre point (Attributes › Show Center), before a press there moves it (while the drag runs the arrow is plain, SelectionCopy with Alt, ArrowHollow while it snaps).", "Reshape over a path or while dragging.", "Inside the Free Transform and Crop Image boxes.", From 050634b6ad44ddefe938b4e636cc9f925bbc5b2d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:19:05 -0800 Subject: [PATCH 235/264] xtask: test-lint skips declared-only items and unapplied should_panic - Functions and macros declared inside a test no longer count as its assertions or calls; a call to one still counts as a helper call. - `should_panic` exempts a test only as an applied attribute: `#[should_panic]`, or inside `#[cfg_attr(test, ...)]`. - `only-weak` strips parentheses around the whole condition, so `assert!((x.is_ok()))` is classified like `assert!(x.is_ok())`. - `#[ cfg(test)]` and attributes with comments between `#`, `[` and `cfg` mark test code like the compact form. --- xtask/src/test_lint.rs | 114 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index bfa4f4728c..8609ace2f5 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -1009,7 +1009,9 @@ fn test_regions(path: &str, m: &[u8], tests: &[TestFn]) -> Vec<(usize, usize)> { let mut out: Vec<(usize, usize)> = tests.iter().map(|t| (t.attr, t.close)).collect(); for at in words(m, b"cfg", 0, m.len()) { let open = skip_ws(m, at + "cfg".len()); - if !m[..at].ends_with(b"#[") || m.get(open) != Some(&b'(') { + // Whitespace and comments (masked to spaces) may separate `#`, `[` and `cfg`. + let outer_attr = m[..at].trim_ascii_end().strip_suffix(b"[").is_some_and(|b| b.trim_ascii_end().ends_with(b"#")); + if !outer_attr || m.get(open) != Some(&b'(') { continue; } let Some(close) = matching(m, open) else { continue }; @@ -1079,8 +1081,8 @@ fn checking<'a>(defs: impl Iterator + Clone) -> HashSet } } -/// The `fn` or `macro_rules!` at `at`. -fn definition(m: &[u8], at: usize) -> Option { +/// The name, kind (`true` for a macro) and body braces of the `fn` or `macro_rules!` at `at`. +fn item_at(m: &[u8], at: usize) -> Option<(&[u8], bool, usize, usize)> { let is_macro = m[at..].starts_with(b"macro_rules"); let mut start = skip_ws(m, at + if is_macro { "macro_rules".len() } else { 2 }); if is_macro { @@ -1094,8 +1096,13 @@ fn definition(m: &[u8], at: usize) -> Option { if m[open] != b'{' { return None; } - let close = matching(m, open)?; - let name = String::from_utf8_lossy(&m[start..end]).into_owned(); + Some((&m[start..end], is_macro, open, matching(m, open)?)) +} + +/// The `fn` or `macro_rules!` at `at`. +fn definition(m: &[u8], at: usize) -> Option { + let (name, is_macro, open, close) = item_at(m, at)?; + let name = String::from_utf8_lossy(name).into_owned(); let called = calls(m, open, close).into_iter().filter(|(_, method)| !method).map(|(n, _)| n).collect(); Some((if is_macro { format!("{name}!") } else { name }, checks_itself(m, open, close), called)) } @@ -1107,6 +1114,9 @@ struct File<'a> { path: &'a str, src: &'a [u8], m: Vec, + /// [`File::m`] with the functions and macros declared inside each test blanked: declaring + /// one does not run its body ([`executed`]). + exec: Vec, lines: Lines, tests: Vec, /// The test code ([`test_regions`]). @@ -1148,7 +1158,8 @@ pub fn lint_file(path: &str, src: &str, ctx: &Ctx) -> Vec { let m = mask(src); let tests = tests_in(&m); let regions = test_regions(path, &m, &tests); - let file = File { path, src: src.as_bytes(), m, lines: Lines::new(src), tests, regions }; + let exec = executed(&m, &tests); + let file = File { path, src: src.as_bytes(), m, exec, lines: Lines::new(src), tests, regions }; let mut hits: Vec = file.tests.iter().flat_map(|t| test_hits(&file, t, ctx)).collect(); hits.extend(ignore_hits(&file)); hits.extend(sleep_hits(&file)); @@ -1162,6 +1173,20 @@ pub fn lint_file(path: &str, src: &str, ctx: &Ctx) -> Vec { hits } +/// `m` with each `fn` and `macro_rules!` declared inside a test's body replaced by spaces, from +/// its keyword to its closing brace. A call to one stays, so it can still count as a helper call. +fn executed(m: &[u8], tests: &[TestFn]) -> Vec { + let mut out = m.to_vec(); + for t in tests { + for at in words(m, b"fn", t.open, t.close).into_iter().chain(words(m, b"macro_rules", t.open, t.close)) { + if let Some((_, _, _, close)) = item_at(m, at).filter(|&(_, _, _, close)| close < t.close) { + blank(&mut out, at, close + 1); + } + } + } + out +} + /// `(line, rule)` of each exemption comment that names a rule and a reason. /// A marker counts only inside a comment: masked (`m`) there, and kept when only literals are /// masked. @@ -1191,7 +1216,7 @@ struct View<'a> { } fn test_hits(file: &File, t: &TestFn, ctx: &Ctx) -> Vec { - let m = &file.m; + let m = &file.exec; let asserts: Vec = macro_calls(m, t.open, t.close).into_iter().filter(|c| is_assert_macro(&c.name)).collect(); let none = HashSet::new(); let helpers = ctx.helpers.get(&crate_of(file.path)).unwrap_or(&none); @@ -1199,7 +1224,7 @@ fn test_hits(file: &File, t: &TestFn, ctx: &Ctx) -> Vec { .iter() .any(|(n, method)| n != &t.name && !(n.ends_with('!') && is_assert_macro(n)) && is_helper_call(n, *method, helpers)); let checks = checks_itself(m, t.open, t.close); - let should_panic = contains(&m[t.attr..t.fn_at], b"should_panic"); + let should_panic = should_panic_attr(m, t.attr, t.fn_at); let v = View { file, t, asserts, delegates, checks, should_panic }; let mut hits = all_unguarded(&v); hits.extend(self_compare(&v)); @@ -1209,6 +1234,27 @@ fn test_hits(file: &File, t: &TestFn, ctx: &Ctx) -> Vec { hits } +/// Whether the attributes in `m[from..to]` include an applied `should_panic`: `#[should_panic]`, +/// `#[should_panic(…)]`, or one inside `#[cfg_attr(test, …)]`. Another `cfg_attr` predicate may +/// not hold, so it does not count. +fn should_panic_attr(m: &[u8], from: usize, to: usize) -> bool { + let attached = words(m, b"should_panic", from, to).into_iter().any(|at| { + let before = m[..at].trim_ascii_end().strip_suffix(b"[").is_some_and(|b| b.trim_ascii_end().ends_with(b"#")); + before && matches!(m.get(skip_ws(m, at + "should_panic".len())), Some(b']' | b'(')) + }); + attached + || words(m, b"cfg_attr", from, to).into_iter().any(|at| { + let open = skip_ws(m, at + "cfg_attr".len()); + let Some(close) = matching(m, open).filter(|&c| m[open] == b'(' && c < to) else { return false }; + let args = split_args(m, open + 1, close); + let name = |&(f, t): &(usize, usize)| { + let a = norm(&m[f..t]); + a == "should_panic" || a.starts_with("should_panic(") + }; + args.first().is_some_and(|&(f, t)| norm(&m[f..t]) == "test") && args.iter().skip(1).any(name) + }) +} + impl View<'_> { fn hit(&self, at: usize, rule: Rule, note: String) -> Hit { self.file.hit(at, rule, &self.t.name, note) @@ -1223,7 +1269,7 @@ impl View<'_> { } fn body(&self) -> &[u8] { - &self.file.m[self.t.open..self.t.close] + &self.file.exec[self.t.open..self.t.close] } /// The masked body with assertion failure-message arguments replaced by spaces. @@ -2149,8 +2195,9 @@ fn reads_counted_local(body: &[u8], all: &[Binding], from: usize, to: usize) -> /// Whether an assertion's (masked, whitespace-free) condition only says that there is a value. fn is_weak(cond: &str) -> bool { + let cond = unparenthesized(cond); let (negated, expr) = match cond.strip_prefix('!') { - Some(rest) => (true, rest), + Some(rest) => (true, unparenthesized(rest)), None => (false, cond), }; let plain = |rest: &str| !["&&", "||", "==", "!=", "<", ">"].iter().any(|op| rest.contains(op)); @@ -2161,6 +2208,14 @@ fn is_weak(cond: &str) -> bool { suffix(".is_ok()") || suffix(".is_some()") || suffix(".len()>0") || suffix(".len()!=0") || suffix(".len()>=1") } +/// `expr` without the balanced parentheses around all of it (`((a.is_ok()))` gives `a.is_ok()`). +fn unparenthesized(mut expr: &str) -> &str { + while expr.starts_with('(') && matching(expr.as_bytes(), 0) == Some(expr.len() - 1) { + expr = &expr[1..expr.len() - 1]; + } + expr +} + fn only_weak(v: &View) -> Option { let all_weak = v.asserts.iter().all(|a| PLAIN_ASSERTS.contains(&a.name.as_str()) && is_weak(&v.first_arg(a))); // Failure messages run only after an assertion has failed, so a check there does not count. @@ -3223,6 +3278,41 @@ mod tests { assert_eq!(hits(refusal), [], "is_err is not on the plan's list"); let compound = "#[test]\nfn t() {\n assert!(a.is_some() && a == Some(2));\n}\n"; assert_eq!(hits(compound), []); + for cond in ["(parse(\"x\").is_ok())", "((parse(\"x\").is_ok()))", "!(list().is_empty())", "(!list().is_empty())"] { + let src = format!("#[test]\nfn t() {{\n assert!({cond});\n}}\n"); + assert_eq!(hits(&src), [(2, "only-weak")], "{cond}"); + } + let grouped = "#[test]\nfn t() {\n assert!((a.is_some()) && (a == Some(2)));\n}\n"; + assert_eq!(hits(grouped), [], "parentheses around one side of a comparison stay"); + } + + #[test] + fn functions_declared_in_a_test_count_only_when_called() { + let unused = "#[test]\nfn t() {\n fn unused() {\n assert_eq!(1, 1);\n }\n assert!(parse(\"x\").is_ok());\n}\n"; + assert_eq!(hits(unused), [(2, "only-weak")], "a declared function's assertion does not run"); + let macro_only = "#[test]\nfn t() {\n macro_rules! check {\n () => { assert_eq!(1, 1) };\n }\n f();\n}\n"; + assert_eq!(hits(macro_only), [(2, "no-assertion")], "a declared macro's assertion does not run"); + let called = unused.replace(" assert!(parse", " unused();\n assert!(parse"); + let files = [("crates/x/src/tests.rs".to_owned(), called.clone())]; + let with_helpers = Ctx { helpers: asserting_helpers(&files), ..ctx() }; + assert_eq!(hits_in("crates/x/src/tests.rs", &called, &with_helpers), [], "a call to it checks"); + } + + #[test] + fn should_panic_counts_only_when_applied() { + let weak = "#[test]\nfn t() {\n assert!(parse(\"x\").is_ok());\n}\n"; + for attr in [ + "#[should_panic]", + "#[ should_panic(expected = \"x\") ]", + "#[cfg_attr(test, should_panic)]", + "#[cfg_attr( test , should_panic(expected = \"x\"))]", + ] { + assert_eq!(hits(&format!("{attr}\n{weak}")), [], "{attr}"); + } + for attr in ["#[cfg_attr(any(), should_panic)]", "#[cfg_attr(windows, should_panic)]", "#[doc = \"should_panic\"]", "#[allow(should_panic)]"] + { + assert_eq!(hits(&format!("{attr}\n{weak}")), [(3, "only-weak")], "{attr}"); + } } #[test] @@ -3554,6 +3644,10 @@ mod tests { let gated = format!("#[cfg({gate})]\nmod tests {{\n fn w() {{ thread::sleep(D); }}\n}}\n"); assert_eq!(hits_in("crates/x/src/lib.rs", &gated, &ctx()), [(3, "sleep")], "{gate} holds only in tests"); } + for attr in ["#[ cfg(all(test, unix))]", "#[/* test-only */cfg(test)]", "# [cfg (test)]"] { + let gated = format!("{attr}\nmod tests {{\n fn w() {{ thread::sleep(D); }}\n}}\n"); + assert_eq!(hits_in("crates/x/src/lib.rs", &gated, &ctx()), [(3, "sleep")], "{attr}"); + } for gate in ["any(test, feature = \"x\")", "not(test)", "all(unix, not(test))", "feature = \"test\""] { let gated = format!("#[cfg({gate})]\nmod helpers {{\n fn w() {{ thread::sleep(D); }}\n}}\n"); assert_eq!(hits_in("crates/x/src/lib.rs", &gated, &ctx()), [], "{gate} also holds outside tests"); From 81cc0fc7973c71bbb5b52c41461669d099088fea Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 05:49:09 -0800 Subject: [PATCH 236/264] Tests: nine engine integration test files join the tests/it binary blend_render_consistency, direct_handle_mirror, ellipse_drag_anchors, eraser_open_fill, group3_reference, path_fill_hits, pen_space_handle, preflight and scissors_snap were each a test binary of their own. They now are modules of crates/engine/tests/it, with their tests unchanged, so the engine's tests link nine fewer binaries. The files that stay separate change process-wide state (installed plug-ins, Safe Mode, the font database, color settings, the working directory), are run by name from CI or xtask (the Affinity corpus tests, script_corpus, import_fuzz), or compile for about a minute on their own (command_sweep), which would make every edit to tests/it rebuild it. Docs that named the old paths name the new ones, and the preflight command in docs/production-preflight.md runs `--test it preflight::`. --- crates/engine/Cargo.toml | 2 +- .../{ => it}/blend_render_consistency.rs | 1 - .../tests/{ => it}/direct_handle_mirror.rs | 1 - .../tests/{ => it}/ellipse_drag_anchors.rs | 1 - .../engine/tests/{ => it}/eraser_open_fill.rs | 2 -- .../engine/tests/{ => it}/group3_reference.rs | 0 crates/engine/tests/it/main.rs | 9 ++++++++ .../engine/tests/{ => it}/path_fill_hits.rs | 1 - .../engine/tests/{ => it}/pen_space_handle.rs | 2 -- crates/engine/tests/{ => it}/preflight.rs | 2 -- crates/engine/tests/{ => it}/scissors_snap.rs | 1 - docs/gaps.md | 10 ++++----- docs/production-preflight.md | 2 +- docs/roadmap.md | 2 +- docs/target-app-parity.md | 22 +++++++++---------- docs/ui-parity.md | 14 ++++++------ 16 files changed, 35 insertions(+), 37 deletions(-) rename crates/engine/tests/{ => it}/blend_render_consistency.rs (99%) rename crates/engine/tests/{ => it}/direct_handle_mirror.rs (99%) rename crates/engine/tests/{ => it}/ellipse_drag_anchors.rs (99%) rename crates/engine/tests/{ => it}/eraser_open_fill.rs (99%) rename crates/engine/tests/{ => it}/group3_reference.rs (100%) rename crates/engine/tests/{ => it}/path_fill_hits.rs (99%) rename crates/engine/tests/{ => it}/pen_space_handle.rs (99%) rename crates/engine/tests/{ => it}/preflight.rs (99%) rename crates/engine/tests/{ => it}/scissors_snap.rs (99%) diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 027ae10251..406851393a 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -116,7 +116,7 @@ zune-core = { workspace = true } # JPEG XL files for the import fuzz tests (tests/import_fuzz.rs). craft-jxl = { workspace = true } # vectorcraft-doc's Group 3 TIFF reader before craft-stream-codecs, the reference -# tests/group3_reference.rs compares it with. +# tests/it/group3_reference.rs compares it with. hayro-ccitt = { workspace = true } craft-stream-codecs = { workspace = true } vectorcraft-affinity = { workspace = true, features = ["synth"] } diff --git a/crates/engine/tests/blend_render_consistency.rs b/crates/engine/tests/it/blend_render_consistency.rs similarity index 99% rename from crates/engine/tests/blend_render_consistency.rs rename to crates/engine/tests/it/blend_render_consistency.rs index fdc2fb3b93..fa69885ad7 100644 --- a/crates/engine/tests/blend_render_consistency.rs +++ b/crates/engine/tests/it/blend_render_consistency.rs @@ -1,5 +1,4 @@ //! Blend edits invalidate every pixel they change, including keys aligned to a curved spine. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use std::sync::Arc; diff --git a/crates/engine/tests/direct_handle_mirror.rs b/crates/engine/tests/it/direct_handle_mirror.rs similarity index 99% rename from crates/engine/tests/direct_handle_mirror.rs rename to crates/engine/tests/it/direct_handle_mirror.rs index 30326d8e74..bfe8db75a0 100644 --- a/crates/engine/tests/direct_handle_mirror.rs +++ b/crates/engine/tests/it/direct_handle_mirror.rs @@ -1,5 +1,4 @@ //! Temporary Cmd/Control symmetry while Direct Selection drags an existing handle. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use serde_json::{Value, json}; use vectorcraft_doc::{Node, NodeId}; diff --git a/crates/engine/tests/ellipse_drag_anchors.rs b/crates/engine/tests/it/ellipse_drag_anchors.rs similarity index 99% rename from crates/engine/tests/ellipse_drag_anchors.rs rename to crates/engine/tests/it/ellipse_drag_anchors.rs index afce996136..1e278505ed 100644 --- a/crates/engine/tests/ellipse_drag_anchors.rs +++ b/crates/engine/tests/it/ellipse_drag_anchors.rs @@ -1,5 +1,4 @@ //! Ellipse arrow keys edit the anchor count of the shape actually being dragged. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use serde_json::{Value, json}; use vectorcraft_doc::{LiveShape, Node, NodeId}; diff --git a/crates/engine/tests/eraser_open_fill.rs b/crates/engine/tests/it/eraser_open_fill.rs similarity index 99% rename from crates/engine/tests/eraser_open_fill.rs rename to crates/engine/tests/it/eraser_open_fill.rs index a0ab760660..a5f6e60956 100644 --- a/crates/engine/tests/eraser_open_fill.rs +++ b/crates/engine/tests/it/eraser_open_fill.rs @@ -1,6 +1,4 @@ //! Fill-only open-path Eraser regressions through the public engine and CPU renderer. -// Integration tests may unwrap and panic on failure (AGENTS.md). -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use serde_json::{Value, json}; use vectorcraft_doc::{NodeId, NodeKind}; diff --git a/crates/engine/tests/group3_reference.rs b/crates/engine/tests/it/group3_reference.rs similarity index 100% rename from crates/engine/tests/group3_reference.rs rename to crates/engine/tests/it/group3_reference.rs diff --git a/crates/engine/tests/it/main.rs b/crates/engine/tests/it/main.rs index ff4a5c22ab..2be85215bb 100644 --- a/crates/engine/tests/it/main.rs +++ b/crates/engine/tests/it/main.rs @@ -12,13 +12,18 @@ mod affinity_local; mod align_automatic_reference; mod artboard_click; mod beyond_canvas; +mod blend_render_consistency; mod clear_commands; mod compound_attributes; mod copy_direct_selection; mod delete_path_pieces; mod dimensions; +mod direct_handle_mirror; +mod ellipse_drag_anchors; +mod eraser_open_fill; mod eyedropper_sources; mod find_replace_paras; +mod group3_reference; mod inline_text; mod js_lexer_vs_scriptcheck; mod known_bugs; @@ -27,12 +32,16 @@ mod model_based; mod param_keys; mod paste_many; mod pasted_clipping_path; +mod path_fill_hits; mod pen_click_after_smooth; mod pen_endpoint_picking; mod pen_rubber_band; +mod pen_space_handle; +mod preflight; mod ruler_guide_nodes; mod ruler_guide_perf; mod ruler_origin; +mod scissors_snap; mod script_host_vs_scriptcheck; mod selection_commands; mod several_handles; diff --git a/crates/engine/tests/path_fill_hits.rs b/crates/engine/tests/it/path_fill_hits.rs similarity index 99% rename from crates/engine/tests/path_fill_hits.rs rename to crates/engine/tests/it/path_fill_hits.rs index f8dfebafaf..28ab79e36b 100644 --- a/crates/engine/tests/path_fill_hits.rs +++ b/crates/engine/tests/it/path_fill_hits.rs @@ -1,5 +1,4 @@ //! Path fill hit testing follows the visible paint stack while transparent paint remains selectable. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use std::sync::Arc; diff --git a/crates/engine/tests/pen_space_handle.rs b/crates/engine/tests/it/pen_space_handle.rs similarity index 99% rename from crates/engine/tests/pen_space_handle.rs rename to crates/engine/tests/it/pen_space_handle.rs index 5e37ca8a11..9bb8a0b8c8 100644 --- a/crates/engine/tests/pen_space_handle.rs +++ b/crates/engine/tests/it/pen_space_handle.rs @@ -1,6 +1,4 @@ //! Pen lends Direct Selection for one handle gesture; Space repositions that handle's owner. -// Integration tests may unwrap and panic (AGENTS.md, Robustness). -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use serde_json::json; use vectorcraft_doc::NodeId; diff --git a/crates/engine/tests/preflight.rs b/crates/engine/tests/it/preflight.rs similarity index 99% rename from crates/engine/tests/preflight.rs rename to crates/engine/tests/it/preflight.rs index e656596d71..73f6066bd3 100644 --- a/crates/engine/tests/preflight.rs +++ b/crates/engine/tests/it/preflight.rs @@ -1,5 +1,3 @@ -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] - //! Production preflight must find actual delivery problems and clear them after repairs. use serde_json::{Value, json}; diff --git a/crates/engine/tests/scissors_snap.rs b/crates/engine/tests/it/scissors_snap.rs similarity index 99% rename from crates/engine/tests/scissors_snap.rs rename to crates/engine/tests/it/scissors_snap.rs index 6d12bd6457..b81ac05bab 100644 --- a/crates/engine/tests/scissors_snap.rs +++ b/crates/engine/tests/it/scissors_snap.rs @@ -1,5 +1,4 @@ //! Scissors receives the view's Smart Guides setting and keeps the split endpoint selected. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use serde_json::json; use vectorcraft_doc::NodeId; diff --git a/docs/gaps.md b/docs/gaps.md index 9130e782f1..01b62dc5d6 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -29,7 +29,7 @@ OpenType panel feature-row context menus (part of G12): a secondary click on a f Actions panel item context menus (2026-11-20): Right-clicking an Action Set row selects it and presents a context menu with New Action…, New Set…, Duplicate Set, Delete Set, and Set Options…. Right-clicking an Action row selects it and presents a context menu with Play, Record, Duplicate, Delete, Action Options…, and Batch…. Duplicate on an action duplicates that action and selects the duplicate; Delete removes it. Headless tests in `crates/ui-egui/src/panels/actions.rs`: `right_clicking_an_action_set_selects_it_and_presents_set_context_options`, `right_clicking_an_action_selects_it_and_presents_action_options`, and `clicking_duplicate_on_an_action_duplicates_that_action_in_the_set`. Scores and estimates unchanged. -**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. Scores and estimates are unchanged. +**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. Scores and estimates are unchanged. Appearance panel row context menus (part of G12): right-clicking stroke and fill rows offers Duplicate Stroke / Duplicate Fill, Delete Stroke / Delete Fill, and Hide Stroke/Show Stroke / Hide Fill/Show Fill; effect rows offer Edit Effect…, Duplicate Effect, Delete Effect, and Hide Effect / Show Effect; the root object row offers Clear Appearance and Reduce to Basic Appearance. Right-clicking an unselected row targets that row before presenting the menu. Item actions run in one undo step. Evidence: `panels::tests_appearance::right_clicking_a_stroke_row_selects_it_and_exposes_context_menu`, `panels::tests_appearance::clicking_duplicate_stroke_duplicates_the_stroke_with_one_undo_step`, `panels::tests_appearance::clicking_delete_effect_removes_the_effect_from_appearance`, and `panels::tests_appearance::right_clicking_root_object_row_exposes_clear_and_reduce_appearance` in `crates/ui-egui/src/panels/tests_appearance.rs`. Scores and estimates unchanged. @@ -185,7 +185,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Temporary handle mirroring (#7842):** with Direct Selection, add Control (Command on macOS) after a direction-handle drag begins to mirror the opposite handle at equal length. This includes ordinary paths, type on a path and blend spines; a missing opposite handle is pulled out while the modifier is held. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without the modifier. Letting go returns to the drag's normal handle behavior, Shift constrains before mirroring, and Alt takes independent-handle priority. The existing Control/Command-before-press Selection-tool loan is unchanged, and the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again. This does not add a persistent coupling mode or change Pen, mesh or warp gestures; the broader G1 scope and estimates remain. -- **Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss. Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged. +- **Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss. Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/it/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. @@ -197,7 +197,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Polygon/Star count persistence:** Exact-size placement saves the chosen count for later drags and reopening the existing canvas dialog. Regression coverage includes both tools, repeated drags, switching tools and Cancel. The remaining G1 scope and estimates are unchanged. -- **Ellipse drag anchor count (#7840):** Up/Down changes the remembered Anchors count from 2 to 1000 in the current preview box. The existing click-dialog count starts later drags; Escape restores the earlier count while an explicit `tool.setOption` update is kept. Regression target: `crates/engine/tests/ellipse_drag_anchors.rs`. Broader G1 scope and estimates unchanged. +- **Ellipse drag anchor count (#7840):** Up/Down changes the remembered Anchors count from 2 to 1000 in the current preview box. The existing click-dialog count starts later drags; Escape restores the earlier count while an explicit `tool.setOption` update is kept. Regression target: `crates/engine/tests/it/ellipse_drag_anchors.rs`. Broader G1 scope and estimates unchanged. - **Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards:** Shared existing preset definitions are reused; no external preset assets are added. Presets preserve each selected artboard's orientation, and orientation choices apply even when the active board already matches. Fit operations draft bounds until OK, affect only the active artboard and leave artwork in place. Regression coverage checks draft/Cancel, selected-set application, active-only fitting and Undo. Broader scope and estimates unchanged. @@ -398,8 +398,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi ## G11 Correctness bugs in core tools -- **Resolved redraw-bounds defect (#5179):** a curved-spine blend's renderer bounds include its rotated keys and steps after Replace Spine; `crates/engine/tests/blend_render_consistency.rs` keeps the straight-blend control and checks all changed pixels against the advertised area. Both focused CPU regressions pass; broader G11 scope and estimates unchanged. -- **Improved (#6582), fill-only scope:** the Eraser subtracts its swept area or Alt-drag marquee from filled open contours with no visible painted stroke, preserving fill outside the sweep. Fill-only open compound members are cut together under their compound fill rule so holes stay empty. The result keeps the existing path/compound piece structure and whole appearance. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Path or Compound clipping masks keep every surviving contour in the same mask node; full erasure leaves an empty mask without promoting clipped contents. The mask identity, fill rule, appearance and parent child order are retained. Path Eraser uses the same preservation of the clipping role. Filled-and-stroked open paths deliberately retain the outline-splitting behavior from main. Public reference semantics for those stroked paths were not established, and their fill behavior is not claimed fixed here. Focused engine integration tests cover fixed and varied tips and Alt-drag marquees on fill-only open/closed geometry and pixels, compound holes and self-crossing fill, plus painted-stroke paths that keep the outline route and clipping-mask split, empty-mask and Path Eraser controls. `crates/engine/tests/eraser_open_fill.rs` also includes container-own paint and evaluated-placement regression cases. Scores and estimates unchanged. +- **Resolved redraw-bounds defect (#5179):** a curved-spine blend's renderer bounds include its rotated keys and steps after Replace Spine; `crates/engine/tests/it/blend_render_consistency.rs` keeps the straight-blend control and checks all changed pixels against the advertised area. Both focused CPU regressions pass; broader G11 scope and estimates unchanged. +- **Improved (#6582), fill-only scope:** the Eraser subtracts its swept area or Alt-drag marquee from filled open contours with no visible painted stroke, preserving fill outside the sweep. Fill-only open compound members are cut together under their compound fill rule so holes stay empty. The result keeps the existing path/compound piece structure and whole appearance. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Path or Compound clipping masks keep every surviving contour in the same mask node; full erasure leaves an empty mask without promoting clipped contents. The mask identity, fill rule, appearance and parent child order are retained. Path Eraser uses the same preservation of the clipping role. Filled-and-stroked open paths deliberately retain the outline-splitting behavior from main. Public reference semantics for those stroked paths were not established, and their fill behavior is not claimed fixed here. Focused engine integration tests cover fixed and varied tips and Alt-drag marquees on fill-only open/closed geometry and pixels, compound holes and self-crossing fill, plus painted-stroke paths that keep the outline route and clipping-mask split, empty-mask and Path Eraser controls. `crates/engine/tests/it/eraser_open_fill.rs` also includes container-own paint and evaluated-placement regression cases. Scores and estimates unchanged. - **Implemented (#6470):** Scissors hover and cuts use the Pen's path, alignment, intersection and anchor snapping, following the existing Smart Guides, Snap to Point, Snap to Pixel and Snap to Grid options. Alt still adds an anchor without cutting, and a cut still leaves one new endpoint selected. Headless regressions are in `crates/tools/src/draw2/anchor/tests.rs`; broader G11 scope and estimates unchanged. diff --git a/docs/production-preflight.md b/docs/production-preflight.md index ecc551f0c9..77698662d8 100644 --- a/docs/production-preflight.md +++ b/docs/production-preflight.md @@ -52,7 +52,7 @@ The same read-only report is available through `document.preflight`; see [MCP](m Checked on Windows with Rust 1.99.1, based on `main` at `36b5a5920c`: -- Engine integration tests: 9 passed (`cargo test -p vectorcraft-engine --test preflight`). +- Engine integration tests: 9 passed (`cargo test -p vectorcraft-engine --test it preflight::`). - Panel tests: 5 passed (`cargo test -p vectorcraft-ui-egui --lib preflight`), including pointer selection/zoom, edits and Undo, document switching, external-file polling and explicit Recheck. - Both test commands used `--offline --target-dir target --config profile.test.opt-level=0`. diff --git a/docs/roadmap.md b/docs/roadmap.md index 971ca6eafa..726ecd790b 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -34,7 +34,7 @@ Color conversion (#8804) builds one first-name index for the document's global swatch bases and uses indexed lookups for linked paints. Document Color Mode, new-art colors and text-style conversion keep first-record shadowing, spot handling, tint behavior and missing-link fallback. The base construction changes from quadratic name searches to O(N log N) index work; this is a source-complexity result, not a measured elapsed-time or budget improvement. Command-level semantic controls are in `crates/engine/src/tests/colormgmt.rs`; scores and estimates are unchanged. -**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. Scores and estimates are unchanged. +**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. Scores and estimates are unchanged. Draft enhancement #5804: Preferences › File Handling can select a raster editor through the native picker, with a private draft outside engine preferences and generic dialog fields. OK saves it, Cancel discards it, and Reset restores PhotoCraft. With Use System Defaults off, a missing chosen editor falls back to PhotoCraft, then the system default; validation and launch failures are reported. Control/MCP and synthetic input cannot choose an application or run external Edit Original. Web behavior, parity scores and estimates are unchanged; macOS/Linux smoke tests remain pending. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 4df379b998..ae083e42e9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -77,7 +77,7 @@ Variables panel row context menus (2026-11-20, G12): Right-click highlights the Actions panel item context menus (2026-11-20): Right-clicking an Action Set row selects it and presents a context menu with New Action…, New Set…, Duplicate Set, Delete Set, and Set Options…. Right-clicking an Action row selects it and presents a context menu with Play, Record, Duplicate, Delete, Action Options…, and Batch…. Duplicate on an action duplicates that action and selects the duplicate; Delete removes it. Headless tests in `crates/ui-egui/src/panels/actions.rs`: `right_clicking_an_action_set_selects_it_and_presents_set_context_options`, `right_clicking_an_action_selects_it_and_presents_action_options`, and `clicking_duplicate_on_an_action_duplicates_that_action_in_the_set`. Scores and estimates unchanged. -**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. Scores and estimates are unchanged. +**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. Scores and estimates are unchanged. `window.panel.float` updates an existing native panel window's supplied position and size (#8391). Positions use the main window's content origin. Omitted coordinates and dimensions keep their current native values, including after an OS window move or resize. Evidence: `panel_docking::native_tests::an_explicit_float_command_updates_an_existing_native_windows_geometry` covers panel, group and column commands. Scores and estimates are unchanged. @@ -346,8 +346,8 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Area | Weight | Done | Main gaps | One agent (h) | Kind | |---|---:|---:|---|---:|---| -| Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); deletion splits an ordinary contour into selected sibling objects with bounds-fitted gradients kept in place (#3380, deletion only; `crates/engine/tests/it/delete_path_pieces.rs`); open-path anchor Delete keeps gaps; Select › Start Global Edit finds the paths, compound paths and symbol instances of the selected object's shape (Appearance, Size and artboard options) and gives an edit of one to all of them in proportion, as one undo step (#3521), and on a group the groups like it, an edit inside one reaching the same object in the others (#4939), and a Shift-click on a highlighted match leaves it out; the Align panel menu's Align to Glyph Bounds › Point Text and Area Text measure type by its glyphs' ink for Align and Distribute (#4231); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of rotated copies, transform nuances (no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | estimated; fill-stack selection regression-tested (`crates/engine/tests/path_fill_hits.rs`, #6625); cap/join follow-up CPU regressions passed; Global Edit regression-tested (`crates/engine/src/tests/globaledit.rs`; Quick Action, menu label and Escape in `panels::properties::tests::start_global_edit_quick_action_and_escape`) | -| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options; Touch Type (#2469) and the Dimension tool (#1788) are done; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged; Scissors shares the Pen's path/align/intersect/anchor snaps (#6470), source and headless regressions below; Eraser preserves fill-only open-path area outside fixed and varied tip sweeps and Alt-drag marquees, including compound holes; clipping masks keep their remaining contours and empty-mask role; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior and result structure (#6582; `crates/engine/tests/eraser_open_fill.rs`), score and hours unchanged; Scissors cut-point preview covered in tool and Session regressions (#8655), scores and hours unchanged | +| Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); deletion splits an ordinary contour into selected sibling objects with bounds-fitted gradients kept in place (#3380, deletion only; `crates/engine/tests/it/delete_path_pieces.rs`); open-path anchor Delete keeps gaps; Select › Start Global Edit finds the paths, compound paths and symbol instances of the selected object's shape (Appearance, Size and artboard options) and gives an edit of one to all of them in proportion, as one undo step (#3521), and on a group the groups like it, an edit inside one reaching the same object in the others (#4939), and a Shift-click on a highlighted match leaves it out; the Align panel menu's Align to Glyph Bounds › Point Text and Area Text measure type by its glyphs' ink for Align and Distribute (#4231); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of rotated copies, transform nuances (no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | estimated; fill-stack selection regression-tested (`crates/engine/tests/it/path_fill_hits.rs`, #6625); cap/join follow-up CPU regressions passed; Global Edit regression-tested (`crates/engine/src/tests/globaledit.rs`; Quick Action, menu label and Escape in `panels::properties::tests::start_global_edit_quick_action_and_escape`) | +| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options; Touch Type (#2469) and the Dimension tool (#1788) are done; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged; Scissors shares the Pen's path/align/intersect/anchor snaps (#6470), source and headless regressions below; Eraser preserves fill-only open-path area outside fixed and varied tip sweeps and Alt-drag marquees, including compound holes; clipping masks keep their remaining contours and empty-mask role; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior and result structure (#6582; `crates/engine/tests/it/eraser_open_fill.rs`), score and hours unchanged; Scissors cut-point preview covered in tool and Session regressions (#8655), scores and hours unchanged | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 80% | Shape Builder on the reporter's file (#937: art past 4,096 segments is cut by lines again; unconfirmed on the file itself); gap detection shares Live Paint’s finder, with a 72 pt custom cap and the existing options; Live Paint Gap Options | 4–8 | estimated; Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog (lowered from 86%: open issues); compound attributes regression-tested (#1197); single-result source names survive SVG export/import (#1293), with [SVG ID semantics](https://www.w3.org/TR/SVG2/struct.html#IDAttribute) and original-shape tests; Simplify component selection and preview regression-tested (#1272); Simplify of a Direct Selection part of a path regression-tested (`tests/simplify_part.rs`); Divide open-cutting-path geometry and appearance regression-tested (#1307); the Shape Builder's edge-source grid is bounded in memory and files a segment once per cell (`planar.rs` test `rect_index_holds_a_bounded_number_of_references`); live compound shapes (Make, Alt-click, member Shape Modes, Release, Expand, saved and exported) regression-tested (#4522); Live Paint Bucket face drags, including narrow faces and one Undo, regression-tested (#6373) | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | Picker Lab entry, picker libraries and Assign-row menus complete the deferred #4028 UI paths (#8031); scores and estimates unchanged; Eyedropper copies effective character dimensions across text transforms (#6404); 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors| 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged; a point on a gradient mesh's outline locates on its edge on every side (#7006: `mesh_locate_takes_a_point_on_any_side_of_the_outline`, `mesh_add_line_exactly_on_the_edge_needs_no_tolerance`), score and hours unchanged; Color panel spectrum grows with the resized panel (#8005); the Color Wheel panel's Show Opacity sets the opacity of the fill, stroke, gradient stop or freeform point it edits (part of #978), score and hours unchanged; gradient stop editor color-mode menu (#7918) | | Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) | @@ -692,12 +692,12 @@ since 2026-10-01. - **`.ai` clipping paths grouped in a compound path (#8128):** `clipping_paths_grouped_in_a_compound_path_are_its_subpaths` in `crates/eps/src/import/ai/tests.rs` covers clipping paths grouped in a compound path (`*u u W n … U *U`, also nested in other groups): they are the compound path's subpaths, and the compound clipping path, their union, clips its clipping group however many there are and wherever in the group it is written. Synthetic files written in the test; no fixtures added. Scores and hours unchanged. -**Production Preflight (2026-11-18, VectorCraft addition):** `document.preflight` and Window > Production Preflight reuse the output-aware type walk, Links status probes, `image.info` effective-PPI calculation and saved Print geometry. Findings locate canvas objects (resource findings name their first visible owner). Rechecking follows document identity/revision, output/scope/threshold changes, explicit Recheck and a two-second external-file timer. Print resolution includes the page transform. Resolution in resource art and placed documents is explicitly not checked; this is not exported-file certification. Regression sources: `crates/engine/tests/preflight.rs`, `crates/ui-egui/src/panels/preflight/tests.rs`. Scores and estimates unchanged. +**Production Preflight (2026-11-18, VectorCraft addition):** `document.preflight` and Window > Production Preflight reuse the output-aware type walk, Links status probes, `image.info` effective-PPI calculation and saved Print geometry. Findings locate canvas objects (resource findings name their first visible owner). Rechecking follows document identity/revision, output/scope/threshold changes, explicit Recheck and a two-second external-file timer. Print resolution includes the page transform. Resolution in resource art and placed documents is explicitly not checked; this is not exported-file certification. Regression sources: `crates/engine/tests/it/preflight.rs`, `crates/ui-egui/src/panels/preflight/tests.rs`. Scores and estimates unchanged. - `object.setBounds` uses the same reference point for whole-number integer and floating-point values, including `0` and `0.0`. It rejects negative and fractional indices without changing geometry, selection, or undo history. An omitted or null reference uses the center, and whole-number references above 8 use point 8. Object and direct-anchor selections follow these rules (`tests::bboxrotate::set_bounds_whole_number_references_match_integer_references`, `set_bounds_rejects_invalid_references_without_changes`). - Twist keeps boundary handles tangent to the rotation inside its outer circle. Regressions cover 90, 400, and -720 degree twists, unchanged boundary anchors, and a sampling midpoint that rounds to an endpoint at large coordinates (`twist_boundary_handles_follow_the_inward_tangent` and `a_midpoint_rounded_to_an_endpoint_keeps_the_handle_direction`). -- **Blend redraw bounds (#5179):** renderer bounds include the reach of keys and steps rotated along a curved spine, so changed pixels remain inside the advertised redraw area. The original straight-blend control and curved Replace Spine, move and Undo regressions are in `crates/engine/tests/blend_render_consistency.rs`; both focused CPU cases pass. This is a redraw-bounds correction. Scores and hours unchanged. +- **Blend redraw bounds (#5179):** renderer bounds include the reach of keys and steps rotated along a curved spine, so changed pixels remain inside the advertised redraw area. The original straight-blend control and curved Replace Spine, move and Undo regressions are in `crates/engine/tests/it/blend_render_consistency.rs`; both focused CPU cases pass. This is a redraw-bounds correction. Scores and hours unchanged. - **Guide row highlight (#7344):** `guide_row_highlight_stays_selected_without_hover` in `crates/ui-egui/src/panels/layers/tests.rs` checks selected guide background after the pointer leaves, with unselected guide and ordinary row controls. Guide selection, dragging and deletion are unchanged. Scores and estimates unchanged. - **Trim View hides guides and the grid (#8363):** while View › Trim View is on, the canvas and tiled panes draw no ruler guides, no guide paths and no grid, the guides are neither snapped to nor picked, and Show/Hide Guides and Show/Hide Grid are greyed out (menu bar, canvas context menu, Properties) and refuse to run; the stored choices come back when it is turned off, and the rulers stay ([trim view hides guides](https://community.adobe.com/t5/illustrator-discussions/trim-view-hides-guides/td-p/14066140), [guides greyed out](https://community.adobe.com/t5/illustrator-discussions/guides-greyed-out/m-p/11132728)). A drag or double-click on a ruler makes no guide while it is on (no preview, no undo step, a status message). `trim_view_hides_the_guides_and_the_grid`, `trim_view_deselects_selected_guide_paths`, `trim_view_makes_no_guide_from_the_rulers` in `crates/ui-egui/src/canvas/tests.rs`; `trim_view_greys_out_show_guides_and_show_grid` in `crates/ui-egui/src/menus/tests.rs`. @@ -716,7 +716,7 @@ since 2026-10-01. - **Save refusal (#6146):** ordinary File > Save to its own location offers Save As after a terminal permission/read-only refusal, suggesting the original name and format, preserving options for the unchanged format and opening the chosen format’s Save options on a change. Cancel keeps the failed-save state. Busy pickers, recovery-copy errors, other failures, explicit destinations and Close/Quit keep the existing dialog. Engine, UI and MCP regression cases are in `cmd/fileio/tests_readonly.rs`, `io/tests_read_only_save.rs` and MCP `tests/fileio.rs`; focused UI regressions passed; engine regression execution and native panel acceptance pending. Scores and hours unchanged. -**Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss with Object Selection by Path Only on or in Outline view, and with it off are picked only when the click hits nothing else there (#9175, below). Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged. +**Selection fill eligibility (#6625):** Path and compound-path interiors use any enabled non-None fill row (#6625). A lower visible fill remains selectable beneath a top None row in the same object; hidden-only and true-None interiors miss with Object Selection by Path Only on or in Outline view, and with it off are picked only when the click hits nothing else there (#9175, below). Zero-opacity fills remain selectable. Original CPU-render and document-hit regressions in `crates/engine/tests/it/path_fill_hits.rs` cover seven Path and five Compound cases, including stroke edges, geometric outlines, Outline/path-only modes and compound holes. Hidden-fill and no-fill stroked paths must respect butt, round and square caps and bevel, round and miter joins. Focused cap/join CPU regressions passed. Scores and estimates unchanged. - **Clicks inside unfilled shapes (#9175):** with Object Selection by Path Only off (the default), the Selection, Direct Selection and Group Selection tools, Object Highlighting and a right-click's selection pick a closed path or compound path with no fill by a click inside its closed subpaths, when the click hits no other object there, by its fill, stroke, path or bounds (a symbol instance, for example, is hit anywhere in its bounds); among such paths the topmost is picked, and Select Behind lists them after the objects that paint there. Open paths, guides and clipping paths are still picked by their path only, and Outline view and layers whose Preview is off are unchanged. This is VectorCraft's own rule. Tests: `an_unfilled_closed_path_is_hit_inside_unless_by_path_only_or_in_outline`, `an_open_path_is_not_hit_inside`, `art_inside_an_unfilled_frame_above_it_is_hit_before_the_frame`, `an_unfilled_compound_path_is_hit_inside_its_members_but_not_its_holes`, `guides_and_clipping_paths_are_not_hit_inside`, `a_repeat_is_hit_inside_its_unfilled_copies_but_not_inside_their_masks` and `symbol_art_parts_are_picked_inside_unfilled_frames_after_what_paints` in `crates/doc/src/hit/tests.rs`, and `a_click_inside_an_unfilled_shape_selects_it_unless_by_path_only` (MCP). Scores and estimates unchanged. @@ -727,7 +727,7 @@ since 2026-10-01. - **PDF Indic type (#5235, #6906):** `crates/pdf/src/tests/reshaped.rs` covers a vowel sign the file draws before its consonant (the line keeps the file's glyphs as outlines, with a note), text in reading order (stays type), a mark with no advance (stays on its line, not vertical type of its own), outlined glyphs stroked with different dashes and translucent outlined glyphs (each keeps its own path). Synthetic font only; one real Gujarati file checked by eye on page 1. Indic type in an uninstalled font keeps the file's glyphs as outlines; reordering signs so more lines stay editable is not done. Scores and hours stay at 75% / 10-20 h. -- **Selection — Space during an ordinary path's direction-handle drag (#7237, request 3 only).** Pressing Space during an ordinary path's Direct Selection handle drag translates the owning anchor and both handles; releasing Space while the mouse stays down resumes handle adjustment. The same gesture during the Pen's Cmd/Ctrl loan returns to drawing from the same endpoint. `crates/engine/tests/pen_space_handle.rs` covers first-motion Space, repeated toggles and Pen continuation (`pen_space_first_motion_repeated_toggle_and_pen_continuation`), one-step Undo/Redo (`pen_space_handle_drag_undo_redo_is_one_step`), and cancellation restoring the borrowed gesture (`pen_space_escape_restores_entire_borrowed_gesture`). Live type-on-path Space behavior is outside this increment; blend-spine editing is unchanged. This does not close the issue's separate handle-hover label request or change Cmd snapping or handle-coupling policy. Score and hours unchanged. +- **Selection — Space during an ordinary path's direction-handle drag (#7237, request 3 only).** Pressing Space during an ordinary path's Direct Selection handle drag translates the owning anchor and both handles; releasing Space while the mouse stays down resumes handle adjustment. The same gesture during the Pen's Cmd/Ctrl loan returns to drawing from the same endpoint. `crates/engine/tests/it/pen_space_handle.rs` covers first-motion Space, repeated toggles and Pen continuation (`pen_space_first_motion_repeated_toggle_and_pen_continuation`), one-step Undo/Redo (`pen_space_handle_drag_undo_redo_is_one_step`), and cancellation restoring the borrowed gesture (`pen_space_escape_restores_entire_borrowed_gesture`). Live type-on-path Space behavior is outside this increment; blend-spine editing is unchanged. This does not close the issue's separate handle-hover label request or change Cmd snapping or handle-coupling policy. Score and hours unchanged. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. @@ -834,7 +834,7 @@ since 2026-10-01. - **Clipping paths on their outline (G1):** the selection tools (Selection, Direct Selection, Group Selection), Object Highlighting and a right-click take a clipping path on its outline before the art it clips; Select Behind lists the same; the eyedropper, the tools that act on what is drawn and the selection tools' double-clicks, loaded text and guide release take the art. Doc and tool regression tests; score unchanged. - **Link cursor for loaded text:** with text loaded from a port, the Selection tool's pointer adds a link badge over a closed path, area type or type on a path that a click threads the text into, and keeps the loaded text elsewhere; a click on a frame already in a thread or a path inside a compound path makes a new frame instead of a `text.thread.add` error (`select::tests::loaded_text_shows_the_link_cursor_where_a_click_threads_it_into_the_object`, `cursors::tests::loaded_text_link_cursor_is_the_loaded_text_with_a_link_badge`); score unchanged. - **Copy and Cut of anchors picked with a lent Direct Selection (#6123):** with the Pen or the Curvature tool, Cmd/Ctrl held lends Direct Selection for the gesture; the anchors and segments it picks are what Edit › Copy and Cut take once the key is let go, as with Direct Selection chosen, while the last anchor the Pen leaves selected as it draws still makes Copy take the whole path (#2122). A Cmd gesture that leaves the selection as it was (a Shift marquee over nothing) picks nothing. Regression test: `tests::draw2::pen_cmd_selected_anchors_are_what_copy_and_cut_take`. -- **Mirrored handles in a Direct Selection drag (#7842):** Cmd/Ctrl added after a handle drag begins puts the anchor's other handle opposite the dragged one at the same length, on paths, type on a path and blend spines, and the anchor keeps its kind; Shift constrains the dragged handle first, and Alt keeps the handles independent. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without Cmd/Ctrl. When Cmd/Ctrl lends Direct Selection for the gesture while another tool, such as the Pen, is chosen, that press does not mirror; letting it go and pressing it again during the drag does. This is VectorCraft's own behavior. Regression tests: `crates/engine/tests/direct_handle_mirror.rs`. +- **Mirrored handles in a Direct Selection drag (#7842):** Cmd/Ctrl added after a handle drag begins puts the anchor's other handle opposite the dragged one at the same length, on paths, type on a path and blend spines, and the anchor keeps its kind; Shift constrains the dragged handle first, and Alt keeps the handles independent. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without Cmd/Ctrl. When Cmd/Ctrl lends Direct Selection for the gesture while another tool, such as the Pen, is chosen, that press does not mirror; letting it go and pressing it again during the drag does. This is VectorCraft's own behavior. Regression tests: `crates/engine/tests/it/direct_handle_mirror.rs`. - **Cut of picked anchors (#6361):** Edit › Cut removes direct-selected anchors from their path and from a compound path's member, with the segments attached to them, as Clear does. Picked segments still lose only those segments. When a path also has a picked segment, Cut removes and copies only its picked segments and ignores its picked anchors, on every contour, as Clear does; an anchor left without a surviving segment is removed with them. Regression tests: `cut_*_anchors_*` and `cut_of_an_anchor_with_a_segment_on_another_contour_leaves_the_source_as_clear_does` in `crates/engine/tests/it/copy_direct_selection.rs`. - **Escape in Selection tool drags:** Escape during a Selection tool move or Alt-drag copy, a bounding-box scale or rotation, a marquee, or a corner widget, pie widget or bracket drag cancels it: the art returns to its state at the press, no copy is left, no undo step is added, the release does nothing, and the tool stays chosen. This is VectorCraft's own behavior. Regression tests: `escape_cancels_*` in `select/tests.rs` and `pie.rs`, and `escape_cancels_a_selection_tool_move_copy_scale_or_rotation` in `tests/selectescape.rs`. - **Commands run during a tool drag:** by VectorCraft's own rule, a command that changes the document while a tool drag is in progress (from a panel, a menu or `run_command`) records its own undo step before the drag's. The drag goes on with the art the command left, Escape cancels only the drag, and Undo takes back the drag first and the command next, with Real-time Drawing on or off. A selection the command makes does not change which objects the drag moves. Commands that keep the drag as a step first (Undo, Redo, `command.batch` and others), a Quick Pen press, and a copy made with `object.transform` during an Alt-drag work as before. Regression tests: `crates/engine/src/tests/interaction_commands.rs` and `tests::drag_commands` in `crates/ui-egui`. @@ -1594,10 +1594,10 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur VectorCraft's own Anchors field in the Ellipse dialog (a click with the Ellipse tool; `shape.ellipse {anchors}`, part of #7840) sets how many smooth anchors the ellipse has, 4 by default; 4 draws a live ellipse, and any other count from 2 to 1000 draws a plain path with the anchors spaced evenly by angle, fitted to the typed width and height. The count last confirmed stays as the Ellipse tool's `anchors` option, and the next Ellipse dialog opens on it (`ellipse_with_four_anchors_is_the_live_ellipse`, `ellipse_anchors_draw_that_many_anchors_on_the_ellipse`, `ellipse_refuses_a_bad_anchor_count`, `the_ellipse_dialog_draws_and_keeps_its_anchor_count`). In the Ellipse dialog, a click on the word Height copies the Width value into the Height field, so OK draws a circle of that width, as [the help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=140) describes for drawing ellipses. The Rectangle and Rounded Rectangle dialogs keep plain labels. VectorCraft's own rules: the word Height is a button that Space or Enter also presses, and that Enter does not press OK (nor does Enter on the Constrain Width and Height Proportions button); with the link on, the link stays on and keeps the circle when a side is typed next; a Width that is empty or not a distance, including one the field refuses as the click leaves it, leaves Height as it is; Cancel discards the copy. Evidence: `dialogs::shapes::tests::{clicking_height_in_the_ellipse_dialog_copies_width_into_height, the_ellipse_height_button_copies_width_from_the_keyboard_and_keeps_the_link_round, enter_on_the_link_button_turns_the_link_on_without_pressing_ok, only_the_ellipse_dialog_has_the_height_button, copying_width_takes_only_a_width_that_reads}`. - The click-dialog field landed in #7964. While an ellipse is dragged out, Up/Down raises or lowers the same remembered Anchors count within 2…1000 (#7840), keeping the preview box and its Shift, Alt and Space behavior. Four anchors keep the live ellipse; other counts use the existing plain-path geometry. Releasing commits one undo step. Escape restores the count from before the drag, unless `tool.setOption` explicitly updated it during the gesture, in which case that value stays. Regression target: `crates/engine/tests/ellipse_drag_anchors.rs` (`ellipse_drag_anchors_`). + The click-dialog field landed in #7964. While an ellipse is dragged out, Up/Down raises or lowers the same remembered Anchors count within 2…1000 (#7840), keeping the preview box and its Shift, Alt and Space behavior. Four anchors keep the live ellipse; other counts use the existing plain-path geometry. Releasing commits one undo step. Escape restores the count from before the drag, unless `tool.setOption` explicitly updated it during the gesture, in which case that value stays. Regression target: `crates/engine/tests/it/ellipse_drag_anchors.rs` (`ellipse_drag_anchors_`). - **Cutting:** Eraser, Scissors, Knife, Mirror & Cut, Line Cut and Rectangle Cut (real geometry, compound paths keep their holes). - The Eraser cuts fill-only open contours as areas (#6582), retaining fill outside its sweep or Alt-drag marquee. An eligible appearance has a visible non-None fill and no visible non-None stroke of positive width. Fill-only open compound members are cut together under their compound fill rule so holes stay empty. Cut pieces keep the existing path/compound representation and whole appearance. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Path or Compound clipping masks keep every surviving contour in the same mask node; full erasure leaves an empty mask without promoting clipped contents. The mask identity, fill rule, appearance and parent child order are retained. Path Eraser uses the same preservation of the clipping role. Filled-and-stroked open paths retain the outline-splitting behavior from main. `crates/engine/tests/eraser_open_fill.rs` covers fixed and varied tips on fill-only open/closed geometry and raster output, compound holes and self-crossing fill, plus a painted-stroke outline control and clipping-mask split, empty-mask and Path Eraser cases. The same public target includes container-own paint and evaluated-placement regression cases. This deliberately scoped fix does not claim to repair filled-and-stroked open-path fill behavior. Scores and hours are unchanged. - With Alt released, Scissors hover and cuts snap as the Pen does: onto paths and anchors, into alignment and onto intersections (#6470). The hover guides and cut use the same snapped point; the cursor follows the current hover target. The existing Smart Guides, Snap to Point, Snap to Pixel and Snap to Grid options keep their precedence. Pixel Preview turns off Smart Guides through the tool view context; Snap to Point keeps its existing rules. Alt Add Anchor and the cut's endpoint selection below are unchanged. Source: `crates/tools/src/draw2/anchor.rs`. Headless regressions: `scissors_snaps_intersections_with_the_drawing_options`, `scissors_shows_paths_alignment_and_configured_anchor_snaps`, `scissors_cursor_and_press_use_current_snaps` and `scissors_clears_its_snap_when_the_interaction_ends_or_alt_takes_over` in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. + The Eraser cuts fill-only open contours as areas (#6582), retaining fill outside its sweep or Alt-drag marquee. An eligible appearance has a visible non-None fill and no visible non-None stroke of positive width. Fill-only open compound members are cut together under their compound fill rule so holes stay empty. Cut pieces keep the existing path/compound representation and whole appearance. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Path or Compound clipping masks keep every surviving contour in the same mask node; full erasure leaves an empty mask without promoting clipped contents. The mask identity, fill rule, appearance and parent child order are retained. Path Eraser uses the same preservation of the clipping role. Filled-and-stroked open paths retain the outline-splitting behavior from main. `crates/engine/tests/it/eraser_open_fill.rs` covers fixed and varied tips on fill-only open/closed geometry and raster output, compound holes and self-crossing fill, plus a painted-stroke outline control and clipping-mask split, empty-mask and Path Eraser cases. The same public target includes container-own paint and evaluated-placement regression cases. This deliberately scoped fix does not claim to repair filled-and-stroked open-path fill behavior. Scores and hours are unchanged. + With Alt released, Scissors hover and cuts snap as the Pen does: onto paths and anchors, into alignment and onto intersections (#6470). The hover guides and cut use the same snapped point; the cursor follows the current hover target. The existing Smart Guides, Snap to Point, Snap to Pixel and Snap to Grid options keep their precedence. Pixel Preview turns off Smart Guides through the tool view context; Snap to Point keeps its existing rules. Alt Add Anchor and the cut's endpoint selection below are unchanged. Source: `crates/tools/src/draw2/anchor.rs`. Headless regressions: `scissors_snaps_intersections_with_the_drawing_options`, `scissors_shows_paths_alignment_and_configured_anchor_snaps`, `scissors_cursor_and_press_use_current_snaps` and `scissors_clears_its_snap_when_the_interaction_ends_or_alt_takes_over` in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. A Scissors cut (`path.split`) leaves one of the two new end points selected and the rest of the path unselected, as [Cut paths](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/split-paths.html) and the "Split a path" section of the [CS3 user guide](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf) describe: the two end points lie on top of each other, and a Direct Selection drag from them moves the selected one with its handles and no other anchor. A closed path cut once stays one open path. The paths a Scissors cut (`path.split`) or Cut Path at Selected Anchor Points (`path.cutAtAnchors`) makes keep the source path's fill and stroke settings, and every stroke's alignment becomes Center in the same undo step, as [the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/split-paths.html) describes. Resetting hidden stroke rows too, centering the strokes of a path's other subpaths and of the compound path a cut member belongs to are VectorCraft's own rules (`scissors_cut_paths_have_their_strokes_centered`, `cut_at_anchors_paths_have_their_strokes_centered`). While Alt is held, the Scissors tool works as the Add Anchor Point tool ([Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)): a click on a segment adds an anchor point without cutting (`path.insertAnchor`), and the pointer shows the Add Anchor Point cursor. When Alt is let go, a click cuts again. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d131053a67..957cfa9479 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -25,7 +25,7 @@ ## Feature submission evidence -**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. Scores and estimates are unchanged. +**Scissors cut-point preview (#8655):** A native point marker shows the anchor or position on a curve that the current Scissors click targets, including the existing snapping rules. Hovering changes no artwork; an ineligible or stale hover has no marker. Existing cut and Alt Add Anchor behavior are retained. Focused tool and Session regressions live in `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. Scores and estimates are unchanged. Draft enhancement #5804: Preferences › File Handling can select a raster editor through the native picker, with a private draft outside engine preferences and generic dialog fields. OK saves it, Cancel discards it, and Reset restores PhotoCraft. With Use System Defaults off, a missing chosen editor falls back to PhotoCraft, then the system default; validation and launch failures are reported. Control/MCP and synthetic input cannot choose an application or run external Edit Original. Web behavior, parity scores and estimates are unchanged; macOS/Linux smoke tests remain pending. @@ -204,12 +204,12 @@ tools, never checked side by side) isn't captured row by row. | Pen cursors (new path ×, continue /, close o, add +, delete −, convert ^) | done | the nib is a fountain-pen nib, tip on the hotspot, with the slit widening into the breather hole and the heel clipped square to its axis; bitmap tests at 1× and 2× pin the nib and the new-path asterisk, and in-app screenshots compare the Pen with Direct Selection | | Node-editing cursors: Direct Selection's white arrow with a hollow or filled square over an anchor (path unselected or selected); the Reshape Segment cursor over a curved segment (Direct Selection, Anchor Point, the Pen with Alt); the Anchor Point caret for the Pen with Alt; Group Selection's plus (also Direct Selection with Alt); a filled arrow while dragging that turns hollow on a snap; a double arrowhead for an Alt-drag copy | partial | as the public manual describes them, drawn in code; no cue over handles (none documented) | | Anchor Point and Curvature tools' own cursors | done | the caret on the anchor it converts; the pen nib with a curve badge | -| Scissors hover and cuts use the Pen's path, alignment, intersection and anchor snapping (#6470) | implemented | Existing Smart Guides, Snap to Point, pixel and grid options apply; Pixel Preview turns off Smart Guides. Alt still adds an anchor without cutting, and a cut still leaves one new endpoint selected. Headless regressions: `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/scissors_snap.rs`. | -| Scissors cut-point preview (#8655) | implemented | Native marker at the actual anchor or curve target; current snapping, cut and Alt Add Anchor behavior retained. `crates/tools/src/draw2/anchor/tests.rs`, `crates/engine/tests/scissors_snap.rs`. | +| Scissors hover and cuts use the Pen's path, alignment, intersection and anchor snapping (#6470) | implemented | Existing Smart Guides, Snap to Point, pixel and grid options apply; Pixel Preview turns off Smart Guides. Alt still adds an anchor without cutting, and a cut still leaves one new endpoint selected. Headless regressions: `crates/tools/src/draw2/anchor/tests.rs` and `crates/engine/tests/it/scissors_snap.rs`. | +| Scissors cut-point preview (#8655) | implemented | Native marker at the actual anchor or curve target; current snapping, cut and Alt Add Anchor behavior retained. `crates/tools/src/draw2/anchor/tests.rs`, `crates/engine/tests/it/scissors_snap.rs`. | | Free Transform's Cmd/Ctrl side-shear cursor | done | two arrows passing along the side (ShearH, ShearV), instead of the resize arrow across it | | Live Paint Bucket cursors | partial | a filled bucket over a face a click fills, a brush over an edge it paints, an empty bucket where it paints nothing, following Paint Fills, Paint Strokes and Shift; the Eyedropper with Alt; the crosshair with Use Precise Cursors. No cursor swatch preview | | Cursors of their own for Lasso, Magic Wand, the freehand tools, Shaper, Measure, Print Tiling, the symbolism tools, vertical type, Scissors (over a segment and away), Mesh and Puppet Warp | partial | each tool returns its own cursor and Use Precise Cursors turns them into the crosshair; until they're drawn they borrow the crosshair, the I-beam, the Pen's add cursor or not-allowed | -| Eraser: filled open paths and compound holes | partial | Fill-only open paths preserve fill outside sweeps and Alt-drag marquees and keep compound holes under their fill rule (#6582). Path or Compound clipping masks retain all surviving contours or empty geometry in the same node, preserving the mask role; Path Eraser shares this behavior. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Focused engine tests cover fixed and varied tips and Alt-drag marquees on open/closed geometry, raster output, compound holes and self-crossing fill, plus a painted-stroke outline control and clipping-mask split, empty-mask and Path Eraser cases. `crates/engine/tests/eraser_open_fill.rs` also includes container-own paint and evaluated-placement regression cases. Filled-and-stroked open paths retain main behavior; that fill behavior is not claimed fixed. See G11 in [gaps.md](gaps.md#g11-correctness-bugs-in-core-tools). | +| Eraser: filled open paths and compound holes | partial | Fill-only open paths preserve fill outside sweeps and Alt-drag marquees and keep compound holes under their fill rule (#6582). Path or Compound clipping masks retain all surviving contours or empty geometry in the same node, preserving the mask role; Path Eraser shares this behavior. Bounds-fitted gradients on ordinary paths, compounds, groups and layers keep their original evaluated placement when it can be reproduced in the stored paint. Effects that draw replacement artwork, effect plug-ins, Rasterize, gradients along or across a stroke, and flattened placements or placements that cannot reproduce the original appearance keep their existing fitted behavior. Hidden Rasterize rows and hidden strokes with gradients along or across their paths do not block preserving a visible gradient. Already placed gradients and live-effect settings are retained; changes to a live effect's geometry can still move its paint. Focused engine tests cover fixed and varied tips and Alt-drag marquees on open/closed geometry, raster output, compound holes and self-crossing fill, plus a painted-stroke outline control and clipping-mask split, empty-mask and Path Eraser cases. `crates/engine/tests/it/eraser_open_fill.rs` also includes container-own paint and evaluated-placement regression cases. Filled-and-stroked open paths retain main behavior; that fill behavior is not claimed fixed. See G11 in [gaps.md](gaps.md#g11-correctness-bugs-in-core-tools). | | Knife cursor | done | a knife, the blade's point on the hotspot, white blade and black handle, for the Knife and the Trim at Crossings Tool; the crosshair with Use Precise Cursors; `the_knife_shows_a_knife_with_its_point_on_the_hotspot`, `drawing_tools_show_their_own_cursor` | | Blob Brush and Eraser: the tip's outline at the pointer | done | before a press and while painting, the outline of the tip (its size, angle and roundness, at the zoom) follows the pointer, black on a white halo, round a small centre dot; `[` / `]` and Tool Options change it at once; precise cursors (Caps Lock) show only the crosshair; it goes when the pointer leaves the canvas, while Cmd/Ctrl lends a selection tool and while Alt lends the Blob Brush the Smooth tool (#4977); `crates/tools/src/draw2/gesture.rs` and its tests While the button is down a round Blob Brush shows the outline of the area it will add, rounded at both ends, not a line as wide as the brush that ends square (#4343). | | Eraser: an Alt-drag draws a marquee and the release erases everything inside it (closed shapes and fill-only open paths lose the rectangle's area, other open paths are cut where they cross its edges); Alt+Shift keeps the marquee square; Escape cancels it, and a click erases nothing | done | `path.eraseRegion {rect}`; [public behavior reference](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=133); `eraser_alt_drag_draws_a_marquee_and_erases_the_rectangle`, `eraser_alt_shift_drag_keeps_the_marquee_square`, `eraser_marquee_click_or_escape_erases_nothing`, `erase_region_rect_erases_everything_inside_it`, `erase_region_rect_refuses_bad_values` | @@ -250,7 +250,7 @@ tools, never checked side by side) isn't captured row by row. | Behaviour | Status | Notes | |---|---|---| -| Path and compound-path interior selection follows enabled non-None fill rows | done | #6625; lower visible fill beneath a top None row stays selectable; hidden-only/None interiors miss; zero-opacity, edge, Outline/path-only and hole controls in `crates/engine/tests/path_fill_hits.rs`; hidden-fill and no-fill stroke cap/join CPU regressions passed | +| Path and compound-path interior selection follows enabled non-None fill rows | done | #6625; lower visible fill beneath a top None row stays selectable; hidden-only/None interiors miss; zero-opacity, edge, Outline/path-only and hole controls in `crates/engine/tests/it/path_fill_hits.rs`; hidden-fill and no-fill stroke cap/join CPU regressions passed | | Backquote/~ arrow nudges move selected pattern fills and strokes | done | #7717: Selection, partial-anchor Direct Selection and other idle tools; Keyboard Increment/Shift; geometry, guides and anchor selection stay fixed. Tests: `crates/ui-egui/tests/pattern_only_nudge.rs` | | Deleting segments or anchors that disconnect an ordinary path creates independent selected objects | done | #3380, deletion only: first piece retains its ID, styles and transforms carry over in sibling order, bounds-fitted gradients keep their original placement, and one Undo restores the original. Existing multi-subpath paths and compound members stay intact. `delete_path_pieces` covers transformed/styled rectangles, cubic handles and Undo/Redo. Endpoint highlighting remains open. | | Click/Shift-click anchors; marquee toggles with Shift | done | #483 | @@ -269,7 +269,7 @@ tools, never checked side by side) isn't captured row by row. | Drag a curved segment to bend it, a straight one to move its anchors | done | | | Drag by an anchor of a path selected whole moves the whole path; Alt-drag by an anchor or a segment copies it, Alt toggles the copy during the drag, and the copy snaps by the anchor pressed, onto the original too | done | #1104 | | Handles shown are the handles that drag; tolerance from Selection & Anchor Display | done | #494 | -| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Control/Command added mid-drag (mirror the opposite handle), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); #7842: temporary mirroring covers paths, transformed type on a path and blend spines, preserves the anchor mode and the pre-press selection-tool loan, and keeps Alt independent priority; the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again; `crates/engine/tests/direct_handle_mirror.rs`; Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) | +| Drag a handle with Shift (45° about its anchor), Alt (move one handle alone), Control/Command added mid-drag (mirror the opposite handle), Space (ordinary paths: move its anchor and both handles) | done | handles snap to smart guides; handle and anchor drags no longer stall when the pointer leaves and re-enters the window, and a move in the release's frame lands (#834); #7842: temporary mirroring covers paths, transformed type on a path and blend spines, preserves the anchor mode and the pre-press selection-tool loan, and keeps Alt independent priority; the Control/Command press that lends Direct Selection while another tool, such as the Pen, is chosen does not mirror until it is let go and pressed again; `crates/engine/tests/it/direct_handle_mirror.rs`; Space pressed during an ordinary path's handle drag moves its owning anchor and both handles; releasing Space while keeping the mouse down resumes handle adjustment. This also applies while Cmd/Ctrl lends Direct Selection to the Pen, which then continues the same path (#7237, request 3 only) | | Show handles when multiple anchors are selected; Highlight anchors on mouse over; anchor and handle size | done | Preferences › Selection & Anchor Display | | Convert selected anchors to corner/smooth from the Control bar and Properties | done | | | Cut path at selected anchors, Remove Anchor Points, Delete removes segments | done | Open-path anchor Delete removes adjoining segments without bridging the gap; #3380 (deletion only): disconnected survivors of an ordinary contour become independent selected sibling objects, while multi-subpath paths and compound members stay intact; targeted core and full-frame Delete/Backspace regressions pass for survivor selection and Undo/Redo. Explicit Remove Anchor Points keeps its reconnect/refit behavior; #1278: segment Delete preserves neighboring edges and endpoint anchors; a second Delete removes all selected surviving objects; explicit anchor Delete retains its behavior; #1674: Delete removes every selected anchor of a closed path and objects selected whole along with them, and keeps the surviving objects selected; #2241: Remove Anchor Points then selects the next anchor along the path (the one before at an open end), so it can be run again without picking each anchor | @@ -405,7 +405,7 @@ tools, never checked side by side) isn't captured row by row. | Artboard Options › Display: Show Center Mark and Show Cross Hairs ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/modify-display-settings-of-artboards.html)) | done | Per-artboard checkboxes (`artboard.setProps`/`artboard.new` `showCenterMark`, `showCrossHairs`, one undo step); the canvas draws a cross 12 points across on screen at the center and lines from the middle of each side through it, 1 point wide on screen at any zoom and turned with the view; exports and print leave them out; tests `an_artboard_shows_its_center_mark_and_cross_hairs`, `artboard_options_show_center_mark_and_cross_hairs` | | View › Hide Artboards (Ctrl/Cmd+Shift+H) hides the artboards' edges, bleeds, marks and names and shows the whole canvas as paper (white, or Simulate Colored Paper's colour); the Artboard tool still shows them | done | #4038, `canvas::tests::hidden_artboards_leave_a_paper_canvas_without_edges` | | Artboard Options › Display: Show Video Safe Areas and Video Ruler Pixel Aspect Ratio ([public source](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/set-video-display-options-for-artboards.html)) | done | #2849; per artboard (`artboard.setProps`/`artboard.new` `showVideoSafeAreas`, `videoRulerPixelAspectRatio` 0.1–10, default 1; one undo step; native format). The page gives no safe-area numbers: our choice is [EBU R 95](https://tech.ebu.ch/docs/r/r095.pdf)'s, the action-safe area 3.5% and the title-safe area 5% in from each edge, outlined 1 point wide on the canvas and turned with the view; exports and print leave them out. Tests `an_artboard_shows_its_video_safe_areas`, `artboard_options_show_video_display_options`, `artboard_video_display_options_*` | -| Shape tools: Shift constrains, Alt from centre, Space moves while dragging, arrows change sides/points/rows and Ellipse anchors | done | #7840: Ellipse Up/Down changes the remembered Anchors count within 2…1000; four anchors keep a live ellipse, other counts a plain path. Release is one undo step; Escape restores the earlier count unless explicitly updated with `tool.setOption`. `crates/engine/tests/ellipse_drag_anchors.rs` | +| Shape tools: Shift constrains, Alt from centre, Space moves while dragging, arrows change sides/points/rows and Ellipse anchors | done | #7840: Ellipse Up/Down changes the remembered Anchors count within 2…1000; four anchors keep a live ellipse, other counts a plain path. Release is one undo step; Escape restores the earlier count unless explicitly updated with `tool.setOption`. `crates/engine/tests/it/ellipse_drag_anchors.rs` | | Eraser: Shift-drag erases along a horizontal, vertical or diagonal line ([public source](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=82)) | done | the line runs from the press point at the 45° step from the Constrain Angle nearest the pointer, taken once the pointer is 3 screen pixels from the press and kept until Shift is released; the tip outline follows the line; released, the drag goes on freehand from the last point on the line, and Shift again takes a new step from the press point (VectorCraft's own rules); `eraser_shift_keeps_the_stroke_on_a_45_degree_line` in `crates/tools/src/draw2/gesture/tests.rs` | | Polygon/Star exact-size placement remembers the chosen sides/points for later drags and dialog openings; Cancel preserves the previous count | done | Session tool options; existing dialog-opening gestures retained; regression in `toolbar.rs` | | Tool double-click opens its options | done | | From 98026915ab97e38ce28c7eb8c3afca0c5cfe67ee Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 15:26:38 +0100 Subject: [PATCH 237/264] Check the Selection move pointer over source art and document the centre-point modifier --- crates/engine/src/tests/select_effects.rs | 2 +- crates/tools/src/cursors.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/tests/select_effects.rs b/crates/engine/src/tests/select_effects.rs index 055711cb43..07feda9d7c 100644 --- a/crates/engine/src/tests/select_effects.rs +++ b/crates/engine/src/tests/select_effects.rs @@ -235,7 +235,7 @@ fn shift_click_direct_selection_and_hover_on_a_drop_shadow_pass_through_it() { run(&mut s, "select.set", json!({"ids": [a.0]})); let v = ViewInfo::default(); s.select_tool("selection", v).unwrap(); - assert_eq!(s.cursor(Point::new(50.0, 50.0), Mods::default(), v), Cursor::Move); + assert_eq!(s.cursor(Point::new(50.0, 50.0), Mods::default(), v), Cursor::SelectionMove); assert_eq!(s.cursor(Point::new(110.0, 50.0), Mods::default(), v), Cursor::Arrow); assert_eq!(s.cursor(Point::new(92.0, 50.0), Mods::default(), v), Cursor::Arrow); } diff --git a/crates/tools/src/cursors.toml b/crates/tools/src/cursors.toml index fd528eaeef..5528b7cd97 100644 --- a/crates/tools/src/cursors.toml +++ b/crates/tools/src/cursors.toml @@ -133,7 +133,7 @@ look = "Arrow with a small x badge (nothing to select)." id = "SelectionMove" group = "Selection" shown_when = [ - "The Selection tool over a selected object, its movable source artwork, or its visible centre point.", + "The Selection tool over a selected object or its movable source artwork, or over its visible centre point without Cmd/Ctrl held.", "The Selection tool over artwork while Alt is held, before the copy drag begins.", ] hotspot = "The arrow's tip." From 83a8e775d47f0a0bfb693a625badf0fdb7e25d49 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:34:14 -0800 Subject: [PATCH 238/264] Graphics: start on Mesa's software renderer when no adapter can show the window Part of #2654. On Linux and the BSDs, when no graphics adapter could show the window (no wgpu backend started, or the restarts left no adapter), the app ended. It now starts once more with LIBGL_ALWAYS_SOFTWARE=1 and VECTORCRAFT_GPU_SOFTWARE=1 and says in the status bar that it draws on the CPU. When that start also fails, or on Windows and macOS, or with WGPU_BACKEND, WGPU_ADAPTER_NAME or LIBGL_ALWAYS_SOFTWARE set, the error names the backends the driver needs. wgpu draws with Vulkan, OpenGL 3.3 or OpenGL ES 3.0. Intel's Ironlake graphics (8086:0046) has OpenGL 2.1 alone, so the window's surface failed with "Failed to create surface for any enabled backend: {}" before any adapter was listed, and gpu::finish restarted only without an adapter that had been picked. --- apps/vectorcraft/src/gpu.rs | 133 ++++++++++++++++++++++++++---- apps/vectorcraft/src/gpu/tests.rs | 49 +++++++++-- apps/vectorcraft/src/main.rs | 8 +- docs/development.md | 2 + 4 files changed, 169 insertions(+), 23 deletions(-) diff --git a/apps/vectorcraft/src/gpu.rs b/apps/vectorcraft/src/gpu.rs index 198e7dcc85..f71cc434ba 100644 --- a/apps/vectorcraft/src/gpu.rs +++ b/apps/vectorcraft/src/gpu.rs @@ -32,6 +32,12 @@ //! that adapter, as the next one in the order would be tried. Each restart leaves out one more //! adapter, so it ends when none is left. //! +//! When no adapter is picked at all, because none is left or no graphics backend started (wgpu +//! needs Vulkan, OpenGL 3.3 or OpenGL ES 3.0, and the driver of Intel's Ironlake graphics offers +//! none of them, so the window's surface failed "for any enabled backend" with no backend listed, +//! #2654), Linux and the BSDs start once more on Mesa's software renderer ([`Software`]); after +//! that, the error that ends the app says what the graphics driver needs. +//! //! An adapter can also hang instead of failing: on a hybrid laptop with High Performance chosen, //! the discrete GPU never put the window's first frame on the screen, with no error and no panic, //! and the app stayed in the background without a window (#964). [`watch_first_frame`] gives the @@ -853,7 +859,7 @@ pub fn watch_first_frame(startup: Arc) { // The new app records its own start. startup.ended(); skip.push(failed.to_string()); - match restart(&skip.join(",")) { + match restart(&skip.join(","), false) { Ok(()) => std::process::exit(0), Err(e) => { log::error!("starting again failed: {e}"); @@ -950,6 +956,94 @@ fn restart_without<'a>(graphics_failed: bool, frames: u64, picked: Option<&'a st picked.filter(|p| graphics_failed && frames < STARTUP_FRAMES && !skip.iter().any(|s| s == p)) } +/// Whether a start whose window no graphics adapter could show may start again on Mesa's software +/// renderer, which draws OpenGL on the CPU (llvmpipe). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Software { + /// Linux and the BSDs, where Mesa provides OpenGL, and this start isn't on it yet. + Possible, + /// This start already draws on it: the app started again with [`SOFTWARE_ENV`], or the user + /// set `LIBGL_ALWAYS_SOFTWARE`. + Tried, + /// Windows and macOS, or a start that `WGPU_BACKEND` or `WGPU_ADAPTER_NAME` chooses. + Unavailable, +} + +impl Software { + /// This start's [`Software`], from the platform and the environment. + pub fn from_env() -> Self { + if cfg!(any(windows, target_os = "macos")) || explicit_choice() { + Software::Unavailable + } else if software_start() || std::env::var_os("LIBGL_ALWAYS_SOFTWARE").is_some() { + Software::Tried + } else { + Software::Possible + } + } +} + +/// Set by the app when it starts again on Mesa's software renderer because no graphics adapter +/// could show the window (#2654). +pub const SOFTWARE_ENV: &str = "VECTORCRAFT_GPU_SOFTWARE"; + +/// Whether this start is the one the app made on Mesa's software renderer ([`SOFTWARE_ENV`]). +pub fn software_start() -> bool { + std::env::var_os(SOFTWARE_ENV).is_some() +} + +/// The graphics APIs the window can draw with on this platform, for the error that ends the app +/// when no adapter can show it and for the note of a start on Mesa's software renderer. +pub const NEEDS: &str = if cfg!(windows) { + "Direct3D 12, OpenGL 3.3 or OpenGL ES 3.0" +} else if cfg!(target_os = "macos") { + "Metal" +} else { + "Vulkan, OpenGL 3.3 or OpenGL ES 3.0" +}; + +/// What follows the window's run ([`next`]). +#[derive(Debug, PartialEq, Eq)] +enum Next { + /// The window closed normally. + Done, + /// Start again without the adapters in `skip`, on Mesa's software renderer when `software`. + Restart { skip: Vec, software: bool }, + /// End the app with this error. + Stop(String), +} + +/// What follows the window's run: `why` it failed (`None` when it closed normally), whether the +/// graphics failed, the `frames` the UI ran, the adapter `picked`, those left out (`skip`) and +/// whether the software renderer is still to try. A failure on an adapter while starting up starts +/// again without it. When no adapter was picked, because none can show the window or no graphics +/// backend started at all (an old GPU whose driver offers neither Vulkan nor OpenGL 3.3 or OpenGL +/// ES 3.0, such as Intel's Ironlake graphics, #2654), Linux and the BSDs start once more on Mesa's +/// software renderer, and after that the error says what the window needs. +fn next(why: Option, graphics_failed: bool, frames: u64, picked: Option<&str>, mut skip: Vec, software: Software) -> Next { + let Some(why) = why else { return Next::Done }; + if let Some(failed) = restart_without(graphics_failed, frames, picked, &skip) { + log::error!("the window failed on graphics adapter {failed} ({why}): starting again without it"); + skip.push(failed.to_string()); + return Next::Restart { skip, software: false }; + } + if !graphics_failed { + return Next::Stop(why); + } + if picked.is_some() || frames >= STARTUP_FRAMES { + return Next::Stop(format!("{why} ({HELP})")); + } + match software { + Software::Possible => { + log::error!("no graphics adapter could show the window ({why}): starting again on Mesa's software renderer, which draws on the CPU"); + Next::Restart { skip, software: true } + } + Software::Tried => Next::Stop(format!( + "{why}: no graphics adapter could show the window, not even Mesa's software renderer (the graphics driver needs {NEEDS}; {HELP})" + )), + Software::Unavailable => Next::Stop(format!("{why}: no graphics adapter could show the window (the graphics driver needs {NEEDS}; {HELP})")), + } +} + /// After the window's run: `Ok` when it closed normally or the app started again (see the module /// docs), otherwise why it failed. `outcome` is eframe's result, or the message of a panic that /// ended it. @@ -957,28 +1051,35 @@ pub fn finish(outcome: Result, startup: &Startup) -> Res // Whatever follows, this start didn't crash; a new app records its own start. startup.ended(); let (why, graphics_failed) = match outcome { - Ok(Ok(())) => return Ok(()), - Ok(Err(e @ eframe::Error::Wgpu(_))) => (e.to_string(), true), - Ok(Err(e)) => (e.to_string(), false), - Err(panic) => (panic, GRAPHICS_PANIC.load(Ordering::Relaxed)), + Ok(Ok(())) => (None, false), + Ok(Err(e @ eframe::Error::Wgpu(_))) => (Some(e.to_string()), true), + Ok(Err(e)) => (Some(e.to_string()), false), + Err(panic) => (Some(panic), GRAPHICS_PANIC.load(Ordering::Relaxed)), }; let frames = startup.ui.get().map_or(0, egui::Context::cumulative_frame_nr); - let mut skip = skipped(); - let Some(failed) = restart_without(graphics_failed, frames, startup.adapter.get().map(String::as_str), &skip) else { - return Err(if graphics_failed { format!("{why} ({HELP})") } else { why }); - }; - log::error!("the window failed on graphics adapter {failed} ({why}): starting again without it"); - skip.push(failed.to_string()); - restart(&skip.join(",")).map_err(|e| format!("{why}; starting again failed: {e}")) + let picked = startup.adapter.get().map(String::as_str); + match next(why.clone(), graphics_failed, frames, picked, skipped(), Software::from_env()) { + Next::Done => Ok(()), + Next::Stop(e) => Err(e), + Next::Restart { skip, software } => { + let why = why.unwrap_or_default(); + restart(&skip.join(","), software).map_err(|e| format!("{why}; starting again failed: {e}")) + } + } } -/// Start the app again with the same arguments, leaving out the adapters in `skip`. On Unix the -/// new app replaces this process (same process id, so an AppImage keeps its files mounted), and -/// this returns only on failure; on Windows it starts beside this one, which then exits. -fn restart(skip: &str) -> std::io::Result<()> { +/// Start the app again with the same arguments, leaving out the adapters in `skip`, and on Mesa's +/// software renderer when `software` (`LIBGL_ALWAYS_SOFTWARE`, with [`SOFTWARE_ENV`] so it is +/// tried once). On Unix the new app replaces this process (same process id, so an AppImage keeps +/// its files mounted), and this returns only on failure; on Windows it starts beside this one, +/// which then exits. +fn restart(skip: &str, software: bool) -> std::io::Result<()> { log::logger().flush(); let mut c = std::process::Command::new(std::env::current_exe()?); c.args(std::env::args_os().skip(1)).env(SKIP_ENV, skip); + if software { + c.env("LIBGL_ALWAYS_SOFTWARE", "1").env(SOFTWARE_ENV, "1"); + } #[cfg(unix)] { use std::os::unix::process::CommandExt as _; diff --git a/apps/vectorcraft/src/gpu/tests.rs b/apps/vectorcraft/src/gpu/tests.rs index 792518993d..4b660854f6 100644 --- a/apps/vectorcraft/src/gpu/tests.rs +++ b/apps/vectorcraft/src/gpu/tests.rs @@ -602,15 +602,52 @@ fn only_a_graphics_failure_while_starting_up_restarts_without_the_adapter() { fn a_normal_exit_or_another_failure_does_not_restart() { let startup = Startup::default(); assert_eq!(finish(Ok(Ok(())), &startup), Ok(())); - // No adapter was picked (none can show the window): the error is returned, nothing restarts. - let none = eframe::Error::Wgpu(eframe::egui_wgpu::WgpuError::CustomNativeAdapterSelectionError("no graphics adapter can show the window".into())); - assert_eq!( - finish(Ok(Err(none)), &startup), - Err(format!("WGPU error: Adapter selection failed: no graphics adapter can show the window ({HELP})")) - ); let _ = startup.adapter.set("Vulkan:1002:164e".into()); GRAPHICS_PANIC.store(false, Ordering::Relaxed); assert_eq!(finish(Err("a bug".into()), &startup), Err("a bug".into())); + // The same, decided without starting anything. + let amd = Some("Vulkan:1002:164e"); + for software in [Software::Possible, Software::Tried, Software::Unavailable] { + assert_eq!(next(None, false, 0, amd, vec![], software), Next::Done); + assert_eq!(next(Some("a bug".into()), false, 0, None, vec![], software), Next::Stop("a bug".into())); + // A failure after start-up, or on an adapter already left out, is not the start's. + assert_eq!(next(Some("lost".into()), true, STARTUP_FRAMES, amd, vec![], software), Next::Stop(format!("lost ({HELP})"))); + let skip = vec!["Vulkan:1002:164e".to_string()]; + assert_eq!(next(Some("lost".into()), true, 0, amd, skip, software), Next::Stop(format!("lost ({HELP})"))); + } + // An adapter that failed while starting up is left out, never with the software renderer. + assert_eq!( + next(Some("lost".into()), true, 0, amd, vec!["Gl:8086:0046".into()], Software::Possible), + Next::Restart { skip: vec!["Gl:8086:0046".into(), "Vulkan:1002:164e".into()], software: false } + ); +} + +/// #2654: on a ThinkPad T510 with Intel's Ironlake graphics, whose driver offers neither Vulkan +/// nor OpenGL 3.3 or OpenGL ES 3.0, wgpu started no backend, so the window's surface failed before +/// any adapter was listed and the app ended; started with `LIBGL_ALWAYS_SOFTWARE=1`, it ran on +/// llvmpipe. With no adapter picked, Linux starts once more on Mesa's software renderer, keeping +/// the adapters already left out, and the error after that says what the driver needs. +#[test] +fn a_start_no_adapter_can_show_tries_the_software_renderer_once() { + let surface = "WGPU error: Failed to create surface for any enabled backend: {}"; + let skip = vec!["Vulkan:8086:0046".to_string()]; + assert_eq!(next(Some(surface.into()), true, 0, None, skip.clone(), Software::Possible), Next::Restart { skip: skip.clone(), software: true }); + // No adapter left that can show the window, after restarts without each. + let none = "WGPU error: Adapter selection failed: no graphics adapter can show the window"; + assert_eq!(next(Some(none.into()), true, 0, None, skip.clone(), Software::Possible), Next::Restart { skip: skip.clone(), software: true }); + // Already on the software renderer: the app ends, saying what the window needs. + let Next::Stop(tried) = next(Some(surface.into()), true, 0, None, skip.clone(), Software::Tried) else { + panic!("a start already on the software renderer starts again") + }; + assert!(tried.starts_with(surface), "{tried}"); + assert!(tried.contains("not even Mesa's software renderer") && tried.contains(NEEDS) && tried.contains(HELP), "{tried}"); + // Windows, macOS or a backend the user chose: no software renderer to start on. + let Next::Stop(unavailable) = next(Some(surface.into()), true, 0, None, skip, Software::Unavailable) else { + panic!("a start without the software renderer starts again") + }; + assert!(unavailable.contains(NEEDS) && unavailable.contains(HELP) && !unavailable.contains("Mesa"), "{unavailable}"); + // A failure outside the graphics never starts again. + assert_eq!(next(Some("a bug".into()), false, 0, None, vec![], Software::Possible), Next::Stop("a bug".into())); } /// A log folder of its own for each test. diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 6ab6778597..b34c3c23d9 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -920,7 +920,13 @@ fn main() -> std::process::ExitCode { let summary = adapter_summary(&rs.adapter.get_info()); log::info!("rendering with {summary} (power preference {power:?})"); created.created(&cc.egui_ctx); - if !gpu::skipped().is_empty() { + if gpu::software_start() { + // No graphics processor could show the window, so Mesa draws it on the CPU (#2654). + app.status(format!( + "No graphics processor could show the window, so VectorCraft started again on {summary}, which draws on the CPU and is slower. Showing it on the graphics processor needs a driver with {}", + gpu::NEEDS + )); + } else if !gpu::skipped().is_empty() { // A processor chosen in Settings can be the one that can't show the window. if chosen_gpu { app.status(format!( diff --git a/docs/development.md b/docs/development.md index 5a1b6efd95..3a1f06fd39 100644 --- a/docs/development.md +++ b/docs/development.md @@ -74,6 +74,7 @@ The canvas is rasterized on the CPU (`vectorcraft-render`, vello_cpu); the GPU ( - **Automatic on Linux and the BSDs** is the GPU that drives the panel or a monitor, then the system's order: Mesa's Vulkan device-select layer puts the GPU the desktop runs on first (the integrated one on hybrid laptops; `DRI_PRIME` and `MESA_VK_DEVICE_SELECT` steer it). A Wayland compositor may not accept frames from another GPU: on a desktop whose compositor ran on an NVIDIA GPU, rendering on the Ryzen's integrated GPU made KWin end the window's connection ("importing the supplied dmabufs failed") and 0.5.0 crashed at startup (#502). - 0.5.0 saved `powerSaving`, its default, for everyone; it reads as `automatic`. - **If the window fails on its adapter while starting up** (an error from wgpu, or a panic inside wgpu or egui-wgpu during the first frames), the app starts again without that adapter and tries the next one, telling which in the status bar; the run that failed keeps its log as `vectorcraft.1.log`. On Unix the new app replaces the process (an AppImage stays mounted); on Windows it starts beside it. Adapters are told apart by backend and PCI ids, or by name where the backend reports no ids (Metal lists every GPU of a dual-GPU Mac as `0000:0000`, #651). The adapters left out travel in `VECTORCRAFT_GPU_SKIP` (`backend:vendor:device`, such as `Vulkan:1002:164e`), one more on each restart, so the restarts end. When no adapter is left, the app logs why and exits with an error instead of panicking. +- **If no graphics adapter can show the window at all** on Linux or a BSD, the app starts once more on Mesa's software renderer (llvmpipe, through `LIBGL_ALWAYS_SOFTWARE=1`), which draws on the CPU and is slower, and says so in the status bar. That covers every adapter left out by the restarts above, and a GPU whose driver offers none of the backends wgpu draws with: Vulkan, OpenGL 3.3 or OpenGL ES 3.0. Intel's Ironlake graphics (PCI id `8086:0046`, in a ThinkPad T510) has OpenGL 2.1 alone, so wgpu started no backend and the window failed with `Failed to create surface for any enabled backend: {}` (#2654). The software start carries `VECTORCRAFT_GPU_SOFTWARE`, so it happens once; when it fails too, or when `WGPU_BACKEND`, `WGPU_ADAPTER_NAME` or `LIBGL_ALWAYS_SOFTWARE` is set, the app exits with an error that names the backends the driver needs. On a laptop with a second GPU, choosing that GPU in the firmware settings may give a driver with one of these backends. - **If the window's first frame never reaches the screen** within 20 seconds of the app being created (the files named at the start opened), the adapter counts as hanging and the app starts again without it in the same way (#964: High Performance on a hybrid laptop left the app running in the background with no window and nothing in the log). A window minimized at the start isn't counted. When the processor that hung was chosen in Preferences, the status bar points to Automatic. - **If the app crashes while the window starts**, as when Intel's Direct3D 12 driver (`igd12umd64.dll`) ended 0.9.0 before its window appeared on an Intel UHD Graphics 605 (#2243), no code in the process runs to start it again, so the next start leaves the adapter out. Each start writes `graphics-start.json` in the log folder before the graphics start and adds the adapter once one is picked; when the first frame reaches the screen or the app ends without crashing, the start is cleared from the file. A start that finds an earlier start still recorded there logs the adapter, leaves it out and shows a note in the status bar. When the crash came while the adapters were being listed (wgpu's Direct3D 12 backend creates a device on each GPU to list it), the next start lists OpenGL's adapters alone; on macOS, where wgpu has no OpenGL adapters, it lists them all. Later starts keep leaving them out until the app version or Preferences › Performance › Graphics Processor changes, a start shows its first frame on the adapter that crashed, or no adapter is left that can show the window. `WGPU_BACKEND` and `WGPU_ADAPTER_NAME` choose regardless of the file: a start with `WGPU_BACKEND=dx12` tries Direct3D 12 again, and when its first frame appears, the crash is cleared. A process ended from outside during the start (Task Manager, `kill`) counts as a crash. Runs without preferences (`VECTORCRAFT_NO_PREFS`) record nothing, and a start made while another copy of the app is starting neither reads nor writes the file. - **To recover from a Graphics Processor choice that doesn't work** without editing files: start once with `WGPU_POWER_PREF=low` (or `WGPU_ADAPTER_NAME=…`), which overrides the preference for that start while settings still save, and set Graphics Processor back to Automatic. `VECTORCRAFT_NO_PREFS=1` also starts without it, but saves nothing. @@ -109,6 +110,7 @@ When the interface thread stays in one part of a frame for 3 s (VectorCraft's ow | `WGPU_ADAPTER_NAME` | Graphics adapter by (part of) its name, any case (see [Desktop graphics processor](#desktop-graphics-processor)) | | `WGPU_BACKEND` | Graphics backends: `vulkan`, `dx12`, `metal`, `gl` | | `VECTORCRAFT_GPU_SKIP` | Set by the app when it starts again without a graphics adapter that failed (see [Desktop graphics processor](#desktop-graphics-processor)) | +| `VECTORCRAFT_GPU_SOFTWARE` | Set by the app, with `LIBGL_ALWAYS_SOFTWARE=1`, when it starts again on Mesa's software renderer because no graphics adapter could show the window (Linux and the BSDs; see [Desktop graphics processor](#desktop-graphics-processor)) | | `RUST_LOG` | Log levels for standard error and the log file (see [Logs](#logs)) | ## macOS: the menu bar From a6c530518a3d8acdbb4496075cd3b75e0995a47d Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 15:35:56 +0100 Subject: [PATCH 239/264] Scroll overflowing panel forms inside their dock group --- crates/ui-egui/src/dock.rs | 12 +++++++++++- crates/ui-egui/src/panels/pattern_options.rs | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index fdaaebcee1..6a70094ac2 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -1,6 +1,8 @@ //! Panel bodies: what the dock area ([`crate::panel_docking`]) draws inside a docked, floating or //! flyout panel. +use craft::ui::contract::{Props as _, Scroll, ShowContainer as _}; +use craft::ui::layout_components::Stack; use egui::Ui; use crate::state::DockTab; @@ -13,6 +15,14 @@ pub(crate) fn panel_body(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { Some(DockTab::Properties) => panels::properties::show(app, ui), Some(DockTab::Layers) => panels::layers::show(app, ui), Some(DockTab::Libraries) => panels::libraries(app, ui), - None => panels::show_icon_panel(app, ui, id), + None => { + // The dock clips the group at its assigned height. Keep the panel's own collection + // viewport bounded while allowing a form that exceeds that height to scroll. + let height = ui.available_height(); + Stack::new().id_salt(id).fill().scroll(Scroll::vertical()).show(ui, |ui, _| { + ui.set_max_height(height); + panels::show_icon_panel(app, ui, id); + }); + } } } diff --git a/crates/ui-egui/src/panels/pattern_options.rs b/crates/ui-egui/src/panels/pattern_options.rs index 93e93681f2..0bd03fac9c 100644 --- a/crates/ui-egui/src/panels/pattern_options.rs +++ b/crates/ui-egui/src/panels/pattern_options.rs @@ -267,6 +267,26 @@ mod tests { Panel::new(app, show) } + #[test] + fn scrolling_a_short_docked_form_reaches_its_last_action() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + app.run("object.pattern.make", json!({"name": "Dots"})).unwrap(); + let mut panel = Panel::new(app, |app, ui| crate::dock::panel_body(app, ui, "patternOptions")); + panel.room(egui::vec2(300.0, 200.0)); + panel.frame(); + panel.frame(); + assert!(!panel.in_view("Done")); + for _ in 0..20 { + panel.scroll_at(egui::pos2(150.0, 100.0), -120.0); + panel.frame(); + } + assert!(panel.in_view("Done")); + panel.click("Done"); + assert!(editing(&panel.app()).is_none()); + } + /// Shift+Enter in the Name field renames the pattern and keeps the field active; Enter then /// renames it again and ends the editing. #[test] From 49344097e40c724d9c5c21fe9a1cd6664f067601 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:39:42 -0800 Subject: [PATCH 240/264] Docs: keep the original preflight test command in the 2026-11-18 record The 2026-11-18 validation ran when preflight was its own test binary, so the record keeps `--test preflight`. A separate line gives the current command, `--test it preflight::`. --- docs/production-preflight.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/production-preflight.md b/docs/production-preflight.md index 77698662d8..cc84d2ef59 100644 --- a/docs/production-preflight.md +++ b/docs/production-preflight.md @@ -52,7 +52,7 @@ The same read-only report is available through `document.preflight`; see [MCP](m Checked on Windows with Rust 1.99.1, based on `main` at `36b5a5920c`: -- Engine integration tests: 9 passed (`cargo test -p vectorcraft-engine --test it preflight::`). +- Engine integration tests: 9 passed (`cargo test -p vectorcraft-engine --test preflight`). - Panel tests: 5 passed (`cargo test -p vectorcraft-ui-egui --lib preflight`), including pointer selection/zoom, edits and Undo, document switching, external-file polling and explicit Recheck. - Both test commands used `--offline --target-dir target --config profile.test.opt-level=0`. @@ -77,6 +77,9 @@ WebAssembly Clippy run also encounters existing target-specific lints in unchang (`drop_non_drop`) and `font_menu.rs` (`unnecessary_lazy_evaluations`); the WebAssembly typecheck and the native Clippy run above pass without source changes for those findings. +The engine preflight tests now live in the `it` test binary. Run them with +`cargo test -p vectorcraft-engine --test it preflight::`. + ### Review follow-up on `main` at `ee60c51fd` The exact-threshold and locked-artboard regressions were first run against the original From 5321337ce845efb5bef7834388b1d01bcb145742 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:42:57 -0800 Subject: [PATCH 241/264] Open: say when a file dialog is already open instead of waiting silently On some Wayland compositors the system file dialog can open as its own window out of sight. Pressing Open again on the Home screen then queued a second picker behind the first and showed nothing, so Open seemed to do nothing at all (#6160). - File > Open, Open With and Install Plug-in refuse a new picker while a file dialog is still open and say so in the status bar. - The Home screen's New, Open, template and Clear Recent buttons report a failed command in the status bar instead of dropping it. - An open picker that fails (the browser could not read the file) says why instead of being taken for a cancel. Part of #6160 --- crates/ui-egui/src/canvas/home.rs | 15 ++++++++++----- crates/ui-egui/src/io/open.rs | 9 ++++++++- crates/ui-egui/src/tests/home.rs | 20 ++++++++++++++++++++ crates/ui-egui/src/tests/picks.rs | 25 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/canvas/home.rs b/crates/ui-egui/src/canvas/home.rs index d95cdc02e1..5034e23f17 100644 --- a/crates/ui-egui/src/canvas/home.rs +++ b/crates/ui-egui/src/canvas/home.rs @@ -73,15 +73,20 @@ pub(super) fn home(app: &mut VectorcraftApp, ui: &mut Ui, rect: egui::Rect) { } } -/// What the start screen's user did. +/// What the start screen's user did. A command that fails says why in the status bar (#6160). fn run_action(app: &mut VectorcraftApp, action: StartAction) { + fn run(app: &mut VectorcraftApp, id: &str, params: serde_json::Value) { + if let Err(e) = app.run(id, params) { + app.status(e); + } + } match action { - StartAction::New => drop(app.run("file.newDialog", json!({}))), - StartAction::Open => drop(app.run("file.open", json!({}))), + StartAction::New => run(app, "file.newDialog", json!({})), + StartAction::Open => run(app, "file.open", json!({})), // A failure is reported to the user there. StartAction::OpenRecent(path) => drop(crate::io::open_reporting(app, &path.to_string_lossy())), - StartAction::UseTemplate(name) => drop(app.run("file.new", json!({ "preset": name }))), - StartAction::ClearRecent => drop(app.run("file.clearRecent", json!({}))), + StartAction::UseTemplate(name) => run(app, "file.new", json!({ "preset": name })), + StartAction::ClearRecent => run(app, "file.clearRecent", json!({})), StartAction::RemoveRecent(path) => app.ui.recent_files.retain(|recent| std::path::Path::new(recent) != path), StartAction::RevealRecent(path) => { // PLAN: `io::export` is a private module of `io`; `reveal_path` needs a re-export from io.rs (unowned). diff --git a/crates/ui-egui/src/io/open.rs b/crates/ui-egui/src/io/open.rs index 673f78af10..e5c59365b1 100644 --- a/crates/ui-egui/src/io/open.rs +++ b/crates/ui-egui/src/io/open.rs @@ -233,13 +233,19 @@ fn open_request<'a>(purpose: &str, folder: Option, filters: impl IntoIte /// Asks for a file to open with `request`; `then` gets its path. The web answers with the file's /// bytes, which open as File › Open opens them (the extension decides). A cancelled picker runs -/// nothing. While it is open the reply is `{pending: "fileDialog"}`. +/// nothing, and a picker that failed (the browser could not read the file) reports why. While it is +/// open the reply is `{pending: "fileDialog"}`. While another file dialog is still open, which can +/// be a window the system placed out of sight, the reply is an error saying so (#6160): a second +/// picker would only wait behind the first. fn ask_open( app: &mut VectorcraftApp, request: PickRequest, owner: Owner, then: impl FnOnce(&mut VectorcraftApp, String) -> Result + 'static, ) -> Result { + if app.file_dialog_open() { + return Err(file_asks::busy().into()); + } Ok(file_asks::ask(app, request, owner, move |app, picked| match picked { Picked::Contents(files) => { for (name, bytes) in &files { @@ -247,6 +253,7 @@ fn ask_open( } Ok(Value::Null) } + Picked::Failed(error) => Err(error), picked => match picked.first_path() { Some(path) => then(app, path.to_string_lossy().into_owned()), None => Err("cancelled".into()), diff --git a/crates/ui-egui/src/tests/home.rs b/crates/ui-egui/src/tests/home.rs index 5ccb6412a9..904de40932 100644 --- a/crates/ui-egui/src/tests/home.rs +++ b/crates/ui-egui/src/tests/home.rs @@ -125,6 +125,26 @@ fn home_screen(app: VectorcraftApp) -> Panel { home } +/// Home's Open while a file dialog is still open (a window the system may have placed out of sight) +/// says so in the status bar and asks for no second picker; once the first answers, Open asks again +/// (#6160). +#[test] +fn home_open_while_a_file_dialog_is_open_says_so() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let picker = crate::tests::picks::scripted(&mut app); + let mut home = home_screen(app); + home.click("Open"); + assert_eq!(picker.requests().len(), 1); + assert!(home.app().ui.status.is_empty()); + home.click("Open"); + assert_eq!(picker.requests().len(), 1, "no second picker waits behind the first"); + assert_eq!(home.app().ui.status, crate::file_asks::busy()); + picker.cancel(); + crate::file_asks::poll(&mut home.app()); + home.click("Open"); + assert_eq!(picker.requests().len(), 2, "Open asks again once the first dialog answered"); +} + /// The Home screen lists the first recent files (#663); opening one that can't be opened says so. #[test] fn home_lists_recent_files_and_a_click_opens_one() { diff --git a/crates/ui-egui/src/tests/picks.rs b/crates/ui-egui/src/tests/picks.rs index 851d438904..1d521af1c0 100644 --- a/crates/ui-egui/src/tests/picks.rs +++ b/crates/ui-egui/src/tests/picks.rs @@ -49,6 +49,10 @@ impl Picker { pub(crate) fn cancel(&self) { self.files.answer(Picked::Cancelled); } + /// The newest open pick fails with `why`, as the browser's picker does when it cannot read the file. + pub(crate) fn fail(&self, why: &str) { + self.files.answer(Picked::Failed(why.into())); + } /// The bytes a save through the service (`Files::save`) wrote to `path`. pub(crate) fn file(&self, path: &str) -> Option> { self.files.file(std::path::Path::new(path)) @@ -197,6 +201,27 @@ fn app() -> VectorcraftApp { VectorcraftApp::new(Session::new(), Services::default()) } +/// File › Open and Install Plug-in ask for no second picker while a file dialog is still open, and +/// say so; an open picker that fails says why, and opens nothing (#6160). +#[test] +fn an_open_picker_is_refused_while_a_dialog_is_open_and_a_failed_one_says_why() { + for command in ["file.open", "ui.installPlugin"] { + let mut app = app(); + let picker = scripted(&mut app); + asks(&mut app, command); + for again in ["file.open", "ui.installPlugin"] { + assert_eq!(app.run(again, json!({})), Err(file_asks::busy().to_string()), "{again} after {command}"); + } + assert_eq!(picker.requests().len(), 1, "no second picker waits behind the first after {command}"); + picker.fail("the file could not be read"); + settle(&mut app); + assert_eq!(app.ui.status, "the file could not be read", "{command}"); + assert!(app.session.documents().is_empty(), "{command}"); + asks(&mut app, command); + assert_eq!(picker.requests().len(), 2, "{command} asks again once the first answered"); + } +} + /// The picks' answers, then the rest of a frame's pumps (Save Changes goes on once its save is written). fn settle(app: &mut VectorcraftApp) { let ctx = app.ui_ctx.clone().unwrap_or_default(); From 1cb4193974223fb394e250c63b3bf2f19dc907c1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:48:25 -0800 Subject: [PATCH 242/264] Fix #6192: Curvature, a point dragged far out narrows toward it Dragging a point of a selected path with the Curvature tool gave the point the handles of the circle through it and its neighbors, while the neighbors kept their own tangents. Stretching a circle's top point far up made those handles reach well past the circle's sides, so the shape swung out wider than the circle before it narrowed toward the point. Each handle of the moved point is now no longer than the handle of the circular arc tangent to it and to the neighbor's handle on that segment. Where the neighbor is on the circle the tool follows, that arc is the circle and the handles do not change. The shortening fades out as the two handle lines meet near the neighbor or turn parallel, so the handles change continuously during a drag. --- crates/tools/src/draw2/curvature.rs | 48 +++++++++++- crates/tools/src/draw2/curvature/tests.rs | 92 +++++++++++++++++++++++ 2 files changed, 138 insertions(+), 2 deletions(-) diff --git a/crates/tools/src/draw2/curvature.rs b/crates/tools/src/draw2/curvature.rs index 06ad1c1230..e4c15c4784 100644 --- a/crates/tools/src/draw2/curvature.rs +++ b/crates/tools/src/draw2/curvature.rs @@ -136,7 +136,9 @@ fn neighbours(sp: &SubPath, i: usize) -> [Option; 2] { /// Move anchor `i` of `sp` to `q` as the Curvature tool drags a point: only the two segments at it /// change. A smooth anchor takes the Curvature tool's own handles ([`smooth_handles`]: along the /// circle through it and its neighbours; at an end of an open path the one [`end_handle`] into the -/// curve). The neighbours' handles on those segments, and a corner's own +/// curve), each no longer than [`fit_to_tangent`] allows against the neighbor's handle on its +/// segment, so a point dragged far out narrows toward it instead of swinging wide around that +/// circle (#6192). The neighbors' handles on those segments, and a corner's own /// handles, keep their directions, their lengths scaling with their segment's chord, so the /// segments beyond don't move and a corner without handles keeps none. /// @@ -163,7 +165,7 @@ pub fn curvature_move(sp: &mut SubPath, i: usize, q: Point) -> bool { match ends { [Some(prev), Some(next)] => { if let Some((h_in, h_out)) = smooth_handles(prev.p, q, next.p) { - (m.h_in, m.h_out) = (h_in, h_out); + (m.h_in, m.h_out) = (fit_to_tangent(q, h_in, prev.p, prev.h_out), fit_to_tangent(q, h_out, next.p, next.h_in)); } } // An end of an open path has one segment: its handle only, and a corner like the @@ -179,6 +181,48 @@ pub fn curvature_move(sp: &mut SubPath, i: usize, q: Point) -> bool { true } +/// cos 75°: [`fit_to_tangent`] shortens a handle in full up to a turn of 150°, and less toward a +/// half turn. +const FADE_HALF_TURN: f64 = 0.258_819_045_102_520_8; + +/// Handle `h` of the point `q` on its segment to `b`, whose handle there is `hb`, shortened toward +/// the handle of the circular arc tangent to both handle lines: `2/3 · (1 − tan²(θ/4))` of `q`'s +/// distance `r` to where the lines meet, `θ` the turn between them. A longer handle swings the +/// segment out past `b`'s tangent line. The shortening applies in full while the lines meet at +/// least half the chord ahead of `b` and the turn is at most 150°, and fades to none as the meeting +/// point comes back to `b` or the turn nears a half turn, so the handle changes continuously as `q` +/// moves. Where `b` is on the circle [`smooth_handles`] +/// follows, the arc is the circle's and `h` is unchanged; `h` is also unchanged when `b` has no +/// handle there or the lines are parallel. +fn fit_to_tangent(q: Point, h: Point, b: Point, hb: Point) -> Point { + let (d, t) = (h - q, hb - b); + let (ld, lt) = (d.hypot(), t.hypot()); + let w = b - q; + let chord = w.hypot(); + if !(ld > 1e-9 && lt > 1e-9 && chord > 1e-9) { + return h; + } + let (d, t) = (d / ld, t / lt); + let den = d.cross(t); + if den.abs() <= 1e-12 { + return h; + } + // q + r·d = b + s·t. + let (r, s) = (w.cross(t) / den, w.cross(d) / den); + // The curve leaves `b` along `t` and comes into `q` along −d. + let cos_half = ((1.0 - t.dot(d)) / 2.0).clamp(0.0, 1.0).sqrt(); + // A circular arc under a half turn meets its tangents at least half its chord out. Toward a + // half turn the lines meet ever further away, on one side or the other, and the shortening + // fades out. + let weight = (2.0 * s / chord).clamp(0.0, 1.0) * (cos_half / FADE_HALF_TURN).min(1.0); + let tan2 = (1.0 - cos_half) / (1.0 + cos_half); + let cap = 2.0 / 3.0 * (1.0 - tan2) * r.abs(); + if !(weight > 0.0 && cap.is_finite() && ld > cap) { + return h; + } + q + d * (ld + (cap - ld) * weight) +} + /// Add a smooth anchor at `t` on segment `seg` of `sp` without changing its shape: the new anchor's /// index. On a straight segment its handles lie along it, each a third of its own part of the /// segment ([`curvature_smooth`]: a line is a circle's limit), so a drag bends the line evenly; a drag then moves it as a diff --git a/crates/tools/src/draw2/curvature/tests.rs b/crates/tools/src/draw2/curvature/tests.rs index 50ef2281d1..f59e0ed77b 100644 --- a/crates/tools/src/draw2/curvature/tests.rs +++ b/crates/tools/src/draw2/curvature/tests.rs @@ -139,6 +139,98 @@ fn moving_a_corner_without_handles_keeps_its_sides_straight() { assert_eq!(sp.anchors[0], Anchor::corner(pt(80.0, 70.0))); } +/// A circle's top point dragged far up stretches it into a shape that narrows from its sides +/// toward the point (#6192), instead of swinging out wider than the circle first. The moved point +/// stays smooth, and its segments meet the neighbors' unchanged tangents. +#[test] +fn stretching_a_circle_narrows_toward_the_dragged_point() { + let k = 100.0 * 0.552_284_749_830_793_4; + let circle = SubPath::new( + vec![ + Anchor::with_handles(pt(0.0, -100.0), pt(-k, -100.0), pt(k, -100.0)), + Anchor::with_handles(pt(100.0, 0.0), pt(100.0, -k), pt(100.0, k)), + Anchor::with_handles(pt(0.0, 100.0), pt(k, 100.0), pt(-k, 100.0)), + Anchor::with_handles(pt(-100.0, 0.0), pt(-100.0, k), pt(-100.0, -k)), + ], + true, + ); + // On the circle, the neighbors' tangents match it, and the point keeps the circle's handles. + let mut near = circle.clone(); + assert!(curvature_move(&mut near, 0, pt(0.0, -100.0))); + for (a, b) in near.anchors.iter().zip(&circle.anchors) { + assert!(a.h_in.distance(b.h_in) < 1e-6 && a.h_out.distance(b.h_out) < 1e-6, "{a:?} != {b:?}"); + } + for top in [-150.0, -250.0, -400.0, -800.0] { + let mut sp = circle.clone(); + assert!(curvature_move(&mut sp, 0, pt(0.0, top))); + let a = sp.anchors[0]; + assert_eq!(a.kind, AnchorKind::Smooth); + assert!(collinear(a.h_in - a.p, a.h_out - a.p) && (a.h_in - a.p).dot(a.h_out - a.p) < 0.0); + // Segment 0 runs from the top to the right point, segment 3 from the left point to the top. + for (seg, side) in [(0, 1.0), (3, -1.0)] { + let c = sp.segment(seg); + let mut last: Option = None; + for j in 0..=200 { + let t = j as f64 / 200.0; + let p = c.eval(if side > 0.0 { t } else { 1.0 - t }); + assert!(p.x.abs() <= 100.0 + 1e-9, "top {top}: segment {seg} swings out to x = {}", p.x); + // From the top down to the side the width only grows. + if let Some(l) = last { + assert!(p.x.abs() >= l - 1e-9, "top {top}: segment {seg} narrows again at t = {t}"); + } + last = Some(p.x.abs()); + } + } + } +} + +/// The moved point's handles change continuously while it crosses a neighbor's tangent line, while +/// the line its own handle runs along passes through the neighbor, and while the two lines turn +/// parallel. +#[test] +fn a_moved_point_s_handles_change_continuously() { + let handles = |sp: &SubPath, q: Point| -> (Vec2, Vec2) { + let mut sp = sp.clone(); + assert!(curvature_move(&mut sp, 1, q)); + (sp.anchors[1].h_in - q, sp.anchors[1].h_out - q) + }; + let near = |a: (Vec2, Vec2), b: (Vec2, Vec2)| (a.0 - b.0).hypot() < 0.05 && (a.1 - b.1).hypot() < 0.05; + // The neighbor's handle points away from the moved point: its line passes through it at y = 0. + let away = SubPath::new( + vec![ + Anchor::corner(pt(-100.0, 0.0)), + Anchor::with_handles(pt(0.0, -20.0), pt(-30.0, -20.0), pt(30.0, -20.0)), + Anchor::with_handles(pt(100.0, 0.0), pt(200.0, 10.0), pt(0.0, -10.0)), + ], + false, + ); + assert!(near(handles(&away, pt(0.0, -0.001)), handles(&away, pt(0.0, 0.001)))); + // The neighbor's handle runs the same way as the moved point's: their lines are parallel at x = 0. + let parallel = SubPath::new( + vec![ + Anchor::corner(pt(-100.0, 0.0)), + Anchor::with_handles(pt(0.0, -50.0), pt(-30.0, -50.0), pt(30.0, -50.0)), + Anchor::with_handles(pt(100.0, 0.0), pt(150.0, 0.0), pt(50.0, 0.0)), + ], + false, + ); + assert!(near(handles(¶llel, pt(-0.001, -50.0)), handles(¶llel, pt(0.001, -50.0)))); + // A circle's top dragged across the right point's tangent line, x = 100. + let k = 100.0 * 0.552_284_749_830_793_4; + let circle = SubPath::new( + vec![ + Anchor::with_handles(pt(-100.0, 0.0), pt(-100.0, k), pt(-100.0, -k)), + Anchor::with_handles(pt(0.0, -100.0), pt(-k, -100.0), pt(k, -100.0)), + Anchor::with_handles(pt(100.0, 0.0), pt(100.0, -k), pt(100.0, k)), + Anchor::with_handles(pt(0.0, 100.0), pt(k, 100.0), pt(-k, 100.0)), + ], + true, + ); + for y in [-150.0, -300.0] { + assert!(near(handles(&circle, pt(99.999, y)), handles(&circle, pt(100.001, y))), "y {y}"); + } +} + #[test] fn going_on_from_an_end_keeps_the_old_segments() { let before = wave(); From 0b3cf56b81e34da4fcbe87566043f4bee16615bb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:59:34 -0800 Subject: [PATCH 243/264] Graphics: closing the window after a lost device no longer panics After the graphics device is lost, a frame the device could not present stays acquired by the window's surface. When the window closed, eframe released the surface, and wgpu's Vulkan backend panicked with "Trying to destroy a SwapchainAcquireSemaphore that is still in use by a SurfaceTexture" (gfx-rs/wgpu#9277), so the app stopped with an error. GraphicsLoss now remembers that a loss happened after the frame handled the report. When the window closes after a loss, the process ends in on_exit once the app has saved what it keeps on quitting, before the window's graphics are torn down, on every platform. This is the exit the macOS accessibility quit already takes (#661); a loss during start-up still goes to the adapter restart (#651). Fixes #6374 --- apps/vectorcraft/src/app.rs | 62 ++++++++++++++++++++++++++++------ crates/ui-egui/src/graphics.rs | 39 +++++++++++++++++++-- 2 files changed, 88 insertions(+), 13 deletions(-) diff --git a/apps/vectorcraft/src/app.rs b/apps/vectorcraft/src/app.rs index b91282e7da..791143bb42 100644 --- a/apps/vectorcraft/src/app.rs +++ b/apps/vectorcraft/src/app.rs @@ -1,4 +1,4 @@ -#[cfg(all(target_os = "macos", feature = "accessibility", feature = "wgpu"))] +#[cfg(feature = "wgpu")] use super::gpu; use super::nightly_session; use super::prefs::{flush, save_tick}; @@ -107,7 +107,7 @@ impl eframe::App for App { // Plug-ins still loading end before the launch marker does (the macOS exit below skips // dropping the app). self.app.session.cancel_plugin_loads(); - end_before_teardown(self.frames); + end_before_teardown(self.frames, self.graphics_loss.happened()); } } @@ -202,16 +202,58 @@ impl App { /// its own class, which AppKit's Touch Bar support was observing it under, and AppKit aborts the /// app as it quits on Macs with a Touch Bar. On a normal quit, only the launch marker is needed /// after the window, so it is ended here as `main` ends it after the window on other platforms. +/// On every platform, the process also ends here when the window's graphics device was lost +/// (`device_lost`, #6374). A frame the lost device could not present stays acquired, and releasing +/// the window's surface as eframe tears it down then panics in wgpu (gfx-rs/wgpu#9277). /// Not while the window is still starting up (`frames` below [`gpu::STARTUP_FRAMES`]): a graphics /// failure then starts the app again on another adapter (#651). -#[allow(unused_variables)] -fn end_before_teardown(frames: u64) { - #[cfg(all(target_os = "macos", feature = "accessibility", feature = "wgpu"))] - if frames >= gpu::STARTUP_FRAMES { - safe_mode::end_launch(); - log::info!("quitting"); - log::logger().flush(); - std::process::exit(0); +fn end_before_teardown(frames: u64, device_lost: bool) { + if !ends_before_teardown(frames, device_lost) { + return; + } + if device_lost { + log::info!("the graphics device was lost: quitting before the window's graphics are torn down"); + } + // `main` does these after the window, which this exit skips. + #[cfg(not(target_os = "macos"))] + single_instance::resign(); + safe_mode::end_launch(); + log::info!("quitting"); + log::logger().flush(); + std::process::exit(0); +} + +/// Whether [`end_before_teardown`] ends the process: after the window's start-up, on macOS with +/// accessibility, or once the graphics device was lost. +#[cfg(feature = "wgpu")] +fn ends_before_teardown(frames: u64, device_lost: bool) -> bool { + frames >= gpu::STARTUP_FRAMES && (device_lost || cfg!(all(target_os = "macos", feature = "accessibility"))) +} + +/// Without wgpu there is no device-lost report, and the window is torn down as usual. +#[cfg(not(feature = "wgpu"))] +fn ends_before_teardown(_frames: u64, _device_lost: bool) -> bool { + false +} + +#[cfg(all(test, feature = "wgpu"))] +mod tests { + use vectorcraft_ui_egui::graphics::GraphicsLoss; + + use super::*; + + /// A device lost while the app runs ends the process before eframe releases the window's + /// surface, on every platform; before the window has started, the start-up restart takes over. + #[test] + fn a_lost_graphics_device_ends_the_process_before_teardown() { + let always = cfg!(all(target_os = "macos", feature = "accessibility")); + let (loss, ctx) = (GraphicsLoss::default(), egui::Context::default()); + assert_eq!(ends_before_teardown(gpu::STARTUP_FRAMES, loss.happened()), always, "no loss: the usual teardown"); + let (l, c) = (loss.clone(), ctx.clone()); + std::thread::spawn(move || l.report(&c, "Unknown: Device is lost")).join().unwrap(); + assert!(loss.take().is_some(), "a frame handles the report"); + assert!(ends_before_teardown(gpu::STARTUP_FRAMES, loss.happened()), "after a loss the window is not torn down"); + assert!(!ends_before_teardown(gpu::STARTUP_FRAMES - 1, loss.happened()), "during start-up the adapter restart runs"); } } diff --git a/crates/ui-egui/src/graphics.rs b/crates/ui-egui/src/graphics.rs index 0ff54d12d3..27cf2c623c 100644 --- a/crates/ui-egui/src/graphics.rs +++ b/crates/ui-egui/src/graphics.rs @@ -10,6 +10,10 @@ //! - The web host then starts again with new graphics and a new egui context, handing it the same //! app. The app notices the new context and makes everything it uploaded to the old one again: //! its fonts and theme, the canvas, and every texture cache ([`TexCache`]). +//! - The desktop host can't give the window a new device. When the window closes after a loss +//! ([`GraphicsLoss::happened`]), the process ends once the app has saved what it keeps on +//! quitting, before the window's graphics are torn down: releasing a swapchain that still holds +//! a frame the lost device couldn't present panics in the graphics driver layer (#6374). use std::cell::{Cell, Ref, RefCell, RefMut}; use std::sync::atomic::{AtomicU64, Ordering}; @@ -20,7 +24,16 @@ use crate::VectorcraftApp; /// Raised by the host when the window's graphics device is lost (from any thread), read on the UI /// thread. Cheap to clone; the clones share the report. #[derive(Clone, Default)] -pub struct GraphicsLoss(Arc>>); +pub struct GraphicsLoss(Arc>); + +/// What a [`GraphicsLoss`] holds. +#[derive(Default)] +struct Loss { + /// The loss not handled yet, for [`GraphicsLoss::take`]. + why: Option, + /// A loss was reported at some point, handled or not. + happened: bool, +} impl GraphicsLoss { /// The graphics device was lost (`why`, for the log): the next frame of `ctx` handles it. A @@ -28,13 +41,23 @@ impl GraphicsLoss { pub fn report(&self, ctx: &egui::Context, why: impl Into) { let why = why.into(); log::error!("vectorcraft: the graphics device was lost: {why}"); - self.0.lock().unwrap_or_else(|e| e.into_inner()).get_or_insert(why); + { + let mut loss = self.0.lock().unwrap_or_else(|e| e.into_inner()); + loss.why.get_or_insert(why); + loss.happened = true; + } ctx.request_repaint(); } /// The loss reported since the last call, if any. pub fn take(&self) -> Option { - self.0.lock().unwrap_or_else(|e| e.into_inner()).take() + self.0.lock().unwrap_or_else(|e| e.into_inner()).why.take() + } + + /// Whether the device was lost at any point, a loss [`Self::take`] already handled included. + /// A window can't be given a new device, so once true this stays true. + pub fn happened(&self) -> bool { + self.0.lock().unwrap_or_else(|e| e.into_inner()).happened } } @@ -190,6 +213,16 @@ mod tests { assert_eq!(loss.take(), None, "handled once"); } + #[test] + fn a_handled_loss_is_still_known_when_the_window_closes() { + let (loss, ctx) = (GraphicsLoss::default(), crate::testing::ui_context()); + assert!(!loss.happened(), "nothing lost yet"); + let (l, c) = (loss.clone(), ctx.clone()); + std::thread::spawn(move || l.report(&c, "Unknown: Device is lost")).join().unwrap(); + assert!(loss.take().is_some(), "the next frame handles it"); + assert!(loss.happened(), "the device stays lost after the frame handled the report"); + } + #[test] fn a_tex_cache_empties_when_the_ui_moves_to_a_new_context() { thread_local! { From d69f9c041c09bfc43d3121ba2b8c0dfb2bcfc6a3 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:07:02 +0100 Subject: [PATCH 244/264] Keep collection panels and their fixed footers in their own viewport --- crates/ui-egui/src/dock.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 6a70094ac2..dcff2191a4 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -15,14 +15,28 @@ pub(crate) fn panel_body(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { Some(DockTab::Properties) => panels::properties::show(app, ui), Some(DockTab::Layers) => panels::layers::show(app, ui), Some(DockTab::Libraries) => panels::libraries(app, ui), - None => { - // The dock clips the group at its assigned height. Keep the panel's own collection - // viewport bounded while allowing a form that exceeds that height to scroll. - let height = ui.available_height(); - Stack::new().id_salt(id).fill().scroll(Scroll::vertical()).show(ui, |ui, _| { - ui.set_max_height(height); - panels::show_icon_panel(app, ui, id); - }); + None if matches!( + id, + "align" + | "attributes" + | "blend" + | "character" + | "color" + | "magicWand" + | "openType" + | "paragraph" + | "pathfinder" + | "patternOptions" + | "stroke" + | "tabs" + | "transform" + | "transparency" + ) => + { + // These panels lay out forms. Collection panels own their scrolling viewport + // and reserve their own footer outside it. + Stack::new().id_salt(id).fill().scroll(Scroll::vertical()).show(ui, |ui, _| panels::show_icon_panel(app, ui, id)); } + None => panels::show_icon_panel(app, ui, id), } } From ede596a7ed8d6dc6ad6e1c308d4174f6d41b2b05 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 07:28:17 -0800 Subject: [PATCH 245/264] =?UTF-8?q?Fix=20#3211:=20Text=20Wrap=20=E2=80=BA?= =?UTF-8?q?=20Make=20wraps=20the=20area=20type=20selected=20with=20the=20o?= =?UTF-8?q?bject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make set the wrap option on every selected object, the area type included, and the wrap resolver never wraps an object that has the option, so selecting the object and the type together and choosing Make left the type as it was. - Make leaves a selected type object with another selected object above it in its layer out of the wrap objects, and takes the option off it if an earlier Make set it there. Text Wrap Options leaves it out too. - Make warns in the status bar when no area type lies below any of its wrap objects (the object is below the type, or the type is point type). - Make and Options record no undo step when nothing changes. Docs: docs/mcp.md, the text_wrap tool description and the command params text. --- crates/engine/src/cmd/textwrap.rs | 179 ++++++++++++++++++++++++++-- crates/mcp/src/tools/definitions.rs | 2 +- docs/mcp.md | 2 +- 3 files changed, 169 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/textwrap.rs b/crates/engine/src/cmd/textwrap.rs index 9ff48848af..ade875b4c9 100644 --- a/crates/engine/src/cmd/textwrap.rs +++ b/crates/engine/src/cmd/textwrap.rs @@ -4,6 +4,8 @@ //! resolves, for each area text object, the outlines of the wrap objects above it into //! `TextObject::wrap` (text space); the layout engine subtracts them from each line's span. +use std::collections::{HashMap, HashSet}; + use serde_json::{Value, json}; use vectorcraft_doc::{Document, NodeId, NodeKind, TextWrap}; @@ -17,7 +19,7 @@ pub fn specs() -> Vec { "Make", ["Object", "Text Wrap"], None, - "{offset?: pt (6), invert?: bool, ids?} area type below the selected objects (same layer) wraps around them; offset -1000 to 1000 (a negative one lets the text that far into them); an offset outside that range or not a number, or an invert that is not true or false, is an error → {ids}", + "{offset?: pt (6), invert?: bool, ids?} area type below the selected objects (same layer) wraps around them; a selected type object with another selected object above it in its layer is the text to wrap, not a wrap object, and loses a wrap it had; offset -1000 to 1000 (a negative one lets the text that far into them); an offset outside that range or not a number, or an invert that is not true or false, is an error → {ids (the wrap objects), warning? (no area type lies below any of them)}", has_selection, make ), @@ -27,13 +29,16 @@ pub fn specs() -> Vec { "Text Wrap Options…", ["Object", "Text Wrap"], None, - "{offset?: pt, invert?: bool, ids?} set the options of the selected wrap objects (offset -1000 to 1000; a negative one lets text into the objects); an offset outside that range or not a number, or an invert that is not true or false, is an error; no options (or null ones) → the current {offset, invert}", + "{offset?: pt, invert?: bool, ids?} set the options of the selected wrap objects, leaving out the type selected below them as Make does (offset -1000 to 1000; a negative one lets text into the objects); an offset outside that range or not a number, or an invert that is not true or false, is an error; no options (or null ones) → the current {offset, invert}", has_selection, options ), ] } +/// The warning Make gives when no area type lies below any of its wrap objects in their layer. +pub const NO_AREA_TYPE_BELOW: &str = "Text Wrap: no area type lies below these objects in their layer, so no text wraps around them. Move the objects above the area type with Object › Arrange › Bring to Front. Point type does not wrap."; + /// The Offset a wrap object takes, in points. pub const TEXT_WRAP_OFFSET_RANGE: std::ops::RangeInclusive = -1000.0..=1000.0; @@ -51,20 +56,70 @@ fn wrap_param(p: &Value, base: TextWrap, cmd: &str) -> Result { Ok(TextWrap { offset, invert: switch_or(p, "invert", base.invert, cmd)? }) } +/// The type objects of `ids` that lie below another of `ids` in their layer: the text Make wraps +/// when the wrap objects and the type are selected together. Make leaves them out of the wrap +/// objects, and takes the wrap off any of them that has one. +fn type_to_wrap(d: &Document, ids: &[NodeId]) -> HashSet { + let wanted: HashSet = ids.iter().copied().collect(); + // One pass in paint order: each selected type object with its layer and place, and the place of + // the topmost selected object other than a layer in each layer. + let mut texts = vec![]; + let mut top: HashMap = HashMap::new(); + let mut at = 0usize; + for (layer, l) in d.layers.iter().enumerate() { + l.walk(&mut |n| { + if wanted.contains(&n.id) { + match n.kind { + NodeKind::Layer { .. } => {} + NodeKind::Text(_) => { + texts.push((n.id, layer, at)); + top.insert(layer, at); + } + _ => { + top.insert(layer, at); + } + } + } + at += 1; + }); + } + texts.into_iter().filter(|(_, layer, at)| top.get(layer).is_some_and(|t| t > at)).map(|(id, _, _)| id).collect() +} + fn make(s: &mut Session, p: &Value) -> Result { let ids = checked_ids_or_selection(s, p, "object.textWrap.make")?; let w = wrap_param(p, TextWrap::default(), "object.textWrap.make")?; - s.edit("Make Text Wrap", |d, _| { - for id in &ids { - let n = d.node_mut(*id).ok_or(EngineError::NoNode(*id))?; - if matches!(n.kind, NodeKind::Layer { .. }) { + let (objects, text, changed) = { + let d = &s.doc()?.doc; + let text = type_to_wrap(d, &ids); + let objects: Vec = ids.iter().copied().filter(|i| !text.contains(i)).collect(); + for id in &objects { + if d.node(*id).is_some_and(|n| matches!(n.kind, NodeKind::Layer { .. })) { return Err(EngineError::Other("layers can't be wrap objects".into())); } - n.extras_mut().wrap = Some(w); } - Ok(()) - })?; - Ok(json!({ "ids": ids.iter().map(|i| i.0).collect::>() })) + let changed = objects.iter().any(|i| d.node(*i).is_some_and(|n| n.extras().wrap != Some(w))) + || text.iter().any(|i| d.node(*i).is_some_and(|n| n.extras().wrap.is_some())); + (objects, text, changed) + }; + if changed { + s.edit("Make Text Wrap", |d, _| { + for id in &objects { + d.node_mut(*id).ok_or(EngineError::NoNode(*id))?.extras_mut().wrap = Some(w); + } + for id in &text { + d.node_mut(*id).ok_or(EngineError::NoNode(*id))?.extras_mut().wrap = None; + } + Ok(()) + })?; + } + let mut out = json!({ "ids": objects.iter().map(|i| i.0).collect::>() }); + let mut wraps = false; + vectorcraft_doc::text::wrap_sources(&s.doc()?.doc, |_, sources, _| wraps |= sources.iter().any(|n| objects.contains(&n.id))); + if !wraps { + out["warning"] = json!(NO_AREA_TYPE_BELOW); + } + Ok(out) } fn release(s: &mut Session, p: &Value) -> Result { @@ -91,14 +146,25 @@ fn release(s: &mut Session, p: &Value) -> Result { fn options(s: &mut Session, p: &Value) -> Result { let ids = checked_ids_or_selection(s, p, "object.textWrap.options")?; - let current = { + // The type selected below the wrap objects is the text they wrap, as in Make. + let (ids, current) = { let d = &s.doc()?.doc; - ids.iter().find_map(|i| d.node(*i).and_then(|n| n.extras().wrap)).unwrap_or_default() + let text = type_to_wrap(d, &ids); + let ids: Vec = ids.into_iter().filter(|i| !text.contains(i)).collect(); + let current = ids.iter().find_map(|i| d.node(*i).and_then(|n| n.extras().wrap)).unwrap_or_default(); + (ids, current) }; if ["offset", "invert"].iter().all(|k| p.get(k).is_none_or(Value::is_null)) { return Ok(json!({ "offset": current.offset, "invert": current.invert })); } let w = wrap_param(p, current, "object.textWrap.options")?; + let changed = { + let d = &s.doc()?.doc; + ids.iter().any(|i| d.node(*i).is_some_and(|n| !matches!(n.kind, NodeKind::Layer { .. }) && n.extras().wrap != Some(w))) + }; + if !changed { + return Ok(json!({ "offset": w.offset, "invert": w.invert })); + } s.edit("Text Wrap Options", |d, _| { for id in &ids { if let Some(n) = d.node_mut(*id) @@ -287,6 +353,95 @@ mod tests { assert_eq!(s.execute("object.textWrap.options", &json!({"invert": true})).unwrap(), json!({"offset": 5000.0, "invert": true})); } + fn wrap_of(s: &Session, id: u64) -> Option { + s.doc().unwrap().doc.node(NodeId(id)).unwrap().extras().wrap + } + + fn area_type(s: &mut Session) -> u64 { + s.execute("text.create", &json!({"x": 0, "y": 0, "text": "word ".repeat(300), "size": 12, "area": {"width": 400, "height": 400}})) + .unwrap()["id"] + .as_u64() + .unwrap() + } + + fn ellipse(s: &mut Session) -> u64 { + s.execute("shape.ellipse", &json!({"x": 150, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap() + } + + /// Make with the wrap object and the area type below it selected together wraps the type: the + /// type is the text to wrap, not another wrap object (#3211). + #[test] + fn make_with_the_area_type_selected_wraps_it() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 600})).unwrap(); + let t = area_type(&mut s); + let plain = lines(&s, t); + let c = ellipse(&mut s); + s.execute("select.set", &json!({"ids": [c, t]})).unwrap(); + let r = s.execute("object.textWrap.make", &json!({})).unwrap(); + assert_eq!(r, json!({"ids": [c]}), "{r}"); + assert!(wrap_of(&s, c).is_some()); + assert!(wrap_of(&s, t).is_none(), "the area type became a wrap object"); + assert_ne!(lines(&s, t), plain, "the area type did not wrap"); + // Make again with the same options changes nothing and records no undo step. + let steps = s.doc().unwrap().history.undo.len(); + assert_eq!(s.execute("object.textWrap.make", &json!({})).unwrap(), json!({"ids": [c]})); + assert_eq!(s.doc().unwrap().history.undo.len(), steps); + // Text Wrap Options with both still selected sets the wrap object's options only, and the + // type keeps wrapping; the same options again record no undo step. + let wrapped = lines(&s, t); + assert_eq!(s.execute("object.textWrap.options", &json!({"offset": 30})).unwrap()["offset"], json!(30.0)); + assert_eq!(wrap_of(&s, c).map(|w| w.offset), Some(30.0)); + assert!(wrap_of(&s, t).is_none(), "Options made the area type a wrap object"); + assert_ne!(lines(&s, t), wrapped, "the type did not follow the new offset"); + assert_ne!(lines(&s, t), plain); + let steps = s.doc().unwrap().history.undo.len(); + s.execute("object.textWrap.options", &json!({"offset": 30})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), steps); + s.execute("edit.undo", &json!({})).unwrap(); + // One undo takes the wrap off again. + s.execute("edit.undo", &json!({})).unwrap(); + assert!(wrap_of(&s, c).is_none()); + assert_eq!(lines(&s, t), plain); + } + + /// Make with the object below the area type warns that no text wraps. After Bring to Front, + /// Make with both selected wraps the type, and the type that the first Make made a wrap object + /// is the text to wrap again (#3211). + #[test] + fn make_warns_when_the_object_is_below_the_type_and_wraps_after_bring_to_front() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 600})).unwrap(); + let c = ellipse(&mut s); + let t = area_type(&mut s); + let plain = lines(&s, t); + s.execute("select.set", &json!({"ids": [c, t]})).unwrap(); + let r = s.execute("object.textWrap.make", &json!({})).unwrap(); + assert_eq!(r["warning"], json!(super::NO_AREA_TYPE_BELOW), "{r}"); + assert_eq!(lines(&s, t), plain); + s.execute("select.set", &json!({"ids": [c]})).unwrap(); + s.execute("object.arrange.bringToFront", &json!({})).unwrap(); + s.execute("select.set", &json!({"ids": [c, t]})).unwrap(); + let r = s.execute("object.textWrap.make", &json!({})).unwrap(); + assert!(r.get("warning").is_none(), "{r}"); + assert!(wrap_of(&s, t).is_none(), "the area type is still a wrap object"); + assert_ne!(lines(&s, t), plain, "the area type did not wrap"); + } + + /// Point type below a wrap object does not wrap, so Make warns. + #[test] + fn make_warns_over_point_type() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 600})).unwrap(); + let p = s.execute("text.create", &json!({"x": 0, "y": 100, "text": "point type", "size": 12})).unwrap()["id"].as_u64().unwrap(); + let r = s.execute("shape.rectangle", &json!({"x": 0, "y": 80, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [r, p]})).unwrap(); + let out = s.execute("object.textWrap.make", &json!({})).unwrap(); + assert_eq!(out["warning"], json!(super::NO_AREA_TYPE_BELOW), "{out}"); + assert!(wrap_of(&s, r).is_some()); + assert!(wrap_of(&s, p).is_none(), "the point type became a wrap object"); + } + #[test] fn text_flows_on_both_sides_of_a_centred_object() { let mut s = Session::new(); diff --git a/crates/mcp/src/tools/definitions.rs b/crates/mcp/src/tools/definitions.rs index d9bf1c8d98..98267484e0 100644 --- a/crates/mcp/src/tools/definitions.rs +++ b/crates/mcp/src/tools/definitions.rs @@ -514,7 +514,7 @@ pub fn tool_definitions() -> Vec { tool( "text_wrap", "Text wrap", - "Make the selected (or `ids`) objects wrap objects: area type below them in the same layer flows around them (offset in pt, invert = flow inside). `release: true` removes the wrap. An offset outside -1000 to 1000 or not a number, or an invert or release that is not true or false, is an error and changes nothing.", + "Make the selected (or `ids`) objects wrap objects: area type below them in the same layer flows around them (offset in pt, invert = flow inside). A type object in `ids` below another of them is the text to wrap, not a wrap object. A `warning` says when no area type lies below them. `release: true` removes the wrap. An offset outside -1000 to 1000 or not a number, or an invert or release that is not true or false, is an error and changes nothing.", obj( json!({ "ids": {"type": "array", "items": {"type": "integer"}}, diff --git a/docs/mcp.md b/docs/mcp.md index a9e9d9649a..84950b4b17 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -821,7 +821,7 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions | `pathfinder` | `{operation, ids?}` | `unite`, `minusFront`, `intersect`, `exclude`, `divide`, `trim`, `merge`, `crop`, `outline`, `minusBack`. For a live version, apply the `pathfinder.*` effect to a group (`effect.apply` groups several loose selected objects first). In remote desktop mode, `run_command` and `invoke_menu` can both call `pathfinder.repeat` with `{}`. Successful panel operations, direct `object.pathfinder.*` commands, and `command.batch` steps (including Actions panel playback) set its history. Repeat applies it to the current selection using current Pathfinder Options. Trap, compound-shape edits, live effects and `action.batch` do not set history. With no history it returns "no Pathfinder operation applied yet". | | `transform` | `{ids?, dx?, dy?, rotate?, scale?, scaleX?, scaleY?, reflect?, shear?, origin?, copy?}` | Runs move, rotate, scale, reflect, shear in that order. `rotate` is in degrees counter-clockwise; a positive `shear` moves the top to the right. With `copy`, the first step duplicates. A `scale`, `reflect` or `shear` that its command would refuse returns that error before any step runs; nothing changes and no undo step is recorded. The same holds for a step that is neither a number nor null, a `reflect` that is not a string, a `copy` that is not true or false, and an `origin` that is not two numbers. A null `rotate`, `scale`, `scaleX`, `scaleY`, `shear`, `reflect`, `copy` or `origin` is left out; a null `dx` or `dy` counts as 0, so it still runs the move. | | `create_graph` | `{type?, x, y, width, height, csv? \| series?, categories?, rows?}` | The nine Illustrator graph types: column, stacked column, bar, stacked bar, line, area, scatter, pie and radar. An empty CSV cell or a `null` in `rows` is a blank value; a number in straight quotes is a label. Edit later with `graph.setData` / `graph.setType` via `run_command`. `graph.column {design, columnType: vertical\|uniform\|repeating\|sliding, each, fractions: chop\|scale}` draws the columns or bars of the series picked with Group Selection (or `seriesIndexes`, or all of them) with a graph design saved by `graph.design`; with no `design` it returns the series' current design and options. Type in the design that holds a `%` followed by two digits shows each column's value, with at least the first digit's places before the decimal point and the second digit's places after it. | -| `text_wrap` | `{ids?, offset?, invert?, release?}` | Area type below the objects (same layer) flows around them. `offset` is in points, from -1000 to 1000 (default 6). An offset outside that range or not a number, or an `invert` or `release` that is not true or false, is an error and changes nothing; `object.textWrap.make` and `object.textWrap.options` refuse the same values. | +| `text_wrap` | `{ids?, offset?, invert?, release?}` | Area type below the objects (same layer) flows around them. A type object in `ids` with another of them above it in its layer is the text to wrap, not a wrap object, so the objects and the type can be selected together. The reply has a `warning` when no area type lies below any of the wrap objects. `offset` is in points, from -1000 to 1000 (default 6). An offset outside that range or not a number, or an `invert` or `release` that is not true or false, is an error and changes nothing; `object.textWrap.make` and `object.textWrap.options` refuse the same values. | | `undo` / `redo` | `{}` | Many calls that change nothing record no undo step, for example `object.align` with nothing to move, `object.move` by 0 without `copy`, `path.moveAnchors` by 0, `layer.setProps` with every row already as given and `object.showAll` with nothing hidden. `undo` (`edit.undo`) after such a call undoes the step before it. Settings that change without an undo step stay as they are when `undo` or `redo` brings back a step that did not change them: the perspective grid's view options and active plane, the grid preferences (`gridlineEvery`, `gridSubdivisions`), the export settings (`assets.settings.set`), and the current brush and symbol. A step that changed one of them, such as a perspective grid preset that shows the grid, takes that change back. The point Automatic Plane Positioning holds comes back with the step, and is let go when the active plane kept is another one. `inspect_document` lists the undo steps as `history`. `run_command` with `edit.clearHistory` removes every undo and redo step of the active document and returns `{cleared}`, the number of steps removed; the document stays as it is, and the command records no undo step. `run_command` with `edit.newDocumentFromState` and `{index?, created?}` makes a new document holding the art as it was at that state and makes it the active document, and returns `{index, title}`. `index` is a row of the History panel, with 0 the oldest state kept, and an omitted or null `index` uses the current state. An `index` that names no state fails with `no history state N`, one that is not a whole number with `` `index` must be a whole number ``, and either changes nothing. `created` is File Info's created date in Unix seconds or null, and defaults to now. The new document takes the next `Untitled-N` name, is marked unsaved, has nothing selected and has no steps to undo or redo. It is out of symbol, opacity-mask and pattern editing, and the art drawn in a pattern's tile is stored in the pattern, as `object.pattern.done` stores it. The source document and its steps stay as they are, except that typing or a drag in progress is first kept as a step. When a command keeps a drag whose preview Real-time Drawing off had not applied yet (`edit.undo`, `edit.redo`, `edit.clearHistory`, `edit.newDocumentFromState` and the other commands that end a drag first), and applying that preview gives a warning, the command's result carries it as `previewWarning`, and as `warning` too when the command gives no warning of its own; the app's status bar shows `warning`. Any other command that changes the document during a tool's drag, from `run_command`, a panel or a menu, records its own undo step before the drag's. The command acts on the document without the drag's preview, and the drag then continues from the command's result: with Real-time Drawing on, the drag's preview is applied again at once, and with it off, the release applies it as before. The release records the drag's step after the command's, `undo` takes back the drag first and the command next, and Escape cancels only the drag. The drag acts on the objects it started with, so a selection the command makes (`select.all`, `edit.duplicate`) does not change what the drag moves, and the drag's release and Escape set the selection as they do without the command (with Real-time Drawing on, so does each move of the drag); a command that records no undo step, such as `select.none`, adds no step. When the command deletes or changes the art being dragged, the drag continues with the art the command left, and a drag left with nothing to change records no step. A warning or an error from the drag's preview applied again after the command is in the command's result as `previewWarning`. Typing in progress is kept as a step of its own before the command. Two cases run the command inside the drag, which then keeps the command's edit as part of its own step: a press of the Quick Pen (an edit to its path ends the path), and `object.transform` with `copy` during an Alt-drag, which copies the art as the drag's move left it. A command run while a dialog's or a panel's preview is open runs inside that preview. While the Type tool edits type, `undo` and `redo` put its caret, with no characters selected, at the end of the text the step changed: after the text it puts back or retypes, or where the text it takes out was. A step that changes no characters, such as a formatting change, leaves the caret and the selection where they are. | For example, create editable Japanese area type with the engine's vertical writing mode: From 8cd5376786d912bd6da594611d54bff32c282e56 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:33:21 +0100 Subject: [PATCH 246/264] Route selected Zoom to canvas navigation and keep freehand edges stationary --- crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/caches.rs | 2 + .../ui-egui/src/canvas/tests_edge_scroll.rs | 60 ++++++++++++++++++- crates/ui-egui/src/canvas/tool_adapter.rs | 26 ++++++-- 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 228a01b2f6..b2e2fa1331 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -140,6 +140,7 @@ impl VectorcraftApp { text_nodes: Default::default(), momentary: None, hand: None, + zoom_tool: None, selection_box: None, selection_bounds: None, selection_marks: None, diff --git a/crates/ui-egui/src/caches.rs b/crates/ui-egui/src/caches.rs index cdf59a99f8..06c564f4c8 100644 --- a/crates/ui-egui/src/caches.rs +++ b/crates/ui-egui/src/caches.rs @@ -82,6 +82,8 @@ pub struct CanvasCache { /// passes; the tool adapter takes it out for its call and puts it back. pub momentary: Option, pub hand: Option, + /// The selected Zoom tool keeps its press and drag rectangle between canvas passes. + pub zoom_tool: Option, /// [`VectorcraftApp::selection_box`] for (document uid, revision, Use Preview Bounds and /// Measure Type by Glyph Bounds). pub selection_box: Option<((u64, u64, vectorcraft_effects::preview::Measure), Option)>, diff --git a/crates/ui-egui/src/canvas/tests_edge_scroll.rs b/crates/ui-egui/src/canvas/tests_edge_scroll.rs index 167f938861..405d14a4e0 100644 --- a/crates/ui-egui/src/canvas/tests_edge_scroll.rs +++ b/crates/ui-egui/src/canvas/tests_edge_scroll.rs @@ -9,7 +9,12 @@ use vectorcraft_geom::Point; /// One headless canvas frame on an 800 × 600 window. fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) { - let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), events, ..Default::default() }; + frame_with_modifiers(app, ctx, events, Default::default()); +} + +fn frame_with_modifiers(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec, modifiers: egui::Modifiers) { + let raw = + egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), events, modifiers, ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| show(app, ui)); out.textures_delta.clear(); } @@ -139,3 +144,56 @@ fn a_hand_drag_held_near_the_edge_does_not_scroll_on() { assert_eq!(center(&app), c0); frame(&mut app, &ctx, vec![button(edge, false)]); } + +#[test] +fn a_freehand_stroke_at_the_edge_keeps_the_artwork_stationary() { + let (mut app, ctx, original) = zoomed_in("pencil"); + let rect = app.canvas_view().unwrap().rect; + let start = rect.center() - vec2(120.0, 60.0); + let edge = pos2(rect.right() - 2.0, start.y + 40.0); + let initial = center(&app); + let nodes = |app: &VectorcraftApp| { + let mut count = 0; + app.session.active().unwrap().doc.walk(|_| count += 1); + count + }; + let before = nodes(&app); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start), button(start, true)]); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start + vec2(15.0, 25.0))]); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(edge)]); + for _ in 0..5 { + frame(&mut app, &ctx, vec![]); + assert_eq!(center(&app), initial); + } + frame(&mut app, &ctx, vec![button(edge, false)]); + assert!(nodes(&app) > before, "the pencil drew a new path"); + assert!(app.session.active().unwrap().doc.node(original).is_some()); +} + +#[test] +fn selected_zoom_tool_clicks_option_clicks_and_drags_a_marquee() { + let (mut app, ctx, _) = zoomed_in("zoom"); + app.session.prefs.animated_zoom = false; + let rect = app.canvas_view().unwrap().rect; + let position = rect.center(); + let zoom = |app: &VectorcraftApp| app.view().unwrap().zoom; + let initial = zoom(&app); + for pressed in [true, false] { + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(position), button(position, pressed)]); + } + let enlarged = zoom(&app); + assert!(enlarged > initial, "click should zoom in: {initial} -> {enlarged}"); + let modifiers = egui::Modifiers::ALT; + for pressed in [true, false] { + let event = egui::Event::PointerButton { pos: position, button: egui::PointerButton::Primary, pressed, modifiers }; + frame_with_modifiers(&mut app, &ctx, vec![event], modifiers); + } + let reduced = zoom(&app); + assert!(reduced < enlarged, "Option-click should zoom out: {enlarged} -> {reduced}"); + let start = position - vec2(90.0, 65.0); + let end = position + vec2(80.0, 55.0); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start), button(start, true)]); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(end)]); + frame(&mut app, &ctx, vec![button(end, false)]); + assert!(zoom(&app) > reduced, "the marquee should fit its region to the view"); +} diff --git a/crates/ui-egui/src/canvas/tool_adapter.rs b/crates/ui-egui/src/canvas/tool_adapter.rs index cc2750f2a4..2e33ef9cf8 100644 --- a/crates/ui-egui/src/canvas/tool_adapter.rs +++ b/crates/ui-egui/src/canvas/tool_adapter.rs @@ -590,7 +590,9 @@ impl CanvasTool for SessionTool<'_> { } fn autoscrolls(&self) -> bool { - !self.carrying.get() && !self.view_only() + // Sampled freehand tools trace the pointer on the artwork. Scrolling + // under a held pen would extend the stroke without another sample. + !self.carrying.get() && !self.view_only() && !self.app().session.tool_wants_samples() } fn view_only(&self) -> bool { @@ -651,18 +653,30 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too let mut picked = ToolHostResponse::default(); let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) { picked - } else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 && app.ui.rearrange_placement.is_none() { + } else if matches!(app.session.tool_id(), "hand" | "zoom") && app.ui.screen_mode != 3 && app.ui.rearrange_placement.is_none() { let options = crate::app::view::navigation(&app.session.prefs); - let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options)); - hand.options = options; - let response = host_run(app, ui, pass, &mut hand); + let response = if app.session.tool_id() == "zoom" { + app.canvas.hand = None; + let mut zoom = app.canvas.zoom_tool.take().unwrap_or_else(|| craft::ui::canvas::ZoomTool::new(options)); + zoom.options = options; + let response = host_run(app, ui, pass, &mut zoom); + app.canvas.zoom_tool = Some(zoom); + response + } else { + app.canvas.zoom_tool = None; + let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options)); + hand.options = options; + let response = host_run(app, ui, pass, &mut hand); + app.canvas.hand = Some(hand); + response + }; if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down() || i.pointer.primary_pressed()) { crate::shortcuts::note_tool_use(app); } - app.canvas.hand = Some(hand); response } else { app.canvas.hand = None; + app.canvas.zoom_tool = None; let mut tool = SessionTool::new(app, view_info, ui); let response = host_run_session(&mut tool, ui, pass); drop(tool); From 2baca48a3dccb2a218c286ccdd3ecf79a99910ed Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:38:56 +0100 Subject: [PATCH 247/264] Collect macOS menu key equivalents before consuming native key-up --- crates/ui-egui/src/app.rs | 7 ++++++- crates/ui-egui/src/menus/native.rs | 1 - crates/ui-egui/src/tests/nativemenu.rs | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 228a01b2f6..246341ef71 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -380,7 +380,12 @@ impl VectorcraftApp { } /// A window's raw input, before egui and the keys read it (the host's `raw_input_hook`). - pub fn raw_input(&self, ctx: &egui::Context, raw: &mut egui::RawInput) { + pub fn raw_input(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) { + // AppKit consumes the key-down and winit can already have queued its key-up. + // Poll before the runtime orders the press and release in this frame's input. + if let Some(menu) = self.services.native_menu.as_mut() { + menu.poll(ctx); + } crate::type_editing::keep_layout_text(self, ctx, raw); } diff --git a/crates/ui-egui/src/menus/native.rs b/crates/ui-egui/src/menus/native.rs index 0cd3eeaa87..2450a9b201 100644 --- a/crates/ui-egui/src/menus/native.rs +++ b/crates/ui-egui/src/menus/native.rs @@ -27,7 +27,6 @@ pub(crate) fn run(app: &mut VectorcraftApp, ctx: &egui::Context) { let gate = Gate::default().modal(app.file_dialog_open()).recording_shortcut(recording_shortcut(app)).text_editing(ctx.egui_wants_keyboard_input()); let Some(menu) = app.services.native_menu.as_mut() else { return }; - menu.poll(ctx); menu.set_gate(gate); let clicks = menu.take_clicks(ctx); // A menu opening reads the Scripts folder again. diff --git a/crates/ui-egui/src/tests/nativemenu.rs b/crates/ui-egui/src/tests/nativemenu.rs index 1fad419639..41b5264479 100644 --- a/crates/ui-egui/src/tests/nativemenu.rs +++ b/crates/ui-egui/src/tests/nativemenu.rs @@ -458,3 +458,24 @@ fn a_key_equivalent_paste_pastes_a_picture_from_another_app() { assert_eq!(images(&m), n, "press {n} pastes one picture"); } } + +/// AppKit handles a menu shortcut's key-down before winit delivers the matching key-up. +/// The two must reach the same input batch, even if this frame can have only one pass. +#[test] +fn a_native_undo_and_redo_key_equivalent_each_change_the_canvas_once() { + let mut m = Mac::new(true); + m.ctx.options_mut(|o| o.max_passes = std::num::NonZeroUsize::MIN); + let id = m.app.run("shape.rectangle", json!({"x": 200, "y": 150, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap(); + let id = vectorcraft_doc::NodeId(id); + m.frame(vec![]); + for (chord, shift, present) in [("Cmd+Z", false, false), ("Cmd+Shift+Z", true, true)] { + let mut modifiers = if crate::keymap::platform().is_mac() { Modifiers::MAC_CMD } else { Modifiers::CTRL }; + modifiers.command = true; + modifiers.shift = shift; + m.fake.report(MenuEvent::Key(Chord::parse(chord).unwrap())); + m.frame(vec![Event::Key { key: Key::Z, physical_key: Some(Key::Z), pressed: false, repeat: false, modifiers }]); + assert_eq!(m.app.session.active().unwrap().doc.node(id).is_some(), present, "{chord} with the native key-up"); + m.frame(vec![]); + assert_eq!(m.app.session.active().unwrap().doc.node(id).is_some(), present, "{chord} was applied once"); + } +} From c8abbce26b357d668c8018b30c603aff82d5c2b4 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:41:07 +0100 Subject: [PATCH 248/264] Deliver Option as a modifier-change event in Zoom regression --- crates/ui-egui/src/canvas/tests_edge_scroll.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests_edge_scroll.rs b/crates/ui-egui/src/canvas/tests_edge_scroll.rs index 405d14a4e0..3a67ee6840 100644 --- a/crates/ui-egui/src/canvas/tests_edge_scroll.rs +++ b/crates/ui-egui/src/canvas/tests_edge_scroll.rs @@ -9,12 +9,7 @@ use vectorcraft_geom::Point; /// One headless canvas frame on an 800 × 600 window. fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec) { - frame_with_modifiers(app, ctx, events, Default::default()); -} - -fn frame_with_modifiers(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec, modifiers: egui::Modifiers) { - let raw = - egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), events, modifiers, ..Default::default() }; + let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), events, ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| show(app, ui)); out.textures_delta.clear(); } @@ -186,8 +181,9 @@ fn selected_zoom_tool_clicks_option_clicks_and_drags_a_marquee() { let modifiers = egui::Modifiers::ALT; for pressed in [true, false] { let event = egui::Event::PointerButton { pos: position, button: egui::PointerButton::Primary, pressed, modifiers }; - frame_with_modifiers(&mut app, &ctx, vec![event], modifiers); + frame(&mut app, &ctx, vec![egui::Event::ModifiersChanged(modifiers), event]); } + frame(&mut app, &ctx, vec![egui::Event::ModifiersChanged(egui::Modifiers::NONE)]); let reduced = zoom(&app); assert!(reduced < enlarged, "Option-click should zoom out: {enlarged} -> {reduced}"); let start = position - vec2(90.0, 65.0); From dd8e474b64367a3969a0c808bd7aaff78cf3dede Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:41:31 +0100 Subject: [PATCH 249/264] Measure the Done button against the compact panel's actual bounds --- crates/ui-egui/src/panels/pattern_options.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/panels/pattern_options.rs b/crates/ui-egui/src/panels/pattern_options.rs index 0bd03fac9c..866588c468 100644 --- a/crates/ui-egui/src/panels/pattern_options.rs +++ b/crates/ui-egui/src/panels/pattern_options.rs @@ -274,15 +274,19 @@ mod tests { app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); app.run("object.pattern.make", json!({"name": "Dots"})).unwrap(); let mut panel = Panel::new(app, |app, ui| crate::dock::panel_body(app, ui, "patternOptions")); - panel.room(egui::vec2(300.0, 200.0)); + let viewport = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(300.0, 200.0)); + panel.room(viewport.size()); panel.frame(); panel.frame(); - assert!(!panel.in_view("Done")); + let before = panel.rect("Done"); + assert!(before.center().y > viewport.bottom(), "Done starts at {before:?} in {viewport:?}"); for _ in 0..20 { - panel.scroll_at(egui::pos2(150.0, 100.0), -120.0); + panel.scroll_at(egui::pos2(30.0, 30.0), -120.0); + panel.advance(0.2); panel.frame(); } - assert!(panel.in_view("Done")); + let after = panel.rect("Done"); + assert!(viewport.contains(after.center()), "Done moved from {before:?} to {after:?} in {viewport:?}"); panel.click("Done"); assert!(editing(&panel.app()).is_none()); } From ab4e56934be4afed5f89b44b64945d0e389bb8b5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 07:48:08 -0800 Subject: [PATCH 250/264] Linux: the log says why a pen's window stays on Wayland, and names the pens XWayland lists Part of #5622. On a Wayland session winit 0.30 receives no input from a pen, so the app opens its window through XWayland when a pen is attached (#4967). When it did not, the log said nothing, and a report could not tell a pen that was not found from a session with no X display. - On a Wayland session the log now says why the window opens on Wayland: no pen in /proc/bus/input/devices, the device list could not be read, VECTORCRAFT_NATIVE_WAYLAND is set, or there is no X display (DISPLAY is unset, as in the Flatpak, which has --socket=fallback-x11). The pen-found line names the pen, and the missing-libraries warning no longer says Linux Display Server is X11 when a pen chose XWayland. - Under X11 the tablet reader logs the pens the X server lists (for example XWayland's "xwayland-tablet stylus:16"), again when that list changes, and the first event from each pen. - docs/development.md lists the new log lines, the Flatpak override that gives it an X display, and that GDK_BACKEND=x11 does not move the window to XWayland. --- apps/vectorcraft/src/main.rs | 29 ++++++- apps/vectorcraft/src/tablet.rs | 71 ++++++++++++++++- apps/vectorcraft/src/xwayland.rs | 130 ++++++++++++++++++++++++++----- docs/development.md | 2 +- 4 files changed, 204 insertions(+), 28 deletions(-) diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 6ab6778597..943c4c6302 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -396,15 +396,36 @@ fn read_command_line( /// Whether the window opens through XWayland, for Linux Display Server `pref` (`main`). #[cfg(target_os = "linux")] fn opens_through_xwayland(pref: Option<&str>) -> bool { - if !xwayland::wanted(pref, |name| std::env::var_os(name), xwayland::pen_attached) { + use xwayland::Choice; + let choice = xwayland::choose(pref, |name| std::env::var_os(name), xwayland::pen_attached); + // On native Wayland winit 0.30 receives no pen input, so the log says why the window stays there. + match &choice { + Choice::NotWayland | Choice::Chosen | Choice::Pen(_) => {} + Choice::NoXDisplay { x11: true } => { + log::warn!("Linux Display Server is X11, but there is no X display (DISPLAY is unset): opening the window on Wayland") + } + Choice::NoXDisplay { x11: false } => log::info!( + "opening the window on Wayland, where a pen does not reach it: there is no X display (DISPLAY is unset) to open it through XWayland" + ), + Choice::NativeWayland => log::info!("VECTORCRAFT_NATIVE_WAYLAND is set: opening the window on Wayland, where a pen does not reach it"), + Choice::NoPen => log::info!("no pen in /proc/bus/input/devices: opening the window on Wayland"), + Choice::NoDeviceList(e) => log::warn!("can't look for a pen ({e}): opening the window on Wayland, where a pen does not reach it"), + } + if !choice.xwayland() { return false; } if !xwayland::x11_libraries_found() { - log::warn!("Linux Display Server is X11, but the X11 libraries aren't all installed: opening the window on Wayland"); + if let Choice::Pen(name) = &choice { + log::warn!( + "pen found ({name}), but the X11 libraries aren't all installed: opening the window on Wayland, where the pen does not reach it" + ); + } else { + log::warn!("Linux Display Server is X11, but the X11 libraries aren't all installed: opening the window on Wayland"); + } return false; } - if pref != Some("x11") { - log::info!("pen found: opening the window through XWayland, where the pen works (VECTORCRAFT_NATIVE_WAYLAND=1 keeps Wayland)"); + if let Choice::Pen(name) = &choice { + log::info!("pen found ({name}): opening the window through XWayland, where the pen works (VECTORCRAFT_NATIVE_WAYLAND=1 keeps Wayland)"); } else { log::info!("opening the window through XWayland (Preferences › Performance › Linux Display Server)"); } diff --git a/apps/vectorcraft/src/tablet.rs b/apps/vectorcraft/src/tablet.rs index 4dd8f7d9ec..2c6a8b68c1 100644 --- a/apps/vectorcraft/src/tablet.rs +++ b/apps/vectorcraft/src/tablet.rs @@ -41,7 +41,7 @@ //! the rotation's range is 0°, and an axis a pen lacks reads nothing. #![cfg_attr(not(target_os = "linux"), allow(dead_code))] -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use craft::behavior::PointerSample; use craft::ui::runtime::pen::PenSource; @@ -189,6 +189,8 @@ enum Update { struct Pens { devices: HashMap, last: HashMap; 5]>, + /// The pens an event has come from, for the log. + heard: HashSet, } impl Pens { @@ -197,10 +199,37 @@ impl Pens { /// same id starts without them. fn set_devices(&mut self, devices: impl IntoIterator) { let devices: HashMap = devices.into_iter().take(MAX_DEVICES).map(|d| (d.id, d)).collect(); - self.last.retain(|id, _| devices.get(id).is_some_and(|d| self.devices.get(id) == Some(d))); + let unchanged = |id: &u16| devices.get(id).is_some_and(|d| self.devices.get(id) == Some(d)); + self.last.retain(|id, _| unchanged(id)); + self.heard.retain(|id| unchanged(id)); self.devices = devices; } + /// The names of the pens listed, by device id, for the log. + fn pen_names(&self) -> Vec<&str> { + let mut pens: Vec<&Device> = self.devices.values().filter(|d| d.is_pen()).collect(); + pens.sort_by_key(|d| d.id); + pens.into_iter().map(|d| d.name.as_str()).collect() + } + + /// The pens listed, as the log line says it: under XWayland on a Wayland session this tells + /// whether XWayland lists the pen at all (#5622). + fn summary(&self) -> String { + let names = self.pen_names(); + if names.is_empty() { + "the X server lists no pen (a pointer device with an \"Abs Pressure\" valuator): a pen draws at full pressure".to_string() + } else { + format!("pens listed: {}", names.join(", ")) + } + } + + /// The name of pen `id` when this is the first event from it since it was listed, for the log: + /// it tells whether the pen's events reach the app at all. + fn first_event(&mut self, id: u16) -> Option<&str> { + let device = self.devices.get(&id).filter(|d| d.is_pen())?; + self.heard.insert(id).then_some(device.name.as_str()) + } + /// A raw motion or button event of device `id`, with the valuators that changed. fn handle(&mut self, id: u16, valuators: impl IntoIterator) -> Update { let Some(device) = self.devices.get(&id) else { return Update::Keep }; @@ -231,6 +260,9 @@ impl Pens { /// A raw event as the X server sends it: its valuator mask and the values of the valuators /// set in it. A pen's sample or another pointer's `None` goes into `pen`. fn raw_event(&mut self, pen: &PenSource, id: u16, mask: &[u32], values: &[f64]) { + if let Some(name) = self.first_event(id) { + log::info!("tablet: events arrive from the pen {name:?}"); + } if let Update::Set(sample) = self.handle(id, valuators(mask, values)) { pen.set(sample); } @@ -304,6 +336,7 @@ mod x11 { .map_err(|e| format!("XISelectEvents failed: {e}"))?; let mut pens = Pens::default(); pens.set_devices(query_devices(&conn)); + log::info!("tablet: {}", pens.summary()); std::thread::Builder::new() .name("vectorcraft-tablet-x11".into()) .spawn(move || run(&conn, &mut pens, &pen)) @@ -321,7 +354,14 @@ mod x11 { let values: Vec = e.axisvalues.iter().map(|v| fp3232(v.integral, v.frac)).collect(); pens.raw_event(pen, e.deviceid, &e.valuator_mask, &values); } - Event::XinputHierarchy(_) | Event::XinputDeviceChanged(_) => pens.set_devices(query_devices(conn)), + Event::XinputHierarchy(_) | Event::XinputDeviceChanged(_) => { + let before = pens.summary(); + pens.set_devices(query_devices(conn)); + let after = pens.summary(); + if after != before { + log::info!("tablet: {after}"); + } + } _ => {} } } @@ -623,6 +663,31 @@ mod tests { assert!(s.pressure < 0.001, "{}", s.pressure); } + /// #5622: the log names the pens the X server lists (XWayland's included) and the first event + /// from each, once, again after the pen is listed anew, and never for a mouse. + #[test] + fn the_log_names_the_pens_listed_and_the_first_event_from_each() { + let stylus = Device::new(11, "xwayland-tablet stylus:16", Some("xwayland-tablet stylus"), pen_valuators()); + let eraser = Device::new(12, "xwayland-tablet eraser:16", Some("xwayland-tablet eraser"), pen_valuators()); + let mut pens = Pens::default(); + assert!(pens.summary().contains("lists no pen"), "{}", pens.summary()); + pens.set_devices([eraser.clone(), mouse(4), stylus.clone()]); + assert_eq!(pens.summary(), "pens listed: xwayland-tablet stylus:16, xwayland-tablet eraser:16"); + assert_eq!(pens.first_event(11), Some("xwayland-tablet stylus:16")); + assert_eq!(pens.first_event(11), None, "once"); + assert_eq!(pens.first_event(4), None, "a mouse"); + assert_eq!(pens.first_event(99), None, "a device not listed"); + // Listed again unchanged: still heard. Another device under the same id: heard anew. + pens.set_devices([eraser.clone(), mouse(4), stylus]); + assert_eq!(pens.first_event(11), None); + pens.set_devices([eraser, mouse(4), pen(11)]); + assert_eq!(pens.first_event(11), Some("Wacom Intuos Pro M Pen stylus")); + // The events go into the feed as before. + let source = PenSource::default(); + pens.raw_event(&source, 12, &[0b100], &[65535.0]); + assert_eq!(source.current().map(|s| (s.eraser, s.pressure)), Some((true, 1.0))); + } + #[test] fn fixed_point_values() { assert_eq!(fp3232(3, 1 << 31), 3.5); diff --git a/apps/vectorcraft/src/xwayland.rs b/apps/vectorcraft/src/xwayland.rs index 38b210c05e..1471f44199 100644 --- a/apps/vectorcraft/src/xwayland.rs +++ b/apps/vectorcraft/src/xwayland.rs @@ -22,18 +22,61 @@ use std::path::{Path, PathBuf}; const X11_LIBS: &[&str] = &["libX11.so.6", "libX11-xcb.so.1", "libxcb.so.1", "libXcursor.so.1", "libXi.so.6", "libxkbcommon.so.0", "libxkbcommon-x11.so.0"]; -/// Whether the saved `linuxDisplayServer` and the environment ask for XWayland: `x11` chosen, or -/// any other choice (`automatic`, `x11WithPen`, none saved) with `pen` finding a pen and -/// `VECTORCRAFT_NATIVE_WAYLAND` unset (or `0`); a Wayland session (winit picks Wayland whenever -/// `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set); and an X display to open. `pen` runs only after -/// the other checks. -pub fn wanted(pref: Option<&str>, var: impl Fn(&str) -> Option, pen: impl FnOnce() -> bool) -> bool { +/// What the pen check found: the name of the first pen, `None` when there is none, or why the +/// device list could not be read. +pub type PenProbe = Result, String>; + +/// Where the window opens, and why, as [`choose`] decides it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Choice { + /// Not a Wayland session: the window opens where winit opens it. + NotWayland, + /// XWayland, because Linux Display Server is X11 (XWayland). + Chosen, + /// XWayland, because the pen of this name is attached. + Pen(String), + /// Wayland: the session has no X display (`DISPLAY` is unset, as in the Flatpak on a Wayland + /// session), so XWayland can't be used. `x11` is whether X11 (XWayland) was chosen. + NoXDisplay { x11: bool }, + /// Wayland: `VECTORCRAFT_NATIVE_WAYLAND` keeps the window there. + NativeWayland, + /// Wayland: no pen is attached. + NoPen, + /// Wayland: the input devices could not be listed, for this reason. + NoDeviceList(String), +} + +impl Choice { + /// Whether the window opens through XWayland. + pub fn xwayland(&self) -> bool { + matches!(self, Self::Chosen | Self::Pen(_)) + } +} + +/// Where the saved `linuxDisplayServer` and the environment open the window: XWayland for `x11` +/// chosen, or for any other choice (`automatic`, `x11WithPen`, none saved) with `pen` finding a pen +/// and `VECTORCRAFT_NATIVE_WAYLAND` unset (or `0`), on a Wayland session (winit picks Wayland +/// whenever `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set) with an X display to open. `pen` runs +/// only after the other checks. +pub fn choose(pref: Option<&str>, var: impl Fn(&str) -> Option, pen: impl FnOnce() -> PenProbe) -> Choice { let set = |name: &str| var(name).is_some_and(|v| !v.is_empty()); - let session = (set("WAYLAND_DISPLAY") || set("WAYLAND_SOCKET")) && set("DISPLAY"); - let native_wayland = var("VECTORCRAFT_NATIVE_WAYLAND").is_some_and(|v| !v.is_empty() && v != "0"); - match pref { - Some("x11") => session, - _ => session && !native_wayland && pen(), + if !set("WAYLAND_DISPLAY") && !set("WAYLAND_SOCKET") { + return Choice::NotWayland; + } + let x11 = pref == Some("x11"); + if !set("DISPLAY") { + return Choice::NoXDisplay { x11 }; + } + if x11 { + return Choice::Chosen; + } + if var("VECTORCRAFT_NATIVE_WAYLAND").is_some_and(|v| !v.is_empty() && v != "0") { + return Choice::NativeWayland; + } + match pen() { + Ok(Some(name)) => Choice::Pen(name), + Ok(None) => Choice::NoPen, + Err(e) => Choice::NoDeviceList(e), } } @@ -44,20 +87,28 @@ const BTN_TOOL_PEN: u32 = 0x140; const ABS_X: u32 = 0x00; const ABS_Y: u32 = 0x01; -/// Is a pen attached? Reads `/proc/bus/input/devices`; a file that can't be read has no pen. -pub fn pen_attached() -> bool { - std::fs::read_to_string("/proc/bus/input/devices").is_ok_and(|devices| has_pen(&devices)) +/// The pen attached, from `/proc/bus/input/devices`, or why that file could not be read. +pub fn pen_attached() -> PenProbe { + std::fs::read_to_string("/proc/bus/input/devices").map(|devices| find_pen(&devices)).map_err(|e| format!("/proc/bus/input/devices: {e}")) } -/// Is a pen among the input devices `/proc/bus/input/devices` lists? A pen is a device whose +/// Is a pen among the input devices `/proc/bus/input/devices` lists? +#[cfg(test)] +fn has_pen(devices: &str) -> bool { + find_pen(devices).is_some() +} + +/// The name of the first pen among the input devices `/proc/bus/input/devices` lists (its +/// `N: Name=` line without the quotes, empty when it has none). A pen is a device whose /// `B: KEY=` bitmap has `BTN_TOOL_PEN` and whose `B: ABS=` bitmap has `ABS_X` and `ABS_Y`, as /// libinput asks of a tablet tool. A virtual keyboard made with uinput can claim every key code, /// `BTN_TOOL_PEN` included, but has no absolute axes. -fn has_pen(devices: &str) -> bool { - devices.split("\n\n").any(|device| { - let bitmap = |name: &str| device.lines().find_map(|l| l.strip_prefix(name)); - bitmap("B: KEY=").is_some_and(|keys| bit_set(keys, BTN_TOOL_PEN)) - && bitmap("B: ABS=").is_some_and(|axes| bit_set(axes, ABS_X) && bit_set(axes, ABS_Y)) +fn find_pen(devices: &str) -> Option { + devices.split("\n\n").find_map(|device| { + let field = |name: &str| device.lines().find_map(|l| l.strip_prefix(name)); + let pen = field("B: KEY=").is_some_and(|keys| bit_set(keys, BTN_TOOL_PEN)) + && field("B: ABS=").is_some_and(|axes| bit_set(axes, ABS_X) && bit_set(axes, ABS_Y)); + pen.then(|| field("N: Name=").map_or_else(String::new, |n| n.trim().trim_matches('"').to_string())) }) } @@ -147,6 +198,11 @@ mod tests { panic!("the pen check ran") } + /// [`choose`] as a yes or no, with a pen check that finds a pen or none. + fn wanted(pref: Option<&str>, var: impl Fn(&str) -> Option, pen: impl FnOnce() -> bool) -> bool { + choose(pref, var, || Ok(pen().then(|| "Pen".to_string()))).xwayland() + } + #[test] fn xwayland_only_when_chosen_on_wayland_with_an_x_display() { let wayland = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0")]); @@ -183,6 +239,40 @@ mod tests { assert!(wanted(Some("x11"), &native, no_probe)); } + /// #5622: the choice names why the window stays on Wayland, where the pen does not reach it, + /// so that the log tells a missing X display (the Flatpak on a Wayland session) from a pen + /// that is not listed or a device list that can't be read. + #[test] + fn the_choice_says_why_the_window_stays_on_wayland() { + let wayland = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0")]); + let no_x = env(&[("WAYLAND_DISPLAY", "wayland-0")]); + let native = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0"), ("VECTORCRAFT_NATIVE_WAYLAND", "1")]); + let pen = || Ok(Some("ELAN9008:00 04F3:2C82 Stylus".to_string())); + let never = || -> PenProbe { panic!("the pen check ran") }; + assert_eq!(choose(None, env(&[("DISPLAY", ":0")]), never), Choice::NotWayland); + assert_eq!(choose(None, &no_x, never), Choice::NoXDisplay { x11: false }); + assert_eq!(choose(Some("x11"), &no_x, never), Choice::NoXDisplay { x11: true }); + assert_eq!(choose(Some("x11"), &wayland, never), Choice::Chosen); + assert_eq!(choose(Some("automatic"), &native, never), Choice::NativeWayland); + assert_eq!(choose(Some("automatic"), &wayland, pen), Choice::Pen("ELAN9008:00 04F3:2C82 Stylus".to_string())); + assert_eq!(choose(Some("x11WithPen"), &wayland, || Ok(None)), Choice::NoPen); + let unreadable = choose(None, &wayland, || Err("/proc/bus/input/devices: Permission denied".to_string())); + assert_eq!(unreadable, Choice::NoDeviceList("/proc/bus/input/devices: Permission denied".to_string())); + for stays in [Choice::NotWayland, Choice::NoXDisplay { x11: true }, Choice::NativeWayland, Choice::NoPen, unreadable] { + assert!(!stays.xwayland(), "{stays:?}"); + } + assert!(Choice::Chosen.xwayland() && Choice::Pen(String::new()).xwayland()); + } + + /// The pen check names the pen it found, for the log. + #[test] + fn the_pen_check_names_the_pen() { + assert_eq!(find_pen(WITH_PEN).as_deref(), Some("Wacom Intuos Pro M Pen")); + let without = WITH_PEN.split("\n\n").take(2).collect::>().join("\n\n"); + assert_eq!(find_pen(&without), None); + assert_eq!(find_pen("B: KEY=1c03 0 0 0 0 0\nB: ABS=3\n").as_deref(), Some(""), "a pen without a name line"); + } + /// `/proc/bus/input/devices` of a laptop with a Wacom Intuos Pro attached (64-bit longs: the /// pen's `KEY=1c03 0 0 0 0 0` has bit 0x140, `BTN_TOOL_PEN`), from PhotoCraft's tests. const WITH_PEN: &str = "I: Bus=0011 Vendor=0001 Product=0001 Version=ab83\n\ diff --git a/docs/development.md b/docs/development.md index 5a1b6efd95..ce215da81f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -134,7 +134,7 @@ The window runs natively on Wayland (eframe's `wayland` feature) and on X11. On - **Clipboard owners that never answer (#510):** reading the clipboard waits on the app that owns it: arboard gives up on an X11 owner after 4 s for each format it tries, and a Wayland read waits for the owner to send its data. So on Linux the check that enables the Paste menu items runs on a background thread with a second clipboard handle (`crates/ui-egui/src/clipboard_probe.rs`, installed as `Services::clipboard_probe`), only while nothing is copied in the app and a document is open, and the window keeps drawing. Every arboard read on Linux and the BSDs, including the UI thread's (a paste, and a Copy or Cut checking what the clipboard held), runs on a worker thread with a handle of its own and waits 2 s at most: an owner that never sends its data costs one read that wait, and later reads fail at once until it answers. A paste's bitmap read waits up to 10 s on the paste's background thread, so the UI thread does not wait for it. When one of a paste's reads gets no answer in its 2 s, or a paste follows a read that has not been answered yet, such as the paste's own check whether the clipboard still holds what VectorCraft copied, the paste waits on that thread for that read's answer, up to 10 s after the read was sent, and pastes what it holds. When the answer is what VectorCraft copied, holds nothing to paste, or does not come, the paste takes the internal clipboard. On X11, quitting within 25 s of a read that got no answer waits for that read to end, so the app's own handle is the last one and hands what it copied to the clipboard manager when one runs. That includes a read of the Paste menu check's handle: quitting waits up to 27 s for the background thread to drop it before the app drops its own, and quits after that wait even when the handle has not been dropped. The app takes its windows off screen before these waits (`apps/vectorcraft/src/quit_windows.rs`). An X11 main window, an XWayland one included, is hidden. winit cannot hide a native Wayland window, so on Linux the app attaches no buffer to the main window's surface, which unmaps it while the window and its connection stay open for the Wayland clipboard. On Linux the X11 windows of floating panels and documents are unmapped through a second X11 connection. On native Wayland, floating panels and documents are normally drawn inside the main window; on the BSDs a native Wayland main window stays on screen until the waits end. Windows and macOS keep the check on the UI thread: Windows only asks which formats the clipboard holds, macOS asks the pasteboard server. - **Copied files:** files copied in a file manager (`text/uri-list`; `CF_HDROP` on Windows, file URLs on macOS) paste as the first one that is art (SVG, PDF, EPS, EMF/WMF or a bitmap; a `.ai` or `.ait` file from the editing data it holds, else as the PDF or PostScript it holds), before the clipboard's other formats (which include the files' paths as text). - **Dropping files on the window does not work under Wayland:** winit 0.30, which eframe 0.37 runs on, has no Wayland drag and drop ([winit#1881](https://github.com/rust-windowing/winit/issues/1881), added in winit 0.31; [egui#1563](https://github.com/emilk/egui/issues/1563)), so no `dropped_files` arrive. Until eframe moves to winit 0.31: copy the files in the file manager and paste them, use File › Place or Open, or open the window through XWayland, where drops work: set **Preferences › Performance › Linux Display Server** to **X11 (XWayland)** and restart (#1151), or start the app with `WAYLAND_DISPLAY= vectorcraft`. The preference (`linuxDisplayServer`, read at startup in `apps/vectorcraft/src/main.rs`, shown on Linux only) has winit open the window on X11 (`EventLoopBuilderExtX11::with_x11`) when the session is Wayland, `DISPLAY` is set and the X11 libraries winit loads are installed (`apps/vectorcraft/src/xwayland.rs` reads `ldconfig -p` and the usual library directories); otherwise the window opens on Wayland and the log says why. Unlike clearing `WAYLAND_DISPLAY`, it leaves the clipboard on the compositor's own. -- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found: opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way. +- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found (): opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). When the window stays on Wayland on such a session, the log says why (#5622): `no pen in /proc/bus/input/devices`, `can't look for a pen` with the reason, `VECTORCRAFT_NATIVE_WAYLAND is set`, `there is no X display (DISPLAY is unset)`, or that the X11 libraries aren't all installed. The Flatpak gets no X display on a Wayland session (`--socket=fallback-x11`); `flatpak override --user --socket=x11 ai.storyteller.vectorcraft` gives it one. `GDK_BACKEND=x11` does not move the window to XWayland: winit does not read it. Under X11 the log lists the pens the X server lists (`tablet: pens listed: …`, for example `xwayland-tablet stylus:16` under XWayland, or `the X server lists no pen`) and the first event from each pen (`tablet: events arrive from the pen …`). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way. - **Pen pressure under X11 and XWayland (#764):** winit 0.30 hands a pen to an X11 window as a mouse, without its pressure. When the window is on X11, XWayland included, the desktop app opens a second X connection (x11rb's `RustConnection`) and reads XInput2 raw events for every device (`apps/vectorcraft/src/tablet.rs`, from PhotoCraft's `crates/tablet`). A device with an `Abs Pressure` valuator is a pen, unless its XInput type is `TOUCHPAD` or `TOUCHSCREEN`. While a pen is the pointer that moved last, its pressure, scaled from the valuator's range to 0..1, reaches the tools that use pressure: the Paintbrush's pressure-sensitive brushes and the Liquify tools' Use Pressure Pen. The reader also reads `Abs Tilt X` and `Abs Tilt Y` (from a pen that has both) in degrees, scaled to ±60° when the valuator's range does not fit in ±90, and `Abs Rotary Z` (an Art Pen's barrel rotation) as a turn with the middle of the range at 0°; the Paintbrush records them for brushes with Tilt, Bearing and Rotation variation. A pen device whose name or XInput type contains `eraser` (in any case) is the pen's eraser end: while the pointer is over the window, the canvas selects the Eraser tool when the eraser end moves, and it selects the tool used before when the tip moves again (`crates/ui-egui/src/stylus.rs`). The X server needs XInput 2.1 or later; otherwise the log has a `tablet pressure:` warning with the reason, and the pen draws at full pressure. - **Pen tilt and rotation on macOS (#764):** with each tablet event's pressure (#852), `apps/vectorcraft/src/mac_tablet.rs` reads its `tilt`, −1..1 on each axis, scaled to ±60° with each axis keeping AppKit's sign (x positive to the right, y positive towards the bottom and the user), and its `rotation`, negated to run clockwise. Until a pen reports a tilt or a rotation other than 0 after it comes near the tablet, that value reads as none, since a pen without one reports 0. The Paintbrush records them as it does under X11. From 7310a8eb4f63ee0fc478c882cfecffd3204100c0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 07:49:50 -0800 Subject: [PATCH 251/264] Dimension: Alt whole-path measure takes the outside of the stroke with Use Preview Bounds off too With Alt held, the Dimension tool's box over a path and the dimension of the whole path it places now reach the outside of the path's strokes whether Use Preview Bounds is on or off. Before, they did so only with Use Preview Bounds on, and with it off they went through the outermost points of the path. Every dimension of a whole path the tool places now records `"preview": true` in its extent source. Dimensions saved without it keep measuring between the outermost points, and `dimension.create` still defaults `preview` to false. --- crates/doc/src/dimension.rs | 14 +++--- crates/tools/src/dimension.rs | 80 +++++++++++++++++------------------ docs/dimensions.md | 16 ++++--- docs/target-app-parity.md | 2 +- 4 files changed, 58 insertions(+), 54 deletions(-) diff --git a/crates/doc/src/dimension.rs b/crates/doc/src/dimension.rs index 537a1d6e60..8a5c4e24fb 100644 --- a/crates/doc/src/dimension.rs +++ b/crates/doc/src/dimension.rs @@ -394,9 +394,11 @@ pub enum DimensionSource { /// it is vertical. Versions without this source do not open the file. Extent { node: NodeId, - /// Placed with Use Preview Bounds on: the points are moved out to the outside of the - /// strokes the path paints ([`preview_extents`]), the width or height that W and H show. - /// Versions without it measure between the outermost points themselves. + /// The points are moved out to the outside of the strokes the path paints + /// ([`preview_extents`]), the width or height that W and H show with Use Preview Bounds on. + /// The Dimension tool sets it on every dimension of a whole path it places. Without it, + /// as in files saved before the tool set it and in versions without it, the dimension + /// measures between the outermost points themselves. #[serde(default, skip_serializing_if = "std::ops::Not::not")] preview: bool, }, @@ -431,9 +433,9 @@ impl DimensionSource { } /// Whether a path it measures differs between `before` and `after`, or is in only one of them. /// A node without a path, or missing from both, counts as changed. For a dimension of a whole - /// path placed with Use Preview Bounds on, so does a change to the strokes the path paints - /// ([`stroked_by`]): their appearance, the node they come from, or which arrowheads they draw - /// on it, and the path being made into a guide or released from one. + /// path measured to the outside of its strokes (`preview`), so does a change to the strokes the + /// path paints ([`stroked_by`]): their appearance, the node they come from, or which arrowheads + /// they draw on it, and the path being made into a guide or released from one. pub fn art_changed(&self, before: &Document, after: &Document) -> bool { let strokes = matches!(self, Self::Extent { preview: true, .. }); self.nodes().into_iter().any(|id| match (before.node(id), after.node(id)) { diff --git a/crates/tools/src/dimension.rs b/crates/tools/src/dimension.rs index 7f2a652e1f..e2337b5be0 100644 --- a/crates/tools/src/dimension.rs +++ b/crates/tools/src/dimension.rs @@ -42,35 +42,37 @@ impl Kind { } /// What the pointer is over. `Extent` is a path hovered with Alt held: its overall width or height, -/// with `preview` (Use Preview Bounds on) to the outside of its strokes. +/// to the outside of its strokes. #[derive(Clone, Debug, PartialEq)] enum Target { Segment(SegmentRef), Corner { first: SegmentRef, second: SegmentRef, at: Point }, Radial { source: DimensionSource, center: Point, radius: f64 }, - Extent { node: NodeId, preview: bool }, + Extent { node: NodeId }, } -/// A path, whether its points are moved out to its strokes, and the document its outermost points -/// ([`whole_ends`]) were read from ([`whole_box_source`]). -type WholeBoxKey = (NodeId, bool, (u64, u64, usize)); +/// A path and the document its outermost points ([`whole_ends`]) were read from +/// ([`whole_box_source`]). +type WholeBoxKey = (NodeId, (u64, u64, usize)); /// The key of a path's outermost points ([`WholeBoxKey`]), with the points. type WholeBox = (WholeBoxKey, Option<[(Point, Point); 2]>); /// The document a path's box is read from, with what identifies it: while an interaction is in /// progress, the document as it began; otherwise the document `cx` shows, at its revision. -fn whole_box_source<'a>(cx: &ToolContext<'a>, node: NodeId, preview: bool) -> (&'a vectorcraft_doc::Document, WholeBoxKey) { +fn whole_box_source<'a>(cx: &ToolContext<'a>, node: NodeId) -> (&'a vectorcraft_doc::Document, WholeBoxKey) { match cx.interaction_doc { - Some(began) => (began, (node, preview, (cx.revision.0, 0, std::ptr::from_ref(began).addr()))), - None => (cx.doc, (node, preview, (cx.revision.0, cx.revision.1, 0))), + Some(began) => (began, (node, (cx.revision.0, 0, std::ptr::from_ref(began).addr()))), + None => (cx.doc, (node, (cx.revision.0, cx.revision.1, 0))), } } -/// The outermost points a dimension of the whole path `node` measures: [`dimension::extents`], or -/// with `preview` [`dimension::preview_extents`], moved out to the outside of the path's strokes. -fn whole_ends(doc: &vectorcraft_doc::Document, node: NodeId, preview: bool) -> Option<[(Point, Point); 2]> { - if preview { dimension::preview_extents(doc, node) } else { dimension::extents(doc, node) } +/// The outermost points a dimension the tool places on the whole path `node` measures +/// ([`dimension::preview_extents`]): moved out to the outside of the path's strokes, whether Use +/// Preview Bounds is on or off. The dimension records `"preview": true`, so it measures to there +/// after later edits too. +fn whole_ends(doc: &vectorcraft_doc::Document, node: NodeId) -> Option<[(Point, Point); 2]> { + dimension::preview_extents(doc, node) } #[derive(Default)] @@ -1045,23 +1047,23 @@ impl DimensionTool { /// document changes. While an interaction is in progress they are read from the document as /// the interaction began, which each preview starts again from (as the levels in /// [`Self::preview`] are), so the previews themselves do not make the tool read the path again. - fn whole_box(&mut self, cx: &ToolContext, node: NodeId, preview: bool) -> Option<[(Point, Point); 2]> { - let (from, key) = whole_box_source(cx, node, preview); + fn whole_box(&mut self, cx: &ToolContext, node: NodeId) -> Option<[(Point, Point); 2]> { + let (from, key) = whole_box_source(cx, node); if let Some((kept, ends)) = self.whole_box && kept == key { return ends; } - let ends = whole_ends(from, node, preview); + let ends = whole_ends(from, node); self.whole_box = Some((key, ends)); ends } /// What the pointer at `p` is over. A Linear path hovered with `alt` held, before any point - /// is picked, is the whole path: with Use Preview Bounds on, to the outside of its strokes. + /// is picked, is the whole path, to the outside of its strokes. fn target(&self, cx: &ToolContext, p: Point, alt: bool) -> Option { let edge = pick(cx, p)?; match self.kind { - Kind::Linear if alt && self.points.is_empty() => Some(Target::Extent { node: edge.node, preview: cx.preview_bounds }), + Kind::Linear if alt && self.points.is_empty() => Some(Target::Extent { node: edge.node }), Kind::Linear => Some(Target::Segment(edge)), Kind::Angular => { let (anchor, at) = anchor_near(cx, &edge, p)?; @@ -1113,8 +1115,8 @@ impl DimensionTool { let mode = if p.distance(*center) >= *radius { DimensionMode::Radius } else { DimensionMode::Diameter }; self.recipe(mode, *center, p, Point::ZERO, Some(source.clone())) } - Target::Extent { node, preview } => { - let source = DimensionSource::Extent { node: *node, preview: *preview }; + Target::Extent { node } => { + let source = DimensionSource::Extent { node: *node, preview: true }; let mut d = self.recipe(DimensionMode::Linear, Point::ZERO, Point::new(1.0, 0.0), Point::ZERO, Some(source)); d.orientation = Orientation::Horizontal; d @@ -1139,7 +1141,7 @@ impl DimensionTool { } self.level_guide = None; let whole = match self.pending.as_ref().and_then(|d| d.source.as_ref()) { - Some(DimensionSource::Extent { node, preview }) => Some(self.whole_box(cx, *node, *preview)), + Some(DimensionSource::Extent { node, .. }) => Some(self.whole_box(cx, *node)), _ => None, }; let Some(d) = &mut self.pending else { return vec![] }; @@ -1408,8 +1410,8 @@ impl Tool for DimensionTool { } self.hover = self.target(cx, ev.pos, ev.mods.alt); let whole = match self.hover { - Some(Target::Extent { node, preview }) => { - self.whole_box(cx, node, preview); + Some(Target::Extent { node }) => { + self.whole_box(cx, node); true } _ => false, @@ -1562,15 +1564,14 @@ impl Tool for DimensionTool { out.push(Overlay::Line { a: *center, b: *center + toward / toward.hypot() * *radius, color, dashed: true }); } } - Some(Target::Extent { node, preview }) => { - // The box through the path's outermost points (with Use Preview Bounds on, out - // to its strokes): a Smart Guide, or with Smart Guides off a line in the - // tool's own color. Read again when the path changed since the pointer last - // moved. - let (from, at) = whole_box_source(cx, *node, *preview); + Some(Target::Extent { node }) => { + // The box through the path's outermost points, out to its strokes: a Smart + // Guide, or with Smart Guides off a line in the tool's own color. Read again + // when the path changed since the pointer last moved. + let (from, at) = whole_box_source(cx, *node); let b = match self.whole_box { Some((key, ends)) if key == at => ends, - _ => whole_ends(from, *node, *preview), + _ => whole_ends(from, *node), } .map(extent_box); if let Some(b) = b { @@ -2890,7 +2891,7 @@ mod tests { }; let mut t = DimensionTool::default(); t.pointer(&c, &held(PointerKind::Move, 150.0, 100.0)); - assert_eq!(t.hover, Some(Target::Extent { node: id, preview: false })); + assert_eq!(t.hover, Some(Target::Extent { node: id })); assert!(t.overlays(&c).iter().any(|o| matches!(o, Overlay::Line { color, .. } if *color == c.smart_guide_color))); // With Smart Guides off the box is not a Smart Guide, and at a high zoom the size stays by // the pointer. @@ -2907,7 +2908,7 @@ mod tests { t.pointer(&c, &held(PointerKind::Up, 150.0, 100.0)); assert!(t.pending.is_some() && t.points.is_empty()); let above = preview(t.pointer(&c, &PointerEvent::new(PointerKind::Move, 150.0, 60.0))); - assert_eq!(above["source"], json!({"kind":"extent","node":id})); + assert_eq!(above["source"], json!({"kind":"extent","node":id,"preview":true})); assert_eq!(above["orientation"], json!("horizontal")); // Past a corner, the side the pointer is farther out on decides. let corner = preview(t.pointer(&c, &PointerEvent::new(PointerKind::Move, 280.0, 70.0))); @@ -2954,29 +2955,28 @@ mod tests { assert!(o.iter().any(near), "{o:?}"); } - /// With Use Preview Bounds on, the box Alt shows over a stroked path reaches the outside of its - /// stroke, and the dimension of the whole path it places measures to there, as W and H do; it - /// keeps doing so after the art changes (`"preview": true`). With the preference off, the box - /// and the dimension go through the outermost points. + /// With Use Preview Bounds on or off, the box Alt shows over a stroked path reaches the outside + /// of its stroke, and the dimension of the whole path it places measures to there; it keeps + /// doing so after the art changes (`"preview": true`). #[test] - fn with_preview_bounds_an_alt_placed_dimension_measures_the_outside_of_the_stroke() { + fn an_alt_placed_dimension_measures_the_outside_of_the_stroke_with_preview_bounds_on_or_off() { let (d, id) = doc_with_rect(); let (s, p) = (Selection::default(), paint()); let held = |kind, x: f64, y: f64| PointerEvent::new(kind, x, y).with_mods(Mods { alt: true, ..Mods::default() }); let near = |a: f64, b: f64| (a - b).abs() < 1e-9; - for (preview, (left, right)) in [(true, (99.5, 200.5)), (false, (100.0, 200.0))] { + let (left, right) = (99.5, 200.5); + for preview in [true, false] { let c = ToolContext { preview_bounds: preview, ..cx(&d, &s, &p) }; let mut t = DimensionTool::default(); t.pointer(&c, &held(PointerKind::Move, 150.0, 100.0)); - assert_eq!(t.hover, Some(Target::Extent { node: id, preview })); + assert_eq!(t.hover, Some(Target::Extent { node: id })); let xs: Vec = t.overlays(&c).iter().filter_map(|o| if let Overlay::Line { a, .. } = o { Some(a.x) } else { None }).collect(); assert!(xs.iter().any(|x| near(*x, left)) && xs.iter().any(|x| near(*x, right)), "preview {preview}: {xs:?}"); t.pointer(&c, &held(PointerKind::Down, 150.0, 100.0)); t.pointer(&c, &held(PointerKind::Up, 150.0, 100.0)); let acts = t.pointer(&c, &PointerEvent::new(PointerKind::Move, 150.0, 60.0)); let Some(Action::Preview(_, params)) = acts.last() else { panic!("{acts:?}") }; - let source = if preview { json!({"kind":"extent","node":id,"preview":true}) } else { json!({"kind":"extent","node":id}) }; - assert_eq!(params["source"], source); + assert_eq!(params["source"], json!({"kind":"extent","node":id,"preview":true}), "preview {preview}"); let (a, b) = (params["a"][0].as_f64().unwrap_or(f64::NAN), params["b"][0].as_f64().unwrap_or(f64::NAN)); assert!(near(a, left) && near(b, right), "preview {preview}: {a} to {b}"); } diff --git a/docs/dimensions.md b/docs/dimensions.md index ab5003a2b9..27972418af 100644 --- a/docs/dimensions.md +++ b/docs/dimensions.md @@ -105,12 +105,14 @@ The **Dimension Tool** is in the Modify section of the toolbar. Its strip offers that starts no segment is left out. They are read again whenever the path changes, so a turned path shows its new overall width or height rather than that of its bounding box before the turn. The line keeps its distance from the whole path when the path changes or the dimension - changes orientation. With Use Preview Bounds on, the box and the dimension reach the outside of - the path's strokes, the width or height that W and H show: each outermost point moves out to the - edge of the box the strokes paint (a member of a compound path takes the compound path's - strokes, with an arrowhead only where the compound path draws one on that member), and a dimension placed that way measures to there again when the path or its strokes - change. Geometry effects are not included. Alt has this effect only before the first point is - clicked. + changes orientation. With Use Preview Bounds on or off, the box and the dimension reach the + outside of the path's strokes, the width or height that W and H show with Use Preview Bounds + on: each outermost point moves out to the edge of the box the strokes paint (a member of a + compound path takes the compound path's strokes, with an arrowhead only where the compound path + draws one on that member), and a dimension placed that way measures to there again when the + path or its strokes change. Geometry effects are not included. A dimension of a whole path saved + without `"preview":true` keeps measuring between the outermost points. Alt has this effect only + before the first point is clicked. - **Angular:** hover a corner where two straight segments meet and drag outwards. Or click two straight lines that meet (or would, extended), then click to place. - **Radial:** hover a circle, or a segment that is a perfect arc, and drag: outwards gives its @@ -205,7 +207,7 @@ another document. `vertical`), offset and style; returns the group id and label. `{"kind":"extent","node":}` measures a whole path, linear only: between its leftmost and rightmost points when horizontal or aligned, and its topmost and bottommost points when vertical. With `"preview":true` (what - the tool records with Use Preview Bounds on; `false` when omitted, and any value other than + the tool records for an Alt-placed dimension; `false` when omitted, and any value other than `true` or `false` is an error) those points move out to the outside of the path's strokes. A version without the extent source does not open a file that holds one, and a version without `preview` measures such a dimension between the points themselves. `offset` is the distance of diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 9469046bc4..51ba964c82 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -757,7 +757,7 @@ since 2026-10-01. **Drawing tools, Ellipse tool circle from its center sized to touch a path:** By VectorCraft's own rule, with Smart Guides and Snap to Tangent on, a circle drawn from its center (Alt and Shift) snaps its radius so that the circle touches a nearby path whenever the radius comes within the snapping tolerance of that size. The touch point is where the line from the center meets a straight segment or a curve square, inside a segment or at an anchor where the path runs smoothly, also where a curve's handle lies on that anchor. A circle can touch another circle from outside or touch it from inside, and a center inside a closed path gives a circle that touches the path from within. A corner or an open path's end is not offered, nor a curve around the same center. The touch point shows the "tangent" label and the line from the center as guides; the radius is measured along the Constrain Angle's axes, as the drawn box is, and Space moves the circle at the size it snapped to, which it keeps when Space is let go. The snap does not apply to an ellipse (no Shift). When an anchor, center or crossing is within the snapping tolerance of the pointer, or the dragged corner snapped onto one, the circle is not resized to touch a path. Snap to Grid and pixel snapping place the drawn point instead, also when turned on during the drag, and turning Snap to Tangent off during the drag stops the snap. A press with a small jitter is still a click rather than a drag. At most 256 segments near that radius are measured per pointer move, the ones nearest the pointer. `a_circle_from_its_center_snaps_its_radius_to_touch_a_line`, `a_circle_from_its_center_snaps_to_touch_another_circle_from_outside_and_inside`, `a_circle_from_its_center_snaps_to_touch_a_curve`, `a_circle_from_its_center_keeps_its_radius_without_the_snap_or_a_smooth_touch`, `a_circle_from_its_center_prefers_an_anchor_and_measures_the_segments_nearest_the_pointer`, `a_circle_snapped_to_touch_keeps_to_the_constrain_angle`, `a_circle_from_its_center_does_not_snap_to_touch_with_the_grid_or_pixels`, `a_jittered_alt_shift_press_beside_a_path_is_a_click`, `a_circle_from_its_center_prefers_an_anchor_or_a_crossing_at_the_pointer` and `a_circle_from_its_center_touches_a_path_at_an_anchor_with_retracted_handles` cover it. **Drawing tools, selected Dimension extension-line style (#7078):** Properties › Dimension exposes the selected editable dimension's existing extension-line color and weight. Both extension lines share that style, independently of the main dimension line and label. Apply to All keeps its full-style behavior for editable dimensions, leaving a protected dimension unchanged; Set as Default keeps the whole style for a new dimension created without explicit options, without changing existing dimensions. The dimension remains editable. Four cases in `crates/ui-egui/tests/dimension_extension_properties.rs` verify actual Properties input, both canvas extension lines, independent main-line/label styling, full-style Apply to All, locked and unselected controls, defaults/new dimensions, Undo/Redo, and native save/reopen with further editing. Existing document-color conversion is unchanged. The measured geometry and existing snapping behavior are unchanged; no whole-Dimension completion or score/hour change is claimed. **Drawing tools, Dimension tool horizontal and vertical linear dimensions:** A linear dimension between two clicked points or dragged out from a segment is aligned, horizontal or vertical, chosen by where the pointer moves while it is placed, and a click again by the second point gives aligned; `dimension.create` and `dimension.update` take `orientation`, and the dimension stays linked to the anchors it measures, keeps its orientation when it or the art turns, with a line that lay outside the points kept outside them; an unlinked horizontal or vertical dimension that is reflected has its line on the reflected side. `the_pointer_chooses_aligned_horizontal_or_vertical`, `two_points_measure_horizontally_vertically_or_aligned`, `clicking_again_by_the_second_point_places_an_aligned_dimension`, `a_segment_drag_measures_horizontally_vertically_or_aligned`, `points_on_a_vertical_line_measure_aligned`, `horizontal_and_vertical_dimensions_draw_lines_along_their_axis`, `turned_horizontal_dimensions_stay_horizontal`, `a_linked_horizontal_dimension_keeps_its_gap_from_turned_art`, `a_linked_horizontal_dimension_below_or_between_its_points_follows_turned_art`, `a_reflected_horizontal_dimension_keeps_its_line_on_the_reflected_side`, `a_dimension_without_an_orientation_reads_as_aligned`, `dimension_orientation_is_checked` and `a_turned_dimension_keeps_its_line_on_its_side` cover it. -**Drawing tools, Dimension tool overall width and height of a path:** The [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes plotting an object's horizontal and vertical dimensions with Alt (Option on macOS) held over its path. By VectorCraft's own rule, hovering a path with Alt held shows a box through its outermost points (a Smart Guide when Smart Guides are on); a click then a placing click, or a drag out from the path, places a linear dimension of the whole path, and the pointer above or below the path gives its width and beside it its height. `dimension.create` takes the `extent` source, whose points are the outermost points of the path's curves, read again after every edit, so a turned path shows its new overall size, and the line keeps its distance from the whole path. With Use Preview Bounds on, the box and the dimension reach the outside of the path's strokes, which is the size W and H show when the path is not rotated and has no geometry effect (geometry effects such as Offset Path are not included), and the source records `"preview":true` so the dimension measures to there after later edits, a new stroke weight included. `an_alt_click_or_drag_on_a_path_places_its_overall_width_or_height`, `with_preview_bounds_an_alt_placed_dimension_measures_the_outside_of_the_stroke`, `a_dimension_of_a_whole_path_measures_its_overall_width_and_height`, `a_dimension_of_a_whole_path_with_preview_bounds_measures_the_outside_of_the_stroke`, `a_dimension_of_a_whole_path_stays_clear_of_the_path_it_draws` and `a_dimension_of_a_whole_path_survives_a_native_file` cover it. +**Drawing tools, Dimension tool overall width and height of a path:** The [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes plotting an object's horizontal and vertical dimensions with Alt (Option on macOS) held over its path. By VectorCraft's own rule, hovering a path with Alt held shows a box through its outermost points (a Smart Guide when Smart Guides are on); a click then a placing click, or a drag out from the path, places a linear dimension of the whole path, and the pointer above or below the path gives its width and beside it its height. `dimension.create` takes the `extent` source, whose points are the outermost points of the path's curves, read again after every edit, so a turned path shows its new overall size, and the line keeps its distance from the whole path. With Use Preview Bounds on or off, the box and the dimension reach the outside of the path's strokes, which is the size W and H show with Use Preview Bounds on when the path is not rotated and has no geometry effect (geometry effects such as Offset Path are not included), and the source records `"preview":true` so the dimension measures to there after later edits, a new stroke weight included; a dimension saved without it keeps measuring between the outermost points. `an_alt_click_or_drag_on_a_path_places_its_overall_width_or_height`, `an_alt_placed_dimension_measures_the_outside_of_the_stroke_with_preview_bounds_on_or_off`, `a_dimension_of_a_whole_path_measures_its_overall_width_and_height`, `a_dimension_of_a_whole_path_with_preview_bounds_measures_the_outside_of_the_stroke`, `a_dimension_of_a_whole_path_stays_clear_of_the_path_it_draws` and `a_dimension_of_a_whole_path_survives_a_native_file` cover it. **Drawing tools, Dimension tool points that are not anchors follow the art:** A clicked point on a segment stays at its place along the segment, also when the segment curves, and a point off the art is linked to anchors (or, when the anchors lie on one line, anchors and handles) of the path, so both ends of the dimension follow when the art is moved, scaled, turned or reflected, also when the point was placed by a Smart Guide and when the dimension is saved and opened again; a linked linear dimension of reflected art (other than art on one line) has its line on the reflected side; deleting the art, changing its anchor count or whether it is closed, turning an angle's arm into a curve, or making a measured circle or arc no longer circular leaves the dimension where it was, no longer linked, instead of removing it. `a_dimension_to_a_point_on_a_segment_follows_the_art_at_both_ends`, `a_dimension_to_a_point_off_the_art_moves_with_the_art`, `a_dimension_whose_art_changes_its_anchors_stays_where_it_was`, `a_dimension_whose_art_is_opened_stays_where_it_was`, `angle_and_arc_dimensions_whose_art_no_longer_fits_stay_where_they_were`, `a_dimension_that_cannot_be_drawn_again_keeps_its_art`, `a_linked_dimension_of_reflected_art_has_its_line_on_the_reflected_side`, `a_dimension_to_a_point_off_a_line_follows_the_line`, `a_point_off_an_arch_is_reflected_with_the_arch`, `a_point_beside_an_almost_straight_curve_follows_it`, `a_point_off_a_loop_with_its_anchors_in_one_place_follows_it`, `a_point_beside_a_reflected_line_moves_as_a_half_turn_would`, `a_point_on_a_segment_stays_on_it_when_the_segment_curves`, `a_linked_dimension_of_a_reflected_curve_has_its_line_on_the_reflected_side`, `a_dimension_of_art_reflected_across_its_points_changes_sides`, `a_dimension_between_paths_reflected_each_in_its_own_way_keeps_its_offset`, `free_points_survive_a_native_file`, `dimension_free_points_are_checked`, `points_off_anchors_are_held_against_the_path` and `a_point_smart_guides_place_is_held_against_the_path` cover it. **Drawing tools, Dimension tool points on a Smart Guide stay on the guide:** By VectorCraft's own rule, a clicked point that lies on a Smart Guide already, such as one in line with an object's center, stays where the pointer is when no anchor is within 8 pixels and no segment is within the Smart Guides snapping tolerance, instead of moving onto a segment farther than that tolerance and within 8 pixels; with Snap to Grid or Snap to Pixel on, a point stays on the grid or the whole pixel those options give. `a_point_on_a_guide_stays_on_the_guide` covers it. **Drawing tools, Dimension tool second point without construction guides through a first point off the anchors:** By VectorCraft's own rule, with Smart Guides on, the second Linear point does not snap to the construction guides through a first point that is not on an anchor, so a click beside a segment straight below such a first point lands on the segment; after a first point picked on an anchor, the construction guides through it still apply. The second point still snaps to anchors, centers and alignment lines, and with Snap to Perpendicular or Snap to Tangent on, it lands where the line from the first point meets a segment square or grazes a curve. `a_point_on_a_guide_stays_on_the_guide`, `the_second_point_after_an_anchor_lands_on_construction_guides`, `the_second_point_lands_square_to_a_segment_or_grazing_a_curve` and `linear_picks_show_and_snap_to_smart_guides` cover it. From ed0859d0d0a8809adc95feab96190324aa532b9f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 07:51:17 -0800 Subject: [PATCH 252/264] Scripts: kept-default option enumerations and refusal of non-UTF-8 real paths The enumerations whose default member an option keeps (OutputFlattening, CompressionQuality, the PDF color, compression, mark and security enums, and the SVG encoding, DTD, CSS and font enums) are now defined, so a script that sets an option to its default no longer throws a ReferenceError; another member still throws as not available yet. saveAs, exportFile, app.open and close with SAVECHANGES refuse a path whose real file name is not valid UTF-8 instead of writing to or opening a file named with a lossy copy of it. --- crates/engine/src/script/dom/save_open.rs | 88 +++++++++++++++++-- crates/engine/src/tests/script_save_open.rs | 86 ++++++++++++++++++ .../tests/it/script_host_vs_scriptcheck.rs | 37 +++++++- docs/mcp.md | 8 +- docs/target-app-parity.md | 2 +- 5 files changed, 209 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/script/dom/save_open.rs b/crates/engine/src/script/dom/save_open.rs index 060454798a..510364d249 100644 --- a/crates/engine/src/script/dom/save_open.rs +++ b/crates/engine/src/script/dom/save_open.rs @@ -110,6 +110,76 @@ pub(super) const ENUMS: &[(&str, &[&str])] = &[ ("PDFOverprint", &["DISCARDPDFOVERPRINT", "PRESERVEPDFOVERPRINT"]), ("UserInteractionLevel", &["DISPLAYALERTS", "DONTDISPLAYALERTS"]), ("SaveOptions", &["DONOTSAVECHANGES", "PROMPTTOSAVECHANGES", "SAVECHANGES"]), + // The enumerations of the options that keep their defaults (`Default::Member`). + ("OutputFlattening", &["PRESERVEAPPEARANCE", "PRESERVEPATHS"]), + ( + "CompressionQuality", + &[ + "AUTOMATICJPEG2000HIGH", + "AUTOMATICJPEG2000LOSSLESS", + "AUTOMATICJPEG2000LOW", + "AUTOMATICJPEG2000MAXIMUM", + "AUTOMATICJPEG2000MEDIUM", + "AUTOMATICJPEG2000MINIMUM", + "AUTOMATICJPEGHIGH", + "AUTOMATICJPEGLOW", + "AUTOMATICJPEGMAXIMUM", + "AUTOMATICJPEGMEDIUM", + "AUTOMATICJPEGMINIMUM", + "JPEG2000HIGH", + "JPEG2000LOSSLESS", + "JPEG2000LOW", + "JPEG2000MAXIMUM", + "JPEG2000MEDIUM", + "JPEG2000MINIMUM", + "JPEGHIGH", + "JPEGLOW", + "JPEGMAXIMUM", + "JPEGMEDIUM", + "JPEGMINIMUM", + "None", + "ZIP4BIT", + "ZIP8BIT", + ], + ), + ("ColorConversion", &["COLORCONVERSIONREPURPOSE", "COLORCONVERSIONTODEST", "None"]), + ( + "ColorDestination", + &[ + "COLORDESTINATIONDOCCMYK", + "COLORDESTINATIONDOCRGB", + "COLORDESTINATIONPROFILE", + "COLORDESTINATIONWORKINGCMYK", + "COLORDESTINATIONWORKINGRGB", + "None", + ], + ), + ("ColorProfile", &["INCLUDEALLPROFILE", "INCLUDEDESTPROFILE", "INCLUDERGBPROFILE", "LEAVEPROFILEUNCHANGED", "None"]), + ("DownsampleMethod", &["AVERAGEDOWNSAMPLE", "BICUBICDOWNSAMPLE", "NODOWNSAMPLE", "SUBSAMPLE"]), + ("MonochromeCompression", &["CCIT3", "CCIT4", "MONOZIP", "None", "RUNLENGTH"]), + ("PageMarksTypes", &["Japanese", "Roman"]), + ( + "PDFChangesAllowedEnum", + &[ + "CHANGE128ANYCHANGES", + "CHANGE128COMMENTING", + "CHANGE128EDITPAGE", + "CHANGE128FILLFORM", + "CHANGE128NONE", + "CHANGE40ANYCHANGES", + "CHANGE40COMMENTING", + "CHANGE40NONE", + "CHANGE40PAGELAYOUT", + ], + ), + ("PDFPrintAllowedEnum", &["PRINT128HIGHRESOLUTION", "PRINT128LOWRESOLUTION", "PRINT128NONE", "PRINT40HIGHRESOLUTION", "PRINT40NONE"]), + ("PDFTrimMarkWeight", &["TRIMMARKWEIGHT0125", "TRIMMARKWEIGHT025", "TRIMMARKWEIGHT05"]), + ("PDFXStandard", &["PDFX1A2001", "PDFX1A2003", "PDFX32002", "PDFX32003", "PDFX42007", "PDFXNONE"]), + ("SVGCSSPropertyLocation", &["ENTITIES", "PRESENTATIONATTRIBUTES", "STYLEATTRIBUTES", "STYLEELEMENTS"]), + ("SVGDocumentEncoding", &["ASCII", "UTF16", "UTF8"]), + ("SVGDTDVersion", &["SVG1_0", "SVG1_1", "SVGBASIC1_1", "SVGTINY1_1", "SVGTINY1_1PLUS", "SVGTINY1_2"]), + ("SVGFontSubsetting", &["ALLGLYPHS", "COMMONENGLISH", "COMMONROMAN", "GLYPHSUSED", "GLYPHSUSEDPLUSENGLISH", "GLYPHSUSEDPLUSROMAN", "None"]), + ("SVGFontType", &["CEFFONT", "OUTLINEFONT", "SVGFONT"]), ]; const DISPLAY: &str = "UserInteractionLevel.DISPLAYALERTS"; @@ -676,9 +746,9 @@ fn warned(h: &Host, method: &str, id: &str, p: &Value) -> Answer { Ok(answer) } -/// The path to give a command for the real path `real`. -fn plain(real: std::path::PathBuf) -> String { - crate::cmd::findfiles::plain(real).to_string_lossy().into_owned() +/// The path to give a command for the real path `real`, or an error when it is not valid UTF-8. +fn plain(real: std::path::PathBuf) -> std::result::Result { + crate::cmd::findfiles::plain(real).into_os_string().into_string().map_err(|_| HostError::Error("Script file path is not valid UTF-8".into())) } /// The built-in preset names scripts use that VectorCraft's built-in presets name otherwise, and the @@ -738,7 +808,7 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer { p.insert("format".into(), json!(format)); } let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?; - p.insert("path".into(), json!(plain(real))); + p.insert("path".into(), json!(plain(real)?)); exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "saveAs", "file.saveAs", &Value::Object(p))))?; Ok(Data::Undefined) } @@ -793,7 +863,7 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer { } let named = with_extension(path, &kind, svgz); let real = h.disk.borrow().save_target(&named).map_err(|m| refused(m, &named))?; - p.insert("path".into(), json!(plain(real))); + p.insert("path".into(), json!(plain(real)?)); exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "exportFile", "document.export", &Value::Object(p))))?; Ok(Data::Undefined) } @@ -841,8 +911,10 @@ fn app_open(h: &Host, a: &[Data]) -> Answer { if p.contains_key("cropTo") { p.insert("editingData".into(), json!(false)); } - h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; - p.insert("path".into(), json!(plain(std::path::PathBuf::from(path)))); + // The command opens the given path; a real path that is not valid UTF-8 is still refused. + let real = h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?; + plain(real)?; + p.insert("path".into(), json!(plain(std::path::PathBuf::from(path))?)); let r = exactly(h, || warned(h, "open", "document.open", &Value::Object(p)))?; let index = match &r { Data::Object(items) => items.iter().find_map(|(k, v)| match (k.as_str(), v) { @@ -1012,7 +1084,7 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer { // A refusal names the document, as `fullName` does when the read roots hide its file. let name = super::with_doc(h, doc, |_, st| st.title()); let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?; - let p = json!({"path": plain(real), "format": format}); + let p = json!({"path": plain(real)?, "format": format}); exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "close", "file.saveAs", &p)))?; } _ => return Err(HostError::Error(UNSAVED_CHANGES.into())), diff --git a/crates/engine/src/tests/script_save_open.rs b/crates/engine/src/tests/script_save_open.rs index 064ff3c15a..e8bd8675cb 100644 --- a/crates/engine/src/tests/script_save_open.rs +++ b/crates/engine/src/tests/script_save_open.rs @@ -212,6 +212,92 @@ fn omitted_options_are_a_new_options_objects_defaults() { let _ = std::fs::remove_dir_all(base); } +/// A path that resolves to a name that is not valid UTF-8 is refused before anything is written or +/// opened, so no file with a lossy copy of the name is touched. +#[cfg(unix)] +#[test] +fn script_file_commands_refuse_non_utf8_resolved_paths() { + use std::os::unix::ffi::OsStringExt; + + let base = folder("non-utf8-target"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let original = dir.join("original.vectorcraft"); + s.execute("file.saveAs", &json!({"path": original.to_string_lossy()})).unwrap(); + let bytes = std::fs::read(&original).unwrap(); + let target = dir.join(std::ffi::OsString::from_vec(b"target-\xff.vectorcraft".to_vec())); + // A file system that refuses such a name has nothing to refuse. + if std::fs::write(&target, &bytes).is_err() { + let _ = std::fs::remove_dir_all(base); + return; + } + let link = dir.join("alias.vectorcraft"); + std::os::unix::fs::symlink(&target, &link).unwrap(); + let lossy = PathBuf::from(target.to_string_lossy().into_owned()); + std::fs::write(&lossy, &bytes).unwrap(); + for call in ["app.activeDocument.saveAs(f);", "app.activeDocument.exportFile(f, ExportType.SVG);", "app.open(f);"] { + let alias = if call.contains("exportFile") { + let alias = dir.join("alias.svg"); + std::os::unix::fs::symlink(&target, &alias).unwrap(); + alias + } else { + link.clone() + }; + let count = s.documents().len(); + let error = failure(&mut s, &base, &format!("Folder.userData; var f = new File({}); {call}", quoted(&alias))); + assert!(error.contains("Script file path is not valid UTF-8"), "{call}: {error}"); + assert_eq!(s.documents().len(), count); + assert_eq!(std::fs::read(&target).unwrap(), bytes); + assert_eq!(std::fs::read(&lossy).unwrap(), bytes); + } + let _ = std::fs::remove_dir_all(base); +} + +/// Every enumeration an option keeps its default in is defined: the default member is accepted, and +/// another member of the same enumeration is refused as not available yet. +#[test] +fn kept_enum_options_accept_their_default_member() { + let base = folder("keptenums"); + let mut s = session(&base); + let dir = data_folder(&mut s, &base); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let file = |n: &str| format!("new File({})", quoted(&dir.join(n))); + let cases: &[(&str, &str, &str, &str)] = &[ + ("IllustratorSaveOptions", "flattenOutput", "OutputFlattening.PRESERVEAPPEARANCE", "OutputFlattening.PRESERVEPATHS"), + ("PDFSaveOptions", "colorCompression", "CompressionQuality.None", "CompressionQuality.ZIP8BIT"), + ("PDFSaveOptions", "colorConversionID", "ColorConversion.None", "ColorConversion.COLORCONVERSIONTODEST"), + ("PDFSaveOptions", "colorDestinationID", "ColorDestination.None", "ColorDestination.COLORDESTINATIONPROFILE"), + ("PDFSaveOptions", "colorDownsamplingMethod", "DownsampleMethod.NODOWNSAMPLE", "DownsampleMethod.SUBSAMPLE"), + ("PDFSaveOptions", "colorProfileID", "ColorProfile.None", "ColorProfile.INCLUDEALLPROFILE"), + ("PDFSaveOptions", "monochromeCompression", "MonochromeCompression.None", "MonochromeCompression.CCIT4"), + ("PDFSaveOptions", "pageMarksType", "PageMarksTypes.Roman", "PageMarksTypes.Japanese"), + ("PDFSaveOptions", "pDFAllowPrinting", "PDFPrintAllowedEnum.PRINT128HIGHRESOLUTION", "PDFPrintAllowedEnum.PRINT40NONE"), + ("PDFSaveOptions", "pDFChangesAllowed", "PDFChangesAllowedEnum.CHANGE128ANYCHANGES", "PDFChangesAllowedEnum.CHANGE40NONE"), + ("PDFSaveOptions", "pDFXStandard", "PDFXStandard.PDFXNONE", "PDFXStandard.PDFX42007"), + ("PDFSaveOptions", "trimMarkWeight", "PDFTrimMarkWeight.TRIMMARKWEIGHT0125", "PDFTrimMarkWeight.TRIMMARKWEIGHT05"), + ("ExportOptionsSVG", "cssProperties", "SVGCSSPropertyLocation.STYLEATTRIBUTES", "SVGCSSPropertyLocation.ENTITIES"), + ("ExportOptionsSVG", "documentEncoding", "SVGDocumentEncoding.ASCII", "SVGDocumentEncoding.UTF8"), + ("ExportOptionsSVG", "DTD", "SVGDTDVersion.SVG1_1", "SVGDTDVersion.SVGTINY1_2"), + ("ExportOptionsSVG", "fontSubsetting", "SVGFontSubsetting.ALLGLYPHS", "SVGFontSubsetting.GLYPHSUSED"), + ("ExportOptionsSVG", "fontType", "SVGFontType.CEFFONT", "SVGFontType.OUTLINEFONT"), + ]; + for (i, (class, key, default, other)) in cases.iter().enumerate() { + let call = |value: &str, n: String| { + let set = format!("var o = new {class}(); o.{key} = {value};"); + match *class { + "ExportOptionsSVG" => format!("{set} app.activeDocument.exportFile({}, ExportType.SVG, o);", file(&format!("{n}.svg"))), + "PDFSaveOptions" => format!("{set} app.activeDocument.saveAs({}, o);", file(&format!("{n}.pdf"))), + _ => format!("{set} app.activeDocument.saveAs({}, o);", file(&format!("{n}.ai"))), + } + }; + logged(&mut s, &base, &format!("Folder.userData; {}", call(default, format!("ok{i}")))); + let e = failure(&mut s, &base, &format!("Folder.userData; {}", call(other, format!("no{i}")))); + assert!(e.contains("is not available yet"), "{class}.{key} = {other}: {e}"); + } + let _ = std::fs::remove_dir_all(base); +} + /// A raster export at 100% has one pixel per point, whatever the document's raster effects /// resolution. #[test] diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 4263fad910..b55418acb2 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -192,9 +192,42 @@ const INSIDE: &[(&str, &str)] = &[ // The enumerations of saving, exporting and opening. ( "", - "Compatibility EPSPostScriptLevelEnum EPSPreview ExportType PDFBoxType PDFCompatibility PDFOverprint SaveOptions \ - UserInteractionLevel", + "ColorConversion ColorDestination ColorProfile Compatibility CompressionQuality DownsampleMethod EPSPostScriptLevelEnum \ + EPSPreview ExportType MonochromeCompression OutputFlattening PDFBoxType PDFChangesAllowedEnum PDFCompatibility \ + PDFOverprint PDFPrintAllowedEnum PDFTrimMarkWeight PDFXStandard PageMarksTypes SVGCSSPropertyLocation SVGDTDVersion \ + SVGDocumentEncoding SVGFontSubsetting SVGFontType SaveOptions UserInteractionLevel", ), + ("ColorConversion.", "COLORCONVERSIONREPURPOSE COLORCONVERSIONTODEST None"), + ( + "ColorDestination.", + "COLORDESTINATIONDOCCMYK COLORDESTINATIONDOCRGB COLORDESTINATIONPROFILE COLORDESTINATIONWORKINGCMYK \ + COLORDESTINATIONWORKINGRGB None", + ), + ("ColorProfile.", "INCLUDEALLPROFILE INCLUDEDESTPROFILE INCLUDERGBPROFILE LEAVEPROFILEUNCHANGED None"), + ( + "CompressionQuality.", + "AUTOMATICJPEG2000HIGH AUTOMATICJPEG2000LOSSLESS AUTOMATICJPEG2000LOW AUTOMATICJPEG2000MAXIMUM AUTOMATICJPEG2000MEDIUM \ + AUTOMATICJPEG2000MINIMUM AUTOMATICJPEGHIGH AUTOMATICJPEGLOW AUTOMATICJPEGMAXIMUM AUTOMATICJPEGMEDIUM AUTOMATICJPEGMINIMUM \ + JPEG2000HIGH JPEG2000LOSSLESS JPEG2000LOW JPEG2000MAXIMUM JPEG2000MEDIUM JPEG2000MINIMUM JPEGHIGH JPEGLOW JPEGMAXIMUM \ + JPEGMEDIUM JPEGMINIMUM None ZIP4BIT ZIP8BIT", + ), + ("DownsampleMethod.", "AVERAGEDOWNSAMPLE BICUBICDOWNSAMPLE NODOWNSAMPLE SUBSAMPLE"), + ("MonochromeCompression.", "CCIT3 CCIT4 MONOZIP None RUNLENGTH"), + ("OutputFlattening.", "PRESERVEAPPEARANCE PRESERVEPATHS"), + ( + "PDFChangesAllowedEnum.", + "CHANGE128ANYCHANGES CHANGE128COMMENTING CHANGE128EDITPAGE CHANGE128FILLFORM CHANGE128NONE CHANGE40ANYCHANGES \ + CHANGE40COMMENTING CHANGE40NONE CHANGE40PAGELAYOUT", + ), + ("PDFPrintAllowedEnum.", "PRINT128HIGHRESOLUTION PRINT128LOWRESOLUTION PRINT128NONE PRINT40HIGHRESOLUTION PRINT40NONE"), + ("PDFTrimMarkWeight.", "TRIMMARKWEIGHT0125 TRIMMARKWEIGHT025 TRIMMARKWEIGHT05"), + ("PDFXStandard.", "PDFX1A2001 PDFX1A2003 PDFX32002 PDFX32003 PDFX42007 PDFXNONE"), + ("PageMarksTypes.", "Japanese Roman"), + ("SVGCSSPropertyLocation.", "ENTITIES PRESENTATIONATTRIBUTES STYLEATTRIBUTES STYLEELEMENTS"), + ("SVGDTDVersion.", "SVG1_0 SVG1_1 SVGBASIC1_1 SVGTINY1_1 SVGTINY1_1PLUS SVGTINY1_2"), + ("SVGDocumentEncoding.", "ASCII UTF16 UTF8"), + ("SVGFontSubsetting.", "ALLGLYPHS COMMONENGLISH COMMONROMAN GLYPHSUSED GLYPHSUSEDPLUSENGLISH GLYPHSUSEDPLUSROMAN None"), + ("SVGFontType.", "CEFFONT OUTLINEFONT SVGFONT"), ( "Compatibility.", "ILLUSTRATOR10 ILLUSTRATOR11 ILLUSTRATOR12 ILLUSTRATOR13 ILLUSTRATOR14 ILLUSTRATOR15 ILLUSTRATOR16 ILLUSTRATOR17 \ diff --git a/docs/mcp.md b/docs/mcp.md index d4cb072175..3e795ea765 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3131,7 +3131,13 @@ through `$`: explicit `null` throws a type error. `app.userInteractionLevel` is `UserInteractionLevel.DISPLAYALERTS` at the start of each run. The enumerations `ExportType`, `Compatibility`, `PDFCompatibility`, `PDFBoxType`, `EPSPreview`, `EPSPostScriptLevelEnum`, `PDFOverprint`, `SaveOptions` and `UserInteractionLevel` hold strings such as - `"ExportType.PNG24"`. + `"ExportType.PNG24"`. The enumerations of the options that keep their defaults (`OutputFlattening`, + `CompressionQuality`, `ColorConversion`, `ColorDestination`, `ColorProfile`, `DownsampleMethod`, + `MonochromeCompression`, `PageMarksTypes`, `PDFChangesAllowedEnum`, `PDFPrintAllowedEnum`, `PDFTrimMarkWeight`, + `PDFXStandard`, `SVGCSSPropertyLocation`, `SVGDocumentEncoding`, `SVGDTDVersion`, `SVGFontSubsetting` and + `SVGFontType`) are defined too: the default member is accepted, and another member throws as not available yet. A + path whose real file name is not valid UTF-8 throws `Script file path is not valid UTF-8` before anything is written + or opened. VectorCraft's own rules: each path is checked as a `File` opened for reading or writing is checked, before the command runs. A path outside the script's folders throws `Script file access denied`, also when it is an open document's file, a link that leads outside them, or the settings folder; a read-only file throws `Script file is diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 4e695e800b..0547365012 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1127,7 +1127,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Scripts: `document.characterStyles` and `document.paragraphStyles` add, find, rename, redefine, apply and remove character and paragraph styles, with the Normal styles listed first and kept, and a text range lists the styles its text is in, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyle/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyle/ and https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ describe them (`docs/mcp.md`). Style names of 1 to 256 characters without control characters, and at most 4,096 styles named in one run, are VectorCraft's own rules. Load Character Styles, Load Paragraph Styles and Load All Styles refuse a file larger than 64 MB. A paragraph style's character attributes are not there yet. `crates/engine/src/tests/script_styles.rs`. - Scripts: a text frame's `nextFrame` and `previousFrame` read and set its links to the frames before and after it, `areaText` and `pathText` thread a new frame to a base frame, and `document.stories` lists the stories, each with its frames in thread order and its text across them as one text range with its characters, words and paragraphs, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItem/, https://ai-scripting.docsforadobe.dev/jsobjref/Story/ and https://ai-scripting.docsforadobe.dev/jsobjref/Stories/ describe them; `text.thread.setNeighbor` links or unlinks two frames by id (`docs/mcp.md`). Which links are refused, and how a story is listed and found, are VectorCraft's own rules. `crates/engine/src/tests/script_threads.rs`. - Scripts: `PageItem.tags` reads, adds, renames and deletes an object's tags, name and value pairs that the native file keeps, and `Document.tags` reads, renames and deletes the tags of every page item but adds none (its `add` throws; a script adds a tag through the page item's `tags`), as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Tags/ and https://ai-scripting.docsforadobe.dev/jsobjref/Tag/ describe them, through `object.tags` and the `object.tag.*` commands, at most 64 tags an object (`docs/mcp.md`). `crates/engine/src/tests/script_tags.rs`. - - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe, and read and write only where the script's `File` objects may; the warnings of each save, export and open go to the console (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. + - Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe (the enumerations of the options that keep their defaults included), and read and write only where the script's `File` objects may, refusing a path whose real file name is not valid UTF-8; the warnings of each save, export and open go to the console (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`. - Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). A script can check a member with `hasOwnProperty`, and can read a collection by name and name `activeDocument`, `documents` and `selection` without `app.` (https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/). A key such as `1` is an array index and reads that position; in `pageItems` and `documents`, a number that is not an array index, such as `-1` or `1.5`, is looked up by name when the key is the text JavaScript writes for that number. VectorCraft's own rule. `app.executeMenuCommand` runs the menu items Select All, Deselect, Group, Ungroup, Make and Release Clipping Mask, Make and Release Compound Path, and Fit to Artwork Bounds by their menu command names (https://community.adobe.com/questions-652/a-list-of-illustrator-menu-commands-we-can-call-from-javascript-769510, https://gist.github.com/shalakolee/df3246659d4289eb99149b9ed00a00ee). The `parent` of a page item at the top of a layer is a `Layer` with `name`, `typename` and `toString`. A page item's `blendingMode` reads and sets its blend mode with the `BlendModes` values (https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/). `Document.views` lists the document's drawn windows with their bounds, center, zoom and screen mode (https://ai-scripting.docsforadobe.dev/jsobjref/View/). Zoom follows each window's displayed percentage, including display density with Display Print Size at 100% Zoom enabled; bounds retain the physical camera scale. View objects keep their targets when windows are renumbered. View changes run no command, add no undo step, and remain when a script fails. A center outside the canvas after coordinate conversion throws a `RangeError`. `Document.layers`, `Document.activeLayer`, type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`. - Scripts: `app.redraw()` (https://ai-scripting.docsforadobe.dev/jsobjref/Application/) returns without changing the documents or adding an undo step; the app goes on drawing the documents as they were before the run until the run ends. VectorCraft's own rule. `crates/engine/src/tests/script_dom.rs`. From dbcd460c53f70b8d2baebf40599e7fa76af0ed8e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 07:56:01 -0800 Subject: [PATCH 253/264] Tests: let the Move dialog close before the units test opens Rectangle dialog_lengths_show_in_the_general_unit confirmed the Move dialog and opened the Rectangle dialog in the same frame. Move holds its OK, so it stays on the stack until the next frame, and Rectangle is laid out once over it and once more, unseen, after Move leaves. The test drew two frames and passed only because the frame after the selection change ran a second pass for the Properties panel. With that panel drawn in one pass, the second frame showed nothing and the assertion failed. The test now draws a frame after OK, so Move has closed before the selection change and the Rectangle dialog. Its assertions are unchanged. --- crates/ui-egui/src/panels/tests_units.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/panels/tests_units.rs b/crates/ui-egui/src/panels/tests_units.rs index ecac244136..d5837ffed5 100644 --- a/crates/ui-egui/src/panels/tests_units.rs +++ b/crates/ui-egui/src/panels/tests_units.rs @@ -101,6 +101,8 @@ fn dialog_lengths_show_in_the_general_unit() { window.type_text("10 mm"); window.key(egui::Key::Tab, egui::Modifiers::NONE); confirm_dialog(&mut window.app()); + // The Move dialog holds its OK, so it leaves the stack in the next frame. + window.frame(); let square = { let app = window.app(); let st = app.session.active().unwrap(); From aa3415aa5e6d8a4f0b09a2511a80f191d739d34c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 08:09:18 -0800 Subject: [PATCH 254/264] Dimension: the Alt hover box is described as reaching the outside of the stroke The parity doc, docs/dimensions.md and two comments said the box shown while hovering a path with Alt held goes through the path's outermost points. It follows the box the strokes paint, which reaches 0.5 pt past those points for a centered 1 pt stroke. --- crates/tools/src/dimension.rs | 5 +++-- docs/dimensions.md | 4 ++-- docs/target-app-parity.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/tools/src/dimension.rs b/crates/tools/src/dimension.rs index e2337b5be0..b63dc44d9a 100644 --- a/crates/tools/src/dimension.rs +++ b/crates/tools/src/dimension.rs @@ -177,7 +177,8 @@ fn orientation_at(a: Point, b: Point, p: Point) -> Orientation { .map_or(Orientation::Aligned, |(_, orientation)| orientation) } -/// The box through a path's outermost points ([`whole_ends`]): left, top, right and bottom. +/// The box through a path's outermost points moved out to its strokes ([`whole_ends`]): left, top, +/// right and bottom. fn extent_box([(left, right), (top, bottom)]: [(Point, Point); 2]) -> Rect { Rect::new(left.x, top.y, right.x, bottom.y) } @@ -2875,7 +2876,7 @@ mod tests { } } - /// With Alt held, hovering a path shows the box through its outermost points as a Smart Guide, + /// With Alt held, hovering a path shows the box its strokes paint as a Smart Guide, /// and a click starts placing a dimension of the whole path: above or below it, its width; /// beside it, its height. A drag places it on release. Without Alt the same click picks a point. #[test] diff --git a/docs/dimensions.md b/docs/dimensions.md index 27972418af..a7359497aa 100644 --- a/docs/dimensions.md +++ b/docs/dimensions.md @@ -93,8 +93,8 @@ The **Dimension Tool** is in the Modify section of the toolbar. Its strip offers The [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes plotting an object's horizontal and vertical dimensions by holding Alt - (Option on macOS) over its path. With Alt held, hovering a path shows a box through the path's - outermost points, as a Smart Guide when Smart Guides are on and in the tool's own color when + (Option on macOS) over its path. With Alt held, hovering a path shows the box the path's strokes + paint (described below), as a Smart Guide when Smart Guides are on and in the tool's own color when they are off, with its width and height beside the pointer when Measurement Labels are on. Clicking the path, then moving and clicking, places a dimension of the whole path; dragging out from the path places it on release. The rest is VectorCraft's own rule. With diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 51ba964c82..fa9187df61 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -757,7 +757,7 @@ since 2026-10-01. **Drawing tools, Ellipse tool circle from its center sized to touch a path:** By VectorCraft's own rule, with Smart Guides and Snap to Tangent on, a circle drawn from its center (Alt and Shift) snaps its radius so that the circle touches a nearby path whenever the radius comes within the snapping tolerance of that size. The touch point is where the line from the center meets a straight segment or a curve square, inside a segment or at an anchor where the path runs smoothly, also where a curve's handle lies on that anchor. A circle can touch another circle from outside or touch it from inside, and a center inside a closed path gives a circle that touches the path from within. A corner or an open path's end is not offered, nor a curve around the same center. The touch point shows the "tangent" label and the line from the center as guides; the radius is measured along the Constrain Angle's axes, as the drawn box is, and Space moves the circle at the size it snapped to, which it keeps when Space is let go. The snap does not apply to an ellipse (no Shift). When an anchor, center or crossing is within the snapping tolerance of the pointer, or the dragged corner snapped onto one, the circle is not resized to touch a path. Snap to Grid and pixel snapping place the drawn point instead, also when turned on during the drag, and turning Snap to Tangent off during the drag stops the snap. A press with a small jitter is still a click rather than a drag. At most 256 segments near that radius are measured per pointer move, the ones nearest the pointer. `a_circle_from_its_center_snaps_its_radius_to_touch_a_line`, `a_circle_from_its_center_snaps_to_touch_another_circle_from_outside_and_inside`, `a_circle_from_its_center_snaps_to_touch_a_curve`, `a_circle_from_its_center_keeps_its_radius_without_the_snap_or_a_smooth_touch`, `a_circle_from_its_center_prefers_an_anchor_and_measures_the_segments_nearest_the_pointer`, `a_circle_snapped_to_touch_keeps_to_the_constrain_angle`, `a_circle_from_its_center_does_not_snap_to_touch_with_the_grid_or_pixels`, `a_jittered_alt_shift_press_beside_a_path_is_a_click`, `a_circle_from_its_center_prefers_an_anchor_or_a_crossing_at_the_pointer` and `a_circle_from_its_center_touches_a_path_at_an_anchor_with_retracted_handles` cover it. **Drawing tools, selected Dimension extension-line style (#7078):** Properties › Dimension exposes the selected editable dimension's existing extension-line color and weight. Both extension lines share that style, independently of the main dimension line and label. Apply to All keeps its full-style behavior for editable dimensions, leaving a protected dimension unchanged; Set as Default keeps the whole style for a new dimension created without explicit options, without changing existing dimensions. The dimension remains editable. Four cases in `crates/ui-egui/tests/dimension_extension_properties.rs` verify actual Properties input, both canvas extension lines, independent main-line/label styling, full-style Apply to All, locked and unselected controls, defaults/new dimensions, Undo/Redo, and native save/reopen with further editing. Existing document-color conversion is unchanged. The measured geometry and existing snapping behavior are unchanged; no whole-Dimension completion or score/hour change is claimed. **Drawing tools, Dimension tool horizontal and vertical linear dimensions:** A linear dimension between two clicked points or dragged out from a segment is aligned, horizontal or vertical, chosen by where the pointer moves while it is placed, and a click again by the second point gives aligned; `dimension.create` and `dimension.update` take `orientation`, and the dimension stays linked to the anchors it measures, keeps its orientation when it or the art turns, with a line that lay outside the points kept outside them; an unlinked horizontal or vertical dimension that is reflected has its line on the reflected side. `the_pointer_chooses_aligned_horizontal_or_vertical`, `two_points_measure_horizontally_vertically_or_aligned`, `clicking_again_by_the_second_point_places_an_aligned_dimension`, `a_segment_drag_measures_horizontally_vertically_or_aligned`, `points_on_a_vertical_line_measure_aligned`, `horizontal_and_vertical_dimensions_draw_lines_along_their_axis`, `turned_horizontal_dimensions_stay_horizontal`, `a_linked_horizontal_dimension_keeps_its_gap_from_turned_art`, `a_linked_horizontal_dimension_below_or_between_its_points_follows_turned_art`, `a_reflected_horizontal_dimension_keeps_its_line_on_the_reflected_side`, `a_dimension_without_an_orientation_reads_as_aligned`, `dimension_orientation_is_checked` and `a_turned_dimension_keeps_its_line_on_its_side` cover it. -**Drawing tools, Dimension tool overall width and height of a path:** The [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes plotting an object's horizontal and vertical dimensions with Alt (Option on macOS) held over its path. By VectorCraft's own rule, hovering a path with Alt held shows a box through its outermost points (a Smart Guide when Smart Guides are on); a click then a placing click, or a drag out from the path, places a linear dimension of the whole path, and the pointer above or below the path gives its width and beside it its height. `dimension.create` takes the `extent` source, whose points are the outermost points of the path's curves, read again after every edit, so a turned path shows its new overall size, and the line keeps its distance from the whole path. With Use Preview Bounds on or off, the box and the dimension reach the outside of the path's strokes, which is the size W and H show with Use Preview Bounds on when the path is not rotated and has no geometry effect (geometry effects such as Offset Path are not included), and the source records `"preview":true` so the dimension measures to there after later edits, a new stroke weight included; a dimension saved without it keeps measuring between the outermost points. `an_alt_click_or_drag_on_a_path_places_its_overall_width_or_height`, `an_alt_placed_dimension_measures_the_outside_of_the_stroke_with_preview_bounds_on_or_off`, `a_dimension_of_a_whole_path_measures_its_overall_width_and_height`, `a_dimension_of_a_whole_path_with_preview_bounds_measures_the_outside_of_the_stroke`, `a_dimension_of_a_whole_path_stays_clear_of_the_path_it_draws` and `a_dimension_of_a_whole_path_survives_a_native_file` cover it. +**Drawing tools, Dimension tool overall width and height of a path:** The [linear dimensions help](https://helpx.adobe.com/illustrator/desktop/measure-and-align/plot-and-measure/plot-linear-dimensions-of-objects.html) describes plotting an object's horizontal and vertical dimensions with Alt (Option on macOS) held over its path. By VectorCraft's own rule, hovering a path with Alt held shows the box its strokes paint, which reaches 0.5 pt past its outermost points for a centered 1 pt stroke (a Smart Guide when Smart Guides are on); a click then a placing click, or a drag out from the path, places a linear dimension of the whole path, and the pointer above or below the path gives its width and beside it its height. `dimension.create` takes the `extent` source, whose points are the outermost points of the path's curves, read again after every edit, so a turned path shows its new overall size, and the line keeps its distance from the whole path. With Use Preview Bounds on or off, the box and the dimension reach the outside of the path's strokes, which is the size W and H show with Use Preview Bounds on when the path is not rotated and has no geometry effect (geometry effects such as Offset Path are not included), and the source records `"preview":true` so the dimension measures to there after later edits, a new stroke weight included; a dimension saved without it keeps measuring between the outermost points. `an_alt_click_or_drag_on_a_path_places_its_overall_width_or_height`, `an_alt_placed_dimension_measures_the_outside_of_the_stroke_with_preview_bounds_on_or_off`, `a_dimension_of_a_whole_path_measures_its_overall_width_and_height`, `a_dimension_of_a_whole_path_with_preview_bounds_measures_the_outside_of_the_stroke`, `a_dimension_of_a_whole_path_stays_clear_of_the_path_it_draws` and `a_dimension_of_a_whole_path_survives_a_native_file` cover it. **Drawing tools, Dimension tool points that are not anchors follow the art:** A clicked point on a segment stays at its place along the segment, also when the segment curves, and a point off the art is linked to anchors (or, when the anchors lie on one line, anchors and handles) of the path, so both ends of the dimension follow when the art is moved, scaled, turned or reflected, also when the point was placed by a Smart Guide and when the dimension is saved and opened again; a linked linear dimension of reflected art (other than art on one line) has its line on the reflected side; deleting the art, changing its anchor count or whether it is closed, turning an angle's arm into a curve, or making a measured circle or arc no longer circular leaves the dimension where it was, no longer linked, instead of removing it. `a_dimension_to_a_point_on_a_segment_follows_the_art_at_both_ends`, `a_dimension_to_a_point_off_the_art_moves_with_the_art`, `a_dimension_whose_art_changes_its_anchors_stays_where_it_was`, `a_dimension_whose_art_is_opened_stays_where_it_was`, `angle_and_arc_dimensions_whose_art_no_longer_fits_stay_where_they_were`, `a_dimension_that_cannot_be_drawn_again_keeps_its_art`, `a_linked_dimension_of_reflected_art_has_its_line_on_the_reflected_side`, `a_dimension_to_a_point_off_a_line_follows_the_line`, `a_point_off_an_arch_is_reflected_with_the_arch`, `a_point_beside_an_almost_straight_curve_follows_it`, `a_point_off_a_loop_with_its_anchors_in_one_place_follows_it`, `a_point_beside_a_reflected_line_moves_as_a_half_turn_would`, `a_point_on_a_segment_stays_on_it_when_the_segment_curves`, `a_linked_dimension_of_a_reflected_curve_has_its_line_on_the_reflected_side`, `a_dimension_of_art_reflected_across_its_points_changes_sides`, `a_dimension_between_paths_reflected_each_in_its_own_way_keeps_its_offset`, `free_points_survive_a_native_file`, `dimension_free_points_are_checked`, `points_off_anchors_are_held_against_the_path` and `a_point_smart_guides_place_is_held_against_the_path` cover it. **Drawing tools, Dimension tool points on a Smart Guide stay on the guide:** By VectorCraft's own rule, a clicked point that lies on a Smart Guide already, such as one in line with an object's center, stays where the pointer is when no anchor is within 8 pixels and no segment is within the Smart Guides snapping tolerance, instead of moving onto a segment farther than that tolerance and within 8 pixels; with Snap to Grid or Snap to Pixel on, a point stays on the grid or the whole pixel those options give. `a_point_on_a_guide_stays_on_the_guide` covers it. **Drawing tools, Dimension tool second point without construction guides through a first point off the anchors:** By VectorCraft's own rule, with Smart Guides on, the second Linear point does not snap to the construction guides through a first point that is not on an anchor, so a click beside a segment straight below such a first point lands on the segment; after a first point picked on an anchor, the construction guides through it still apply. The second point still snaps to anchors, centers and alignment lines, and with Snap to Perpendicular or Snap to Tangent on, it lands where the line from the first point meets a segment square or grazes a curve. `a_point_on_a_guide_stays_on_the_guide`, `the_second_point_after_an_anchor_lands_on_construction_guides`, `the_second_point_lands_square_to_a_segment_or_grazing_a_curve` and `linear_picks_show_and_snap_to_smart_guides` cover it. From 3d628608c6a488ec490fe759f888402cd84eb9d8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 08:09:21 -0800 Subject: [PATCH 255/264] Docs: the Flatpak override clears fallback-x11 before it allows X11 --- docs/development.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development.md b/docs/development.md index ce215da81f..d176088bcb 100644 --- a/docs/development.md +++ b/docs/development.md @@ -134,7 +134,7 @@ The window runs natively on Wayland (eframe's `wayland` feature) and on X11. On - **Clipboard owners that never answer (#510):** reading the clipboard waits on the app that owns it: arboard gives up on an X11 owner after 4 s for each format it tries, and a Wayland read waits for the owner to send its data. So on Linux the check that enables the Paste menu items runs on a background thread with a second clipboard handle (`crates/ui-egui/src/clipboard_probe.rs`, installed as `Services::clipboard_probe`), only while nothing is copied in the app and a document is open, and the window keeps drawing. Every arboard read on Linux and the BSDs, including the UI thread's (a paste, and a Copy or Cut checking what the clipboard held), runs on a worker thread with a handle of its own and waits 2 s at most: an owner that never sends its data costs one read that wait, and later reads fail at once until it answers. A paste's bitmap read waits up to 10 s on the paste's background thread, so the UI thread does not wait for it. When one of a paste's reads gets no answer in its 2 s, or a paste follows a read that has not been answered yet, such as the paste's own check whether the clipboard still holds what VectorCraft copied, the paste waits on that thread for that read's answer, up to 10 s after the read was sent, and pastes what it holds. When the answer is what VectorCraft copied, holds nothing to paste, or does not come, the paste takes the internal clipboard. On X11, quitting within 25 s of a read that got no answer waits for that read to end, so the app's own handle is the last one and hands what it copied to the clipboard manager when one runs. That includes a read of the Paste menu check's handle: quitting waits up to 27 s for the background thread to drop it before the app drops its own, and quits after that wait even when the handle has not been dropped. The app takes its windows off screen before these waits (`apps/vectorcraft/src/quit_windows.rs`). An X11 main window, an XWayland one included, is hidden. winit cannot hide a native Wayland window, so on Linux the app attaches no buffer to the main window's surface, which unmaps it while the window and its connection stay open for the Wayland clipboard. On Linux the X11 windows of floating panels and documents are unmapped through a second X11 connection. On native Wayland, floating panels and documents are normally drawn inside the main window; on the BSDs a native Wayland main window stays on screen until the waits end. Windows and macOS keep the check on the UI thread: Windows only asks which formats the clipboard holds, macOS asks the pasteboard server. - **Copied files:** files copied in a file manager (`text/uri-list`; `CF_HDROP` on Windows, file URLs on macOS) paste as the first one that is art (SVG, PDF, EPS, EMF/WMF or a bitmap; a `.ai` or `.ait` file from the editing data it holds, else as the PDF or PostScript it holds), before the clipboard's other formats (which include the files' paths as text). - **Dropping files on the window does not work under Wayland:** winit 0.30, which eframe 0.37 runs on, has no Wayland drag and drop ([winit#1881](https://github.com/rust-windowing/winit/issues/1881), added in winit 0.31; [egui#1563](https://github.com/emilk/egui/issues/1563)), so no `dropped_files` arrive. Until eframe moves to winit 0.31: copy the files in the file manager and paste them, use File › Place or Open, or open the window through XWayland, where drops work: set **Preferences › Performance › Linux Display Server** to **X11 (XWayland)** and restart (#1151), or start the app with `WAYLAND_DISPLAY= vectorcraft`. The preference (`linuxDisplayServer`, read at startup in `apps/vectorcraft/src/main.rs`, shown on Linux only) has winit open the window on X11 (`EventLoopBuilderExtX11::with_x11`) when the session is Wayland, `DISPLAY` is set and the X11 libraries winit loads are installed (`apps/vectorcraft/src/xwayland.rs` reads `ldconfig -p` and the usual library directories); otherwise the window opens on Wayland and the log says why. Unlike clearing `WAYLAND_DISPLAY`, it leaves the clipboard on the compositor's own. -- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found (): opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). When the window stays on Wayland on such a session, the log says why (#5622): `no pen in /proc/bus/input/devices`, `can't look for a pen` with the reason, `VECTORCRAFT_NATIVE_WAYLAND is set`, `there is no X display (DISPLAY is unset)`, or that the X11 libraries aren't all installed. The Flatpak gets no X display on a Wayland session (`--socket=fallback-x11`); `flatpak override --user --socket=x11 ai.storyteller.vectorcraft` gives it one. `GDK_BACKEND=x11` does not move the window to XWayland: winit does not read it. Under X11 the log lists the pens the X server lists (`tablet: pens listed: …`, for example `xwayland-tablet stylus:16` under XWayland, or `the X server lists no pen`) and the first event from each pen (`tablet: events arrive from the pen …`). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way. +- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found (): opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). When the window stays on Wayland on such a session, the log says why (#5622): `no pen in /proc/bus/input/devices`, `can't look for a pen` with the reason, `VECTORCRAFT_NATIVE_WAYLAND is set`, `there is no X display (DISPLAY is unset)`, or that the X11 libraries aren't all installed. The Flatpak gets no X display on a Wayland session (`--socket=fallback-x11`); `flatpak override --user --nosocket=fallback-x11 --socket=x11 ai.storyteller.vectorcraft` gives it one and keeps its Wayland socket. `--socket=x11` alone is not enough: while `fallback-x11` is set, Flatpak gives the app no X display whenever Wayland is available. `GDK_BACKEND=x11` does not move the window to XWayland: winit does not read it. Under X11 the log lists the pens the X server lists (`tablet: pens listed: …`, for example `xwayland-tablet stylus:16` under XWayland, or `the X server lists no pen`) and the first event from each pen (`tablet: events arrive from the pen …`). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way. - **Pen pressure under X11 and XWayland (#764):** winit 0.30 hands a pen to an X11 window as a mouse, without its pressure. When the window is on X11, XWayland included, the desktop app opens a second X connection (x11rb's `RustConnection`) and reads XInput2 raw events for every device (`apps/vectorcraft/src/tablet.rs`, from PhotoCraft's `crates/tablet`). A device with an `Abs Pressure` valuator is a pen, unless its XInput type is `TOUCHPAD` or `TOUCHSCREEN`. While a pen is the pointer that moved last, its pressure, scaled from the valuator's range to 0..1, reaches the tools that use pressure: the Paintbrush's pressure-sensitive brushes and the Liquify tools' Use Pressure Pen. The reader also reads `Abs Tilt X` and `Abs Tilt Y` (from a pen that has both) in degrees, scaled to ±60° when the valuator's range does not fit in ±90, and `Abs Rotary Z` (an Art Pen's barrel rotation) as a turn with the middle of the range at 0°; the Paintbrush records them for brushes with Tilt, Bearing and Rotation variation. A pen device whose name or XInput type contains `eraser` (in any case) is the pen's eraser end: while the pointer is over the window, the canvas selects the Eraser tool when the eraser end moves, and it selects the tool used before when the tip moves again (`crates/ui-egui/src/stylus.rs`). The X server needs XInput 2.1 or later; otherwise the log has a `tablet pressure:` warning with the reason, and the pen draws at full pressure. - **Pen tilt and rotation on macOS (#764):** with each tablet event's pressure (#852), `apps/vectorcraft/src/mac_tablet.rs` reads its `tilt`, −1..1 on each axis, scaled to ±60° with each axis keeping AppKit's sign (x positive to the right, y positive towards the bottom and the user), and its `rotation`, negated to run clockwise. Until a pen reports a tilt or a rotation other than 0 after it comes near the tablet, that value reads as none, since a pen without one reports 0. The Paintbrush records them as it does under X11. From 2791318a353861d5bb8066b1f961228c59d37687 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 18:15:06 +0100 Subject: [PATCH 256/264] Keep artwork visible behind live effect controls --- crates/ui-egui/src/dialogs/effect.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/ui-egui/src/dialogs/effect.rs b/crates/ui-egui/src/dialogs/effect.rs index 06fa47f045..057eac94eb 100644 --- a/crates/ui-egui/src/dialogs/effect.rs +++ b/crates/ui-egui/src/dialogs/effect.rs @@ -350,9 +350,14 @@ fn launch(app: &mut VectorcraftApp, mut open: Open, baseline: Map // Free Distort's Reset puts the corners back on the box, wherever they were when it opened. let reset_to = (id == super::free_distort::FREE_DISTORT) .then(|| form::fields_of(&rows, &Map::from_iter([("corners".to_string(), json!(super::free_distort::IDENTITY))]))); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); let dialog = HostedParamDialog::new(&ctx, "effect", fields, move |f| { let rows = effect_params(&cx, f); let dialog = ParamDialog::new("effect", title.clone(), rows).values(Bind::bound(f)).previews(true); + let dialog = match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + }; let dialog = match &reset_to { Some(target) => dialog.reset_to(target.clone()), None => dialog, From 452281a2694aa938fc5ffa83c736f9bc6c4be9f8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 09:33:37 -0800 Subject: [PATCH 257/264] Smooth Bridge: a selected group of circles is bridged Smooth Bridge refused a selected group with "select two or more circles to bridge", even when every object in the group was a circle, so grouping circles first and selecting the group did nothing. The command now takes the objects inside each selected group (at any depth; a clipping group stays one object), so a group of circles is bridged in place, inside the group. A group that holds anything other than a circle is still refused, as before. The dialog's Reach field counts a selected group's objects too, so it is available when a selected group holds three or more circles; a circle selected together with its group counts once. --- .../engine/src/cmd/addons/pathtools/bridge.rs | 24 ++++++-- .../src/cmd/addons/pathtools/bridge/tests.rs | 57 +++++++++++++++++++ crates/ui-egui/src/addons/pathtools/bridge.rs | 52 ++++++++++++++++- docs/mcp.md | 8 ++- 4 files changed, 132 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge.rs b/crates/engine/src/cmd/addons/pathtools/bridge.rs index 4d4eb9cdf8..457114f820 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge.rs @@ -3,7 +3,7 @@ //! the bridges connect, replacing the circles or added above them. use serde_json::{Value, json}; -use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_doc::{Document, Node, NodeId, NodeKind}; use vectorcraft_geom::PathData; use vectorcraft_pathops::addons::pathtools as pt; @@ -34,7 +34,7 @@ pub(super) fn specs() -> Vec { "Smooth Bridge", ["Object", "Plug-ins", "Path Precision Tools"], None, - "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", + "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection; a group, other than a clipping group, gives the objects inside it)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", has_selection, bridge )] @@ -54,8 +54,8 @@ fn bridge(s: &mut Session, p: &Value) -> Result { None => pt::ArcRadius::Share(percent.unwrap_or(RADIUS) / 100.0), }; let keep = switch_or(p, "keepOriginals", false, C)?; - let mut roots = checked_ids_or_selection(s, p, C)?; - // An id given twice is one circle. + let mut roots = members(&s.doc()?.doc, &checked_ids_or_selection(s, p, C)?); + // An id given twice, or a circle given with its group, is one circle. roots.sort_unstable(); roots.dedup(); if roots.len() > pt::MAX_BRIDGED_CIRCLES { @@ -140,6 +140,22 @@ fn bridge(s: &mut Session, p: &Value) -> Result { Ok(out) } +/// The objects `ids` names, with each group among them (a clipping group excepted) as the objects +/// inside it, at any depth. +fn members(d: &Document, ids: &[NodeId]) -> Vec { + fn visit(n: &Node, out: &mut Vec) { + match &n.kind { + NodeKind::Group { children, clip: false } => children.iter().for_each(|c| visit(c, out)), + _ => out.push(n.id), + } + } + let mut out = vec![]; + for n in ids.iter().filter_map(|&id| d.node(id)) { + visit(n, &mut out); + } + out +} + /// The ids of `circles` at indices `at`, in paint order (the circles are listed in paint order). fn roots_of(circles: &[(NodeId, pt::Circle)], at: &[usize]) -> Vec { at.iter().filter_map(|&i| circles.get(i)).map(|(id, _)| *id).collect() diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index 745f216b68..8409ac2be6 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -354,3 +354,60 @@ fn locked_and_hidden_circles_are_not_bridged() { s.execute("object.hide", &json!({})).unwrap(); assert!(err(&mut s, json!({"ids": [a.0, b.0]})).contains("select two or more circles to bridge")); } + +fn group(s: &mut Session, ids: &[NodeId]) -> NodeId { + NodeId(s.execute("object.group", &json!({"ids": ids.iter().map(|i| i.0).collect::>()})).unwrap()["id"].as_u64().unwrap()) +} + +fn children(s: &Session, id: NodeId) -> Vec { + s.doc().unwrap().doc.node(id).unwrap().children().unwrap().iter().map(|n| n.id).collect() +} + +#[test] +fn a_selected_group_of_circles_bridges_the_circles_inside_it() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let g = group(&mut s, &[a, b]); + select(&mut s, &[g]); + let steps = s.doc().unwrap().history.undo.len(); + let r = s.execute(BRIDGE, &json!({})).unwrap(); + assert_eq!(r["id"], json!(b.0), "two circles, joined in the upper one's place"); + assert_eq!(top_level(&s), [g]); + assert_eq!(children(&s, g), [b], "the outline stays in the group"); + assert!(area(&s, b) > 2.0 * std::f64::consts::PI * 400.0); + assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(children(&s, g), [a, b]); + + // A group inside a group, given with one of its own circles, and a loose circle: three circles, so the reach + // applies. + let c = circle(&mut s, 300.0, 100.0, 20.0); + let outer = group(&mut s, &[g]); + let r = s.execute(BRIDGE, &json!({"ids": [outer.0, a.0, c.0], "reach": 30})).unwrap(); + assert_eq!(r["ids"], json!([b.0]), "the grouped circles are joined"); + assert_eq!(r["alone"], json!([c.0]), "the far circle is out of reach"); +} + +#[test] +fn a_selected_group_with_other_objects_or_a_clipping_group_is_refused() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let square = NodeId(s.execute("shape.rectangle", &json!({"x": 200, "y": 200, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let g = group(&mut s, &[a, b, square]); + let steps = s.doc().unwrap().history.undo.len(); + assert!(err(&mut s, json!({"ids": [g.0]})).contains("select two or more circles to bridge")); + assert_eq!(children(&s, g), [a, b, square]); + assert_eq!(s.doc().unwrap().history.undo.len(), steps, "nothing changed, no undo step"); + + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let mask = circle(&mut s, 130.0, 100.0, 80.0); + select(&mut s, &[a, b, mask]); + let clip = NodeId(s.execute("object.clippingMask.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let before = top_level(&s); + assert!(err(&mut s, json!({"ids": [clip.0]})).contains("select two or more circles to bridge")); + assert_eq!(top_level(&s), before); +} diff --git a/crates/ui-egui/src/addons/pathtools/bridge.rs b/crates/ui-egui/src/addons/pathtools/bridge.rs index 76b3627f76..9cdf738b18 100644 --- a/crates/ui-egui/src/addons/pathtools/bridge.rs +++ b/crates/ui-egui/src/addons/pathtools/bridge.rs @@ -40,8 +40,8 @@ fn params(fields: &DialogFields) -> Value { /// Opens Smooth Bridge's dialog on the command's defaults. pub(crate) fn open(app: &mut VectorcraftApp) -> Result { // The reach applies to three or more circles; two are bridged at any distance. Counted once, before a preview - // replaces the selection with its result. - let many = app.session.doc().map(|doc| doc.selection.objects.len() > 2).unwrap_or(true); + // replaces the selection with its result, with a selected group counting the objects inside it. + let many = app.session.doc().map(|doc| members(&doc.doc, &doc.selection.objects) > 2).unwrap_or(true); let fields = DialogFields::from_pairs([ ("radius", FieldValue::Number(RADIUS)), ("constantGap", FieldValue::Bool(false)), @@ -72,6 +72,24 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result { }) } +/// How many objects the command bridges for objects `ids`: each one, or for a group (a clipping group excepted) the +/// objects inside it, at any depth; an object given twice, or with its group, counts once. +fn members(doc: &vectorcraft_doc::Document, ids: &[vectorcraft_doc::NodeId]) -> usize { + fn visit(n: &vectorcraft_doc::Node, out: &mut std::collections::BTreeSet) { + match &n.kind { + vectorcraft_doc::NodeKind::Group { children, clip: false } => children.iter().for_each(|c| visit(c, out)), + _ => { + out.insert(n.id); + } + } + } + let mut out = std::collections::BTreeSet::new(); + for n in ids.iter().filter_map(|&id| doc.node(id)) { + visit(n, &mut out); + } + out.len() +} + #[cfg(test)] mod tests { use serde_json::{Value, json}; @@ -158,6 +176,36 @@ mod tests { assert_eq!(geometry(&panel.app()), original); } + #[test] + fn reach_counts_the_circles_inside_a_selected_group() { + use crate::tests::panel_harness::Panel; + + for (xs, many) in [(&[100.0, 124.0][..], false), (&[100.0, 124.0, 148.0][..], true)] { + let mut app = bridge_app(xs); + let ids: Vec = app.session.doc().unwrap().selection.objects.iter().map(|id| id.0).collect(); + let group = app.run("object.group", json!({ "ids": ids })).unwrap()["id"].as_u64().unwrap(); + app.run("select.set", json!({"ids": [group]})).unwrap(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + menus::invoke(&mut panel.app(), super::COMMAND, Value::Null); + panel.frame(); + assert_eq!(panel.enabled("Reach"), many, "{} circles in the group", xs.len()); + panel.click("OK"); + panel.frame(); + let inside = panel.app().session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(group)).unwrap().children().unwrap().len(); + assert_eq!(inside, 1, "the circles in the group became one shape"); + } + // A group of two circles selected together with one of them: still two circles. + let mut app = bridge_app(&[100.0, 124.0]); + let ids: Vec = app.session.doc().unwrap().selection.objects.iter().map(|id| id.0).collect(); + let group = app.run("object.group", json!({ "ids": ids })).unwrap()["id"].as_u64().unwrap(); + app.run("select.set", json!({"ids": [group, ids[0]]})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects.len(), 2); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + menus::invoke(&mut panel.app(), super::COMMAND, Value::Null); + panel.frame(); + assert!(!panel.enabled("Reach"), "a circle selected with its group counts once"); + } + #[test] fn constant_gap_shows_the_gap_and_bridges_many_circles_within_reach() { let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); diff --git a/docs/mcp.md b/docs/mcp.md index a7fec3009e..7d8a3743ed 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16843,8 +16843,9 @@ Commands: drawn, and the path's fills stay on it, below its dashes (a path without fills goes). A compound path's dashes are plain paths with its appearance. Paths without a dashed stroke stay as they are, and it is an error if none has one. The dashes are selected; more than 100,000 (or a pattern too fine to draw) is refused. → `{ids, dashes}`. -- `addon.pathtools.bridge {radius?, gap?, reach?, keepOriginals?, ids?}` joins circles (`ids`, default: the selection; - paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes, as one undo step (Object › +- `addon.pathtools.bridge {radius?, gap?, reach?, keepOriginals?, ids?}` joins circles (`ids`, default: the selection, + with a group other than a clipping group giving the objects inside it at any depth, which must all be circles; paths + whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes, as one undo step (Object › Plug-ins › Path Precision Tools › Smooth Bridge…). Two circles become one closed outline that goes around each circle on its side away from the other and along two concave arcs, one on each side of the line through the centers, each touching both circles from outside, so every anchor is smooth. `radius` is the arcs' radius as a percentage of the @@ -16870,7 +16871,8 @@ Commands: only when the largest would bridge a pair of them under these rules), when no two circles are within reach, and above 2,000 circles or 8,000 bridges. → `{ids, alone}`: the shapes and the circles left as they are, with `id` as well for two circles. Smooth Bridge… opens a dialog (`ui.menuDialog {command}`, kind `smoothBridge`) with Constant Gap (a Gap field in place of the Radius field in - percent), Reach (unavailable with two circles selected), Keep Originals and Preview. + percent), Reach (unavailable when the selection, a selected group's objects counted, holds two objects), Keep Originals + and Preview. - `addon.pathtools.tangentCircle {ids?, radius?, circle?}` draws the circles that touch two paths or compound paths and have `radius` (0.01 to 1,000,000 pt, needed with two), or that touch three (which set the radius themselves, so `radius` is then an error), as one undo step (Object › Plug-ins › Path Precision Tools › Tangent Circle…). `ids` From 53ec5af6c866e9201b88a583762f31144e7597bb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 10:28:37 -0800 Subject: [PATCH 258/264] Smooth Bridge: a refusal says why an object is not a circle Smooth Bridge only joins circles. Anything else in the selection gave "select two or more circles to bridge", the same message as for one circle. An ellipse drawn by dragging without Shift is a few tenths of a point off a circle and was refused with that message, which did not say which object was at fault or why. The refusal now names the first object that is not a circle and why: an ellipse whose width and height differ (draw it with Shift held, or give it equal width and height), a compound path (release it first), an object that is hidden or locked, or another object. The message shows on the status line while the dialog previews and after OK. --- .../engine/src/cmd/addons/pathtools/bridge.rs | 47 +++++++++++++++---- .../src/cmd/addons/pathtools/bridge/tests.rs | 34 ++++++++++++++ crates/ui-egui/src/addons/pathtools/bridge.rs | 23 +++++++++ docs/mcp.md | 4 +- 4 files changed, 99 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge.rs b/crates/engine/src/cmd/addons/pathtools/bridge.rs index 457114f820..449853d683 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge.rs @@ -3,7 +3,7 @@ //! the bridges connect, replacing the circles or added above them. use serde_json::{Value, json}; -use vectorcraft_doc::{Document, Node, NodeId, NodeKind}; +use vectorcraft_doc::{Document, LiveShape, Node, NodeId, NodeKind}; use vectorcraft_geom::PathData; use vectorcraft_pathops::addons::pathtools as pt; @@ -34,7 +34,7 @@ pub(super) fn specs() -> Vec { "Smooth Bridge", ["Object", "Plug-ins", "Path Precision Tools"], None, - "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection; a group, other than a clipping group, gives the objects inside it)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", + "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection; a group, other than a clipping group, gives the objects inside it)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. An object that is not a circle is an error that says why (an ellipse whose width and height differ, a compound path, a hidden or locked object, or another object). One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", has_selection, bridge )] @@ -61,17 +61,30 @@ fn bridge(s: &mut Session, p: &Value) -> Result { if roots.len() > pt::MAX_BRIDGED_CIRCLES { return Err(bad(C, "select at most 2000 circles to bridge")); } - let circles: Vec<(NodeId, pt::Circle)> = { + // The circles, and why the first object that is not one is refused. + let (circles, why): (Vec<(NodeId, pt::Circle)>, Option<&str>) = { let d = &s.doc()?.doc; let editable = d.editable(); - d.paint_order(roots.iter().copied()) + let mut why = None; + let circles = d + .paint_order(roots.iter().copied()) .into_iter() - .filter_map(|id| match &d.node(id)?.kind { - NodeKind::Path { path, guide: false, clipping: false, .. } if editable(id) => Some((id, pt::circle_of(path)?)), - _ => None, + .filter_map(|id| { + let found = match &d.node(id)?.kind { + NodeKind::Path { path, guide: false, clipping: false, .. } if editable(id) => pt::circle_of(path).map(|c| (id, c)), + _ => None, + }; + if found.is_none() && why.is_none() { + why = Some(not_a_circle(d, id, editable(id))); + } + found }) - .collect() + .collect(); + (circles, why) }; + if let Some(why) = why { + return Err(bad(C, format!("select two or more circles to bridge: {why}"))); + } if circles.len() != roots.len() || circles.len() < 2 { return Err(bad(C, "select two or more circles to bridge")); } @@ -156,6 +169,24 @@ fn members(d: &Document, ids: &[NodeId]) -> Vec { out } +/// Why object `id`, which is not a circle the command bridges, is refused; `editable` says whether it can be +/// edited (not hidden or locked). +fn not_a_circle(d: &Document, id: NodeId, editable: bool) -> &'static str { + // A pie spanning the whole turn, or none of it, is the whole ellipse. + let whole = |(start, end): (f64, f64)| { + let span = (end - start).rem_euclid(360.0); + span < 1e-9 || 360.0 - span < 1e-9 + }; + match d.node(id).map(|n| &n.kind) { + _ if !editable => "a selected object is hidden or locked", + Some(NodeKind::Path { live: Some(live), guide: false, clipping: false, .. }) if matches!(**live, LiveShape::Ellipse { pie, .. } if whole(pie)) => { + "an ellipse whose width and height differ is not a circle: draw it with Shift held, or give it equal width and height" + } + Some(NodeKind::Compound { .. }) => "a compound path is not a circle: release it first", + _ => "a selected object is not a circle", + } +} + /// The ids of `circles` at indices `at`, in paint order (the circles are listed in paint order). fn roots_of(circles: &[(NodeId, pt::Circle)], at: &[usize]) -> Vec { at.iter().filter_map(|&i| circles.get(i)).map(|(id, _)| *id).collect() diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index 8409ac2be6..caaa0b1b42 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -173,6 +173,40 @@ fn far_apart_nested_and_other_objects_are_refused() { assert_eq!(s.doc().unwrap().history.undo.len(), steps, "nothing changed, no undo step"); } +#[test] +fn a_refusal_says_why_an_object_is_not_a_circle() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + // A hand-drawn ellipse 1 pt taller than wide. + let oval = NodeId(s.execute("shape.ellipse", &json!({"x": 200, "y": 80, "width": 40, "height": 41})).unwrap()["id"].as_u64().unwrap()); + let square = NodeId(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let steps = s.doc().unwrap().history.undo.len(); + let e = err(&mut s, json!({"ids": [a.0, oval.0]})); + assert!( + e.ends_with( + "select two or more circles to bridge: an ellipse whose width and height differ is not a circle: draw it with Shift held, or give it equal width and height" + ), + "{e}" + ); + let e = err(&mut s, json!({"ids": [a.0, square.0]})); + assert!(e.ends_with("select two or more circles to bridge: a selected object is not a circle"), "{e}"); + let e = err(&mut s, json!({"ids": [a.0]})); + assert!(e.ends_with("select two or more circles to bridge"), "one circle: {e}"); + select(&mut s, &[b]); + s.execute("object.hide", &json!({})).unwrap(); + let e = err(&mut s, json!({"ids": [a.0, b.0]})); + assert!(e.ends_with("select two or more circles to bridge: a selected object is hidden or locked"), "{e}"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), steps, "no undo step for a refusal"); + + select(&mut s, &[a, b]); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + let c = circle(&mut s, 300.0, 200.0, 20.0); + let e = err(&mut s, json!({"ids": [compound.0, c.0]})); + assert!(e.ends_with("select two or more circles to bridge: a compound path is not a circle: release it first"), "{e}"); +} + /// A 3 × 3 grid of circles of radius 10, 4 apart (centers 24 apart), in rows from (100, 100). fn grid(s: &mut Session) -> Vec { (0..9).map(|k| circle(s, 100.0 + 24.0 * (k % 3) as f64, 100.0 + 24.0 * (k / 3) as f64, 10.0)).collect() diff --git a/crates/ui-egui/src/addons/pathtools/bridge.rs b/crates/ui-egui/src/addons/pathtools/bridge.rs index 9cdf738b18..5ddeee621b 100644 --- a/crates/ui-egui/src/addons/pathtools/bridge.rs +++ b/crates/ui-egui/src/addons/pathtools/bridge.rs @@ -228,4 +228,27 @@ mod tests { let top: Vec = app.session.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id.0).collect(); assert_eq!(top, [ids[2], ids[3]], "one shape in the topmost joined circle's place, and the far circle"); } + + #[test] + fn the_status_line_says_why_an_ellipse_is_refused() { + use crate::tests::panel_harness::Panel; + + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let a = circle(&mut app, 100.0, 10.0); + let oval = app.run("shape.ellipse", json!({"x": 130, "y": 90, "width": 20, "height": 21})).unwrap()["id"].as_u64().unwrap(); + app.run("select.set", json!({"ids": [a, oval]})).unwrap(); + let original = geometry(&app); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + let before = panel.app().session.doc().unwrap().history.undo.len(); + menus::invoke(&mut panel.app(), super::COMMAND, Value::Null); + panel.frame(); + let why = "an ellipse whose width and height differ is not a circle"; + assert!(panel.app().ui.status.contains(why), "the preview's refusal: {}", panel.app().ui.status); + panel.click("OK"); + panel.frame(); + assert!(panel.app().ui.status.contains(why), "OK's refusal: {}", panel.app().ui.status); + assert_eq!(geometry(&panel.app()), original); + assert_eq!(panel.app().session.doc().unwrap().history.undo.len(), before, "no undo step"); + } } diff --git a/docs/mcp.md b/docs/mcp.md index 7d8a3743ed..88a10b3ad0 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16854,7 +16854,9 @@ Commands: circle of the smaller circle's size about the arc's center. For equal circles that gap apart, that center is where a third circle the gap from both would sit, as in a triangular grid, so the channels around an empty place in such a grid are one width; in a square grid they are not. Giving both `radius` and `gap` is an error. Overlapping and - touching circles are joined at every radius. One circle inside the other is an error, and so are circles too far apart + touching circles are joined at every radius. An object that is not a circle is an error that says why: an ellipse whose + width and height differ, a compound path, an object that is hidden or locked, or another object. One circle inside the + other is an error, and so are circles too far apart for the radius or gap: the arcs would not reach both circles, or would cross before they do. The error suggests a larger radius or gap only when the largest (1,000% or 1,000 pt) would bridge the circles. The outline replaces the two circles, painted as the upper one (a plain path), unless `keepOriginals` is true: then it goes directly above the From 9a060cfbf7e5dfa9fb06e98aa8a66b873e65411d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 11:17:57 -0800 Subject: [PATCH 259/264] Smooth Bridge: a stretched circle is not called an ellipse of unequal width and height A transform that stretches an ellipse keeps its stored width and height, so a circle stretched into an oval still stores equal ones. The refusal now names unequal width and height only when the stored values differ, and gives the general message otherwise. docs/mcp.md notes that more than 2,000 objects are refused by the circle limit before any object is checked. --- crates/engine/src/cmd/addons/pathtools/bridge.rs | 4 +++- .../engine/src/cmd/addons/pathtools/bridge/tests.rs | 12 +++++++++++- docs/mcp.md | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge.rs b/crates/engine/src/cmd/addons/pathtools/bridge.rs index 449853d683..ea4f940ab9 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge.rs @@ -179,7 +179,9 @@ fn not_a_circle(d: &Document, id: NodeId, editable: bool) -> &'static str { }; match d.node(id).map(|n| &n.kind) { _ if !editable => "a selected object is hidden or locked", - Some(NodeKind::Path { live: Some(live), guide: false, clipping: false, .. }) if matches!(**live, LiveShape::Ellipse { pie, .. } if whole(pie)) => { + // A transform that stretches an ellipse leaves its stored width and height as they were, so one stored with + // equal width and height gets the general message. + Some(NodeKind::Path { live: Some(live), guide: false, clipping: false, .. }) if matches!(**live, LiveShape::Ellipse { w, h, pie, .. } if whole(pie) && w != h) => { "an ellipse whose width and height differ is not a circle: draw it with Shift held, or give it equal width and height" } Some(NodeKind::Compound { .. }) => "a compound path is not a circle: release it first", diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index caaa0b1b42..f9b9ea23ef 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -2,7 +2,7 @@ //! gap, many circles joined to their neighbors within reach, and what it refuses. use serde_json::{Value, json}; -use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_doc::{LiveShape, NodeId, NodeKind}; use vectorcraft_geom::kurbo::Shape; use crate::Session; @@ -181,6 +181,8 @@ fn a_refusal_says_why_an_object_is_not_a_circle() { // A hand-drawn ellipse 1 pt taller than wide. let oval = NodeId(s.execute("shape.ellipse", &json!({"x": 200, "y": 80, "width": 40, "height": 41})).unwrap()["id"].as_u64().unwrap()); let square = NodeId(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let stretched = circle(&mut s, 300.0, 100.0, 20.0); + s.execute("object.transform", &json!({"ids": [stretched.0], "matrix": [2.0, 0.0, 0.0, 1.0, 0.0, 0.0]})).unwrap(); let steps = s.doc().unwrap().history.undo.len(); let e = err(&mut s, json!({"ids": [a.0, oval.0]})); assert!( @@ -191,6 +193,14 @@ fn a_refusal_says_why_an_object_is_not_a_circle() { ); let e = err(&mut s, json!({"ids": [a.0, square.0]})); assert!(e.ends_with("select two or more circles to bridge: a selected object is not a circle"), "{e}"); + // A circle stretched by a transform keeps its equal stored width and height, so it is not called unequal. + let equal = match s.doc().unwrap().doc.node(stretched).map(|n| &n.kind) { + Some(NodeKind::Path { live: Some(live), .. }) => matches!(**live, LiveShape::Ellipse { w, h, .. } if w == h), + _ => false, + }; + assert!(equal, "the stretched circle keeps a live ellipse of equal width and height"); + let e = err(&mut s, json!({"ids": [a.0, stretched.0]})); + assert!(e.ends_with("select two or more circles to bridge: a selected object is not a circle"), "{e}"); let e = err(&mut s, json!({"ids": [a.0]})); assert!(e.ends_with("select two or more circles to bridge"), "one circle: {e}"); select(&mut s, &[b]); diff --git a/docs/mcp.md b/docs/mcp.md index 88a10b3ad0..3797b2b3f6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16855,7 +16855,9 @@ Commands: third circle the gap from both would sit, as in a triangular grid, so the channels around an empty place in such a grid are one width; in a square grid they are not. Giving both `radius` and `gap` is an error. Overlapping and touching circles are joined at every radius. An object that is not a circle is an error that says why: an ellipse whose - width and height differ, a compound path, an object that is hidden or locked, or another object. One circle inside the + width and height differ, a compound path, an object that is hidden or locked, or another object. More than 2,000 + objects (with groups counted as the objects inside them) are refused as more than 2,000 circles before any of them is + checked, so that error does not say which object is not a circle. One circle inside the other is an error, and so are circles too far apart for the radius or gap: the arcs would not reach both circles, or would cross before they do. The error suggests a larger radius or gap only when the largest (1,000% or 1,000 pt) would bridge the circles. The outline replaces the two From 798a029bfcb4f445b42f6c545d220b7d554131eb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 11:44:20 -0800 Subject: [PATCH 260/264] Smooth Bridge: a group the bridged circles leave empty goes When outlines replace circles that sit in different groups, the circles that go left their groups behind with nothing in them. Each group or compound path left empty now goes in the same undo step, and so does each group above it left empty in turn; layers and sublayers stay. --- .../engine/src/cmd/addons/pathtools/bridge.rs | 25 ++++- .../src/cmd/addons/pathtools/bridge/tests.rs | 97 +++++++++++++++++++ docs/mcp.md | 4 +- 3 files changed, 123 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge.rs b/crates/engine/src/cmd/addons/pathtools/bridge.rs index 4d4eb9cdf8..6742183bb8 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge.rs @@ -34,7 +34,7 @@ pub(super) fn specs() -> Vec { "Smooth Bridge", ["Object", "Plug-ins", "Path Precision Tools"], None, - "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", + "{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them, and a group or compound path the other circles leave empty goes; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles", has_selection, bridge )] @@ -117,7 +117,8 @@ fn bridge(s: &mut Session, p: &Value) -> Result { } beside.finish(d)?; } else { - // Each shape's topmost circle becomes its outline (a plain path now) and the others go. + // Each shape's topmost circle becomes its outline (a plain path now) and the others go, + // with each group they leave empty. let mut gone = vec![]; for (members, outline) in shapes { let Some((&top, rest)) = members.split_last() else { continue }; @@ -128,7 +129,9 @@ fn bridge(s: &mut Session, p: &Value) -> Result { made.push(top); gone.extend_from_slice(rest); } + let parents: Vec = gone.iter().filter_map(|id| d.parent_of(*id)).collect(); remove_each(d, &gone)?; + remove_emptied(d, parents)?; } sel.set(made.iter().chain(&alone).copied()); Ok(made) @@ -140,6 +143,24 @@ fn bridge(s: &mut Session, p: &Value) -> Result { Ok(out) } +/// Remove each of `parents` that is left with nothing in it, and then each group above it left with +/// nothing in it in turn. Layers stay. +fn remove_emptied(d: &mut vectorcraft_doc::Document, parents: Vec) -> Result<()> { + for parent in parents { + let mut at = Some(parent); + while let Some(id) = at { + match d.node(id) { + Some(n) if !n.is_layer() && n.children().is_some_and(|c| c.is_empty()) => { + at = d.parent_of(id); + d.remove(id)?; + } + _ => break, + } + } + } + Ok(()) +} + /// The ids of `circles` at indices `at`, in paint order (the circles are listed in paint order). fn roots_of(circles: &[(NodeId, pt::Circle)], at: &[usize]) -> Vec { at.iter().filter_map(|&i| circles.get(i)).map(|(id, _)| *id).collect() diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index 745f216b68..726277b8b7 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -329,6 +329,103 @@ fn an_id_given_twice_is_one_circle() { assert_eq!(top_level(&s), [b]); } +/// The objects directly inside `id`. +fn inside(s: &Session, id: NodeId) -> Vec { + s.doc().unwrap().doc.node(id).unwrap().children().unwrap().iter().map(|n| n.id).collect() +} + +fn make(s: &mut Session, command: &str, ids: &[NodeId]) -> NodeId { + select(s, ids); + NodeId(s.execute(command, &json!({})).unwrap()["id"].as_u64().unwrap()) +} + +#[test] +fn a_group_the_bridged_circles_leave_empty_goes_in_the_same_undo_step() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let ga = make(&mut s, "object.group", &[a]); + let gb = make(&mut s, "object.group", &[b]); + let steps = s.doc().unwrap().history.undo.len(); + let r = s.execute(BRIDGE, &json!({"ids": [a.0, b.0]})).unwrap(); + assert_eq!(r["id"], json!(b.0)); + assert_eq!(top_level(&s), [gb], "the lower circle's group, left empty, goes"); + assert_eq!(inside(&s, gb), [b], "the outline stays in the upper circle's group"); + assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(top_level(&s), [ga, gb]); + assert_eq!((inside(&s, ga), inside(&s, gb)), (vec![a], vec![b])); + + // Kept circles leave their groups as they are. + s.execute(BRIDGE, &json!({"ids": [a.0, b.0], "keepOriginals": true})).unwrap(); + assert_eq!(top_level(&s), [ga, gb]); + assert_eq!(inside(&s, ga), [a]); +} + +#[test] +fn groups_above_an_emptied_group_go_in_turn_and_a_group_with_other_objects_stays() { + let mut s = session(); + // a in a group that is all of another group; c in a group with a square; b on the layer. + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 150.0, 100.0, 20.0); + let c = circle(&mut s, 200.0, 100.0, 20.0); + let square = NodeId(s.execute("shape.rectangle", &json!({"x": 300, "y": 200, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let inner = make(&mut s, "object.group", &[a]); + let outer = make(&mut s, "object.group", &[inner]); + let gc = make(&mut s, "object.group", &[square, c]); + let layer = s.doc().unwrap().doc.layers[0].id; + let r = s.execute(BRIDGE, &json!({"ids": [a.0, b.0, c.0]})).unwrap(); + assert_eq!(ids(&r["ids"]), [c], "one shape, in the topmost circle's place"); + assert_eq!(top_level(&s), [gc], "both groups around a go, b goes from the layer"); + assert_eq!(inside(&s, gc), [c, square], "the group with the square stays"); + let d = &s.doc().unwrap().doc; + assert!(d.node(inner).is_none() && d.node(outer).is_none()); + assert!(d.node(layer).is_some(), "the layer stays"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(inside(&s, outer), [inner]); + assert_eq!(inside(&s, inner), [a]); +} + +#[test] +fn a_compound_path_the_bridged_circles_leave_empty_goes() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let compound = make(&mut s, "object.compoundPath.make", &[a]); + assert_eq!(inside(&s, compound), [a]); + s.execute(BRIDGE, &json!({"ids": [a.0, b.0]})).unwrap(); + assert_eq!(top_level(&s), [b]); + assert!(s.doc().unwrap().doc.node(compound).is_none()); +} + +#[test] +fn layers_and_sublayers_the_bridged_circles_leave_empty_stay() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let upper = NodeId(s.execute("layer.new", &json!({})).unwrap()["id"].as_u64().unwrap()); + let sub = NodeId(s.execute("layer.newSublayer", &json!({"parent": upper.0})).unwrap()["id"].as_u64().unwrap()); + s.execute("layer.setCurrent", &json!({"id": sub.0})).unwrap(); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let c = circle(&mut s, 220.0, 100.0, 20.0); + // a below in the first layer, b and c in the sublayer: c's shape takes a's and b's places. + s.execute(BRIDGE, &json!({"ids": [a.0, b.0, c.0], "reach": 30})).unwrap(); + let d = &s.doc().unwrap().doc; + assert!(d.layers.iter().any(|l| l.id != upper && l.children().is_some_and(|c| c.is_empty())), "the emptied layer stays"); + assert_eq!(inside(&s, sub), [c]); + // The sublayer left with nothing in it stays too. + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let upper = NodeId(s.execute("layer.new", &json!({})).unwrap()["id"].as_u64().unwrap()); + let sub = NodeId(s.execute("layer.newSublayer", &json!({"parent": upper.0})).unwrap()["id"].as_u64().unwrap()); + s.execute("layer.setCurrent", &json!({"id": sub.0})).unwrap(); + let b = circle(&mut s, 160.0, 100.0, 20.0); + s.execute("layer.setCurrent", &json!({"id": upper.0})).unwrap(); + let c = circle(&mut s, 220.0, 100.0, 20.0); + s.execute(BRIDGE, &json!({"ids": [a.0, b.0, c.0], "reach": 30})).unwrap(); + assert_eq!(inside(&s, sub), Vec::::new(), "the emptied sublayer stays"); + assert_eq!(inside(&s, upper), [sub, c]); +} + #[test] fn small_circles_at_the_default_reach_bridge_the_pairs_the_arcs_can_join() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index e0e702d1cc..47247d1b8c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16869,7 +16869,9 @@ Commands: larger radius or gap only when the largest (1,000% or 1,000 pt) would bridge the circles. The outline replaces the two circles, painted as the upper one (a plain path), unless `keepOriginals` is true: then it goes directly above the upper circle, painted as it, and the circles stay. The outline is selected. Two circles are bridged however far apart - their outlines are; `reach` does not apply to them. + their outlines are; `reach` does not apply to them. When outlines replace circles (with any number of circles), a group + or compound path that the circles leave with nothing in it is removed, and so is each group above it left empty in + turn; layers stay. With three or more circles, every two whose outlines are at most `reach` apart (0 to 10,000 pt, 10 by default; overlapping ones included) are bridged the same way, and the bridges that connect are united into one shape each, which can have holes where bridges enclose space; holes smaller than 1% of the smallest circle's area are filled. A From 0c722fbf2a6b9561a7597be6697242951797b5c4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 11:53:03 -0800 Subject: [PATCH 261/264] Docs: a clipping group counts as one object toward the Smooth Bridge limit docs/mcp.md said every group counts as the objects inside it toward the 2,000-object limit. The command expands only groups other than clipping groups (bridge.rs, the clip: false arm), so a clipping group counts as one object, which is not a circle. --- docs/mcp.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/mcp.md b/docs/mcp.md index 32e0a0617b..033bdf6bc5 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16867,7 +16867,8 @@ Commands: grid are one width; in a square grid they are not. Giving both `radius` and `gap` is an error. Overlapping and touching circles are joined at every radius. An object that is not a circle is an error that says why: an ellipse whose width and height differ, a compound path, an object that is hidden or locked, or another object. More than 2,000 - objects (with groups counted as the objects inside them) are refused as more than 2,000 circles before any of them is + objects (with each group other than a clipping group counted as the objects inside it, and a clipping group as one + object, which is not a circle) are refused as more than 2,000 circles before any of them is checked, so that error does not say which object is not a circle. One circle inside the other is an error, and so are circles too far apart for the radius or gap: the arcs would not reach both circles, or would cross before they do. The error suggests a From 1d880065f3168180a251a4a9102238f8d02d113c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 12:17:05 -0800 Subject: [PATCH 262/264] Smooth Bridge: test a selected group of grouped circles A selected group that holds two groups of one circle each keeps the group with the outline, and the lower circle's group is removed. --- .../src/cmd/addons/pathtools/bridge/tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index 088b707af3..3630bd6650 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -398,6 +398,21 @@ fn a_compound_path_the_bridged_circles_leave_empty_goes() { assert!(s.doc().unwrap().doc.node(compound).is_none()); } +#[test] +fn a_selected_group_of_grouped_circles_keeps_only_the_outlines_group() { + let mut s = session(); + let a = circle(&mut s, 100.0, 100.0, 20.0); + let b = circle(&mut s, 160.0, 100.0, 20.0); + let ga = make(&mut s, "object.group", &[a]); + let gb = make(&mut s, "object.group", &[b]); + let outer = make(&mut s, "object.group", &[ga, gb]); + select(&mut s, &[outer]); + s.execute(BRIDGE, &json!({})).unwrap(); + assert_eq!(top_level(&s), [outer]); + assert_eq!(inside(&s, outer), [gb], "the lower circle's group goes, the outline's stays"); + assert_eq!(inside(&s, gb), [b]); +} + #[test] fn layers_and_sublayers_the_bridged_circles_leave_empty_stay() { let mut s = session(); From 77ed30177516bc6c2ef7f1de6a564a0692ae50d8 Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 1 Dec 2026 03:42:59 +0700 Subject: [PATCH 263/264] SVG import: refuse an SVG the memory can't hold instead of running out (#10303) * SVG import: refuse an SVG the memory can't hold instead of running out The element limit now follows the installed memory, or the process's cgroup limit where that is lower: about 8 KB an element, up to the 999,999 elements usvg reads. Past it the SVG is refused with an error naming the memory, before usvg makes its tree. Fixes #10165 * Tests: the shared element limit test follows the machine's limit --- Cargo.lock | 1 + crates/svg/Cargo.toml | 2 + crates/svg/src/import.rs | 13 +++++-- crates/svg/src/import/budget.rs | 54 ++++++++++++++++++++++++--- crates/svg/src/import/files.rs | 8 ++-- crates/svg/src/lib.rs | 6 ++- crates/svg/tests/it/import_details.rs | 21 +++++++++-- xtask/src/layers.rs | 2 + 8 files changed, 89 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 170ad40f3d..5aff7bd0a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9049,6 +9049,7 @@ dependencies = [ "vectorcraft-effects", "vectorcraft-geom 0.25.1", "vectorcraft-pathops 0.25.1", + "vectorcraft-render", "vectorcraft-testkit", "vectorcraft-text", ] diff --git a/crates/svg/Cargo.toml b/crates/svg/Cargo.toml index 310b9c8e6f..08fcbbd3de 100644 --- a/crates/svg/Cargo.toml +++ b/crates/svg/Cargo.toml @@ -21,6 +21,8 @@ vectorcraft-effects = { workspace = true } vectorcraft-brush = { workspace = true } vectorcraft-text = { workspace = true } vectorcraft-pathops = { workspace = true } +# Installed memory (cgroup limits included), which sizes the element limit. +vectorcraft-render = { workspace = true } kurbo = { workspace = true } # Image elements still go through usvg's image href resolution (src/import/files.rs, src/import/budget.rs). usvg = { workspace = true } diff --git a/crates/svg/src/import.rs b/crates/svg/src/import.rs index 5e7afdd55a..20261eef95 100644 --- a/crates/svg/src/import.rs +++ b/crates/svg/src/import.rs @@ -28,6 +28,11 @@ pub(crate) use fx::BLEND; /// expansion bombs (#3564). pub const MAX_NODES: usize = if cfg!(target_arch = "wasm32") { 500_000 } else { 2_000_000 }; +/// Most elements an SVG may expand to on this machine, its memory considered (#10165). +pub fn max_elements() -> usize { + budget::max_elements() as usize +} + mod convert; mod importer; mod layers; @@ -112,7 +117,7 @@ pub(crate) fn svg_filters(svg: &str, room: usize, taken: impl Fn(&str) -> bool) } let xml = parse(svg)?; // Before the style cascade of `depth::height`, as `import` measures it. - budget::check(&xml, budget::Cost::LIMITS, depth::MAX_ELEMENT_DEPTH)?; + budget::check(&xml, budget::Cost::limits(), depth::MAX_ELEMENT_DEPTH)?; if depth::height(&xml, depth::MAX_ELEMENT_DEPTH).is_none() { return Err(too_deep()); } @@ -142,7 +147,7 @@ pub(crate) fn import_finding( let xml = parse(svg)?; // Before the style cascade of `depth::height` and the prepass, which keeps the declarations of // each element it reads; measured again below on the text usvg reads when that differs. - let spent = budget::check(&xml, budget::Cost::LIMITS, depth::MAX_ELEMENT_DEPTH)?; + let spent = budget::check(&xml, budget::Cost::limits(), depth::MAX_ELEMENT_DEPTH)?; let Some(height) = depth::height(&xml, depth::MAX_ELEMENT_DEPTH) else { return Err(too_deep()); }; @@ -165,8 +170,8 @@ pub(crate) fn import_finding( // Before usvg copies what ``s show and the style values of each copy: the text usvg reads. let spent = match &src { Cow::Borrowed(_) if !rewritten => spent, - Cow::Borrowed(_) => budget::check(&xml, budget::Cost::LIMITS, usize::MAX)?, - Cow::Owned(prepared) => budget::check(&parse(prepared)?, budget::Cost::LIMITS, usize::MAX)?, + Cow::Borrowed(_) => budget::check(&xml, budget::Cost::limits(), usize::MAX)?, + Cow::Owned(prepared) => budget::check(&parse(prepared)?, budget::Cost::limits(), usize::MAX)?, }; let files = found.files; files.spent_by_svg(spent); diff --git a/crates/svg/src/import/budget.rs b/crates/svg/src/import/budget.rs index 2520a8932a..b7b45f03da 100644 --- a/crates/svg/src/import/budget.rs +++ b/crates/svg/src/import/budget.rs @@ -6,8 +6,9 @@ //! sheets and the `style` attribute give the element, so a long style on an element that ``s //! copy, again and again in a chain, or that a style sheet rule gives to many elements, takes more //! memory than the file holds many times over. usvg stops past 1,000,000 elements, but only after -//! it has made them and copied their styles. An SVG past [`MAX_SVG_ELEMENTS`] elements or -//! [`MAX_COPIED_STYLES`] bytes of copied styles is refused here instead. +//! it has made them and copied their styles. An SVG past [`max_elements`] elements (fewer than +//! [`MAX_SVG_ELEMENTS`] when the machine's memory has room for fewer) or [`MAX_COPIED_STYLES`] +//! bytes of copied styles is refused here instead. //! //! The copies are counted, never made: each element's count is worked out once and added up, so a //! `` of an element costs one addition, however many elements its copy holds. References @@ -43,6 +44,32 @@ use crate::{MAX_ELEMENT_DEPTH, SvgError}; /// which usvg stops (its count includes a root of its own). pub(crate) const MAX_SVG_ELEMENTS: usize = if MAX_NODES < 999_999 { MAX_NODES } else { 999_999 }; +/// Memory an element takes, about, from reading the SVG to drawing what is made of it (bytes): a +/// 400,000-path SVG converted to PNG peaked at about 4.4 KB a path (#10165), with room to spare. +const ELEMENT_BYTES: u64 = 8 << 10; + +/// Most elements usvg may make of an SVG on this machine: [`MAX_SVG_ELEMENTS`], fewer when the +/// installed memory (or the process's cgroup limit) has room for fewer, so a large SVG is refused +/// with an error instead of running out of memory. +pub(crate) fn max_elements() -> u64 { + static LIMIT: std::sync::OnceLock = std::sync::OnceLock::new(); + *LIMIT.get_or_init(|| elements_for(vectorcraft_render::installed_memory())) +} + +/// [`max_elements`] with `memory` bytes installed (`None` or 0: not known). +fn elements_for(memory: Option) -> u64 { + memory.filter(|&m| m > 0).map_or(MAX_SVG_ELEMENTS as u64, |m| (m / ELEMENT_BYTES).min(MAX_SVG_ELEMENTS as u64)) +} + +/// The error for an SVG past [`max_elements`]: naming the memory when that is what limits it. +fn too_many_elements() -> SvgError { + let most = max_elements(); + match vectorcraft_render::installed_memory() { + Some(memory) if most < MAX_SVG_ELEMENTS as u64 => SvgError::TooLargeForMemory(most as usize, memory >> 20), + _ => SvgError::TooLarge(MAX_SVG_ELEMENTS), + } +} + /// Most bytes of style values usvg may copy into the elements of an SVG and the SVG images it /// shows, all together: VectorCraft's own limit. pub(crate) const MAX_COPIED_STYLES: u64 = 64 << 20; @@ -209,7 +236,9 @@ pub(crate) struct Cost { impl Cost { /// The most an SVG and the SVG images it shows may cost together. - pub(crate) const LIMITS: Cost = Cost { elements: MAX_SVG_ELEMENTS as u64, bytes: MAX_COPIED_STYLES, tests: MAX_SELECTOR_TESTS }; + pub(crate) fn limits() -> Cost { + Cost { elements: max_elements(), bytes: MAX_COPIED_STYLES, tests: MAX_SELECTOR_TESTS } + } pub(crate) fn add(self, other: Cost) -> Cost { Cost { @@ -408,7 +437,7 @@ pub(super) fn check(xml: &roxmltree::Document, left: Cost, depth: usize) -> Resu pub(super) fn check_spending(xml: &roxmltree::Document, left: Cost, depth: usize) -> (Result, u64) { let (result, tests) = measure_spending(xml, left, depth); let result = result.map_err(|past| match past { - Past::Elements => SvgError::TooLarge(MAX_SVG_ELEMENTS), + Past::Elements => too_many_elements(), Past::Bytes => SvgError::StylesTooLarge((MAX_COPIED_STYLES >> 20) as usize), Past::Tests => SvgError::StylesTooComplex, Past::Depth => SvgError::TooDeep(MAX_ELEMENT_DEPTH), @@ -562,6 +591,19 @@ mod tests { assert_eq!(MAX_SVG_ELEMENTS, if cfg!(target_arch = "wasm32") { 500_000 } else { 999_999 }); } + #[test] + fn less_memory_reads_fewer_elements_up_to_the_element_limit() { + let most = MAX_SVG_ELEMENTS as u64; + assert_eq!(elements_for(None), most, "unknown memory"); + assert_eq!(elements_for(Some(0)), most, "unknown memory"); + assert_eq!(elements_for(Some(1 << 40)), most, "plenty of memory"); + // A 1 GiB container can't hold the 400,000 paths that took 1.77 GB (#10165). + let small = elements_for(Some(1 << 30)); + assert!(small < 400_000, "{small}"); + assert!(elements_for(Some(512 << 20)) < small); + assert!(max_elements() <= most); + } + #[test] fn style_sheet_rules_count_where_they_match() { let groups = "".repeat(4); @@ -614,7 +656,7 @@ mod tests { let xml = roxmltree::Document::parse(&deep).unwrap(); assert_eq!(measure(&xml, NO_LIMITS, MAX_ELEMENT_DEPTH).err(), Some(Past::Depth)); assert!(super::super::depth::height(&xml, MAX_ELEMENT_DEPTH).is_none()); - assert!(matches!(check(&xml, Cost::LIMITS, MAX_ELEMENT_DEPTH), Err(SvgError::TooDeep(_)))); + assert!(matches!(check(&xml, Cost::limits(), MAX_ELEMENT_DEPTH), Err(SvgError::TooDeep(_)))); for text in [chain(5, ""), svg("")] { let xml = roxmltree::Document::parse(&text).unwrap(); let height = super::super::depth::height(&xml, usize::MAX).unwrap_or(0); @@ -674,7 +716,7 @@ mod tests { fn a_selector_that_never_matches_stops_at_the_test_limit() { let never = nested(60, &format!(".missing{} {{fill:red}}", " g".repeat(20))); let xml = roxmltree::Document::parse(&never).unwrap(); - assert_eq!(measure(&xml, Cost::LIMITS, usize::MAX).err(), Some(Past::Tests)); + assert_eq!(measure(&xml, Cost::limits(), usize::MAX).err(), Some(Past::Tests)); let before = super::super::css::selector_tests(); let err = super::super::import(&never, &crate::ImportOptions::default(), MAX_NODES).err(); assert!(matches!(err, Some(SvgError::StylesTooComplex)), "{err:?}"); diff --git a/crates/svg/src/import/files.rs b/crates/svg/src/import/files.rs index 631bed3d0c..525e900c87 100644 --- a/crates/svg/src/import/files.rs +++ b/crates/svg/src/import/files.rs @@ -478,7 +478,7 @@ impl Files { // reads it ([`Files::svg_tree`]), which then refuses one past the limits, within what the // linked SVG files measured before it left: past it, its links aren't read, and the // selector tests it made still count. - let (result, tests) = budget::check_spending(&xml, budget::Cost::LIMITS.less(reading.measured), left); + let (result, tests) = budget::check_spending(&xml, budget::Cost::limits().less(reading.measured), left); match result { Ok(cost) => reading.measured = reading.measured.add(cost), Err(e) => { @@ -593,13 +593,13 @@ impl Files { } /// What usvg makes of the SVG holding the images ([`budget::check`]): its images make at most - /// what is left of [`budget::Cost::LIMITS`]. + /// what is left of [`budget::Cost::limits()`]. pub(in crate::import) fn spent_by_svg(&self, spent: budget::Cost) { self.set_spent(spent); } fn spent(&self) -> budget::Cost { - self.spent.lock().map(|s| *s).unwrap_or(budget::Cost::LIMITS) + self.spent.lock().map(|s| *s).unwrap_or(budget::Cost::limits()) } fn set_spent(&self, spent: budget::Cost) { @@ -807,7 +807,7 @@ impl Files { // with theirs while usvg reads it, and only when it decodes. Too deep, it is left out; // past the other limits, the whole SVG is refused. let spent = self.spent(); - let cost = match budget::check(&xml, budget::Cost::LIMITS.less(spent), left) { + let cost = match budget::check(&xml, budget::Cost::limits().less(spent), left) { Ok(cost) => cost, Err(SvgError::TooDeep(_)) => return leave_out(&self.too_deep, true), Err(e) => { diff --git a/crates/svg/src/lib.rs b/crates/svg/src/lib.rs index ad3e91588f..0bcd5999b7 100644 --- a/crates/svg/src/lib.rs +++ b/crates/svg/src/lib.rs @@ -363,6 +363,10 @@ pub enum SvgError { /// nested-image expansion bombs, #3564). #[error("the SVG expands to more than {0} objects")] TooLarge(usize), + /// The SVG expands to more objects (the first number) than this machine's memory, or the + /// process's memory limit (the second number, in MB), has room to read (#10165). + #[error("the SVG expands to more than {0} objects, more than the {1} MB of memory available has room for")] + TooLargeForMemory(usize, u64), /// The SVG expands to more nested SVG images than the reader takes (a guard against /// nested-image expansion bombs, #3564). #[error("the SVG expands to more than {0} nested SVG images")] @@ -536,7 +540,7 @@ pub fn svg_filters(svg: &str, room: usize, taken: impl Fn(&str) -> bool) -> Resu pub use glyph::glyph_art; pub use import::{ MAX_DATA_URL_BYTES, MAX_ELEMENT_DEPTH, MAX_FOREIGN, MAX_FOREIGN_VALUE, MAX_NESTED_SVG_IMAGES, MAX_NESTED_SVG_READS, MAX_NESTED_SVG_TEXT, - MAX_NODES, + MAX_NODES, max_elements, }; /// Import an SVG document reading the files it links to as `opts` says, also returning warnings. diff --git a/crates/svg/tests/it/import_details.rs b/crates/svg/tests/it/import_details.rs index 25c5152de9..a4046e3fe7 100644 --- a/crates/svg/tests/it/import_details.rs +++ b/crates/svg/tests/it/import_details.rs @@ -892,11 +892,22 @@ fn styles_that_expand_past_the_limit_are_refused() { assert_eq!(art(&d).len(), 5000); } +/// `err` refuses an SVG past the element limit: the most usvg reads, or fewer on a machine whose +/// memory has room for fewer (#10165). +fn past_the_element_limit(err: &SvgError) -> bool { + let most = vectorcraft_svg::MAX_NODES.min(999_999); + match *err { + SvgError::TooLarge(n) => n == most, + SvgError::TooLargeForMemory(n, _) => n < most && n == vectorcraft_svg::max_elements(), + _ => false, + } +} + /// A chain of ``s that makes more elements than usvg reads is refused before usvg makes them. #[test] fn a_use_chain_past_the_elements_usvg_reads_is_refused() { let err = import_with(&use_chain(20, ""), &ImportOptions::default()).unwrap_err(); - assert!(matches!(err, SvgError::TooLarge(n) if n == vectorcraft_svg::MAX_NODES.min(999_999)), "{err:?}"); + assert!(past_the_element_limit(&err), "{err:?}"); } /// An SVG image whose styles expand past the limit refuses the SVG showing it, and the SVG images @@ -927,9 +938,13 @@ fn svg_images_share_the_element_limit() { assert_ne!(chain, unshown); let image = image_of("image/svg+xml", &unshown); let rect = r#""#; - assert!(import_with(&svg(&format!("{rect}{image}")), &ImportOptions::default()).is_ok()); + // One image fits, unless this machine's memory has room for fewer elements than it makes. + match import_with(&svg(&format!("{rect}{image}")), &ImportOptions::default()) { + Ok(_) => {} + Err(err) => assert!(vectorcraft_svg::max_elements() < 700_000 && past_the_element_limit(&err), "{err:?}"), + } let err = import_with(&svg(&format!("{rect}{}", image.repeat(2))), &ImportOptions::default()).unwrap_err(); - assert!(matches!(err, SvgError::TooLarge(n) if n == vectorcraft_svg::MAX_NODES.min(999_999)), "{err:?}"); + assert!(past_the_element_limit(&err), "{err:?}"); } /// A `:not()` rule, which only the import's own style cascade reads, counts toward the style limit diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs index f2fb1f1ce0..869074b03f 100644 --- a/xtask/src/layers.rs +++ b/xtask/src/layers.rs @@ -80,6 +80,8 @@ pub const INTRA_LAYER_ORDER: &[&[&str]] = &[ &["pathops", "trace"], &["text", "effects"], &["render", "eps"], + // SVG import sizes its element limit from the installed memory the renderer reads (#10165). + &["render", "svg"], &["metafile", "eps"], // Non-native art in Illustrator editing data is a PDF, drawn by the PDF importer. &["pdf", "eps"], From cf2d168d49e50f92ff03fd9b89e51de247c67219 Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 1 Dec 2026 05:05:57 +0700 Subject: [PATCH 264/264] PDF import: inline images with the same dictionary keep their own pixels (#10313) An inline image has no object of its own, and the interpreter keys an image by its dictionary alone, so every inline image of one size and encoding got the key of the first one and was imported with its pixels: Type 3 glyphs drawn as inline stencil images came in as the wrong letters. An inline raster image is now keyed by its samples too, and a stencil image by its decoded pixels. Fixes #9247 --- crates/pdf/src/import/device.rs | 10 +++++++- crates/pdf/src/tests/import_fidelity.rs | 33 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/pdf/src/import/device.rs b/crates/pdf/src/import/device.rs index 70aacd89cf..cd40578cec 100644 --- a/crates/pdf/src/import/device.rs +++ b/crates/pdf/src/import/device.rs @@ -246,8 +246,13 @@ impl<'a> Device<'a> for Builder<'_> { // replaces DeviceCMYK, so it is cached apart from the same image drawn where one does. let intent = !white && self.intent_cmyk.is_some() && self.scan.cmyk_defaults.get(&r.stream().dict().obj_id()) == Some(&false); // Inside an alpha mask the same image is read again, white (its own cache key). - let key = craft::pdf::interpret::CacheKey::cache_key(&r) ^ if white { WHITE_KEY } else { 0 } ^ if intent { INTENT_KEY } else { 0 }; let st = r.stream(); + // An inline image (no object of its own) is keyed by its samples too: the + // interpreter keys an image by its dictionary, the same for inline images of one + // size and encoding (#9247). + let inline = if st.dict().obj_id().is_none() { crate::import_scan::hash128(&*st.raw_data()) } else { 0 }; + let key = + craft::pdf::interpret::CacheKey::cache_key(&r) ^ inline ^ if white { WHITE_KEY } else { 0 } ^ if intent { INTENT_KEY } else { 0 }; let (w, h) = (r.width(), r.height()); // CMYK images keep their samples (read once per image). let known = !white && self.cmyk_keys.contains(&key); @@ -370,6 +375,9 @@ impl<'a> Device<'a> for Builder<'_> { None, ); let Some((px, w, h, sf)) = decoded else { return }; + // Keyed by its pixels too, as an inline raster image is by its samples: a stencil + // doesn't show its stream, and inline ones of one size share a dictionary (#9247). + let key = key ^ crate::import_scan::hash128(&px); let xf = transform * Affine::scale_non_uniform(sf.0 as f64, sf.1 as f64); match colorize { // Its own key: its pixels are the gray ones, whatever color paints it. diff --git a/crates/pdf/src/tests/import_fidelity.rs b/crates/pdf/src/tests/import_fidelity.rs index 0be8dce82f..5fdafeb5fc 100644 --- a/crates/pdf/src/tests/import_fidelity.rs +++ b/crates/pdf/src/tests/import_fidelity.rs @@ -507,6 +507,39 @@ fn a_form_drawn_many_times_reads_its_font_resources_once() { assert_eq!(walk.fonts.len(), 1); } +/// Inline images with the same dictionary but other samples come in with their own pixels: the +/// stencil glyphs of a Type 3 font (#9247) and raster images on the page. +#[test] +fn inline_images_with_the_same_dictionary_keep_their_own_pixels() { + let n = first_extra(1); + let glyph = |hex: &str| { + stream("", &format!("1000 0 0 0 1000 1000 d1 q 1000 0 0 1000 0 0 cm BI /IM true /W 8 /H 8 /BPC 1 /D [1 0] /F /AHx ID\n{hex}>\nEI Q")) + }; + let objects = [ + format!( + "<< /Type /Font /Subtype /Type3 /FontBBox [0 0 1000 1000] /FontMatrix [0.001 0 0 0.001 0 0] /CharProcs << /a {} 0 R /b {} 0 R >> /Encoding << /Type /Encoding /Differences [97 /a /b] >> /FirstChar 97 /LastChar 98 /Widths [1000 1000] /Resources << >> >>", + n + 1, + n + 2 + ), + glyph("1818181818181818"), + glyph("000000FFFF000000"), + ]; + let raster = |hex: &str| format!("q 10 0 0 10 0 0 cm BI /W 2 /H 1 /CS /RGB /BPC 8 /F /AHx ID\n{hex}>\nEI Q "); + let content = format!("BT /T3 24 Tf 10 30 Td (ab) Tj ET {}{}", raster("FF000000FF00"), raster("0000FFFFFFFF")); + let extra: Vec<&str> = objects.iter().map(String::as_str).collect(); + let d = open(&one_page(&content, &format!("/Font << /T3 {n} 0 R >>"), &extra)); + let blobs: Vec>> = all(&d) + .iter() + .filter_map(|n| match &n.kind { + NodeKind::Image(im) => Some(d.images[&im.key].bytes.clone()), + _ => None, + }) + .collect(); + assert_eq!(blobs.len(), 4, "two glyphs and two raster images"); + let distinct: std::collections::HashSet<&Arc>> = blobs.iter().collect(); + assert_eq!(distinct.len(), blobs.len(), "each image has its own pixels"); +} + /// A Type 3 font that every page lists in a font dictionary of its own, and a form lists in its /// resources, has its glyph procedures read once for the document. Each page still maps the font's /// glyphs, and the font whose glyphs set their own color (`d0`) is told from the one whose glyphs