Commit Graph
12 Commits
Author SHA1 Message Date
dotCooCoo 1d3e835927 Scripts: ScriptUI review fixes for heap-limit adds and removes, listeners, list texts, Enter, the run's questions and automation requests
- Adding a control or an item, and removing items, builds both arrays
  before the first write, so a run that ends at the heap limit leaves the
  lists and the dialog's counts as they were.
- A listener registered after an event started does not hear it in a later
  phase, a capturing container's re-registration included.
- show() reads the dialog again when a getter changes a list item's text
  after the item was read.
- Enter and Escape skip an OK or Cancel button inside a hidden or disabled
  container.
- A resource string of a name and a type without braces throws a
  SyntaxError, and a \u escape pair of surrogates reads as one character.
- In the app, queued events wait while another dialog is open over the
  script's dialog, and the run's own questions wait while a popup, such as
  an open drop-down list, is over it. ui.dialog.confirm and
  ui.dialog.cancel take only the dialog, ui.dialog.set needs a field or an
  action and answers with the dialog it set, and OK is refused while a
  dialog open over it waits. A cancel after typed text clicks the cancel
  button the dialog has when its turn comes, and an immediate cancel the
  run refuses is an error.
- A click on a list box row gives the list the keyboard focus.
- The vc hint test names BridgeTalk, since Window now exists; the params
  text and docs/mcp.md say that a show() in a handler notify runs throws
  only in the app, and define_script_ui says when end is not called.
2026-11-28 02:43:06 -08:00
dotCooCoo 5654c06c6d Scripts: ScriptUI review fixes for resource strings, list choices, listeners and the dialog's cancel and close
A resource string's characters size edit fields and static text, a list's items must be an array, a listener added again runs in a later dispatch only, a close asked for while the dialog is described closes it, a list selection a getter changes is read again, and Escape during a handler cancels the dialog the run waits at next. The thrown error of a failed host call stays kept while the failure callback runs.
2026-11-26 00:18:53 -08:00
dotCooCoo 48357310ad Merge feat/scripts-scriptui-dialogs into feat/scripts-scriptui-resources 2026-11-25 20:43:55 -08:00
dotCooCoo 9dc197b4e4 Scripts: ScriptUI dialogs refuse look-alike containers, noecho fields and stale descriptions
- An answer step with an empty control matches only an unnamed control whose
  text is empty, not the first unnamed control.
- add() and add("item") on an object made to look like a container or list
  throw a TypeError and charge nothing to the dialog's limits.
- A new list's initial items are read through ordinary property access, so an
  index getter gives its value.
- findElement() keeps the controls it has still to look at rooted while a
  name getter runs, and skips a control the element no longer holds.
- A close() that onClose calls before it returns false belongs to the close it
  refuses; the dialog waits for the next event.
- show() throws for an edittext with noecho before the dialog opens.
- show() reads the dialog again when a getter adds or removes a control after
  the controls were read, and throws when it changes again.
- An edit field takes at most 32,768 characters while it is typed.
2026-11-25 14:41:28 -08:00
dotCooCoo a28882a78c Scripts: a hidden ScriptUI control takes no room, and a confirmed event waits behind queued ones
A control whose visible is false, and everything in it, no longer adds to
its container's size or pushes the next control along. An event sent with
ui.dialog.confirm while the dialog still holds events the script has not
taken goes after them, so handlers run in the order the events were given.
2026-11-24 23:37:24 -08:00
dotCooCoo aa8c9b8d36 Scripts: ScriptUI builds windows and controls from resource strings
new Window() and add() threw that resource specifications were not
available yet. They now read a resource specification in place of the
type, as
https://extendscript.docsforadobe.dev/user-interface-tools/resource-specifications/
describes it: a type, then braces holding `name: value` properties,
where `name: Class { ... }` defines a control.

- `crates/js/src/scriptui_resource.rs` reads `[name:] Type { ... }`.
  A value is null, true, false, a quoted string, a number, an inline
  array or an inline object. The commas between properties may be left
  out, as in the page's own example. A malformed specification throws a
  SyntaxError. One longer than 1 MiB or nested more than 64 deep throws
  a RangeError; these limits are VectorCraft's own.
- With a resource specification, new Window() and add() read no other
  argument. `properties` gives the creation properties. Each control in
  the braces is added through add(), with its limits of 512 controls
  nested 16 deep, and set as the container's property of its name. A
  list's `items` gives its item texts, as add()'s third argument does.
  Each other value is assigned to the property of its name. Palettes and
  windows still throw that they are not available yet.
- The script.run params text, docs/mcp.md and the Scripts line in
  docs/target-app-parity.md describe resource specifications.
2026-11-24 17:29:22 -08:00
dotCooCoo 46478976ce Scripts: a window answer names a control by its text only when the control has no name
A headless window step whose control matched no name fell back to the
first control with that text, even when that control had a name of its
own, so a step could reach a different control than the one it named.
The text now matches only controls without a name.
2026-11-24 17:20:38 -08:00
dotCooCoo e323636ac8 Scripts: the report lists a ScriptUI dialog before the dialogs its handlers open
A ScriptUI dialog's record was added when its show() ended, so an alert,
confirm or prompt a handler opened came first in the report's dialogs.
The record now keeps the place the dialog took when it opened. When the
dialogs its handlers opened leave no room for it, the last of them are
dropped until it fits, and the list stops before it when it does not fit
alone, so the list keeps the first dialogs in the order they opened.
2026-11-24 13:24:00 -08:00
dotCooCoo 3089ed73a5 Scripts: ScriptUI listeners are limited and removed controls leave their dialog
- A control with alignment fill stays within its maximumSize when its
  container's room is larger.
