Commit Graph
171 Commits
Author SHA1 Message Date
dotCooCoo 29187c520d Merge main into feat/print-per-job-settings 2026-12-04 18:53:20 -08:00
.CooCoo 85bd77b528 Merge pull request #9315 from dotCooCoo/feat/scripts-export-for-screens
Scripts: Document.exportForScreens writes artboards, assets or the document into a folder
2026-12-04 17:59:22 -08:00
dotCooCoo a8d0ac7caf Merge main into feat/print-per-job-settings 2026-12-04 16:44:13 -08:00
dotCooCoo 8b82ccf327 Scripts: null exportForScreens arguments throw, and a read before a closing brace is shared
- Document.exportForScreens throws a TypeError for null in place of the
  options, itemToExport or fileNamePrefix, as exportFile does for null
  options, instead of taking the defaults.
- The script checker counts a variable read just before the `}` that
  closes a function body (`function get() { return $.global['local'] }`)
  as read in that body, so a later literal's saveAs is no longer exempt.
2026-12-04 16:04:49 -08:00
dotCooCoo ddfc1c4c7a Scripts: a method replacement counts for the body that declares the variable
The script checker kept a replacement of a variable's methods
(`give(local)`, `local.saveAs = w`) for the body that had declared the
name so far in the text. A `var` statement declares the name for the
whole body, and a parameter is the function's own variable, so the
replacement could count for the wrong variable:

- A function whose own later `var local` or parameter `local` declares
  the name no longer ends the exemption of an outer `local`'s own
  `saveAs` (`function h(a, local) { return local; }`).
- A replacement now counts for the innermost body around it that
  declares the name anywhere in the body, found once every body's
  names are known.
- When a body past the nesting limit or out of room for its names is
  around the replacement, the declaring body is not known, and the
  replacement counts for a variable of that name in every body.
- The call site looks the replacement up for the body that declares
  the receiver, walking outward from the innermost body.
2026-12-04 01:36:17 -08:00
dotCooCoo cd36c78004 Scripts: a method changed through a computed key, an operator or another name ends the own-method exemption
The declarations pass recorded a function body or loop replacing a
variable's document write method only for `local.saveAs = ...` and
`local['saveAs'] = ...`. A hoisted function or a later loop pass could
still change the method through a compound or update operator
(`local.saveAs += w`, `local['saveAs']++`), or hold the object under
another name (`var y = local; y.saveAs = w`, `give(local)`), and an
earlier `local.saveAs(f)` kept its exemption.

The pass now reads these the way the main pass reads them: any compound
or update operator on a write method, `++local.saveAs`, a key in brackets
that is not one string or number literal, `delete local`, and the
variable used as a value. Each recorded replacement is kept by the body
that declares the variable, so a function's own variable of the same name
keeps its exemption.
2026-12-04 01:18:12 -08:00
dotCooCoo ba27846c2a Merge main into feat/print-per-job-settings 2026-12-04 01:02:33 -08:00
dotCooCoo 904cf66f86 Scripts: a method replaced in a loop or a later function, and a global member used as a value, end the own-method exemption
- A loop that assigns `local.saveAs` or `local['saveAs']` marks `local` as assigned in that
  loop, so a call earlier in the loop writes a file.
- A function body that replaces a variable's write method, declared anywhere in the file,
  ends the exemption for that variable's calls. A variable the innermost body declares
  itself is left alone, and a key whose escapes do not decode counts as a write method.
- `$.global.local`, `this.local` and `globalThis.local` used as a value forget the variable's
  methods as `$.global['local']` does. A variable of the same name that the function body
  declares keeps its own.
