Commit Graph
21 Commits
Author SHA1 Message Date
dotCooCoo 74e572c8c5 Merge main into fix/script-page-item-edits
# Conflicts:
#	crates/engine/src/script/dom/paths.rs
2026-11-30 19:56:24 -08:00
dotCooCoo fe89d3f81e Scripts: list rebuilds count against the run, a stop is not masked, bad answers throw at the call
- pageItems, pathItems and textFrames build their list of a document again
  after every edit. The rebuild walked the whole document without counting
  anything against the run, so a loop that edits and reads a collection in a
  large document did unbounded host work. A rebuilt list now counts 16 bytes
  per object (as the selection's list does) against the run's host-call
  allowance, and the path and type lists count the page items they scan.
- An edit's own ordinary error was returned ahead of a stop (an uncatchable
  Abort) from putting back the selection or switching back to the active
  document, so a script could catch it and go on. A stop now comes first.
- An answer to a waiting call that could not be read as a value (nested too
  deep, too many entries) ended the run instead of being thrown at the call.
  It is now thrown there, where the script can catch it, and a ScriptUI dialog
  that waited for the answer stops showing, as when its host call fails.
- The selection cost test also compares the host calls, under the same
  64 KiB limit for both documents.
2026-11-30 15:54:45 -08:00
dotCooCoo 4082035b82 Scripts: locked artboards stop path edits, and move and zOrder respect clipping paths
- PathItem point, paint, stroke and transform changes on a path on a locked
  artboard now throw `Cannot edit` and change nothing, as the PageItem
  setters do. `pathItems.removeAll()` deletes nothing when a path is on a
  locked artboard, as `pageItems.removeAll()` does; it used to delete them.
- `move` and `duplicate` with `PLACEAFTER` and the clipping path of a clip
  group or clipping layer as the relative object throw instead of putting
  the object above the clipping path, or reporting success without moving it.
- `zOrder` counts the art above a clipping path and below the layer's ruler
  guides, as the Arrange commands do, so a method that leaves the object
  where it is runs no command.

Docs: docs/mcp.md.
2026-11-30 15:51:02 -08:00
dotCooCoo 87b5aef639 Scripts: point removals keep the selection, defaults and batching right
Follow-up to #9288.

- Removing the last anchor of a closed path with its closing segment
  selected also deselects the first anchor, the segment's other end.
- Removing a point puts back new art's paint, so a default stroke width
  a script set still applies to the next path it draws.
- A removal that leaves the direct selection as it was waits with the
  other point changes, unless every remaining anchor is now selected,
  the selection refers to points that are gone, or the path is in an
  Objects on Path group.
- Reading the points of a path first writes the waiting point changes
  of another path in the same Objects on Path group.
- Writing a path in an Objects on Path group checks the other tracked
  paths in the outermost such group, so their PathPoint handles go stale
  when the group moves them, even after an undo.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-29 10:24:53 -08:00
dotCooCoo 7a71837dea Scripts: keep new-art defaults and direct selections through path edits
- PathPoint.remove() renumbers the direct-selected anchors and segments
  after the removed point, and drops the removed anchor and the selected
  segments it ended, through selection commands after the points are
  written. A removed anchor no longer stays selected, and the same index
  no longer selects a different point.
- pathItems.add() reads new art's paint after the target document is
  active, so a path added to a document in the back keeps the stroke
  that document's selection gives new art.
- Paths a script draws put new art's paint back afterwards, so a
  defaultStrokeWidth the script set applies to every path it draws, not
  only the first.
- appearance.setNewArt refuses a fill or stroke paint with a setting a
  paint does not take, such as opacity, instead of applying the rest.
2026-11-29 05:51:46 -08:00
dotCooCoo 4b7ac69692 Scripts: fix path handles after main's revert count and review findings on path edits
PathItem handles carry the document's revert count, as page item
handles on main do, so path members find their path again.

setEntirePath and the path point setters throw a RangeError for a point
off the canvas. Opening a path whose closing segment is selected keeps
the edit. pathItems.add() leaves new art's paint as it was with New Art
Has Basic Appearance off. addDocument reports settings the built-in
preset refuses. appearance.setNewArt refuses a swatch that is not a
name. Writing one path's points looks only at that path afterwards.
2026-11-29 00:42:20 -08:00
dotCooCoo 0d5850f616 Scripts: build on main's optional item bounds and painting-tool check
main's item_rect now gives no bounds for an empty object, and the
Live Paint Bucket check became tool_paints for the fill and the
stroke. rotate and resize leave a path without bounds unchanged, and
appearance.setNewArt uses the same inheritance test as paint.rs.
2026-11-28 18:41:43 -08:00
dotCooCoo d471933b0d Merge main into feat/scripts-doc-defaults 2026-11-28 18:11:42 -08:00
dotCooCoo 7baaac6391 Scripts: read a new path's id from the command's own result
pathItems.add() and the shape constructors read the new path's id from
the script's copy of the command result, where it is a number. An id
above 2^53 was rounded there, so the constructor could return another
path, or fail after the path was made. They now read the id as an
integer from the command's result.
2026-11-25 18:24:19 -08:00
dotCooCoo f5afa0b84a Scripts: review fixes for the document defaults and the object model
- appearance.setNewArt is listed among the commands a plug-in may call, so
  every_command_is_reviewed passes.
