Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@remixproject/engine

Package Overview
Dependencies
Maintainers
4
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remixproject/engine

Plugin Engine that power Remix IDE

  • 0.3.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-43.3%
Maintainers
4
Weekly downloads
 
Created
Source

Engine

The engine manages

  • Plugin registration
  • Plugin activation
  • Plugin communication

Tutorial

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

APIs

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(manager)
const plugin = new Plugin({ name: 'plugin-name' })

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

// Register plugins
engine.register(plugin)

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

Registration

The registration make 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 pocess is managed by the PluginManager.

Actvating a plugin makes it visible by other plugins. Now they can communicate.

manager.activatePlugin('console')

The PluginManager is a plugin itself.

Communication

Plugin exposes a simple interface to communicate with each others :

  • 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(manager)
const emptyPlugin = new Plugin({ name: 'empty' })
const consolePlugin = new Console()

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

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

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

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

Keywords

FAQs

Package last updated on 27 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc