Commit Graph
80 Commits
Author SHA1 Message Date
dotCooCoo af09fc2064 Scripts: open files are written in the order they were opened
When two File objects held changes to the same file, copy, length, a
new open of the file and a withdrawn grant wrote them in no fixed
order, so the copy or the file could end up with the older object's
bytes. They now write them in the order the objects were opened, as
the end of the run does.
2026-11-17 07:14:42 -08:00
dotCooCoo 3c73995861 Merge main into feat/script-file-folder-write 2026-11-15 16:06:24 -08:00
dotCooCoo dc2ae3dbc2 Merge main into feat/script-file-folder-write 2026-11-14 22:56:25 -08:00
dotCooCoo 34be6ee324 Merge main into fix/the-liquify-warning-s-tool-name-and-object-kinds 2026-11-14 21:54:06 -08:00
BFlat b4bd916141 Merge pull request #7737 from dotCooCoo/feat/select-similar-button
Control bar: Select Similar Objects selects by the attribute its menu keeps
2026-11-15 12:37:57 +07:00
dotCooCoo fa53bc2940 Merge main into fix/the-liquify-warning-s-tool-name-and-object-kinds 2026-11-14 20:48:34 -08:00
dotCooCoo 24f7303c08 Merge main into feat/script-file-folder-write 2026-11-14 20:47:33 -08:00
dotCooCoo f05d481247 Control bar: Select Similar Objects selects by the attribute its menu keeps
With something selected, the Control bar shows a Select Similar Objects
button and, beside it, the Select Similar Options menu. The button
selects the objects like the first selected one by the attribute kept
for the session; a menu item selects by its attribute and keeps it,
and the kept item is checked. The items are All, Fill Color, Fill &
Stroke, Stroke Color, Stroke Weight, Opacity, Blending Mode,
Appearance, Graphic Style, Shape and Symbol Instance.

- select.similar {by?} runs the select.same command of that name, or
  for "all" matches fill and stroke colors, stroke weight, opacity and
  blending mode together. An unknown by is an error that keeps the
  selection and the kept attribute. The journal records the attribute
  used, so a recorded action repeats it, and a failed script or plug-in
  call puts the kept attribute back.
- The button and menu belong to the Object Options group and sit at
  the right end of the bar, after the X, Y, W and H fields. They take
  only the room the other controls leave, so the bar leaves them out
  before any other control.
- The Paragraph tests' control_bar_node looks for a label before a
  value, so a link's text run listed first no longer stands in for
  the link.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-14 18:41:14 -08:00
dotCooCoo 8620f0611c Scripts: a file whose write fails after it was emptied is named as written
Writing an open file's bytes empties the file first. When the write then
failed, for example on a full disk, the file had lost its old bytes but
was left out of the files the run names as written. It is now named as
soon as it has been opened for the write.
2026-11-14 15:37:25 -08:00
dotCooCoo 828817c4b2 Scripts: File › Scripts runs the text its check read, with includes from the checked folder
The menu item checked a listed script and then ran script.run by its path,
which opened the file again; a link put in place of the file or a folder on
its path in between could make it run a file the check never saw, and the
include folder was looked up from the path again as well.

