Commit Graph
12 Commits
Author SHA1 Message Date
dotCooCoo 226eb80e6f Merge main into feat/scripts-api-d8b-tracing 2026-11-26 00:17:34 -08:00
.CooCoo 5f35daad7b Scripts: File and Folder give their localizedName (#9185) 2026-11-25 00:54:37 +07:00
dotCooCoo fde921a744 Scripts: review fixes for tracing, placed items, saves and the New Document layout
- The Image Trace panel's lookup test skips an Image Trace object's source
  image, as imageTrace.make does since trace() came in.
- A save of several files refuses a path the file access in force refuses
  before any file is written, whatever writer the caller gives.
- move and duplicate look a page item up through its class, so a PlacedItem
  that was embedded is stale as the relative object.
- PLACEATEND into an Image Trace object puts the object directly above the
  source image, which stays the first child.
- controlBounds takes in the anchors and Bezier handles of the item's paths.
- The file of a PlacedItems.add() result is stale once its document closes.
- Assigning PlacedItem.file reads the placed image's id from the command's
  own result, so an id above 2^53 binds and clears exactly.
- The enumerations the save and export option defaults name are registered,
  with the members the scripting constants page lists.
- A tracing replaced twice and then undone is followed to the one the
  document holds.
- Choosing the artboard layout in force again keeps a preset's rows.
- docs/mcp.md and docs/gaps.md describe controlBounds, a null preset for
  addDocument, the view options and scripted tracing.
2026-11-22 07:44:39 -08:00
dotCooCoo 022d0ce7e8 Scripts: PlacedItem.trace and RasterItem.trace make an Image Trace object with its tracing options
`PlacedItem.trace()` and `RasterItem.trace()` run `imageTrace.make` with the
Default preset and return the Image Trace object as a `PluginItem`. Its
`tracing` is a `TracingObject` with the source image, the path, anchor and
color counts, the image's resolution, `expandTracing()`, `releaseTracing()`
and a `TracingOptions` object. Assigning an option or loading a preset traces
the image again, keeping its source image and view; a value the tracing
already has runs no command. Option values are checked for type and range
before any trace, and nothing changes when one is refused. Options with no
VectorCraft setting and `expandTracing(true)` throw. `storeToPreset` returns
`false` for a built-in preset name or `Custom` and throws for any other name.

A tracing that was expanded, released, deleted or traced again by a command
is stale. The source image is reached through `sourceArt` and is not listed
in `pageItems`, `placedItems` or `rasterItems`, and the name of a tracing
cannot be changed from a script. With a script running, `imageTrace.make`
stops at the run's stop request.

Setting `File.hidden` stores the new path with `set_path`, since the path is
held in the object's class on this branch.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-21 23:25:42 -08:00
dotCooCoo 1ab09c8978 Scripts: UnitValue measurements convert and calculate with their units
Scripts get the global UnitValue constructor: a number with one of the
length units (inches, feet, yards, miles, millimeters, centimeters,
meters, kilometers, points, picas, traditional points and picas,
ciceros), pixels or percent. as() and convert() give or change the
unit, baseUnit sets what one pixel and 100% measure, and the arithmetic,
comparison and unary operators calculate with the object's number. With
two objects the right one is converted to the left one's unit.

Conversions go through exact ratios to the inch, so 1 in is exactly
72 pt. An unknown unit or text makes an invalid object; converting it or
using it with an operator, a result that is not finite and a comparison
with a number that is not finite throw a RangeError.

A realm without UnitValue keeps the standard operators. docs/mcp.md
describes the class.
2026-11-21 19:56:57 -08:00
dotCooCoo dc7d5ccfd7 Tests: the script host name tables list the placed and raster item names
PlacedItem and RasterItem leave the bare classes, and the tables list
Document.placedItems and rasterItems, the PlacedItems, RasterItems,
PlacedItem and RasterItem members, and the ImageColorSpace and
RasterLinkState enumerations. PlacedItem.file= and relink read the image
file they are given, so they stay inside the document.
2026-11-21 18:29:28 -08:00
dotCooCoo 610f7c5b14 Merge branch feat/scripts-api-d1a-app-documents into feat/scripts-api-d8-placed-raster
# Conflicts:
#	crates/engine/src/script/dom.rs
#	crates/engine/tests/it/script_host_vs_scriptcheck.rs
2026-11-21 18:10:02 -08:00
dotCooCoo d14830b6b7 Scripts: saveAs and exportFile refuse a file open for writing and scales under 1%
A save or export to a file that a File object holds open for writing throws "Script file is open for writing", and a command the script runs does not write such a file besides the one named (an SVG's images), so the bytes the File writes at the end of the run do not replace the output. horizontalScale and verticalScale take 1 to 776.19, since a raster export writes at least 0.01 pixels per point.

The script checker reports a document's saveAs and exportFile as file writes, and the host name check lists the save, export and open names, option classes and enumerations.
2026-11-21 17:36:55 -08:00
dotCooCoo ba0441c458 Scripts: addDocument takes only a DocumentPreset and throws when its profile cannot be read
- new DocumentPreset() now makes an object of the DocumentPreset class whose settings the run
  keeps, so addDocument refuses a plain object, one with a typename of DocumentPreset included,
  with a TypeError naming presetSettings.
- When file.new reports a profileError, addDocument throws an error that names the profile and
  the reason, and the document made with the defaults is put back.
- A script's file.new reads the New Document profile file in the app's own profiles folder;
  the automation roots in force still apply. Before, the script's file gate refused the folder,
  so a scripted addDocument never used an edited profile.

Docs: docs/mcp.md.
2026-11-21 14:33:43 -08:00
dotCooCoo 626d843520 Scripts: list the object model in the host name check, refuse zOrder inside a compound path
The host name test now has rows for app, the document model classes and the enumerations the script host adds. zOrder on a path inside a compound path throws an error and leaves the document unchanged, as duplicate does.
2026-11-21 10:34:09 -08:00
dotCooCoo b2e7784160 Docs: progress line for the script checker's File setters and host test
docs/target-app-parity.md gets a line for the file.write report on a
File object's length, hidden and readonly and for the test that lists
every name the script host adds, with the tests that cover them. The
test's comment on vc no longer names another app.
2026-11-20 19:05:54 -08:00
dotCooCoo 417ed94431 Script checker: setting a File's length, hidden or readonly counts as a file write
Setting a File object's length truncates or pads the file, and setting
readonly or hidden changes it, but script.check reported no outside
category for those assignments. It now reports file.write and
filesWritten for them: plain and compound assignment, ++ and -- before
or after, and the property name as a string literal in brackets.

A new integration test lists every global and member the script host
adds to the JavaScript engine (the own properties of the global object,
of each object or function it holds and of each function's prototype,
compared with a plain engine) and fails when one has no row. Each name
that reaches outside the document has a probe script, and the test
checks that script.check gives it the expected outside id. vc is listed
as not checked: script.check reads scripts written for the reference
app's scripting, and what vc.run does depends on the command. The test
also checks that the checker lists every preprocessor directive the
host reads, through the new DirectiveName::ALL.

File object properties:
https://extendscript.docsforadobe.dev/file-system-access/file-object/
2026-11-20 18:36:13 -08:00