Commit Graph
580 Commits
Author SHA1 Message Date
dotCooCoo a7176b835a Merge main into fix/doc-tests-unsafe-code 2026-12-03 11:34:34 -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 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 98c6e5fb20 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 15:57:11 -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 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 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 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
dotCooCoo f2d79f2460 Merge main into feat/js-es2015-proxy-reflect 2026-12-02 05:57:22 -08:00
dotCooCoo c2a2f38a4e Merge main into feat/js-es2017-async-await 2026-12-02 05:32:01 -08:00
dotCooCoo e61533b320 Merge main into feat/scripts-pageitem-transforms 2026-12-02 05:28:03 -08:00
dotCooCoo cbf870502a Scripts: palette state checks use the no-script property lookup
Main changed `Interp::find_property` to take `&mut self`, since it now
runs the traps of a proxy on the prototype chain. `plain_state` called it
through `&Interp`, so the merge of main did not compile (E0596 at
crates/js/src/scriptui.rs:2010). It now calls `find_ordinary_property`,
which keeps reading `enabled` and `visible` without running any script.
2026-12-02 05:26:28 -08:00
dotCooCoo ddeb70f2c2 Merge main into feat/scripts-scriptui-palettes 2026-12-02 05:12:36 -08:00
dotCooCoo 2fa0dccc39 Merge main into feat/scripts-scriptui-palettes 2026-12-02 02:48:47 -08:00
.CooCoo 2498ef4682 Merge pull request #10185 from dotCooCoo/feat/js-object-set-prototype-of
Scripts: ES2015 realms have Object.setPrototypeOf
2026-12-02 02:36:46 -08:00
dotCooCoo d09d00fa25 Merge main into feat/scripts-export-autocad 2026-12-02 02:20:49 -08:00
dotCooCoo 666f7e3db2 Scripts: a palette click is dropped when a later getter disables its button
A getter read after a button while the palette was described could
disable or hide the button, or a group above it, after the description
recorded it as enabled, and the click still ran its handler.

- Palette states are read without running a getter, once every
  description getter (the default and cancel elements included) has
  run, and a state that a getter gives counts as off. Dialogs keep
  reading the states through their getters.
- Delivering a palette event reads the states of the control and the
  groups above it again the same way, and checks that the palette still
  holds the control, before the handler runs.
- docs/mcp.md, the progress line and script.palette.event's params text
  describe the rule.
2026-12-02 01:54:08 -08:00
dotCooCoo 622459dd4b JavaScript: roll back every object of a family after a failed class install
main's failed-install roll back (#10544) read one object for each family
and handle, while this branch keeps one for each branch of the family.
The install now records the class and prototype of each of those objects
and the roll back puts each one back, so the merged tree builds again.
2026-12-02 01:42:49 -08:00
dotCooCoo 4bcdc5d77c Merge main into feat/scripts-api-d8b-tracing 2026-12-02 01:26:36 -08:00
dotCooCoo 91f76bc40a JavaScript: Symbol reads through a proxy call its get trap, and ownKeys traps may return Symbol keys
A read of a Symbol key on a proxy, or on an object with a proxy on its
prototype chain, now calls the proxy's get trap with the Symbol and the
receiver (ECMA-262 9.5.8) and checks the result against the target's
non-configurable Symbol properties.

An ownKeys trap may now return Symbol keys (9.5.11). A Symbol given
twice, a non-configurable Symbol key of the target left out, and for a
non-extensible target any Symbol key left out or added throw a
TypeError. The target's descriptors are read in its key order with one
isExtensible call. Reflect.ownKeys, Object.getOwnPropertySymbols and the
Object functions that list keys take a proxy's keys from one trap call
and keep the order the trap gave, Symbols included.
2026-12-02 01:09:46 -08:00
dotCooCoo 7e3feff631 Tests: drop a String-to-String conversion in the sealed-global proxy test
Clippy's useless_conversion lint stopped the gate at
crates/js/src/proxy_tests.rs:127, where `names.clone().into()` converted
a String to itself. The assertion compares the same value.
2026-12-02 00:32:34 -08:00
dotCooCoo 0a66352e8c JavaScript: a failed host class install adds none of its classes
Realm::define_host_classes registered each class, and defined its global
constructor, before it checked the next one. A batch whose second class
named an unknown parent or a member twice failed with the first class
already installed, so a retry failed with "defined twice". A failed
instance did the same, and could leave an object scripts held with a
class the realm no longer had.

Every class's name, parent and members are now checked before any class
is added, so a child must still follow its parent in the batch. A
failure after that point removes the classes added, puts back each
global the call replaced and the class of each object an instance moved
to a new class. The replaced globals stay rooted until the call ends, so
a collection during the call does not free them.
2026-12-01 23:19:55 -08:00