- A window or control takes at most 256 event listeners (VectorCraft's
  own limit); one more throws a RangeError. A show listener can be
  added only to the dialog, and on a control it throws an Error.
- A capturing listener on a container that stops a click keeps the
  default or cancel button from closing the dialog. Listeners on the
  containers that do not capture still leave the button to close it.
- stopPropagation() acts only on an event whose listeners are running,
  and preventDefault() does nothing, since the events are not
  cancelable.
- A control removed from its container has no parent, its events no
  longer reach the containers it was in, and add and remove on it, or
  on a control it holds, throw an Error. Its controls are no longer
  counted toward the dialog's limits.
- remove(text) throws an Error, and removes nothing, when a text getter
  changes the list or container while it looks for a match.
- A group takes its creation properties fourth again when the third
  argument is not an object, as in add("group", undefined, undefined,
  {name: "g"}).
- A click on a radio button now turns off only the radio buttons of its
  set, the ones added next to it with no other kind of control between
  them. It used to turn off every radio button in its container.

Docs: docs/mcp.md now says that notify runs the handlers without closing
the dialog.
2026-11-23 12:25:38 -08:00
dotCooCoo 29153af625 Scripts: ScriptUI controls take size objects, event listeners, list find and remove, and Window.alert
- Every element starts with preferredSize, size, minimumSize and
  maximumSize objects whose width and height are -1, so a script can
  set one side, as in preferredSize.width = 100. A positive side of
  size takes the place of preferredSize's, and the layout keeps a
  control within its minimum and maximum.
- Controls and the dialog take addEventListener and
  removeEventListener for click, change, changing and show. Handlers
  run in the capture phase on the containers, on the control after its
  onClick, onChange or onChanging, then on the containers again until
  one calls stopPropagation(). A button with a click listener no longer
  closes the dialog by itself.
- Window.alert, Window.confirm and Window.prompt open the same dialogs
  as alert, confirm and prompt.
- A list has find(text) and remove(what), and takes its items in
  properties.items; a container has remove(what).
- A group takes its creation properties as the third argument of add(),
  and orientation, alignChildren, spacing, margins and alignment given
  there are its first values.
- Setting a radio button's value to true turns off the radio buttons
  added next to it in its container, and notify("onClick") turns a
  radio button on and a check box over before onClick runs.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-23 11:35:40 -08:00
dotCooCoo 3745b14db4 Scripts: ScriptUI dialogs keep to their limits and steps under reentrant handlers
- A show() that a handler's error ended with steps left in `answers` now
  ends the run and rolls it back, even when the script catches the error.
- A list step's value written as a whole float (1.0) is an item index,
  in `answers` and in ui.dialog.confirm; a fraction is still refused.
- A progress bar's fraction stays finite across the widest range.
- add() checks the control and item counts again after the getters and
  conversions it runs, refuses an initial item array longer than the
  items left before reading it, and counts a new list's items only once
  the list is added.
- show() keeps the values a getter gives while their properties are
  read, and reads the dialog again when a getter changes a list after
  it was read; a list that changes again throws an Error.
- A click or close from ui.dialog.confirm gives the text still typed in
  the dialog's fields first.
- Quitting while a handler runs keeps the dialog and its queued events,
  so Cancel shows it again with them.
- Screen readers call an edit field without a name by the visible static
  text just before it in its container.
- The dialog's heading follows a title a handler changed while the
  dialog is open.
- A list box gives screen readers a list box node named by its name or
  the static text before it, with the selected item as its value, and a
  drop-down list is named the same way.
- The dialog closes when show() returns, also when the script goes on
  running.
- Enter clicks the default button while the keyboard focus is on a
  control other than an edit field, such as a slider.
2026-11-22 04:00:21 -08:00
dotCooCoo c3ea4e2f9c Scripts: build and show ScriptUI dialogs with new Window("dialog")
A script can now build a modal dialog with new Window("dialog", title)
and add() groups, panels, static text, edit fields, buttons, check
boxes, radio buttons, drop-down lists, list boxes, sliders and progress
bars. The engine checks the description and lays it out without
recursion, within VectorCraft's own limits (512 controls 16 deep, 1024
list items, 16 KiB a text, sizes clamped to 8192 px). Other control
types, palettes and resource strings throw that they are not available
yet.

- show() waits like alert, runs onClick, onChanging, onChange, onShow
  and onClose in the run's fuel, and returns close(result)'s result, 1
  for the default button or 2 for the cancel button, or 0 for the close
  box. A show() inside a handler throws.
- In the app the dialog draws the controls where the engine placed
  them, gives text still typed in a field before a click or a close,
  and keeps its state while a handler runs. Enter clicks the default
  button, Escape the cancel button, and Stop ends the run and puts the
  documents back.
- A run over MCP or the command line takes a window answer: the steps
  of one show(), each a click, a change or a close.
- The report lists each dialog with its controls, events and result;
  vc.api.has("scriptui") is true.

Docs: docs/mcp.md (script.run), docs/target-app-parity.md.
2026-11-22 00:14:17 -08:00