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
a27b0ccd
Unverified
Commit
a27b0ccd
authored
Oct 11, 2018
by
yann300
Committed by
GitHub
Oct 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1539 from ethereum/addAPI
Add addProvider/removeProvider
parents
7c7f624e
28a41901
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
237 additions
and
6 deletions
+237
-6
bundle.js
src/app/plugin/bundle.js
+94
-0
plugin.md
src/app/plugin/plugin.md
+2
-0
pluginAPI.js
src/app/plugin/pluginAPI.js
+8
-0
pluginManager.js
src/app/plugin/pluginManager.js
+5
-1
run-tab.js
src/app/tabs/run-tab.js
+17
-0
bundle.js
test-browser/plugin/bundle.js
+94
-0
index.html
test-browser/plugin/index.html
+7
-5
plugin.js
test-browser/plugin/plugin.js
+10
-0
No files found.
src/app/plugin/bundle.js
0 → 100644
View file @
a27b0ccd
(
function
e
(
t
,
n
,
r
){
function
s
(
o
,
u
){
if
(
!
n
[
o
]){
if
(
!
t
[
o
]){
var
a
=
typeof
require
==
"function"
&&
require
;
if
(
!
u
&&
a
)
return
a
(
o
,
!
0
);
if
(
i
)
return
i
(
o
,
!
0
);
var
f
=
new
Error
(
"Cannot find module '"
+
o
+
"'"
);
throw
f
.
code
=
"MODULE_NOT_FOUND"
,
f
}
var
l
=
n
[
o
]
=
{
exports
:{}};
t
[
o
][
0
].
call
(
l
.
exports
,
function
(
e
){
var
n
=
t
[
o
][
1
][
e
];
return
s
(
n
?
n
:
e
)},
l
,
l
.
exports
,
e
,
t
,
n
,
r
)}
return
n
[
o
].
exports
}
var
i
=
typeof
require
==
"function"
&&
require
;
for
(
var
o
=
0
;
o
<
r
.
length
;
o
++
)
s
(
r
[
o
]);
return
s
})({
1
:[
function
(
require
,
module
,
exports
){
'use strict'
;
var
_createClass
=
function
()
{
function
defineProperties
(
target
,
props
)
{
for
(
var
i
=
0
;
i
<
props
.
length
;
i
++
)
{
var
descriptor
=
props
[
i
];
descriptor
.
enumerable
=
descriptor
.
enumerable
||
false
;
descriptor
.
configurable
=
true
;
if
(
"value"
in
descriptor
)
descriptor
.
writable
=
true
;
Object
.
defineProperty
(
target
,
descriptor
.
key
,
descriptor
);
}
}
return
function
(
Constructor
,
protoProps
,
staticProps
)
{
if
(
protoProps
)
defineProperties
(
Constructor
.
prototype
,
protoProps
);
if
(
staticProps
)
defineProperties
(
Constructor
,
staticProps
);
return
Constructor
;
};
}();
function
_classCallCheck
(
instance
,
Constructor
)
{
if
(
!
(
instance
instanceof
Constructor
))
{
throw
new
TypeError
(
"Cannot call a class as a function"
);
}
}
var
RemixExtension
=
function
()
{
function
RemixExtension
()
{
var
_this
=
this
;
_classCallCheck
(
this
,
RemixExtension
);
this
.
_notifications
=
{};
this
.
_pendingRequests
=
{};
this
.
_id
=
0
;
window
.
addEventListener
(
'message'
,
function
(
event
)
{
return
_this
.
_newMessage
(
event
);
},
false
);
}
_createClass
(
RemixExtension
,
[{
key
:
'listen'
,
value
:
function
listen
(
key
,
type
,
callback
)
{
if
(
!
this
.
_notifications
[
key
])
this
.
_notifications
[
key
]
=
{};
this
.
_notifications
[
key
][
type
]
=
callback
;
}
},
{
key
:
'call'
,
value
:
function
call
(
key
,
type
,
params
,
callback
)
{
this
.
_id
++
;
this
.
_pendingRequests
[
this
.
_id
]
=
callback
;
window
.
parent
.
postMessage
(
JSON
.
stringify
({
action
:
'request'
,
key
:
key
,
type
:
type
,
value
:
params
,
id
:
this
.
_id
}),
'*'
);
}
},
{
key
:
'_newMessage'
,
value
:
function
_newMessage
(
event
)
{
if
(
!
event
.
data
)
return
;
if
(
typeof
event
.
data
!==
'string'
)
return
;
var
msg
;
try
{
msg
=
JSON
.
parse
(
event
.
data
);
}
catch
(
e
)
{
return
console
.
log
(
'unable to parse data'
);
}
var
_msg
=
msg
,
action
=
_msg
.
action
,
key
=
_msg
.
key
,
type
=
_msg
.
type
,
value
=
_msg
.
value
;
if
(
action
===
'notification'
)
{
if
(
this
.
_notifications
[
key
]
&&
this
.
_notifications
[
key
][
type
])
{
this
.
_notifications
[
key
][
type
](
value
);
}
}
else
if
(
action
===
'response'
)
{
var
_msg2
=
msg
,
id
=
_msg2
.
id
,
error
=
_msg2
.
error
;
if
(
this
.
_pendingRequests
[
id
])
{
this
.
_pendingRequests
[
id
](
error
,
value
);
delete
this
.
_pendingRequests
[
id
];
}
}
}
}]);
return
RemixExtension
;
}();
if
(
window
)
window
.
RemixExtension
=
RemixExtension
;
if
(
module
&&
module
.
exports
)
module
.
exports
=
RemixExtension
;
},{}]},{},[
1
]);
src/app/plugin/plugin.md
View file @
a27b0ccd
...
...
@@ -26,6 +26,8 @@ plugin api
-
getProviderEndpoint
`@return {String} url`
-
updateTitle
`@param {String} title`
-
detectNetWork
`@return {Object} {name, id}`
-
addProvider
`@param {String} name, @param {String} url`
-
removeProvider
`@return {String} name`
### config
...
...
src/app/plugin/pluginAPI.js
View file @
a27b0ccd
...
...
@@ -26,6 +26,14 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
executionContext
.
detectNetwork
((
error
,
network
)
=>
{
cb
(
error
,
network
)
})
},
addProvider
:
(
mod
,
name
,
url
,
cb
)
=>
{
executionContext
.
addProvider
({
name
,
url
})
cb
()
},
removeProvider
:
(
mod
,
name
,
cb
)
=>
{
executionContext
.
removeProvider
(
name
)
cb
()
}
},
config
:
{
...
...
src/app/plugin/pluginManager.js
View file @
a27b0ccd
...
...
@@ -172,7 +172,11 @@ module.exports = class PluginManager {
data
.
value
.
push
((
error
,
result
)
=>
{
response
(
data
.
key
,
data
.
type
,
data
.
id
,
error
,
result
)
})
pluginAPI
[
data
.
key
][
data
.
type
].
apply
({},
data
.
value
)
if
(
pluginAPI
[
data
.
key
]
&&
pluginAPI
[
data
.
key
][
data
.
type
])
{
pluginAPI
[
data
.
key
][
data
.
type
].
apply
({},
data
.
value
)
}
else
{
response
(
data
.
key
,
data
.
type
,
data
.
id
,
`Endpoint
${
data
.
key
}
/
${
data
.
type
}
not present`
,
null
)
}
},
false
)
}
unregister
(
desc
)
{
...
...
src/app/tabs/run-tab.js
View file @
a27b0ccd
...
...
@@ -22,6 +22,7 @@ var css = require('./styles/run-tab-styles')
var
MultiParamManager
=
require
(
'../../multiParamManager'
)
var
modalDialog
=
require
(
'../ui/modaldialog'
)
var
CompilerAbstract
=
require
(
'../compiler/compiler-abstract'
)
var
tootip
=
require
(
'../ui/tooltip'
)
function
runTab
(
opts
,
localRegistry
)
{
/* -------------------------
...
...
@@ -639,6 +640,22 @@ function settings (container, self) {
instanceContainer
.
appendChild
(
self
.
_view
.
noInstancesText
)
})
executionContext
.
event
.
register
(
'addProvider'
,
(
network
)
=>
{
selectExEnv
.
appendChild
(
yo
`<option
title="Manually added environment:
${
network
.
url
}
"
value="
${
network
.
name
}
" name="executionContext">
${
network
.
name
}
</option>`
)
tootip
(
`
${
network
.
name
}
[
${
network
.
url
}
] added`
)
})
executionContext
.
event
.
register
(
'removeProvider'
,
(
name
)
=>
{
var
env
=
selectExEnv
.
querySelector
(
`option[value="
${
name
}
"]`
)
if
(
env
)
{
selectExEnv
.
removeChild
(
env
)
tootip
(
`
${
name
}
removed`
)
}
})
selectExEnv
.
addEventListener
(
'change'
,
function
(
event
)
{
let
context
=
selectExEnv
.
options
[
selectExEnv
.
selectedIndex
].
value
executionContext
.
executionContextChange
(
context
,
null
,
()
=>
{
...
...
test-browser/plugin/bundle.js
0 → 100644
View file @
a27b0ccd
(
function
e
(
t
,
n
,
r
){
function
s
(
o
,
u
){
if
(
!
n
[
o
]){
if
(
!
t
[
o
]){
var
a
=
typeof
require
==
"function"
&&
require
;
if
(
!
u
&&
a
)
return
a
(
o
,
!
0
);
if
(
i
)
return
i
(
o
,
!
0
);
var
f
=
new
Error
(
"Cannot find module '"
+
o
+
"'"
);
throw
f
.
code
=
"MODULE_NOT_FOUND"
,
f
}
var
l
=
n
[
o
]
=
{
exports
:{}};
t
[
o
][
0
].
call
(
l
.
exports
,
function
(
e
){
var
n
=
t
[
o
][
1
][
e
];
return
s
(
n
?
n
:
e
)},
l
,
l
.
exports
,
e
,
t
,
n
,
r
)}
return
n
[
o
].
exports
}
var
i
=
typeof
require
==
"function"
&&
require
;
for
(
var
o
=
0
;
o
<
r
.
length
;
o
++
)
s
(
r
[
o
]);
return
s
})({
1
:[
function
(
require
,
module
,
exports
){
'use strict'
;
var
_createClass
=
function
()
{
function
defineProperties
(
target
,
props
)
{
for
(
var
i
=
0
;
i
<
props
.
length
;
i
++
)
{
var
descriptor
=
props
[
i
];
descriptor
.
enumerable
=
descriptor
.
enumerable
||
false
;
descriptor
.
configurable
=
true
;
if
(
"value"
in
descriptor
)
descriptor
.
writable
=
true
;
Object
.
defineProperty
(
target
,
descriptor
.
key
,
descriptor
);
}
}
return
function
(
Constructor
,
protoProps
,
staticProps
)
{
if
(
protoProps
)
defineProperties
(
Constructor
.
prototype
,
protoProps
);
if
(
staticProps
)
defineProperties
(
Constructor
,
staticProps
);
return
Constructor
;
};
}();
function
_classCallCheck
(
instance
,
Constructor
)
{
if
(
!
(
instance
instanceof
Constructor
))
{
throw
new
TypeError
(
"Cannot call a class as a function"
);
}
}
var
RemixExtension
=
function
()
{
function
RemixExtension
()
{
var
_this
=
this
;
_classCallCheck
(
this
,
RemixExtension
);
this
.
_notifications
=
{};
this
.
_pendingRequests
=
{};
this
.
_id
=
0
;
window
.
addEventListener
(
'message'
,
function
(
event
)
{
return
_this
.
_newMessage
(
event
);
},
false
);
}
_createClass
(
RemixExtension
,
[{
key
:
'listen'
,
value
:
function
listen
(
key
,
type
,
callback
)
{
if
(
!
this
.
_notifications
[
key
])
this
.
_notifications
[
key
]
=
{};
this
.
_notifications
[
key
][
type
]
=
callback
;
}
},
{
key
:
'call'
,
value
:
function
call
(
key
,
type
,
params
,
callback
)
{
this
.
_id
++
;
this
.
_pendingRequests
[
this
.
_id
]
=
callback
;
window
.
parent
.
postMessage
(
JSON
.
stringify
({
action
:
'request'
,
key
:
key
,
type
:
type
,
value
:
params
,
id
:
this
.
_id
}),
'*'
);
}
},
{
key
:
'_newMessage'
,
value
:
function
_newMessage
(
event
)
{
if
(
!
event
.
data
)
return
;
if
(
typeof
event
.
data
!==
'string'
)
return
;
var
msg
;
try
{
msg
=
JSON
.
parse
(
event
.
data
);
}
catch
(
e
)
{
return
console
.
log
(
'unable to parse data'
);
}
var
_msg
=
msg
,
action
=
_msg
.
action
,
key
=
_msg
.
key
,
type
=
_msg
.
type
,
value
=
_msg
.
value
;
if
(
action
===
'notification'
)
{
if
(
this
.
_notifications
[
key
]
&&
this
.
_notifications
[
key
][
type
])
{
this
.
_notifications
[
key
][
type
](
value
);
}
}
else
if
(
action
===
'response'
)
{
var
_msg2
=
msg
,
id
=
_msg2
.
id
,
error
=
_msg2
.
error
;
if
(
this
.
_pendingRequests
[
id
])
{
this
.
_pendingRequests
[
id
](
error
,
value
);
delete
this
.
_pendingRequests
[
id
];
}
}
}
}]);
return
RemixExtension
;
}();
if
(
window
)
window
.
RemixExtension
=
RemixExtension
;
if
(
module
&&
module
.
exports
)
module
.
exports
=
RemixExtension
;
},{}]},{},[
1
]);
test-browser/plugin/index.html
View file @
a27b0ccd
...
...
@@ -44,11 +44,13 @@
<input
type=
"button"
id=
"testcontractcreation"
>
oraclize contract creation
</input>
<br>
<input
type=
"button"
id=
"testaccountcreation"
>
account creation
</input>
<br>
<input
type=
"button"
id=
"testchangetitle"
>
change title
</input>
<br>
<input
type=
"button"
id=
"setcontentof"
>
setcontentof
</input>
<br>
<input
type=
"button"
id=
"getcontentof"
>
getcontentof
</input>
<br>
<input
type=
"button"
id=
"getcurrent"
>
getcurrent
</input>
<br>
<input
type=
"button"
id=
"sethighlight"
>
sethighlight
</input>
<br>
<input
type=
"button"
id=
"getfilesfrompath"
>
getfilesfrompath
</input>
<br>
<input
type=
"button"
id=
"setcontentof"
>
set content of
</input>
<br>
<input
type=
"button"
id=
"getcontentof"
>
get content of
</input>
<br>
<input
type=
"button"
id=
"getcurrent"
>
get current
</input>
<br>
<input
type=
"button"
id=
"sethighlight"
>
set highlight
</input>
<br>
<input
type=
"button"
id=
"getfilesfrompath"
>
get files from path
</input>
<br>
<input
type=
"button"
id=
"addnetwork"
>
add network
</input>
<br>
<input
type=
"button"
id=
"removenetwork"
>
remove network
</input>
<br>
<br>
<div
id=
'compilationdata'
></div>
</body>
...
...
test-browser/plugin/plugin.js
View file @
a27b0ccd
...
...
@@ -78,4 +78,14 @@ window.onload = function () {
extension
.
call
(
'editor'
,
'getFilesFromPath'
,
[
document
.
getElementById
(
'filename'
).
value
],
function
(
error
,
result
)
{
console
.
log
(
error
,
result
)
})
})
document
.
querySelector
(
'input#addnetwork'
).
addEventListener
(
'click'
,
function
()
{
extension
.
call
(
'app'
,
'addProvider'
,
[
document
.
getElementById
(
'filename'
).
value
,
document
.
getElementById
(
'valuetosend'
).
value
],
function
(
error
,
result
)
{
console
.
log
(
error
,
result
)
})
})
document
.
querySelector
(
'input#removenetwork'
).
addEventListener
(
'click'
,
function
()
{
extension
.
call
(
'app'
,
'removeProvider'
,
[
document
.
getElementById
(
'filename'
).
value
],
function
(
error
,
result
)
{
console
.
log
(
error
,
result
)
})
})
}
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