|
|
|
@ -81,7 +81,7 @@ class Terminal extends Plugin { |
|
|
|
|
scopedCommands.log(`> ${script}`) |
|
|
|
|
self._shell(script, scopedCommands, function (error, output) { |
|
|
|
|
if (error) scopedCommands.error(error) |
|
|
|
|
else scopedCommands.log(output) |
|
|
|
|
else if (output) scopedCommands.log(output) |
|
|
|
|
}) |
|
|
|
|
}, { activate: true }) |
|
|
|
|
function basicFilter (value, query) { try { return value.indexOf(query) !== -1 } catch (e) { return false } } |
|
|
|
@ -98,6 +98,26 @@ class Terminal extends Plugin { |
|
|
|
|
if (opts.shell) self._shell = opts.shell // ???
|
|
|
|
|
register(self) |
|
|
|
|
} |
|
|
|
|
onActivation () { |
|
|
|
|
this.on('scriptRunner', 'log', (msg) => { |
|
|
|
|
this.commands['log'].apply(this.commands, msg.data) |
|
|
|
|
}) |
|
|
|
|
this.on('scriptRunner', 'info', (msg) => { |
|
|
|
|
this.commands['info'].apply(this.commands, msg.data) |
|
|
|
|
}) |
|
|
|
|
this.on('scriptRunner', 'warn', (msg) => { |
|
|
|
|
this.commands['warn'].apply(this.commands, msg.data) |
|
|
|
|
}) |
|
|
|
|
this.on('scriptRunner', 'error', (msg) => { |
|
|
|
|
this.commands['error'].apply(this.commands, msg.data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
onDeactivation () { |
|
|
|
|
this.off('scriptRunner', 'log') |
|
|
|
|
this.off('scriptRunner', 'info') |
|
|
|
|
this.off('scriptRunner', 'warn') |
|
|
|
|
this.off('scriptRunner', 'error') |
|
|
|
|
} |
|
|
|
|
logHtml (html) { |
|
|
|
|
var command = this.commands['html'] |
|
|
|
|
if (typeof command === 'function') command(html) |
|
|
|
@ -124,6 +144,7 @@ class Terminal extends Plugin { |
|
|
|
|
${self._view.input} |
|
|
|
|
</div> |
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
self._view.icon = yo` |
|
|
|
|
<i onmouseenter=${hover} onmouseleave=${hover} onmousedown=${minimize} |
|
|
|
|
class="btn btn-secondary btn-sm align-items-center ${css.toggleTerminal} fas fa-angle-double-down" data-id="terminalToggleIcon"></i>` |
|
|
|
@ -659,17 +680,27 @@ class Terminal extends Plugin { |
|
|
|
|
} |
|
|
|
|
return self.commands[name] |
|
|
|
|
} |
|
|
|
|
_shell (script, scopedCommands, done) { // default shell
|
|
|
|
|
async _shell (script, scopedCommands, done) { // default shell
|
|
|
|
|
if (script.indexOf('remix:') === 0) { |
|
|
|
|
return done(null, 'This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.') |
|
|
|
|
} |
|
|
|
|
var self = this |
|
|
|
|
if (script.indexOf('remix.') === 0) { |
|
|
|
|
// we keep the old feature. This will basically only be called when the command is querying the "remix" object.
|
|
|
|
|
// for all the other case, we use the Code Executor plugin
|
|
|
|
|
var context = domTerminalFeatures(self, scopedCommands, self.blockchain) |
|
|
|
|
try { |
|
|
|
|
var cmds = vm.createContext(Object.assign(self._jsSandboxContext, context, self._jsSandboxRegistered)) |
|
|
|
|
var result = vm.runInContext(script, cmds) |
|
|
|
|
self._jsSandboxContext = Object.assign(cmds, context) |
|
|
|
|
done(null, result) |
|
|
|
|
return done(null, result) |
|
|
|
|
} catch (error) { |
|
|
|
|
return done(error.message) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
await this.call('scriptRunner', 'execute', script) |
|
|
|
|
done() |
|
|
|
|
} catch (error) { |
|
|
|
|
done(error.message) |
|
|
|
|
} |
|
|
|
|