- The test with two `a.saveAs(f)` calls puts them on separate lines and checks both.
2026-12-04 00:49:56 -08:00
dotCooCoo a7176b835a Merge main into fix/doc-tests-unsafe-code 2026-12-03 11:34:34 -08:00
dotCooCoo 644a4e6b8c Merge main into feat/scripts-export-for-screens 2026-12-03 11:15:24 -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
dotCooCoo ad8f6bdd59 Scripts: a bracketed global read used as a value ends the own saveAs
`var alias = $.global['local']` or `f(this['local'])` may share the
global variable's object, so a later literal's saveAs is no longer the
script's own and its calls are reported as file writes. Adds tests for
that case and for `$.global.local.saveAs = ...` under a parameter named
`local`.
2026-12-02 21:38:50 -08:00
dotCooCoo 06d963a5f4 Scripts: wrap two long scriptcheck imports to rustfmt's width
The gate's fmt step failed on a9c8f363: the use lists in analyze.rs and
analyze/features.rs grew past rustfmt's max_width of 150 and were left on
one line. They are now wrapped as cargo fmt writes them.
2026-12-02 20:40:23 -08:00
dotCooCoo a9c8f36345 Scripts: read a bracketed global key in full before forgetting its variable
The script checker stored a bracketed global key such as $.global['name']
cut to 256 characters, so a longer key forgot a different variable and a
later own saveAs call on the real one was not reported. Keys are now
decoded in full. A key whose escape does not decode to one exact name
(\u{63}, a short \x or \u, a lone surrogate) forgets every variable's
own methods instead of one name.
2026-12-02 20:24:17 -08:00
dotCooCoo dbe8120de7 Scripts: report saveAs replaced through bracketed global members
The checker treated `$.global.local.saveAs = …` as replacing the
variable's own saveAs, but missed the bracket forms
`$.global['local'].saveAs = …`, `this['local'].saveAs = …`,
`globalThis['local']['saveAs'] = …` and `$.global.local['saveAs'] = …`,
so a script could rebind a document write method that way and its
later writes were not reported. These forms now end the variable's
own saveAs, including when a function body declares a variable of
the same name.
2026-12-02 20:04:48 -08:00
dotCooCoo 891d24f822 Scripts: report saveAs through global-object rebinds in loops and installers
A property assignment in a loop (`$.global.local = d`, `o['local'] = d`)
may give the global variable `local` another value on the next pass, so a
call of its own `saveAs` earlier in the same loop may save a document. The
check now treats such an assignment as a rebinding of the global variable
in that loop. A key with an escape may name any variable, so every call in
a loop is checked after one.

A function that assigns `$.global.local.saveAs`, `globalThis.local.saveAs`
or `this.local.saveAs` replaces the method of the global variable `local`,
also when the function declares its own `local`, so a later call of
`local.saveAs` is reported. A `global` property of another object
(`holder.global.local`) is not the global object.
2026-12-02 19:37:30 -08:00
dotCooCoo 9e3327da32 Merge main into feat/print-per-job-settings 2026-12-02 18:25:50 -08:00
dotCooCoo d8caffae61 Merge main into feat/scripts-scriptui-palettes 2026-12-02 17:15:19 -08:00
dotCooCoo 0a2d25e334 Merge main into feat/scripts-export-for-screens 2026-12-02 17:00:47 -08:00
dotCooCoo 7b433a52fe Merge main into feat/scripts-api-d8c-rasterize-capture 2026-12-02 16:27:15 -08:00
dotCooCoo d09d00fa25 Merge main into feat/scripts-export-autocad 2026-12-02 02:20:49 -08:00
dotCooCoo c6f678e4a4 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-12-02 02:20:09 -08:00
dotCooCoo 625c9949fb Merge main into feat/scripts-export-for-screens 2026-12-02 00:38:39 -08:00
dotCooCoo e26768c531 Merge main into feat/scripts-scriptui-palettes 2026-12-01 21:45:23 -08:00
dotCooCoo 6d175f9e64 Merge main into feat/print-per-job-settings 2026-12-01 20:03:49 -08:00
dotCooCoo ccf5765419 Tests: assert counts and saved names in tool, path, 3D, brush and CAD tests
Tests whose all() passed on an empty list now check the list's length or
that it is not empty:
- huge_circles_bridge_with_finite_anchors_or_are_refused (pathops bridge)
- smooth_rounds_corners (pathops ops): the four corners stay, smoothed
- a_held_rotation_turns_the_art_around_its_pin (tools ARAP): one point
  per mesh vertex