- appearance.setNewArt refuses `tint` on a pattern that has no swatch entry,
  and its help and docs/mcp.md say an omitted `weight` keeps the stored weight.
- The dash checks of appearance.setNewArt, strokeDashes and
  defaultStrokeDashes share one helper.
- defaultStrokeWidth, defaultStrokeMiterLimit and defaultStrokeDashOffset
  compare exactly, so a slightly different value reaches new art.
- An RGB default in a CMYK document is compared in the document's color mode,
  and a color read back from a path or a default (a Gray too small for its
  value to name) assigns back without a command.
- addDocument starts from the profile's built-in first preset even when a
  saved preset has the same name.
- A saved preset's rows are read as at most 1000.
- The page item and path lists are kept for each open document, the
  selection list stops at its limit, the typename of a removed PathPoint and
  of a stale PathPoints or PathItems throws, and an item edit whose
  selection cannot be restored is undone with it.
- A path's subpath starts are counted once and kept while its points keep
  their layout, so reading or setting each of its points in turn no longer
  walks every subpath for each point.
- A run that ended while waiting for a growth answer is checked against its
  allowance again before it is kept.
- docs/mcp.md says which file limits apply to reading a profile's file.
2026-11-25 15:07:36 -08:00
dotCooCoo 1e382904fa Merge feat/scripts-api-d2-paths-colors into feat/scripts-doc-defaults 2026-11-25 00:32:34 -08:00
dotCooCoo e97b0b49ae Scripts: Document default fill and stroke members and scaleFactor
A script that read or assigned a document's defaultFillColor,
defaultStrokeWidth or another default paint member, or read scaleFactor,
got undefined. The twelve default members now read and set the fill,
stroke and stroke options of the next object drawn, and scaleFactor
reads 1.

- appearance.setNewArt sets new art's fill, stroke and stroke options
  whatever is selected, leaving the selection, its art, the active proxy
  and Recent Colors as they were. Every value is checked before anything
  changes.
- The default members run it only when the value changes. A bad value
  throws an error with nothing changed.
- paths.rs shares its dash length checks with defaultStrokeDashes.
2026-11-25 00:31:11 -08:00
dotCooCoo a278d6a837 Scripts: a path in a selected group reads as selected with its own picks too
When a group or compound path is selected together with one of its
paths, and that path also has its own anchor or segment pick,
selectedPathPoints and PathPoint.selected now report the path as
selected as a whole, as docs/mcp.md says for a path in a selected
group. Before, the path's own pick was reported instead.
2026-11-24 21:51:12 -08:00
dotCooCoo 496ac0c785 Scripts: state the segment and no-change rules of selected and guides
Assigning PathPointSelection.ANCHORPOINT to a point of a path with
selected segments replaces that path's segment selection, as
select.anchorsMany does for any anchor pick on such a path; the module
doc, the setter's doc and docs/mcp.md now say so. docs/mcp.md also says
that changing PathPoint.selected adds no undo step, and that assigning
guides the value a path already has runs no command, which is why a
hidden, locked or compound-member path, or locked guides, throw only
for the other value. The touched lines of the PathItem paragraph are
rewrapped to its width.

New tests cover a point added by the script and selected in the same
run, selectedPathPoints after an added point, a path with a selected
segment, and assigning guides its current value while guides are
locked.
2026-11-23 13:14:01 -08:00
dotCooCoo fbc057f8b0 Scripts: points of a path in a selected group read as selected
PathPoint.selected and PathItem.selectedPathPoints now count a path as
selected as a whole when a group or compound path that holds it is
selected, as the canvas shows its anchors. Assigning
PathPointSelection.NOSELECTION to a point of such a path throws an
error that says it is not available yet, and ANCHORPOINT on it runs no
command, so the selection is not left holding both the group and one
of its paths.

Selecting a point of a guide while guides are locked throws an error
instead of running a selection that the guide lock undoes.

Assigning guides = false on a path that cannot be selected (outside
the isolated object) throws Cannot edit, as guides = true does.

Reading PathPoint.selected no longer writes the point changes waiting
for its path unless they add or remove points, so a loop that reads
selected and moves the selected anchors writes the path once.
2026-11-23 13:14:01 -08:00
dotCooCoo dd74879624 Scripts: guides refuse compound members and locked guides in both directions
Assigning PathItem.guides on a path inside a compound path made every
path in that compound a guide, because Make Guides acts on the compound
that holds a selected member; it now throws an error that says it is not
available yet, as duplicate and zOrder do for compound members. While
guides are locked, assigning false threw and assigning true succeeded;
now either value throws when it would change the path. A path that
cannot be selected, for example one outside the isolated group or on a
locked artboard, throws Cannot edit before any command runs. Assigning
the value a path already has runs no command and throws no error. These
are VectorCraft's own rules, and docs/mcp.md lists them with the other
rules of its own.

