add plugin ethdoc

pull/3094/head
yann300 6 years ago
parent 2055aba847
commit 27aef76b08
  1. 2
      package.json
  2. 12
      src/app.js
  3. 21
      src/app/components/swap-panel-api.js
  4. 12
      src/app/components/vertical-icons-api.js
  5. 51
      src/remixAppManager.js

@ -42,7 +42,7 @@
"remix-analyzer": "0.3.1",
"remix-debug": "0.3.1",
"remix-lib": "0.4.1",
"remix-plugin": "0.0.1-alpha.5",
"remix-plugin": "0.0.1-alpha.6",
"remix-solidity": "0.3.1",
"remix-tests": "0.1.1",
"remixd": "0.1.8-alpha.6",

@ -409,8 +409,13 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// TODOs those are instanciated before hand. should be instanciated on demand
const pluginManagerComponent = new PluginManagerComponent()
const swapPanelComponent = new SwapPanelComponent()
const verticalIconComponent = new VerticalIconsComponent()
const swapPanelApi = new SwapPanelApi(swapPanelComponent, verticalIconComponent) // eslint-disable-line
const verticalIconsApi = new VerticalIconsApi(verticalIconComponent) // eslint-disable-line
let appStore = new EntityStore('module', { actives: [], ids: [], entities: {} })
const appManager = new RemixAppManager(appStore)
const appManager = new RemixAppManager(appStore, swapPanelApi, verticalIconsApi)
registry.put({api: appManager.proxy(), name: 'pluginmanager'})
pluginManagerComponent.setApp(appManager)
@ -445,10 +450,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
{ profile: run.profile(), api: run },
{ profile: pluginManagerComponent.profile(), api: pluginManagerComponent }])
const swapPanelComponent = new SwapPanelComponent()
const verticalIconComponent = new VerticalIconsComponent()
const swapPanelApi = new SwapPanelApi(swapPanelComponent, verticalIconComponent, appManager) // eslint-disable-line
const verticalIconsApi = new VerticalIconsApi(verticalIconComponent, appManager) // eslint-disable-line
appStore.addEntities(appManager.plugins())
swapPanelApi.event.on('toggle', () => {
this._components.resizeFeature.panel1.clientWidth !== 0 ? this._components.resizeFeature.minimize() : this._components.resizeFeature.maximise()

@ -1,7 +1,7 @@
import EventEmmitter from 'events'
class SwapPanelApi {
constructor (swapPanelComponent, verticalIconsComponent, appManager) {
constructor (swapPanelComponent, verticalIconsComponent) {
this.event = new EventEmmitter()
this.component = swapPanelComponent
this.currentContent
@ -14,29 +14,18 @@ class SwapPanelApi {
this.component.showContent(moduleName)
this.currentContent = moduleName
})
appManager.event.on('requestContainer', (mod, content) => {
this.add(mod.name, content)
})
appManager.event.on('removingItem', (mod) => {
this.remove(mod.name)
})
}
/*
content: DOM element
by appManager
*/
add (moduleName, content) {
// add the DOM to the swappanel
return this.component.add(moduleName, content)
}
remove (moduleName) {
return this.component.remove(moduleName)
add (profile, content) {
return this.component.add(profile.name, content)
}
reference (modulename, domElement) {
this.nodes[modulename] = domElement
remove (profile) {
return this.component.remove(profile.name)
}
}

@ -1,10 +1,16 @@
// API
class VerticalIconsApi {
constructor (verticalIconsComponent, appManager) {
constructor (verticalIconsComponent) {
this.component = verticalIconsComponent
appManager.event.on('requestContainer', (mod, content) => verticalIconsComponent.addIcon(mod))
appManager.event.on('removingItem', (mod) => verticalIconsComponent.removeIcon(mod))
}
addIcon (mod) {
this.component.addIcon(mod)
}
removeIcon (mod) {
this.component.removeIcon(mod)
}
}
module.exports = VerticalIconsApi

@ -1,12 +1,15 @@
import { AppManagerApi } from 'remix-plugin'
import { AppManagerApi, Plugin } from 'remix-plugin'
import { EventEmitter } from 'events'
import PluginManagerProxy from './app/components/plugin-manager-proxy'
export class RemixAppManager extends AppManagerApi {
constructor (store) {
constructor (store, swapPanelApi, verticalIconsApi) {
super(null)
this.store = store
this.verticalIconsApi = verticalIconsApi
this.swapPanelApi = swapPanelApi
this.hiddenNodes = {}
this.event = new EventEmitter()
this.data = {
proxy: new PluginManagerProxy()
@ -21,9 +24,14 @@ export class RemixAppManager extends AppManagerApi {
setActive (name, isActive) {
const entity = this.getEntity(name)
if (entity && entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') {
isActive ? this.event.emit('requestContainer', entity.profile, entity.api.render())
: this.event.emit('removingItem', entity.profile)
// here we have an internal module (it does not need to be rendered necessarily - "rendered" means pushed to the DOM)
// if it contains `render` function, we push the view to `resolveLocation`
isActive ? this.resolveLocation(entity.profile, entity.api.render())
: this.removeComponent(entity.profile)
}
// at this point, if it's an iframe plugin, it should have already been rendered (to the DOM)
// either using `location` in json profile or using the optionnal api in the `Plugin` class
// temp
if (entity && name === 'SolidityCompile') {
isActive ? this.data.proxy.register(entity.api) : this.data.proxy.unregister(entity.api)
@ -37,5 +45,40 @@ export class RemixAppManager extends AppManagerApi {
addEntity (entity) {
this.store.add(entity.profile.name, entity)
}
resolveLocation (profile, domEl) {
// if there's an icon, we add to the swap panel
// if not we suppose it just need to be put to DOM (that would be)
if (profile.icon) {
this.swapPanelApi.add(profile, domEl)
this.verticalIconsApi.addIcon(profile)
return
}
this.hiddenNodes[profile.name] = domEl
document.body.appendChild(domEl)
}
removeComponent (profile) {
if (profile.icon) {
this.swapPanelApi.remove(profile)
this.verticalIconsApi.removeIcon(profile)
return
}
let hiddenNode = this.hiddenNodes[profile.name]
if (hiddenNode) document.body.removeChild(hiddenNode)
}
plugins () {
let ethDoc = {
name: 'ethdoc',
events: ['newDoc'],
methods: ['getdoc'],
notifications: {
'solCompiler': ['getCompilationFinished']
},
url: 'https://ipfs.io/ipfs/Qmdu56TjQLMQmwitM6GRZXwvTWh8LBoNCWmoZbSzykPycJ/'
}
return [{ profile: ethDoc, api: new Plugin(ethDoc, { resolveLocaton: (iframe) => { return this.resolveLocation(ethDoc, iframe) } }) }]
}
}

Loading…
Cancel
Save