From 35ff5dc710d9e92a7803a3ab3f66c1fc35bf516d Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Wed, 25 Sep 2024 13:58:40 +0000 Subject: [PATCH] main: work in progress [might break] --- com/isoterminal.js | 1 + com/isoterminal/feat/jsconsole.js | 10 +++++---- com/isoterminal/feat/xterm.js | 34 +++++++++++++++---------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/com/isoterminal.js b/com/isoterminal.js index a2bea00..c4ab4fe 100644 --- a/com/isoterminal.js +++ b/com/isoterminal.js @@ -151,6 +151,7 @@ if( typeof AFRAME != 'undefined '){ animation:fade 1000ms infinite; -webkit-animation:fade 1000ms infinite; } + ` }, diff --git a/com/isoterminal/feat/jsconsole.js b/com/isoterminal/feat/jsconsole.js index f8f73bb..fcb64c1 100644 --- a/com/isoterminal/feat/jsconsole.js +++ b/com/isoterminal/feat/jsconsole.js @@ -39,14 +39,16 @@ ISOTerminal.addEventListener('emulator-started', function(){ }) window.addEventListener('error', function(event) { - console.error(event.filename+":"+event.lineno+":"+event.colno) - console.error(event.message); - console.error(event.error); + if( event.filename ){ + console.error(event.filename+":"+event.lineno+":"+event.colno) + console.error(event.message); + console.error(event.error); + }else console.error(event) }); window.addEventListener('unhandledrejection', function(event) { console.error('Unhandled promise rejection:') - console.error(event.reason); + console.error(event); }); // enable/disable logging file (echo 1 > mnt/console.tty) diff --git a/com/isoterminal/feat/xterm.js b/com/isoterminal/feat/xterm.js index 9e7d265..592f559 100644 --- a/com/isoterminal/feat/xterm.js +++ b/com/isoterminal/feat/xterm.js @@ -30,36 +30,36 @@ ISOTerminal.prototype.xtermInit = function(){ // xterm relies on requestAnimationFrame (which does not called in immersive mode) let _window = term._core._coreBrowserService._window - if( !_window.requestAnimationFrameAFRAME ){ // patch the planet! + if( !_window._XRSH_proxied ){ // patch the planet! -// _window.requestAnimationFrameAFRAME = function(cb){ -// if( term.tid != null ) clearTimeout(term.tid) -// term.tid = setTimeout( function(){ -// console.log("render") -// cb() -// term.tid = null -// },100) -// } - _window.requestAnimationFrameAFRAME = - AFRAME.utils.throttleLeadingAndTrailing( function(cb){ - cb() - },150 ) + //_window.requestAnimationFrameAFRAME = function(cb){ + // if( term.tid != null ) clearTimeout(term.tid) + // term.tid = setTimeout( function(){ + // console.log("render") + // cb() + // term.tid = null + // },100) + //} + const requestAnimationFrameAFRAME = AFRAME.utils.throttleLeadingAndTrailing( + function(cb){ cb() },150 + ) // we proxy the _window object of xterm, and reroute // requestAnimationFrame to requestAnimationFrameAFRAME - _window = new Proxy(_window,{ + _window_new = new Proxy(_window,{ get(me,k){ + if( k == '_XRSH_proxied' ) return true if( k == 'requestAnimationFrame' ){ - return me.requestAnimationFrameAFRAME + return requestAnimationFrameAFRAME.bind(me) } - return me[k] + return typeof me[k] == 'function' ? me[k].bind(me) : me[k] }, set(me,k,v){ me[k] = v return true } }) - term._core._coreBrowserService._window = _window + term._core._coreBrowserService._window = _window_new } })