Commit Graph
143 Commits
Author SHA1 Message Date
dotCooCoo b47eaf582c Merge main into feat/scripts-api-d8-placed-raster 2026-12-02 14:14:45 -08:00
dotCooCoo 82ed3b1d70 Merge main into feat/scripts-api-d8-placed-raster 2026-12-02 11:57:33 -08:00
dotCooCoo 497e2eb4e7 Merge main into feat/scripts-api-d8b-tracing 2026-12-02 11:33:20 -08:00
.CooCoo 5cfc4cf100 Merge pull request #9041 from dotCooCoo/feat/scripts-api-d2-paths-colors
Scripts: documents give scripts their paths, path points and colors
2026-12-02 11:15:31 -08:00
.CooCoo 0a14ee1d23 Merge pull request #10363 from dotCooCoo/fix/close-native-range
Scripts: close with SaveOptions.SAVECHANGES saves a native file whose last save named a range
2026-12-02 11:15:06 -08:00
dotCooCoo eb5e4c5eb7 Scripts: retrace and release refuse a tracing with locked traced artwork
Retracing and releasing a tracing discard the objects its trace made, so
both now throw "Cannot edit page item <id>" when one of them is locked,
with nothing changed. Added artwork is still reported first. The scan
stops at the first added object and charges the objects it looked at to
the run on both the success and refusal paths.
2026-12-02 08:32:22 -08:00
dotCooCoo 549a383942 Merge main into feat/scripts-api-d2-paths-colors 2026-12-02 05:32:57 -08:00
dotCooCoo d359bb7e1a Print: Document.print throws for CUSTOMPROFILE without a profile name
A script that set PrintColorManagementOptions.colorProfileMode to
CUSTOMPROFILE and assigned no name printed with the base settings'
profile, as though no custom profile had been asked for. The job now
throws before anything is written, as it does for an empty name.

Follows up on #9087.
2026-12-02 05:13:50 -08:00
dotCooCoo 47a8bcde18 Merge main into feat/scripts-api-d8b-tracing 2026-12-02 02:46:39 -08:00
dotCooCoo 3ea259e6b9 Merge main into feat/scripts-api-d2-paths-colors 2026-12-02 02:20:34 -08:00
dotCooCoo a1b8b01383 Scripts: refuse moves that make a tracing, and a release that drops added art
- move, remove() and zOrder throw "Only Image Trace can make a tracing",
  with nothing changed, when they would leave an image at the bottom of
  an ordinary group named Image Trace: a path moved out of the group or
  to its top, Send to Back or Send Backward on the image, and Bring to
  Front or Bring Forward on the object below it.
- releaseTracing() throws "Cannot release a tracing containing added
  artwork", with nothing changed, when the tracing holds an object its
  trace did not make. imageTrace.release keeps only the source image, so
  the added object would be deleted.
- The TracingOptions members with no setting and TracingObject.areaCount
  are left out of hasOwnProperty and reflect. Reading them still throws.

Docs: docs/mcp.md.
2026-12-02 01:26:30 -08:00
dotCooCoo e5df2445e3 Scripts: new IllustratorSaveOptions reads compatibility as ILLUSTRATOR19
A new IllustratorSaveOptions left compatibility unset, so a script that
read it before setting it got undefined. It now starts at
Compatibility.ILLUSTRATOR19, the documented default, which saveAs already
accepts without changing what it writes.
2026-12-01 21:31:56 -08:00
dotCooCoo a7129f3eed Merge main into feat/scripts-api-d8b-tracing 2026-12-01 14:07:15 -08:00
dotCooCoo 85a46c0e7d Merge main into feat/scripts-api-d8-placed-raster 2026-12-01 14:07:03 -08:00
.CooCoo a5a3e40c5e Merge pull request #9087 from dotCooCoo/feat/scripts-print-printer
Scripts: Document.print prints to an installed printer and app.printerList lists the printers
2026-12-01 13:11:17 -08:00
dotCooCoo d9d9354ec7 Scripts: moving an image cannot make a tracing; counts do only their work
- move() and duplicate() refuse to put an image at the bottom of an
  ordinary group named Image Trace, before the document changes, as
  renaming such a group already does. A tracing's source image moved
  out keeps its own error.
- pathCount and usedColorCount no longer walk the anchor points, and
  anchorCount charges each path inside a compound path it reads.
- The run keeps the reverse of its replacement map, so finding the
  first object of a chain no longer scans the whole map at each step.
- docs: the source image of a traced item is left out of pageItems,
  placedItems and rasterItems and is reached through
  PluginItem.tracing.sourceArt; docs/mcp.md lists the new error.
