- A save of several files whose file access refuses one of them returns
the refusal before any file goes to the writer, so a writer that does
not check the file access writes nothing.
- close(SaveOptions.SAVECHANGES) throws before writing, and leaves the
document open, when the document's last save named some of its
artboards, since saving with those options again could leave changes
out of the file.
- The script check no longer treats an object literal's saveAs or
exportFile as the script's own when a function body assigns the
variable without declaring it, or when the script assigns it as a
property of this (the global object in global code and in a function
called without a receiver).
- The close-with-SAVECHANGES format test reads the saved PDF and checks
that it holds the change made after the first save.
- docs/mcp.md limits the "none of them is written" sentence for SVG
linked images to refusals found before the first write, and documents
the new close refusal.
`(d).write(s)` and `(d).length = 0` on a variable holding `new Folder(p)`
counted as file writes, while `d.write(s)` and `d.length = 0` did not.
Grouping parentheses now keep what the variable holds, so a Folder
variable in them is left out the same way. A variable that may hold a
File object still counts, and a grouped assignment (`x = (d)`) still
gives `x` a value that may be a File object.
The script host ran its realm with E4X off, so XML literals were syntax
errors and XML, XMLList, Namespace, QName, isXMLName and
setDefaultXMLNamespace were missing from every script, although
vectorcraft-js has them. script.run and File › Scripts now turn E4X on
for .js and .jsx files, script text, #include files, $.evalFile, eval
and Function, and for a #targetengine engine.
script.check lists the e4x and xml features under the language need
instead of hostOnly, since VectorCraft runs them.
script.check counted write(), writeln(), copy(), createAlias(), open(),
read(), readch(), readln(), openDlg() and saveDlg() as file reads,
writes or dialogs on any object that may hold a File or Folder object.
A Folder object has none of these functions, so on new Folder(...), a
Folder place such as Folder.temp (other than Folder.current), or a
variable that only ever holds one, the call fails without reaching the
file system. The check now leaves those calls out, using the same rule
that already leaves out setting length, hidden or readonly on such an
object. Folder(...) without new and Folder.current may hold a File
object, so calls on them still count, and the Folder object's own
create(), remove(), rename(), getFiles() and selectDlg() still count
on every object.
Folder object functions:
https://extendscript.docsforadobe.dev/file-system-access/folder-object/
File object functions:
https://extendscript.docsforadobe.dev/file-system-access/file-object/
docs/mcp.md and the progress line in docs/target-app-parity.md state
the rule.
Brings in main through #9019's branch. The PDF presets now come from the shared pdf crate, so a bracketed preset name is looked up with the app's name and "Default" names its default preset.
- Document.fullName is a File for the document's file, and Document.path a
Folder for its folder. A document without a file has a fullName of a
File for its name in Folder.current and a path of "". Both throw
`Script file access denied` with the document's name when the
automation read roots do not allow the file.
- Document.saved reads whether the document has unsaved changes. Setting
it runs the new command document.setSaved, which records the document
as saved or as changed without saving it and adds no undo step.
- Document.close(saveOptions) closes a document without unsaved changes
with any SaveOptions value. With unsaved changes,
SaveOptions.DONOTSAVECHANGES closes it without them, and
SaveOptions.SAVECHANGES saves them first with file.saveAs, in the
format the file's extension names and after the write-access check
saveAs makes, and throws for a document without a file (a converted
or recovered one included). SaveOptions.PROMPTTOSAVECHANGES, the
default, throws, since a script cannot show the prompt.
- The script checker reports SaveOptions.SAVECHANGES under filesWritten
wherever the script reads it.
- A pDFPreset in square brackets, such as [Smallest File Size], names
the built-in preset of the name inside them.
- artboardRange takes a whole number from 1 as well as a string; any
other number throws.
- With saveMultipleArtboards true, a .ai or EPS save also writes each
artboard of the range to a file of its own. Without it the range is
not used, but text that is not a range of artboard numbers throws.
Document page: https://ai-scripting.docsforadobe.dev/jsobjref/Document/
The check leaves out `length`, `hidden` and `readonly` set on `new
Folder(...)`, a `Folder` place, or a variable holding one, but a script
can give that name a File object in ways the check does not read. Such a
setter now counts as a file write in a check whose files:
- use `with`, or name `eval`, `Function`, `evalFile` or `constructor`,
as a word or as a string literal in brackets (`this['eval'](s)`,
`$['evalFile'](f)`, `(function () {}).constructor(s)`)
- read, call or assign a property in brackets when the brackets hold
anything but one string or number literal (`this[k](s)`,
`this['ev' + 'al'](s)`, `this[('eval')](s)`, `this[0, 'eval'](s)`,
`$[k](f)`, `g[k] = ...`), including a preprocessor line inside the
brackets
- assign a property in brackets whose name is a string literal longer
than 256 characters, or properties of more than 1,000 names
- assign or declare `Folder`
A variable whose name a member assignment writes (`$.global.d = ...`,
`this.d = ...`, `this['d'] = ...`) counts as one that may hold a File
object. Array literals, `o['plain']` and `a[0]` leave the Folder alone.
docs/mcp.md and the progress line in docs/target-app-parity.md state the
rule.
The script checker treats a saveAs or exportFile key of the script's own
object literal as the script's own method only when the key's whole value
is one function expression: `function`, an optional name, the parameters
and the body, followed by `,` or the literal's closing brace. A value that
goes on after the body, such as `function () {} && doc.saveAs`, a call of
the function or a conditional, leaves the method reported as a file write.
The variable takes the literal's methods before the token after the
literal closes a function body, so a literal given to the body's own
variable on the body's last line no longer hides a save on the outer
variable of the same name.
A literal such as `{saveAs: function () {}, saveAs: (doc.saveAs)}` kept
the first key's exemption, because the value's opening bracket had
already raised the depth when the key was read. The key is now read at
the depth outside that bracket, so the later value replaces the
function and `n['saveAs'](f)` is reported as a file write.
The checker treats `x.saveAs(f)` as the script's own method only when
`x` was declared by a `var` statement, directly in a function body or
the global code, whose first name takes an object literal with a
`saveAs` or `exportFile` function as its whole value. The name counts
from the end of the statement.
- A literal given in a branch (`if (c) var e = {...}`), one the value
goes on from (`{...} && doc`), one given by an assignment or to a
later name of the statement, and a call inside the literal keep
reporting the write.
- A function that gives an outer variable another value removes the
exemption after the function body.
The script checker treats a saveAs or exportFile key of the script's own
object literal as the script's own method only when its value is a function
expression. A key holding another value, such as a document's method, is still
reported as a file write when called, and so is a key whose last value in the
literal is not a function expression.
- saveAs, exportFile and app.open throw "<Class> has no option <name>" for a
property their option class's help page does not list, instead of leaving it
out. An undefined property is still left out, and PDFFileOptions also takes
its read-only typename and parent.
- The script checker no longer reports a file write for saveAs or exportFile
called on a variable holding the script's own object literal that defines
that method, with `.` or in brackets. It reports it again once the method is
assigned or deleted, the object is indexed with a computed key, or another
name may hold the object.
- The read-only file test checks the open-document grant on its own, with no
folder scope that also covers the file.
A realm with Options::es2015 now has Map, Set, WeakMap and WeakSet, and
ArrayBuffer, DataView and the nine typed arrays from Int8Array to
Float64Array with %TypedArray%.from, of and the prototype methods
(ECMA-262 6th edition, sections 22.2 to 24.2). A realm without the
option, the ExtendScript realm included, has none of these names.
- Map and Set compare keys with SameValueZero and keep insertion order.
forEach and iterators skip entries deleted before they reach them and
visit entries added during the walk; the collector removes holes and
moves live iterators.
- WeakMap and WeakSet hold their keys weakly. The collector marks a
WeakMap value only once its key is reachable another way and drops the
entries of unreachable keys, also when a value refers to its key.
- Typed arrays store elements little-endian; DataView is big-endian
unless littleEndian is true. Numeric property names are elements or
nothing, with the element descriptors of later editions. Copies to the
same element type keep every bit.
- An ArrayBuffer longer than 2^32 - 1 bytes or than the heap limit is a
RangeError before anything is allocated, and every element a method
visits takes fuel.
- Until the language has iterators, the collection constructors and
%TypedArray%.from read an array, a string by code point or an object
with a length, by index. A typed array constructor reads an array or
an object with a length the same way, and converts a first argument
that is not an object to a length.
- The %TypedArray%.prototype methods that share an Array method use the
element count, and an Array method called on a typed array reads its
length property. Array methods visit every element of a typed array
longer than 4,096.
- Check Script counts new of these constructors as the language's.
test262 runs the Map, Set, WeakMap, WeakSet, ArrayBuffer, DataView,
TypedArray and TypedArrayConstructors folders in ES2015 realms.
Docs: docs/mcp.md, docs/target-app-parity.md.
Every object now has a read-only reflect property. Each read gives a new
frozen reflection with the class name, the properties and methods as
entries (name, type, dataType, defaultValue, min, max, isCollection,
arguments), and find(name).
- app, its documents, page items, layers, DocumentPreset and each class
constructor are described from the host class registry: the installed
members give the names and access, and the new HostClass.info gives the
types, bounds, defaults and method arguments dom.rs declares beside
each member. Members that are not available yet are left out. A class
that names a member twice or describes a member it does not have is
refused.
- Any other object is described by its own properties without running a
getter; a JavaScript function's parameters are its arguments.
- An object with more than 10,000 members and arguments throws a
RangeError.
- script.check counts reflection as a language feature, not host-only.
Docs: docs/mcp.md, docs/target-app-parity.md.
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.
doc['exportVariables'](f) now reports file.write and filesWritten on its line, as the dot form does. Reading the method without calling it reports nothing.
- variable.setBinding refuses an embedded image only for an image variable,
so a script can bind an embedded image's visibility.
- A Dataset object stays usable after dataset.import, variable.loadLibrary
or variable.import leaves the document's data sets as they were, or the
import is put back; it goes stale only when the data sets change.
- script.check reports a document's exportVariables as filesWritten and
file.write, and the script host test lists the variable and data set
names the host adds.
Docs: docs/mcp.md.
script.check reported file.write and filesWritten when a script set
length, hidden or readonly on a Folder object as well as on a File
object. It now leaves out only objects that are Folder objects whatever
the path names: new Folder(...), new Folder, and the Folder places such
as Folder.temp, except Folder.current, which a script can assign.
Folder(...) without new gives a File object when the path names a file,
and Folder.selectDialog() gives a File or Folder object, so setting
those still counts.
A variable counts as a Folder only when every assignment the check
reads gives it one: an assignment in another branch, in a function
body, or in an included file that gives it an object that may be a
File object keeps it counting, and a variable assigned another
variable counts as a possible File object. A File object assigned to a
function's own variable or parameter, or to a catch block's parameter,
ends with them. Calls such as remove() on a Folder object still count
as writes.
Folder object constructors and selectDialog:
https://extendscript.docsforadobe.dev/file-system-access/folder-object/
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/
Inside braces, a line such as `#include$size = 1` was taken for an `#include` line, because only the ASCII letters, digits and `_` after the `#` were compared with the directive names. The name now runs over every character a name may hold, written out or as an escape, before the comparison.
- A name may hold \u{...} escapes with any number of hexadecimal digits
up to U+10FFFF. An empty, unclosed, out-of-range or surrogate escape is
not part of a name. Each \u{...} escape read in a name is reported as
syntax newer than ES3, with the escape as written.
- # followed by an escaped name start is one private name, also in the
code of an XML literal, and its escapes are read in the report
(this.#app is #app).
- A # and a name at the start of a line is a private name, not a
directive, when the name starts with an escape, or when the line is
inside braces and the name is not a directive's. A private name whose
decoded name would make the line a directive is reported as written.
- The identifier test against vectorcraft-js also compares braced
escapes.
Docs: docs/mcp.md, docs/target-app-parity.md.
vectorcraft-js and Check Script took identifier categories from
unicode-general-category 1.1.0, which carries Unicode 16.0, so letters
and marks assigned in Unicode 17.0 (U+088F at the start of a name,
U+1ACF after its first character) were refused. Both lexers now read
general categories from unicode-properties 0.1.4 (Unicode 17.0), which
Cargo.lock already holds. The version is exact because 0.1.5 adds the
Unicode-3.0 license, which is not on the license allowlist. The
Other_ID_Start, Other_ID_Continue and Pattern_Syntax lists are the same
in PropList 17.0.
The exhaustive identifier test now expects the DerivedCoreProperties
17.0 totals (145,916 ID_Start, 149,240 ID_Continue), and new tests read
U+088F and U+1ACF written out and as escapes in both lexers.
A script whose first lines name an engine with `#targetengine name` (or
`//@targetengine name`) runs in that engine, and a later script that names
it sees the globals and functions earlier runs left, until the engine is
dropped or the session ends. A script without the line, and
`#targetengine main`, still get a new engine for each run.
- A session keeps at most 8 named engines, each with a 64 MiB heap. A run
that goes past the heap ends with the heap limit, and the engine stays
usable. Names are 1 to 64 bytes. The line comes once, in the script
itself, before its code and its #include lines.
- An uncaught error, a limit or script.stop puts the documents back and
keeps the globals the run set. An internal error drops the engine. A run
stopped at a dialog or left paused ends where it was before the engine
is kept. An error in a function an earlier run defined is reported
without a line and column.
- `vc`, `$`, `alert`, `confirm` and `prompt` are made once for each engine
and act for the run that calls them, including copies an earlier run kept
in a global. `vc.args` gives a read-only copy of the calling run's
`args`, and what a run sets on `$` lasts for that run only.
- `script.engines` lists the named engines with their heap, and
`script.engine.drop {name}` drops one. Scripts cannot run either.
- The engines stay on the thread that made them. A session used on
another thread starts there with no named engines, and the old ones are
dropped on their own thread.
- The web build has no named engines: a run that names one other than
`main` ends with an error before any of it runs.
- `Realm::end` ends a run where it is, `Realm::error_source` counts from
the realm's last script, and `HostItem::FrozenGetter` gives a frozen
value each time it is read.
- The script checker lists `#targetengine` as a supported directive.
Docs: docs/mcp.md, docs/target-app-parity.md, docs/gaps.md.
Check Script read names with Rust's alphabetic and alphanumeric tests, so it
split names at U+2118, U+203F, U+00B7 and the zero width non-joiner and joiner,
and took U+00B2 and U+2E2F into names. It now uses the Unicode 16.0 ID_Start
and ID_Continue rule that vectorcraft-js uses, with `$` and `_`
(https://www.unicode.org/reports/tr31/,
https://tc39.es/ecma262/#sec-names-and-keywords).
A `\uXXXX` escape is part of a name only when it stands for a character the
name may hold where it is: `\u0030abc` no longer becomes `0abc`, and malformed
escapes end the name.
The engine's lexer comparison test now checks that both crates take the same
characters into names, written out and as escapes.
A script's $ object now has the other members the Dollar object page
lists: about, appEncoding, bp, build, buildDate, colorPicker,
decimalPoint, engineName, error, flags, gc, getenv, setenv, global,
hiresTimer, level, line, locale, localize, memCache, os, screens, sleep,
stack, strict and version. Scripts also get the global
localize(object, ...values), toSource(value) and
Object.prototype.toSource().
Each run starts with the interface's locale and its own $ state;
$.setenv changes only the run's copy of LANG, LC_MESSAGES, LC_ALL and
OS, and $.getenv returns null for every other name. $.sleep waits from
0 to 1,000 ms between frames, and script.stop ends the wait. toSource
writes plain data only and throws on cycles, getters, host objects and
values past the data limits.
The script checker reports $.localize as a $ member instead of the
global localize function.
Replace glob imports (`use super::*`, `use crate::*`, `use sig::*`) with
the names each file uses, in scriptcheck, pdf, render, text and ui-egui.
No code changes.
Without a loader, check() scanned the script once, so a function using a
variable the global code assigns after it (`function g(){ f.write('x'); }
var f = new File('a');`) missed file.write, while the loader path found it.
The no-loader path now runs the same fix-point, keeping a scan that finds
nothing new as the report scan, so a script that includes nothing gets the
same report with and without a loader.
Fixes#4011
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the declaration pass, the significant-token helpers and the feature
recognisers into analyze/declared.rs, sig.rs and features.rs without
changing their code, and replace the duplicated line-break and directive
dispatch of scan and declarations with LineBreaks::read.
Part of #4014
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FeatureId and OutsideId replace the string ids the analyzer passed around.
One table each gives the id, the need and the report order, so
catalog::FEATURES and catalog::need() are gone. Feature.id and the engine
JSON are unchanged; OUTSIDE is generated from the same table.
Fixes#4013
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Work out the unescaped text and the declared names of each file once and
share them between the scans, keep included files as bytes and decode
them on demand, check the cheap tokens before unquoting in the '=' case,
and stop allocating a String per recorded chain.
Fixes#4010Fixes#4012
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>