@remixproject/engine
This is the core library used to create a new plugin engine.
Last updated 11 days ago by grandschtroumpf .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @remixproject/engine 
SYNC missed versions from official npm registry.

Engine Core

This is the core library used to create a new plugin engine.

Name Latest Version
@remixproject/engine badge

Use this library if you want to create an engine for a new environment.

If you want to create an engine for an existing envrionment, use the specific library. For example :

Tutorial

  1. Getting Started
  2. Plugin Communication
  3. Host a Plugin with UI
  4. External Plugins
  5. Plugin Service

API

API Description
Engine Register plugins & redirect messages
Manager Activate & Deactive plugins

Connector

The plugin connector is the main component of @remixproject/engine, it defines how an external plugin can connect to the engine. Checkout the documentation.


Getting started

npm install @remixproject/engine

The engine works a with two classes :

  • PluginManager: manage activation/deactivation
  • Engine: manage registration & communication
import { PluginManager, Engine, Plugin } from '@remixproject/engine'

const manager = new PluginManager()
const engine = new Engine()
const plugin = new Plugin({ name: 'plugin-name' })

// Wait for the manager to be loaded
await engine.onload()

// Register plugins
engine.register([manager, plugin])

// Activate plugins
manager.activatePlugin('plugin-name')

Registration

The registration makes the plugin available for activation in the engine.

To register a plugin you need:

  • Profile: The ID card of your plugin.
  • Plugin: A class that expose the logic of the plugin.
const profile = {
  name: 'console',
  methods: ['print']
}

class Console extends Plugin {
  constructor() {
    super(profile)
  }
  print(msg: string) {
    console.log(msg)
  }
}
const consolePlugin = new Console()

// Register plugins
engine.register(consolePlugin)

In the future, this part will be manage by a Marketplace plugin.

Activation

The activation process is managed by the PluginManager.

Activating a plugin makes it visible to other plugins. Now they can communicate.

manager.activatePlugin('console')

The PluginManager is a plugin itself.

Communication

Plugin exposes a simple interface for communicate between plugins :

  • call: Call a method exposed by another plugin (This returns always a Promise).
  • on: Listen on event emitted by another plugin.
  • emit: Emit an event broadcasted to all listeners.

This code will call the method print from the plugin console with the parameter 'My message'.

plugin.call('console', 'print', 'My message')

Full code example

import { PluginManager, Engine, Plugin } from '@remixproject/engine'
const profile = {
  name: 'console',
  methods: ['print']
}

class Console extends Plugin {
  constructor() {
    super(profile)
  }
  print(msg: string) {
    console.log(msg)
  }
}

const manager = new PluginManager()
const engine = new Engine()
const emptyPlugin = new Plugin({ name: 'empty' })
const consolePlugin = new Console()

// Register plugins
engine.register([manager, plugin, consolePlugin])

// Activate plugins
manager.activatePlugin(['empty', 'console'])

// Plugin communication
emptyPlugin.call('console', 'print', 'My message')

Current Tags

  • 0.3.3                                ...           latest (11 days ago)
  • 0.3.3-alpha                                ...           next (11 days ago)
  • 0.3.0-alpha.6-test                                ...           test (6 months ago)

65 Versions

  • 0.3.3                                ...           11 days ago
  • 0.3.3-alpha                                ...           11 days ago
  • 0.3.2                                ...           18 days ago
  • 0.3.1                                ...           25 days ago
  • 0.3.0                                ...           a month ago
  • 0.3.0-beta.14                                ...           a month ago
  • 0.3.0-beta.13                                ...           a month ago
  • 0.3.0-beta.12                                ...           2 months ago
  • 0.3.0-beta.11                                ...           2 months ago
  • 0.3.0-beta.10                                ...           2 months ago
  • 0.3.0-beta.9                                ...           2 months ago
  • 0.3.0-beta.8                                ...           2 months ago
  • 0.3.0-beta.7                                ...           2 months ago
  • 0.3.0-beta.6                                ...           2 months ago
  • 0.3.0-beta.5                                ...           3 months ago
  • 0.3.0-beta.4                                ...           3 months ago
  • 0.3.0-beta.3                                ...           3 months ago
  • 0.3.0-beta.2                                ...           3 months ago
  • 0.2.5                                ...           5 months ago
  • 0.2.4                                ...           5 months ago
  • 0.3.0-alpha.8                                ...           5 months ago
  • 0.3.0-alpha.7                                ...           6 months ago
  • 0.3.0-alpha.6-test                                ...           6 months ago
  • 0.3.0-alpha.6                                ...           6 months ago
  • 0.3.0-alpha.5                                ...           6 months ago
  • 0.3.0-alpha.4                                ...           6 months ago
  • 0.3.0-alpha.3                                ...           7 months ago
  • 0.3.0-alpha.2                                ...           7 months ago
  • 0.3.0-alpha.1                                ...           7 months ago
  • 0.2.3                                ...           7 months ago
  • 0.2.2                                ...           7 months ago
  • 0.2.1                                ...           7 months ago
  • 0.2.0-alpha.8                                ...           8 months ago
  • 0.2.0-alpha.7                                ...           8 months ago
  • 0.2.0-alpha.6                                ...           9 months ago
  • 0.2.0-alpha.5                                ...           9 months ago
  • 0.2.0-alpha.4                                ...           9 months ago
  • 0.2.0-alpha.3                                ...           9 months ago
  • 0.2.0-alpha.2                                ...           9 months ago
  • 0.2.0-alpha.1                                ...           10 months ago
  • 0.2.0                                ...           a year ago
  • 0.1.16                                ...           a year ago
  • 0.1.15                                ...           a year ago
  • 0.1.14                                ...           a year ago
  • 0.1.13                                ...           a year ago
  • 0.1.11                                ...           a year ago
  • 0.1.9                                ...           a year ago
  • 0.1.8                                ...           a year ago
  • 0.1.7                                ...           a year ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3-1                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2-7                                ...           a year ago
  • 0.1.2-6                                ...           a year ago
  • 0.1.2-5                                ...           a year ago
  • 0.1.2-4                                ...           a year ago
  • 0.1.2-3                                ...           a year ago
  • 0.1.2-2                                ...           a year ago
  • 0.1.2-1                                ...           a year ago
  • 0.1.2-0                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Downloads
Today 3
This Week 25
This Month 297
Last Day 6
Last Week 83
Last Month 452
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |