Commit Graph
70 Commits
Author SHA1 Message Date
dotCooCoo a9fda9f97c Merge main into feat/scripts-app-redraw 2026-11-28 08:12:03 -08:00
dotCooCoo 88fb7a8128 Merge main into feat/scripts-document-views 2026-11-28 07:25:53 -08:00
dotCooCoo 37be9d4372 Merge main into feat/scripts-app-redraw 2026-11-28 04:00:58 -08:00
.CooCoo 87b3dd9a98 Merge pull request #9853 from dotCooCoo/fix/script-documents-strict-assign
Scripts: assigning documents throws in strict mode and is ignored otherwise
2026-11-28 01:24:23 -08:00
dotCooCoo 7d6abb1d23 Merge main into fix/script-documents-strict-assign 2026-11-28 00:29:51 -08:00
dotCooCoo e75b26cffc Merge main into feat/scripts-reflection 2026-11-27 23:38:58 -08:00
.CooCoo 8f9fda6a7d Merge pull request #9432 from dotCooCoo/fix/script-handles-after-revert
Scripts: invalidate page-item handles after file.revert
2026-11-27 23:34:31 -08:00
dotCooCoo 5162f5db7b Merge main into feat/scripts-app-redraw 2026-11-27 22:26:34 -08:00
dotCooCoo f7ccc194fc Merge main into feat/scripts-document-views 2026-11-27 22:14:06 -08:00
dotCooCoo f56fcd99f6 Merge main into feat/scripts-reflection 2026-11-27 22:13:50 -08:00
dotCooCoo 1371fdab0d Merge main into fix/script-handles-after-revert 2026-11-27 22:12:29 -08:00
dotCooCoo 1583808eec Merge main into fix/script-documents-strict-assign
# Conflicts:
#	crates/engine/src/script/dom.rs
2026-11-27 22:10:35 -08:00
dotCooCoo c97b5eac1e Merge main into feat/scripts-api-d7a-variables 2026-11-27 21:57:44 -08:00
.CooCoo a95a52e06a Merge pull request #9866 from dotCooCoo/fix/script-preset-field-size
Scripts: DocumentPreset settings refuse a value of the wrong kind or size
2026-11-27 21:54:22 -08:00
dotCooCoo 8ff8dbefc6 Scripts: DocumentPreset settings refuse a value of the wrong kind or size
Assigning a DocumentPreset setting stored any value until the run ended,
and the value was checked only when addDocument read it. A script could
keep gigabytes of strings in presets that no addDocument would accept.

The setter now checks the value before storing it: a value of the
setting's enumeration, a finite number, a title of at most 4096 bytes,
true or false for documentBleedLink, or four finite numbers for
documentBleedOffsetRect. undefined unsets any setting, and the three
settings addDocument does not apply yet also take null. A value of
another kind throws a TypeError, a longer title throws a RangeError, and
the setting keeps its old value. addDocument still checks the ranges.
2026-11-27 20:16:03 -08:00
dotCooCoo efb7911139 Scripts: assigning documents throws in strict mode and is ignored otherwise
The global `documents` has only a getter. The docs and the module and
test comments said only that assigning it keeps its value. They now say
that the assignment is ignored outside strict mode and throws a
TypeError in strict mode code or with `#strict on`, and the test also
checks the `#strict on` case.
2026-11-27 18:46:40 -08:00
dotCooCoo 55bf6604be Scripts: app.documents lists the active document first
A script's documents[0] was the first tab, not the active document, so
scripts that read app.documents[0] as the document in front acted on
another one. The scripting guide says documents[0] is always the active
document:
https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/

Each open document now records when it last became the current one.
documents lists the current document first and then the others from the
one current most recently to the one current longest ago (VectorCraft's
own rule). documents["name"] and getByName search in the same order. A
change a script makes to a document in the back switches to it and back,
and that switch no longer moves the document in the list.

