Skip to content

dotbc/dotbc-plugin-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotbc-plugin-manager

dotbc-plugin-manager is a utility for creating, verifying, and installing dotbc plugins.

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"
  }
}

PluginManager

{Function} PluginManager

Kind: global class
Requires: module:events, module:debug, module:lodash.get, module:path, module:lodash.set
License: MIT

PluginManager._onMessage(msg)

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.

PluginManager._activatePluginCapabilities(msg)

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.

PluginManager.activateRpcMethod(plugin, name, type)

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

PluginManager.activate(plugin, name, type)

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

PluginManager.connect(pkg)

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

PluginManager.load(pkg)

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

PluginManager.registerResourcePath(propertyPath)

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

PluginManager.sendEvent(name, params)

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published