Scripts: app.startupPresetsList lists Print first

Scripts read app.startupPresetsList[0] as the print preset. The list now
starts with Print, then Web, Mobile, Film & Video, Art & Illustration,
Branding and Social, then Basic CMYK and Basic RGB. The order is
VectorCraft's own.

The test now checks that Print comes first and that the list holds each
New Document profile and both Basic presets once, instead of comparing
with the profiles' order in the New Document dialog.

docs/mcp.md states the new order and that a script which changes the
array a read gave does not change the list a later read gives.
This commit is contained in:
dotCooCoo committed 2026-11-23 12:22:32 -08:00
1 parent 2f931e0444
commit d7ba04760d
4 files changed
+22 -16

No files matched your search

+7 -6
View File
@@ -27,9 +27,9 @@
//! same. Changing the result changes nothing else. Each result counts toward the run's limit
//! of `DocumentPreset` objects, as `new DocumentPreset()` does.
//! - `startupPresetsList` is an array of the startup preset names, each of which
//! `documents.addDocument` and `getPresetSettings` take: the New Document profiles in the order
//! the New Document dialog lists them, then `Basic CMYK` and `Basic RGB`. Each read gives a new
//! array, so changing it changes nothing else.
//! `documents.addDocument` and `getPresetSettings` take: `Print` first, then the other New
//! Document profiles, then `Basic CMYK` and `Basic RGB`. Each read gives a new
//! array; a script that changes that array does not change the list a later read gives.
//! - The workspace methods, `loadColorSettings`, `showPresets` and the perspective grid preset
//! files are not available yet.
@@ -238,12 +238,13 @@ fn preset_settings(h: &Host, a: &[Data]) -> Answer {
super::add_preset(h, out)
}
/// The startup presets besides the New Document profiles, which give a document of one color mode.
const BASIC_PRESETS: [&str; 2] = ["Basic CMYK", "Basic RGB"];
/// The startup presets in the order `app.startupPresetsList` gives them: `Print` first, then the
/// other New Document profiles, then the presets that give a document of one color mode.
const STARTUP_PRESETS: [&str; 9] = ["Print", "Web", "Mobile", "Film & Video", "Art & Illustration", "Branding", "Social", "Basic CMYK", "Basic RGB"];
/// `app.startupPresetsList`: the names of the startup presets, as a new array.
fn startup_presets(_: &Host, _: &[Data]) -> Answer {
Ok(Data::Array(crate::cmd::newdoc::profile_names().chain(BASIC_PRESETS).map(text).collect()))
Ok(Data::Array(STARTUP_PRESETS.into_iter().map(text).collect()))
}
/// The members this module adds to `Document`'s.
@@ -287,9 +287,14 @@ fn startup_presets_list_names_presets_add_document_takes() {
var d = app.documents.addDocument(n); vc.log([n, d.width === p.width && d.documentColorSpace === p.colorMode]); }",
);
let names: Vec<&str> = out[0].as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
// The New Document profiles in the dialog's order, then the Basic presets.
let listed: Vec<&str> = crate::cmd::newdoc::profile_names().chain(["Basic CMYK", "Basic RGB"]).collect();
assert_eq!(names, listed);
// Scripts take `startupPresetsList[0]` as the print preset.
assert_eq!(names.first(), Some(&"Print"));
// Every New Document profile and both Basic presets, each once.
let mut sorted = names.clone();
sorted.sort_unstable();
let mut listed: Vec<&str> = crate::cmd::newdoc::profile_names().chain(["Basic CMYK", "Basic RGB"]).collect();
listed.sort_unstable();
assert_eq!(sorted, listed);
assert_eq!(out[1..3], [json!(true), json!(true)]);
assert_eq!(out.len(), 3 + names.len());
for (name, made) in names.iter().zip(&out[3..]) {
+6 -6
View File
@@ -2742,8 +2742,8 @@ app through the global object `vc`, and writes to the Script Console and runs ot
- A document also has `showPerspectiveGrid()`, `hidePerspectiveGrid()`, `getPerspectiveActivePlane()`,
`setActivePlane(gridPlane)` and `selectPerspectivePreset(gridType, presetName)`
(https://ai-scripting.docsforadobe.dev/jsobjref/Document/), and `app` has `getPresetSettings(preset)` and
`startupPresetsList` (https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `showPerspectiveGrid` and `hidePerspectiveGrid`
run `perspective.grid.show`, and `setActivePlane` runs `perspective.plane.set`; none of them adds an undo step, and
`startupPresetsList` (https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `showPerspectiveGrid`
and `hidePerspectiveGrid` run `perspective.grid.show`, and `setActivePlane` runs `perspective.plane.set`; none of them adds an undo step, and
a failed run puts the grid back. `selectPerspectivePreset` runs `perspective.grid.preset` with a built-in or saved
preset of `perspective.presets.list` (its name in any case), which shows the grid and is part of the run's undo
step when the grid changes. The enumerations `PerspectiveGridType` (`OnePointPerspectiveGridType`,
@@ -2759,10 +2759,10 @@ app through the global object `vc`, and writes to the Script Console and runs ot
preset's PPI is not 72, 150 or 300, `numArtboards` and `artboardRowsOrCols` when the preset has more than 100
artboards, and `artboardRowsOrCols` alone for a grid by column that no row count lays out the same, so
`addDocument` with the same preset keeps the preset's own. `startupPresetsList` is a read-only array of the
startup preset names, each of which `addDocument` and `getPresetSettings` take: the New Document profiles in the
order the New Document dialog lists them (`Mobile`, `Web`, `Print`, `Film & Video`, `Art & Illustration`,
`Branding`, `Social`), then `Basic CMYK` and `Basic RGB`. This order is VectorCraft's own. Each read gives a new
array, so changing it changes nothing else. As the Document page describes,
startup preset names, each of which `addDocument` and `getPresetSettings` take: `Print`, `Web`, `Mobile`,
`Film & Video`, `Art & Illustration`, `Branding`, `Social`, `Basic CMYK` and `Basic RGB`, in that order, so
`app.startupPresetsList[0]` is `Print`. This order is VectorCraft's own. Each read gives a new array; a script
that changes that array does not change the list a later read gives. As the Document page describes,
`showPerspectiveGrid` and `setActivePlane` give `true` on success, and `hidePerspectiveGrid` gives `true` when it
hides a grid and `false` when the grid was already hidden.
VectorCraft's own rules: `showPerspectiveGrid` and `setActivePlane` also give `true` when nothing changed.
+1 -1
View File
@@ -1026,7 +1026,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Scripts: File › Scripts › Other Script… and `script.run` run a JavaScript file against the open documents as one transaction with one undo step for each changed document. A failed or stopped run puts every document back. `crates/engine/src/tests/script_run.rs`.
- Scripts: the global `app` gives the open documents, new documents from a startup preset and a `DocumentPreset`, the active document, each document's selection and its page items with their names, notes, visibility, lock, opacity, position, size, bounds and stacking order, and moves and copies them into or beside other objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Application/, https://ai-scripting.docsforadobe.dev/jsobjref/Documents/, https://ai-scripting.docsforadobe.dev/jsobjref/DocumentPreset/, https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ describe them; each change runs a command inside the run's transaction (`docs/mcp.md`). Paths, type and the other classes are not there yet, except that `CompoundPathItem.pathItems` reads the paths of a compound path. `crates/engine/src/tests/script_dom.rs`.
- Scripts: a document's layers and sublayers with their options, stacking and current layer, its groups and compound paths with clipping masks and new empty groups, 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/Artboard/ and https://ai-scripting.docsforadobe.dev/jsobjref/Artboards/ describe them (`docs/mcp.md`). Views are not there yet. `crates/engine/src/tests/script_dom.rs`, `crates/ui-egui/src/tests/script_run.rs`.
- Scripts: a document's perspective grid is shown, hidden, given its active plane and reset to a built-in or saved preset of the type the script names, and `app.getPresetSettings` gives the settings of a startup preset as a `DocumentPreset`, and `app.startupPresetsList` lists the startup presets' names, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and https://ai-scripting.docsforadobe.dev/jsobjref/Application/ list them (`docs/mcp.md`). Showing, hiding and the active plane add no undo step in a script run, as outside one. Workspaces, `loadColorSettings`, `showPresets` and perspective grid preset files are not there yet. `crates/engine/src/tests/script_dom_perspective.rs`.
- Scripts: a document's perspective grid is shown, hidden, given its active plane and reset to a built-in or saved preset of the type the script names; `app.getPresetSettings` gives the settings of a startup preset as a `DocumentPreset`; and `app.startupPresetsList` lists the startup presets' names, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and https://ai-scripting.docsforadobe.dev/jsobjref/Application/ list them (`docs/mcp.md`). Showing, hiding and the active plane add no undo step in a script run, as outside one. Workspaces, `loadColorSettings`, `showPresets` and perspective grid preset files are not there yet. `crates/engine/src/tests/script_dom_perspective.rs`.
- Scripts: Window › Script Console shows each run's `$.write` and `$.writeln` output, `vc.log` entries, uncaught error with the script's name, line and column, and a report of its time, host calls and slowest commands, keeping at most 2,048 lines and counting the lines it dropped. `script.run`'s report carries the same data, and `script.console`, `script.console.clear` and `ui.copyScriptConsole` read, clear and copy it. `crates/engine/src/tests/script_console.rs`.
- Scripts: the status bar translates its own words around a failed run's error and the app's own error messages, and shows text the script threw itself (a value, an error it made, or an error whose name or message it changed) as it is, even when that text reads like one of the app's messages. `script.run`'s report gives `messageOrigin` (`script` or `built-in`), and the advice about objects other applications give their scripts follows only the app's own reference errors. VectorCraft's own rule. `crates/js/src/interp_tests.rs`, `crates/engine/src/tests/script_run.rs`, `crates/ui-egui/src/chrome/tests.rs`.
- Scripts: the `$` object has the other members the Dollar object page lists (https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/), from `$.about()` to `$.version`, and scripts have the global `localize(object, ...values)` (https://extendscript.docsforadobe.dev/extendscript-tools-features/localizing-extendscript-strings/), `toSource(value)` and `Object.prototype.toSource()`. Each run starts with the interface's locale, and what a script changes in `$` lasts only for that run. `crates/engine/src/tests/script_dollar.rs`, `crates/js/src/extension_tests.rs`.