Resolve recorded Action reference forms at playback

This commit is contained in:
yoriswind committed 2026-11-01 12:55:02 -08:00
1 parent 2df9f80770
commit 21b6546907
16 files changed
+818 -46

No files matched your search

+15 -3
View File
@@ -103,6 +103,7 @@ pub mod layer_menu_cmds;
pub mod layer_multi_cmds;
pub mod layer_nav_cmds;
mod layer_params;
mod layer_references;
pub mod layer_xmp_cmds;
pub mod lens_cmds;
pub mod magnetic_cmds;
@@ -166,6 +167,7 @@ pub(crate) use enabled::{always, check_all_unlocked, check_pixels_unlocked, has_
use enabled::{can_redo, can_undo, has_doc, has_layer, has_pixel_layer, has_pixel_or_channel, has_selection};
pub use layer_params::blend_from_str;
pub(crate) use layer_params::{NEW_LAYER_PATH, explicit_layer, layer_listing, layer_panel_option, layer_param, mask_at_depth, mask_new_layer, selection_mask};
pub(crate) use layer_references::{recorded_drop, recorded_layer};
use ops::{arrange, merge_group, set_mask, set_mask_and_deselect};
pub(crate) use ops::{layer_copy, translate_layer};
use params::{bad, set_clipped};
@@ -586,7 +588,7 @@ fn build() -> Vec<CommandSpec> {
"Select Layer",
[],
None,
r##"{"layer":id|str | "name":str,"occurrence":index?,"mode":"replace|toggle|range|add|remove"="replace"} (name occurrence: zero-based document walk order; required for duplicate names; toggle = ⌘-click, range = ⇧-click, remove = deselect it, keeping at least one)"##,
r##"{"layer":id|str|{"index":uint}|{"ordinal":"Trgt|Frwr|Bckw|Frnt|Back"} | "name":str,"occurrence":index?,"mode":"replace|toggle|range|add|remove"="replace"} (typed references use the recorded full layer stack; name occurrence: zero-based document walk order; required for duplicate names; toggle = ⌘-click, range = ⇧-click, remove = deselect it, keeping at least one)"##,
has_doc,
crate::layer_multi_cmds::select
),
@@ -910,7 +912,7 @@ fn build() -> Vec<CommandSpec> {
"Reorder Layer",
[],
None,
r##"{"layer":id?| "layers":[id,…]?, "target":id|name,"targetOccurrence":n? (which of several layers named `target`, in document order),"position":"above|below|into"="above","copy":bool=false} (layers: one undoable move, document order preserved; copy: place duplicates there and leave the layers, as ⌥-dragging a Layers panel row; a recorded action keeps the target by name)"##,
r##"{"layer":id|{"index":uint}|{"ordinal":"Trgt|Frwr|Bckw|Frnt|Back"}?| "layers":[id,…]?, "target":id|name|{"index":uint},"targetOccurrence":n? (which of several layers named `target`, in document order),"position":"above|below|into"="above","copy":bool=false} (typed target: pre-move recorded stack boundary, omit position; layers: one undoable move, document order preserved; copy: place duplicates there and leave the layers, as ⌥-dragging a Layers panel row; recorded typed references retain their form)"##,
has_layer,
crate::layer_multi_cmds::move_to
),
@@ -1045,7 +1047,7 @@ fn build() -> Vec<CommandSpec> {
label: "Activate Document",
menu: &[],
shortcut: None,
params: r##"{"document":index} or {"offset":int} (the document that many places after the active one in opening order, before it when negative: a Photoshop action's switch to another document) → {document}"##,
params: r##"{"document":index|{"index":uint}} or {"offset":int} (numeric document: zero-based tab index; typed index: one-based opening order; offset: places after the active document in opening order, before it when negative) → {document}"##,
enabled: has_doc,
run: |s, p| {
// A null key counts as omitted.
@@ -1060,6 +1062,16 @@ fn build() -> Vec<CommandSpec> {
s.document_at_offset(o)?
}
(Some(d), None) => {
if let Some(selector) = d.as_object() {
let index = selector
.get("index")
.filter(|_| selector.len() == 1)
.and_then(Value::as_u64)
.ok_or_else(|| bad("document.activate", "document reference needs one non-negative index"))?;
return s
.document_at_index(index)
.and_then(|idx| if s.set_active(idx) { Ok(json!({"document": idx})) } else { Err(EngineError::NoDocument) });
}
let i = d.as_u64().ok_or_else(|| bad("document.activate", "`document` must be a tab index"))?;
usize::try_from(i).map_err(|_| bad("document.activate", "`document` out of range"))?
}
@@ -116,6 +116,22 @@ pub(super) fn layer_target(r: &[ReferenceItem]) -> Option<Map<String, Value>> {
Some(m)
}
/// Select and Move retain stack references until playback rather than capturing local ids.
pub(super) fn recorded_layer_target(r: &[ReferenceItem]) -> Option<Map<String, Value>> {
let selector = match r {
[ReferenceItem::Index { class, index }] if trimmed(&class.class_id) == "Lyr" => json!({"index": index}),
[ReferenceItem::Enumerated { class, type_id, value }]
if trimmed(&class.class_id) == "Lyr" && type_id.is("Ordn") && matches!(trimmed(value).as_str(), "Trgt" | "Frwr" | "Bckw" | "Frnt" | "Back") =>
{
json!({"ordinal": trimmed(value)})
}
[ReferenceItem::Index { .. } | ReferenceItem::Enumerated { .. }] => return None,
_ if matches!(target(r), Target::Index(_) | Target::Ordinal(_)) => return None,
_ => return layer_target(r),
};
Some(Map::from_iter([("layer".into(), selector)]))
}
// ------------------------------------------------------------------ descriptor building
/// A Photoshop id: codes shorter than four characters are space-padded (`H `, `Rd `),
@@ -181,6 +197,27 @@ pub(super) fn layer_ref(p: &Value) -> Option<D> {
}
}
/// Write the recorded form, including the padded four-byte ordinal codes.
pub(super) fn recorded_layer_ref(p: &Value) -> Option<D> {
let Some(Value::Object(selector)) = p.get("layer") else { return layer_ref(p) };
if !selector.contains_key("index") && !selector.contains_key("ordinal") {
return layer_ref(p);
}
if selector.len() != 1 {
return None;
}
let item = if let Some(index) = selector.get("index") {
ReferenceItem::Index { class: class("Lyr "), index: u32::try_from(index.as_u64()?).ok()? }
} else {
let ordinal = selector.get("ordinal")?.as_str()?;
if !matches!(ordinal, "Trgt" | "Frwr" | "Bckw" | "Frnt" | "Back") {
return None;
}
ReferenceItem::Enumerated { class: class("Lyr "), type_id: code("Ordn"), value: code(ordinal) }
};
Some(D::Reference(vec![item]))
}
pub(super) fn desc(cls: &str) -> Descriptor {
Descriptor::new(cls)
}
+8 -1
View File
@@ -478,7 +478,14 @@ pub(super) const EVENTS: &[Event] = &[
code: "move",
name: "move",
label: "Move",
ids: &["layer.translate", "layer.arrange.bringToFront", "layer.arrange.sendToBack", "layer.arrange.bringForward", "layer.arrange.sendBackward"],
ids: &[
"layer.translate",
"layer.moveTo",
"layer.arrange.bringToFront",
"layer.arrange.sendToBack",
"layer.arrange.bringForward",
"layer.arrange.sendBackward",
],
from: move_from,
to: move_to,
},
+84 -31
View File
@@ -1,7 +1,7 @@
use super::convert::clip_name;
use super::descriptors::{
PT, PX, Target, ang, class, code, color_desc, color_hex, desc, enm, get_bool, get_enum, get_num, get_obj, get_ref, get_text, jbool, jnum, jstr, layer_ref,
layer_target, long, name_ref, pct, px, ref_class, target, target_ref, text, trimmed,
layer_target, long, name_ref, pct, px, recorded_layer_ref, recorded_layer_target, ref_class, target, target_ref, text, trimmed,
};
use super::events::pixel_target;
use super::fields::{F, Kind, Mapped, fields_to, none, step, steps};
@@ -9,11 +9,13 @@ use super::steps_make::is_tool_class;
use super::tables::{FILL_CONTENTS, INTERPOLATION, MENU_ITEMS, STROKE_LOCATION, blend_label, blend_ps, lookup, lookup_back};
use super::{D, Descriptor, Id, Map, ReferenceItem, UnicodeString, Value, json};
/// Import recorded targets while retaining stack and opening-order references for playback.
pub(super) fn select_from(d: &Descriptor) -> Mapped {
let Some(r) = get_ref(d, "null") else { return Mapped::Unsupported { harmless: false } };
match (ref_class(r).as_deref(), target(r)) {
(Some("Lyr"), Target::Name(n)) => {
let mut p = json!({"layer": n});
(Some("Lyr"), Target::Name(_) | Target::Index(_) | Target::Ordinal(_)) => {
let Some(params) = recorded_layer_target(r) else { return Mapped::Unsupported { harmless: false } };
let mut p = Value::Object(params);
match get_enum(d, "selectionModifier").as_deref() {
Some("addToSelection") => p["mode"] = json!("add"),
Some("removeFromSelection") => p["mode"] = json!("remove"),
@@ -34,19 +36,6 @@ pub(super) fn select_from(d: &Descriptor) -> Mapped {
// History › Step Backward / Step Forward.
(Some("HstS"), Target::Ordinal(o)) if o == "Prvs" => none("edit.undo"),
(Some("HstS"), Target::Ordinal(o)) if o == "Nxt" => none("edit.redo"),
(Some("Lyr"), Target::Ordinal(o)) => {
// Shift+Alt+[ / ] add the next layer to the selection instead of replacing it.
let add = get_enum(d, "selectionModifier").as_deref() == Some("addToSelection");
match (o.as_str(), add) {
("Frwr", false) => none("layer.selectAbove"),
("Frwr", true) => none("layer.addAboveToSelection"),
("Bckw", false) => none("layer.selectBelow"),
("Bckw", true) => none("layer.addBelowToSelection"),
("Frnt", _) => none("layer.selectTop"),
("Back", _) => none("layer.selectBottom"),
_ => Mapped::Unsupported { harmless: false },
}
}
(Some(c), Target::Class) if is_tool_class(c) => Mapped::Unsupported { harmless: true },
// A menu item chosen while recording (`Mn`): the View menu's zoom items replay.
(Some("Mn"), Target::Ordinal(item)) => match lookup(MENU_ITEMS, &item) {
@@ -56,10 +45,12 @@ pub(super) fn select_from(d: &Descriptor) -> Mapped {
// Switching to another open document: its offset from the active one, -1 for the previous
// opened document and 1 for the next, independently of dragged tabs (#7103).
(Some("Dcmn"), Target::Offset(o)) => step("document.activate", json!({"offset": o})),
(Some("Dcmn"), Target::Index(index)) if r.len() == 1 => step("document.activate", json!({"document": {"index": index}})),
_ => Mapped::Unsupported { harmless: false },
}
}
/// Write supported selection/navigation references without replacing their kind with a name.
pub(super) fn select_to(id: &str, p: &Value) -> Option<Descriptor> {
let ord = |o: &str| D::Reference(vec![ReferenceItem::Enumerated { class: class("Lyr "), type_id: code("Ordn"), value: code(o) }]);
let enumerated = |cls: &str, ty: &str, v: &str| D::Reference(vec![ReferenceItem::Enumerated { class: class(cls), type_id: code(ty), value: code(v) }]);
@@ -68,8 +59,13 @@ pub(super) fn select_to(id: &str, p: &Value) -> Option<Descriptor> {
if p.get("occurrence").is_some() {
return None;
}
let name = jstr(p, "name").or_else(|| jstr(p, "layer"))?;
let mut d = desc("null").with("null", name_ref("Lyr ", name));
let reference = if let Some(name) = p.get("name") {
name_ref("Lyr ", name.as_str()?)
} else {
p.get("layer").filter(|v| !v.is_null())?;
recorded_layer_ref(p)?
};
let mut d = desc("null").with("null", reference);
match jstr(p, "mode") {
None | Some("replace") => {}
Some("add") => d = d.with("selectionModifier", enm("selectionModifierType", "addToSelection")),
@@ -95,7 +91,15 @@ pub(super) fn select_to(id: &str, p: &Value) -> Option<Descriptor> {
"layer.addBelowToSelection" => desc("null").with("null", ord("Bckw")).with("selectionModifier", enm("selectionModifierType", "addToSelection")),
"layer.selectTop" => desc("null").with("null", ord("Frnt")),
"layer.selectBottom" => desc("null").with("null", ord("Back")),
// An absolute tab index has no Photoshop equivalent; an offset is what Photoshop records.
"document.activate" if p.get("document").is_some_and(Value::is_object) => {
if p.get("offset").is_some_and(|v| !v.is_null()) {
return None;
}
let selector = p.get("document")?.as_object().filter(|selector| selector.len() == 1)?;
let index = u32::try_from(selector.get("index")?.as_u64()?).ok()?;
desc("null").with("null", D::Reference(vec![ReferenceItem::Index { class: class("Dcmn"), index }]))
}
// A native numeric document selects a tab; the typed index above selects opening order.
"document.activate" if p.get("document").is_none_or(Value::is_null) => {
let offset = i32::try_from(p.get("offset")?.as_i64()?).ok()?;
desc("null").with("null", D::Reference(vec![ReferenceItem::Offset { class: class("Dcmn"), offset }]))
@@ -193,6 +197,7 @@ pub(super) fn visibility_to(_: &str, p: &Value) -> Option<Descriptor> {
Some(desc("null").with("null", D::List(vec![layer_ref(p)?])))
}
/// Import supported layer moves while retaining pre-move stack boundaries.
pub(super) fn move_from(d: &Descriptor) -> Mapped {
let Some(r) = get_ref(d, "null") else { return Mapped::Unsupported { harmless: false } };
// The selection outline nudged.
@@ -208,7 +213,7 @@ pub(super) fn move_from(d: &Descriptor) -> Mapped {
if ref_class(r).as_deref() != Some("Lyr") {
return Mapped::Unsupported { harmless: false };
}
let Some(mut p) = layer_target(r) else { return Mapped::Unsupported { harmless: false } };
let Some(mut p) = layer_target(r).or_else(|| recorded_layer_target(r)) else { return Mapped::Unsupported { harmless: false } };
match d.get("T ") {
Some(D::Descriptor(t)) => {
let unit = |k: &str| match t.get(k) {
@@ -233,15 +238,18 @@ pub(super) fn move_from(d: &Descriptor) -> Mapped {
step("layer.translate", Value::Object(p))
}
Some(D::Reference(t)) => {
if let Target::Index(index) = target(t) {
if t.len() != 1 || ref_class(t).as_deref() != Some("Lyr") {
return Mapped::Unsupported { harmless: false };
}
p.insert("target".into(), json!({"index": index}));
return step("layer.moveTo", Value::Object(p));
}
let id = match target(t) {
Target::Ordinal(o) if o == "Frnt" => "layer.arrange.bringToFront",
Target::Ordinal(o) if o == "Back" => "layer.arrange.sendToBack",
Target::Ordinal(o) if o == "Nxt" => "layer.arrange.bringForward",
Target::Ordinal(o) if o == "Prvs" => "layer.arrange.sendBackward",
Target::Offset(1) => "layer.arrange.bringForward",
Target::Offset(-1) => "layer.arrange.sendBackward",
// Index 0 is the bottom of the stack.
Target::Index(0) => "layer.arrange.sendToBack",
_ => return Mapped::Unsupported { harmless: false },
};
step(id, Value::Object(p))
@@ -250,9 +258,20 @@ pub(super) fn move_from(d: &Descriptor) -> Mapped {
}
}
/// Encode an indexed boundary or a supported relative move without losing its source selector.
pub(super) fn move_to(id: &str, p: &Value) -> Option<Descriptor> {
let ord = |o: &str| D::Reference(vec![ReferenceItem::Enumerated { class: class("Lyr "), type_id: code("Ordn"), value: code(o) }]);
let t = match id {
"layer.moveTo" => {
if ["layers", "position", "targetOccurrence"].iter().any(|key| p.get(key).is_some_and(|value| !value.is_null()))
|| p.get("copy").is_some_and(|value| value.as_bool() != Some(false))
{
return None;
}
let selector = p.get("target")?.as_object().filter(|selector| selector.len() == 1)?;
let index = u32::try_from(selector.get("index")?.as_u64()?).ok()?;
D::Reference(vec![ReferenceItem::Index { class: class("Lyr "), index }])
}
"layer.translate" => {
let unit = match jstr(p, "units") {
None | Some("px") => PX,
@@ -268,7 +287,7 @@ pub(super) fn move_to(id: &str, p: &Value) -> Option<Descriptor> {
"layer.arrange.sendBackward" => ord("Prvs"),
_ => return None,
};
Some(desc("null").with("null", layer_ref(p)?).with("T ", t))
Some(desc("null").with("null", recorded_layer_ref(p)?).with("T ", t))
}
pub(super) fn duplicate_from(d: &Descriptor) -> Mapped {
@@ -326,18 +345,52 @@ pub(super) fn duplicate_to(id: &str, p: &Value) -> Option<Descriptor> {
Some(d)
}
/// Only a comp name in the active document is portable across action playback.
/// Retain measured comp reference forms and resolve them against the playback document.
pub(super) fn apply_comp_from(d: &Descriptor) -> Mapped {
match get_ref(d, "null") {
let comp = match get_ref(d, "null") {
Some([ReferenceItem::Name { class, name }]) if trimmed(&class.class_id) == "compsClass" => {
step("layerComp.apply", json!({"comp": name.to_string_lossy()}))
json!(name.to_string_lossy())
}
_ => Mapped::Unsupported { harmless: false },
}
Some([ReferenceItem::Index { class, index }]) if trimmed(&class.class_id) == "compsClass" => json!({"index": index}),
Some([ReferenceItem::Identifier { class, id }]) if trimmed(&class.class_id) == "compsClass" => json!({"id": id}),
Some([ReferenceItem::Enumerated { class, type_id, value }])
if trimmed(&class.class_id) == "compsClass"
&& type_id.is("Ordn")
&& matches!(trimmed(value).as_str(), "Trgt" | "Nxt" | "Prvs" | "Frst" | "Lst" | "Al") =>
{
json!({"ordinal": trimmed(value)})
}
_ => return Mapped::Unsupported { harmless: false },
};
step("layerComp.apply", json!({"comp": comp}))
}
/// Write the original reference kind, including padded ordinal codes and signed index bits.
pub(super) fn apply_comp_to(_: &str, p: &Value) -> Option<Descriptor> {
Some(desc("null").with("null", name_ref("compsClass", jstr(p, "comp")?)))
let reference = match p.get("comp")? {
Value::String(name) => name_ref("compsClass", name),
Value::Object(selector) if selector.len() == 1 => {
let item = if let Some(index) = selector.get("index") {
let index = if let Some(index) = index.as_u64() {
u32::try_from(index).ok()?
} else {
u32::from_be_bytes(i32::try_from(index.as_i64()?).ok()?.to_be_bytes())
};
ReferenceItem::Index { class: class("compsClass"), index }
} else if let Some(id) = selector.get("id") {
ReferenceItem::Identifier { class: class("compsClass"), id: u32::try_from(id.as_u64()?).ok()? }
} else {
let ordinal = selector.get("ordinal")?.as_str()?;
if !matches!(ordinal, "Trgt" | "Nxt" | "Prvs" | "Frst" | "Lst" | "Al") {
return None;
}
ReferenceItem::Enumerated { class: class("compsClass"), type_id: code("Ordn"), value: code(ordinal) }
};
D::Reference(vec![item])
}
_ => return None,
};
Some(desc("null").with("null", reference))
}
pub(super) fn play_from(d: &Descriptor) -> Mapped {
+31 -6
View File
@@ -184,10 +184,9 @@ fn layer_comp_apply_unknown_references_are_kept_and_stop_playback() {
Some(D::Integer(1)),
Some(D::Reference(vec![])),
Some(name_ref("Lyr ", "Comp 1")),
Some(target_ref("compsClass")),
Some(class_ref("compsClass")),
Some(D::Reference(vec![ReferenceItem::Index { class: class("compsClass"), index: 1 }])),
Some(D::Reference(vec![ReferenceItem::Identifier { class: class("compsClass"), id: 1 }])),
Some(D::Reference(vec![ReferenceItem::Offset { class: class("compsClass"), offset: 1 }])),
Some(D::Reference(vec![ReferenceItem::Enumerated { class: class("compsClass"), type_id: code("Ordn"), value: code("unsupported") }])),
Some(D::Reference(vec![
ReferenceItem::Name { class: class("compsClass"), name: UnicodeString::new_nul("Comp 1") },
ReferenceItem::Name { class: class("Dcmn"), name: UnicodeString::new_nul("Other") },
@@ -473,6 +472,7 @@ fn settings_at_the_value_the_event_plays_still_export() {
}
}
/// Every exported command has a canonical import, including recorded full-stack navigation.
#[test]
fn every_mapped_command_exports_and_imports_back() {
let cases: Vec<(&str, Value)> = vec![
@@ -564,6 +564,11 @@ fn every_mapped_command_exports_and_imports_back() {
("layer.setLabelColor", json!({"color": "red"})),
("layer.select", json!({"layer": "Shadow", "mode": "add"})),
("layer.select", json!({"layer": "Shadow", "mode": "range"})),
("layer.select", json!({"layer": {"index": 2}})),
("layer.moveTo", json!({"target": {"index": 0}})),
("layer.moveTo", json!({"layer": {"index": 2}, "target": {"index": 4}})),
("layer.selectAbove", json!({})),
("layer.selectBottom", json!({})),
("layer.selectTop", json!({})),
("layer.selectBelow", json!({})),
("layer.addBelowToSelection", json!({})),
@@ -641,6 +646,7 @@ fn every_mapped_command_exports_and_imports_back() {
("actions.play", json!({"action": "Other", "set": "S"})),
(STOP_MESSAGE, json!({"message": "Hi", "allowContinue": false})),
("document.activate", json!({"offset": -1})),
("document.activate", json!({"document": {"index": 2}})),
// The TrueGrit Texture Supply sets (Debaser, Distress Press, Halftone Zine Machine).
("filter.distort.ripple", json!({"amount": 50, "size": "medium"})),
("filter.pixelate.crystallize", json!({"cellSize": 5})),
@@ -672,6 +678,9 @@ fn every_mapped_command_exports_and_imports_back() {
("history.clear", json!({})),
("history.newSnapshot", json!({"name": "CopyCat - action result", "from": "fullDocument", "replaceExisting": true})),
("layerComp.apply", json!({"comp": "Comp 1"})),
("layerComp.apply", json!({"comp": {"index": 2}})),
("layerComp.apply", json!({"comp": {"id": 7}})),
("layerComp.apply", json!({"comp": {"ordinal": "Nxt"}})),
];
for (id, params) in &cases {
let item = export_item(id, params, "S").unwrap_or_else(|| panic!("{id} does not export"));
@@ -684,6 +693,23 @@ fn every_mapped_command_exports_and_imports_back() {
match (e.from)(item.descriptor.as_ref().unwrap()) {
Mapped::Steps(steps) => {
assert_eq!(steps.len(), 1, "{id}: {steps:?}");
let navigation = match *id {
"layer.selectAbove" => Some(("Frwr", false)),
"layer.selectBelow" => Some(("Bckw", false)),
"layer.selectTop" => Some(("Frnt", false)),
"layer.selectBottom" => Some(("Back", false)),
"layer.addAboveToSelection" => Some(("Frwr", true)),
"layer.addBelowToSelection" => Some(("Bckw", true)),
_ => None,
};
if let Some((ordinal, add)) = navigation {
let mut expected = json!({"layer": {"ordinal": ordinal}});
if add {
expected["mode"] = json!("add");
}
assert_eq!(steps, vec![("layer.select".into(), expected)]);
continue;
}
assert_eq!(steps[0].0, *id, "{id} came back as another command");
let mut back = steps[0].1.clone();
normalise(&mut back);
@@ -739,8 +765,6 @@ fn every_mapped_command_exports_and_imports_back() {
"layer.newAdjustmentLayer.vibrance",
"layer.rasterize.layer",
"layer.renameLayer",
"layer.selectAbove",
"layer.selectBottom",
"layer.setAdjustment",
"select.allLayers",
"select.deselectLayers",
@@ -1483,10 +1507,11 @@ fn remaining_events_import_in_their_photoshop_shapes() {
let more_steps = &more.actions[0].steps;
assert_eq!(
more_steps.iter().map(|(id, _)| id.as_str()).collect::<Vec<_>>(),
["edit.transform", "select.transformSelection", "layer.arrange.sendToBack", "view.fitOnScreen", "tools.setColors"]
["edit.transform", "select.transformSelection", "layer.moveTo", "view.fitOnScreen", "tools.setColors"]
);
assert_eq!(more_steps[0].1, json!({"dx": 4, "dy": 6, "scaleX": 50, "scaleY": 50}));
assert_eq!(more_steps[1].1, json!({"dx": 3, "dy": -2}));
assert_eq!(more_steps[2].1, json!({"target": {"index": 0}}));
assert_eq!(more_steps[4].1, json!({"foreground": "#000000"}));
assert!(more.unsupported.is_empty());
assert_eq!(rest_steps[0].1, json!({"if": "hasLayers", "then": "FS8-Layers", "else": "FS8-No-Layers"}));
+41 -1
View File
@@ -202,8 +202,38 @@ fn apply(s: &mut Session, id: u32, label: &str) -> Result<Value> {
Ok(json!({"comp": id, "missingLayers": missing}))
}
/// Resolve recorded comp forms without confusing panel indexes with persisted ids.
fn recorded_comp(doc: &Document, selector: &Value) -> Result<Option<u32>> {
const CMD: &str = "layerComp.apply";
let fields = selector.as_object().filter(|fields| fields.len() == 1).ok_or_else(|| bad(CMD, "comp reference needs one index, id or ordinal"))?;
if let Some(index) = fields.get("index") {
if let Some(index) = index.as_u64() {
return Ok(index.checked_sub(1).and_then(|index| usize::try_from(index).ok()).and_then(|index| doc.layer_comps.get(index)).map(|comp| comp.id));
}
if index.as_i64().is_some_and(|index| index < 0) {
return Ok(None);
}
return Err(bad(CMD, "comp index must be an integer"));
}
if let Some(id) = fields.get("id") {
let id = crate::commands::u32_id(CMD, "comp id", id)?;
return doc.comp(id).map(|comp| Some(comp.id)).ok_or_else(|| bad(CMD, format!("no layer comp with id {id}")));
}
let ordinal = fields.get("ordinal").and_then(Value::as_str).ok_or_else(|| bad(CMD, "comp reference needs an index, id or ordinal"))?;
match ordinal {
"Trgt" | "Nxt" | "Prvs" => Ok(doc.last_applied_comp.filter(|id| doc.comp(*id).is_some()).or_else(|| doc.layer_comps.first().map(|comp| comp.id))),
"Frst" | "Lst" | "Al" => Ok(doc.layer_comps.first().map(|comp| comp.id)),
_ => Err(bad(CMD, format!("unsupported comp ordinal {ordinal}"))),
}
}
/// Apply the selected comp; an out-of-range recorded index succeeds without an edit.
fn apply_cmd(s: &mut Session, p: &Value) -> Result<Value> {
let d = s.active().ok_or(EngineError::NoDocument)?;
if let Some(selector @ Value::Object(_)) = p.get("comp") {
let Some(id) = recorded_comp(&d.doc, selector)? else { return Ok(json!({"comp": null, "unchanged": true})) };
return apply(s, id, "Apply Layer Comp");
}
let id = comp_param(&d.doc, p, "layerComp.apply")?;
apply(s, id, "Apply Layer Comp")
}
@@ -213,6 +243,9 @@ fn apply_cmd(s: &mut Session, p: &Value) -> Result<Value> {
/// (#7181); by name the step finds that document's comp of the name, or stops with an error.
/// The comp is the one just applied, so `{}` and `null` (the last applied) record its name too.
pub(crate) fn recorded_apply(s: &Session, mut p: Value) -> Value {
if p.get("comp").is_some_and(Value::is_object) {
return p;
}
let Some(d) = s.active() else { return p };
let Some(comp) = d.doc.last_applied_comp.and_then(|id| d.doc.comp(id)) else { return p };
// `null` params run as `{}` (the last applied comp), so they are recorded by name too.
@@ -461,7 +494,14 @@ pub fn specs() -> Vec<CommandSpec> {
has_comps,
update_comp
),
spec!("layerComp.apply", "Apply Layer Comp", &[], r##"{"comp":id|name? (default: last applied)} → {comp, missingLayers}"##, has_comps, apply_cmd),
spec!(
"layerComp.apply",
"Apply Layer Comp",
&[],
r##"{"comp":id|name|{"index":int}|{"id":uint}|{"ordinal":"Trgt|Nxt|Prvs|Frst|Lst|Al"}? (default: last applied; typed index is one-based panel order, invalid indexes do nothing)} → {comp, missingLayers}"##,
has_comps,
apply_cmd
),
spec!("layerComp.previous", "Apply Previous Layer Comp", &[], "{}", has_comps, |s, _| step(s, -1)),
spec!("layerComp.next", "Apply Next Layer Comp", &[], "{}", has_comps, |s, _| step(s, 1)),
spec!("layerComp.delete", "Delete Layer Comp", &[], r##"{"comp":id|name?}"##, has_comps, delete),
@@ -396,6 +396,38 @@ fn apply_move(doc: &mut Document, moved_ids: &[LayerId], target: LayerId, pos: &
/// selected nodes are detached, and every reference is validated before editing.
pub fn move_to(s: &mut Session, p: &Value) -> Result<Value> {
const CMD: &str = "layer.moveTo";
let indexed = p.get("target").is_some_and(Value::is_object);
let resolved;
let p = if let Some(Value::Object(selector)) = p.get("target") {
let index = selector
.get("index")
.filter(|_| selector.len() == 1)
.and_then(Value::as_u64)
.ok_or_else(|| bad(CMD, "target reference needs one non-negative index"))?;
if p.get("position").is_some_and(|value| !value.is_null()) {
return Err(bad(CMD, "an indexed target already defines its drop position"));
}
let doc = &s.active().ok_or(EngineError::NoDocument)?.doc;
let (target, position) = crate::commands::recorded_drop(doc, index)?;
let mut fields = p.as_object().cloned().ok_or_else(|| bad(CMD, "params must be an object"))?;
fields.insert("target".into(), json!(target.0));
fields.insert("position".into(), json!(position));
if !fields.contains_key("layer") && !fields.contains_key("layers") {
match selected(s).as_slice() {
[layer] => {
fields.insert("layer".into(), json!(layer.0));
}
layers if !layers.is_empty() => {
fields.insert("layers".into(), json!(layers.iter().map(|layer| layer.0).collect::<Vec<_>>()));
}
_ => {}
}
}
resolved = Value::Object(fields);
&resolved
} else {
p
};
let pos = p.get("position").and_then(Value::as_str).unwrap_or("above");
if !matches!(pos, "above" | "below" | "into") {
return Err(bad(CMD, "position must be above, below, or into"));
@@ -432,7 +464,7 @@ pub fn move_to(s: &mut Session, p: &Value) -> Result<Value> {
}
}
let moved_ids = top_level(doc, &requested);
if moved_ids.len() == 1 && moved_ids[0] == target && batch.is_none() && !copy {
if moved_ids.len() == 1 && moved_ids[0] == target && (batch.is_none() || indexed) && !copy {
// Preserve single-layer drag-to-self semantics.
return Ok(Value::Null);
}
@@ -449,6 +481,26 @@ pub fn move_to(s: &mut Session, p: &Value) -> Result<Value> {
return Err(bad(CMD, "target is not a group"));
}
if indexed
&& !copy
&& let [source] = moved_ids.as_slice()
{
let source_path = doc.path_of(*source).ok_or(EngineError::NoLayer(*source))?;
if let Some((&at, parent)) = source_path.split_last() {
let unchanged = match pos {
"below" => target_path.split_last().is_some_and(|(&to, target_parent)| parent == target_parent && at.checked_add(1) == Some(to)),
"into" => {
parent == target_path.as_slice()
&& doc.layer(target).and_then(Layer::children).is_some_and(|children| at.checked_add(1) == Some(children.len()))
}
_ => false,
};
if unchanged {
return Ok(Value::Null);
}
}
}
let original_active = st.active_layer;
let add_copy = crate::commands::layer_panel_option(s, "addCopyToCopiedLayersAndGroups", true);
let (count, copies) = s.edit(if copy { "Duplicate Layer" } else { "Reorder Layers" }, |doc, active| {
@@ -222,6 +222,20 @@ fn range_order(layers: &[Layer], include_collapsed: bool, out: &mut Vec<LayerId>
/// `layer.select`: `{"layer": id, "mode": "replace|toggle|range|add|remove"}`.
pub fn select(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(selector @ Value::Object(fields)) = p.get("layer")
&& (fields.contains_key("index") || fields.contains_key("ordinal"))
&& crate::commands::recorded_layer(s, selector)?.is_none()
{
if p.get("name").is_some() || p.get("occurrence").is_some() {
return Err(bad("layer.select", "a layer reference cannot be combined with name or occurrence"));
}
let mode = p.get("mode").and_then(Value::as_str).unwrap_or("replace");
if !matches!(mode, "replace" | "toggle" | "range" | "add" | "remove") {
return Err(bad("layer.select", format!("unknown mode `{mode}`")));
}
// A group-end index leaves the active layer, anchor and full selection unchanged.
return Ok(json!({"selected": selected(s).iter().map(|id| id.0).collect::<Vec<_>>()}));
}
let id = selection_target(s, p)?;
let mode = p.get("mode").and_then(Value::as_str).unwrap_or("replace");
let st = s.active().ok_or(EngineError::NoDocument)?;
+2
View File
@@ -21,6 +21,7 @@ pub(crate) fn explicit_layer(s: &Session, p: &Value) -> Result<Option<LayerId>>
.map(|(_, _, l)| Some(l.id))
.ok_or_else(|| EngineError::Other(format!("no layer named \"{name}\"; {}", layer_listing(&d.doc))))
}
Some(v @ Value::Object(fields)) if fields.contains_key("index") || fields.contains_key("ordinal") => super::recorded_layer(s, v),
Some(Value::Null) | None => Ok(None),
Some(other) => Err(EngineError::Other(format!("`layer` must be an id or a name, not {other}"))),
}
@@ -51,6 +52,7 @@ pub(crate) fn layer_listing(doc: &Document) -> String {
pub(crate) fn layer_param(s: &Session, p: &Value) -> Result<LayerId> {
match explicit_layer(s, p)? {
Some(id) => Ok(id),
None if p.get("layer").is_some_and(Value::is_object) => Err(EngineError::Other("a group end is not a layer".into())),
None => s.active().and_then(|d| d.active_layer).ok_or(EngineError::Other("no active layer".into())),
}
}
+79
View File
@@ -0,0 +1,79 @@
//! Recorded layer references use the full stack, including hidden group-end entries.
use super::{Document, EngineError, LayerId, Result, Session, Value};
#[derive(Clone, Copy)]
enum Entry {
Layer(LayerId),
GroupEnd(LayerId),
}
/// Bottom-to-top recording order, independent of collapsed Layers panel rows.
fn stack(doc: &Document) -> Vec<Entry> {
let mut pending: Vec<_> = doc.layers.iter().rev().map(|layer| (layer, false)).collect();
let mut out = Vec::new();
while let Some((layer, visited)) = pending.pop() {
if !visited && let Some(children) = layer.children() {
out.push(Entry::GroupEnd(layer.id));
pending.push((layer, true));
pending.extend(children.iter().rev().map(|child| (child, false)));
} else {
out.push(Entry::Layer(layer.id));
}
}
out
}
fn bad(message: impl Into<String>) -> EngineError {
EngineError::Other(message.into())
}
/// A Background occupies index zero; without it the first stack entry is one.
fn at_index(doc: &Document, index: u64) -> Result<Entry> {
let first = u64::from(doc.background().is_none());
let entry = index.checked_sub(first).and_then(|n| usize::try_from(n).ok()).and_then(|n| stack(doc).get(n).copied());
entry.ok_or_else(|| bad(format!("no layer at stack index {index}")))
}
/// Resolve one typed selector; a group-end index succeeds without selecting a layer.
pub(crate) fn recorded_layer(s: &Session, selector: &Value) -> Result<Option<LayerId>> {
let fields = selector.as_object().filter(|fields| fields.len() == 1).ok_or_else(|| bad("layer reference needs one index or ordinal"))?;
let st = s.active().ok_or(EngineError::NoDocument)?;
if let Some(index) = fields.get("index") {
let index = index.as_u64().ok_or_else(|| bad("layer index must be a non-negative integer"))?;
return Ok(match at_index(&st.doc, index)? {
Entry::Layer(id) => Some(id),
Entry::GroupEnd(_) => None,
});
}
let ordinal = fields.get("ordinal").and_then(Value::as_str).ok_or_else(|| bad("layer reference needs an index or ordinal"))?;
let rows: Vec<_> = stack(&st.doc).into_iter().filter_map(|entry| if let Entry::Layer(id) = entry { Some(id) } else { None }).collect();
let last = rows.len().checked_sub(1).ok_or_else(|| bad("the document has no layers"))?;
let current = st.active_layer.and_then(|id| rows.iter().position(|layer| *layer == id));
let target = match ordinal {
"Frnt" => last,
"Back" => 0,
"Trgt" => current.ok_or_else(|| bad("no active layer"))?,
"Frwr" => current.ok_or_else(|| bad("no active layer"))?.saturating_add(1).min(last),
"Bckw" => current.ok_or_else(|| bad("no active layer"))?.saturating_sub(1),
_ => return Err(bad(format!("unsupported layer ordinal {ordinal}"))),
};
rows.get(target).copied().map(Some).ok_or_else(|| bad("no layer there"))
}
/// Convert a pre-move stack boundary to an existing layer.moveTo drop position.
pub(crate) fn recorded_drop(doc: &Document, index: u64) -> Result<(LayerId, &'static str)> {
if index == 0 {
if doc.background().is_some() {
return Err(bad("cannot move a layer below the Background"));
}
return doc.layers.first().map(|layer| (layer.id, "below")).ok_or_else(|| bad("the document has no layers"));
}
match at_index(doc, index)? {
Entry::GroupEnd(id) => Ok((id, "below")),
Entry::Layer(id) => {
let position = if doc.layer(id).is_some_and(|layer| layer.is_group()) { "into" } else { "below" };
Ok((id, position))
}
}
}
+10
View File
@@ -114,6 +114,16 @@ impl Session {
self.docs.iter().position(|st| st.doc.id == *id).ok_or(EngineError::NoDocument)
}
/// A recorded index is one-based opening order, even after tabs are dragged.
pub(crate) fn document_at_index(&self, index: u64) -> Result<usize> {
let id = index
.checked_sub(1)
.and_then(|index| usize::try_from(index).ok())
.and_then(|index| self.open_document_order.get(index))
.ok_or_else(|| EngineError::Other(format!("no document at opening index {index}")))?;
self.docs.iter().position(|st| st.doc.id == *id).ok_or(EngineError::NoDocument)
}
/// Add a document (from File → New, an import, etc.) and make it active.
/// Preserve its identity unless another open document already owns it.
/// Identity-dependent callers must read the admitted document at the returned index.
+15 -1
View File
@@ -143,6 +143,16 @@ impl Session {
if self.names_existing_layer(spec.id, params) {
return Ok(());
}
// A recorded invalid comp index succeeds without an edit, even with no comps.
// Ordinary Apply and references by id/name retain the command's usual precondition.
if spec.id == "layerComp.apply"
&& params
.get("comp")
.and_then(Value::as_object)
.is_some_and(|fields| fields.len() == 1 && fields.get("index").is_some_and(|index| index.as_u64().is_some() || index.as_i64().is_some()))
{
return self.active().map(|_| ()).ok_or_else(|| "no document open".into());
}
// `ifPresent`: with no Background there is nothing to do, which isn't an error.
if spec.id == "layer.new.layerFromBackground" && params.get("ifPresent").and_then(Value::as_bool) == Some(true) {
return self.active().map(|_| ()).ok_or_else(|| "no document open".into());
@@ -171,7 +181,11 @@ impl Session {
if !spec.params.contains("\"layer\":id") {
return None;
}
let target = LayerId(params.get("layer")?.as_u64()?);
let layer = params.get("layer")?;
if !(layer.is_number() || layer.is_object()) {
return None;
}
let target = commands::explicit_layer(self, params).ok()??;
let d = self.active_mut()?;
d.doc.layer(target)?;
let active = d.active_layer.replace(target);
@@ -0,0 +1,416 @@
use photocraft_engine::{Session, actions_cmds::Action, atn_cmds};
use photocraft_psd::atn::{self, AtnAction, AtnEvent, AtnFile, AtnItem};
use photocraft_psd::descriptor::{Class, Descriptor, Id, ReferenceItem, UnicodeString, Value as D};
use serde_json::{Value, json};
fn class(name: &str) -> Class {
Class { name: UnicodeString::new_nul(""), class_id: Id::new(name) }
}
fn ordinal(name: &str) -> ReferenceItem {
ReferenceItem::Enumerated { class: class("Lyr "), type_id: Id::new("Ordn"), value: Id::new(name) }
}
fn load(s: &mut Session, reference: ReferenceItem) {
let descriptor = Descriptor::new("null").with("null", D::Reference(vec![reference]));
s.actions.list = vec![imported(AtnEvent::Code(*b"slct"), descriptor)];
}
fn bytes(event: AtnEvent, descriptor: Descriptor) -> Vec<u8> {
let file = AtnFile {
name: UnicodeString::new_nul("References"),
actions: vec![AtnAction {
name: UnicodeString::new_nul("Select"),
items: vec![AtnItem { event, descriptor: Some(descriptor), ..Default::default() }],
..Default::default()
}],
..Default::default()
};
atn::write(&file).unwrap()
}
fn imported(event: AtnEvent, descriptor: Descriptor) -> Action {
let mut result = atn_cmds::import(&bytes(event, descriptor)).unwrap();
assert!(result.unsupported.is_empty(), "{:?}", result.unsupported);
result.actions.remove(0)
}
/// Check actual saved reference kinds/codes, not only a matching import/export implementation.
fn roundtrip(action: &Action, reference: &ReferenceItem, target: Option<&ReferenceItem>) {
let (data, skipped) = atn_cmds::export("References", &[action], &[], false).unwrap();
assert!(skipped.is_empty());
let file = atn::parse(&data).unwrap();
let descriptor = file.actions[0].items[0].descriptor.as_ref().unwrap();
assert_eq!(descriptor.get("null"), Some(&D::Reference(vec![reference.clone()])));
if let Some(target) = target {
assert_eq!(descriptor.get("T "), Some(&D::Reference(vec![target.clone()])));
}
assert_eq!(atn_cmds::import(&data).unwrap().actions[0].steps, action.steps);
}
fn replay(s: &mut Session, action: &Action) {
s.actions.list = vec![action.clone()];
let result = s.execute("actions.play", json!({"action":"Select"})).unwrap();
assert_eq!(result["ran"], 1, "{result}");
assert!(result.get("failed").is_none(), "{result}");
}
fn layer(s: &Session, name: &str) -> u64 {
s.active().unwrap().doc.walk().into_iter().find(|(_, _, layer)| layer.name == name).unwrap().2.id.0
}
fn selection(s: &Session) -> Value {
let st = s.active().unwrap();
json!({"ids":st.selected_layers().iter().map(|id|id.0).collect::<Vec<_>>(),"active":st.active_layer.map(|id|id.0),"anchor":st.layer_anchor.map(|id|id.0),"revision":st.revision})
}
/// The measured stack has a collapsed group and an optional structural Background.
fn scene(background: bool) -> Session {
let mut s = Session::new();
s.execute("file.new", json!({"width":4,"height":4,"background":if background {"white"} else {"transparent"}})).unwrap();
s.execute("layer.renameLayer", json!({"name":"Base"})).unwrap();
for name in ["L1", "L2", "Gchild"] {
s.execute("layer.new.layer", json!({"name":name})).unwrap();
}
s.execute("layer.groupLayers", json!({"name":"G"})).unwrap();
s.execute("layer.new.layer", json!({"name":"L3"})).unwrap();
assert_eq!(s.active().unwrap().doc.background().is_some(), background);
s
}
fn index(class_name: &str, index: u32) -> ReferenceItem {
ReferenceItem::Index { class: class(class_name), index }
}
fn select(reference: ReferenceItem) -> Action {
imported(AtnEvent::Code(*b"slct"), Descriptor::new("null").with("null", D::Reference(vec![reference])))
}
fn moved(reference: ReferenceItem, target: ReferenceItem) -> Action {
imported(AtnEvent::Code(*b"move"), Descriptor::new("null").with("null", D::Reference(vec![reference])).with("T ", D::Reference(vec![target])))
}
fn fixture() -> (Session, u64, u64, u64) {
let mut s = Session::new();
s.execute("file.new", json!({"width": 4, "height": 4})).unwrap();
s.execute("layer.new.layer", json!({"name": "L1"})).unwrap();
let l2 = s.execute("layer.new.layer", json!({"name": "L2"})).unwrap()["layer"].as_u64().unwrap();
let child = s.execute("layer.new.layer", json!({"name": "Gchild"})).unwrap()["layer"].as_u64().unwrap();
let group = s.execute("layer.groupLayers", json!({"name": "G"})).unwrap()["layer"].as_u64().unwrap();
s.execute("layer.new.layer", json!({"name": "L3"})).unwrap();
(s, l2, child, group)
}
/// Recorded navigation enters collapsed groups; native keyboard navigation follows visible rows.
#[test]
fn recorded_forward_enters_a_collapsed_group() {
let (mut s, l2, child, group) = fixture();
s.execute("layer.select", json!({"layer": l2})).unwrap();
s.execute("layer.selectAbove", json!({})).unwrap();
assert_eq!(s.active().unwrap().active_layer.unwrap().0, group);
s.execute("layer.select", json!({"layer": l2})).unwrap();
load(&mut s, ordinal("Frwr"));
s.execute("actions.play", json!({"action": "Select"})).unwrap();
assert_eq!(s.active().unwrap().active_layer.unwrap().0, child);
}
/// Indexes count group ends; recorded navigation visits collapsed children and retains its form.
#[test]
fn indexes_and_ordinals_use_the_recorded_stack_with_or_without_background() {
for background in [false, true] {
let mut s = scene(background);
let first = u32::from(!background);
let expected = [Some("Base"), Some("L1"), Some("L2"), None, Some("Gchild"), Some("G"), Some("L3")];
for (offset, name) in expected.into_iter().enumerate() {
s.execute("layer.select", json!({"layer":layer(&s,"L2")})).unwrap();
let reference = index("Lyr ", first + offset as u32);
let action = select(reference.clone());
roundtrip(&action, &reference, None);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().active_layer.unwrap().0, layer(&s, name.unwrap_or("L2")));
}
for (code, expected) in [("Trgt", "L2"), ("Frwr", "Gchild"), ("Bckw", "L1"), ("Frnt", "L3"), ("Back", "Base")] {
s.execute("layer.select", json!({"layer":layer(&s,"L2")})).unwrap();
let reference = ordinal(code);
let action = select(reference.clone());
roundtrip(&action, &reference, None);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().active_layer.unwrap().0, layer(&s, expected));
}
for invalid in [first + 7, u32::MAX].into_iter().chain((!background).then_some(0)) {
let action = select(index("Lyr ", invalid));
let before = selection(&s);
assert!(s.execute(&action.steps[0].0, action.steps[0].1.clone()).is_err());
assert_eq!(selection(&s), before);
}
}
}
/// An end marker is a true no-op, including multi-selection, anchor and add/remove modifiers.
#[test]
fn group_end_does_not_replace_the_current_selection() {
let mut s = scene(true);
s.execute("layer.select", json!({"layer":layer(&s,"L1")})).unwrap();
s.execute("layer.select", json!({"layer":layer(&s,"L2"),"mode":"add"})).unwrap();
for modifier in [None, Some("addToSelection"), Some("removeFromSelection"), Some("addToSelectionContinuous")] {
let mut d = Descriptor::new("null").with("null", D::Reference(vec![index("Lyr ", 3)]));
if let Some(modifier) = modifier {
d = d.with("selectionModifier", D::Enumerated { type_id: Id::new("selectionModifierType"), value: Id::new(modifier) });
}
let action = imported(AtnEvent::Code(*b"slct"), d);
let before = selection(&s);
replay(&mut s, &action);
assert_eq!(selection(&s), before);
}
for extras in [json!({"name":"L1"}), json!({"occurrence":0}), json!({"mode":"invalid"})] {
let mut params = json!({"layer":{"index":3}});
params.as_object_mut().unwrap().extend(extras.as_object().unwrap().clone());
let before = selection(&s);
assert!(s.execute("layer.select", params).is_err());
assert_eq!(selection(&s), before);
}
}
/// Move indexes name pre-move boundaries; the two self boundaries preserve selection/history.
#[test]
fn indexed_moves_follow_the_measured_boundary_table() {
for target in 0..=6 {
let mut s = scene(true);
let reference = index("Lyr ", 2);
let destination = index("Lyr ", target);
let action = moved(reference.clone(), destination.clone());
roundtrip(&action, &reference, Some(&destination));
let before = selection(&s);
if target == 0 {
let doc = s.active().unwrap().doc.clone();
assert!(s.execute(&action.steps[0].0, action.steps[0].1.clone()).is_err());
assert_eq!(s.active().unwrap().doc, doc);
assert_eq!(selection(&s), before);
continue;
}
replay(&mut s, &action);
let expected = match target {
1 => vec!["Base", "L2", "L1", "G", "L3"],
2 | 3 => vec!["Base", "L1", "L2", "G", "L3"],
4 | 5 => vec!["Base", "L1", "G", "L3"],
_ => vec!["Base", "L1", "G", "L2", "L3"],
};
let doc = &s.active().unwrap().doc;
assert_eq!(doc.layers.iter().map(|l| l.name.as_str()).collect::<Vec<_>>(), expected, "target {target}");
let children = doc.layer(photocraft_doc::LayerId(layer(&s, "G"))).unwrap().children().unwrap();
assert_eq!(
children.iter().map(|l| l.name.as_str()).collect::<Vec<_>>(),
match target {
4 => vec!["L2", "Gchild"],
5 => vec!["Gchild", "L2"],
_ => vec!["Gchild"],
}
);
if matches!(target, 2 | 3) {
assert_eq!(selection(&s), before);
}
}
let mut s = scene(false);
let action = moved(index("Lyr ", 3), index("Lyr ", 0));
replay(&mut s, &action);
assert_eq!(s.active().unwrap().doc.layers[0].name, "L2");
}
/// A target-layer move keeps the complete selected source set and remains one undoable edit.
#[test]
fn indexed_move_preserves_multiple_selected_sources() {
let mut s = scene(true);
s.execute("layer.select", json!({"layer":layer(&s,"L1")})).unwrap();
s.execute("layer.select", json!({"layer":layer(&s,"L2"),"mode":"add"})).unwrap();
let before = selection(&s);
let action = moved(ordinal("Trgt"), index("Lyr ", 6));
roundtrip(&action, &ordinal("Trgt"), Some(&index("Lyr ", 6)));
replay(&mut s, &action);
let after = selection(&s);
for key in ["ids", "active", "anchor"] {
assert_eq!(after[key], before[key], "{key}");
}
assert_eq!(s.active().unwrap().doc.layers.iter().map(|layer| layer.name.as_str()).collect::<Vec<_>>(), ["Base", "G", "L1", "L2", "L3"]);
assert!(s.undo());
assert_eq!(s.active().unwrap().doc.layers.iter().map(|layer| layer.name.as_str()).collect::<Vec<_>>(), ["Base", "L1", "L2", "G", "L3"]);
}
/// Nested empty groups have distinct end/header boundaries, and cycle refusals are atomic.
#[test]
fn nested_empty_group_boundaries_reparent_at_the_correct_level() {
for target in [1, 2, 3] {
let mut s = Session::new();
s.execute("file.new", json!({"width":4,"height":4,"background":"white"})).unwrap();
s.execute("layer.new.group", json!({"name":"Inner"})).unwrap();
s.execute("layer.groupLayers", json!({"name":"Outer"})).unwrap();
s.execute("layer.new.layer", json!({"name":"Top"})).unwrap();
let outer = photocraft_doc::LayerId(layer(&s, "Outer"));
let inner = photocraft_doc::LayerId(layer(&s, "Inner"));
let action = moved(index("Lyr ", 5), index("Lyr ", target));
replay(&mut s, &action);
let doc = &s.active().unwrap().doc;
let parent = doc.path_of(photocraft_doc::LayerId(layer(&s, "Top"))).unwrap();
assert_eq!(
parent.len(),
match target {
1 => 1,
2 => 2,
_ => 3,
}
);
assert_eq!(doc.layer(outer).unwrap().children().unwrap().len(), if target == 2 { 2 } else { 1 });
assert_eq!(doc.layer(inner).unwrap().children().unwrap().len(), usize::from(target == 3));
let action = moved(index("Lyr ", 5), index("Lyr ", 4));
let before = doc.clone();
assert!(s.execute(&action.steps[0].0, action.steps[0].1.clone()).is_err());
assert_eq!(s.active().unwrap().doc, before);
}
}
/// Typed document indexes use opening order while numeric document indexes still address tabs.
#[test]
fn document_indexes_survive_tab_moves_close_and_reopen_with_old_ids() {
let mut s = Session::new();
for name in ["A", "B", "C"] {
s.execute("file.new", json!({"width":2,"height":2,"name":name})).unwrap();
}
let reopened = (*s.documents()[0].doc).clone();
s.execute("document.move", json!({"document":2,"to":0})).unwrap();
s.execute("document.activate", json!({"document":0})).unwrap();
assert_eq!(s.active().unwrap().doc.name, "C");
let reference = index("Dcmn", 2);
let action = select(reference.clone());
roundtrip(&action, &reference, None);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().doc.name, "B");
s.execute("file.close", json!({"document":1})).unwrap();
s.add_document(reopened, None);
for (n, expected) in [(1, "B"), (2, "C"), (3, "A")] {
replay(&mut s, &select(index("Dcmn", n)));
assert_eq!(s.active().unwrap().doc.name, expected);
}
for invalid in [0, u32::MAX, 4] {
let before = s.active_index();
let action = select(index("Dcmn", invalid));
assert!(s.execute(&action.steps[0].0, action.steps[0].1.clone()).is_err());
assert_eq!(s.active_index(), before);
}
}
fn comp_scene() -> (Session, u32, u32) {
let mut s = Session::new();
s.execute("file.new", json!({"width":2,"height":2})).unwrap();
let dead = s.execute("layerComp.new", json!({"name":"Deleted"})).unwrap()["comp"].as_u64().unwrap();
s.execute("layer.hideLayers", json!({})).unwrap();
let first = s.execute("layerComp.new", json!({"name":"First"})).unwrap()["comp"].as_u64().unwrap() as u32;
s.execute("layer.showLayers", json!({})).unwrap();
let second = s.execute("layerComp.new", json!({"name":"Second"})).unwrap()["comp"].as_u64().unwrap() as u32;
s.execute("layerComp.delete", json!({"comp":dead})).unwrap();
(s, first, second)
}
/// Comp ids, panel indexes and unusual measured ordinals stay distinct after reordering.
#[test]
fn comp_forms_keep_their_wire_kind_and_resolve_at_playback() {
let (mut s, first, second) = comp_scene();
for reordered in [false, true] {
if reordered {
s.execute("layerComp.reorder", json!({"comp":second,"index":0})).unwrap();
}
let panel_first = if reordered { second } else { first };
let panel_second = if reordered { first } else { second };
let current = panel_second;
let mut cases = vec![
(index("compsClass", 1), panel_first),
(index("compsClass", 2), panel_second),
(ReferenceItem::Identifier { class: class("compsClass"), id: first }, first),
];
for (code, expected) in [("Trgt", current), ("Nxt ", current), ("Prvs", current), ("Frst", panel_first), ("Lst ", panel_first), ("Al ", panel_first)] {
cases.push((
ReferenceItem::Enumerated { class: class("compsClass"), type_id: Id::new("Ordn"), value: Id::Code(code.as_bytes().try_into().unwrap()) },
expected,
));
}
for (reference, expected) in cases {
s.execute("layerComp.apply", json!({"comp":current})).unwrap();
let action = imported(AtnEvent::name("applyComp"), Descriptor::new("null").with("null", D::Reference(vec![reference.clone()])));
roundtrip(&action, &reference, None);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().doc.last_applied_comp, Some(expected));
assert_eq!(s.active().unwrap().doc.layers[0].visible, expected == second);
}
}
}
/// Invalid comp indexes succeed without edits; unmeasured layer/comp reference forms stay kept.
#[test]
fn invalid_comp_indexes_and_unsupported_references_preserve_state() {
let (mut s, _, _) = comp_scene();
for invalid in [0, 3, u32::MAX] {
let reference = index("compsClass", invalid);
let action = imported(AtnEvent::name("applyComp"), Descriptor::new("null").with("null", D::Reference(vec![reference.clone()])));
roundtrip(&action, &reference, None);
let before = s.active().unwrap().doc.clone();
let state = selection(&s);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().doc, before);
assert_eq!(selection(&s), state);
}
let before = s.active().unwrap().doc.clone();
s.execute("layerComp.apply", json!({"comp":{"index":-1}})).unwrap();
assert_eq!(s.active().unwrap().doc, before);
assert!(s.execute("layerComp.apply", json!({"comp":{"id":u32::MAX}})).is_err());
assert_eq!(s.active().unwrap().doc, before);
let negative = Action::new("Select", vec![("layerComp.apply".into(), json!({"comp":{"index":-1}}))]);
let (saved, _) = atn_cmds::export("References", &[&negative], &[], false).unwrap();
assert_eq!(
atn::parse(&saved).unwrap().actions[0].items[0].descriptor.as_ref().unwrap().get("null"),
Some(&D::Reference(vec![index("compsClass", u32::MAX)]))
);
for (event, reference) in [
(AtnEvent::Code(*b"slct"), ReferenceItem::Identifier { class: class("Lyr "), id: 2 }),
(AtnEvent::Code(*b"slct"), ReferenceItem::Offset { class: class("Lyr "), offset: 1 }),
(AtnEvent::name("applyComp"), ReferenceItem::Offset { class: class("compsClass"), offset: 0 }),
(AtnEvent::name("applyComp"), ReferenceItem::Enumerated { class: class("compsClass"), type_id: Id::new("wrong"), value: Id::new("Trgt") }),
(AtnEvent::Code(*b"slct"), ReferenceItem::Enumerated { class: class("Lyr "), type_id: Id::new("wrong"), value: Id::new("Frwr") }),
] {
let d = Descriptor::new("null").with("null", D::Reference(vec![reference]));
let data = bytes(event, d.clone());
let result = atn_cmds::import(&data).unwrap();
assert_eq!(result.unsupported.len(), 1);
assert_eq!(result.actions[0].steps[0].0, atn_cmds::PHOTOSHOP_STEP);
let (saved, _) = atn_cmds::export("References", &[&result.actions[0]], &[], false).unwrap();
assert_eq!(atn::parse(&saved).unwrap().actions[0].items[0].descriptor, Some(d));
}
for offset in [-1, 0, 1] {
let d = Descriptor::new("null")
.with("null", D::Reference(vec![ordinal("Trgt")]))
.with("T ", D::Reference(vec![ReferenceItem::Offset { class: class("Lyr "), offset }]));
assert_eq!(atn_cmds::import(&bytes(AtnEvent::Code(*b"move"), d)).unwrap().unsupported.len(), 1);
}
}
/// A recorded invalid index is a no-op even with zero comps; ordinary Apply stays disabled.
#[test]
fn empty_comp_list_index_is_noop() {
let mut s = Session::new();
assert!(!s.is_enabled_with("layerComp.apply", &json!({"comp":{"index":0}})));
s.execute("file.new", json!({"width":2,"height":2})).unwrap();
assert!(s.active().unwrap().doc.layer_comps.is_empty());
assert!(!s.is_enabled("layerComp.apply"));
for invalid in [0, 1, u32::MAX] {
let reference = index("compsClass", invalid);
let action = imported(AtnEvent::name("applyComp"), Descriptor::new("null").with("null", D::Reference(vec![reference.clone()])));
roundtrip(&action, &reference, None);
let before = s.active().unwrap().doc.clone();
let state = selection(&s);
replay(&mut s, &action);
assert_eq!(s.active().unwrap().doc, before);
assert_eq!(selection(&s), state);
}
s.execute("layerComp.apply", json!({"comp":{"index":-1}})).unwrap();
assert!(!s.is_enabled("layerComp.apply"));
for params in [json!({}), json!({"comp":{"id":1}}), json!({"comp":{"index":false}})] {
assert!(s.execute("layerComp.apply", params).is_err());
}
}
+1
View File
@@ -3,6 +3,7 @@
mod affinity;
mod artboard_export_names;
mod atn_crystallize_cell_size;
mod atn_reference_forms;
mod atn_ripple_amount;
mod atn_selective_color;
mod atn_stroke_width;
+9
View File
@@ -631,6 +631,15 @@ PhotoCraft equivalent.
Events outside the table load as `actions.photoshopStep` steps that keep the descriptor
verbatim (so Save Actions writes them back) and fail at playback with the step's Photoshop name.
Recorded layer indexes and ordinals resolve against the full stack, including collapsed children
and hidden group-end positions. Indexed moves use the stack before the move. Recorded document
indexes are one-based opening order; a native numeric `document` parameter remains a zero-based
tab index. Layer comp references retain their name, index, ID or ordinal form when saved, including
the measured comp ordinals that reapply the current or first comp. Invalid comp indexes do nothing,
even with an empty comp list. Recording-document layer IDs and layer/comp offsets stay kept steps.
These rules follow [davidmann4's measured reference](https://github.com/storytold/photocraft/pull/10603)
(#10701).
## Remove Tool quality
`cargo run --release -p photocraft-engine --example remove_quality -- <dir> [out dir]` fills
+3 -2
View File
@@ -1,6 +1,6 @@
# File-format parity
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-26 · **Change:** minor (TIFFs up to 300,000 px a side open, decoded a group of rows at a time into the layer, #8169; embedded AI/PDF/EPS save-back retains native format with a source-bound SVG display preview; PSD Filter Gallery: Halftone Pattern dot/circle/line settings survive PSD/PSB saves (#8940); Save for Web writes WebP, lossy or lossless, #6391; Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency, #8877; layered TIFF writes the TySh text version and descriptor in PSD big-endian order while the header, matrix, warp and bounds keep container order, #9098; layered TIFF writes Photoshop's 14-byte global layer mask, so Photoshop opens the layers instead of only the composite, #9095; legacy PSD point text placed from the layout ink box after font resolution, #6094; `.atn`: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; `.asl` layer style libraries read and written, #1051; JPEG Options on File › Save, Save As and Save a Copy, FILE-215-19 partial (no Matte, progressive Scans or size preview); 32-bit Hue/Saturation unclipped and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; JPEG Options on Save As and Save a Copy, FILE-215-19; TIFF compression for scripted saves, `tiffCompression`, #5301; the Nikon D4 white level follows the sample depth (12 and 14 bit), #5978; Apply Layer Comp action mapping, #7101; Cineon write: 10-bit gray/RGB; animated WebP frames load into video layers, #1198; Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 53 filters (39 more: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag, Invert, Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: smart objects keep Photoshop's Cylinder warp through re-renders and saves, #4112; PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding; Amiga IFF write: 24-plane ILBM, Save As `.iff`; PSD stores spot channels as Photoshop does, ink 0 = solid, and numbers them in 1053, #7415 split; TIFF writes and reads alpha and spot channels as extra samples with Photoshop's channel resources, PSD output unchanged, FILE-215-7, FILE-215-17's TIFF part, #7415; Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency) · **Target:** Adobe Photoshop 2026
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-11-01 · **Change:** minor (`.atn` recorded layer/document/comp reference forms, #10701; TIFFs up to 300,000 px a side open, decoded a group of rows at a time into the layer, #8169; embedded AI/PDF/EPS save-back retains native format with a source-bound SVG display preview; PSD Filter Gallery: Halftone Pattern dot/circle/line settings survive PSD/PSB saves (#8940); Save for Web writes WebP, lossy or lossless, #6391; Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency, #8877; layered TIFF writes the TySh text version and descriptor in PSD big-endian order while the header, matrix, warp and bounds keep container order, #9098; layered TIFF writes Photoshop's 14-byte global layer mask, so Photoshop opens the layers instead of only the composite, #9095; legacy PSD point text placed from the layout ink box after font resolution, #6094; `.atn`: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; `.asl` layer style libraries read and written, #1051; JPEG Options on File › Save, Save As and Save a Copy, FILE-215-19 partial (no Matte, progressive Scans or size preview); 32-bit Hue/Saturation unclipped and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; JPEG Options on Save As and Save a Copy, FILE-215-19; TIFF compression for scripted saves, `tiffCompression`, #5301; the Nikon D4 white level follows the sample depth (12 and 14 bit), #5978; Apply Layer Comp action mapping, #7101; Cineon write: 10-bit gray/RGB; animated WebP frames load into video layers, #1198; Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 53 filters (39 more: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag, Invert, Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: smart objects keep Photoshop's Cylinder warp through re-renders and saves, #4112; PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding; Amiga IFF write: 24-plane ILBM, Save As `.iff`; PSD stores spot channels as Photoshop does, ink 0 = solid, and numbers them in 1053, #7415 split; TIFF writes and reads alpha and spot channels as extra samples with Photoshop's channel resources, PSD output unchanged, FILE-215-7, FILE-215-17's TIFF part, #7415; Photoshop's `MTrn` merged-transparency marker, from a layered TIFF saved with Save Transparency, marks the merged transparency) · **Target:** Adobe Photoshop 2026
**PSD Filter Gallery (#8940, 2026-10-23):** Halftone Pattern maps its size, contrast and dot/circle/line pattern as editable settings on import and export, with the reference application's descriptor keys (`HlSz`, `Cntr`, `ScrT`: `ScrD`/`ScrC`/`ScrL`). PSD/PSB round trips pass at 8/16/32 bits. This does not claim pixel equivalence for the existing renderer. Unknown or malformed settings remain verbatim on import.
@@ -133,7 +133,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.
| LUTs `.cube` / `.3dl` / `.look` | R/W (Export Color Lookup) | R/W / R / R | `cms/src/lutfile.rs` |
| Keyboard shortcuts `.kys` | R/W | R/W | `engine/src/kys.rs` (`write`: Edit › Keyboard Shortcuts › Export…, rows carry our id; Photoshop reading our files is unverified) |
| ICC profiles | R | R | Own CMS |
| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (Photoshop events ↔ commands, including Apply Layer Comp by name, #7101; other steps kept verbatim; Save As maps to `file.saveAs`/`file.saveACopy` when its destination is a file, #7102). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) |
| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (Photoshop events ↔ commands, including Apply Layer Comp by name, #7101; recorded layer indexes/ordinals and indexed moves, opening-order document indexes, and comp index/ID/ordinal references, #10701; other steps kept verbatim; Save As maps to `file.saveAs`/`file.saveACopy` when its destination is a file, #7102). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) |
| Styles `.asl` | R/W | R/W | `psd/src/asl.rs`, `io/src/asl_map.rs`; Styles panel Import/Export Styles…, `style.presets.importAsl`/`exportAsl` (#1051) |
| Contours `.shc` | R/W | R/W | `psd/src/shc.rs`; Contour Editor Load…/Save… (FILE-215-15). No user contour library; not yet checked against a Photoshop-written file |
| Custom shapes `.csh`, tool presets `.tpl` | R/W | no | |
@@ -148,6 +148,7 @@ Embedded SVG and PDF-compatible AI/PDF/EPS payloads can use an explicit VectorCr
| Date | Change | Summary |
|---|---|---|
| 2026-11-01 | minor | `.atn`: layer indexes/ordinals include collapsed children and group ends; indexed moves use pre-move boundaries; document indexes use opening order; comp index/ID/ordinal forms retain their reference kind (#10701). |
| 2026-10-26 | minor | Embedded AI/PDF/EPS save-back retains native format and a separate source-bound display preview; original sources remain undoable. Native Adobe interoperability and standalone EPS/DCS remain unverified; no corpus floor or percentage changed. |
| 2026-10-22 | minor | Embedded PSD vectors gain explicit bounded SVG editor/save-back; standalone EPS/DCS and native-format fidelity remain open. |
| 2026-10-22 | minor | TIFF: flat pages up to 300,000 px a side open (was 2^30 px, about 32,768²): `codecs::TiffBands` decodes a group of rows at a time into the layer's tiles. The 117,504 × 22,464 px banner from #8456 opens in 3.3 s at 11.45 GB peak for a 10.56 GB layer; 30,000² 6.8 s / 6.43 GB → 1.1 s / 3.86 GB; 36 MP 220 → 52 ms. Layered TIFFs still decode whole (#8169) |