Tests cover a compound path member, a clipping path, a locked and a
hidden path, the guide lock in both directions, a path in a group of
two, and the TypeError name for a value that is not a boolean.
2026-11-23 13:14:01 -08:00
dotCooCoo 262090d75a Scripts: path points read and set their selection, and guides can be assigned
PathPoint.selected and PathItem.selectedPathPoints threw an error that
said they were not available yet, and PathItem.guides could only be
read. selected now reads PathPointSelection.ANCHORPOINT for a selected
anchor point and NOSELECTION otherwise, and assigning either adds or
removes the point with select.anchorsMany, keeping the other selected
objects and anchors. Every point of a path selected as a whole counts
as selected. Direction handles cannot be selected on their own, so the
handle values throw an error. selectedPathPoints lists the selected
points in pathPoints order. Assigning guides makes the path a guide or
a path again with view.guides.make or view.guides.release, keeping the
selection; a value that is not a boolean throws a TypeError, and a
clipping path cannot be made a guide. A value the point or path already
has runs no command.

https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/
https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/
2026-11-23 11:06:19 -08:00
dotCooCoo bd945697e8 Scripts: a path point read before a command changes its path is stale
A PathPoint read before vc.run('path.setAnchors', ...) replaced its
path's points stayed valid, so a later write changed the replacement's
point at the same index. The object model now keeps each path whose
points the script read and checks it after every command and when a
point is used. When the path's points differ from the ones it last saw,
or the path is gone, the points read before throw `Stale path point`.
This covers any command run with vc.run, an undo, and a change that a
later command reverses. Points stay valid through the object model's
own changes to the path or to an object that holds it, such as
translate().

docs/mcp.md and the module doc state the rule.
2026-11-21 18:06:28 -08:00
dotCooCoo 07d673898f Scripts: a path point read before its path's points are removed is stale
A PathPoint kept its index, so after `remove()` of an earlier point it
read and changed the point that moved into its place. A point read
before the script removed a point of its path (`remove()`,
`removeAll()`) or replaced its points (`setEntirePath`) now throws
`Stale path point`.
2026-11-21 15:14:52 -08:00
dotCooCoo 55f615d0c9 Scripts: write path point edits with one command, keep colors exact
- Changes to a path's points (closed, setEntirePath, pathPoints and each
  PathPoint) wait in the object model and are written by one
  path.setAnchors before any other member or command, before another
  path's points change, and when the script ends. A loop over 2,000
  points now runs one command and makes one undo step. A path aligned to
  the pixel grid is written at each change so its points read snapped.
- A color component reads with the fewest decimals, at least 4, that give
  the stored value back, so assigning a color read from a path leaves the
  path unchanged (RGB, CMYK, Gray and Lab, fill and stroke).
- add() and the shape creators put the new path on top of the active
  layer whatever the drawing mode, and leave the mode as it was.
- fillOverprint and strokeOverprint change the top fill or stroke only.
- filled = true on a compound path member places the new-art gradient on
  the compound path's bounds.
- An identity rotate or resize checks its arguments and runs no command,
  on an empty path too.
- Tests for each of these, and for setAnchors reading smooth false as a
  corner.

Docs: docs/mcp.md, docs/gaps.md, docs/roadmap.md,
docs/target-app-parity.md.
2026-11-21 13:32:25 -08:00
dotCooCoo 43813db855 Scripts: paths, path points and colors for scripts
Document.pathItems lists a document's paths and makes empty paths,
rectangles, rounded rectangles, ellipses, polygons and stars with the
parameter order and defaults of the PathItems help page. A PathItem
reads and changes its points, closed state, fill rule, area, length,
fill and stroke colors, stroke options and overprint, and translates,
rotates and resizes. PathPoints and PathPoint read and set each
point's anchor, handles and type. RGBColor, CMYKColor, GrayColor,
LabColor and NoColor make colors; a gradient, spot or pattern paint
reads as GradientColor, SpotColor or PatternColor.

Each change runs an existing command (path.create, the shape.*
commands, path.setAnchors, path.close, path.setFillRule,
paint.setFill, paint.setStroke, stroke.set, object.setOverprint,
object.move, object.rotate, object.scale) inside the run's one undo
step, and puts back the selection and the paint for new art. A value
that changes nothing runs no command; a bad value throws and changes
nothing.

path.setAnchors now makes an anchor a corner when it is given
`smooth: false`; before, the key was ignored and handles in line made
it smooth.
2026-11-21 11:03:42 -08:00