Three tests that read documents[0] as the first tab with two documents
open now read documents[1].
2026-11-27 13:22:06 -08:00
dotCooCoo f9011cf8e2 Merge main into feat/scripts-api-d7b-tags-notes-uuid 2026-11-26 10:45:34 -08:00
dotCooCoo 66724868b1 Merge main into fix/script-handles-after-revert 2026-11-26 10:24:41 -08:00
dotCooCoo 80a24bf8a6 Use each window's displayed zoom in script views 2026-11-26 09:36:45 -08:00
dotCooCoo 93a5d81d2e Merge main into feat/scripts-api-d7b-tags-notes-uuid 2026-11-26 09:34:56 -08:00
dotCooCoo f4704bb688 Scripts: reject protected page-item mutations 2026-11-26 08:35:37 -08:00
dotCooCoo 54ff9ac323 Scripts: invalidate page-item and layer handles after revert 2026-11-26 08:24:54 -08:00
dotCooCoo b64cbe2174 Merge main into feat/scripts-document-views 2026-11-26 08:05:40 -08:00
BFlat aeb9f99e7e Merge pull request #9314 from dotCooCoo/feat/scripts-execute-menu-command
Scripts: app.executeMenuCommand runs a menu command
2026-11-26 16:49:34 +07:00
dotCooCoo 2909471ebc Merge main into feat/scripts-api-d7a-variables 2026-11-25 23:38:36 -08:00
dotCooCoo 562bec3f1e Merge main into feat/scripts-api-d7b-tags-notes-uuid 2026-11-25 23:07:28 -08:00
dotCooCoo 165423a9c0 Scripts: Views and View toString refuse a stale collection or view
A collection or view kept by a named engine from an earlier run now
throws on toString() as typename does. The tests also check that
`k in document.views` is false for an index or name with no view, and
the error type of each bad view value. docs/mcp.md says a centerPoint
outside the canvas throws a RangeError.
2026-11-25 22:20:39 -08:00
dotCooCoo 7b776dea92 Merge main into feat/scripts-reflection 2026-11-25 22:14:36 -08:00
dotCooCoo df3d7ab275 Scripts: stale page item lists throw from toString; unavailable members stop hasOwnProperty
- `toString()` on a page item list from a closed or replaced document throws
  "Stale document", as its other members do.
- A member a host class declares unavailable is not reported by
  `hasOwnProperty` or `propertyIsEnumerable` even when a parent class has it.
- Assigning a name an object of a host class inherits from a prototype no
  longer calls the class's indexer, so a non-strict assignment is ignored
  instead of throwing.
- Assigning a selection checks repeated objects with a set instead of
  scanning the list for each object.
- The script report test throws a text that names `Window` for the case of
  an error the script wrote itself.
2026-11-25 21:50:05 -08:00
dotCooCoo 0ea397db72 Scripts: Fit Artboard to artwork bounds does nothing on a locked or empty artboard
app.executeMenuCommand('Fit Artboard to artwork bounds') threw the
command's error when the active artboard was locked or had no art on
it. The canvas's right-click menu dims Fit to Artwork Bounds then
(DocState::any_art_to_fit), so the script now does nothing and adds
no undo step, as for the other menu items that are not available. The docs state
that an available menu item runs its command and that an error that
command returns throws.

The host-versus-checker name table lists
Application.prototype.executeMenuCommand.
2026-11-25 06:08:03 -08:00
dotCooCoo 98a6ed7fc7 Scripts: each view is sized as the area its document was last drawn in
Since the move to the craft UI framework each document's view keeps the
area it last drew the document in, so Document.views now gives a view
for every document the app has drawn, in a tab, a tiled pane or a
floating window, sized as that area. A document the app has not drawn
yet has no view. View and Views also get toString, as the other script
objects have.
2026-11-25 01:06:23 -08:00
dotCooCoo 656aafffd7 Merge #9019's branch into feat/scripts-document-views
# Conflicts:
#	crates/engine/src/lib.rs
#	crates/engine/src/script/dom.rs
#	crates/ui-egui/src/script_runs.rs
#	crates/ui-egui/src/tests/script_run.rs
#	docs/target-app-parity.md
2026-11-25 00:26:34 -08:00
dotCooCoo 5986c0d94b Scripts: Document.views gives the document's view with its bounds, center and zoom
Document.views holds one view while the desktop app shows the document
on its canvas: every document's while documents are under the tabs, and
only the current document's while they are tiled or one floats in a
window. Without a window (headless) it holds none. The view has
typename, parent, bounds (the part of the document the canvas shows),
centerPoint, zoom (1 is 100%, from 0.0313 to 640) and screenMode.

