[Feature Request] Scripting improvements for dialogs, long-running tasks, and more

After working with the scripting functions for a bit I’ve come across a few major limitations. With the changes below, much more would be possible:

  1. Non-blocking versions of async dialogs
    – This would be different from the existing async dialogs, in that the user would still be able to interact with the editor while the dialog is open

  2. Collect input from dialogs without closing them
    – For example, rather than only “YesNoCancel” and “OkCancel” button combinations, allow the developer to declare each button’s text as well as whether or not the button should close the dialog so that functions could be repeated without having to re-open the dialog

  3. Allow the Custom Dialog definition to declare a widget to be focused upon open, so the cursor will begin in a specific text box
    – A simpler solution would be to immediately focus the first widget in a dialog so that users don’t need to press tab twice to get to the form

  4. Support for long-running scripts
    – Currently scripts are intended to be run once and execute to completion, however the only way we can currently build long-running scripts is with awkward chains of SV.setTimeout.

  5. Event hooks
    – Currently the only way to detect a change in the editor is by constantly polling for a certain condition. Adding event hooks would be a welcome addition in tandem with support for long-running scripts.

  6. A function for Note objects that puts them in “lyric editing” or “phoneme editing” mode as if the user had double-clicked on the note or phoneme
    – Or just a regular keybind to do this, either works

  7. The ability to get the current grid snap setting
    – This is used by CoordinateSystem.snap but is not exposed for other purposes, and would be helpful for scaling a scripted task based on the user’s current grid snapping

  8. Get dictionary mapping for a lyric
    – Ideally we could specify default or currently selected dictionary mapping, and easily check the mapping for a single or array of strings
    – This is sort of possible with SV.getPhonemesForGroup, but it’s clunky

  9. Allow changing the currently active track
    – We can access and modify tracks that are not currently active, but there is no way to show those changes to the user

  10. Project-level variables
    – There is currently no easy way to pass variables between scripts, or store them for future use. Implementing the equivalent to a browser’s localStorage.setItem and localStorage.getItem as functions of the Project (and persisted as part of the SVP) would help streamline things greatly

  11. Load common library files
    – There is no way to load additional js libraries (for example with require), even ones that are present in the local folder
    – I understand there are concerns about the ability to fetch remote resources, however surely there could be a specific “script resources” folder in the SynthV directory where users could explicitly place these js files to be loaded in a secure manner
    – I believe to some degree lua scripts can already do this, so it is a strange omission from the javascript implementation

  12. Add functions for currently-inaccessible properties and objects
    – Along with the limitations to Tracks and Grid Snapping mentioned above, there is no way to fetch or set Vocal Modes, interact with the Retakes feature, check if Instant Mode is enabled, or even check the current language setting