Plug-in Overview
Plug-in Folder Structure
A Jancy plug-in is just a folder with a couple of special files at a minimum.
|-- folder
| | -- package.json
| | -- src
| | | -- index.js
package.json
The package.json file must contain a valid JSON object with the following keys:
name
(string
) The name of your plug-in. This is what you’ll see this in the list of plug-ins on the Plug-in settings pageversion
(string
) Version information about your plug-in. Mostly for informational purposes but might serve a bigger role in the future.description
(string
) Brief description about your plug-in. It’s also displayed in the list of plug-ins next to your plug-inmain
(string
) Path to a file relative to your folder that implements your entry point.
{ "name": "your-plugin-name", "version": "0.1", "description": "A short description of your plug-in", "main": "src/index.js" }
Plug-in Entry Point
All plug-ins need an entry point file. The entry point must export a Javascript object with the following properties and functions.
The name of the entry point folder and file within the plug-in folder can be whatever you want. It doesn’t have to be src/index.js
.
jancy_props
(Object
) required
registryVersion
(Integer
) required Informs the plug-in system what version of the plugin registry this plug-in expects.enabled
(boolean
) optional Iffalse
, your plug-in will not be enabled the first time it loads and the user will have to enable it manually. Default istrue
.
Only registryVersion
1 is supported at the moment.
jancy_onInit(jancy, enabled)
(Function
) required
This function will get called after the plug-in system loads your plug-in. This is your first opportunity to interact with Jancy. It will be called with the following arguments.
jancy
(Jancy object
) the global Jancy objectenabled
(boolean
) flag that indicates if your plug-in is enabled or disabled
jancy_onInit
can optionally return a promise that will be awaited on before the next plug-in is loaded. This makes it possible forjancy_onInit
to be declared with theasync
keyword.
jancy_onEnabled(jancy)
optional
This function will get called when your plug-in has been enabled after being disabled. It will be called with the following argument.
jancy
(Jancy object
) the global Jancy object
jancy_onEnabled
can optionally return a promise that will be awaited. This makes it possible forjancy_onEnabled
to be declared with theasync
keyword.
jancy_onDisabled(jancy)
optional
This function will get called when your plug-in has been disabled after being enabled. It will be called with the following argument.
jancy
(Jancy object
) the global Jancy object
When this function is called you should try and do your best to undo the things your plug-in did in either jancy_onInit
or jancy_onEnabled
.
module.exports = { jancy_props: { registryVersion: 1 }, jancy_onInit(jancy, enabled) { if (enabled) { this.onEnabled(jancy) } }, jancy_onEnabled(jancy) { // Add stuff to jancy }, jancy_onDisabled(jancy) { // Remove stuff from jancy } }
jancy_onDisabled
can optionally return a promise that will be awaited. This makes it possible forjancy_onDisabled
to be declared with theasync
keyword.
Distribution
When you’re done writing your plug-in or you want to test it, just copy or move your plug-in folder to the Jancy plug-ins folder.
If Jancy is currently running, you’ll need to restart it in order for it to see your plug-in.
- On Windows the plug-in folder is located at
%appdata%\Jancy\plugins
- On MacOS the plug-in folder is locatd at
~/Library/Application Support/Jancy/plugins