Commit Graph
604 Commits
Author SHA1 Message Date
dotCooCoo 49186cb426 Merge main into feat/scripts-api-layer-path-items 2026-12-04 12:28:26 -08:00
.CooCoo 534291eb8f Merge pull request #10818 from dotCooCoo/fix/script-palette-review-9147
Scripts: palette events keep drags, drafts and frames as the person left them
2026-12-04 11:42:17 -08:00
.CooCoo f92dcd346e Merge pull request #10623 from dotCooCoo/fix/js-block-function-hoist-lookup
JavaScript: block functions look up top-level function names in a set
2026-12-04 10:35:17 -08:00
dotCooCoo d5a54ccffa Merge main into feat/scripts-api-layer-path-items 2026-12-04 02:57:25 -08:00
dotCooCoo 90b6a7640b Scripts: palette events keep drags, drafts and frames as the person left them
Follow-up to the review of #9147 (script palettes):

- A waiting click or change that can no longer run (its control was
  disabled, hidden or removed by an earlier handler) is dropped before
  the open edit is settled, so it no longer commits or cancels a drag
  in the active document with no handler run.
- A palette title or other getter that hides or closes the palette
  while the palette is being described no longer sends that
  description to the host: the host keeps the controls the palette had
  when it was hidden.
- A typed text that matches the field's stored text is still given to
  the script, before a click, a close or on focus loss, when another
  change of that field waits, so the handler reads the typed text and
  not the waiting change.
- After a palette event's run fails to begin, the app does not retry
  and ask for a frame on every pass. It tries again after the next
  input in the window, another palette event, or a change to the
  documents' edit state, the active document or the recovery settings.
- The print test now checks that the click's handler ran after the
  print jobs were canceled, and the list test only fails when the
  earlier item's text changed.
2026-12-04 02:54:11 -08:00
dotCooCoo 69afdf9194 Merge main into feat/scripts-api-layer-path-items 2026-12-04 01:01:08 -08:00
dotCooCoo a7176b835a Merge main into fix/doc-tests-unsafe-code 2026-12-03 11:34:34 -08:00
dotCooCoo 8e23837867 Merge main into feat/scripts-api-layer-path-items 2026-12-03 11:15:06 -08:00
dotCooCoo 6f8f89fd62 Merge main into fix/js-block-function-hoist-lookup 2026-12-03 10:26:08 -08:00
dotCooCoo 9c11c47f75 Doc tests: unsafe code is denied in doc tests too
Rustdoc builds each doc test as its own crate, without the workspace's
`unsafe_code = "deny"` and without a library's `#![forbid(unsafe_code)]`,
so a doc test holding an `unsafe` block passed `cargo test --doc`.

- Every library root now carries `#![doc(test(attr(forbid(unsafe_code))))]`,
  or `deny` in cad, eps and metafile, which rely on the workspace lint.
- `cargo xtask layers` reports a library whose doc tests are missing the
  attribute, or use `deny` where the library forbids unsafe code.
- AGENTS.md names the rule next to the `unsafe` allowlist.
2026-12-03 09:51:28 -08:00
dotCooCoo c4a737f255 Merge main into feat/scripts-scriptui-palettes 2026-12-03 09:29:28 -08:00
.CooCoo 26aa108881 Merge pull request #10624 from dotCooCoo/fix/js-export-async-function
JavaScript: modules export async function declarations
2026-12-03 07:30:40 -08:00
.CooCoo 0727763819 Merge pull request #10620 from dotCooCoo/fix/async-function-subclass
Scripts: a class can extend AsyncFunction and GeneratorFunction
2026-12-03 07:30:16 -08:00
.CooCoo 9a1f0e92ea Merge pull request #10619 from dotCooCoo/fix/eval-default-param-annexb
JavaScript: eval in a default parameter leaves a parameter of a block function's name alone
2026-12-03 07:29:53 -08:00
dotCooCoo 4010eb5be2 Merge main into feat/scripts-api-layer-path-items 2026-12-02 18:24:31 -08:00
dotCooCoo 6826f306ae Scripts: palette tests check the post-limit refresh and the list revision
The engine test now records what the palette's getter plays only after the
handler starts, and asserts that a refresh ran after the limit with the
run's own actions. The list test turns the item's text getter back into a
plain text before it replaces the items, so only the revision check
rejects the choice.
2026-12-02 18:15:18 -08:00
dotCooCoo d8caffae61 Merge main into feat/scripts-scriptui-palettes 2026-12-02 17:15:19 -08:00
dotCooCoo 79ef692ce5 Scripts: palette events keep their checks after getters and print questions
- paletteClose with another engine's palette id no longer drops that
  palette's waiting events.