script.run takes installed: true. With a path it reads the file once through
script::folder::read, runs that text, and reads #include and $.evalFile in the
Scripts folder's real path followed by the names that read found. The menu
item runs script.run {path, installed: true}.
2026-11-14 15:37:18 -08:00
dotCooCoo b173bd7b40 Scripts: a folder renamed under another case of its name moves its open files
`rename` matched open File objects by the path as given, while the objects
hold the names the file system keeps. Where case does not matter, a folder
named in another case was renamed but its open files kept the old path, so
their changes could not be written and they stayed under the old path's
rules for reading. The objects are now matched by the kept name, and a
rename whose kept name cannot be learned is refused.
2026-11-14 15:00:12 -08:00
dotCooCoo 82620a1b27 Scripts: copy and length reach files open for reading
A file opened with open('r') kept its old bytes after copy wrote over it
or length changed it, while an object open for writing took the new
bytes. Both now update every object that holds the file. An object
that holds a renamed file is found at the new path, and an object whose
file was removed is not taken for a file made later at its path.
2026-11-14 13:19:25 -08:00
dotCooCoo 1ae70095cc Scripts: the grants-file lock waits a bounded time
Taking the lock on Script Grants.lock blocked until the holder let go,
so another process that stalled while holding it stopped listing,
loading, keeping and revoking grants for good. The lock is now tried 20
times, 50 ms apart, and then fails with TimedOut: a change is not made
and a read gives no grants rather than reading without the lock.
2026-11-14 13:06:54 -08:00
dotCooCoo d435ae1a27 Scripts: an open file that is renamed is read under its new path's rules
`rename` moved the write path of open File objects but left the path they
were read from at the old name. When new code then withdrew the kept grant
for the folder, a grant the run still held for the old path let the object
go on giving the file's bytes. The read path now moves with the write path.
2026-11-14 12:42:21 -08:00
dotCooCoo cefaeefca9 Scripts: grants kept earlier in a run keep the code evaluated before a later one
Keeping a second grant with Always marked all the code the run had
evaluated as recorded, so the run's end skipped the grants kept before
it, and they kept the code list from when they were kept. The next run
that evaluated that code withdrew them. Keeping a grant now writes the
current code list into the grants the run kept before it as well.
2026-11-14 12:38:25 -08:00
dotCooCoo 76ab8efad5 Merge main into fix/singular-messages-translated 2026-11-14 02:16:53 -08:00
dotCooCoo d621a077da Merge main into feat/script-file-folder-write 2026-11-14 02:16:44 -08:00
dotCooCoo df951caea4 Docs: $.fileName names the file being run in code eval or Function compiled
The script module docs, the script.run params text and the evidence line now
say that $.fileName in code that eval or Function compiled gives the file
being run, and the params text says that the empty name applies to code
compiled from a script given as text.
2026-11-13 21:09:02 -08:00
dotCooCoo 64662b435b Scripts: a file opened under a withdrawn grant is not read
When a run evaluated code that withdrew a kept grant, a File opened under that grant still gave the bytes it held to read, readln and readch, and seek to the end showed its length. Those calls now give Script file access denied and set error, and eof is true. docs/mcp.md says so.
2026-11-13 20:34:27 -08:00
dotCooCoo efd57a4a5d i18n: unused-answers and Liquify skip messages translate for one item too
The script error for answers left in `answers` and Liquify's warning about
objects under the brush that it left as they were built their singular by
adding an empty suffix, so no catalog template could match the singular
form, and neither message had a catalog row for either count.

- Both messages are now built from complete singular and plural English
  sentences; `it was` and `they were` are part of the sentence. The
  English the commands return does not change.
- Every complete-message catalog has an `@msgplural` row for each, with
  the language's own count forms. The tool name and the list of kinds
  stay as written.
2026-11-13 20:31:22 -08:00
dotCooCoo b73c9834c8 Scripts: grants file changes take turns and use a file of their own
Two processes that changed Script Grants.json at once both wrote Script Grants.json.part, so one could overwrite the other's file or fail on it. Each write now goes to a new file named for its process and write, passing over a name an earlier write left behind, and only that file is removed when the write fails. Changes hold a lock on Script Grants.lock beside the grants file and are not made when it cannot be taken; reads take it when they can.
2026-11-13 19:08:44 -08:00
dotCooCoo 0104aaeb9d Docs: script stack frames and $.fileName name the file of the code
docs/mcp.md's line and stack row said $.stack shows at most 64 lines
and uses [global] only for the script's own code. It keeps the
innermost 64 frames after a leading line "…" when some are left out,
and [global] names any code outside a function, including code that
an included file, $.evalFile or eval runs. The row now also says how
a frame's file compares with $.fileName in each case: the same file
for code from a file, the run's name where $.fileName is empty for a
script given as source, [eval] where $.fileName is the file being run,
and [unknown] at line 0 where $.fileName is empty.

