Commit Graph
20 Commits
Author SHA1 Message Date
dotCooCoo 02c4ac0f74 Scripts: a Color Picker pick converts through the script document's profiles
app.showColorPicker answers the run between slices, when the active
color settings hold the profiles of the document the window shows. A
pick in the run's own document, made or assigned other profiles by the
script, was converted to that document's RGB space and separated to CMYK
through the window's profiles instead.

The dialog now carries the RGB and CMYK profiles assigned to the run's
active document when the picker opens. On OK a display-sRGB pick (hex,
sample, HSB) is taken into that document's RGB space, RGB values typed
into the picker convert from the shown RGB profile to the document's,
and an RGB pick in a CMYK document separates through the document's
CMYK profile.
2026-12-04 18:38:31 -08:00
dotCooCoo 232b9e1597 Merge main into feat/scripts-show-color-picker 2026-12-04 01:13:39 -08:00
dotCooCoo 1a4b4be93e Merge main into feat/scripts-show-color-picker 2026-12-02 15:27:47 -08:00
dotCooCoo e1558e7e4a Merge main into feat/scripts-scriptui-palettes 2026-12-02 15:27:42 -08:00
dotCooCoo 77cc99b2bd Scripts: palette refreshes run their getters' promise jobs, and events keep their place
- A prompt, confirm or alert answer that cannot reach the script is listed
  in the report with the answer "error" instead of the answer given.
- After a named-engine run, point changes that a palette getter makes
  while the palettes are refreshed are written before the run ends.
- The promise jobs a palette getter queues during that refresh run in the
  same fuel, the host gets the controls once more after them, and their
  unhandled rejections are part of the run's report. An update() they
  call takes no waiting event.
- A waiting text change merges with a newer one only when no click or
  close of its palette waits after it.
- With nobody to ask, an open edit that cannot be finished before the run
  ends script.palette.event with that error, and the event does not wait.
- A click whose onClick getter hid the palette runs no handler, and a list
  choice whose list a text getter removed, or whose earlier item text a
  later getter changed, is refused.
- add() and remove() on a shown palette return their result when a getter
  throws while the host's copy is updated; the host gets the controls at
  the next update or when the run ends.
- In the app, a palette event whose run cannot begin shows its own error
  instead of an earlier stopped run's message.
- The overview comments, docs/mcp.md and the progress line describe the
  update() handling, the merge rule, onClose returning false and the
  named engine a palette needs.
2026-11-30 15:05:36 -08:00
dotCooCoo 8107acadf2 Scripts: a color picker answer refuses out-of-range arrays and objects
An answer given as an array or object, such as [1.00000001, 0, 0] or
{c: 100.000001, m: 0, y: 0, k: 0}, was narrowed to f32 before its range
check, so a component just past a limit rounded onto it and passed. Its
components are now checked as written, in f64 and on the scale
paint.setFill reads them in, as color keys already were. Boundary values
are still accepted.

docs/mcp.md and script.run's params text list "stop" as a colorPicker
answer, which a run stopped at the picker records.
2026-11-30 10:50:35 -08:00
dotCooCoo 7b3690163e Scripts: palette events report their own run, and dialogs keep typed texts on a failed handoff
- script.palette.event with nobody to ask answers with the report of the
  run that handled the given event, also when it took the place of an
  earlier waiting event or a run of its engine took it with update(); an
  event dropped without a run is an error, and a later event that cannot
  start leaves the given event's result. An open drag in a document other
  than the active one is refused before the event waits, and the app's
  palette start check uses the same rule.
- A palette event's handler and the refresh after a run take no waiting
  event through update(), so a later event does not run inside them. The
  refresh after a named run spends at most the unbroken-run allowance.
- A click whose button a getter removed during the event runs no handler.
- A window answer that could not reach the script lists the dialog with
  the answer "error" instead of "stop".
- In a ScriptUI dialog, Escape, ui.dialog.cancel and a click keep the typed
  texts when the run does not take the event, and a refused event asks for
  the next frame so the queued events after it go on.
- Quitting while only palettes are open asks whether to stop the run.
2026-11-30 03:31:54 -08:00
dotCooCoo 75d4c949d2 Scripts: transform scales a compound member's stroke, and the warning confirm is known by its origin
- PageItem.transform with changeLineWidths at the matrix's own scale sets
  the stroke weight of a path whose paint the compound holds, as resize
  does.
  resize and transform set that weight by the scale itself, and an explicit
  100 keeps the weights even for a scale within the tolerance of 100%.
- A changeLineWidths of 0 no longer matches a tiny scale; a positive value
  is compared with the scale relative to its size.
- translate refuses an offset past the canvas only when the call moves the
  object or a pattern it uses; a non-finite offset is still refused.
- Number conversion of preference text no longer trims U+0085, as
  JavaScript does not.
- A real preference changes between 0 and -0: values are compared by their
  bits in the setter and when the run's keys are merged.
- A clipboard.importSvg whose result cannot reach the script puts the
  clipboard back.
- Moving an object works out its index without copying the list of its
  siblings.
- The app's question before the external script warning turns off is known
  by the confirm the app opened, not by its text, so a script's confirm
  with the same text answers Yes through automation and is not translated.
- docs: only calls that move or reshape the object run
  object.transform, and transform sets a compound member's stroke.
