v1.2.0.1-beta1
|
A complete, standalone, multi-threaded JavaScript environment available as a plugin for use with Touch Portal macro launcher software.
This is the ultimate in Touch Portal extensibility short of writing your own plugin.
This plugin evaluates expressions using a JavaScript "engine" and (optionally) returns results as a Touch Portal State.
(If you're not familiar, Touch Portal uses States to display information to the user and/or trigger events.)
You can send other dynamic States/Values to this plugin as part of the expressions it evaluates, for example to do some math on a numeric value, or to format a piece of text in a particular way. It can evaluate anything from basic math to complex JavaScript modules.
You do not need to know anything about JavaScript to start using the basic features of this plugin.
The original idea was for something to do math operations in one step and with more features (not a Touch Portal strong point), and it can certainly do that with aplomb.
It then grew into a full-blown scripting environment, which you may choose to utilize at any level you wish.
So, what can yo udo with this? A lot! Here's a non-exhaustive list of some examples.
(Note: The ${value:MyVariable}
in the examples represents Touch Portal's notation for a dynamic global Value or a plugin State and will be replaced by Touch Portal with the actual variable value before it is sent to the plugin.)
${value:MyVariable} * 100 / (33 + 25)
sin( ( round(${value:MyVariable} * 100) / 100 ) % 360 ) * (180 / Math.PI)
Format("MyVariable to 2 decimals:\n {0:F2}", ${value:MyVariable})
sprintf("MyVariable to 2 decimals:\n %.2f", ${value:MyVariable})
`MyVariable to 2 decimals:\n ${(${value:MyVariable}).toFixed(2)}`
(${value:MyVariable} == 0 ? "The value is False" : "The value is True")
new Date().addDays(${value:test.dynamic_value_1}).format("yyyy MMM dd, dddd")
(eg. "2022 Dec 15, Thursday")Color("#FF000088").spin(${value:MyVariable} * 3.6).argb()
Net.request("https://dse.tpp.max.paperno.us/images/logo/icon_64.png").get().base64()
File.readLines(`../logs/console-${new Date().format("yyyyMMdd")}.log`, 5, -1))
JSON.parse(File.read("data.json")).myProperty
Net.request("https://jsonplaceholder.typicode.com/todos/1").get().json().title
TP.stateUpdateById("MyVariable", ${value:MyVariable} * 25)
TP.showNotification("myNotififyId", "Something Happened", "Hey, something happened, check it out!")
include()
function is available to read an evaluate any block of code from another file, and require()
to import modules or parts of them, both available for easy code re-use within standalone scripts or modules.console.log()
(and family) support for debugging/etc; output is sent to a separate plugin log file dedicated for scripting output and errors.setTimeout()
/setInterval()
.Process
class.Note: As with all plugins, this requires the Touch Portal Pro (paid) version to function. Use the latest available Touch Portal version for best results.
.tpp
plugin file. If you know how to import a plugin, just do that... otherwise continue here..tpp
file and select it.Unless stated otherwise in the notes of a particular release version, it is OK to just re-install a newer version of the plugin "on top of" a previous version without uninstalling the old version first. Either way is OK, just keep in mind that uninstalling the plugin via Touch Portal will also remove any current log files as well.
In GitHub (with an account) you can Watch -> Custom -> Releases this repository (button at top right).
Or subscribe to the ATOM feed for release notifications.
Release announcements are also made in the Touch Portal Discord Server room #dynamic-script-engine
Or use the provided example script to check for new versions right from Touch Portal!
Use the GitHub Issues feature for bug reports and concise feature suggestions. Use Discussions for any other topic.
There is also a Discord support forum on my server, an announcements channel, and discussion rooms on my server @ #dse-general and at Touch Portal's Discord server channel #dynamic-script-engine
All feedback and input is always welcome! I'd love to know how you're using DSEP!
The most likely cause of something not working right is going to be scripting syntax errors or data being passed to functions in unexpected format (eg. un-escaped backslashes).
See the Status and Logging documentation page for more details on script error reporting and plugin logging in general.
This project is written, tested, and documented by myself, Maxim (Max) Paperno.
https://github.com/mpaperno/
Contributions are welcome!
Uses portions of the Qt Library under the terms of the GPL v3 license.
Uses and includes a slightly modified version of the String.format for JavaScript library, used under the terms of the zlib license.
Uses and includes a modified version of the TinyColor library, used under the terms of the MIT license.
Uses and includes the sprintf
function from Locutus project, used under the terms of the Locutus license.
Documentation generated with Doxygen and styled with the most excellent Doxygen Awesome.
Dynamic Script Engine Project
COPYRIGHT: Maxim Paperno; All Rights Reserved.
This program and associated files may be used under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License is included in this repository and is also available at http://www.gnu.org/licenses/.
This project may also use 3rd-party Open Source software under the terms of their respective licenses. The copyright notice above does not apply to any 3rd-party components used within.