2026-12-01 13:09:41 -08:00
dotCooCoo 6de89eece9 Merge main into feat/scripts-api-d8b-tracing 2026-12-01 09:00:59 -08:00
dotCooCoo 6a9ab599c4 Scripts: image lists propagate a page item rebuild error
The merge of main brought in fe89d3f8, which makes page_items return a Result so that a rebuilt list counts against the run. The image collection still used the list as a plain Vec, so the engine did not compile (E0308, E0599 in images.rs). It now propagates the error with ?, as the other collections do.
2026-12-01 03:14:32 -08:00
dotCooCoo a0c0bce325 Merge main into feat/scripts-api-d8-placed-raster 2026-12-01 02:55:47 -08:00
dotCooCoo 08bc2d2009 Scripts: image lists propagate the page item list's run error
Cause: main's fe89d3f8 changed page_items to return a Result, since
building the list again now counts against the run's host-call allowance.
The image collections' list builder still used the old return type, so
vectorcraft-engine did not compile once main was merged in, and every
gate shard failed. The builder now passes the error on with `?`, as the
path and text lists do.
2026-12-01 02:37:29 -08:00
dotCooCoo ec4a813fa3 Scripts: stale placed items are refused as relative objects; exact image matrix checks
- move() and duplicate() resolve a page-item relative object, an add()
  result included, through item_of, so a PlacedItem object made stale by
  embed() throws "Stale page item" instead of acting as a target.
- Assigning matrix compares each requested coefficient exactly with the
  value the getter reports. A coefficient left as reported keeps the
  image's own value, so a change of 5e-10 still moves the image and an
  untouched axis does not shift. A move alone is applied as an offset.
  A matrix that a nearly singular image cannot reach within 1e-6 pt at
  its corners, or that would leave it with no area, throws an error with
  nothing changed, and a change that rounds away runs no command.
- The RasterItem.embedded test calls the getter itself on 1 and on a
  live raster item.
- docs/mcp.md states when assigning matrix runs no command and when it
  is refused.
2026-12-01 02:32:07 -08:00
dotCooCoo 99bea87cff Merge main into feat/scripts-api-d8b-tracing 2026-12-01 02:16:37 -08:00
dotCooCoo bf56f4d062 Scripts: a group holding an image cannot take the tracing's name
PageItem.name now refuses "Image Trace" for an unclipped group whose
first object is an image and that is not already a tracing. That name
would make the group a tracing, and expanding it would delete its first
object.

The snapshot of a tracing's objects is now taken only for a tracing
saved without the record of the objects its trace made, and only the
first time a run sees it. Retrace reads it only in that case.

docs/target-app-parity.md now says that the view options only change
the view, and docs/mcp.md lists the new rename error.
2026-12-01 02:00:17 -08:00
dotCooCoo ea8352c5d7 Merge main into feat/scripts-print-printer 2026-11-30 20:57:56 -08:00
dotCooCoo 32543571f3 Scripts: close with SaveOptions.SAVECHANGES saves a native file whose last save named a range
A native save keeps every artboard in its main file and reads `range` only
for the separate files of `separateArtboards`. The close check treated a
native document last saved with `range` and without `separateArtboards` as
a save of some artboards, and refused to close it although the save writes
every artboard.
2026-11-30 20:41:27 -08:00
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 ac03057d2f Scripts: retrace keeps the tracing's appearance and its script object
Tracing an Image Trace object again built a new group with default
object settings, so a tracing's opacity, blend mode and appearance items
were lost on each retrace. The new group now takes them from the tracing
it replaces.

After an option change replaced the tracing, a PluginItem read from a
collection or the selection was a different object from the one the
script already held. Handles to a replaced tracing now name the first
object of its chain of replacements, so they compare equal.
2026-11-30 19:00:58 -08:00
dotCooCoo 795bef8b29 Scripts: retrace refuses a tracing that holds artwork its trace did not make
imageTrace.make records the ids of the objects it made in the tracing's
trace settings as `made`, and copying the tracing records the ids of their
copies. Tracing again through the scripting API throws, with nothing
changed, when the tracing holds any other object, whether it was added in
this run, an earlier run or by a command. A tracing saved without `made`
is checked only for objects added in the same run, as before.
2026-11-30 17:54:54 -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 7b6c730df6 Merge main into feat/scripts-api-d8b-tracing 2026-11-30 15:48:31 -08:00
dotCooCoo 8e682687ce Merge main into feat/scripts-api-d8-placed-raster 2026-11-30 15:39:04 -08:00
dotCooCoo 1b2da536cc Merge main into feat/scripts-print-printer 2026-11-30 15:25:50 -08:00
dotCooCoo 0c13a1edb2 Scripts: close the review gaps in print, saveAs, File paths and presets
- The 1000% scale limit applies only when Fit to Page is off, since the
  scale factors are not used with it on.
- A script run clears the print command allowance when it ends, so a
  panic inside print cannot leave file.print open to later runs.