- the_eraser_drag_area_matches_the_release_when_pressure_or_a_mode_starts_during_the_drag
  (tools gesture): one released point per press
- every_effect_casts_a_shadow, inflate_cells_across_a_hole_edge_are_cut_to_the_shape,
  a_plane_has_only_a_front_and_a_hollow_solid_none and
  perspective_runs_0_to_160_degrees_with_the_eye_outside_the_object (three-d)
- a_file_two_branches_include_is_followed_from_the_shallower_one
  (scriptcheck): one row per include line
- pens_pick_colors_and_widths (cad HP-GL): four widths
- junk_pressure_brushes_draw_finite_art (brush): all 12 cases draw

Round trips that hold by construction (parse finds the id in ALL) are
replaced with one saved name that must parse and one that must not:
follow_names_parse (pathops shared edge), the shape kinds (pathops
shapes), surfaces_parse_from_their_ids (three-d), the Quick Pen actions
(tools), names_parse_and_serialize_as_names (plugins) and the brush
variation modes, which also compare the serde names with the ids.

crop_keeps_an_instance_whose_art_reaches_the_region (cad) names the
entities written instead of checking that some were.
the_saved_engine_preference_is_found (app) pins the GPU choices the
preferences offer to the three the app reads.
timing_unite_1000_circles (pathops) gets an ignore reason and checks
that Unite gives one shape.

Each changed assertion fails when the code under test is broken (an id
renamed, a list emptied, a flush or instance dropped) and passes when it
is restored.
2026-12-01 17:35:21 -08:00
dotCooCoo 7f10f7aa96 Merge main into feat/scripts-export-autocad 2026-12-01 15:10:18 -08:00
dotCooCoo 856d1a3870 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-12-01 14:59:55 -08:00
dotCooCoo 784491b1bd Merge main into feat/scripts-api-d10-print-options 2026-12-01 14:13:21 -08:00
dotCooCoo 682f27810a Merge main into feat/scripts-scriptui-palettes 2026-12-01 14:04:42 -08:00
dotCooCoo 172a6c6c99 Merge main into feat/scripts-export-for-screens 2026-12-01 13:57:07 -08:00
dotCooCoo 00cf8a148f Scripts: a global property assignment in a function ends a later literal's own saveAs
A function body that assigns `$.global.name`, `globalThis.name` or
`$.global['name']` may run after a later literal gives `name` its methods,
as `this.name` already did. The assignment now records the name as
reassigned later, so the literal's later calls keep reporting the write.
An assignment in the global code runs once and still leaves a later
literal's methods the script's own.

The shadowing test is split so the named-global case and the computed-key
case each check their own line.
2026-12-01 08:47:08 -08:00
dotCooCoo 56dd6d07e5 Script checker: open on a File held in a variable named app writes
`var app = new File(p); app.open('w');` was reported as an application
open (file.read). A receiver that holds a File now takes the File open
mode rules, so the check reports file.write and filesWritten.
2026-12-01 07:31:35 -08:00
dotCooCoo 406a612d7b Merge main into feat/scripts-export-for-screens 2026-11-30 16:01:57 -08:00
dotCooCoo 186a083fc2 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-11-30 15:27:15 -08:00
dotCooCoo 270ffca6ef Merge main into feat/scripts-export-autocad 2026-11-30 15:26:54 -08:00
dotCooCoo 1b2da536cc Merge main into feat/scripts-print-printer 2026-11-30 15:25:50 -08:00
dotCooCoo f44ecb3741 Scripts: refusals name files as the save was given them; locked folders give READ_ONLY_LOCATION
A save job now takes its path naming from whether the plan was given a
path, so a refused multi-file save without a path names its files by
their file names for every caller of `save_job`, as `document.save`
already did. Merging the save, export and open branch had left the job
naming full paths unless `save` set the field, which failed
`refused_multi_file_save_never_calls_the_writer`.

A multi-file save or export into a folder that may not be read no
longer fails with "automation path rejected: cannot resolve": a path
whose real path cannot be found is compared as written, and its write
reports READ_ONLY_LOCATION as other saves there do.

The print tests remove their folders when an assertion fails, and Check
Script has a test for printing the document `app['open']` returns.
2026-11-30 14:48:45 -08:00
dotCooCoo b3def332ff Merge main into feat/scripts-print-printer 2026-11-30 11:40:16 -08:00
dotCooCoo b6a9e8f363 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-11-30 11:34:24 -08:00
dotCooCoo 8842f0ac6f Merge main into feat/scripts-export-for-screens 2026-11-30 11:32:01 -08:00
dotCooCoo 280477d1b8 Merge main into feat/scripts-export-autocad 2026-11-30 11:26:36 -08:00
dotCooCoo 4474c1cb2f Merge feat/scripts-api-d6-save-export-open into feat/scripts-api-d10-print-options
# Conflicts:
#	crates/engine/tests/it/script_host_vs_scriptcheck.rs
2026-11-30 11:18:56 -08:00
dotCooCoo 8a5f206e3c Merge main into feat/scripts-api-d6-save-export-open 2026-11-30 10:55:42 -08:00
dotCooCoo 30188730b8 Merge main into feat/scripts-scriptui-palettes 2026-11-30 10:02:43 -08:00
dotCooCoo f4aa208239 Scripts: Check Script reads document member names given in brackets
Check Script now counts print on a document as a file write when the
document is reached with member names as string literals in brackets
(app['activeDocument'].print(o), app["documents"][0].print(o),
app.documents['getByName']('Draft').print(o)), also through a
variable, parentheses, a closed function or catch scope, and included
files. A string key on a collection stays an item lookup by name
(app.documents['Draft']) unless it names one of the collection's
documented members or an Object.prototype member. The report still
shows each chain as written.
2026-11-30 09:28:31 -08:00
dotCooCoo 374afab73b Merge feat/scripts-api-d6-save-export-open into feat/scripts-api-d10-print-options
Takes #9052's File and Folder design: a File keeps its path in
Class::FsEntry, which now also holds the native slots this branch keeps
out of a File's own properties. Hosts give File and Folder values with
file_ref and folder_ref, so the separate File ref writer is removed.

The save, export and open warnings keep the full method name as their
prefix (Document.saveAs:, Document.exportFile:, app.open:,
Document.close:). A script command's read stops at the smaller of the
script read limit and a scoped read limit, so app.open's limit no
longer skips the script read limit. PageMarksTypes is defined once.
2026-11-30 08:44:53 -08:00
dotCooCoo f4c911d4d3 Scripts: open options with an importer, null export options and close checks for files that keep every artboard
- document.open refuses page, cropTo, pages and crop when a named importer reads the file (linkPages
  still uses the built-in reader).
- exportFile with explicit null options throws a TypeError for GIF, PNG8 and TIFF too.
- close(SaveOptions.SAVECHANGES) saves a modern .ai or .ait file and an SVG file with Preserve
  Editing whatever range was remembered; a range the save refuses still refuses.
- The script checker keeps a try statement's catch and finally, and an else after a nested
  do-while, inside the loop body; a line break after a label does not start a new statement; a
  this assignment in a function that hides a global clears the global's saved methods; and
  holder.d['saveAs'] = ... no longer counts as a write to d.
- docs/mcp.md describes which files keep every artboard on close.
2026-11-30 03:36:01 -08:00
dotCooCoo 82d4ec4336 Scripts: explicit crop boxes, EPS close-with-save and writer receivers checked per call
- document.open with an explicit PDFCROPBOX crop opens on the crop box
  of a file with editing data; the default keeps the trim box and bleed.
- Closing with save changes keeps an EPS document's artboard range, since
  the EPS file holds the whole document.
- The script checker treats a writer receiver captured from an outer
  scope as able to change before each call, and finds the loop that holds
  a call with a binary search instead of a scan of every loop.
2026-11-29 19:01:56 -08:00