Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


TouchDevelop editor can be extended with plugins. Right now we allow plugins which run in the context of a script, when the user explicitly invokes them (script plugins).
In future, we plan plugins that run on an action when asked by the user, or line of code when it for example has an error. If you have an idea of a plugin, let us know, and we'll think about extensibility points that could enable it!

script plugins

Script plugins are identified with hash tag #scriptPlugin in the description of a script. They are invoked using the plugins button, above add new action, event, ..., below publish in the editor. It will show the list of installed scripts with #scriptPlugin. When you select one of these plugins, TouchDevelop will load it, and run the action named code->plugin passing it an Editor object. The action has to be public.
For example, the following plugin will print out the name of the current script:
ed : Editor)
var script ast := ed → current script ast
wall → prompt("The name of the script is "script ast → string("name"))
end function
Check docs of bazaar→ast of to learn more about the JSON format of TouchDevelop scripts.

button plugins

Scripts marked with #buttonPlugin are "mined" for buttons. Any public action taking an editor as argument will be inlined as a button in the UI. The action name will be used for the button text.

restricting apis

This feature applies to button plugin scripts. If a private action called supported apis is found, its content will be used as an API slice in the editor. This allows to restrict the APIs available to the user in the context of the plugin.

displaying results

Plugins cannot post to the wall. In fact they have no wall.
If the results of your plugin are some sort of messages about the code, use Editor→annotate ast. Otherwise use wall→prompt, wall→ask ..., and friends. You can also use Editor→progress to display a progress message.
Plugins can use logging to display values to the user. See app→log and app→create logger.

modifying scripts

Plugins can also update the current script. Typically, you would call Json Object→to json builder first, then operate on the resulting object and then use bazaar→save ast. For example, this plugin renames the current script to "super-cool script" (granted, it may not be very useful...):
ed : Editor)
var script ast := bazaar → ast of(ed → current script id) → to json builder
script ast → set string("name", "super-cool script")
bazaar → save ast(ed → current script id, script ast → to json)
end function

legacy plugins

The plugin action used to be plugin(id) where id is the id of the current script (to be used with bazaar→ast of). These plugins could write to the wall.
They are now obsolete


the AST library

You can also use the AST library, which makes some of these manipulations easier. Here is a template to get you started.