Commit Graph
230 Commits
Author SHA1 Message Date
BFlat b9fe04f769 Merge pull request #9392 from dotCooCoo/fix/promise-combinator-iterators
JavaScript: Promise combinators consume iterable inputs
2026-11-27 00:52:25 +07:00
dotCooCoo 350fb2bdb3 Merge main into fix/realm-replaces-paused-run 2026-11-26 08:33:48 -08:00
dotCooCoo 714791d75f Merge main into fix/promise-combinator-iterators 2026-11-26 08:26:20 -08:00
BFlat 5db6caf090 Merge pull request #9405 from dotCooCoo/fix/promise-rejection-sites
JavaScript: preserve Promise rejection relay locations
2026-11-26 23:18:48 +07:00
BFlat b65a0b1542 Merge pull request #9396 from dotCooCoo/fix/prepare-call-gc-roots
Scripts: keep nested apply operands alive during collection
2026-11-26 23:18:10 +07:00
dotCooCoo 0983b6dfd5 End paused JavaScript runs before compiling replacement source 2026-11-26 06:57:29 -08:00
dotCooCoo fc07f8a326 JavaScript: root the running rejection site code 2026-11-26 06:56:03 -08:00
dotCooCoo ff9bd64003 JavaScript: preserve Promise rejection relay locations 2026-11-26 06:53:49 -08:00
dotCooCoo 1b6bcd370a JavaScript: cache shared rejection reason attribution 2026-11-26 06:42:40 -08:00
dotCooCoo 75fd52fca6 Scripts: keep nested apply operands alive during collection 2026-11-26 06:40:33 -08:00
dotCooCoo 59ddb9c3e2 JavaScript: consume iterators in Promise combinators 2026-11-26 06:28:05 -08:00
BFlat 2f4cceb462 Merge pull request #9074 from dotCooCoo/feat/js-promise-job-queue
Scripts: .js scripts have Promise and run its jobs before the run ends
2026-11-26 19:32:14 +07:00
BFlat cb7bdfd0f4 Merge pull request #9306 from dotCooCoo/fix/js-global-boolean
JavaScript: scripts have the global Boolean constructor
2026-11-26 16:49:49 +07:00
dotCooCoo 7b9726c71e Scripts: Promise statics refuse arrow functions and methods as this
The statics' constructor check now treats an arrow function, a method
and a function bound to one as non-constructors, as new does, so
Promise.resolve.call(() => {}, 1) throws a TypeError. The test262 line
in docs/target-app-parity.md now gives the count on current main: 440
of 538 runs.
2026-11-25 22:12:51 -08:00
dotCooCoo 6a72901192 Scripts: adding Promise to a realm leaves the language it reads as it was
Realm::add_es2015 no longer turns on Options::es2015, which now also
selects the ECMAScript 2015 syntax. A realm made without the option gets
Promise and still reads ES5.1 until set_es2015 changes it; the engine
calls set_es2015 for each run before it adds Promise.
2026-11-25 21:58:54 -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 ae8c902401 Merge main into feat/js-promise-job-queue 2026-11-25 21:19:42 -08:00
dotCooCoo 948ebd6adb Merge main into feat/scripts-api-d1a-app-documents 2026-11-25 10:21:51 -08:00
dotCooCoo e116212318 Merge main into fix/js-global-boolean 2026-11-25 10:17:04 -08:00
dotCooCoo 382e40dce1 JavaScript: spread tests follow the iterator protocol
Since #9138, spread steps the array's iterator, so spreading a long
array ends at the fuel limit instead of an early RangeError. Three
tests in es2015_tests.rs still expected the by-index RangeError and
failed:

- an_index_setter_without_a_getter_does_not_delay_the_spread_s_check
- a_prototype_getter_behind_an_own_element_does_not_delay_the_spread_s_check
- looking_for_index_getters_takes_fuel_for_each_property

The setter and prototype-getter tests now check the fuel limit and that
the setter or getter did not run. The test of the index-getter scan,
which #9138 removed, is deleted.

