Scripts: visibility variables on embedded images, data sets kept after a no-op import

- variable.setBinding refuses an embedded image only for an image variable,
  so a script can bind an embedded image's visibility.
- A Dataset object stays usable after dataset.import, variable.loadLibrary
  or variable.import leaves the document's data sets as they were, or the
  import is put back; it goes stale only when the data sets change.
- script.check reports a document's exportVariables as filesWritten and
  file.write, and the script host test lists the variable and data set
  names the host adds.

Docs: docs/mcp.md.
This commit is contained in:
dotCooCoo committed 2026-11-21 10:15:47 -08:00
1 parent 90752660ad
commit 6db0f6c1ad
10 files changed
+81 -13

No files matched your search

+1 -1
View File
@@ -301,7 +301,7 @@ impl<'s, 'a, 'l> Analyzer<'s, 'a, 'l> {
self.acc.feature(FeatureId::FileDialog, line);
} else if catalog::FOLDER_READS.contains(&n) || (file && catalog::FILE_READS.contains(&n)) {
self.acc.feature(FeatureId::FileRead, line);
} else if file && catalog::FILE_WRITES.contains(&n) {
} else if (file && catalog::FILE_WRITES.contains(&n)) || catalog::DOM_FILE_WRITES.contains(&n) {
self.acc.feature(FeatureId::FileWrite, line);
self.acc.outside(OutsideId::FilesWritten, line, None);
} else if n == catalog::EXECUTE {
+3
View File
@@ -72,6 +72,9 @@ pub(crate) const REFLECT: &str = "reflect";
// The roots of the document model: https://ai-scripting.docsforadobe.dev/jsobjref/Application/
pub(crate) const DOM_ROOTS: [&str; 4] = ["app", "activeDocument", "documents", "selection"];
// Document methods that write the file they are given: https://ai-scripting.docsforadobe.dev/jsobjref/Document/
pub(crate) const DOM_FILE_WRITES: &[&str] = &["exportVariables"];
// Application methods that page doesn't list, named in public forum posts:
// https://community.adobe.com/t5/illustrator-discussions/changes-in-cs6/td-p/4173362 (executeMenuCommand,
// doScript, loadAction, unloadAction) and
+8
View File
@@ -530,6 +530,14 @@ fn the_scripts_own_platform_names_are_not_the_platforms() {
assert_eq!(r.outside.iter().map(|o| o.id).collect::<Vec<_>>(), ["filesWritten"]);
}
/// A document's `exportVariables` writes the file it is given; `importVariables` only reads one.
#[test]
fn export_variables_writes_a_file() {
let r = report("var f = new File(p);\napp.activeDocument.importVariables(f);\napp.activeDocument.exportVariables(f);\n");
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3][..]));
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[3][..])]);
}
/// Setting a File object's length, hidden or read-only flag changes the file; reading them, comparing
/// them and setting them on another object does not.
#[test]