mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 21:12:57 -05:00
Merge pull request #10750 from dotCooCoo/fix/script-print-success-clears-failure
Scripts: a print batch sent after a spool failure clears that failure
This commit is contained in:
7 files changed
+213
-14
No files matched your search
@@ -960,6 +960,7 @@ pub(crate) fn notes_of(r: &Value) -> Vec<String> {
|
||||
/// hover ([`crate::state::UiState::status_notes`]). Without notes nothing is kept.
|
||||
pub(crate) fn show_with_notes(app: &mut VectorcraftApp, status: String, notes: Vec<String>) {
|
||||
app.status(status);
|
||||
app.ui.script_print_failure_notes.clear();
|
||||
app.ui.status_notes = (!notes.is_empty()).then(|| (app.ui.status.clone(), notes));
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,10 @@ const NO_SCRIPT_PRINTING: &str = "Printing from scripts is not available here: t
|
||||
const SCRIPT_PRINT_FAILED: &str = "Printing from a script failed";
|
||||
|
||||
/// Sends the jobs a script prepared, which the person approved, each to its printer. Every printer
|
||||
/// must still be one the service lists, by its exact name, or no job is sent. → `{sent}`, or
|
||||
/// must still be one the service lists, by its exact name, or no job is sent. When the desktop's
|
||||
/// worker sends them all, the status bar drops the failures of batches that failed before these
|
||||
/// were submitted and keeps its other hover notes; it shows a failure reported since then, or else
|
||||
/// the last job's note. → `{sent}`, or
|
||||
/// `{background: true}` while the desktop's worker sends them.
|
||||
pub(crate) fn send_script_prints(app: &mut VectorcraftApp, jobs: Vec<PreparedPrint>) -> Result<Value, String> {
|
||||
let service = app.services.print.as_mut().filter(|s| s.scripts_may_print()).ok_or(NO_SCRIPT_PRINTING)?;
|
||||
@@ -363,6 +366,7 @@ pub(crate) fn send_script_prints(app: &mut VectorcraftApp, jobs: Vec<PreparedPri
|
||||
}
|
||||
let count = jobs.len();
|
||||
if let Some(submit) = service.shared_print() {
|
||||
let failed_before = app.ui.script_print_failures;
|
||||
return crate::background::run(
|
||||
app,
|
||||
true,
|
||||
@@ -371,23 +375,102 @@ pub(crate) fn send_script_prints(app: &mut VectorcraftApp, jobs: Vec<PreparedPri
|
||||
move |_| send_each(&mut |job| submit(job), &jobs).map(|notes| json!({ "notes": notes })),
|
||||
move |app, result| {
|
||||
let notes = result.inspect_err(|e| {
|
||||
app.ui.script_print_failures = app.ui.script_print_failures.wrapping_add(1);
|
||||
let failure = format!("{SCRIPT_PRINT_FAILED}: {e}");
|
||||
let mut failures = std::mem::take(&mut app.ui.script_print_failure_notes);
|
||||
let mut kept = app
|
||||
.ui
|
||||
.status_notes
|
||||
.take()
|
||||
.filter(|(status, notes)| *status == app.ui.status || notes.iter().any(|n| n.starts_with(SCRIPT_PRINT_FAILED)))
|
||||
.map(|(_, notes)| notes)
|
||||
.unwrap_or_default();
|
||||
.unwrap_or_else(|| {
|
||||
failures.clear();
|
||||
Vec::new()
|
||||
});
|
||||
if failures.len() >= 64 {
|
||||
let (_, index) = failures.remove(0);
|
||||
if kept.get(index).is_some_and(|n| n.starts_with(SCRIPT_PRINT_FAILED)) {
|
||||
kept.remove(index);
|
||||
}
|
||||
for (_, i) in &mut failures {
|
||||
if *i > index {
|
||||
*i -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (_, i) in &mut failures {
|
||||
*i += 1;
|
||||
}
|
||||
kept.insert(0, failure.clone());
|
||||
failures.push((app.ui.script_print_failures, 0));
|
||||
io::show_with_notes(app, failure, kept);
|
||||
app.ui.script_print_failure_notes = failures;
|
||||
})?;
|
||||
let failed = app.ui.status_notes.clone().filter(|(_, notes)| notes.iter().any(|n| n.starts_with(SCRIPT_PRINT_FAILED)));
|
||||
if let Some((status, kept)) = failed {
|
||||
io::show_with_notes(app, status, kept);
|
||||
} else if !app.ui.status.starts_with(SCRIPT_PRINT_FAILED) {
|
||||
app.status(notes["notes"].as_array().and_then(|n| n.last()).and_then(Value::as_str).unwrap_or_default());
|
||||
let noted = app.ui.status_notes.as_ref().is_some_and(|(_, notes)| notes.iter().any(|n| n.starts_with(SCRIPT_PRINT_FAILED)));
|
||||
if !noted {
|
||||
app.ui.script_print_failure_notes.clear();
|
||||
if !app.ui.status.starts_with(SCRIPT_PRINT_FAILED) {
|
||||
let note = notes["notes"].as_array().and_then(|n| n.last()).and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
let shown = app
|
||||
.ui
|
||||
.status_notes
|
||||
.as_ref()
|
||||
.filter(|(status, notes)| *status == app.ui.status && !notes.is_empty())
|
||||
.map(|(_, notes)| notes.clone());
|
||||
match shown {
|
||||
Some(mut kept) => {
|
||||
if !note.is_empty() {
|
||||
if kept.len() > 1 && kept.first() == app.ui.script_print_receipt.as_ref() {
|
||||
kept.remove(0);
|
||||
}
|
||||
kept.insert(0, note.clone());
|
||||
app.ui.script_print_receipt = Some(note);
|
||||
}
|
||||
if let Some(first) = kept.first().cloned() {
|
||||
io::show_with_notes(app, first, kept);
|
||||
}
|
||||
}
|
||||
None => app.status(note),
|
||||
}
|
||||
}
|
||||
return Ok(json!({ "sent": count }));
|
||||
}
|
||||
let mut kept = app.ui.status_notes.take().map(|(_, notes)| notes).unwrap_or_default();
|
||||
let mut failures = std::mem::take(&mut app.ui.script_print_failure_notes);
|
||||
let mut stale: Vec<usize> = failures.iter().filter(|(id, _)| *id <= failed_before).map(|(_, i)| *i).collect();
|
||||
failures.retain(|(id, _)| *id > failed_before);
|
||||
stale.sort_unstable();
|
||||
for index in stale.into_iter().rev() {
|
||||
if !kept.get(index).is_some_and(|n| n.starts_with(SCRIPT_PRINT_FAILED)) {
|
||||
continue;
|
||||
}
|
||||
kept.remove(index);
|
||||
for (_, i) in &mut failures {
|
||||
if *i > index {
|
||||
*i -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(failure) = kept.iter().find(|n| n.starts_with(SCRIPT_PRINT_FAILED)).cloned() {
|
||||
io::show_with_notes(app, failure, kept);
|
||||
} else {
|
||||
let note = notes["notes"].as_array().and_then(|n| n.last()).and_then(Value::as_str).unwrap_or_default().to_string();
|
||||
if !note.is_empty() && !kept.is_empty() {
|
||||
if kept.first() == app.ui.script_print_receipt.as_ref() {
|
||||
kept.remove(0);
|
||||
}
|
||||
if !kept.is_empty() {
|
||||
kept.insert(0, note.clone());
|
||||
app.ui.script_print_receipt = Some(note.clone());
|
||||
}
|
||||
}
|
||||
match kept.first().cloned() {
|
||||
Some(first) => io::show_with_notes(app, first, kept),
|
||||
None => app.status(note),
|
||||
}
|
||||
}
|
||||
app.ui.script_print_failure_notes = failures;
|
||||
Ok(json!({ "sent": count }))
|
||||
},
|
||||
);
|
||||
|
||||
@@ -198,13 +198,23 @@ fn end_round(app: &mut VectorcraftApp) {
|
||||
return;
|
||||
}
|
||||
let mut notes = std::mem::take(&mut app.ui.startup_notes);
|
||||
let mut failures = Vec::new();
|
||||
match app.ui.status_notes.take() {
|
||||
Some((status, more)) if status == app.ui.status && more == notes => {}
|
||||
Some((status, more)) if status == app.ui.status && !more.is_empty() => notes.extend(more),
|
||||
Some((status, more)) if status == app.ui.status && more == notes => {
|
||||
failures = std::mem::take(&mut app.ui.script_print_failure_notes);
|
||||
}
|
||||
Some((status, more)) if status == app.ui.status && !more.is_empty() => {
|
||||
failures = std::mem::take(&mut app.ui.script_print_failure_notes);
|
||||
for (_, i) in &mut failures {
|
||||
*i += notes.len();
|
||||
}
|
||||
notes.extend(more);
|
||||
}
|
||||
_ if app.ui.status.is_empty() || notes.contains(&app.ui.status) => {}
|
||||
_ => notes.push(app.ui.status.clone()),
|
||||
}
|
||||
show_notes(app, notes);
|
||||
app.ui.script_print_failure_notes = failures;
|
||||
}
|
||||
|
||||
/// Shows the first of `notes` in the status bar, and keeps them all for its hover, which lists
|
||||
|
||||
@@ -728,6 +728,18 @@ pub struct UiState {
|
||||
/// later can tell whether the line it started with is still the latest one. Not saved.
|
||||
#[serde(skip)]
|
||||
pub status_sets: u64,
|
||||
/// How many batches of a script's print jobs the desktop's worker has failed to send, so that a
|
||||
/// batch sent later can tell a failure from before it was submitted from one since. Not saved.
|
||||
#[serde(skip)]
|
||||
pub script_print_failures: u64,
|
||||
/// The status bar's hover-note indexes for those failures, each with its count in
|
||||
/// `script_print_failures`, while those notes are kept. Not saved.
|
||||
#[serde(skip)]
|
||||
pub script_print_failure_notes: Vec<(u64, usize)>,
|
||||
/// The sent batch's note that heads the status bar's hover notes, so the next sent batch
|
||||
/// replaces it instead of adding another. Not saved.
|
||||
#[serde(skip)]
|
||||
pub script_print_receipt: Option<String>,
|
||||
/// The Replace Font request behind the status bar's warning ([`ReplaceFontWarning`]). Not saved.
|
||||
#[serde(skip)]
|
||||
pub replace_font_warning: Option<ReplaceFontWarning>,
|
||||
@@ -1542,6 +1554,9 @@ impl Default for UiState {
|
||||
touch_drawing_tool: None,
|
||||
status: String::new(),
|
||||
status_sets: 0,
|
||||
script_print_failures: 0,
|
||||
script_print_failure_notes: Vec::new(),
|
||||
script_print_receipt: None,
|
||||
replace_font_warning: None,
|
||||
live_warning: None,
|
||||
last_find: None,
|
||||
|
||||
@@ -379,7 +379,8 @@ fn a_sent_batch_does_not_hide_an_earlier_spool_failure() {
|
||||
assert!(app.ui.status.contains("The printer Office is offline"), "{}", app.ui.status);
|
||||
}
|
||||
|
||||
/// A spool failure stays visible after the next batch is approved and sent.
|
||||
/// A spool failure stays visible while the next batch is approved and printing, and that batch
|
||||
/// clears it once the worker sends it without a new failure.
|
||||
#[test]
|
||||
fn a_batch_submitted_after_a_spool_failure_does_not_hide_it() {
|
||||
let mut app = worker_print_app("The printer Lab is offline");
|
||||
@@ -396,9 +397,97 @@ fn a_batch_submitted_after_a_spool_failure_does_not_hide_it() {
|
||||
assert!(!asking(&app));
|
||||
assert!(!app.background.jobs.is_empty(), "the next batch was submitted");
|
||||
assert_eq!(app.ui.status, "Printing from a script…");
|
||||
assert_eq!(app.ui.status_notes, Some((failure.clone(), vec![failure.clone()])), "the failure stays while the batch prints");
|
||||
crate::background::wait_all(&mut app);
|
||||
assert_eq!(app.ui.status, failure);
|
||||
assert_eq!(app.ui.status_notes, Some((failure.clone(), vec![failure])));
|
||||
assert!(!app.ui.status.contains("offline"), "{}", app.ui.status);
|
||||
assert!(!app.ui.status.is_empty());
|
||||
assert_eq!(app.ui.status_notes, None);
|
||||
}
|
||||
|
||||
/// A batch that is sent clears only the failures reported before it was submitted: the same
|
||||
/// failure reported again since then stays in the status bar and its hover notes.
|
||||
#[test]
|
||||
fn a_repeated_spool_failure_keeps_its_own_hover_note() {
|
||||
let mut app = worker_print_app("The printer Lab is offline");
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 10.0, "Print");
|
||||
crate::background::wait_all(&mut app);
|
||||
crate::print::send_script_prints(&mut app, Vec::new()).unwrap();
|
||||
let earlier_batch = std::mem::take(&mut app.background);
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 20.0, "Print");
|
||||
crate::background::wait_all(&mut app);
|
||||
app.background = earlier_batch;
|
||||
crate::background::wait_all(&mut app);
|
||||
let failure = app.ui.status.clone();
|
||||
assert!(failure.contains("The printer Lab is offline"), "{failure}");
|
||||
let notes = &app.ui.status_notes.as_ref().unwrap().1;
|
||||
assert_eq!(notes.iter().filter(|n| **n == failure).count(), 1, "{notes:?}");
|
||||
assert_eq!(app.ui.script_print_failure_notes.len(), 1);
|
||||
}
|
||||
|
||||
/// Two batches sent after a spool failure keep the other hover notes the failure shared, such as a
|
||||
/// startup script's error, once the first batch has cleared the failure.
|
||||
#[test]
|
||||
fn queued_sent_batches_keep_other_hover_notes() {
|
||||
let mut app = worker_print_app("The printer Lab is offline");
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 10.0, "Print");
|
||||
crate::background::wait_all(&mut app);
|
||||
let failure = app.ui.status.clone();
|
||||
assert!(failure.contains("The printer Lab is offline"), "{failure}");
|
||||
let startup = "The startup script b.jsx failed".to_string();
|
||||
let tracked = app.ui.script_print_failure_notes.clone();
|
||||
crate::io::show_with_notes(&mut app, failure.clone(), vec![failure.clone(), startup.clone()]);
|
||||
app.ui.script_print_failure_notes = tracked;
|
||||
app.services.print = worker_print_app("").services.print;
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 20.0, "Print");
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 30.0, "Print");
|
||||
assert_eq!(app.background.jobs.len(), 2, "both batches are queued");
|
||||
crate::background::wait_all(&mut app);
|
||||
assert!(!app.ui.status.contains("offline"), "{}", app.ui.status);
|
||||
let (status, notes) = app.ui.status_notes.as_ref().expect("the startup error stays in the hover notes");
|
||||
assert_eq!(status, &app.ui.status, "the hover notes match the displayed status");
|
||||
assert_eq!(notes, &vec!["Sent".to_string(), startup], "the second batch's note replaces the first's");
|
||||
}
|
||||
|
||||
/// A batch that clears a spool failure replaces the note of the batch sent before the failure,
|
||||
/// so the hover notes hold one receipt.
|
||||
#[test]
|
||||
fn a_batch_that_clears_a_failure_replaces_the_earlier_receipt() {
|
||||
let mut app = worker_print_app("The printer Lab is offline");
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 10.0, "Print");
|
||||
crate::background::wait_all(&mut app);
|
||||
let failure = app.ui.status.clone();
|
||||
let startup = "The startup script b.jsx failed".to_string();
|
||||
let tracked = app.ui.script_print_failure_notes.clone();
|
||||
crate::io::show_with_notes(&mut app, failure.clone(), vec![failure, startup.clone()]);
|
||||
app.ui.script_print_failure_notes = tracked;
|
||||
app.services.print = worker_print_app("").services.print;
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 20.0, "Print");
|
||||
app.services.print = worker_print_app("The printer Lab is offline").services.print;
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 30.0, "Print");
|
||||
assert_eq!(app.background.jobs.len(), 2, "both batches are queued");
|
||||
crate::background::wait_all(&mut app);
|
||||
assert!(app.ui.status.contains("The printer Lab is offline"), "{}", app.ui.status);
|
||||
let (_, notes) = app.ui.status_notes.as_mut().expect("the failure keeps the other hover notes");
|
||||
assert_eq!(notes.get(1..), Some(&["Sent".to_string(), startup.clone()][..]), "{notes:?}");
|
||||
let earlier = "Sent to Lab earlier".to_string();
|
||||
notes[1] = earlier.clone();
|
||||
app.ui.script_print_receipt = Some(earlier);
|
||||
app.services.print = worker_print_app("").services.print;
|
||||
run(&mut app, PRINT_TO_LAB);
|
||||
click_after_delay(&mut app, 40.0, "Print");
|
||||
crate::background::wait_all(&mut app);
|
||||
assert!(!app.ui.status.contains("offline"), "{}", app.ui.status);
|
||||
let (status, notes) = app.ui.status_notes.as_ref().expect("the startup error stays in the hover notes");
|
||||
assert_eq!(status, &app.ui.status);
|
||||
assert_eq!(notes, &vec!["Sent".to_string(), startup], "one receipt, from the last batch");
|
||||
}
|
||||
|
||||
/// A spool failure keeps the startup scripts' errors in the status bar's hover notes.
|
||||
|
||||
+2
-1
@@ -5112,7 +5112,8 @@ next one starts at the frame after, and a later run that cannot start, the chose
|
||||
status bar. A queued run also waits while the jobs the previous run prepared for a printer wait for Print or Cancel.
|
||||
Each queued run lists the printers listed when the runs were queued; the runs with reason `launch` list no
|
||||
printers, so they cannot print to a printer. A job that fails to spool is reported in the status bar even when a
|
||||
later run or a later job's note took it.
|
||||
later run or a later job's note took it. A batch submitted after the failure was reported clears it once the
|
||||
worker sends every job of that batch without a failure; a failure reported after that batch was submitted stays.
|
||||
Stop (`script.stop`) asked for between two runs stops the run that starts next. In the app, stopping the runs from
|
||||
the prompt shown on quitting, between two runs, drops the runs not yet started, and the status bar says so. While that prompt is open, the next run does not start. Under `--automation-read-root` it reads the folder only when the folder lies inside a
|
||||
read root. With the preference on, `ui.runScript` and `ui.runInstalledScript` still return `script.run`'s reply,
|
||||
|
||||
@@ -1133,7 +1133,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Scripts: a document's layers and sublayers with their options, stacking and current layer, its groups and compound paths with clipping masks, new empty groups and compound paths and paths moved into compound paths, and its artboards with their rectangles, names, ruler origins and display options, added, inserted, removed and made active, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/Layers/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItems/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItems/, https://ai-scripting.docsforadobe.dev/jsobjref/Artboard/ and https://ai-scripting.docsforadobe.dev/jsobjref/Artboards/ describe them (`docs/mcp.md`); `artboards.add` returns the new artboard and `artboards.insert` returns nothing. Scoped collections support string conversion, which fails for `Layers`, `GroupItems`, `CompoundPathItems` and `Artboards` once their container is gone; compound paths expose `PathItems` objects and reject unsupported path creation; `removeAll()` on a compound path's `pathItems` throws when it would empty a compound path that clips a group or layer keeping other objects that are not ruler guides. Empty clipping containers release their masks in the deletion's undo step, and `clipped` changes check the group's, layer's and artboard's locks; turning clipping on also refuses a hidden or locked topmost object, which would become the mask. Layer selection changes keep unrelated selected objects, layer colors are assignable `RGBColor` values, stacking scans count toward the script budget, and paths moved into pixel-aligned compound paths are snapped. The `textFrames` of a layer or group list the type directly in it and put new type on top of its contents (VectorCraft's own rule), as https://ai-scripting.docsforadobe.dev/jsobjref/Layer/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ list them. `crates/engine/src/tests/script_dom.rs`, `crates/engine/src/tests/script_text.rs`, `crates/ui-egui/src/tests/script_run.rs`.
|
||||
- Scripts: `Document.print` prints the document to a file with `PrintOptions` and the job, color management, color separation, coordinate, flattener, font, page marks, paper and PostScript option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/PrintJobOptions/ describe, over the document's print settings, and `app.printPresetsList` lists the print presets (`docs/mcp.md`); `CUSTOMPROFILE` without a profile `name` throws. `crates/engine/src/tests/script_print.rs`.
|
||||
- Scripts: `Document.exportFile` with `ExportType.AutoCAD` writes a DXF file with the `ExportOptionsAutoCAD` options and the AutoCAD enumerations that https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsAutoCAD/ and https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/ describe; DWG throws an error that says it is not available, and `unitScaleRatio` is a percentage, with 100 at full size (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`.
|
||||
- Scripts: `Document.print` without a file prints to the printer `PrintOptions.printerName` names, or the default printer, and `app.printerList` lists the installed printers as `Printer` objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/ and https://ai-scripting.docsforadobe.dev/jsobjref/Printer/ describe. VectorCraft's own rules: the jobs are sent after the run's changes are kept and the person at the keyboard clicks Print or presses Space on it, which takes no click or focus for the first second, nothing is sent from a failed run, and the web build, and MCP or the command line without the app, cannot print to a printer from a script (`docs/mcp.md`). `crates/engine/src/tests/script_print.rs`, `crates/ui-egui/src/tests/script_print.rs`.
|
||||
- Scripts: `Document.print` without a file prints to the printer `PrintOptions.printerName` names, or the default printer, and `app.printerList` lists the installed printers as `Printer` objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/ and https://ai-scripting.docsforadobe.dev/jsobjref/Printer/ describe. VectorCraft's own rules: the jobs are sent after the run's changes are kept and the person at the keyboard clicks Print or presses Space on it, which takes no click or focus for the first second, nothing is sent from a failed run, and the web build, and MCP or the command line without the app, cannot print to a printer from a script (`docs/mcp.md`); a batch submitted after a spool failure was reported clears it once the worker sends every job of the batch without a failure, while a failure reported after submission stays. `crates/engine/src/tests/script_print.rs`, `crates/ui-egui/src/tests/script_print.rs`.
|
||||
- Scripts: `Document.saveAs`, `Document.exportFile` and `app.open` save, export and open documents, `Document.fullName` and `saved` give a document's file and saved state, setting `saved` records that state (`document.setSaved`), `Document.path` gives its folder as a `Folder` (VectorCraft's own type), and `Document.close` closes it, saving to its file first with `SaveOptions.SAVECHANGES`, with the option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/EPSSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFSaveOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsPNG24/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsJPEG/, https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsSVG/, https://ai-scripting.docsforadobe.dev/jsobjref/PDFFileOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/Document/ describe (the enumerations of the options that keep their defaults included), and read and write only where the script's `File` objects may, refusing a path whose real file name is not valid UTF-8; the warnings of each save, export and open go to the console (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`.
|
||||
- Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). A script can check a member with `hasOwnProperty`, and can read a collection by name and name `activeDocument`, `documents` and `selection` without `app.` (https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/). A key such as `1` is an array index and reads that position; in `pageItems` and `documents`, a number that is not an array index, such as `-1` or `1.5`, is looked up by name when the key is the text JavaScript writes for that number. VectorCraft's own rule. `app.executeMenuCommand` runs the menu items Select All, Deselect, Group, Ungroup, Make and Release Clipping Mask, Make and Release Compound Path, and Fit to Artwork Bounds by their menu command names (https://community.adobe.com/questions-652/a-list-of-illustrator-menu-commands-we-can-call-from-javascript-769510, https://gist.github.com/shalakolee/df3246659d4289eb99149b9ed00a00ee). The `parent` of a page item at the top of a layer is a `Layer` with `name`, `typename` and `toString`. A page item's `blendingMode` reads and sets its blend mode with the `BlendModes` values (https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/).
|
||||
`Document.views` lists the document's drawn windows with their bounds, center, zoom and screen mode (https://ai-scripting.docsforadobe.dev/jsobjref/View/). Zoom follows each window's displayed percentage, including display density with Display Print Size at 100% Zoom enabled; bounds retain the physical camera scale. View objects keep their targets when windows are renumbered. View changes run no command, add no undo step, and remain when a script fails. A center outside the canvas after coordinate conversion throws a `RangeError`. Type and the other classes are not there yet. `crates/engine/src/tests/script_dom.rs`.
|
||||
|
||||
Reference in new issue
Block a user