move part of rhpAPI to plugin API

pull/3094/head
yann300 7 years ago
parent 7b9884b0d0
commit 23b436326c
  1. 18
      src/app.js
  2. 2
      src/app/panels/righthand-panel.js
  3. 27
      src/app/plugin/pluginAPI.js
  4. 4
      src/app/plugin/pluginManager.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))

@ -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()

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

@ -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)

Loading…
Cancel
Save