dotbc-desktop uses dotbc-plugin-manager to load and run plugins, and dotbc-plugin-manager provides utilities plugin makers can leverage to develop additional functionality for dotbc-desktop.
// example plugin index.js mainFile
const pm = require('dotbc-plugin-manager');
const Plugin = require('./plugin');
let interval;
// register resource paths to for expansion from relative to absolute paths
pm.registerResourcePath('capabilities.search.imageUrl');
pm.registerResourcePath('capabilities.search.searchImageUrl');
module.exports.activate = function (cb) {
cb(null, new Plugin());
};
module.exports.deactivate = function () {
console.log('plugin deactivated');
}
/// matching package.json:
{
"name": "my-plugin",
"displayName": "My Plugin",
"version": "0.0.0",
"description": "example plugin for dotBC",
"publisher": "dotBC",
"main": "index.js",
"capabilities": {
"search": {
"name": "My Search API",
"description": "Look up artists on my api.",
"imageUrl": "public/images/icon.png",
"searchImageUrl": "public/images/icon-search.png",
"supportedSearchTypes": [
"artist", "work"
],
"commands": [
"search",
"getDetails"
]
}
},
"author": "",
"license": "MIT",
"dependencies": {
"dotbc-plugin-manager": "git+ssh://git@github.com/dotbc/dotbc-plugin-manager.git",
"debug": "^2.2.0",
"lodash": "^4.15.0",
"superagent": "^2.2.0"
}
}
{Function} PluginManager
Kind: global class
Requires: module:events
, module:debug
, module:lodash.get
, module:path
, module:lodash.set
License: MIT
Internal: handles messages passed to plugin process via ipc.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
msg | Object |
message object passed from main process to plugin process. |
Internal: iterates through and activates all plugin capabilities provided in package.json
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
msg | Object |
message object passed from main process to plugin process. |
Wires up IPC mechanics required to perform rpc from the dotBC main process, via the renderer process, to plugin processes and vice versa.
activateRpcMethod creates a strategy function used to process incoming messages passed to the plugin process via IPC. Functions route incoming message parameters to be applied to command methods or event handlers defined on the provided plugin instance.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
plugin | Object |
plugin instance |
name | String |
the name of the command or event. |
type | String |
type method type [command |
Third stage of dotBC plugin loading lifecycle. the activate method is called after a plugin is connected. this method in turn calls the plugin.activate method definted on the plugin instance being started. after the plugin's activate function completes and config-defined capabilities and their commands and events are activated. When complete, this function emits an 'activated' event.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
plugin | Object |
plugin instance |
name | String |
the name of the command or event. |
type | String |
type method type [command |
Second stage of dotBC plugin loading lifecycle. Connect sends a message to the main process, signaling that a plugin has started but not yet activated. Connect emits a 'connected' event locally.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
pkg | Object |
plugin package.json object |
First stage of dotBC plugin loading lifecycle. the activate method is called after a plugin is connected. this method in turn calls the plugin.activate method definted on the plugin instance being started. after the plugin's activate function completes and config-defined capabilities and their commands and events are activated. When complete, this function emits an 'activated' event.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
pkg | Object |
plugin package.json object |
Registers a path defined in a plugin's package.json to be expanded from relative to absolute. Not registering a resource path for expansion may result in resources being improperly rendered.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
propertyPath | String |
dot separated path of json property, located in a plugin's package.json structure |
Sends an event to the main process via an IPC message.
Kind: instance method of PluginManager
Param | Type | Description |
---|---|---|
name | String |
name of the event being sent. |
params | Object |
data parameters of the event being sent. |