Websocket plugin activation

pull/11/head
ioedeveloper 5 years ago
parent d80cc48b14
commit e23439df4e
  1. 23
      apps/remix-ide/src/app.js
  2. 14
      apps/remix-ide/src/app/files/fileManager.js
  3. 79
      apps/remix-ide/src/app/files/remixDProvider.js
  4. 2
      apps/remix-ide/src/app/panels/main-view.js

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

@ -266,13 +266,13 @@ class FileManager extends Plugin {
localhostExplorer: this._components.registry.get('fileproviders/localhost').api,
filesProviders: this._components.registry.get('fileproviders').api
}
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.localhostExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) })
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('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
// 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.localhostExplorer.event.register('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) })
// 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('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
// this._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this.getCurrentFile = this.file
this.getFile = this.readFile
this.getFolder = this.readdir

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

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

Loading…
Cancel
Save