diff --git a/package.json b/package.json index 3b186abf8d..1975bef152 100644 --- a/package.json +++ b/package.json @@ -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.2", + "remix-plugin": "0.0.1-alpha.4", "remix-solidity": "0.3.1", "remix-tests": "0.1.1", "remixd": "0.1.8-alpha.6", diff --git a/src/app.js b/src/app.js index d08ae3fdaf..051330aea5 100644 --- a/src/app.js +++ b/src/app.js @@ -36,7 +36,6 @@ var toolTip = require('./app/ui/tooltip') var TransactionReceiptResolver = require('./transactionReceiptResolver') const PluginManagerComponent = require('./app/components/plugin-manager-component') -const PluginManagerApi = require('./app/components/plugin-manager-api') const VerticalIconsComponent = require('./app/components/vertical-icons-component') const VerticalIconsApi = require('./app/components/vertical-icons-api') @@ -44,7 +43,17 @@ const VerticalIconsApi = require('./app/components/vertical-icons-api') const SwapPanelComponent = require('./app/components/swap-panel-component') const SwapPanelApi = require('./app/components/swap-panel-api') -const AppManager = require('remix-plugin').AppManager +const CompileTab = require('./app/tabs/compile-tab') +const SettingsTab = require('./app/tabs/settings-tab') +const AnalysisTab = require('./app/tabs/analysis-tab') +const DebuggerTab = require('./app/tabs/debugger-tab') +const SupportTab = require('./app/tabs/support-tab') +const TestTab = require('./app/tabs/test-tab') +const RunTab = require('./app/tabs/run-tab') +const FilePanel = require('./app/panels/file-panel') + +import { EntityStore } from './lib/store' +import { RemixAppManager } from './remixAppManager' var styleGuide = require('./app/ui/styles-guide/theme-chooser') var styles = styleGuide.chooser() @@ -208,7 +217,7 @@ class App { profile () { return { - type: 'app', + name: 'App', description: 'the app', methods: ['getExecutionContextProvider', 'getProviderEndpoint', 'detectNetWork', 'addProvider', 'removeProvider'] } @@ -407,7 +416,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org event: new EventEmitter(), profile () { return { - type: 'txListener', + name: 'TxListener', events: ['newTransaction'] } } @@ -442,41 +451,74 @@ Please make a backup of your contracts and start using http://remix.ethereum.org - the current API is not optimal. For instance methods of `app` only refers to `executionContext`, wich does not make really sense. */ - const appManager = new AppManager({modules: [], plugins: []}) + // TODOs those are instanciated before hand. should be instanciated on demand - const swapPanelComponent = new SwapPanelComponent() - const pluginManagerComponent = new PluginManagerComponent( - { - app: this, - udapp: udapp, - fileManager: fileManager, - sourceHighlighters: registry.get('editor').api.sourceHighlighters, - config: self._components.filesProviders['config'], - txListener: txListenerModuleProxy - }) + const pluginManagerComponent = new PluginManagerComponent() registry.put({api: pluginManagerComponent.proxy(), name: 'pluginmanager'}) - self._components.editorpanel.init() - self._components.fileManager.init() + let filePanel = new FilePanel() + registry.put({api: filePanel, name: 'filepanel'}) + + let compileTab = new CompileTab(self._components.registry) + let run = new RunTab(self._components.registry) + let settings = new SettingsTab(self._components.registry) + let analysis = new AnalysisTab(self._components.registry) + let debug = new DebuggerTab(self._components.registry) + let support = new SupportTab(self._components.registry) + let test = new TestTab(self._components.registry, compileTab) + + let appStore = new EntityStore('module', { actives: [], ids: [], entities: {} }, 'name') + + const appManager = new RemixAppManager(appStore) + + pluginManagerComponent.setApp(appManager) + pluginManagerComponent.setStore(appStore) + + let sourceHighlighters = registry.get('editor').api.sourceHighlighters + let configProvider = self._components.filesProviders['config'] + appManager.init([ + { profile: this.profile(), api: this }, + { profile: udapp.profile(), api: udapp }, + { profile: fileManager.profile(), api: fileManager }, + { profile: sourceHighlighters.profile(), api: sourceHighlighters }, + { profile: configProvider.profile(), api: configProvider }, + { profile: txListenerModuleProxy.profile(), api: txListenerModuleProxy }, + { profile: compileTab.profile(), api: compileTab }, + { profile: filePanel.profile(), api: filePanel }, + { profile: test.profile(), api: test }, + { profile: support.profile(), api: support }, + { profile: debug.profile(), api: debug }, + { profile: analysis.profile(), api: analysis }, + { profile: settings.profile(), api: settings }, + { 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) + const verticalIconsApi = new VerticalIconsApi(verticalIconComponent, appManager) - const swapPanelApi = new SwapPanelApi(swapPanelComponent, verticalIconComponent, pluginManagerComponent) - const verticalIconsApi = new VerticalIconsApi(verticalIconComponent, pluginManagerComponent) - const pluginManagerAPI = new PluginManagerApi(pluginManagerComponent) - + self._components.editorpanel.init() + self._components.fileManager.init() + self._view.mainpanel.appendChild(self._components.editorpanel.render()) self._view.iconpanel.appendChild(verticalIconComponent.render()) self._view.swappanel.appendChild(swapPanelComponent.render()) - pluginManagerComponent.initDefault() - verticalIconComponent.select('FilePanel') - // appManager.init(pluginManagerAPI) + appManager.doActivate('App') + appManager.doActivate('Udapp') + appManager.doActivate('FileManager') + appManager.doActivate('SourceHighlighters') + appManager.doActivate('config') + appManager.doActivate('TxListener') + appManager.doActivate('FilePanel') + appManager.doActivate('SolidityCompile') + appManager.doActivate('Run') + appManager.doActivate('PluginManager') + appManager.doActivate('Settings') + appManager.doActivate('Support') - pluginManagerAPI.init({ - modules: [], - plugins: [] - }) + verticalIconComponent.select('FilePanel') // The event listener needs to be registered as early as possible, because the // parent will send the message upon the "load" event. diff --git a/src/app/components/plugin-manager-api.js b/src/app/components/plugin-manager-api.js deleted file mode 100644 index 66acb32242..0000000000 --- a/src/app/components/plugin-manager-api.js +++ /dev/null @@ -1,21 +0,0 @@ -// const remixLib = require('remix-lib') - -class PluginManagerApi { - constructor (pluginManagerComponent) { - this.component = pluginManagerComponent - pluginManagerComponent.event.on('activation', (item) => this.event.emit('activation', item)) // listen by appManager - pluginManagerComponent.event.on('deactivation', (item) => this.event.emit('deactivation', item)) // listen by appManager - } - - init (data) { - for (var m in data.modules) { - this.renderItem(m) - } - - for (var n in data.plugins) { - this.renderItem(n) - } - } -} - -module.exports = PluginManagerApi diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index 53963013f9..cc4be780c7 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -14,6 +14,7 @@ var registry = require('../../global/registry') const styleguide = require('../ui/styles-guide/theme-chooser') const styles = styleguide.chooser() +import { EntityStore } from '../../lib/store.js' const PluginManagerProxy = require('./plugin-manager-proxy') @@ -21,147 +22,73 @@ const EventEmitter = require('events') class PluginManagerComponent { - constructor ({ app, udapp, fileManager, sourceHighlighters, config, txListener }) { + constructor () { this.event = new EventEmitter() - this.modulesDefinition = { - // service module. They can be seen as daemon - // they usually don't have UI and only represent the minimal API a plugins can access. - 'App': { name: 'App', target: app }, - 'Udapp': { name: 'Udapp', target: udapp }, - 'FileManager': { name: 'FileManager', target: fileManager }, - 'SourceHighlighters': { name: 'SourceHighlighters', target: sourceHighlighters }, - 'Config': { name: 'Config', target: config }, - 'TxListener': { name: 'TxListener', target: txListener }, - // internal components. They are mostly views, they don't provide external API for plugins - 'SolidityCompile': { name: 'SolidityCompile', description: 'Compile functionality for solidity', class: 'evm-compiler', Type: CompileTab, icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvP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ZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9Ik0zMC45MzMsMzIuNTI4Yy0wLjE0Ni0xLjYxMi0wLjA5LTIuNzM3LTAuMDktNC4yMWMwLjczLTAuMzgzLDIuMDM4LTIuODI1LDIuMjU5LTQuODg4YzAuNTc0LTAuMDQ3LDEuNDc5LTAuNjA3LDEuNzQ0LTIuODE4ICBjMC4xNDMtMS4xODctMC40MjUtMS44NTUtMC43NzEtMi4wNjVjMC45MzQtMi44MDksMi44NzQtMTEuNDk5LTMuNTg4LTEyLjM5N2MtMC42NjUtMS4xNjgtMi4zNjgtMS43NTktNC41ODEtMS43NTkgIGMtOC44NTQsMC4xNjMtOS45MjIsNi42ODYtNy45ODEsMTQuMTU2Yy0wLjM0NSwwLjIxLTAuOTEzLDAuODc4LTAuNzcxLDIuMDY1YzAuMjY2LDIuMjExLDEuMTcsMi43NzEsMS43NDQsMi44MTggIGMwLjIyLDIuMDYyLDEuNTgsNC41MDUsMi4zMTIsNC44ODhjMCwxLjQ3MywwLjA1NSwyLjU5OC0wLjA5MSw0LjIxQzE5LjM2NywzNy4yMzgsNy41NDYsMzUuOTE2LDcsNDVoMzggIEM0NC40NTUsMzUuOTE2LDMyLjY4NSwzNy4yMzgsMzAuOTMzLDMyLjUyOHoiLz48L3N2Zz4=' }, - 'PluginManager': { name: 'PluginManager', target: this, description: 'Mangement of Plugins and Modules', icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU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MTY3ICBjLTAuNDIzLTEuNjkxLTEuMDg3LTMuMjgxLTEuOTYyLTQuNzM3bDQuMTYyLTUuOTMybC00LjI0My00LjI0MWwtNS44NTYsNC4yMWMtMS40Ni0wLjg4NC0zLjA2LTEuNTU4LTQuNzYzLTEuOTgybC0xLjI0NS03LjEwNmgtNiAgbC0xLjE1Niw3LjA4M2MtMS43MDQsMC40MTgtMy4zMTMsMS4wODMtNC43NzcsMS45NjNMMTAuMTgsNS44NzNsLTQuMjQzLDQuMjQxbDQuMTA3LDUuODc0Yy0wLjg4OCwxLjQ3LTEuNTYzLDMuMDc3LTEuOTkyLDQuNzkyICBMMSwyMS45NTR2Nmw3LjA0NCwxLjI0OWMwLjQyNSwxLjcxMSwxLjEwMSwzLjMxOCwxLjk5Miw0Ljc5bC00LjE2Myw1LjgyM2w0LjI0MSw0LjI0NWw1Ljg4MS00LjExOSAgYzEuNDY4LDAuODgyLDMuMDczLDEuNTUyLDQuNzc3LDEuOTczbDEuMTgsNy4wODdoNmwxLjI2MS03LjEwNWMxLjY5NS0wLjQzLDMuMjk3LTEuMTA1LDQuNzUxLTEuOTlsNS45MjIsNC4xNTVsNC4yNDItNC4yNDUgIGwtNC4yMjctNS44N2MwLjg3NS0xLjQ1NiwxLjUzOS0zLjA0OCwxLjk1OC00LjczOUw0OSwyNy45NTR6IE0yNSwzM2MtNC40MTgsMC04LTMuNTgyLTgtOHMzLjU4Mi04LDgtOHM4LDMuNTgyLDgsOFMyOS40MTgsMzMsMjUsMzMgIHoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMiIvPjwvc3ZnPg==' } + this.data = { + proxy: new PluginManagerProxy() + } + this.views = { + root: null, + items: {} } - this.activated = {} // list all activated modules - // this.activated = [] // list all activated modules - this.plugins = [] - this.data = {} - this.data.proxy = new PluginManagerProxy() - - // This load the state from localstorage first then from the second parameter is nothing is found in localstorage - // this.store = Store.fromLocal('***', {}) // Or EntityStore.fromLocal('***', {}, 'id') } - proxy () { - return this.data.proxy + profile () { + return { + name: 'PluginManager', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9IiAgTTMyLDM1YzAsMCw4LjMxMiwwLDkuMDk4LDBDNDUuNDYzLDM1LDQ5LDMxLjQ2Myw0OSwyNy4wOTlzLTMuNTM3LTcuOTAyLTcuOTAyLTcuOTAyYy0wLjAyLDAtMC4wMzgsMC4wMDMtMC4wNTgsMC4wMDMgIGMwLjA2MS0wLjQ5NCwwLjEwMy0wLjk5NCwwLjEwMy0xLjUwNGMwLTYuNzEtNS40MzktMTIuMTUtMTIuMTUtMTIuMTVjLTUuMjI5LDAtOS42NzIsMy4zMDktMTEuMzg2LDcuOTQxICBjLTEuMDg3LTEuMDg5LTIuNTkxLTEuNzY0LTQuMjUxLTEuNzY0Yy0zLjMxOSwwLTYuMDA5LDIuNjktNi4wMDksNi4wMDhjMCwwLjA4NSwwLjAxLDAuMTY3LDAuMDEzLDAuMjUxICBDMy42OTUsMTguOTk1LDEsMjIuMzQ0LDEsMjYuMzMxQzEsMzEuMTE5LDQuODgxLDM1LDkuNjcsMzVjMC44MjcsMCw4LjMzLDAsOC4zMywwIiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBzdHJva2Utd2lkdGg9IjIiLz48cG9seWxpbmUgZmlsbD0ibm9uZSIgcG9pbnRzPSIzMCw0MSAyNSw0NiAyMCw0MSAgICIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyIi8+PGxpbmUgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyIiB4MT0iMjUiIHgyPSIyNSIgeTE9IjI2IiB5Mj0iNDUuNjY4Ii8+PC9zdmc+' + } + } + + setApp (appManager) { + this.appManager = appManager + } + + setStore (store) { + this.store = store + this.store.event.on('activate', (name) => { this.views.items[name] ? this.views.items[name].querySelector('button').innerHTML = 'deactivate' : null }) + this.store.event.on('deactivate', (name) => { this.views.items[name] ? this.views.items[name].querySelector('button').innerHTML = 'activate' : null }) } - initDefault () { - this.activateInternal('App') - this.activateInternal('Udapp') - this.activateInternal('FileManager') - this.activateInternal('SourceHighlighters') - this.activateInternal('Config') - this.activateInternal('TxListener') - - this.activateInternal('FilePanel') - this.activateInternal('SolidityCompile') - this.activateInternal('Run') - this.activateInternal('PluginManager') - this.activateInternal('Settings') - this.activateInternal('Support') + proxy () { + return this.data.proxy } render () { - // var self = this - // loop over all this.modules and this.plugins - let pluginManagerDiv = yo` + this.views.root = yo`