- saveAs without options takes the format from the path the script
  names, so a link at that path cannot change it.
- A File the host gives back charges its path to the heap.
- DocumentPreset.typename throws for a preset from an earlier run.
- Documents.addDocumentNoUI throws that it is not available yet.
- The print tests remove their folders when an assertion fails.
2026-11-30 14:54:47 -08:00
dotCooCoo 164c3c53a6 Scripts: tracing counts leave out only the trace's own seam fills
pathCount, anchorCount and usedColorCount skipped every group anywhere in
the tracing that looked like seam fills, so a group named "Seam Fills"
moved into a tracing was not counted. The counts now leave out a clip
group directly in the tracing that is seam fills, or the lowest item
above the source image for traces made before seam fills were clipped,
as retracing does. An Image Trace object inside the tracing leaves out
its own seam fills the same way.
2026-11-30 08:59:11 -08:00
dotCooCoo ed0859d0d0 Scripts: kept-default option enumerations and refusal of non-UTF-8 real paths
The enumerations whose default member an option keeps (OutputFlattening,
CompressionQuality, the PDF color, compression, mark and security enums,
and the SVG encoding, DTD, CSS and font enums) are now defined, so a
script that sets an option to its default no longer throws a
ReferenceError; another member still throws as not available yet.

saveAs, exportFile, app.open and close with SAVECHANGES refuse a path
whose real file name is not valid UTF-8 instead of writing to or opening
a file named with a lossy copy of it.
2026-11-30 07:51:17 -08:00
dotCooCoo affd7a8853 Scripts: tracing keeps its source image; image edits roll back on failure
- Moving a tracing's source image out of its tracing throws instead of
  breaking the tracing.
- PlacedItem.file places and checks the linked image under one savepoint,
  so a failed check leaves no linked image behind.
- Retracing restores the selection under the same savepoint as the trace.
- matrix assignment compares the linear part exactly, so a small change
  to the scale or rotation is applied.
- ExportOptionsPNG24 and ExportOptionsJPEG accept white, their default
  matteColor; another color is still an error.
- File objects made without charging their path no longer reserve it.
- Tests: the RTL artboard column check reads the direction from the
  layout, js_path escapes line breaks and quotes, rejected tracing
  options leave the saved document unchanged, and the Image Trace panel
  targets a second image selected with its tracing's source.
- docs/mcp.md: the scale and clipping options apply to PNG24 and JPEG,
  and the source image move error is documented.
2026-11-30 06:16:56 -08:00
dotCooCoo f4c911d4d3 Scripts: open options with an importer, null export options and close checks for files that keep every artboard
- document.open refuses page, cropTo, pages and crop when a named importer reads the file (linkPages
  still uses the built-in reader).
- exportFile with explicit null options throws a TypeError for GIF, PNG8 and TIFF too.
- close(SaveOptions.SAVECHANGES) saves a modern .ai or .ait file and an SVG file with Preserve
  Editing whatever range was remembered; a range the save refuses still refuses.
- The script checker keeps a try statement's catch and finally, and an else after a nested
  do-while, inside the loop body; a line break after a label does not start a new statement; a
  this assignment in a function that hides a global clears the global's saved methods; and
  holder.d['saveAs'] = ... no longer counts as a write to d.
- docs/mcp.md describes which files keep every artboard on close.
2026-11-30 03:36:01 -08:00
dotCooCoo 4edede500d Scripts: retracing refuses added artwork; PlacedItem.file resolves linked paths
- Retracing a tracing that holds artwork added after the trace throws before
  the document changes; the retrace limit counts retraces, not mappings.
- Image Trace warnings from trace and option changes go to the console.
- PlacedItem.file resolves the link against the document's folder.
- saveAs picks the format from the name it was given before resolving aliases.
- controlBounds includes handles inside blends, envelopes and other containers.
2026-11-29 19:07:40 -08:00
dotCooCoo 82d4ec4336 Scripts: explicit crop boxes, EPS close-with-save and writer receivers checked per call
- document.open with an explicit PDFCROPBOX crop opens on the crop box
  of a file with editing data; the default keeps the trim box and bleed.
- Closing with save changes keeps an EPS document's artboard range, since
  the EPS file holds the whole document.
- The script checker treats a writer receiver captured from an outer
  scope as able to change before each call, and finds the loop that holds
  a call with a binary search instead of a scan of every loop.
2026-11-29 19:01:56 -08:00
dotCooCoo 466debdc8f Scripts: tracing refuses protected art; exportFile logs warnings; saveAs rejects unknown extensions
- trace(), retracing, expanding, releasing and view changes refuse a locked
  or hidden item, or one on a locked artboard, and leave it unchanged.
- exportFile writes the export's warnings to the script console.
- saveAs without options refuses a path whose extension names no format,
  after the path's grant check.