Setting zoom, centerPoint or screenMode changes the window when the
slice ends, runs no command and adds no undo step, and a run that fails
keeps the change. The screen mode is the app's, so setting it on one
view sets it on every view. A bad value throws and leaves the view as
it was.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-25 00:24:55 -08:00
dotCooCoo 950cf819dd Merge feat/scripts-api-d1a-app-documents into feat/scripts-app-redraw 2026-11-24 23:59:14 -08:00
dotCooCoo e45b922802 Scripts: app.redraw returns without changing the documents
A script that called app.redraw() stopped with an error, because app had
no such member. The call now returns undefined and adds no undo step. A
run works on its own copy of the documents, and the app draws the
documents as they were before the run until the run ends, so the call
has nothing new to draw.
2026-11-24 23:58:24 -08:00
dotCooCoo 66efae46f2 Scripts: app.executeMenuCommand runs a menu command
app.executeMenuCommand(name) runs the command of a menu item on the
active document. It takes the names selectall, deselectall, group,
ungroup, makeMask, releaseMask, compoundPath, noCompoundPath and
"Fit Artboard to artwork bounds", which fits the active artboard.
Names are matched exactly. Any other name throws an error that names
it, and a name that is not a string throws a TypeError. A menu item
that is not available, with no document open or nothing selected,
does nothing and adds no undo step.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-24 22:45:55 -08:00
dotCooCoo 986da7d0b4 Scripts: assigning undefined to Document.selection throws and keeps the selection
Document.selection treated undefined like null and cleared the selection.
It now throws a TypeError for undefined, as for any value that is not a
page item, a list of them, null or [], and leaves the selection as it was.
2026-11-24 18:06:50 -08:00
dotCooCoo af34f97abc Merge feat/scripts-api-d1a-app-documents into feat/scripts-api-d7b-tags-notes-uuid
# Conflicts:
#	crates/ui-egui/src/dialogs/new_document.rs
2026-11-24 17:00:35 -08:00
dotCooCoo 112eacbb1c Scripts: remove() keeps an emptied compound path, and note takes numbers
- remove() on the last path of a compound path keeps the compound path,
  empty, as move() does, so a script that holds it can still read it.
  edit.clear takes keepEmpty: true for this, and passes it on to
  path.deleteAnchors when it deletes direct-selected anchors; without
  it, Clear still deletes a compound path it empties.
- note, like name, takes a number or a Boolean as the text String()
  gives it.
- Assigning a graph mark or label the opacity it already has throws
  Cannot edit in a hidden or locked layer when the graph keeps another
  opacity for its series or kind, since the assignment would still
  change the graph.
- Only the exact opacity the getter reports counts as the opacity an
  object already has; a value that differs from it by less than 0.0001
  is now applied instead of being dropped.
- Reading a document's selection orders only the selected objects, by
  their place in the tree, so its cost no longer grows with the size of
  the document.
- docs/mcp.md: the opacity exception, note, keepEmpty, and that
  strict-mode code throws a TypeError when it assigns a member an object
  lacks.

Docs: docs/mcp.md.
2026-11-24 16:15:51 -08:00
dotCooCoo fe0e408607 Scripts: zOrder refuses art in a hidden or locked layer, and the same opacity may be assigned
- zOrder() on an object in a hidden or locked layer throws Cannot edit
  and changes nothing, as the other setters do.
- Assigning an object the opacity it already has no longer throws when
  its layer is hidden or locked. hidden and locked are still refused
  there, whatever the value.
- The docs say that a top-level var selection = ... assigns the
  selection, that the selection order and the tab order of documents
  differ from the objectReferences page, and that assigning a member a
  collection lacks throws Not found.

Docs: docs/mcp.md.
2026-11-24 16:15:50 -08:00
dotCooCoo 6b778a4c70 Scripts: setters refuse art in a hidden or locked layer, and empty objects read zero bounds
- Assigning hidden, locked, position, left, top, width or height to an
  object in a hidden or locked layer throws Cannot edit, as opacity
  does, and changes nothing. Its name and note still change.
- An object with nothing in it, such as an empty group or a compound
  path whose paths moved out, reads its bounds, position, width and
  height as zeros, and assigning them does nothing, so reading every
  property for-in lists does not throw on it.
- Assigning selection without app. sets the active document's
  selection, and app.selection can be assigned the same way. Assigning
  activeDocument without app. activates a document, and assigning
  documents keeps its value.
- JSON.stringify writes a collection, or data that holds one, without
  reading toJSON through the collection's name lookup, which threw
  Not found.
- The docs state that Object.keys, Object.getOwnPropertyNames and
  Object.getOwnPropertyDescriptor do not report the members, that a
  value assigned to a member the class lacks is not kept, and that the
  selection order is VectorCraft's own rule.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-23 13:24:33 -08:00
dotCooCoo 9872e6b679 Scripts: page items report their own members, and lists start with the topmost object
Scripts that check a member with hasOwnProperty before using it skipped
every page item, because the members live on the class prototype. Now
hasOwnProperty and propertyIsEnumerable are true for each member of an
object's class that is available, and for-in lists its properties but
not its methods. Members that only throw "not available yet" stay false.

