Websocket plugin activation

pull/262/head
ioedeveloper 5 years ago committed by yann300
parent a266f11438
commit 791f19d640
  1. 23
      src/app.js
  2. 14
      src/app/files/fileManager.js
  3. 79
      src/app/files/remixDProvider.js
  4. 2
      src/app/panels/main-view.js

@ -42,7 +42,7 @@ import { basicLogo } from './app/ui/svgLogo'
import { RunTab, makeUdapp } from './app/udapp' import { RunTab, makeUdapp } from './app/udapp'
import PanelsResize from './lib/panels-resize' import PanelsResize from './lib/panels-resize'
import { Engine } from '@remixproject/engine' import { Engine, WebsocketPlugin } from '@remixproject/engine'
import { RemixAppManager } from './remixAppManager' import { RemixAppManager } from './remixAppManager'
import { FramingService } from './framingService' import { FramingService } from './framingService'
import { MainView } from './app/panels/main-view' import { MainView } from './app/panels/main-view'
@ -146,14 +146,21 @@ class App {
self._components.filesProviders['browser'] = new FileProvider('browser') self._components.filesProviders['browser'] = new FileProvider('browser')
registry.put({api: self._components.filesProviders['browser'], name: 'fileproviders/browser'}) registry.put({api: self._components.filesProviders['browser'], name: 'fileproviders/browser'})
var remixd = new Remixd(65520) self._components.remixd = new WebsocketPlugin({
registry.put({api: remixd, name: 'remixd'}) name: 'remixd-websocket',
remixd.event.register('system', (message) => { methods: ['get'],
if (message.error) toolTip(message.error) url: 'ws://127.0.0.1:65520'
}) })
self._components.filesProviders['localhost'] = new RemixDProvider(remixd) console.log('remixd: ', self._components.remixd)
// registry.put({api: remixd, name: 'remixd'})
// remixd.event.register('system', (message) => {
// if (message.error) toolTip(message.error)
// })
self._components.filesProviders['localhost'] = new RemixDProvider(self._components.remixd)
registry.put({api: self._components.filesProviders['localhost'], name: 'fileproviders/localhost'}) registry.put({api: self._components.filesProviders['localhost'], name: 'fileproviders/localhost'})
console.log('self._components.filesProviders: ', self._components.filesProviders)
registry.put({api: self._components.filesProviders, name: 'fileproviders'}) registry.put({api: self._components.filesProviders, name: 'fileproviders'})
migrateFileSystem(self._components.filesProviders['browser']) migrateFileSystem(self._components.filesProviders['browser'])
@ -304,6 +311,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl)) makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl))
const contextualListener = new ContextualListener({editor}) const contextualListener = new ContextualListener({editor})
const { remixd } = self._components
engine.register([ engine.register([
contentImport, contentImport,
@ -317,7 +325,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
contextualListener, contextualListener,
terminal, terminal,
web3Provider, web3Provider,
fetchAndCompile fetchAndCompile,
remixd
]) ])
// LAYOUT & SYSTEM VIEWS // LAYOUT & SYSTEM VIEWS

@ -266,13 +266,13 @@ class FileManager extends Plugin {
localhostExplorer: this._components.registry.get('fileproviders/localhost').api, localhostExplorer: this._components.registry.get('fileproviders/localhost').api,
filesProviders: this._components.registry.get('fileproviders').api filesProviders: this._components.registry.get('fileproviders').api
} }
this._deps.browserExplorer.event.register('fileChanged', (path) => { this.fileChangedEvent(path) }) // this._deps.browserExplorer.event.register('fileChanged', (path) => { this.fileChangedEvent(path) })
this._deps.browserExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) }) // this._deps.browserExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) })
this._deps.localhostExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) }) // this._deps.localhostExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) })
this._deps.browserExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) }) // this._deps.browserExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) })
this._deps.localhostExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) }) // this._deps.localhostExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) })
this._deps.localhostExplorer.event.register('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) }) // this._deps.localhostExplorer.event.register('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) }) // this._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this.getCurrentFile = this.file this.getCurrentFile = this.file
this.getFile = this.readFile this.getFile = this.readFile
this.getFolder = this.readdir this.getFolder = this.readdir