2026-11-29 23:14:06 -08:00
dotCooCoo bdb753eef9 Scripts: a color picker answer refuses out-of-range color keys
A headless colorPicker answer written as a color key, such as
"rgb 300 0 0" or "rgb 255.000001 0 0", was clamped into range and
accepted, while the same color as an array or object was refused. The
key's components are now checked as written, in f64, before the key is
read. The near-white gray note in docs/mcp.md and colors.rs now says
which paint keeps its color when the read-back gray is assigned.
2026-11-29 21:40:40 -08:00
dotCooCoo 468affa17c Merge main into feat/scripts-show-color-picker 2026-11-29 19:57:02 -08:00
dotCooCoo 02ef75749e Merge main into feat/scripts-api-d1b-prefs-matrix-clipboard
# Conflicts:
#	crates/engine/src/cmd/scripts.rs
#	crates/engine/src/script/dom.rs
#	crates/engine/tests/it/script_host_vs_scriptcheck.rs
#	crates/ui-egui/src/tests/script_run.rs
2026-11-28 14:26:05 -08:00
dotCooCoo e4d1dabf9e Scripts: path point reads scale with subpaths; the script color picker keeps its color
- app.showColorPicker opens on the script's color even when an earlier
  picker left Only Web Colors on, and a changed RGB pick takes the model
  of the run's own active document, which may be one the script made.
- Point reads and edits look a point up in a cached layout of where each
  subpath's points start, so a loop over a path with many subpaths no
  longer counts every subpath for each point. selectedPathPoints walks the
  selected anchors of a partial selection instead of every point.
- PathPoint.selected writes the waiting point changes whenever any of
  them added or removed points of the path.
- The path creators read the new path's id from the command's own result,
  so an id above 2^53 stays exact.
- typename of a stale PathPoint or PathPoints throws as the other members
  do.
- pageItems, pathItems and documents look up a key that reads as a number
  but is not an index, such as "-1", by name first.
- artboardLayout keeps the columns the rows gave the current artboards
  when a new layout replaces the rows without its own columns.
- Docs: pathItems.add() and the shape creators follow isolation; reading
  another path's points does not write the waiting changes; a gray within
  about 1e-14 % of white reads as 100; assigning documents throws in
  strict mode; when showColorPicker keeps the given color's model.
2026-11-28 01:31:48 -08:00
dotCooCoo 58292d605a Scripts: app.showColorPicker asks for a color
app.showColorPicker(color) opens the Color Picker on an RGBColor,
CMYKColor, GrayColor or LabColor and returns the color picked for OK.
Cancel, and OK with the color unchanged, return a new object of the
color the script gave. Anything else throws a TypeError.

- In the app the run waits at the picker, which previews nothing on
  the selection. Stop and quitting end the run as at the other script
  dialogs and close the picker.
- A run with nobody to ask takes {kind: "colorPicker", value: color |
  null} from answers. The report lists the picker with the color it
  opened on and the answer.
- script.run's params text, docs/mcp.md and the Scripts line in
  docs/target-app-parity.md describe it.
2026-11-25 02:23:19 -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 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
dotCooCoo 1b13f0ad1e Scripts: app gives scripts preferences, matrices and the clipboard
`app.preferences` reads, stores and removes values by key with the
type they were set as. Keys that are not VectorCraft preferences are
kept with the preferences under `scriptPreferences`, so they last
across runs and restarts, and a failed or stopped run puts them back.
Keys, values and the store have size limits, a setter refuses a value
of the wrong type, and two windows that set different keys keep both
when the preferences file is saved.

- `ShowExternalJSXWarning` is the warning before a picked script runs.
  Setting it to true, or removing it, turns the warning on. Setting it
  to false opens a confirm with No as its default and turns the warning
  off only after Yes; a run that cannot show a dialog throws and
  changes nothing. This confirm is VectorCraft's own rule.
- `app.getIdentityMatrix`, the `get…Matrix` and `concatenate…Matrix`
  functions, `invertMatrix`, `isEqualMatrix` and `isSingularMatrix`
  work on plain `Matrix` records and never change the records passed
  in.
- `app.copy`, `app.cut` and `app.paste` run `edit.copy`, `edit.cut`
  and `edit.paste` on the active document inside the run's
  transaction.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-21 12:06:41 -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 c0adc6e9d7 Merge main into feat/script-alert-confirm-prompt 2026-11-11 01:09:54 -08:00
dotCooCoo df0373aa26 Scripts: alert, confirm and prompt open dialogs with Stop, and headless runs take their answers from script.run
alert(message[, title, errorIcon]), confirm(message[, noAsDflt, title])
and prompt(message, preset[, title]) are globals in a script run. In the
app the run waits at the call for the person's answer, spends no
instructions while it waits, and every dialog has Stop, which ends the
run and puts every document back. A run over MCP or the command line
takes its answers in order from script.run's answers, a list of
{kind, value} records; a missing, mismatched or unused answer ends the
run. The report lists each dialog with its answer in dialogs, with
dialogCount and dialogsTruncated.

The interpreter gains a host call that waits at the call for its
result, from the script's own code only; a dialog called in a callback
of a built-in, a getter or a conversion throws in the app.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-10 22:14:01 -08:00