diff --git a/com/isoterminal/feat/jsconsole.js b/com/isoterminal/feat/jsconsole.js index cc393a0..c5ea3fa 100644 --- a/com/isoterminal/feat/jsconsole.js +++ b/com/isoterminal/feat/jsconsole.js @@ -3,7 +3,7 @@ ISOTerminal.prototype.redirectConsole = function(handler){ const dir = console.dir; const err = console.error; const warn = console.warn; - const addLineFeeds = (str) => str.replace(/\n/g,"\n\r") + const addLineFeeds = (str) => typeof str == 'string' ? str.replace(/\n/g,"\n\r") : str console.log = (...args)=>{ const textArg = args[0]; @@ -34,9 +34,10 @@ ISOTerminal.prototype.enableConsole = function(opts){ opts = opts || {stdout:false} this.redirectConsole( (str,prefix) => { + let _str = typeof str == 'string' ? str : JSON.stringify(str) let finalStr = ""; prefix = prefix ? prefix+' ' : '' - str.trim().split("\n").map( (line) => { + _str.trim().split("\n").map( (line) => { finalStr += `${opts.stdout ? '' : "\x1b[38;5;165m/dev/browser: \x1b[0m"}`+prefix+line+'\n' }) if( opts.stdout ){ diff --git a/com/isoterminal/feat/pastedrop.js b/com/isoterminal/feat/pastedrop.js index ca34864..ed4ecc0 100644 --- a/com/isoterminal/feat/pastedrop.js +++ b/com/isoterminal/feat/pastedrop.js @@ -17,7 +17,8 @@ if( typeof emulator != 'undefined' ){ ISOTerminal.prototype.pasteFile = async function(data){ const {type,item,pastedText} = data if( pastedText){ - this.pasteWriteFile( this.convert.toUint8Array(pastedText) ,type, null, true) + // the terminal handles this (pastes text) + // this.pasteWriteFile( this.convert.toUint8Array(pastedText) ,type, null, true) }else{ const file = item.getAsFile(); const reader = new FileReader(); @@ -35,8 +36,9 @@ if( typeof emulator != 'undefined' ){ const el = aEntity.el.dom.querySelector('#pastedrop') // upload input el.addEventListener('change', (e) => { const file = el.files[0]; - const item = {...file, getAsFile: () => file } - this.el.emit('pasteFile', { item, type: file.type }); + const item = {...file, getAsFile: () => file } // pasteFile-event works with File objets + const data = { item, type: file.type } + this.emit( 'pasteFile', data, "worker" ) // impersonate as worker (as worker cannot handle File objet) }) }