diff --git a/src/app.js b/src/app.js index 412ad57b08..3524973435 100644 --- a/src/app.js +++ b/src/app.js @@ -44,6 +44,7 @@ var BasicReadOnlyExplorer = require('./app/files/basicReadOnlyExplorer') var NotPersistedExplorer = require('./app/files/NotPersistedExplorer') var toolTip = require('./app/ui/tooltip') var CommandInterpreter = require('./lib/cmdInterpreter') +var PluginAPI = require('./app/plugin/pluginAPI') var styleGuide = require('./app/ui/styles-guide/theme-chooser') var styles = styleGuide.chooser() @@ -780,17 +781,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org }, newAccount: (pass, cb) => { udapp.newAccount(pass, cb) - }, - setConfig: (mod, path, content, cb) => { - self._api.filesProviders['config'].set(mod + '/' + path, content) - cb() - }, - getConfig: (mod, path, cb) => { - cb(null, self._api.filesProviders['config'].get(mod + '/' + path)) - }, - removeConfig: (mod, path, cb) => { - cb(null, self._api.filesProviders['config'].remove(mod + '/' + path)) - if (cb) cb() } } var rhpEvents = { @@ -800,7 +790,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org editor: editor.event, staticAnalysis: staticanalysis.event } - self._components.righthandpanel = new RighthandPanel(rhpAPI, rhpEvents) + var rhpOpts = { + pluginAPI: new PluginAPI(self, compiler) + } + + self._components.righthandpanel = new RighthandPanel(rhpAPI, rhpEvents, rhpOpts) self._view.rightpanel.appendChild(self._components.righthandpanel.render()) self._components.righthandpanel.init() self._components.righthandpanel.event.register('resize', delta => self._adjustLayout('right', delta)) diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index 4dc36b7fb6..30a3d2235e 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -63,7 +63,7 @@ function RighthandPanel (appAPI = {}, events = {}, opts = {}) { this._view.tabbedMenu.addTab('Support', 'supportView', optionViews.querySelector('#supportView')) this._view.tabbedMenu.selectTabByTitle('Compile') - self.pluginManager = new PluginManager(appAPI, events) + self.pluginManager = new PluginManager(opts.pluginAPI, events) events.rhp.register('plugin-loadRequest', (json) => { var tab = new PluginTab(appAPI, events, json) var content = tab.render() diff --git a/src/app/plugin/pluginAPI.js b/src/app/plugin/pluginAPI.js index 6f0c13d754..eb1f72322f 100644 --- a/src/app/plugin/pluginAPI.js +++ b/src/app/plugin/pluginAPI.js @@ -1,5 +1,26 @@ 'use strict' - -module.exports = { - +/* + Defines available API. `key` / `type` +*/ +module.exports = (app, compiler) => { + return { + config: { + setConfig: (mod, path, content, cb) => { + app._api.filesProviders['config'].set(mod + '/' + path, content) + cb() + }, + getConfig: (mod, path, cb) => { + cb(null, app._api.filesProviders['config'].get(mod + '/' + path)) + }, + removeConfig: (mod, path, cb) => { + cb(null, app._api.filesProviders['config'].remove(mod + '/' + path)) + if (cb) cb() + } + }, + compiler: { + getCompilationResult: () => { + return compiler.lastCompilationResult + } + } + } } diff --git a/src/app/plugin/pluginManager.js b/src/app/plugin/pluginManager.js index 93d4206992..9b06e98804 100644 --- a/src/app/plugin/pluginManager.js +++ b/src/app/plugin/pluginManager.js @@ -72,7 +72,7 @@ class PluginManager { this.inFocus = tabName this.post(tabName, JSON.stringify({ type: 'compilationData', - value: api.getCompilationResult() + value: api.compiler.getCompilationResult() })) } }) @@ -93,7 +93,7 @@ class PluginManager { data.arguments.push((error, result) => { response(data.type, data.id, error, result) }) - api[data.type].apply({}, data.arguments) + api[data.key][data.type].apply({}, data.arguments) } } }, false)