Plugin Manager

` - for (var mod in this.modulesDefinition) { - if (this.modulesDefinition[mod].icon) { - pluginManagerDiv.appendChild(this.renderItem(mod)) - } - } - console.log(this.activated) - return pluginManagerDiv + var modules = this.store.getAll() + modules.forEach((mod) => { + this.views.root.appendChild(this.renderItem(mod.profile.name)) + }) + return this.views.root } renderItem (item) { let ctrBtns - let action = (event) => { - if (this.activated.hasOwnProperty(item)) { - this.deactivateInternal(item) - event.target.innerHTML = 'activate' - } else { - this.activateInternal(item) - event.target.innerHTML = 'deactivate' - } - } + const mod = this.store.getOne(item) + if (!mod) return + let action = () => { this.store.isActive(item) ? this.appManager.doDeactivate(item) : this.appManager.doActivate(item) } ctrBtns = yo`
- +
` - - this.plugins.push(item) - // var self = this - this.view = yo` + + this.views.items[item] = yo`
-

${this.modulesDefinition[item].name}

- ${this.modulesDefinition[item].description} +

${mod.profile.name}

+ ${mod.profile.description} ${ctrBtns}
` - return this.view - } - - activatePlugin (jsonProfile, api) { - // let profile = { json: jsonProfile, api } - // let plugin = new Plugin(profile, api) - // this.appManager.addPlugin(plugin) - // this.event.emit('displayableModuleActivated', jsonProfile, plugin.render()) - // this.activated[jsonProfile.name] = plugin - } - - deactivateInternal (name) { - if (!this.activated[name]) return - this.event.emit('removingItem', this.activated[name]) - delete this.activated[name] - } - - activateInternal (name) { - if (this.activated[name]) return - const mod = this.modulesDefinition[name] - let dep - if (mod.dep) dep = this.activateInternal(mod.dep) - let instance = mod.target - if (!instance && mod.Type) instance = new mod.Type(registry, dep) - if (!instance) return console.log(`PluginManagerComponent: no Type or instance to add: ${JSON.stringify(mod)}`) - registry.put({api: instance, name: mod.name.toLocaleLowerCase()}) - if (instance.profile && typeof instance.profile === 'function') { - this.event.emit('requestActivation', instance.profile(), instance) - } - if (mod.icon && instance.render && typeof instance.render === 'function') { - this.event.emit('requestContainer', mod, instance.render()) - } - // if of type evm-compiler, we forward to the internal components - if (mod.class === 'evm-compiler') { - this.data.proxy.register(mod, instance) - } - this.activated[mod.name] = mod - return instance - } - - _activate (item) { - this.event.emit('activation', item) - } - - _deactivate (item) { - this.event.emit('deactivation', item) + + return this.views.items[item] } } diff --git a/src/app/components/swap-panel-api.js b/src/app/components/swap-panel-api.js index eb128b17c6..bae2df24aa 100644 --- a/src/app/components/swap-panel-api.js +++ b/src/app/components/swap-panel-api.js @@ -1,15 +1,15 @@ // const EventEmmitter = require('events') class SwapPanelApi { - constructor (swapPanelComponent, verticalIconsComponent, pluginManagerComponent) { + constructor (swapPanelComponent, verticalIconsComponent, appManager) { this.component = swapPanelComponent verticalIconsComponent.event.on('showContent', (moduleName) => { this.component.showContent(moduleName) }) - pluginManagerComponent.event.on('requestContainer', (mod, content) => { + appManager.event.on('requestContainer', (mod, content) => { this.add(mod.name, content) }) - pluginManagerComponent.event.on('removingItem', (mod) => { + appManager.event.on('removingItem', (mod) => { this.remove(mod.name) }) } diff --git a/src/app/components/vertical-icons-api.js b/src/app/components/vertical-icons-api.js index a167dab0c0..6710e510c0 100644 --- a/src/app/components/vertical-icons-api.js +++ b/src/app/components/vertical-icons-api.js @@ -1,10 +1,10 @@ // API class VerticalIconsApi { - constructor (verticalIconsComponent, pluginManagerComponent) { + constructor (verticalIconsComponent, appManager) { this.component = verticalIconsComponent - pluginManagerComponent.event.on('requestContainer', (mod, content) => verticalIconsComponent.addIcon(mod)) - pluginManagerComponent.event.on('removingItem', (mod) => verticalIconsComponent.removeIcon(mod)) + appManager.event.on('requestContainer', (mod, content) => verticalIconsComponent.addIcon(mod)) + appManager.event.on('removingItem', (mod) => verticalIconsComponent.removeIcon(mod)) } } module.exports = VerticalIconsApi diff --git a/src/app/editor/SourceHighlighters.js b/src/app/editor/SourceHighlighters.js index 8902235fe5..7c53ac19d7 100644 --- a/src/app/editor/SourceHighlighters.js +++ b/src/app/editor/SourceHighlighters.js @@ -9,7 +9,7 @@ module.exports = class SourceHighlighters { profile () { return { - type: 'sourcehighlighter', + name: 'SourceHighlighters', methods: ['highlight', 'discardHighlight'] } } diff --git a/src/app/files/browser-files-tree.js b/src/app/files/browser-files-tree.js index b527d4cd71..54678e5110 100644 --- a/src/app/files/browser-files-tree.js +++ b/src/app/files/browser-files-tree.js @@ -133,7 +133,7 @@ function FilesTree (name, storage) { this.profile = function () { return { - type: this.type, + name: this.type, methods: ['get', 'set', 'remove'] } } diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index a32ef613c8..8f8e23d4bf 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -52,7 +52,7 @@ class FileManager { profile () { return { - type: 'fileManager', + name: 'FileManager', methods: ['getFilesFromPath', 'getCurrentFile', 'getFile', 'setFile'], events: ['currentFileChanged'] } diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 6a8fda6d07..87d6b45335 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -16,6 +16,7 @@ class EditorPanel { constructor (localRegistry) { var self = this self.event = new EventManager() + self._view = {} self._components = {} self._components.registry = localRegistry || globalRegistry self._components.editor = new Editor({}) @@ -39,7 +40,6 @@ class EditorPanel { } } } - self._view = {} var contextualListener = new ContextualListener({editor: self._components.editor, pluginManager: self._deps.pluginManager}) var contextView = new ContextView({contextualListener, editor: self._components.editor}) diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index 49433f1065..31296769b6 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -196,6 +196,15 @@ function filepanel (localRegistry) { self.render = function render () { return element } + self.profile = function () { + return { + name: 'FilePanel', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3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g==' + } + } + function uploadFile (event) { // TODO The file explorer is merely a view on the current state of // the files module. Please ask the user here if they want to overwrite diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js index f2d3b8d6bd..5635dece63 100644 --- a/src/app/tabs/analysis-tab.js +++ b/src/app/tabs/analysis-tab.js @@ -15,6 +15,14 @@ module.exports = class AnalysisTab { self._components.registry = localRegistry || globalRegistry self._deps = {} } + profile () { + return { + name: 'SolidityAnalysis', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxjaXJjbGUgY3g9IjIiIGN5PSIyNSIgcj0iMiIvPjxjaXJjbGUgY3g9IjE1IiBjeT0iMTkiIHI9IjIiLz48Y2lyY2xlIGN4PSIyNSIgY3k9IjExIiByPSIyIi8+PGNpcmNsZSBjeD0iMzUiIGN5PSIxNyIgcj0iMiIvPjxjaXJjbGUgY3g9IjQ4IiBjeT0iNSIgcj0iMiIvPjxjaXJjbGUgY3g9IjIiIGN5PSIzOSIgcj0iMiIvPjxjaXJjbGUgY3g9IjE1IiBjeT0iNDEiIHI9IjIiLz48Y2lyY2xlIGN4PSIyNSIgY3k9IjMzIiByPSIyIi8+PGNpcmNsZSBjeD0iMzUiIGN5PSI0MyIgcj0iMiIvPjxjaXJjbGUgY3g9IjQ4IiBjeT0iMzEiIHI9IjIiLz48cG9seWxpbmUgZmlsbD0ibm9uZSIgcG9pbnRzPSIyLDI1IDE1LDE5IDI1LDExICAgMzUsMTcgNDgsNSAiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMiIvPjxwb2x5bGluZSBmaWxsPSJub25lIiBwb2ludHM9IjIsMzkgMTUsNDEgMjUsMzMgICAzNSw0MyA0OCwzMSAiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMiIvPjwvc3ZnPg==' + } + } render () { const self = this var staticanalysis = new StaticAnalysis() diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 262a78a4f1..bc16ee6f48 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -56,8 +56,7 @@ module.exports = class CompileTab { renderer: self._components.registry.get('renderer').api, swarmfileProvider: self._components.registry.get('fileproviders/swarm').api, fileManager: self._components.registry.get('filemanager').api, - fileProviders: self._components.registry.get('fileproviders').api, - pluginManager: self._components.registry.get('pluginmanager').api + fileProviders: self._components.registry.get('fileproviders').api } self.data = { hideWarnings: self._deps.config.get('hideWarnings') || false, @@ -187,9 +186,10 @@ module.exports = class CompileTab { } profile () { return { - type: 'solidityCompile', + name: 'SolidityCompile', methods: ['getCompilationResult'], - events: ['compilationFinished'] + events: ['compilationFinished'], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmc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ab.js b/src/app/tabs/debugger-tab.js index 94737cec03..7754bb7808 100644 --- a/src/app/tabs/debugger-tab.js +++ b/src/app/tabs/debugger-tab.js @@ -27,6 +27,15 @@ class DebuggerTab { self._components.registry = localRegistry || globalRegistry } + profile () { + return { + name: 'Debugger', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9Ik00NiwxNXYtNCAgYzAtMS4xMDQtMC44OTYtMi0yLTJjMCwwLTI0LjY0OCwwLTI2LDBjLTEuNDY5LDAtMi40ODQtNC00LTRIM0MxLjg5Niw1LDEsNS44OTYsMSw3djR2Mjl2NGMwLDEuMTA0LDAuODk2LDIsMiwyaDM5ICBjMS4xMDQsMCwyLTAuODk2LDItMiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyIi8+PHBhdGggZD0iTTEsNDRsNS0yNyAgYzAtMS4xMDQsMC44OTYtMiwyLTJoMzljMS4xMDQsMCwyLDAuODk2LDIsMmwtNSwyNyIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyIi8+PC9zdmc+' + } + } + render () { const self = this if (self._view.el) return self._view.el diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index d624fc894d..3c6ede3f62 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -178,7 +178,17 @@ function runTab (opts, localRegistry) { ` container.appendChild(el) - return { render () { return container } } + return { + render () { return container }, + profile () { + return { + name: 'Run', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9Ik00My43MzQsMjFjLTMuNjMxLDAtMTUuMDkyLDAtMTUuMDkyLDAgIFMxNi4yNSw1LjE4OCwxNi4wNDcsNC45MzhzLTAuNDIyLTAuNTk0LTEuMTI1LTAuNjcyYy0wLjg1OS0wLjA5NS0xLjk2OS0wLjIwMy0yLjMyOC0wLjIzNGMtMC40MDYtMC4wMzUtMC43MTksMC4xNDEtMC40OTYsMC43MzQgIEMxMi4zODgsNS41MzksMTguNzQ4LDIxLDE4Ljc0OCwyMUg2LjAzNGMwLDAtMi40NTgtNC43MjItMi44NzgtNS41MzFDMi45NjUsMTUuMTAxLDIuNTU3LDE1LjAxNCwyLDE1SDEuMjk3ICBjLTAuMTI1LDAtMC4zMTIsMC0wLjI4MSwwLjM0NEMxLjA1OCwxNS44MTEsMywyNSwzLDI1cy0xLjg4OCw5LjE5Ny0xLjk4NCw5LjY1NkMwLjk1MywzNC45NTMsMS4xNzIsMzUsMS4yOTcsMzVIMiAgYzAuOTY2LTAuMDA5LDAuOTU0LTAuMDc5LDEuMTU2LTAuNDY5QzMuNTc2LDMzLjcyMiw2LjAzNCwyOSw2LjAzNCwyOWgxMi43MTRjMCwwLTYuMzYsMTUuNDYxLTYuNjUsMTYuMjM0ICBjLTAuMjIzLDAuNTk0LDAuMDksMC43NywwLjQ5NiwwLjczNGMwLjM1OS0wLjAzMSwxLjQ2OS0wLjEzOSwyLjMyOC0wLjIzNGMwLjcwMy0wLjA3OCwwLjkyMi0wLjQyMiwxLjEyNS0wLjY3MlMyOC42NDMsMjksMjguNjQzLDI5ICBzMTEuNDYxLDAsMTUuMDkyLDBjMy43NjYsMCw1LjI2NC0zLjAzMSw1LjI2NC00UzQ3LjQ4NCwyMSw0My43MzQsMjF6IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyIi8+PC9zdmc+' + } + } + } } module.exports = runTab diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 525cd33c39..e05b6fd565 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -38,6 +38,14 @@ module.exports = class SettingsTab { self._components.themeStorage = new Storage('style:') self.data.currentTheme = self._components.themeStorage.get('theme') || 'light' } + profile () { + return { + name: 'Settings', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9Ik00OSwyNy45NTR2LTZsLTcuMTQxLTEuMTY3ICBjLTAuNDIzLTEuNjkxLTEuMDg3LTMuMjgxLTEuOTYyLTQuNzM3bDQuMTYyLTUuOTMybC00LjI0My00LjI0MWwtNS44NTYsNC4yMWMtMS40Ni0wLjg4NC0zLjA2LTEuNTU4LTQuNzYzLTEuOTgybC0xLjI0NS03LjEwNmgtNiAgbC0xLjE1Niw3LjA4M2MtMS43MDQsMC40MTgtMy4zMTMsMS4wODMtNC43NzcsMS45NjNMMTAuMTgsNS44NzNsLTQuMjQzLDQuMjQxbDQuMTA3LDUuODc0Yy0wLjg4OCwxLjQ3LTEuNTYzLDMuMDc3LTEuOTkyLDQuNzkyICBMMSwyMS45NTR2Nmw3LjA0NCwxLjI0OWMwLjQyNSwxLjcxMSwxLjEwMSwzLjMxOCwxLjk5Miw0Ljc5bC00LjE2Myw1LjgyM2w0LjI0MSw0LjI0NWw1Ljg4MS00LjExOSAgYzEuNDY4LDAuODgyLDMuMDczLDEuNTUyLDQuNzc3LDEuOTczbDEuMTgsNy4wODdoNmwxLjI2MS03LjEwNWMxLjY5NS0wLjQzLDMuMjk3LTEuMTA1LDQuNzUxLTEuOTlsNS45MjIsNC4xNTVsNC4yNDItNC4yNDUgIGwtNC4yMjctNS44N2MwLjg3NS0xLjQ1NiwxLjUzOS0zLjA0OCwxLjk1OC00LjczOUw0OSwyNy45NTR6IE0yNSwzM2MtNC40MTgsMC04LTMuNTgyLTgtOHMzLjU4Mi04LDgtOHM4LDMuNTgyLDgsOFMyOS40MTgsMzMsMjUsMzMgIHoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMiIvPjwvc3ZnPg==' + } + } render () { const self = this if (self._view.el) return self._view.el diff --git a/src/app/tabs/support-tab.js b/src/app/tabs/support-tab.js index ea7367d71a..eabf86866c 100644 --- a/src/app/tabs/support-tab.js +++ b/src/app/tabs/support-tab.js @@ -28,6 +28,14 @@ module.exports = class SupportTab { self.data.gitterIsLoaded = true }) } + profile () { + return { + name: 'Support', + methods: [], + events: [], + icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxwYXRoIGQ9Ik0zMC45MzMsMzIuNTI4Yy0wLjE0Ni0xLjYxMi0wLjA5LTIuNzM3LTAuMDktNC4yMWMwLjczLTAuMzgzLDIuMDM4LTIuODI1LDIuMjU5LTQuODg4YzAuNTc0LTAuMDQ3LDEuNDc5LTAuNjA3LDEuNzQ0LTIuODE4ICBjMC4xNDMtMS4xODctMC40MjUtMS44NTUtMC43NzEtMi4wNjVjMC45MzQtMi44MDksMi44NzQtMTEuNDk5LTMuNTg4LTEyLjM5N2MtMC42NjUtMS4xNjgtMi4zNjgtMS43NTktNC41ODEtMS43NTkgIGMtOC44NTQsMC4xNjMtOS45MjIsNi42ODYtNy45ODEsMTQuMTU2Yy0wLjM0NSwwLjIxLTAuOTEzLDAuODc4LTAuNzcxLDIuMDY1YzAuMjY2LDIuMjExLDEuMTcsMi43NzEsMS43NDQsMi44MTggIGMwLjIyLDIuMDYyLDEuNTgsNC41MDUsMi4zMTIsNC44ODhjMCwxLjQ3MywwLjA1NSwyLjU5OC0wLjA5MSw0LjIxQzE5LjM2NywzNy4yMzgsNy41NDYsMzUuOTE2LDcsNDVoMzggIEM0NC40NTUsMzUuOTE2LDMyLjY4NSwzNy4yMzgsMzAuOTMzLDMyLjUyOHoiLz48L3N2Zz4=' + } + } render () { const self = this if (self._view.el) return self._view.el diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index bb85ba84a2..12edc63358 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -23,6 +23,14 @@ module.exports = class TestTab { self.data = {} self.testList = yo`
` } + profile () { + return { + name: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ff --git a/src/lib/store.js b/src/lib/store.js new file mode 100644 index 0000000000..d0ba59722f --- /dev/null +++ b/src/lib/store.js @@ -0,0 +1,250 @@ +import { EventEmitter } from 'events' + +export class Store { + + /** + * Instanciate the store from `localStorage` first + * @template T + * @param {string} name The name of the store + * @param {T} initialState The initial state used if state is not available in `localStorage` + */ + static fromLocal(name, initialState) { + const fromLocal = localStorage.getItem(name) + const intial = fromLocal ? JSON.parse(fromLocal) : initialState + return new Store(name, intial) + } + + /** + * Create a Store that hold the state of the component + * @template T + * @param {string} name The name of the store + * @param {T} initialState The initial state of the store + */ + constructor(name, initialState) { + this.event = new EventEmitter() + this.name = name + this.state = initialState + } + + /** Listen on event from the store */ + get on() { + return this.event.on; + } + + /** Liste once on event from the store */ + get once() { + return this.event.once; + } + + /** + * Update one field of the state + * @param {Partial} state The part of the state updated + */ + /* + update(state) { + this.state = { ...this.state, ...state } + } + */ + + /** + * Get one field of the state + * @template Key key of `this.state` + * @param {Key} key A key of the state + */ + get(key) { + return this.state.entities[key] + } + + /** Reset the state its initial value */ + reset() { + this.state = this.initialState + } + + /** Dispatch an event with the new state */ + dispatch() { + this.event.emit('newState', this.state) + } +} + +/** + * An entity inside a collection + * @typedef {Object} EntityState + * @property {string[]} ids The list of IDs of the entity in the state + * @property {string[]} actives The list of IDs of the activated entities + * @property {Object} entities A map of ids and entities + */ + + + +export class EntityStore extends Store { + + /** + * Instanciate the store from `localStorage` first + * @param {string} name The name of the store + * @param {EntityState} initialState The initial state used if state is not available in `localStorage` + */ + static fromLocal(name, initialState) { + const fromLocal = localStorage.getItem(name) + const intial = fromLocal ? JSON.parse(fromLocal) : initialState + return new EntityStore(name, intial) + } + + /** + * Create a entity Store that hold a map entity of the same model + * @param {string} name The name of the store + * @param {EntityState} initialState The initial state used if state is not available in `localStorage` + */ + constructor(name, initialState) { + super(name, initialState) + } + + //////////// + // GETTER // + //////////// + + /** Tne entities as a Map */ + get entities() { + return this.state.entities + } + + /** List of all the ids */ + get ids() { + return this.state.ids + } + + /** List of all active ID */ + get actives() { + return this.state.actives + } + + /** Return the length of the entity collection */ + get length() { + return this.state.ids.length + } + + ///////////// + // SETTERS // + ///////////// + + /** + * Add a new entity to the state + * @param {Object} entity + */ + add(id, entity) { + this.state.entities[id] = entity + this.state.ids.push(id) + } + + /** + * Remove an entity from the state + * @param {(string|number)} id The id of the entity to remove + */ + remove(id) { + delete this.state.entities[id] + this.state.ids.splice(this.state.ids.indexOf(id), 1) + this.state.actives.splice(this.state.ids.indexOf(id), 1) + } + + /** + * Update one entity of the state + * @param {(string|number)} id The id of the entity to update + * @param {Object} update The fields to update in the entity + */ + /* + updateOne(id, update) { + this.state.entities[id] = { + ...this.state.entities[id], + ...update + } + } + */ + + /** + * Activate one or several entity from the state + * @param {((string|number))} ids An id or a list of id to activate + */ + activate(id) { + this.state.actives.push(id) + this.event.emit('activate', id) + } + + /** + * Deactivate one or several entity from the state + * @param {(string|number))} ids An id or a list of id to deactivate + */ + deactivate(id) { + this.state.actives.splice(this.state.actives.indexOf(id), 1) + this.event.emit('deactivate', id) + } + + /////////// + // QUERY // + /////////// + + /** + * Get one entity + * @param {(string|number)} id The id of the entity to get + */ + getOne(id) { + return this.state.entities[id] + } + + /** + * Get many entities as an array + * @param {(string|number)[]} ids An array of id of entity to get + */ + getMany(ids) { + return ids.map(id => this.state.entities[id]) + } + + /** Get all the entities as an array */ + getAll() { + return this.state.ids.map(id => this.state.entities[id]) + } + + /** Get all active entities */ + getActives() { + return this.state.actives.map(id => this.state.entities[id]) + } + + //////////////// + // CONDITIONS // + //////////////// + + /** + * Is the entity active + * @param {(string|number)} id The id of the entity to check + */ + isActive(id) { + return this.state.actives.includes(id) + } + + /** + * Is this id inside the store + * @param {(string|number)} id The id of the entity to check + */ + hasEntity(id) { + return this.state.ids.includes(id) + } + + /** + * Is the state empty + * @param {(string|number)} id The id of the entity to check + */ + isEmpty() { + return this.state.ids.length === 0 + } +} + +/** + * Store the state of the stores into LocalStorage + * @param {Store[]} stores The list of stores to store into `localStorage` + */ +function localState(stores) { + stores.forEach(store => { + const name = store.name + store.on('newState', (state) => { + localStorage.setItem(name, JSON.stringify(state)) + }) + }) +} diff --git a/src/remixAppManager.js b/src/remixAppManager.js new file mode 100644 index 0000000000..0c6f27b4d8 --- /dev/null +++ b/src/remixAppManager.js @@ -0,0 +1,45 @@ +import { AppManagerApi } from 'remix-plugin' +import { EventEmitter } from 'events' + +export class RemixAppManager extends AppManagerApi { + + constructor (store) { + super(null) + this.store = store + this.event = new EventEmitter() + } + + doActivate (name) { + this.activateOne(name) + // temp + this.store.activate(name) + // promise ? + const entity = this.getEntity(name) + if (entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') { + this.event.emit('requestContainer', entity.profile, entity.api.render()) + } + } + + doDeactivate (name) { + this.deactivateOne(name) + // temp + this.store.deactivate(name) + // promise ? + const entity = this.getEntity(name) + if (entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') { + this.event.emit('removingItem', entity.profile) + } + } + + setActive (name, isActive) { + isActive ? this.store.activate(name) : this.store.deactivate(name) + } + + getEntity (entityName) { + return this.store.get(entityName) + } + + addEntity (entity) { + this.store.add(entity.profile.name, entity) + } +} \ No newline at end of file diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 2262b576ac..aa6afa5300 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -31,14 +31,7 @@ function UniversalDApp (registry) { UniversalDApp.prototype.profile = function () { return { - type: 'udapp', - methods: ['runTestTx', 'getAccounts', 'createVMAccount'] - } -} - -UniversalDApp.prototype.profile = function () { - return { - type: 'udapp', + name: 'Udapp', methods: ['runTestTx', 'getAccounts', 'createVMAccount'] } }