Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b858ce64
Commit
b858ce64
authored
Jun 08, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Websocket client requests
parent
e2e9b67c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
65 deletions
+84
-65
index.js
apps/remix-ide/embark/index.js
+1
-1
app.js
apps/remix-ide/src/app.js
+7
-7
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+59
-48
remixd-handle.js
apps/remix-ide/src/app/files/remixd-handle.js
+17
-9
No files found.
apps/remix-ide/embark/index.js
View file @
b858ce64
...
@@ -13,7 +13,7 @@ const DEFAULT_OPTIONS = {
...
@@ -13,7 +13,7 @@ const DEFAULT_OPTIONS = {
module
.
exports
=
(
embark
)
=>
{
module
.
exports
=
(
embark
)
=>
{
// plugin options
// plugin options
const
readOnly
=
embark
.
pluginConfig
.
readOnly
||
false
const
readOnly
=
embark
.
pluginConfig
.
readOnly
||
false
const
{
protocol
,
host
,
port
}
=
merge
.
recursive
(
DEFAULT_OPTIONS
,
embark
.
pluginConfig
.
remixIde
)
const
{
protocol
,
host
,
port
}
=
merge
.
recursive
(
DEFAULT_OPTIONS
,
embark
.
pluginConfig
.
remixIde
)
// globals
// globals
const
remixIdeUrl
=
`
${
protocol
}
://
${
host
}
`
+
`
${
port
?
`:
${
port
}
`
:
''
}
`
const
remixIdeUrl
=
`
${
protocol
}
://
${
host
}
`
+
`
${
port
?
`:
${
port
}
`
:
''
}
`
...
...
apps/remix-ide/src/app.js
View file @
b858ce64
...
@@ -5,7 +5,7 @@ var csjs = require('csjs-inject')
...
@@ -5,7 +5,7 @@ var csjs = require('csjs-inject')
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
var
registry
=
require
(
'./global/registry'
)
var
registry
=
require
(
'./global/registry'
)
var
Remixd
=
require
(
'./lib/remixd'
)
//
var Remixd = require('./lib/remixd')
var
loadFileFromParent
=
require
(
'./loadFilesFromParent'
)
var
loadFileFromParent
=
require
(
'./loadFilesFromParent'
)
var
{
OffsetToLineColumnConverter
}
=
require
(
'./lib/offsetToLineColumnConverter'
)
var
{
OffsetToLineColumnConverter
}
=
require
(
'./lib/offsetToLineColumnConverter'
)
var
QueryParams
=
require
(
'./lib/query-params'
)
var
QueryParams
=
require
(
'./lib/query-params'
)
...
@@ -147,13 +147,13 @@ class App {
...
@@ -147,13 +147,13 @@ 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
)
//
var remixd = new Remixd(65520)
registry
.
put
({
api
:
remixd
,
name
:
'remixd'
})
//
registry.put({api: remixd, name: 'remixd'})
remixd
.
event
.
register
(
'system'
,
(
message
)
=>
{
//
remixd.event.register('system', (message) => {
if
(
message
.
error
)
toolTip
(
message
.
error
)
//
if (message.error) toolTip(message.error)
})
//
})
self
.
_components
.
filesProviders
[
'localhost'
]
=
new
RemixDProvider
(
remixd
,
self
.
appManager
)
self
.
_components
.
filesProviders
[
'localhost'
]
=
new
RemixDProvider
(
self
.
appManager
)
registry
.
put
({
api
:
self
.
_components
.
filesProviders
[
'localhost'
],
name
:
'fileproviders/localhost'
})
registry
.
put
({
api
:
self
.
_components
.
filesProviders
[
'localhost'
],
name
:
'fileproviders/localhost'
})
registry
.
put
({
api
:
self
.
_components
.
filesProviders
,
name
:
'fileproviders'
})
registry
.
put
({
api
:
self
.
_components
.
filesProviders
,
name
:
'fileproviders'
})
...
...
apps/remix-ide/src/app/files/remixDProvider.js
View file @
b858ce64
...
@@ -3,11 +3,10 @@ var EventManager = require('../../lib/events')
...
@@ -3,11 +3,10 @@ var EventManager = require('../../lib/events')
var
pathtool
=
require
(
'path'
)
var
pathtool
=
require
(
'path'
)
module
.
exports
=
class
RemixDProvider
{
module
.
exports
=
class
RemixDProvider
{
constructor
(
remixd
,
appManager
)
{
constructor
(
appManager
)
{
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
this
.
_remixd
=
remixd
this
.
_appManager
=
appManager
this
.
_appManager
=
appManager
this
.
remixd
=
remixapi
(
remixd
,
this
)
this
.
remixd
=
remixapi
(
appManager
,
this
)
this
.
type
=
'localhost'
this
.
type
=
'localhost'
this
.
error
=
{
'EEXIST'
:
'File already exists'
}
this
.
error
=
{
'EEXIST'
:
'File already exists'
}
this
.
_isReady
=
false
this
.
_isReady
=
false
...
@@ -16,39 +15,39 @@ module.exports = class RemixDProvider {
...
@@ -16,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
.
_appManager
.
call
(
'remixd'
,
'get'
,
{
path
:
data
.
value
},
(
error
,
content
)
=>
{
//
this._appManager.call('remixd', '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,10 +60,15 @@ module.exports = class RemixDProvider {
...
@@ -61,10 +60,15 @@ module.exports = class RemixDProvider {
}
}
async
init
(
cb
)
{
async
init
(
cb
)
{
await
this
.
_appManager
.
call
(
'remixd'
,
'sharedFolder'
,
{
currentSharedFolder
})
this
.
_appManager
.
call
(
'remixd'
,
'folderIsReadOnly'
,
{}).
then
((
result
)
=>
{
this
.
_isReady
=
true
this
.
_isReady
=
true
this
.
_readOnlyMode
=
await
this
.
_appManager
.
call
(
'remixd'
,
'folderIsReadOnly'
,
{})
this
.
_readOnlyMode
=
result
console
.
log
(
'this._readOnlyMode: '
,
this
.
_readOnlyMode
)
console
.
log
(
'this._readOnlyMode: '
,
this
.
_readOnlyMode
)
cb
()
cb
&&
cb
()
}).
catch
((
error
)
=>
{
cb
&&
cb
(
error
)
})
}
}
// @TODO: refactor all `this._remixd.call(....)` uses into `this.remixd[api](...)`
// @TODO: refactor all `this._remixd.call(....)` uses into `this.remixd[api](...)`
...
@@ -79,10 +83,12 @@ module.exports = class RemixDProvider {
...
@@ -79,10 +83,12 @@ module.exports = class RemixDProvider {
async
exists
(
path
,
cb
)
{
async
exists
(
path
,
cb
)
{
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
callId
=
await
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
const
result
=
await
this
.
_appManager
.
receiveResponse
(
callId
)
return
cb
(
null
,
result
)
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
}).
then
((
result
)
=>
{
return
cb
&&
cb
(
null
,
result
)
}).
catch
((
error
)
=>
{
return
cb
&&
cb
(
error
)
})
}
}
getNormalizedName
(
path
)
{
getNormalizedName
(
path
)
{
...
@@ -190,33 +196,38 @@ module.exports = class RemixDProvider {
...
@@ -190,33 +196,38 @@ module.exports = class RemixDProvider {
}
}
}
}
function
remixapi
(
remixd
,
self
)
{
function
remixapi
(
appManager
,
self
)
{
const
read
=
(
path
,
callback
)
=>
{
const
read
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
remixd
.
call
(
'remixd'
,
'get'
,
{
path
},
(
error
,
content
)
=>
callback
(
error
,
content
))
appManager
.
call
(
'remixd'
,
'get'
,
{
path
},
(
error
,
content
)
=>
callback
(
error
,
content
))
}
}
const
write
=
(
path
,
content
,
callback
)
=>
{
const
write
=
(
path
,
content
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
remixd
.
call
(
'remixd'
,
'set'
,
{
path
,
content
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'set'
,
{
path
,
content
},
(
error
,
result
)
=>
callback
(
error
,
result
))
}
}
const
rename
=
(
path
,
newpath
,
callback
)
=>
{
const
rename
=
(
path
,
newpath
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
remixd
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
path
,
newPath
:
newpath
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
path
,
newPath
:
newpath
},
(
error
,
result
)
=>
callback
(
error
,
result
))
}
}
const
remove
=
(
path
,
callback
)
=>
{
const
remove
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
remixd
.
call
(
'remixd'
,
'remove'
,
{
path
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'remove'
,
{
path
},
(
error
,
result
)
=>
callback
(
error
,
result
))
}
}
const
dir
=
(
path
,
callback
)
=>
{
const
dir
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
remixd
.
call
(
'remixd'
,
'resolveDirectory'
,
{
path
},
(
error
,
filesList
)
=>
callback
(
error
,
filesList
))
appManager
.
call
(
'remixd'
,
'resolveDirectory'
,
{
path
}).
then
((
filesList
)
=>
{
console
.
log
(
'filesList: '
,
filesList
)
callback
(
null
,
filesList
)
}).
catch
((
error
)
=>
{
callback
(
error
)
})
}
}
const
exit
=
()
=>
{
remixd
.
close
()
}
const
exit
=
()
=>
{
remixd
.
close
()
}
const
api
=
{
read
,
write
,
rename
,
remove
,
dir
,
exit
,
event
:
remixd
.
event
}
const
api
=
{
read
,
write
,
rename
,
remove
,
dir
,
exit
,
event
:
self
.
event
}
return
api
return
api
}
}
apps/remix-ide/src/app/files/remixd-handle.js
View file @
b858ce64
...
@@ -21,7 +21,7 @@ var css = csjs`
...
@@ -21,7 +21,7 @@ var css = csjs`
const
profile
=
{
const
profile
=
{
name
:
'remixd'
,
name
:
'remixd'
,
url
:
'ws://127.0.0.1:65520'
,
url
:
'ws://127.0.0.1:65520'
,
methods
:
[
'folderIsReadOnly'
],
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
],
events
:
[],
events
:
[],
description
:
'Using Remixd daemon, allow to access file system'
,
description
:
'Using Remixd daemon, allow to access file system'
,
kind
:
'other'
,
kind
:
'other'
,
...
@@ -43,8 +43,7 @@ export class RemixdHandle extends WebsocketPlugin {
...
@@ -43,8 +43,7 @@ export class RemixdHandle extends WebsocketPlugin {
})
})
}
}
async
activate
()
{
activate
()
{
await
super
.
activate
()
this
.
connectToLocalhost
()
this
.
connectToLocalhost
()
}
}
...
@@ -58,7 +57,7 @@ export class RemixdHandle extends WebsocketPlugin {
...
@@ -58,7 +57,7 @@ export class RemixdHandle extends WebsocketPlugin {
*
*
* @param {String} txHash - hash of the transaction
* @param {String} txHash - hash of the transaction
*/
*/
connectToLocalhost
()
{
async
connectToLocalhost
()
{
let
connection
=
(
error
)
=>
{
let
connection
=
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -68,13 +67,12 @@ export class RemixdHandle extends WebsocketPlugin {
...
@@ -68,13 +67,12 @@ export class RemixdHandle extends WebsocketPlugin {
)
)
this
.
canceled
()
this
.
canceled
()
}
else
{
}
else
{
this
.
locahostProvider
.
init
()
this
.
fileSystemExplorer
.
ensureRoot
()
this
.
fileSystemExplorer
.
ensureRoot
()
}
}
}
}
if
(
this
.
locahostProvider
.
isConnected
())
{
if
(
this
.
locahostProvider
.
isConnected
())
{
this
.
locahostProvider
.
close
((
error
)
=>
{
this
.
deactivate
()
if
(
error
)
console
.
log
(
error
)
})
}
else
if
(
!
isElectron
())
{
}
else
if
(
!
isElectron
())
{
// warn the user only if he/she is in the browser context
// warn the user only if he/she is in the browser context
modalDialog
(
modalDialog
(
...
@@ -82,7 +80,12 @@ export class RemixdHandle extends WebsocketPlugin {
...
@@ -82,7 +80,12 @@ export class RemixdHandle extends WebsocketPlugin {
remixdDialog
(),
remixdDialog
(),
{
label
:
'Connect'
,
{
label
:
'Connect'
,
fn
:
()
=>
{
fn
:
()
=>
{
this
.
locahostProvider
.
init
((
error
)
=>
connection
(
error
))
try
{
super
.
activate
()
setTimeout
(()
=>
{
connection
()
},
3000
)
}
catch
(
error
)
{
connection
(
error
)
}
}
}
},
},
{
label
:
'Cancel'
,
{
label
:
'Cancel'
,
...
@@ -92,7 +95,12 @@ export class RemixdHandle extends WebsocketPlugin {
...
@@ -92,7 +95,12 @@ export class RemixdHandle extends WebsocketPlugin {
}
}
)
)
}
else
{
}
else
{
this
.
locahostProvider
.
init
((
error
)
=>
connection
(
error
))
try
{
super
.
activate
()
setTimeout
(()
=>
{
connection
()
},
3000
)
}
catch
(
error
)
{
connection
(
error
)
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment