Commit Graph
143 Commits
Author SHA1 Message Date
.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 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 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 644a4e6b8c Merge main into feat/scripts-export-for-screens 2026-12-03 11:15:24 -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 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 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 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 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 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 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 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 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
dotCooCoo f99ef023ad Scripts: close checks the artboards the saved file keeps; saves report warnings
Document.close(SaveOptions.SAVECHANGES) now judges artboard loss by the
file the save writes. A PDF last saved with useArtboards: false is
refused, since it holds one page of the art's bounds. A native or .ai
file saved with separateArtboards is saved and closed whatever its range
names, since the range picks only the separate files; a version 7 .ai
file keeps the range check.

Document.saveAs, Document.exportFile, app.open and the save that
close(SaveOptions.SAVECHANGES) runs write each warning of their command
to the console after the method's name (for example "saveAs: SVG keeps 1
of the document's 2 artboards ...").

Script Check reports a file write for a saveAs or exportFile call on the
script's own object when the variable is assigned in a loop around the
call, since a later iteration may run the call on a document. Loop bodies
without braces follow if, else and line breaks, and a variable of the
same name that a function declares is kept apart.

A test shows that a waiting point change counts as unsaved for
Document.saved and close().
2026-11-29 16:49:37 -08:00
dotCooCoo 2be5e244f2 Merge main into feat/scripts-export-for-screens 2026-11-29 16:27:06 -08:00
dotCooCoo 13b8b4a325 Merge main into feat/scripts-export-autocad 2026-11-29 16:23:58 -08:00
dotCooCoo 60c1eb34af Merge main into feat/scripts-print-printer 2026-11-29 14:36:49 -08:00
dotCooCoo e3077d3c1f Script check: test the computed-key case of an own saveAs in its own script
A computed key such as c[k] = w makes the check unsure for the whole
script, so since the last commit every saveAs in that script counts as a
write, the ones before the computed key included. The test put that case
in the same script as the others, so the own saveAs calls it expected to
write nothing were reported. The computed-key case now has its own
script and assertion, and the other cases keep theirs.
2026-11-29 14:18:39 -08:00
dotCooCoo b1e9a4cbb3 Merge main into feat/scripts-api-d6-save-export-open
main's Document member list held saveAs and close as members that are not
available yet; this branch's save_open members implement them, so the
merge drops them from that list and keeps main's other entries. The
script host test lists take main's members together with this branch's
open, userInteractionLevel, fullName, path, saved and option classes,
and the heap accounting keeps main's ModuleNamespace arm beside the
FsEntry string arm.
2026-11-29 14:13:21 -08:00
dotCooCoo fda48b02d0 Merge main into feat/scripts-app-select-tool 2026-11-29 10:25:17 -08:00
dotCooCoo 4929a4beb6 Merge main into feat/scripts-scriptui-palettes 2026-11-29 10:23:01 -08:00
dotCooCoo 5ec50ca863 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-11-29 09:29:37 -08:00
dotCooCoo 97952e98a0 Merge main into feat/scripts-api-d8c-rasterize-capture 2026-11-28 23:21:47 -08:00
dotCooCoo ea99ddfa63 Merge main into fix/scriptcheck-linear-steps 2026-11-28 22:20:45 -08:00
dotCooCoo 043650d794 Scripts: tighten save, open and close edge cases
- saveAs picks the encoder from the requested name, so a link to a file of
  another format writes the format the name asks for.
- fullName, path and close(SaveOptions.SAVECHANGES) resolve a relative saved
  path against the working directory.
- close(SAVECHANGES) accepts an artboard range that covers every artboard and
  keeps the document open when the save would drop artboards.
- app.open keeps the requested file name, rejects a file over 128 MiB before
  reading it, applies the requested color space to plug-in imports, and
  rejects PDF options for files that are not PDF content; null PDF options
  keep their defaults.
- Explicit null options throw; assigning the current Document.saved value
  runs no command; Document.path reflects as Folder or string.
- An implicit multi-file save names no refused path in its error.
- The script checker counts SAVECHANGES only on SaveOptions and keeps write
  warnings for receivers that evaluated code can rebind.
2026-11-28 21:21:56 -08:00
dotCooCoo 018dfc2482 Script check: keep reporting SAVECHANGES read through an alias as a file write
A script can pass SaveOptions.SAVECHANGES to a document's close through
a variable that holds SaveOptions, or through a property of an object
that holds it. The check reports any SAVECHANGES member as a file write,
whatever the receiver. A test now covers the alias and member cases, and
a key of the script's own object literal, which is not reported.
2026-11-28 21:00:39 -08:00
dotCooCoo a3ccd60b5b Script check: a script whose only finding is unsure names is scanned once
A script without includes whose declarations give names values the analysis
does not read came back from its first scan with `Known::unsure` set and no
names. `settle` counted that as something known and scanned the script again,
which found the same and doubled the scan's steps. The proptest
`any_bytes_are_checked_in_linear_work` shrank one such input to 104 bytes that
took 550 steps, over its bound of 536.

`settle` now keeps the first scan when it found no bound names and no File
objects: the flag comes from the script's own declarations, which the first
scan already read.
2026-11-28 20:55:33 -08:00