- A hidden palette is not described after a run or an add, so a
  throwing getter on it no longer fails the run; script.palettes and
  docs/mcp.md say a hidden palette lists its controls as they were.
- A check box's click rechecks the box after reading its value, so a
  getter that disables it or closes the palette stops the click.
- A list's change rechecks that the list is still enabled and visible
  after its item texts are read, and is dropped when a getter disabled
  or hid it.
- A waiting palette event does not start its run, or ask for frames,
  while the last run's print jobs wait for their answer.
- script.palette.event's help states that a change merges only after
  its palette's last waiting click or close.
2026-12-02 17:05:59 -08:00
dotCooCoo aa4cce5080 Merge main into feat/scripts-api-layer-path-items 2026-12-02 16:02:05 -08:00
dotCooCoo 98c6e5fb20 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 15:57:11 -08:00
dotCooCoo dfff55991f Merge main into feat/scripts-api-layer-path-items 2026-12-02 15:42:39 -08:00
.CooCoo 822651dc7a Merge pull request #9266 from dotCooCoo/feat/scripts-export-autocad
Scripts: exportFile writes DXF with ExportOptionsAutoCAD
2026-12-02 15:42:04 -08:00
dotCooCoo e369013463 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 15:37:51 -08:00
dotCooCoo e1558e7e4a Merge main into feat/scripts-scriptui-palettes 2026-12-02 15:27:42 -08:00
dotCooCoo 66c71eeb8d JavaScript: modules export async function declarations
`export async function f() {}` stopped with "expected a declaration after
'export'", because the module parser checked only for `var`, `function`
and lexical declarations. `export default async function` read the
function as an expression bound to the default binding, so a named one
did not bind its name in the module and was not hoisted.

Both forms now parse as async function declarations, as ECMA-262 2017
section 15.2.3 (ExportDeclaration with HoistableDeclaration) gives.
Async generators stay syntax errors here, as in a plain declaration.

The export forms were missed when #9131 added async functions.
2026-12-02 14:24:43 -08:00
dotCooCoo ae9ad685b2 JavaScript: block functions look up top-level function names in a set
Deciding whether a block function gets an Annex B variable compared its
name with every top-level function declaration, so a script with N
top-level functions and M block functions made N x M comparisons
(1,000,000 for 1,000 of each). The names are now gathered into a set
once, the first time a block function needs them, and each block
function makes one lookup. Hoisting results are unchanged.

The scan came in with #9131.
2026-12-02 14:23:08 -08:00
dotCooCoo 26c62f92f4 Scripts: a class can extend AsyncFunction and GeneratorFunction
`new` on a class that extends `AsyncFunction` or `GeneratorFunction`
threw "this built-in cannot be subclassed", because the subclass check
listed only `Function` among the function constructors. Both now take
the subclass's prototype from `new.target`, as CreateDynamicFunction
asks (ECMA-262 2017 section 19.2.1.1.1). `AsyncFunction` also parses
its source before it reads `new.target.prototype`, as `Function` and
`GeneratorFunction` already did.

