|
|
@ -1,6 +1,7 @@ |
|
|
|
/* global Node, requestAnimationFrame */ |
|
|
|
/* global Node, requestAnimationFrame */ |
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
|
|
|
|
import * as remixBleach from '../../lib/remixBleach' |
|
|
|
|
|
|
|
|
|
|
|
var yo = require('yo-yo') |
|
|
|
var yo = require('yo-yo') |
|
|
|
var javascriptserialize = require('javascript-serialize') |
|
|
|
var javascriptserialize = require('javascript-serialize') |
|
|
@ -26,7 +27,7 @@ var ghostbar = yo`<div class=${css.ghostbar} bg-secondary></div>` |
|
|
|
const profile = { |
|
|
|
const profile = { |
|
|
|
displayName: 'Terminal', |
|
|
|
displayName: 'Terminal', |
|
|
|
name: 'terminal', |
|
|
|
name: 'terminal', |
|
|
|
methods: [], |
|
|
|
methods: ['log'], |
|
|
|
events: [], |
|
|
|
events: [], |
|
|
|
description: ' - ', |
|
|
|
description: ' - ', |
|
|
|
version: packageJson.version |
|
|
|
version: packageJson.version |
|
|
@ -113,6 +114,32 @@ class Terminal extends Plugin { |
|
|
|
this.off('scriptRunner', 'error') |
|
|
|
this.off('scriptRunner', 'error') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log (message) { |
|
|
|
|
|
|
|
var command = this.commands[message.type] |
|
|
|
|
|
|
|
if (typeof command === 'function') { |
|
|
|
|
|
|
|
if (typeof message.value === 'string' && message.type === 'html') { |
|
|
|
|
|
|
|
var el = document.createElement('div') |
|
|
|
|
|
|
|
el.innerHTML = remixBleach.sanitize(message.value, { |
|
|
|
|
|
|
|
list: [ |
|
|
|
|
|
|
|
'a', |
|
|
|
|
|
|
|
'b', |
|
|
|
|
|
|
|
'p', |
|
|
|
|
|
|
|
'em', |
|
|
|
|
|
|
|
'strong', |
|
|
|
|
|
|
|
'div', |
|
|
|
|
|
|
|
'span', |
|
|
|
|
|
|
|
'ul', |
|
|
|
|
|
|
|
'li', |
|
|
|
|
|
|
|
'ol', |
|
|
|
|
|
|
|
'hr' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
message.value = el |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
command(message.value) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logHtml (html) { |
|
|
|
logHtml (html) { |
|
|
|
var command = this.commands.html |
|
|
|
var command = this.commands.html |
|
|
|
if (typeof command === 'function') command(html) |
|
|
|
if (typeof command === 'function') command(html) |
|
|
@ -653,7 +680,11 @@ class Terminal extends Plugin { |
|
|
|
return function logger (args, scopedCommands, append) { |
|
|
|
return function logger (args, scopedCommands, append) { |
|
|
|
var types = args.filter(filterUndefined).map(type) |
|
|
|
var types = args.filter(filterUndefined).map(type) |
|
|
|
var values = javascriptserialize.apply(null, args.filter(filterUndefined)).map(function (val, idx) { |
|
|
|
var values = javascriptserialize.apply(null, args.filter(filterUndefined)).map(function (val, idx) { |
|
|
|
if (typeof args[idx] === 'string') val = args[idx] |
|
|
|
if (typeof args[idx] === 'string') { |
|
|
|
|
|
|
|
const el = document.createElement('div') |
|
|
|
|
|
|
|
el.innerHTML = args[idx].replace(/(\r\n|\n|\r)/gm, '<br>') |
|
|
|
|
|
|
|
val = el.children.length === 0 ? el.firstChild : el |
|
|
|
|
|
|
|
} |
|
|
|
if (types[idx] === 'element') val = jsbeautify.html(val) |
|
|
|
if (types[idx] === 'element') val = jsbeautify.html(val) |
|
|
|
return val |
|
|
|
return val |
|
|
|
}) |
|
|
|
}) |
|
|
|