- tracing.parent returns the same PluginItem handle the script holds, and a
  placed item bound by assigning file is the same object in collections.
- PluginItem.isTracing goes stale with its TracingObject when the original
  source image is gone.
2026-11-29 18:00:42 -08:00
dotCooCoo db7fe4d38b Scripts: tracing keeps added images and direct selections; app.open logs warnings
- Expanding a tracing removes only its source image; other images a script
  moved or duplicated into the group stay.
- A TracingObject goes stale when its original source image is gone, even
  when another image now sits first in the group.
- Tracing, retracing, expanding and releasing restore the whole selection,
  anchors and segments included, with only the replaced object remapped.
- app.open writes the open's warnings to the script console, as saveAs does.
- embed() checks the image's link state after the command instead of a
  returned id rounded to a JavaScript number.
- The placed-image tests pass ordinary drive paths to File on Windows.
2026-11-29 17:02:07 -08:00
dotCooCoo f99ef023ad Scripts: close checks the artboards the saved file keeps; saves report warnings
Document.close(SaveOptions.SAVECHANGES) now judges artboard loss by the
file the save writes. A PDF last saved with useArtboards: false is
refused, since it holds one page of the art's bounds. A native or .ai
file saved with separateArtboards is saved and closed whatever its range
names, since the range picks only the separate files; a version 7 .ai
file keeps the range check.

Document.saveAs, Document.exportFile, app.open and the save that
close(SaveOptions.SAVECHANGES) runs write each warning of their command
to the console after the method's name (for example "saveAs: SVG keeps 1
of the document's 2 artboards ...").

Script Check reports a file write for a saveAs or exportFile call on the
script's own object when the variable is assigned in a loop around the
call, since a later iteration may run the call on a document. Loop bodies
without braces follow if, else and line breaks, and a variable of the
same name that a function declares is kept apart.

A test shows that a waiting point change counts as unsaved for
Document.saved and close().
2026-11-29 16:49:37 -08:00
dotCooCoo 64972e8a91 Scripts: saveAs logs the save's warnings; exact grants cover linked files; a tracing's source stays first
- Document.saveAs writes each warning file.saveAs gives to the console as a
  line that starts with "saveAs: ", and still returns undefined.
- A save, export or open of a File the script names no longer reads a file
  an open document links to outside the script's grants.
- A save or export that writes several files checks that no folder is where
  one of them goes before it writes the first, so none of them is written.
- Moving the source image of a tracing within its tracing, and zOrder on it,
  leave it first; zOrder SENDTOBACK on another object in a tracing puts it
  just above the source.
- The two new script file errors are English only; their catalog rows are
  removed (translations go through storytold/craft-i18n).
2026-11-29 15:49:36 -08:00
dotCooCoo 1a991e4787 Scripts: pathItems reads names such as -1 and 1.5 as pageItems does
A key that is the text of a number but not an array index, such as -1
or 1.5, reaches the indexer as a number, so pathItems[-1] gave
undefined for a path named -1. pathItems now takes main's pageItems
lookup: an array index is a position, and any other number is looked
up as that name. index() still takes a number as a position. The
progress-doc line for Document.pathItems states the name lookup and
the locked-artboard rule of removeAll().
2026-11-29 14:38:41 -08:00
dotCooCoo 60c1eb34af Merge main into feat/scripts-print-printer 2026-11-29 14:36:49 -08:00
dotCooCoo b1e9a4cbb3 Merge main into feat/scripts-api-d6-save-export-open
main's Document member list held saveAs and close as members that are not
available yet; this branch's save_open members implement them, so the
merge drops them from that list and keeps main's other entries. The
script host test lists take main's members together with this branch's
open, userInteractionLevel, fullName, path, saved and option classes,
and the heap accounting keeps main's ModuleNamespace arm beside the
FsEntry string arm.
2026-11-29 14:13:21 -08:00
dotCooCoo 7865be34a0 Merge main into feat/scripts-api-d8-placed-raster 2026-11-29 14:09:48 -08:00
dotCooCoo e861b20a33 Scripts: pathItems reads a path by name as pageItems does
pathItems["name"] read as undefined and "name" in pathItems was false
even when a path had that name, while pageItems gives the object
getByName gives. pathItems now does the same: a read with a name
nothing has throws Not found, and the in test is false for it.

Applied on main's paths module, keeping its import list.
2026-11-29 13:46:54 -08:00
dotCooCoo 9d175f4e85 Scripts: pathItems.removeAll() refuses paths on a locked artboard
pathItems.removeAll() deleted paths on a locked artboard, while
pageItems.removeAll() and remove() throw for them. It now throws the
same error and deletes nothing when any path, a path in a group
included, is on a locked artboard.

Applied on main's paths module, whose import list now also names
ON_LOCKED_ARTBOARD.
2026-11-29 13:46:20 -08:00