The engineName row now gives the #targetengine name, and the
script.run params text, the script module doc and the Scripts evidence
line say $.fileName is the file of the code that reads it rather than
the file being run.
2026-11-13 18:36:47 -08:00
dotCooCoo 9811cafc25 Scripts: copy reads its source under the rules for reading
copy read the source's real path as it was when looked up, so a file replaced by a link before the read could copy a file from outside the script's places, and a link given as the source that was pointed elsewhere copied the old target. copy now reads the path as given through the same checks open uses and refuses the copy with Script file access denied when the path no longer leads to the file it was looked up as.
2026-11-13 15:39:59 -08:00
dotCooCoo fb12ddb759 Scripts: a renamed file's old path is named in the report's written
rename named only the new path in written, so a run that renamed a file an earlier run wrote did not name the path it emptied. It now names both, as remove names the path it deletes.
2026-11-13 15:06:11 -08:00
dotCooCoo 6644dc4686 Merge main into feat/script-file-folder-write 2026-11-13 11:00:25 -08:00
dotCooCoo dbfffc8ecb Scripts: commands read through the gate in runs the person starts, and the grants file is not written over when it cannot be read
- A command a script runs reads only where the script may, also in a run the person started; only
  reads of the app's own folders inside the command are exempt.
- Always and script.grants.revoke leave a grants file they cannot read as it is, and fail.
- script.grants names a path outside the automation read roots by its file name alone.
- copy reads the source once, within the 8 MiB limit, writes those bytes, and gives the copy the
  source's permissions.
- write joins its values as UTF-16 before making them text, so a surrogate pair split between two
  values is one character.
2026-11-13 10:09:27 -08:00
BFlat c7adea5518 Merge pull request #7144 from dotCooCoo/fix/script-line-numbers
Scripts: $.line and $.stack give the line of the file the code is in
2026-11-14 00:51:19 +07:00
BFlat 10c84a909e Merge pull request #7173 from dotCooCoo/fix/assigned-profile-follows-front-document
Color: assigned profiles follow the document in front
2026-11-13 23:45:03 +07:00
dotCooCoo 13514841c1 Merge main into feat/script-file-folder-write 2026-11-13 08:15:22 -08:00
dotCooCoo c764652469 Merge main into fix/script-line-numbers 2026-11-13 08:14:59 -08:00
dotCooCoo eb1f29f94b Scripts: a script in the settings folder reads only its own file there
A script run from a file directly in the settings folder could read every
file in that folder, Script Grants.json included, because its own folder
was left open inside the fence. Only folders below the settings folder
stay open now, and a script in the settings folder itself reads only its
own file there.
2026-11-13 07:56:02 -08:00
dotCooCoo 5741c7bba0 Color: assigned profiles follow the document in front
The profiles Edit > Assign Profile gives a document stayed the active
color settings after another document came to the front, so a new,
opened or switched-to document drew and converted its colors through the
previous document's profile, and closing the last document left it in
use.

The session now puts the front document's profiles in use (the working
spaces where it has none, or no document is open) after a new or opened
document, a tab switch, a close, File > Revert, every command including
each batch step and Undo or Redo of Assign Profile, a failed batch or
plug-in call, a script's rollback and slice boundaries, a canceled
preview, undo group or undo scope, and for each document Export All Open
and the update of placed documents work in. The active settings are
rebuilt, and the documents redrawn, only when they change.
2026-11-13 07:44:19 -08:00
dotCooCoo 4091f110b1 Scripts: $.line and $.stack give the line of the file the code is in
$.line and $.stack counted lines in the run's expanded source. In code
that comes after an #include they gave lines that match no file, and
this included code in a file $.evalFile ran and code a named engine
kept from an earlier run.

Both now map each frame through the run's source maps, as uncaught
errors already were. $.stack writes each frame as name@file:line,
outermost first, with the run's name as the file of a script given as
source. Code that eval or Function compiled keeps the line of the
source they compiled, in [eval]; code whose place a named engine no
longer keeps is at line 0 of [unknown]. The 64-frame limit, [global]
and [anonymous] are unchanged.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-13 06:19:54 -08:00
dotCooCoo 75c74557bb Scripts: $.fileName names the file of the code that reads it
$.fileName gave the file being run, so a function defined in a file
that #include inserted, in a file $.evalFile ran, or in an earlier run
of a named engine reported the calling file instead of its own.