@ -15,39 +15,39 @@ module.exports = class RemixDProvider {
this.filesContent = {} this.filesContent = {}
this.files = {} this.files = {}
var remixdEvents = ['connecting', 'connected', 'errored', 'closed'] // var remixdEvents = ['connecting', 'connected', 'errored', 'closed']
remixdEvents.forEach((value) => { // remixdEvents.forEach((value) => {
remixd.event.register(value, (event) => { // remixd.event.register(value, (event) => {
this.event.trigger(value, [event]) // this.event.trigger(value, [event])
}) // })
}) // })
remixd.event.register('notified', (data) => { // remixd.event.register('notified', (data) => {
if (data.scope === 'sharedfolder') { // if (data.scope === 'sharedfolder') {
if (data.name === 'created') { // if (data.name === 'created') {
this.init(() => { // this.init(() => {
this.event.trigger('fileAdded', [this.type + '/' + data.value.path, data.value.isReadOnly, data.value.isFolder]) // this.event.trigger('fileAdded', [this.type + '/' + data.value.path, data.value.isReadOnly, data.value.isFolder])
}) // })
} else if (data.name === 'removed') { // } else if (data.name === 'removed') {
this.init(() => { // this.init(() => {
this.event.trigger('fileRemoved', [this.type + '/' + data.value.path]) // this.event.trigger('fileRemoved', [this.type + '/' + data.value.path])
}) // })
} else if (data.name === 'changed') { // } else if (data.name === 'changed') {
this._remixd.call('sharedfolder', 'get', {path: data.value}, (error, content) => { // this._remixd.call('sharedfolder', 'get', {path: data.value}, (error, content) => {
if (error) { // if (error) {
console.log(error) // console.log(error)
} else { // } else {
var path = this.type + '/' + data.value // var path = this.type + '/' + data.value
this.filesContent[path] = content // this.filesContent[path] = content
this.event.trigger('fileExternallyChanged', [path, content]) // this.event.trigger('fileExternallyChanged', [path, content])
} // }
}) // })
} else if (data.name === 'rootFolderChanged') { // } else if (data.name === 'rootFolderChanged') {
// new path has been set, we should reset // // new path has been set, we should reset
this.event.trigger('folderAdded', [this.type + '/']) // this.event.trigger('folderAdded', [this.type + '/'])
} // }
} // }
}) // })
} }
isConnected () { isConnected () {
@ -61,14 +61,11 @@ module.exports = class RemixDProvider {
} }
init (cb) { init (cb) {
this._remixd.ensureSocket((error) => { // this._remixd.call('remixd', 'folderIsReadOnly', {}, (error, result) => {
if (error) return cb(error) // console.log('result -> folderIsReadOnly: ', result)
this._isReady = !error // this._readOnlyMode = result
this._remixd.call('sharedfolder', 'folderIsReadOnly', {}, (error, result) => { // cb(error)
this._readOnlyMode = result // })
cb(error)
})
})
} }
// @TODO: refactor all `this._remixd.call(....)` uses into `this.remixd[api](...)` // @TODO: refactor all `this._remixd.call(....)` uses into `this.remixd[api](...)`

@ -34,7 +34,7 @@ export class MainView {
this.init() this.init()
} }
showApp (name) { showApp (name) {
this.fileManager.unselectCurrentFile() // this.fileManager.unselectCurrentFile()
this.mainPanel.showContent(name) this.mainPanel.showContent(name)
this._view.editor.style.display = 'none' this._view.editor.style.display = 'none'
this._components.contextView.hide() this._components.contextView.hide()

Loading…
Cancel
Save