docs/target-app-parity.md had two ES2015 entries after #9138. The
by-index entry is removed; the entry that describes iterator spread
stays.
2026-11-25 04:31:45 -08:00
.CooCoo d51c4b92fb Scripts: .js object literals take methods and __proto__, and functions get names (#9138) 2026-11-25 19:25:17 +07:00
dotCooCoo 290da5bef2 JavaScript: scripts have the global Boolean constructor
The engine built Boolean.prototype but defined no global Boolean, so
Boolean(x), new Boolean(x), x instanceof Boolean and filter(Boolean)
threw a ReferenceError. Boolean now converts a value when called and
makes a Boolean object with new (ECMA-262 5.1 sections 15.6.1 and
15.6.2), with Boolean.prototype as its prototype.

test262 no longer skips tests that name Boolean, so more of them run;
docs/target-app-parity.md has the new counts.
2026-11-25 03:38:31 -08:00
dotCooCoo 1f1c8ccf8c Merge main into feat/scripts-api-d1a-app-documents 2026-11-24 20:48:43 -08:00
.CooCoo 8e7a6142fc JavaScript: a trailing comma ends call arguments and parameter lists (#9189) 2026-11-25 00:56:02 +07:00
.CooCoo 5f35daad7b Scripts: File and Folder give their localizedName (#9185) 2026-11-25 00:54:37 +07:00
dotCooCoo 71d1600dab Scripts: an error's authored check hashes its name and message without copying them
An error the interpreter throws keeps a hash of its description, and a run compares the error's
current name and message with it to tell whether the text is the script's own. The comparison
copied the whole description first, so a rejected error whose message a script had replaced with
a long string was copied whole at the end of the run. The hash is now fed the strings' code units
a piece at a time along the rope, so nothing is copied, and a change anywhere in the message is
still seen.
2026-11-24 06:12:42 -08:00
BFlat 11a26acb0b Merge pull request #9109 from dotCooCoo/feat/js-es2020-optional-chaining-nullish
Scripts: .js scripts read optional chains and the ?? operator
2026-11-24 16:09:45 +07:00
BFlat cf2c4ae3f7 Merge pull request #9187 from dotCooCoo/fix/js-dollar-stack-script-frame
Scripts: $.stack starts with a line that names the running script
2026-11-24 16:08:08 +07:00
BFlat 7696b503e6 Merge pull request #9079 from dotCooCoo/feat/js-es2015-block-arrow-template
Scripts: .js scripts run let, const, arrows, templates, default and rest parameters and spread
2026-11-24 16:06:07 +07:00
dotCooCoo ff9ed631fa Scripts: an unhandled rejection's reason is read only up to the report's length
The report keeps the first 500 characters of a rejection reason. The reason string is now read up to that length along the rope, instead of being copied whole before it is cut.
2026-11-24 00:13:32 -08:00
dotCooCoo 05d45599dd JavaScript: heap stops leave no global name, and own elements hide prototype getters
- A script's global let and const names are added only after the room
  for them and the declarations is checked, so a run that stops at the
  heap limit leaves no uninitialized name behind and the same script
  runs once the limit is raised.
- Spread of an array with a length too long for an array literal throws
  RangeError at once when every prototype getter with an index name is
  hidden by an own property of the same name earlier in the chain. The
  scan takes one unit of fuel for each earlier object it looks in, and
  stops where the fuel runs out.
- A spread test now checks the heap total right after the limit stops
  the spread, before a later step could collect, and a larger limit
  lets the same spread complete.
2026-11-24 00:13:24 -08:00
dotCooCoo b7278c9b2f Scripts: test a finally callback that returns a pending promise
The result of finally() stays pending until the callback's promise settles in a later run. A fulfilled callback promise keeps the original value or reason, and a rejected one passes on its own reason.
2026-11-24 00:05:54 -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 f205705617 Scripts: $.stack starts with a line that names the running script
$.stack is the current stack trace
(https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/).
It now starts with a line holding the run's name in square brackets, such
as `[main.jsx]`, the name the console shows for the run: the `name` given
to `script.run`, else the `#script` name, else the file's name, else
`script`. The frames follow as before. Scripts that look for a bracketed
line in the trace to find their own name, for example to name a
preferences file, now find it.

The name line comes before the `…` line that stands for frames past 64.
A realm without a name (`Realm::set_script_name(None)`) writes no such
line.

Docs: docs/mcp.md ($ object table), docs/target-app-parity.md.
2026-11-23 11:17:06 -08:00
dotCooCoo 54b9504cb5 JavaScript: a function body reserves room for its arguments object
The call reserves room for the declarations and the arguments object
before the body's let and const environment takes some of it. The body
then reserved room for its declarations again, but not for the
arguments object, so making the object could take the heap estimate
past the limit until the next check. The body now reserves both, with
the arguments size from one helper that the call also uses.
2026-11-22 17:52:55 -08:00
dotCooCoo 723e52c5ec Merge #9079 into feat/js-es2020-optional-chaining-nullish 2026-11-22 17:15:41 -08:00
dotCooCoo d61d494bea JavaScript: declarations and spread checks stay within the heap and fuel limits
- A function body, after default parameters or plain ones, and eval code
  check the heap for their function declarations and variables after
  their `let` and `const` environment is made, so the estimate stays
  within the limit while the declarations are bound.
- Looking for an index getter before spreading a long array takes a unit
  of fuel for each property it inspects, as well as for each object.
- An index accessor with only a setter no longer delays the check of an
  array of length 4294967295 when spread begins, since reading the
  elements does not run it.
- The eval test with `with` now gives the `with` object an `x`, and the
  function case declares its own `var x`, so a function closing over
  the wrong environment fails it.
2026-11-22 16:09:51 -08:00
dotCooCoo 6b8c10999d JavaScript: spread and default parameters stay within the heap limit
- Spreading an array checks the room in the result as each element is
  read, so a getter that shrinks an array of length 4294967295 gives the
  elements it reads. An array no getter reads, and any other object, is
  still checked against its length when spread begins.
- Spread counts each element's index name, and each character of a
  string, against the heap as it reads them.
- A function with default or rest parameters checks the heap again before
  its body's environment and declarations are made, since the parameters'
  values may have used the room the call reserved.
- Without the ES2015 option, a function that eval code declares on the
  global object closes over the global scope, so it sees the scripts'
  `let` and `const` names, as functions of global code do.
- With the ES2015 option, a global `var` whose name the global object
  only inherits gets its own property.
- The test262 ES2015 subset runs a test whose source does not tokenize,
  so the error counts as a failure instead of a skip.
2026-11-22 11:00:34 -08:00
dotCooCoo 1596380f23 Merge #9079 into feat/js-es2020-optional-chaining-nullish 2026-11-22 10:48:32 -08:00
dotCooCoo 15fefc9930 JavaScript: block functions, spread and global declarations follow ECMAScript 2015
- A block function whose name a function of an enclosing block declares is
  not assigned to the variable of that name.
- A labelled function in a block is made when the block is entered, and the
  parser checks it against the `let` and `const` names of its statement list.
- A function standing alone as an `if` branch gets a block of its own.
- Spread reads a `String` object by code point, and reads an array's length
  again before each element.
- A `var` or function declared on the global object stops a later `let` or
  `const` of its name until its property is deleted, and a `var` the global
  object cannot take is a `TypeError` before anything is declared.
- A call keeps its callee, receiver and arguments reachable until its frame
  holds them, and global and eval code keep their environment and their heap
  charge until their frame is pushed.
- Template objects are released when no code that can run holds their sites,
  even when one code has several sites.
- `Realm::set_es2015` during a run applies once the run ends.
- A template piece that spans lines does not let a preprocessor line start
  after it on its last line.
2026-11-22 08:21:30 -08:00
dotCooCoo 001e9ec83e JavaScript: the ?? precedence test tells the two groupings apart
`(null ?? 1 | 2)` and `(null ?? 0 ? 'a' : 'b')` give the same result under
either grouping. `(1 ?? 2 | 4)` gives 5 and `(1 ?? 0 ? 'a' : 'b')` gives 1
when `??` binds the wrong way, so the test now fails on a wrong precedence.
2026-11-22 07:59:50 -08:00
dotCooCoo 438f2a9ba8 Scripts: Promise review fixes for rooting, slices, finally and the combinators
- A promise resolved with itself roots its TypeError before the queue
  reserves room, so a collection there no longer frees the reason.
- A sliced run whose last job ends a slice reports Done in that slice
  instead of Paused, and a pause asked for in a run's last step no longer
  pauses the next run.
- The job queue is replaced at run end, which frees its buffer.
- A reaction job runs a finally callback as its own call, so a slice can
  pause inside it; the callback no longer runs to its end within the
  unbroken-fuel allowance.
- all, allSettled and race read an array to its current length at each
  step, and a string input is flattened through the charged path and
  shared instead of copied.
- The test262 runner checks the expected exception of an async test with
  a runtime negative.
2026-11-22 07:29:09 -08:00
dotCooCoo 74d481ef68 JavaScript: strict eval code keeps its own environment through collections
Strict eval code runs in a new declarative environment that no frame holds
until its declarations are made. Making the scope of its let and const names
reserves heap, and a collection there freed that environment, so the new
scope's outer link pointed at a reused slot. The environment is now a root
while the declarations are made, for direct and indirect eval.
2026-11-22 07:08:44 -08:00
dotCooCoo faa5e3062c Scripts: .js scripts read optional chains and the ?? operator
With Options::es2015, vectorcraft-js reads and runs two ECMAScript 2020
forms: optional chains (a?.b, a?.[key], f?.(args) and the accesses and
calls after them) and ??.

- An optional step that finds undefined or null ends the whole chain
  with undefined, without evaluating its other keys and arguments.
  Parentheses end a chain. a?.b() and a.b?.() call with a as this,
  (a?.b)() does too, eval?.(code) is an indirect eval, and delete a?.b
  is true when a is undefined or null.
- ?? keeps any left side other than undefined and null.
- ?. before a digit still reads as ? and a number (a?.5:1).
- Mixing ?? with && or || without parentheses, assigning to or updating
  an optional chain, a tagged template after one and new a?.b() are
  syntax errors.

Two new jump instructions test for undefined and null, and the verifier
checks both of their paths. A chain of any length compiles with a loop.
.jsx files and source strings stay ES5.1, where ?. and ?? are syntax
errors.

The test262 ES2015 subset now also reads expressions/optional-chaining
and expressions/coalesce: 426 of 426 negative parse runs and 591 of 615
other runs pass with the option. The 24 failing runs are the same as
before this change.
2026-11-22 06:45:48 -08:00
dotCooCoo 33bcf63381 JavaScript: a global function declaration reads the global object's own property
With ES2015 scripts, a function declaration was judged by a property the
global object inherits, so a fixed property on Object.prototype stopped
`function name() {}`. The check now reads the global object's own
property, as ECMA-262 2015 section 8.1.1.4.16 does, and declares nothing
when the global object is not extensible and has no property of that
name. Indirect eval code makes the same check for all of its functions
before it declares any of them, and a function declaration never adds a
property to a global object that is not extensible.
2026-11-22 01:13:14 -08:00
dotCooCoo 4447e02955 JavaScript: a rest parameter checks the heap before its array is made
A call to a function with a rest parameter built the array of its extra
arguments without reserving room for it, so `f.apply(null, big)` could
push the heap estimate past the limit. The call now counts the rest
array, its binding and one property per extra argument in the room it
reserves before the function's environment is made.
2026-11-22 00:52:01 -08:00
dotCooCoo e5a1f339c3 JavaScript: spreading a string counts its flattened copy against the heap
Spreading a concatenated string (`[...s]`, `f(...s)`) flattened it before
any limit was checked, so a script could make the host build the whole
copy before the per-element fuel and heap accounting ran. The spread now
flattens through the same counted helper the string built-ins use, which
ends the run with the heap limit before the copy is made.
2026-11-22 00:44:02 -08:00
dotCooCoo e1e99023c2 Scripts: a failed UnitValue install leaves no constructor or operators behind
When defining the UnitValue members fails part way, the realm turns the
unit operators off again and restores the global UnitValue to what it was
before the call, so a second add_unit_values() installs everything.
2026-11-22 00:30:42 -08:00
dotCooCoo af91c28c64 Merge main into feat/scripts-unitvalue 2026-11-22 00:30:37 -08:00