- vectorcraft_js: HostItem::SiteGetter gives a getter the CallSite
  (source tag, line, column) of the code that reads it.
- $.fileName maps that place through the run's source maps, or the
  maps a named engine kept, to the file the code is in. It is empty in
  code from a script given as source and in kept code whose map was
  dropped. Code that eval or Function compiled still gets the file
  being run.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-13 06:19:23 -08:00
dotCooCoo 4716646c6b Scripts: File and Folder objects write files inside a script's scope, with per-script grants and pickers
A script's File and Folder objects now open files for writing, appending
and editing, and copy, rename, remove and create files and folders. A
script reads and writes its run's temporary folder (Folder.temp) and its
own data folder (Folder.userData), kept between runs for a script run
from a file and inside Folder.temp for a script given as text. It reads
its own folder, and reaches other places only through File.openDialog,
File.saveDialog, Folder.selectDialog and the objects' openDlg, saveDlg and
selectDlg.

- A file dialog asks first. The person picks the file or folder with
  Choose..., then allows it once or, for a script run from a file, always.
  A kept grant is bound to the script's path, the SHA-256 of its text and
  every source the run evaluated. It is withdrawn when a later run of the
  script evaluates other code, including code an earlier run left in the
  same named engine. It stays on the real path that was granted, so a
  link put in that place later does not carry it elsewhere.
- A dialog's filter is a string of file types or a function that is
  called with each file picked; multiSelect gives an array of the files
  picked, at most 2,048, and the dialog says when more were left out.
- A folder's selectDlg opens the host's folder dialog in that folder,
  also where the host shows file dialogs in line. Enter in the file
  dialog denies, unless it goes to the focused Choose... button.
  script.grants.revoke is refused with the busy error while a script
  runs, as the run keeps the grants it started with.
- The paths a file dialog allows come only from the host's file dialog:
  ui.dialog.set cannot set them. Only the person at the keyboard allows
  access; Allow Once and Always Allow sent by automation are refused. The
  dialog describes the access the run asked for, whatever its fields say.
- No grant reaches the settings folder, also when the script's own folder
  holds it.
- A file left open is not written through a link put in place of its
  folder since it was opened, and Folder.userData is null when the data
  folder or the script's folder in it is a link.
- copy onto another link to the same file (a hard link) leaves the file's
  bytes as they are, after the source's open objects have written what
  they hold. Files are compared by identity (device and inode on Unix,
  volume and file index on Windows).
- Folder.temp and Folder.userData check each folder they make against the
  automation write roots first, and Folder.create() makes nothing when a
  missing folder above the target is outside the places the script may
  write.
- An open file holds at most 8 MiB, a run writes at most 32 MiB and keeps
  at most 256 files open, and the files a run left open are written in
  the order they were opened. Setting length and copying a file count the
  bytes every open object of that file takes, and write checks the joined
  text against the limit while joining it. The report names at most 4,096
  written files and sets writtenMore when there were more.
- Errors a script sees are translated in every complete message catalog.
2026-11-13 05:42:56 -08:00
dotCooCoo a14236eca8 i18n: script errors and failed-run lines are translated in every complete-message catalog
The status bar shows a failed script run as one line: the script's
name, the line and column (and the included file), the error and the
kind of failure, with any files the run left written. No catalog had a
row for that line, so the whole line stayed in English. The errors of
File, Folder, vc.run, $.evalFile, a script's $ object, its alert,
confirm and prompt dialogs, vc.document, vc.log, the limits a run can
pass and Drop Script Engine had no row in any complete catalog either,
and several were not listed by the untranslated-strings report.

- Every complete-message catalog has rows for these errors and for the
  failed-run line at each place and for each kind (syntax, thrown,
  limit, stopped, internal). The script's name, paths, numbers, code
  names ($.flags, File, answers, true, null, UTF-8), command ids and
  the text a script throws itself are kept.