- An empty selection is an empty list instead of null.
- pageItems lists art topmost first, as the CMYKColor example reads the
  frontmost path as pathItems[0]
  (https://ai-scripting.docsforadobe.dev/jsobjref/CMYKColor/). A
  document's selection lists the selected objects in that order too,
  whatever order they were picked in. That selection order is
  VectorCraft's own rule.
- A collection read with a name, such as pageItems["Logo"], gives what
  getByName gives, as
  https://ai-scripting.docsforadobe.dev/scriptingJavascript/objectReferences/
  shows. A name nothing has throws Not found, and assigning to such a
  name throws the same error.
- activeDocument, documents and selection can be named without app., as
  that page describes for the application's members.
- move() with the object itself and PLACEBEFORE or PLACEAFTER leaves it
  where it is and adds no undo step.
- move() keeps a compound path whose last path moves out, so a script
  that holds it can still read it.
- Assigning opacity to an object in a hidden or locked layer throws
  Cannot edit and changes nothing.
- name takes a number or a Boolean as its text.
- String() of an object gives its class and name, such as
  [PathItem Logo].

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-23 13:24:32 -08:00
dotCooCoo dc9adb195d Scripts: pageItems lists the art inside blends, envelopes, repeats and intertwines
pageItems walked into groups and compound paths only, so the objects inside a blend,
an envelope, a repeat or an intertwine were missing from length, [i], index and
getByName, although each of them reports that container as its parent. The walk now
goes into every container's children.
2026-11-22 15:33:08 -08:00
dotCooCoo 3d460c1697 Scripts: guide, layer, move and addDocument fixes for the object model
- Document.selection and PageItem.selected refuse a path made into a
  guide while Lock Guides is on, instead of passing the check and then
  selecting nothing. The locked artboards are measured once per
  assignment.
- An edit whose command selects the objects it changes puts the current
  layer and the highlighted Layers panel rows back as they were.
  layer.setCurrent takes keepRows, which leaves the highlighted rows as
  they are.
- move on an object on a locked artboard throws Cannot move, as editable
  reads false for it. duplicate, with or without a relative object, on a
  hidden or locked object or an object on a locked artboard throws
  Cannot duplicate and makes no copy.
- When move takes the last path out of a compound path, the empty
  compound path is deleted in the same undo step.
- addDocument writes each warning from reading the profile's file to the
  Script Console as addDocument: <warning>, and a previewMode of
  PixelPreview throws an error that says it is not available yet.
2026-11-22 15:33:08 -08:00
dotCooCoo 1da34ab336 Merge feat/scripts-api-d1a-app-documents into feat/scripts-api-d7a-variables
# Conflicts:
#	crates/engine/src/script/dom.rs
2026-11-22 12:03:26 -08:00
dotCooCoo e48b811707 Scripts: an opacity a graph mark already has replaces the one its series keeps
Assigning PageItem.opacity skipped object.setProps when the item already
had that opacity, so a graph mark or label set to the opacity it shows
left the graph keeping the opacity another mark of its series or kind had
set. The setter now leaves the no-op check to object.setProps, as the
command does for that case. A value within the getter's rounding of the
item's opacity sends the opacity the item has, so assigning the opacity a
script read back still changes nothing and adds no undo step.
2026-11-22 07:02:06 -08:00
dotCooCoo 341f764458 Scripts: editable is false on a locked artboard, page item lists kept for several documents
- PageItem.editable is false for art on a locked artboard, as remove()
  refuses it. A group on a locked artboard is measured once for all its
  members.
- The lists of page items are kept for the last four documents read, so
  a script that reads two documents in turn does not walk each one again
  on every index.
2026-11-22 03:26:18 -08:00
dotCooCoo 99e07b0f6b Scripts: DocumentPreset arrays count each element against the heap
The heap limit on DocumentPreset values counted a boolean as 4 bytes,
while the host keeps a whole value for each array element, so arrays
kept by many presets could hold several times the run's heap. The
limit now counts the host's copy: a value for the field and for each
element or property, plus the text of its strings and property names.
2026-11-21 21:40:07 -08:00
dotCooCoo 67633efb4d Scripts: a linked profile file is refused and preset values count as passed data
A New Document profile file that is a link or a folder is no longer read:
the read is exempt from a script's file gate, which never checked where a
link leads. file.new reports it as a profileError with the reason "not a
plain file".

Reading a DocumentPreset setting now counts the value it returns toward
the data a run may pass, as assigning it does, and addDocument counts the
preset's settings before copying them.

The removeAll() test on a locked artboard now also holds an object on an
unlocked artboard and checks it is still there after the call throws.
2026-11-21 21:36:54 -08:00