The check came in with the classes support (#9094) and `AsyncFunction`
with async functions (#9131).
2026-12-02 14:20:58 -08:00
dotCooCoo 326c88a8f3 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 14:12:01 -08:00
dotCooCoo 6a3c6cc7a6 JavaScript: eval in a default parameter leaves a parameter of a block function's name alone
A block function in eval code run from a default parameter's value no
longer replaces a parameter of the same name with its variable. The
parameters are bindings between the eval code and the function's
variable environment, so the function gets no variable (Annex B.3.2.3)
and stays in its block. A name that no parameter has still gets the
variable.

The fault came with b900ea2308, which checks the environments out to
the variable environment but not the parameters' environment that a
default parameter's eval declares into.
2026-12-02 14:10:05 -08:00
dotCooCoo 1f2e9bff33 Merge main into feat/scripts-export-autocad 2026-12-02 14:02:36 -08:00
dotCooCoo 32bb7f1228 Merge main into feat/scripts-api-layer-path-items 2026-12-02 14:01:14 -08:00
dotCooCoo d583b8053f Merge main into feat/scripts-pageitem-transforms 2026-12-02 13:09:44 -08:00
.CooCoo aeddf2f03a Merge pull request #9077 from dotCooCoo/feat/scripts-api-d8b-tracing
Scripts: PlacedItem.trace and RasterItem.trace make an Image Trace object with its tracing options
2026-12-02 12:37:15 -08:00
dotCooCoo 930c02ce8f Merge main into feat/scripts-pageitem-transforms 2026-12-02 12:20:10 -08:00
dotCooCoo 46b0d0def6 Merge main into feat/scripts-scriptui-palettes 2026-12-02 12:08:01 -08:00
dotCooCoo d656458366 Merge main into feat/scripts-export-autocad 2026-12-02 11:52:58 -08:00
dotCooCoo c5682d380c Merge main into feat/scripts-api-layer-path-items 2026-12-02 11:50:37 -08:00
dotCooCoo fe3d001806 Merge main into feat/scripts-export-autocad 2026-12-02 11:48:42 -08:00
dotCooCoo cd3a0da644 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 11:39:00 -08:00
.CooCoo d0d73ff553 Merge pull request #9131 from dotCooCoo/feat/js-es2017-async-await
JavaScript: .js scripts run async functions and await
2026-12-02 11:37:17 -08:00
dotCooCoo 497e2eb4e7 Merge main into feat/scripts-api-d8b-tracing 2026-12-02 11:33:20 -08:00
.CooCoo e25243aeb4 Merge pull request #9135 from dotCooCoo/feat/js-es2015-proxy-reflect
JavaScript: ES2015 realms have Proxy and Reflect
2026-12-02 11:15:55 -08:00
dotCooCoo 2cf9f56194 Scripts: palette events keep their file access, hide and enabled checks
- update() takes a waiting palette event only when the run's file access
  roots reach the same files as the event's, so a handler never runs with
  less access than its palette was shown with.
- A palette event is no longer delivered to a handler after its palette
  was hidden and shown again, or after a capturing listener disabled or
  hid the control or a group above it.
- A limit that ends a handler update() took restores the run's own
  actions before the end-of-run refresh.
- A palette refresh that fails reports no unhandled rejection.
- A refused palette field text no longer replaces text typed after it.
- The script.run, script.palette.event and docs texts describe update()
  delivery, list staleness after item edits, and repeating a click or
  close dropped with an oversized text.
2026-12-02 10:49:08 -08:00
dotCooCoo 8aa51b123e JS: assert the qualified name's value in the E4X async test
CI's test-lint step failed on with_e4x_async_before_a_double_colon_is_a_qualified_name:
both of its assertions only checked is_ok. The test now runs x.async::b with async
bound to a Namespace and asserts that it selects the namespaced child.
2026-12-02 10:16:37 -08:00
dotCooCoo c0b4413a5a JS: fix async function review points
- AsyncFunction.prototype has Symbol.toStringTag "AsyncFunction",
  configurable only.
- await checks the room for the awaited promise's reaction or job and
  the suspended frame's bytes before it attaches the reaction, so a
  suspension stays within the heap limit.
- An async function's return pops its frame before resolving its
  promise, so a then getter on the returned value runs without it.
  Returning the function's own promise rejects it at the return.
- Block functions whose variable was not declared are kept in a hash
  set, so each block function's lookup takes constant time.
- A shorthand await in an object pattern of an async arrow function's
  head is a syntax error, and the head accepts patterns with defaults
  such as async ({a = 1}) => a. async({a = 1}) without an arrow is
  still a syntax error.
- docs: .jsx files and source strings run with module: true have
  Promise and the async syntax; await is an identifier only in script
  code.
2026-12-02 08:30:09 -08:00
dotCooCoo ff165a7ec2 JavaScript: descriptor bags keep ECMAScript key order; Symbol hooks need ES2015
Object.defineProperties, Object.create, seal and freeze read an ordinary
object's own names in ECMAScript order (array indices ascending first) in
an ES2015 run, through proxies without an ownKeys trap too; without the
option they keep the order for-in visits.

concat reads Symbol.isConcatSpreadable and with scopes read
Symbol.unscopables only in an ES2015 run, so a Symbol set by an earlier
run does not change code run without the option.

Tests: the host-function proxy refusal checks the throw and that neither
the host function nor the trap ran; the bound-constructor test sets the
custom prototype before constructing.
2026-12-02 08:10:45 -08:00
dotCooCoo 757b667f3d Scripts: for-in keeps the names a proxy listed before the chain returns to it
A getPrototypeOf trap may return the same proxy again. Its second visit
replaced the positions the first visit recorded, so a name only the first
ownKeys call returned was never visited. Each visit now adds its new
positions to the proxy's record, each pair counted once against the heap
limit, and the records are sorted and compacted once after the walk.
2026-12-02 07:39:46 -08:00
dotCooCoo 444c46c515 Scripts: for-in visits a name when a getPrototypeOf trap returns a new proxy each time
A for-in loop asks only the proxies whose ownKeys trap listed a name for
its descriptor. When a getPrototypeOf trap returned a new proxy of the
same target on each call, the proxy met before each name was not the one
that listed it, so the name was skipped. The loop now records, for each
proxy, the proxy its prototype lookup returned, and a new proxy of that
same target in its place answers for it. Proxies that list nothing are
recorded too, so another proxy of their target does not answer for them,
and the listing proxies stay rooted until the iterator holds them.

Follows #10185.
2026-12-02 07:12:47 -08:00
dotCooCoo 337b47a309 JavaScript: with scopes honor Symbol.unscopables; concat reads isConcatSpreadable
- A `with` scope reads `Symbol.unscopables` after it finds a name, through
  a proxy's `get` trap, and skips the binding when that object's property
  for the name is truthy.
- `concat` reads `Symbol.isConcatSpreadable`, through proxy traps; a
  defined value decides whether the object is spread.
- `Object.keys` and `Object.getOwnPropertyNames` keep the target's order
  through empty-handler proxies.
- `%TypedArray%.from` and `of` construct through a proxy constructor and
  check that the result is a typed array long enough.
2026-12-02 06:23:12 -08:00
dotCooCoo 080f3c4a84 JavaScript: legacy reflect find skips proxy traps; replacer lists charge kept names
- `reflect.find` reads the reflection object and its lists with ordinary
  [[GetOwnProperty]], so a proxy receiver throws a TypeError without its
  getOwnPropertyDescriptor trap running.
- `JSON.stringify` charges each distinct name a replacer array keeps for
  the length of the call, instead of reserving bytes for the whole length,
  so a long sparse replacer list no longer hits the heap limit.
- A test checks that an outer proxy reads an inner proxy target's
  descriptors in its trap's combined order of names and Symbols.
2026-12-02 06:01:07 -08:00