- A failure with no line and column, such as an error in code eval
  compiled, is shown with one colon after the script's name
  ("t.js: TypeError: no (thrown)" instead of "t.js:: TypeError: no
  (thrown)").
- A placeholder that occurs twice in a message template matches only
  the same text both times. Before, "{name}: the next answer in
  `answers` is for {_1}, not {name}" matched a whole failed-run line
  and dropped its line, column and kind.
- The message scan reads the script host's fail(, value( and .over(
  helpers and the script interpreter's errors (the js crate), skips
  *_tests.rs files and cfg(all(test, ...)) modules, and reads a
  constant's text from the file or crate that declares it, so the
  Scripts menu's headers are no longer listed as messages.

Tests: i18n::tests::script_errors_are_translated,
script_host_errors_are_translated,
a_repeated_placeholder_matches_the_same_text,
message_scan_reads_constants_of_the_file_and_its_crate,
message_scan_reads_script_interpreter_errors,
message_scan_skips_test_modules_with_any_test_cfg,
tests::script_run::an_error_without_a_place_names_the_script_and_kind.
2026-11-12 16:13:33 -08:00
dotCooCoo 5a7d445807 Merge main into fix/script-failed-run-keeps-no-place 2026-11-12 08:55:15 -08:00
dotCooCoo 2212739c54 MCP: plug-in, recovery and script report replies leave out paths outside the read roots
A client confined by --automation-read-root saw paths outside its read
roots that the person or an earlier request had put in the session:

- plugin.list: the plug-in folder last loaded and its failed files;
  plugin.list and plugin.info: a plug-in's source file; plugin.list,
  plugin.safeMode and plugin.setEnabled: the file of a plug-in turned
  off for the next launch.
- file.recovery.list and file.recovery.restore: a document's original
  file; file.recovery.list and file.recovery.save: the recovery folder.
- ui.inspect's scriptReport: the files a run wrote and the included
  file a failed run stopped in.

A folder outside the read roots is now null, and a file outside them is
named by its file name. plugin.setEnabled {file} takes that name. The
restored documents keep their files, and unconfined clients and the
app's own UI see the same replies as before.
2026-11-12 06:03:01 -08:00
dotCooCoo c9c5d83771 Scripts: a named engine keeps no source map for a run whose script does not compile
A run whose script fails to compile defines no code, so its source map
is not kept and the places of earlier runs stay within the engine's
budget. docs/mcp.md and the progress line say so, and the progress line
names the errors that are reported without a line and column.
2026-11-12 05:18:07 -08:00
dotCooCoo 044c8047f6 Scripts: an error in code an earlier #targetengine run compiled names that run's file and line
A function an earlier run of a named engine defined was reported without
a line, column or file when it threw in a later run. The realm now gives
each source a tag that stays the same from run to run (Realm::error_tag,
Realm::script_tag), and no two sources share one once the tags run out.
Each named engine keeps the source maps of its runs' scripts, included
files and $.evalFile files, within 8 MiB, dropping the oldest first, and
an error in kept code is reported at that file, line and column. The
report's name and the console line keep the calling run's name. For an
earlier script given as source, file is that run's name.

Docs: docs/mcp.md (Script engines), script.run params text,
docs/target-app-parity.md.
2026-11-12 00:39:41 -08:00
dotCooCoo 2f7c3854c7 Merge main into fix/script-sleep-reads-doc-cancel
# Conflicts:
#	docs/target-app-parity.md
2026-11-11 21:01:53 -08:00
dotCooCoo 8bd437687a Scripts: a canceled request stops a sleeping or waiting run at its next slice
script_pump read vectorcraft_doc::cancel only after the guard that keeps
a run waiting, so a run asleep in $.sleep went on waiting until its wake
time (up to 1,000 ms), and a run waiting at a dialog or for approval to
grow waited until someone answered. The check now runs before that
guard, after the dialog-failure check, so a canceled request ends the
run at the next slice and every document goes back.
2026-11-11 20:01:25 -08:00
dotCooCoo 19ed0889b1 Merge main into fix/script-files-followups
# Conflicts:
#	crates/engine/src/script/files.rs
2026-11-11 18:48:18 -08:00
dotCooCoo 5bd1bbf536 Scripts: File and Folder exists checks the kind, encode keeps slashes, every call is counted
- `File.encode` and `Folder.encode` leave `/` unescaped, as the File
  object reference lists it among the characters kept
  (https://extendscript.docsforadobe.dev/file-system-access/file-object/).
- `exists` is true for a `File` only when the path names something
  other than a folder, and for a `Folder` only when it names a folder.
- Fields of the records the app returns are read as own properties, so
  a property a script puts on `Object.prototype` does not turn a
  successful `open` into a failure.
- `File.encode`, `File.decode`, `File.isEncodingAvailable` and the
  `Folder` locations count as file calls and charge the host-call limit.
- On the web the locations are `null` and `File.tempName` names a file
  at the root, without asking the platform for a temporary folder.
2026-11-11 14:46:43 -08:00
dotCooCoo 7fbac74885 Merge main into feat/script-target-engine 2026-11-11 12:09:30 -08:00
dotCooCoo f1c17603bb Scripts: #targetengine runs a script in a named engine that keeps its globals
A script whose first lines name an engine with `#targetengine name` (or
`//@targetengine name`) runs in that engine, and a later script that names
it sees the globals and functions earlier runs left, until the engine is
dropped or the session ends. A script without the line, and
`#targetengine main`, still get a new engine for each run.

- A session keeps at most 8 named engines, each with a 64 MiB heap. A run
  that goes past the heap ends with the heap limit, and the engine stays
  usable. Names are 1 to 64 bytes. The line comes once, in the script
  itself, before its code and its #include lines.
- An uncaught error, a limit or script.stop puts the documents back and
  keeps the globals the run set. An internal error drops the engine. A run
  stopped at a dialog or left paused ends where it was before the engine
  is kept. An error in a function an earlier run defined is reported
  without a line and column.
- `vc`, `$`, `alert`, `confirm` and `prompt` are made once for each engine
  and act for the run that calls them, including copies an earlier run kept
  in a global. `vc.args` gives a read-only copy of the calling run's
  `args`, and what a run sets on `$` lasts for that run only.
- `script.engines` lists the named engines with their heap, and
  `script.engine.drop {name}` drops one. Scripts cannot run either.
- The engines stay on the thread that made them. A session used on
  another thread starts there with no named engines, and the old ones are
  dropped on their own thread.
- The web build has no named engines: a run that names one other than
  `main` ends with an error before any of it runs.
- `Realm::end` ends a run where it is, `Realm::error_source` counts from
  the realm's last script, and `HostItem::FrozenGetter` gives a frozen
  value each time it is read.
- The script checker lists `#targetengine` as a supported directive.

Docs: docs/mcp.md, docs/target-app-parity.md, docs/gaps.md.
2026-11-11 11:17:42 -08:00
dotCooCoo ba05554c64 Merge main into feat/script-file-folder 2026-11-11 07:47:42 -08:00
dotCooCoo b7a6196994 Scripts: File and Folder read files in the script's own folder
Scripts get the File and Folder classes as built-ins of the script
engine. A script run from a file can test whether files exist, read
their properties, list folders with getFiles (a mask or a function),
and open files to read them with read, readln, readch, seek and tell.

- Reads stay inside the script's folder and, when automation read
  roots are set, inside them too. A script given as text reads no
  files. Network and device paths, and paths outside the folder by
  their names, are refused before anything is looked up. Links and
  junctions that lead out are refused, and getFiles leaves them out.
- The encoding comes from the byte order mark, then the encoding the
  script set, then UTF-8 when the bytes are valid, then CP1252.
- Limits: 8 MiB a file, 32 MiB a run, 256 files open at once, 2,048
  getFiles entries and 65,536 names looked at, and paths of at most
  32,767 characters.
- Writing, the file dialogs and execute are not available yet: they
  return false or null and set error.

The report's hostCallCounts gains fileCalls and fileExecutes.
Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-11 07:46:33 -08:00
dotCooCoo 48e342f03b Merge main into feat/script-dollar-object 2026-11-11 05:55:39 -08:00
dotCooCoo f77fe0423f Merge main into fix/script-console-report-text 2026-11-11 04:58:29 -08:00