Merge pull request #10638 from dotCooCoo/fix/retrace-keeps-note-and-tags

Image Trace: tracing again keeps the tracing's note and tags
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-05 06:41:34 -08:00
commit e58d945341
13 files changed
+262 -48

No files matched your search

+1 -1
View File
@@ -119,7 +119,7 @@ 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 node::{ForeignAttribute, ImageMap, MAX_SVG_SCRIPTS, MAX_TAG_TEXT, MAX_TAGS, ObjectAttributes, ObjectTag, SVG_EVENTS, attribute_copies};
pub use orient::OrientedBox;
pub use pattern::{Overlap, PatternDef, PatternEdit, RepeatKind, RepeatSpec, TileType};
pub use perspective::PerspectiveAttachment;
+3 -1
View File
@@ -25,7 +25,9 @@ mod opacity;
mod ops;
mod wire;
pub use attributes::{ForeignAttribute, ImageMap, MAX_SVG_SCRIPTS, MAX_TAG_TEXT, MAX_TAGS, ObjectAttributes, ObjectTag, SVG_EVENTS};
pub use attributes::{
ForeignAttribute, ImageMap, MAX_SVG_SCRIPTS, MAX_TAG_TEXT, MAX_TAGS, ObjectAttributes, ObjectTag, SVG_EVENTS, attribute_copies,
};
#[cfg(test)]
pub(crate) use changed::COUNTERPART_LOOKUPS;
pub use changed::changed_nodes;
+29 -1
View File
@@ -3,7 +3,7 @@ use super::live_shape::LiveShape;
use super::{Deserialize, Node, Serialize};
/// Window → Attributes: an object's settings that don't change how it prints.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ObjectAttributes {
/// Show Center / Don't Show Center (`None`: the object kind's default, [`Node::shows_center`]).
@@ -45,6 +45,34 @@ pub struct ObjectAttributes {
pub tags: Vec<ObjectTag>,
}
impl Clone for ObjectAttributes {
fn clone(&self) -> Self {
ATTRIBUTE_COPIES.set(ATTRIBUTE_COPIES.get().saturating_add(1));
Self {
show_center: self.show_center,
image_map: self.image_map,
url: self.url.clone(),
note: self.note.clone(),
data: self.data.clone(),
events: self.events.clone(),
classes: self.classes.clone(),
foreign: self.foreign.clone(),
tags: self.tags.clone(),
}
}
}
thread_local! {
/// [`attribute_copies`] of this thread.
static ATTRIBUTE_COPIES: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
}
/// How many times an object's [`ObjectAttributes`] have been copied on this thread. Tags can hold
/// up to [`MAX_TAGS`] values of [`MAX_TAG_TEXT`] bytes each, so each copy can cost megabytes.
pub fn attribute_copies() -> u64 {
ATTRIBUTE_COPIES.get()
}
/// The most tags one object has.
pub const MAX_TAGS: usize = 64;
+18 -12
View File
@@ -1118,7 +1118,7 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
return Err(EngineError::Cancelled);
}
let id = s.edit(label, |d, sel| {
let src = d.node(target).cloned().ok_or(EngineError::NoNode(target))?;
let mut src = d.node(target).cloned().ok_or(EngineError::NoNode(target))?;
let mut image = if is_trace_group(&src) {
src.children()
.and_then(|c| c.first())
@@ -1225,17 +1225,23 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
let gid = d.alloc_id();
let mut g = Node::group(gid, children);
g.name = if expand { None } else { Some(TRACE_NAME.into()) };
// Tracing again keeps the tracing's own object settings: opacity, blend mode, its
// appearance items, visibility and lock.
if !expand && is_trace_group(&src) {
g.visible = src.visible;
g.locked = src.locked;
g.opacity = src.opacity;
g.blend = src.blend;
g.isolate = src.isolate;
g.knockout = src.knockout;
g.knockout_shape = src.knockout_shape;
g.appearance = src.appearance.clone();
// Tracing again keeps the tracing's note, tags and URL, including when expanding.
// Without expansion, it also keeps the tracing's other object settings.
if is_trace_group(&src) {
// The attributes move from `src`, this edit's own copy of the tracing, without another copy.
if src.extras().attrs.is_some() {
g.extras_mut().attrs = src.extras_mut().attrs.take();
}
if !expand {
g.visible = src.visible;
g.locked = src.locked;
g.opacity = src.opacity;
g.blend = src.blend;
g.isolate = src.isolate;
g.knockout = src.knockout;
g.knockout_shape = src.knockout_shape;
g.appearance = src.appearance.clone();
}
}
if !expand {
// Tracing again keeps the object's view unless another is asked for, and the Split
+29 -10
View File
@@ -1363,17 +1363,15 @@ fn clear(s: &mut Session, p: &Value) -> Result<Value> {
}
s.edit("Clear", |d, sel| {
let clipped = clipped_ancestors(d, ids.iter().copied());
let parents: Vec<_> = if keep_empty {
Vec::new()
} else {
ids.iter().filter_map(|id| d.parent_of(*id).filter(|p| matches!(d.node(*p).map(|n| &n.kind), Some(NodeKind::Compound { .. })))).collect()
};
let emptied = if keep_empty { Vec::new() } else { emptied_compounds(d, &ids) };
// A compound path inside another emptied one leaves with it.
let outer: Vec<NodeId> = emptied
.iter()
.copied()
.filter(|p| !d.ancestry(*p).unwrap_or_default().iter().rev().skip(1).any(|a| emptied.binary_search(a).is_ok()))
.collect();
d.remove_many(&ids)?;
for p in parents {
if d.node(p).is_some_and(|n| n.children().is_some_and(|c| c.is_empty())) {
d.remove(p)?;
}
}
d.remove_many(&outer)?;
if with_guides {
let gone = sel.guides.clone();
d.retain_guides(sel, |g| !g.id.is_some_and(|id| gone.contains(&id)));
@@ -1390,6 +1388,27 @@ fn clear(s: &mut Session, p: &Value) -> Result<Value> {
ok()
}
/// The compound paths that deleting the objects `ids` together leaves with no members, sorted by
/// id: a compound path counts when each of its members is deleted or is such a compound path, so
/// a compound path holding only an emptied inner one is emptied too.
fn emptied_compounds(d: &Document, ids: &[NodeId]) -> Vec<NodeId> {
let mut gone: BTreeSet<NodeId> = ids.iter().copied().collect();
let mut emptied = BTreeSet::new();
loop {
let parents: BTreeSet<NodeId> = gone.iter().filter_map(|i| d.parent_of(*i)).filter(|p| !gone.contains(p)).collect();
let found: BTreeSet<NodeId> = parents
.into_iter()
.filter(|p| d.node(*p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. })))
.filter(|p| d.children(Some(*p)).is_some_and(|k| k.iter().all(|n| gone.contains(&n.id))))
.collect();
if found.is_empty() {
return emptied.into_iter().collect();
}
gone.extend(found.iter().copied());
emptied.extend(found);
}
}
/// Does Clear remove direct-selected anchors without opening their paths (`keepJoined` param, else
/// General › Delete Removes Anchor Points and Keeps Paths Joined)? Noted in the journal, so a
/// replay removes them the same way whatever the preference is at the time. A saved step without `keepJoined`
+56
View File
@@ -400,3 +400,59 @@ fn selected_roots_are_found_once_for_each_document_and_selection() {
selected_roots(&s).unwrap();
assert_eq!(roots_found() - before, 2, "an edit finds the roots once again");
}
/// Clear removes a compound path whose members are cleared paths and a compound path the clear
/// empties, whichever order the ids come in, and the tracing guard's set counts both as deleted.
#[test]
fn clear_removes_a_compound_path_emptied_through_an_emptied_inner_one() {
for reversed in [false, true] {
let mut s = new_doc();
let outer_paths = [(); 2].map(|()| rect(&mut s));
let (outer, outer_members) = compound(&mut s, &outer_paths);
let inner_paths = [(); 2].map(|()| rect(&mut s));
let (inner, inner_members) = compound(&mut s, &inner_paths);
s.edit("Nest", |d, _| {
let taken = d.remove_many(&[inner])?;
d.insert(Some(outer), 1, (*taken[0]).clone())?;
Ok(())
})
.unwrap();
let mut ids: Vec<NodeId> = outer_members.iter().chain(&inner_members).copied().collect();
if reversed {
ids.reverse();
}
let d = &s.doc().unwrap().doc;
assert_eq!(d.parent_of(inner), Some(outer), "the inner compound path is a member of the outer one");
let want: Vec<NodeId> = BTreeSet::from([outer, inner]).into_iter().collect();
assert_eq!(emptied_compounds(d, &ids), want, "reversed: {reversed}");
run(&mut s, "edit.clear", json!({"ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()}));
let d = &s.doc().unwrap().doc;
assert!(d.node(inner).is_none(), "the emptied inner compound path goes (reversed: {reversed})");
assert!(d.node(outer).is_none(), "the outer compound path it leaves empty goes too (reversed: {reversed})");
}
}
/// With a direct-selected anchor of another path in the selection, Clear still removes the outer
/// compound path that an emptied inner one leaves empty.
#[test]
fn clear_with_direct_anchors_removes_a_compound_path_emptied_through_an_emptied_inner_one() {
let mut s = new_doc();
let outer_paths = [(); 2].map(|()| rect(&mut s));
let (outer, outer_members) = compound(&mut s, &outer_paths);
let inner_paths = [(); 2].map(|()| rect(&mut s));
let (inner, inner_members) = compound(&mut s, &inner_paths);
let other = rect(&mut s);
s.edit("Nest", |d, _| {
let taken = d.remove_many(&[inner])?;
d.insert(Some(outer), 1, (*taken[0]).clone())?;
Ok(())
})
.unwrap();
let whole: Vec<NodeId> = outer_members.iter().chain(&inner_members).copied().collect();
select_direct(&mut s, &whole, &[(other, two_anchors())]);
run(&mut s, "edit.clear", json!({}));
let d = &s.doc().unwrap().doc;
assert!(d.node(inner).is_none(), "the emptied inner compound path goes");
assert!(d.node(outer).is_none(), "the outer compound path it leaves empty goes too");
assert!(d.node(other).is_some(), "the path with anchors picked keeps its other sides");
}
+5 -1
View File
@@ -2212,9 +2212,13 @@ pub(crate) fn delete_anchors_joined(s: &mut Session, p: &Value, keep_joined: boo
}
}
emptied.finish(d)?;
for p in compounds {
// A compound path left empty by an inner one that went is checked again after it.
let mut compounds = compounds;
while let Some(p) = compounds.pop_first() {
if d.node(p).is_some_and(|n| n.children().is_some_and(|c| c.is_empty())) {
let up = d.parent_of(p).filter(|u| matches!(d.node(*u).map(|n| &n.kind), Some(NodeKind::Compound { .. })));
d.remove(p)?;
compounds.extend(up);
}
}
super::edit::release_empty_clips(d, clipped);
+6 -8
View File
@@ -719,7 +719,8 @@ thread_local! {
/// `pathItems.removeAll()` leaves the compound path, empty, as `remove()` of its last path does.
/// It also throws and deletes nothing when it would delete the clipping path of a group or layer
/// that keeps other objects, or leave a compound path or group that clips one with no visible path,
/// image, placed document or visible type that lays out glyphs to clip by.
/// image, placed document or visible type that lays out glyphs to clip by, or leave an image first
/// in an ordinary group named as a tracing.
fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
let (doc, c) = items_scope(h, a)?;
let (ids, refused, on_locked, masks, tracing) = with_doc(h, doc, |_, st| {
@@ -798,13 +799,10 @@ fn items_remove_all(h: &super::Host, a: &[Data]) -> Answer {
let mut masks = Vec::new();
for n in nodes.into_iter().rev() {
let kids = n.children().map_or(&[][..], Vec::as_slice);
// Without `keepEmpty`, clear removes compound paths emptied of direct members, but keeps
// empty groups. A compound path's own `pathItems.removeAll()` keeps it, empty.
if c.is_none()
&& matches!(n.kind, NodeKind::Compound { .. })
&& !kids.is_empty()
&& kids.iter().all(|k| matches!(k.kind, NodeKind::Path { .. }) && going.contains(&k.id))
{
// Without `keepEmpty`, clear removes compound paths whose members all go, emptied inner
// compound paths included (`emptied_compounds`), but keeps empty groups. A compound
// path's own `pathItems.removeAll()` keeps it, empty.
if c.is_none() && matches!(n.kind, NodeKind::Compound { .. }) && !kids.is_empty() && kids.iter().all(|k| going.contains(&k.id)) {
going.insert(n.id);
}
// A clip outline takes in visible paths, the frames of visible images and placed
+6 -3
View File
@@ -47,10 +47,12 @@ fn owner_of(h: &Host, d: &Data) -> std::result::Result<Owner, HostError> {
}
/// The page item a handle's run, document uid and id (as [`id_parts`] gave it) name, which must
/// still be in its document.
/// still be in its document. A tracing the run traced again is followed to the object that
/// replaced it, which keeps its tags, as its `PluginItem` is.
fn resolve_item(h: &Host, run: f64, uid: f64, high: f64, low: f64) -> std::result::Result<Item, HostError> {
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()))?;
let id = super::tracing::follow(h, doc.uid, id);
let alive = with_doc(h, doc, |_, st| st.doc.node(id).is_some_and(|n| typename(n).is_some()));
if !alive {
return Err(HostError::Error(STALE_ITEM.into()));
@@ -111,7 +113,8 @@ fn doc_of_owner(owner: Owner) -> Doc {
}
fn tag_ref(h: &Host, doc: Doc, id: NodeId, tag: u64) -> Data {
let [high, low] = id_parts(id);
// A tracing traced again keeps the id of the first object of its chain, as its `PluginItem` does.
let [high, low] = id_parts(super::tracing::origin(h, doc.uid, id));
let [tag_high, tag_low] = id_parts(NodeId(tag));
host_ref("Tag", &[float(h.run), float(doc.uid), high, low, tag_high, tag_low])
}
@@ -119,7 +122,7 @@ fn tag_ref(h: &Host, doc: Doc, id: NodeId, tag: u64) -> Data {
/// `PageItem.tags`.
pub(super) fn item_tags(h: &Host, a: &[Data]) -> Answer {
let item = item_of(h, arg(a, 0))?;
let [high, low] = id_parts(item.id);
let [high, low] = id_parts(super::tracing::origin(h, item.doc.uid, item.id));
Ok(host_ref("Tags", &[float(h.run), float(item.doc.uid), high, low]))
}
+3 -2
View File
@@ -1539,7 +1539,8 @@ fn frames_path_text(h: &Host, a: &[Data]) -> Answer {
}
/// `removeAll()`: deletes every type object the collection lists in one command; a hidden or
/// locked one, or one on a locked artboard, stops it first, as `PageItems.removeAll()` does.
/// locked one, or one on a locked artboard, stops it first, as `PageItems.removeAll()` does, and
/// so does an image the deletion would leave first in an ordinary group named as a tracing.
fn frames_remove_all(h: &Host, a: &[Data]) -> Answer {
let (doc, c) = frames_scope(h, a)?;
let (ids, refused, on_locked, released, tracing) = with_doc(h, doc, |_, st| {
@@ -1563,7 +1564,7 @@ fn frames_remove_all(h: &Host, a: &[Data]) -> Answer {
let list = on_locked.iter().map(u64::to_string).collect::<Vec<_>>().join(", ");
return Err(HostError::Error(format!("{ON_LOCKED_ARTBOARD}: {list}")));
}
// A clip group named as a tracing, released with an image left first, would become one.
// A group named as a tracing, cleared or released with an image left first, would become one.
if tracing {
return Err(HostError::Error(super::NOT_A_TRACING.into()));
}
@@ -1659,6 +1659,102 @@ fn retraced_plugin_is_the_same_object_as_its_collection_handle() {
let _ = std::fs::remove_dir_all(base);
}
#[test]
fn retrace_keeps_the_tracing_note_and_tags() {
let base = folder("retrace-attributes");
let (mut s, _) = session(&base, false);
let out = log(
&mut s,
&base,
"var p = app.activeDocument.rasterItems[0].trace(); p.note = 'keep me'; var tags = p.tags, t = tags.add(); t.name = 'job'; t.value = '42';\
p.tracing.tracingOptions.threshold = 90; vc.log(p.note); vc.log(p.tags.length); vc.log(p.tags[0].name + '=' + p.tags[0].value);\
vc.log(tags.length); vc.log(t.value); vc.log(t === p.tags[0]); vc.log(tags === p.tags);",
);
assert_eq!(out, [json!("keep me"), json!(1), json!("job=42"), json!(1), json!("42"), json!(true), json!(true)]);
// Image Trace › Make on the tracing keeps them too.
let id = traces(&s)[0];
let r = s.execute("imageTrace.make", &json!({"id": id.0, "params": {"threshold": 100}})).unwrap();
let id = NodeId(r["id"].as_u64().unwrap());
let d = &s.active().unwrap().doc;
let attrs = d.node(id).and_then(|n| n.extras().attrs.as_deref().cloned()).unwrap_or_default();
assert_eq!(attrs.note, "keep me");
let tags: Vec<(&str, &str)> = attrs.tags.iter().map(|t| (t.name.as_str(), t.value.as_str())).collect();
assert_eq!(tags, [("job", "42")]);
let r = s.execute("imageTrace.makeAndExpand", &json!({"id": id.0})).unwrap();
let id = NodeId(r["id"].as_u64().unwrap());
let d = &s.active().unwrap().doc;
let group = d.node(id).unwrap();
assert!(matches!(group.kind, NodeKind::Group { .. }));
let attrs = group.extras().attrs.as_deref().cloned().unwrap_or_default();
assert_eq!(attrs.note, "keep me");
let tags: Vec<(&str, &str)> = attrs.tags.iter().map(|t| (t.name.as_str(), t.value.as_str())).collect();
assert_eq!(tags, [("job", "42")]);
let _ = std::fs::remove_dir_all(base);
}
/// Tracing again moves the tracing's attributes to the new tracing: it copies them once, when it
/// reads the tracing out of the document, and not again for the new object.
#[test]
fn retrace_copies_the_tracing_attributes_once() {
let base = folder("retrace-attribute-copies");
let (mut s, _) = session(&base, false);
log(
&mut s,
&base,
"var p = app.activeDocument.rasterItems[0].trace(); p.note = 'keep me'; var t = p.tags.add(); t.name = 'job'; t.value = '42';",
);
let id = traces(&s)[0];
let before = vectorcraft_doc::attribute_copies();
let r = s.execute("imageTrace.make", &json!({"id": id.0, "params": {"threshold": 100}})).unwrap();
assert_eq!(vectorcraft_doc::attribute_copies() - before, 1, "copies of the attributes");
let id = NodeId(r["id"].as_u64().unwrap());
let note = s.active().unwrap().doc.node(id).and_then(|n| n.extras().attrs.as_deref().map(|a| a.note.clone()));
assert_eq!(note.as_deref(), Some("keep me"));
let _ = std::fs::remove_dir_all(base);
}
/// `pathItems.removeAll()` and `textFrames.removeAll()` refuse to leave an image at the bottom of an
/// ordinary group named as a tracing, before the document changes.
#[test]
fn path_and_type_remove_all_cannot_leave_an_image_first_in_a_group_named_as_a_tracing() {
let setup = |bottom: &str| {
format!(
"var d = app.activeDocument; d.selection = [{bottom}]; vc.run('object.group');\
var g = d.pageItems[0]; g.name = 'Image Trace'; d.rasterItems[0].move(g, ElementPlacement.PLACEATBEGINNING);"
)
};
for (name, bottom, list) in [
("remove-all-trace-name-paths", "d.pathItems.rectangle(10, 10, 20, 20)", "pathItems"),
// `edit.clear` also deletes the compound path its members leave empty.
(
"remove-all-trace-name-compound",
"(function () { d.selection = [d.pathItems.rectangle(10, 10, 20, 20), d.pathItems.rectangle(40, 40, 5, 5)];\
vc.run('object.compoundPath.make'); return d.pageItems[0]; })()",
"pathItems",
),
("remove-all-trace-name-type", "d.textFrames.pointText([10, 10])", "textFrames"),
] {
let base = folder(name);
let (mut s, _) = session(&base, false);
log(&mut s, &base, &setup(bottom));
let before = vectorcraft_format::save(&s.active().unwrap().doc, false);
let steps = undo_steps(&s);
let out = log(
&mut s,
&base,
&format!(
"var d = app.activeDocument, m = ''; try {{ d.{list}.removeAll(); }} catch (e) {{ m = e.message; }}\
vc.log(m); vc.log(d.pageItems[0].typename);"
),
);
assert_eq!(out, [json!("Only Image Trace can make a tracing"), json!("GroupItem")], "{list}");
assert!(traces(&s).is_empty(), "{list}");
assert_eq!(vectorcraft_format::save(&s.active().unwrap().doc, false), before, "{list}");
assert_eq!(undo_steps(&s), steps, "{list}");
let _ = std::fs::remove_dir_all(base);
}
}
#[test]
fn loading_the_same_preset_in_bracket_form_does_not_trace_again() {
let base = folder("retrace-bracket-preset");
+9 -8
View File
@@ -3214,8 +3214,8 @@ through `$`:
its tracing` and changes nothing; a hidden source image (the default) throws `Cannot move`. Moving or duplicating
an image to the bottom of an ordinary group named `Image Trace` throws `Only Image Trace can make a tracing` before
the document changes, as renaming such a group does. `move`, `remove()` and `zOrder` throw the same error, with
nothing changed, when they would leave an image at the bottom of such a group, and so do `groupItems.removeAll()`
and `compoundPathItems.removeAll()`. An object of
nothing changed, when they would leave an image at the bottom of such a group, and so do `groupItems.removeAll()`,
`compoundPathItems.removeAll()`, `pathItems.removeAll()` and `textFrames.removeAll()`. An object of
another document throws `Cross-document placement is not available`, and when
`node.move` refuses the place of a copy, `duplicate` throws that error and leaves the documents, the selection and
the undo history as they were before the call. `move` on an object that is hidden or locked, inside a hidden or
@@ -3741,12 +3741,13 @@ through `$`:
count the seam fills of an Abutting trace, `usedColorCount` counts the different fill and stroke paints, and
`imageResolution` is the image's pixels per inch as placed, an error for an image placed at different resolutions
across and down. Assigning an option, or `loadFromPreset(name)`, traces again with `imageTrace.make`, keeps the
source image and the view, and a value the tracing already has runs no command. `loadFromPreset(name)` runs no
command only when the tracing's preset is `name` and its current parameters equal that preset's. Preset names match
without regard to letter case, and a built-in preset's name with or without brackets, such as `Default` and
`[Default]`, counts as the same preset. Assigning `viewRaster` or
`viewVector` does not trace again: it runs `imageTrace.setView`. The `PluginItem`, `TracingObject`
and `TracingOptions` follow the new object, and a run traces again at most 10,000 times. Tracing again throws
source image, the view, and the tracing's attributes (its note, tags and URL), and a value the tracing already has
runs no command. `loadFromPreset(name)` runs no command only when the tracing's preset is `name` and its current
parameters equal that preset's. Preset names match without regard to letter case, and a built-in preset's name with
or without brackets, such as `Default` and `[Default]`, counts as the same preset. Assigning `viewRaster` or
`viewVector` does not trace again: it runs `imageTrace.setView`. The `PluginItem`, `TracingObject`,
`TracingOptions` and the tracing's `Tags` and `Tag` objects follow the new object, and a run traces again at most
10,000 times. Tracing again throws
`Cannot retrace a tracing containing added artwork`, with nothing changed, when the tracing holds an object its trace
did not make, whether this run, an earlier run or a command added it (any opacity mask on the tracing or on an object
the trace made counts, whether or not the trace made its art; the source image's own mask does not, since both keep
+1 -1
View File
@@ -1128,7 +1128,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Scripts: `Document.placedItems` and `Document.rasterItems` list a document's linked and embedded images; `placedItems.add()` with a `File` assigned to `file` places an image linked, and `PlacedItem.relink(file)` and `embed()` relink and embed it, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItem/, https://ai-scripting.docsforadobe.dev/jsobjref/RasterItems/ and https://ai-scripting.docsforadobe.dev/jsobjref/RasterItem/ describe them. A raster item's bits per channel, channels, color space and transparency come from its encoded pixels' header. Only files the script may read, of at most 256 MiB and holding an image, are placed or relinked. `crates/engine/src/tests/script_dom_images.rs`.
- Scripts: `app.preferences` reads, stores and removes values by key with the type they were set as, keeps them across runs and restarts, and turns the warning before a picked script on with the key `ShowExternalJSXWarning`, and off only after the person answers Yes to a confirm (https://ai-scripting.docsforadobe.dev/jsobjref/Preferences/; the confirm is VectorCraft's own rule); `app` makes, joins, inverts and compares `Matrix` records (https://ai-scripting.docsforadobe.dev/jsobjref/Matrix/), rounding each joined value once from its exact sum of products and deciding whether an inverted value overflows from its exact quotient, and runs Copy, Cut and Paste on the active document inside the run's transaction (https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `crates/engine/src/tests/script_dom_prefs.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`). For ordinary layer placement, the creators use the topmost shown, unlocked layer when the active layer is locked or hidden. The call also throws and makes no path when the document has layers and every one is locked or hidden. `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked, is on a locked artboard or is a guide while guides are locked, or when it would delete or empty the clipping path of a group or layer that keeps other objects. It still deletes the paths of a group that is the clipping path when a visible text object that lays out glyphs stays inside that group, because the text then clips, and the same holds for a visible image or placed document whose frame encloses an area, unless deleting the paths makes a live geometry effect leave no clipping region where there was one before; text beside the clipping path does not count, and a clipping group nested in the mask counts only when its own clipping path keeps such geometry. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`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. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `crates/engine/src/tests/script_dom_paths.rs`.
- Scripts: `PlacedItem.trace()` and `RasterItem.trace()` make an Image Trace object and return it as a `PluginItem` whose `tracing` gives its path, anchor and color counts, the source image's resolution, `expandTracing()`, `releaseTracing()` and its `TracingOptions`; assigning an option or loading a preset traces it again, except that the view options (`viewRaster` and `viewVector`) only change the view, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PluginItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TracingObject/ and https://ai-scripting.docsforadobe.dev/jsobjref/TracingOptions/ describe them. Loading the built-in preset the tracing already has, by its name with or without brackets (`[Default]`), with unchanged options does not trace again. Option values are checked for type and range before any trace, a script cannot save a preset, and the options without a VectorCraft setting throw. Tracing again and `releaseTracing()` throw, with nothing changed, when the tracing holds added artwork, an opacity mask on the tracing or on an object the trace made included; the source image keeps its own mask. A tracing saved without `made` is checked only for artwork added during the same run, so tracing it again or releasing it discards artwork that was added before the run without an error, and the opacity mask check applies with or without `made`. The source image of a traced item is left out of `pageItems`, `placedItems` and `rasterItems`; a script reaches it through `PluginItem.tracing.sourceArt`. `remove()` also refuses a shown source image. Renaming an ordinary group that holds an image first to `Image Trace`, or moving or duplicating an image to the bottom of an ordinary group with that name, throws an error, and so does a `groupItems.removeAll()` or `compoundPathItems.removeAll()` that would leave an image at the bottom of such a group. `crates/engine/src/tests/script_dom_tracing.rs`.
- Scripts: `PlacedItem.trace()` and `RasterItem.trace()` make an Image Trace object and return it as a `PluginItem` whose `tracing` gives its path, anchor and color counts, the source image's resolution, `expandTracing()`, `releaseTracing()` and its `TracingOptions`; assigning an option or loading a preset traces it again, except that the view options (`viewRaster` and `viewVector`) only change the view, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PluginItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TracingObject/ and https://ai-scripting.docsforadobe.dev/jsobjref/TracingOptions/ describe them. Tracing again keeps the tracing's note, tags and URL. Loading the built-in preset the tracing already has, by its name with or without brackets (`[Default]`), with unchanged options does not trace again. Option values are checked for type and range before any trace, a script cannot save a preset, and the options without a VectorCraft setting throw. Tracing again and `releaseTracing()` throw, with nothing changed, when the tracing holds added artwork, an opacity mask on the tracing or on an object the trace made included; the source image keeps its own mask. A tracing saved without `made` is checked only for artwork added during the same run, so tracing it again or releasing it discards artwork that was added before the run without an error, and the opacity mask check applies with or without `made`. The source image of a traced item is left out of `pageItems`, `placedItems` and `rasterItems`; a script reaches it through `PluginItem.tracing.sourceArt`. `remove()` also refuses a shown source image. Renaming an ordinary group that holds an image first to `Image Trace`, or moving or duplicating an image to the bottom of an ordinary group with that name, throws an error, and so does a `groupItems.removeAll()`, `compoundPathItems.removeAll()`, `pathItems.removeAll()` or `textFrames.removeAll()` that would leave an image at the bottom of such a group. `crates/engine/src/tests/script_dom_tracing.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, fill and stroke colors, stroke weight) 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/, https://ai-scripting.docsforadobe.dev/jsobjref/CharacterAttributes/ 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 are not there yet. `crates/engine/src/tests/script_text.rs`.