Compare commits

..

No commits in common. "4f83e1af0b6d713e06642479190c4f18fe2631cd" and "9aff2133a076315899f756aec87067011be743e4" have entirely different histories.

16 changed files with 228 additions and 1798 deletions

View File

@ -4,8 +4,6 @@ AFRAME.registerComponent('codemirror', {
schema: { schema: {
file: { type:"string"}, file: { type:"string"},
term: { type:"selector", default: "[isoterminal]" }, term: { type:"selector", default: "[isoterminal]" },
width: { type:"number", default:900},
height: { type:"number", default:700},
}, },
init: function () { init: function () {
@ -14,7 +12,7 @@ AFRAME.registerComponent('codemirror', {
if( this.data.file && this.data.file[0] != '/'){ if( this.data.file && this.data.file[0] != '/'){
this.data.file = "root/"+this.data.file this.data.file = "root/"+this.data.file
} }
this.isoterminal = this.data.term.components.isoterminal.term this.isoterminal = this.data.term.components.isoterminal.isoterminal
//this.el.innerHTML = ` ` //this.el.innerHTML = ` `
this.requireAll() this.requireAll()
}, },
@ -34,9 +32,8 @@ AFRAME.registerComponent('codemirror', {
html: (me) => `<div class="codemirror"> html: (me) => `<div class="codemirror">
</div>`, </div>`,
css: (me) => `.CodeMirror{ css: (me) => `.codemirror{
width: ${me.com.data.width}px !important; width:100%;
height: ${me.com.data.height-30}px !important;
} }
.codemirror *{ .codemirror *{
font-size: 14px; font-size: 14px;
@ -45,11 +42,7 @@ AFRAME.registerComponent('codemirror', {
letter-spacing: 0 !important; letter-spacing: 0 !important;
text-shadow: 0px 0px 10px #F075; text-shadow: 0px 0px 10px #F075;
} }
.wb-body + .codemirror{ overflow:hidden; }
.wb-body:has(> .codemirror){
overflow:hidden;
}
.CodeMirror { .CodeMirror {
margin-top:18px; margin-top:18px;
} }
@ -60,7 +53,7 @@ AFRAME.registerComponent('codemirror', {
}, },
createEditor: function(value){ createEditor: function(value){
this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id}; width: ${this.data.width}px; height: ${this.data.height}px`) this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id};`)
this.editor = CodeMirror( this.el.dom, { this.editor = CodeMirror( this.el.dom, {
value, value,
mode: "htmlmixed", mode: "htmlmixed",
@ -74,54 +67,33 @@ AFRAME.registerComponent('codemirror', {
} }
}) })
this.editor.setOption("theme", "shadowfox") this.editor.setOption("theme", "shadowfox")
this.editor.updateFile = AFRAME.utils.throttle( (file,str) => { this.editor.updateFile = AFRAME.utils.throttleLeadingAndTrailing( (file,str) => {
this.updateFile(file,str) this.updateFile(file,str),
}, 1500) 2000
})
this.editor.on('change', (instance,changeObj) => { this.editor.on('change', (instance,changeObj) => {
this.editor.updateFile( this.data.file, instance.getValue() ) this.editor.updateFile( this.data.file, instance.getValue() )
}) })
this
.handleFocus()
setTimeout( () => { setTimeout( () => {
this.el.setAttribute("html-as-texture-in-xr", `domid: #${this.el.dom.id}`) // only show aframe-html in xr this.el.setAttribute("html-as-texture-in-xr", `domid: #${this.el.dom.id}`) // only show aframe-html in xr
},1500) },1500)
}, },
handleFocus: function(){
const focus = (showdom) => (e) => {
if( this.editor ){
this.editor.focus()
}
if( this.el.components.window && this.data.renderer == 'canvas'){
this.el.components.window.show( showdom )
}
}
this.el.addEventListener('obbcollisionstarted', focus(false) )
this.el.sceneEl.addEventListener('enter-vr', focus(false) )
this.el.sceneEl.addEventListener('enter-ar', focus(false) )
this.el.sceneEl.addEventListener('exit-vr', focus(true) )
this.el.sceneEl.addEventListener('exit-ar', focus(true) )
},
updateFile: async function(file,str){ updateFile: async function(file,str){
// we don't do via shellcmd: isoterminal.exec(`echo '${str}' > ${file}`,1) // we don't do via shellcmd: isoterminal.exec(`echo '${str}' > ${file}`,1)
// as it would require all kindof ugly stringescaping // as it would require all kindof ugly stringescaping
console.log("updating "+file) console.log("updating "+file)
console.log(str) await this.isoterminal.emulator.fs9p.update_file( file, str)
await this.isoterminal.worker['emulator.update_file'](file, term.convert.toUint8Array(str) )
}, },
events:{ events:{
// component events // component events
DOMready: function(e){ DOMready: function(e){
this.isoterminal.worker.postMessage.promise({event:'read_file',data: this.data.file })
this.isoterminal.worker['emulator.read_file'](this.data.file)
.then( this.isoterminal.convert.Uint8ArrayToString ) .then( this.isoterminal.convert.Uint8ArrayToString )
.then( (str) => { .then( (str) => {
console.log("creating editor")
this.createEditor( str ) this.createEditor( str )
}) })
.catch( (e) => { .catch( (e) => {

View File

@ -2,8 +2,7 @@ if( !AFRAME.components['html-as-texture-in-xr'] ){
AFRAME.registerComponent('html-as-texture-in-xr', { AFRAME.registerComponent('html-as-texture-in-xr', {
schema: { schema: {
domid: { type:"string"}, domid: { type:"string"}
faceuser: { type: "boolean", default: false}
}, },
dependencies:{ dependencies:{
@ -20,9 +19,7 @@ if( !AFRAME.components['html-as-texture-in-xr'] ){
let s = await AFRAME.utils.require(this.dependencies) let s = await AFRAME.utils.require(this.dependencies)
this.el.setAttribute("html",`html: ${this.data.domid}; cursor:#cursor; xrlayer: true`) this.el.setAttribute("html",`html: ${this.data.domid}; cursor:#cursor; xrlayer: true`)
this.el.setAttribute("visible", AFRAME.utils.XD() == '3D' ? 'true' : 'false' ) this.el.setAttribute("visible", AFRAME.utils.XD() == '3D' ? 'true' : 'false' )
if( this.data.faceuser ){ this.el.setAttribute("position", AFRAME.utils.XD.getPositionInFrontOfCamera(0.5) )
this.el.setAttribute("position", AFRAME.utils.XD.getPositionInFrontOfCamera(0.8) )
}
}, },
manifest: { // HTML5 manifest to identify app to xrsh manifest: { // HTML5 manifest to identify app to xrsh

View File

@ -12,7 +12,7 @@
* *
* plane textcanvas enter-VR * plane textcanvas enter-VR
* enter-AR * enter-AR
* renderer=canvas *
* *
* ISOTerminal.js * ISOTerminal.js
* *
@ -35,28 +35,23 @@ if( typeof AFRAME != 'undefined '){
schema: { schema: {
iso: { type:"string", "default":"https://forgejo.isvery.ninja/assets/xrsh-buildroot/main/xrsh.iso" }, iso: { type:"string", "default":"https://forgejo.isvery.ninja/assets/xrsh-buildroot/main/xrsh.iso" },
overlayfs: { type:"string"}, overlayfs: { type:"string"},
width: { type: 'number',"default": -1 }, cols: { type: 'number',"default": 80 },
height: { type: 'number',"default": -1 }, rows: { type: 'number',"default": 20 },
depth: { type: 'number',"default": 0.03 },
lineHeight: { type: 'number',"default": 18 },
padding: { type: 'number',"default": 18 }, padding: { type: 'number',"default": 18 },
minimized: { type: 'boolean',"default":false}, minimized: { type: 'boolean',"default":false},
maximized: { type: 'boolean',"default":true}, maximized: { type: 'boolean',"default":false},
muteUntilPrompt:{ type: 'boolean',"default":true}, // mute stdout until a prompt is detected in ISO muteUntilPrompt:{ type: 'boolean',"default":true}, // mute stdout until a prompt is detected in ISO
HUD: { type: 'boolean',"default":false}, // link to camera movement HUD: { type: 'boolean',"default":false}, // link to camera movement
transparent: { type:'boolean', "default":false }, // need good gpu transparent: { type:'boolean', "default":false }, // need good gpu
memory: { type: 'number', "default":40 }, // VM memory (in MB) [NOTE: quest or smartphone might crash > 40mb ] xterm: { type: 'boolean', "default":true }, // use xterm.js? (=slower)
bufferLatency: { type: 'number', "default":1 }, // in ms: bufferlatency from webworker to xterm (batch-update every char to texture) memory: { type: 'number', "default":64 }, // VM memory (in MB)
debug: { type: 'boolean', "default":false } bufferLatency: { type: 'number', "default":300 }, // in ms: bufferlatency from webworker to xterm (batch-update every char to texture)
canvasLatency: { type: 'number', "default":300 } // in ms: time between canvas re-draws
}, },
init: function(){ init: function(){
this.el.object3D.visible = false this.el.object3D.visible = false
this.calculateDimension()
this.initHud() this.initHud()
this.setupBox()
fetch(this.data.iso,{method: 'HEAD'}) fetch(this.data.iso,{method: 'HEAD'})
.then( (res) => { .then( (res) => {
if( res.status != 200 ) throw 'not found' if( res.status != 200 ) throw 'not found'
@ -73,40 +68,30 @@ if( typeof AFRAME != 'undefined '){
com: "com/dom.js", com: "com/dom.js",
window: "com/window.js", window: "com/window.js",
v86: "com/isoterminal/libv86.js", v86: "com/isoterminal/libv86.js",
vt100: "com/isoterminal/VT100.js",
// allow xrsh to selfcontain scene + itself // allow xrsh to selfcontain scene + itself
xhook: "https://jpillora.com/xhook/dist/xhook.min.js", xhook: "https://jpillora.com/xhook/dist/xhook.min.js",
selfcontain: "com/selfcontainer.js", selfcontain: "com/selfcontainer.js",
// html to texture // html to texture
htmlinxr: "com/html-as-texture-in-xr.js", htmlinxr: "com/html-as-texture-in-xr.js",
// isoterminal global features // isoterminal features
PromiseWorker: "com/isoterminal/PromiseWorker.js",
ISOTerminal: "com/isoterminal/ISOTerminal.js", ISOTerminal: "com/isoterminal/ISOTerminal.js",
localforage: "com/isoterminal/localforage.js", localforage: "https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"
}, },
dom: { dom: {
scale: 0.66, //scale: 0.5,
events: ['click','keydown'], events: ['click','keydown'],
html: (me) => `<div class="isoterminal"> html: (me) => `<div class="isoterminal">
<div id="term" tabindex="0">
<pre></pre>
</div>
</div>`, </div>`,
css: (me) => `.isoterminal{ css: (me) => `.isoterminal{
padding: ${me.com.data.padding}px; padding: ${me.com.data.padding}px;
width:100%; width:100%;
height:100%; height:100%;
position:relative;
} }
.isoterminal div{ .isoterminal div{
display:block; display:block;
position:relative; position:relative;
line-height: ${me.com.data.lineHeight}px;
}
#term {
outline: none !important;
} }
@font-face { @font-face {
font-family: 'Cousine'; font-family: 'Cousine';
@ -123,11 +108,6 @@ if( typeof AFRAME != 'undefined '){
.isoterminal style{ display:none } .isoterminal style{ display:none }
blink{
border:none;
padding:none;
}
#overlay .winbox:has(> .isoterminal){ #overlay .winbox:has(> .isoterminal){
background:transparent; background:transparent;
box-shadow:none; box-shadow:none;
@ -136,21 +116,35 @@ if( typeof AFRAME != 'undefined '){
.wb-body:has(> .isoterminal){ .wb-body:has(> .isoterminal){
background: #000C; background: #000C;
overflow:hidden; overflow:hidden;
border-radius:7px;
} }
.XR .wb-body:has(> .isoterminal){ .XR .wb-body:has(> .isoterminal){
background: transparent;
}
.XR .isoterminal{
background: #000; background: #000;
} }
.isoterminal *{ .isoterminal *,
.isoterminal .xterm-dom-renderer-owner-1 .xterm-rows {
background:transparent !important;
font-size: 14px; font-size: 14px;
font-family: "Cousine",Liberation Mono,DejaVu Sans Mono,Courier New,monospace; font-family: "Cousine",Liberation Mono,DejaVu Sans Mono,Courier New,monospace;
font-weight:500 !important; font-weight:500 !important;
text-shadow: 0px 0px 10px #F075; text-shadow: 0px 0px 10px #F075;
} }
.isoterminal .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-block {
background-color:#a5F !important;
}
.isoterminal .xterm-rows div{
height:8px;
height:18px;
}
.isoterminal .xterm-rows span{
width:8px;
}
.isoterminal .xterm-helpers {
position:absolute;
opacity:0;
top: -2000px;
}
@keyframes fade { @keyframes fade {
from { opacity: 1.0; } from { opacity: 1.0; }
@ -164,6 +158,7 @@ if( typeof AFRAME != 'undefined '){
to { opacity: 1.0; } to { opacity: 1.0; }
} }
.isoterminal .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-block,
.blink{ .blink{
animation:fade 1000ms infinite; animation:fade 1000ms infinite;
-webkit-animation:fade 1000ms infinite; -webkit-animation:fade 1000ms infinite;
@ -174,7 +169,8 @@ if( typeof AFRAME != 'undefined '){
initTerminal: async function(singleton){ initTerminal: async function(singleton){
// why not latest xterm or v3.12 with builtin-canvas support? if( this.data.xterm ){
// why 3.12?
// first versions used 1.5.4, a typescript rewrite which: // first versions used 1.5.4, a typescript rewrite which:
// * acts weird with oculus browser keyboard (does not repaint properly after typing) // * acts weird with oculus browser keyboard (does not repaint properly after typing)
// * does not use canvas anymore [which would be ideal for THREE.js texture] // * does not use canvas anymore [which would be ideal for THREE.js texture]
@ -182,7 +178,10 @@ if( typeof AFRAME != 'undefined '){
// * only allows a standalone WebGL addon (conflicts with THREE) // * only allows a standalone WebGL addon (conflicts with THREE)
// * heavily dependent on requestAnimationFrame (conflicts with THREE) // * heavily dependent on requestAnimationFrame (conflicts with THREE)
// * typescript-rewrite results in ~300k lib (instead of 96k) // * typescript-rewrite results in ~300k lib (instead of 96k)
// * v3.12 had slightly better performance but still very heavy this.requires.xtermcss = "//unpkg.com/xterm@3.12.0/dist/xterm.css",
this.requires.xtermjs = "//unpkg.com/xterm@3.12.0/dist/xterm.js",
this.requires.xtermcss = "com/xterm.js"
}
await AFRAME.utils.require(this.requires) await AFRAME.utils.require(this.requires)
await AFRAME.utils.require({ // ISOTerminal plugins await AFRAME.utils.require({ // ISOTerminal plugins
@ -211,38 +210,42 @@ if( typeof AFRAME != 'undefined '){
} }
// init isoterminal // init isoterminal
this.term = new ISOTerminal(instance,this.data) this.isoterminal = new ISOTerminal(instance,this.data)
instance.addEventListener('DOMready', () => { instance.addEventListener('DOMready', () => {
this.setupVT100(instance) //instance.setAttribute("html-as-texture-in-xr", `domid: #${this.el.dom.id}`)
setTimeout( () => {
instance.setAttribute("html-as-texture-in-xr", `domid: #term; faceuser: true`)
},100)
//instance.winbox.resize(720,380) //instance.winbox.resize(720,380)
let size = `width: ${this.data.width}; height: ${this.data.height}` let size = `width: ${Math.floor(this.data.cols*8.65)}; height: ${Math.floor(this.data.rows*21.1)}`
instance.setAttribute("window", `title: xrsh.iso; uid: ${instance.uid}; attach: #overlay; dom: #${instance.dom.id}; ${size}; min: ${this.data.minimized}; max: ${this.data.maximized}`) instance.setAttribute("window", `title: xrsh.iso; uid: ${instance.uid}; attach: #overlay; dom: #${instance.dom.id}; ${size}; min: ${this.data.minimized}; max: ${this.data.maximized}`)
}) })
instance.addEventListener('window.oncreate', (e) => { instance.addEventListener('window.oncreate', (e) => {
instance.dom.classList.add('blink') instance.dom.classList.add('blink')
instance.setAttribute("xterm",`cols: ${this.data.cols}; rows: ${this.data.rows}; canvasLatency: ${this.data.canvasLatency}`)
instance.addEventListener("xterm-input", (e) => this.isoterminal.send(e.detail,0) )
// run iso // run iso
let opts = {dom:instance.dom} let opts = {dom:instance.dom}
for( let i in this.data ) opts[i] = this.data[i] for( let i in this.data ) opts[i] = this.data[i]
opts.cols = this.cols this.isoterminal.start(opts)
opts.rows = this.rows
this.term.start(opts)
}) })
instance.setAttribute("dom", "") instance.setAttribute("dom", "")
this.term.addEventListener('ready', (e) => { this.isoterminal.addEventListener('postReady', (e)=>{
instance.dom.classList.remove('blink') // bugfix: send window dimensions to xterm (xterm.js does that from dom-sizechange to xterm via escape codes)
this.term.emit('status',"running") let wb = instance.winbox
if( this.data.debug ) this.runTests() if( this.data.maximized ){
wb.restore()
wb.maximize()
}else wb.resize()
}) })
this.term.addEventListener('status', function(e){ this.isoterminal.addEventListener('ready', (e)=>{
instance.dom.classList.remove('blink')
this.isoterminal.emit('status',"running")
})
this.isoterminal.addEventListener('status', function(e){
let msg = e.detail let msg = e.detail
const w = instance.winbox const w = instance.winbox
if(!w) return if(!w) return
@ -259,10 +262,12 @@ if( typeof AFRAME != 'undefined '){
instance.addEventListener('window.onmaximize', resize ) instance.addEventListener('window.onmaximize', resize )
const focus = (showdom) => (e) => { const focus = (showdom) => (e) => {
if( this.el.components.window && this.data.renderer == 'canvas'){ if( this.el.components.xterm ){
this.el.components.xterm.term.focus()
}
if( this.el.components.window ){
this.el.components.window.show( showdom ) this.el.components.window.show( showdom )
} }
this.el.emit('focus',e.detail)
} }
this.el.addEventListener('obbcollisionstarted', focus(false) ) this.el.addEventListener('obbcollisionstarted', focus(false) )
@ -282,72 +287,6 @@ if( typeof AFRAME != 'undefined '){
} }
}, },
runTests: async function(){
await AFRAME.utils.require({
"test_util": "tests/util.js",
"test_isoterminal":"tests/ISOTerminal.js"
})
console.test.run()
},
setupVT100: function(instance){
const el = this.el.dom.querySelector('#term')
const opts = {
cols: this.cols,
rows: this.rows,
el_or_id: el,
max_scroll_lines: 100,
nodim: true
}
this.vt100 = new VT100( opts )
this.vt100.el = el
this.vt100.curs_set( 1, true)
el.focus()
this.el.addEventListener('focus', () => el.focus())
this.vt100.getch( (ch,t) => {
this.term.send( ch )
this.vt100.curs_set( 0, true)
})
this.el.addEventListener('serial-output-byte', (e) => {
const byte = e.detail
var chr = String.fromCharCode(byte);
this.vt100.addchr(chr)
})
this.el.addEventListener('serial-output-string', (e) => {
this.vt100.write(e.detail)
})
//this.el.dom.querySelector('input').addEventListener('keyup', (e) => {
// VT100.handle_onkeypress_( {charCode : e.charCode || e.keyCode, keyCode: e.keyCode}, (chars) => {
// debugger
// chars.map( (c) => this.term.send(str) )
// })
//})
},
setupBox: function(){
// setup slightly bigger black backdrop (this.el.getObject3D("mesh"))
const w = this.data.width/950;
const h = this.data.height/950;
this.el.box = document.createElement('a-entity')
this.el.box.setAttribute("geometry",`primitive: box; width:${w}; height:${h}; depth: -${this.data.depth}`)
this.el.box.setAttribute("material","shader:flat; color:black; opacity:0.9; transparent:true; ")
this.el.box.setAttribute("position",`0 0 ${(this.data.depth/2)-0.001}`)
this.el.appendChild(this.el.box)
},
calculateDimension: function(){
if( this.data.width == -1 ) this.data.width = document.body.offsetWidth
if( this.data.height == -1 ) this.data.height = document.body.offsetHeight
if( this.data.height > this.data.width ) this.data.height = this.data.width // mobile smartphone fix
this.data.width -= this.data.padding*2
this.data.height -= this.data.padding*2
this.cols = Math.floor(this.data.width/this.data.lineHeight*1.9)
this.rows = Math.floor(this.data.height*0.5/this.data.lineHeight*1.7) // keep extra height for mobile browser bottom-bar (android)
},
events:{ events:{
// combined AFRAME+DOM reactive events // combined AFRAME+DOM reactive events

View File

@ -22,7 +22,7 @@ ISOTerminal.prototype.emit = function(event,data,sender){
// this feels complex, but actually keeps event- and function-names more concise in codebase // this feels complex, but actually keeps event- and function-names more concise in codebase
this.dispatchEvent( evObj ) this.dispatchEvent( evObj )
if( sender != "instance" && this.instance ) this.instance.dispatchEvent(evObj) if( sender != "instance" && this.instance ) this.instance.dispatchEvent(evObj)
if( sender != "worker" && this.worker ) this.worker.postMessage({event,data}, PromiseWorker.prototype.getTransferable(data) ) if( sender != "worker" && this.worker ) this.worker.postMessage({event,data}, this.getTransferable(data) )
if( sender !== undefined && typeof this[event] == 'function' ) this[event].apply(this, data && data.push ? data : [data] ) if( sender !== undefined && typeof this[event] == 'function' ) this[event].apply(this, data && data.push ? data : [data] )
//}) //})
} }
@ -61,11 +61,11 @@ ISOTerminal.prototype.convert = {
const bytes = new Uint8Array(buffer); const bytes = new Uint8Array(buffer);
const len = bytes.byteLength; const len = bytes.byteLength;
for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]); for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
return btoa(binary); return window.btoa(binary);
}, },
base64ToArrayBuffer: function(base64) { base64ToArrayBuffer: function(base64) {
const binaryString = atob(base64); const binaryString = window.atob(base64);
const len = binaryString.length; const len = binaryString.length;
const bytes = new Uint8Array(len); const bytes = new Uint8Array(len);
@ -128,30 +128,46 @@ ISOTerminal.prototype.start = function(opts){
//disable_jit: false, //disable_jit: false,
filesystem: {}, filesystem: {},
autostart: true, autostart: true,
debug: this.opts.debug ? true : false
}; };
this
.setupWorker(opts)
.startVM(opts)
}
ISOTerminal.prototype.setupWorker = function(opts){
/* /*
* the WebWorker (which runs v86) * the WebWorker (which runs v86)
* *
*/ */
this.worker = new PromiseWorker( "com/isoterminal/worker.js", (cb,event,data) => {
if( !data.promiseId ) this.emit(event,data,"worker") // forward event to world this.worker = new Worker("com/isoterminal/worker.js");
this.worker.onmessage = (e) => {
const {event,data} = e.data
const cb = (event,data) => () => {
if( data.promiseId ){
this.workerPromise.resolver(data) // forward to promise resolver
}else this.emit(event,data,"worker") // forward event to world
}
this.preventFrameDrop( cb(event,data) ) this.preventFrameDrop( cb(event,data) )
}) }
return this /*
} * postMessage.promise basically performs this.worker.postMessage
* in a promise way (to easily retrieve async output)
*/
this.worker.postMessage.promise = function(data){
if( typeof data != 'object' ) data = {data}
this.resolvers = this.resolvers || {}
this.id = this.id == undefined ? 0 : this.id
data.id = this.id++
// Send id and task to WebWorker
this.preventFrameDrop( () => this.worker.postMessage(data,getTransferable(data) ) )
return new Promise(resolve => this.resolvers[data.id] = resolve);
}.bind(this.worker.postMessage)
this.worker.postMessage.promise.resolver = function(data){
if( !data || !data.promiseId ) throw 'promiseId not given'
this.resolvers[ data.promiseId ](data);
delete this.resolvers[ data.promiseId ]; // Prevent memory leak
}.bind(this.worker.postMessage)
ISOTerminal.prototype.startVM = function(opts){
this.emit('runISO',{...opts, bufferLatency: this.opts.bufferLatency }) this.emit('runISO',{...opts, bufferLatency: this.opts.bufferLatency })
const loading = [ const loading = [
@ -211,14 +227,11 @@ ISOTerminal.prototype.startVM = function(opts){
\r https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬ \r https://xrsh.isvery.ninja ▬▬▬▬▬▬▬▬▬▬▬▬
\r local-first, polyglot, unixy WebXR IDE & runtime \r local-first, polyglot, unixy WebXR IDE & runtime
\r \r
\r credits \r credits: NLnet | @nlnet@nlnet.nl
\r ------- \r MrDoob | THREE.js
\r @nlnet@nlnet.nl \r Diego Marcos | AFRAME.js
\r @lvk@mastodon.online \r Leon van Kammen | @lvk@mastodon.online
\r @utopiah@mastodon.pirateparty.be \r Fabien Benetou | @utopiah@mastodon.pirateparty.be
\r https://www.w3.org/TR/webxr
\r https://three.org
\r https://aframe.org
` `
const text_color = "\r" const text_color = "\r"
@ -290,3 +303,16 @@ ISOTerminal.prototype.preventFrameDrop = function(cb){
} }
} }
ISOTerminal.prototype.getTransferable = function(data){
function isTransferable(obj) {
return obj instanceof ArrayBuffer ||
obj instanceof MessagePort ||
obj instanceof ImageBitmap ||
(typeof OffscreenCanvas !== 'undefined' && obj instanceof OffscreenCanvas) ||
(typeof ReadableStream !== 'undefined' && obj instanceof ReadableStream) ||
(typeof WritableStream !== 'undefined' && obj instanceof WritableStream) ||
(typeof TransformStream !== 'undefined' && obj instanceof TransformStream);
}
if( isTransferable(data) ) console.log("Transferable!")
if( isTransferable(data) ) return isTransferable(data) ? [data] : undefined
}

View File

@ -1,77 +0,0 @@
/*
* This is basically a Javascript Proxy for 'new Worker()'
* which allows calling worker-functions via promises.
*
* It's basically comlink without the fat.
*
* const w = new PromiseWorker("worker.js", (cb,event_or_fn,data) => {
* cb(event_or_fn,data) // decorate/ratelimit/hooks here
* })
* w.foo().then( console.dir )
*
* in worker.js define a function: this.foo = () => return {foo:"Bar"}
*/
function PromiseWorker(file, onmessage){
let proxy
const worker = new Worker(file)
worker.onmessage = (e) => { // handle messages originating from worker
const {event,data} = e.data // this is worker.onmessage(...)
const cb = (event,data) => () => { //
if( data.promiseId ){ //
proxy.resolver(data) // forward to promise resolver
}
}
onmessage(cb,event,data)
}
return proxy = new Proxy(this,{
get(me,k){
if( k.match(/(postMessage|onmessage)/) ) return worker[k].bind(worker)
if( k.match(/(resolver|promise)/) ) return this[k].bind(this)
// promisify postMessage(...) call
return function(){
return this.promise(me,{event: k, data: [...arguments] })
}
},
promise(me,msg){
if( typeof msg != 'object' || !msg.event || !msg.data ){
throw 'worker.promise({event:..,data:..}) did not receive correct msg : '+JSON.stringify(msg)
}
this.resolvers = this.resolvers || {last:1,pending:{}}
msg.data.promiseId = this.resolvers.last++
// Send id and task to WebWorker
worker.postMessage(msg, PromiseWorker.prototype.getTransferable(msg.data) )
return new Promise( resolve => this.resolvers.pending[ msg.data.promiseId ] = resolve );
},
resolver(data){
if( !data || !data.promiseId ) throw 'promiseId not given'
this.resolvers.pending[ data.promiseId ](data.result);
delete this.resolvers.pending[ data.promiseId ]; // Prevent memory leak
}
})
}
PromiseWorker.prototype.getTransferable = function(data){
let objs = []
function isTransferable(obj) {
return obj instanceof ArrayBuffer ||
obj instanceof MessagePort ||
obj instanceof ImageBitmap ||
(typeof OffscreenCanvas !== 'undefined' && obj instanceof OffscreenCanvas) ||
(typeof ReadableStream !== 'undefined' && obj instanceof ReadableStream) ||
(typeof WritableStream !== 'undefined' && obj instanceof WritableStream) ||
(typeof TransformStream !== 'undefined' && obj instanceof TransformStream);
}
for( var i in data ){
if( isTransferable(data[i]) ) objs.push(data[i])
}
if( objs.length ) debugger
return objs.length ? objs : undefined
}

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,7 @@ emulator.fs9p.update_file = async function(file,data){
} }
const inode = this.GetInode(p.id); const inode = this.GetInode(p.id);
const buf = typeof data == 'string' ? convert.toUint8Array(data) : data || "" const buf = typeof data == 'string' ? convert.toUint8Array(data) : data
if( buf.length == 0 ) return new Promise( (resolve,reject) => resolve(data) )
try{
await this.Write(p.id,0, buf.length, buf ) await this.Write(p.id,0, buf.length, buf )
// update inode // update inode
inode.size = buf.length inode.size = buf.length
@ -23,10 +20,7 @@ emulator.fs9p.update_file = async function(file,data){
inode.atime = inode.mtime = now; inode.atime = inode.mtime = now;
me.postMessage({event:'exec',data:[`touch /mnt/${file}`]}) // update inode me.postMessage({event:'exec',data:[`touch /mnt/${file}`]}) // update inode
return new Promise( (resolve,reject) => resolve(buf) ) return new Promise( (resolve,reject) => resolve(buf) )
}catch(e){
console.error({file,data})
return new Promise( (resolve,reject) => reject(e) )
}
} }
emulator.fs9p.append_file = async function(file,data){ emulator.fs9p.append_file = async function(file,data){
@ -50,3 +44,5 @@ emulator.fs9p.append_file = async function(file,data){
} }
this['fs9p.append_file'] = function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) }
this['fs9p.update_file'] = function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) }

View File

@ -1,31 +1,15 @@
if( typeof emulator != 'undefined' ){ if( typeof emulator != 'undefined' ){
// inside worker-thread // inside worker-thread
importScripts("localforage.js") // we don't instance it again here (just use its functions)
this['emulator.restore_state'] = async function(data){ this['emulator.restore_state'] = async function(data){
return new Promise( (resolve,reject) => { await emulator.restore_state(data)
localforage.getItem("state", async (err,stateBase64) => {
if( stateBase64 && !err ){
state = ISOTerminal.prototype.convert.base64ToArrayBuffer( stateBase64 )
await emulator.restore_state(state)
console.log("restored state") console.log("restored state")
}else return reject("worker.js: emulator.restore_state (could not get state from localforage)") this.postMessage({event:"state_restored",data:false})
resolve()
})
})
} }
this['emulator.save_state'] = async function(){ this['emulator.save_state'] = async function(){
console.log("saving session") console.log("saving session")
let state = await emulator.save_state() let state = await emulator.save_state()
localforage.setDriver([ this.postMessage({event:"state_saved",data:state})
localforage.INDEXEDDB,
localforage.WEBSQL,
localforage.LOCALSTORAGE
]).then( () => {
localforage.setItem("state", ISOTerminal.prototype.convert.arrayBufferToBase64(state) )
console.log("state saved")
})
console.dir(state)
} }
@ -46,21 +30,27 @@ if( typeof emulator != 'undefined' ){
localforage.getItem("state", async (err,stateBase64) => { localforage.getItem("state", async (err,stateBase64) => {
if( stateBase64 && !err && confirm('continue last session?') ){ if( stateBase64 && !err && confirm('continue last session?') ){
this.noboot = true // see feat/boot.js this.noboot = true // see feat/boot.js
try{ state = this.convert.base64ToArrayBuffer( stateBase64 )
await this.worker['emulator.restore_state']()
this.addEventListener('state_restored', function(){
// simulate / fastforward boot events // simulate / fastforward boot events
this.postBoot( () => { this.postBoot( () => this.send("l\n") )
this.send("l\n")
this.send("hook wakeup\n")
}) })
}catch(e){ console.error(e) }
this.worker.postMessage({event:'emulator.restore_state',data:state})
} }
}) })
this.save = async () => { this.save = async () => {
await this.worker['emulator.save_state']() const state = await this.worker.postMessage({event:"emulator.save_state",data:false})
} }
this.addEventListener('state_saved', function(e){
const state = e.detail
localforage.setItem("state", this.convert.arrayBufferToBase64(state) )
console.log("state saved")
})
window.addEventListener("beforeunload", function (e) { window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "Sure you want to leave?\nTIP: enter 'save' to continue this session later"; var confirmationMessage = "Sure you want to leave?\nTIP: enter 'save' to continue this session later";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE (e || window.event).returnValue = confirmationMessage; //Gecko + IE

View File

@ -4,11 +4,7 @@ ISOTerminal.addEventListener('ready', function(e){
ISOTerminal.prototype.boot = async function(e){ ISOTerminal.prototype.boot = async function(e){
// set environment // set environment
let env = [ let env = ['export BROWSER=1']
`export LINES=${this.opts.rows}`,
`export COLUMNS=${this.opts.cols}`,
'export BROWSER=1',
]
for ( let i in document.location ){ for ( let i in document.location ){
if( typeof document.location[i] == 'string' ){ if( typeof document.location[i] == 'string' ){
env.push( 'export '+String(i).toUpperCase()+'="'+decodeURIComponent( document.location[i]+'"') ) env.push( 'export '+String(i).toUpperCase()+'="'+decodeURIComponent( document.location[i]+'"') )

View File

@ -2,31 +2,22 @@
if( typeof emulator != 'undefined' ){ if( typeof emulator != 'undefined' ){
// inside worker-thread // inside worker-thread
this.listenIndexHTML = () => { // unix to js device
const file = "dev/browser/html" this.emulator.readFromPipe( 'root/index.html', async (data) => {
emulator.readFromPipe( file, async (data) => { const buf = await emulator.read_file("root/index.html")
const buf = await emulator.read_file( file )
const decoder = new TextDecoder('utf-8'); const decoder = new TextDecoder('utf-8');
const html = decoder.decode(buf).replace(/^#!\/bin\/html/,'') // remove leftover shebangs if any const html = decoder.decode(buf).replace(/^#!\/bin\/html/,'') // remove leftover shebangs if any
try{ try{
this.postMessage({event:'runHTML',data:[html]}) this.postMessage({event:'runHTML',data:[html]})
}catch(e){ }catch(e){
console.error(file)
console.error(e) console.error(e)
} }
}) })
}
}else{ }else{
// inside browser-thread // inside browser-thread
ISOTerminal.addEventListener('emulator-started', function(){
this.addEventListener('ready', async () => {
this.worker.listenIndexHTML()
})
})
ISOTerminal.prototype.runHTML = function(html){ ISOTerminal.prototype.runHTML = function(html){
let $scene = document.querySelector("a-scene") let $scene = document.querySelector("a-scene")
let $root = document.querySelector("a-entity#root") let $root = document.querySelector("a-entity#root")
@ -35,7 +26,6 @@ if( typeof emulator != 'undefined' ){
$root.id = "root" $root.id = "root"
$scene.appendChild($root) $scene.appendChild($root)
} }
console.log(html)
$root.innerHTML = html $root.innerHTML = html
} }

View File

@ -2,8 +2,8 @@ if( typeof emulator != 'undefined' ){
// inside worker-thread // inside worker-thread
// unix to js device // unix to js device
this.emulator.readFromPipe( 'dev/browser/js', async (data) => { this.emulator.readFromPipe( 'root/index.js', async (data) => {
const buf = await emulator.read_file("dev/browser/js") const buf = await emulator.read_file("root/index.js")
const decoder = new TextDecoder('utf-8'); const decoder = new TextDecoder('utf-8');
const js = decoder.decode(buf).replace(/^#!\/bin\/js/,'') // remove leftover shebangs if any const js = decoder.decode(buf).replace(/^#!\/bin\/js/,'') // remove leftover shebangs if any
try{ try{

View File

@ -20,20 +20,10 @@ if( typeof emulator != 'undefined' ){
}else{ }else{
// inside browser-thread // inside browser-thread
ISOTerminal.addEventListener('javascript-eval', async function(e){ ISOTerminal.addEventListener('javascript-eval', function(e){
const {script,PID} = e.detail const {script,PID} = e.detail
let res let res = (new Function(`${script}`))()
try{
res = (new Function(`${script}`))()
if( res && typeof res != 'string' ) res = JSON.stringify(res,null,2) if( res && typeof res != 'string' ) res = JSON.stringify(res,null,2)
}catch(e){
console.error(e)
console.info(script)
res = "error: "+e.toString()
if( e.filename ){
res += "\n"+e.filename+":"+e.lineno+":"+e.colno
}
}
// update output to 9p with PID as filename (in /mnt/run) // update output to 9p with PID as filename (in /mnt/run)
this.emit('fs9p.update_file', [`run/${PID}`, this.convert.toUint8Array(res)] ) this.emit('fs9p.update_file', [`run/${PID}`, this.convert.toUint8Array(res)] )
}) })

View File

@ -9,17 +9,17 @@ ISOTerminal.prototype.redirectConsole = function(handler){
log.apply(log, args); log.apply(log, args);
}; };
console.error = (...args)=>{ console.error = (...args)=>{
const textArg = args[0] const textArg = args[0].message?args[0].message:args[0];
handler( textArg+'\n', '\x1b[31merror\x1b[0m'); handler( textArg+'\n', '\x1b[31merror\x1b[0m');
err.apply(log, args); err.apply(log, args);
}; };
console.dir = (...args)=>{ console.dir = (...args)=>{
const textArg = args[0] const textArg = args[0].message?args[0].message:args[0];
handler( JSON.stringify(textArg,null,2)+'\n'); handler( JSON.stringify(textArg,null,2)+'\n');
dir.apply(log, args); dir.apply(log, args);
}; };
console.warn = (...args)=>{ console.warn = (...args)=>{
const textArg = args[0] const textArg = args[0].message?args[0].message:args[0];
handler(textArg+'\n','\x1b[38;5;208mwarn\x1b[0m'); handler(textArg+'\n','\x1b[38;5;208mwarn\x1b[0m');
err.apply(log, args); err.apply(log, args);
}; };
@ -34,7 +34,7 @@ ISOTerminal.addEventListener('emulator-started', function(){
str.trim().split("\n").map( (line) => { str.trim().split("\n").map( (line) => {
finalStr += '\x1b[38;5;165m/dev/browser: \x1b[0m'+prefix+line+'\n' finalStr += '\x1b[38;5;165m/dev/browser: \x1b[0m'+prefix+line+'\n'
}) })
this.emit('append_file', ["/dev/browser/console",finalStr]) this.emit('fs9p.append_file', ["/dev/browser/console",finalStr])
}) })
window.addEventListener('error', function(event) { window.addEventListener('error', function(event) {
@ -46,6 +46,7 @@ ISOTerminal.addEventListener('emulator-started', function(){
}); });
window.addEventListener('unhandledrejection', function(event) { window.addEventListener('unhandledrejection', function(event) {
console.error('Unhandled promise rejection:')
console.error(event); console.error(event);
}); });

View File

@ -2,14 +2,12 @@ importScripts("libv86.js");
importScripts("ISOTerminal.js") // we don't instance it again here (just use its functions) importScripts("ISOTerminal.js") // we don't instance it again here (just use its functions)
this.runISO = function(opts){ this.runISO = function(opts){
this.opts = opts
if( opts.debug ) console.dir(opts)
if( opts.cdrom && !opts.cdrom.url.match(/^http/) ) opts.cdrom.url = "../../"+opts.cdrom.url if( opts.cdrom && !opts.cdrom.url.match(/^http/) ) opts.cdrom.url = "../../"+opts.cdrom.url
if( opts.bzimage && !opts.cdrom.url.match(/^http/) ) opts.bzimage.url = "../../"+opts.bzimage.url if( opts.bzimage && !opts.cdrom.url.match(/^http/) ) opts.bzimage.url = "../../"+opts.bzimage.url
console.dir(opts)
let emulator = this.emulator = new V86(opts); let emulator = this.emulator = new V86(opts);
console.log("[worker.js] started emulator") console.log("worker:started emulator")
// event forwarding // event forwarding
@ -42,10 +40,8 @@ this.runISO = function(opts){
/* /*
* forward events/functions so non-worker world can reach them * forward events/functions so non-worker world can reach them
*/ */
this['emulator.create_file'] = async function(){ return emulator.create_file.apply(emulator, arguments[0]) } this['emulator.create_file'] = function(){ emulator.create_file.apply(emulator, arguments[0]) }
this['emulator.read_file'] = async function(){ return emulator.read_file.apply(emulator, arguments[0]) } this['emulator.read_file'] = function(){ emulator.read_file.apply(emulator, arguments[0]) }
this['emulator.append_file'] = async function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) }
this['emulator.update_file'] = async function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) }
// filename will be read from 9pfs: "/mnt/"+filename // filename will be read from 9pfs: "/mnt/"+filename
emulator.readFromPipe = function(filename,cb){ emulator.readFromPipe = function(filename,cb){
@ -64,23 +60,11 @@ this.runISO = function(opts){
* forward events/functions so non-worker world can reach them * forward events/functions so non-worker world can reach them
*/ */
this['serial0-input'] = function(c){ emulator.bus.send( 'serial0-input', c) } // to /dev/ttyS0 this['serial0-input'] = function(c){ this.emulator.bus.send( 'serial0-input', c) } // to /dev/ttyS0
this['serial1-input'] = function(c){ emulator.bus.send( 'serial1-input', c) } // to /dev/ttyS1 this['serial1-input'] = function(c){ this.emulator.bus.send( 'serial1-input', c) } // to /dev/ttyS1
this['serial2-input'] = function(c){ emulator.bus.send( 'serial2-input', c) } // to /dev/ttyS2 this['serial2-input'] = function(c){ this.emulator.bus.send( 'serial2-input', c) } // to /dev/ttyS2
this.onmessage = async function(e){ this.onmessage = function(e){
let {event,data} = e.data let {event,data} = e.data
if( this[event] ){ if( this[event] ) this[event](data)
if( this.opts?.debug ) console.log(`[worker.js] this.${event}(${JSON.stringify(data).substr(0,60)})`)
try{
let result = await this[event](data)
if( data.promiseId ){ // auto-callback to ISOTerminal.worker.promise(...)
this.postMessage({event,data: {...data,result}})
}
}catch(e){
if( data.promiseId ){ // auto-callback to ISOTerminal.worker.promise(...)
this.postMessage({event,data: {...data,error:e}})
}
}
}
} }

View File

@ -63,27 +63,9 @@ AFRAME.registerComponent('window', {
this.el.setAttribute("grabbable","") this.el.setAttribute("grabbable","")
if( this.el.object3D.position.x == 0 &&
this.el.object3D.position.y == 0 &&
this.el.object3D.position.z == 0 ){ // position next to previous window
var els = [...document.querySelectorAll('[window]')]
if( els.length < 2 ) return
let current = els[ els.length-1 ]
let last = els[ els.length-2 ]
AFRAME.utils.positionObjectNextToNeighbor( current.object3D , last.object3D, els.length )
}
}, },
show: function(state){ show: function(state){
this.el.dom.closest('.winbox').style.display = state ? '' : 'none' this.el.dom.closest('.winbox').style.display = state ? '' : 'none'
} }
}) })
AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, neighbours, margin = 0.45, degree = 20) {
// *FIXME* this could be more sophisticated :)
object.position.x = lastNeighbor.position.x + ((neighbours-1) * margin)
object.position.y = lastNeighbor.position.y
object.position.z = lastNeighbor.position.z
//object.rotation.y += THREE.MathUtils.degToRad( (neighbours-1) * degree);
}

View File

@ -92,7 +92,6 @@ const TERMINAL_THEME = {
AFRAME.registerComponent('xterm', { AFRAME.registerComponent('xterm', {
schema: Object.assign({ schema: Object.assign({
XRrenderer: { type: 'string', default: 'canvas', },
cols: { type: 'number', default: 110, }, cols: { type: 'number', default: 110, },
rows: { type: 'number', default: Math.floor( (window.innerHeight * 0.7 ) * 0.054 ) }, rows: { type: 'number', default: Math.floor( (window.innerHeight * 0.7 ) * 0.054 ) },
canvasLatency:{ type:'number', default: 200 } canvasLatency:{ type:'number', default: 200 }
@ -109,36 +108,22 @@ AFRAME.registerComponent('xterm', {
overflow: hidden; overflow: hidden;
`) `)
this.el.terminalElement = terminalElement
if( this.data.XRrenderer == 'canvas' ){
// setup slightly bigger black backdrop (this.el.getObject3D("mesh")) // setup slightly bigger black backdrop (this.el.getObject3D("mesh"))
// and terminal text (this.el.planeText.getObject("mesh")) // and terminal text (this.el.planeText.getObject("mesh"))
const w = 2; this.el.setAttribute("geometry",`primitive: box; width:2.07; height:${this.data.rows*5.3/this.data.cols}*2; depth: -0.12`)
const h = (this.data.rows*5/this.data.cols)
this.el.setAttribute("geometry",`primitive: box; width:${w}; height:${h}; depth: -0.12`)
this.el.setAttribute("material","shader:flat; color:black; opacity:0.5; transparent:true; ") this.el.setAttribute("material","shader:flat; color:black; opacity:0.5; transparent:true; ")
this.el.planeText = document.createElement('a-entity') this.el.planeText = document.createElement('a-entity')
this.el.planeText.setAttribute("geometry",`primitive: plane; width:${w}; height:${h}`) this.el.planeText.setAttribute("geometry",`primitive: plane; width:2; height:${this.data.rows*5/this.data.cols}*2`)
this.el.appendChild(this.el.planeText) this.el.appendChild(this.el.planeText)
this.el.terminalElement = terminalElement
// we switch between dom/canvas rendering because canvas looks pixely in nonimmersive mode // we switch between dom/canvas rendering because canvas looks pixely in nonimmersive mode
this.el.sceneEl.addEventListener('enter-vr', this.enterImmersive.bind(this) ) this.el.sceneEl.addEventListener('enter-vr', this.enterImmersive.bind(this) )
this.el.sceneEl.addEventListener('enter-ar', this.enterImmersive.bind(this) ) this.el.sceneEl.addEventListener('enter-ar', this.enterImmersive.bind(this) )
this.el.sceneEl.addEventListener('exit-vr', this.exitImmersive.bind(this) ) this.el.sceneEl.addEventListener('exit-vr', this.exitImmersive.bind(this) )
this.el.sceneEl.addEventListener('exit-ar', this.exitImmersive.bind(this) ) this.el.sceneEl.addEventListener('exit-ar', this.exitImmersive.bind(this) )
}
this.tick = AFRAME.utils.throttleLeadingAndTrailing( () => {
if( this.el.sceneEl.renderer.xr.isPresenting ){
// workaround
// xterm relies on window.requestAnimationFrame (which is not called WebXR immersive mode)
//this.term._core.viewport._innerRefresh()
this.term._core.renderer._renderDebouncer._innerRefresh()
}
}, this.data.canvasLatency)
// Build up a theme object // Build up a theme object
const theme = Object.keys(this.data).reduce((theme, key) => { const theme = Object.keys(this.data).reduce((theme, key) => {
if (!key.startsWith('theme_')) return theme if (!key.startsWith('theme_')) return theme
@ -158,13 +143,21 @@ AFRAME.registerComponent('xterm', {
disableStdin: false, disableStdin: false,
rows: this.data.rows, rows: this.data.rows,
cols: this.data.cols, cols: this.data.cols,
fontFamily: 'Cousine, monospace',
fontSize: this.fontSize, fontSize: this.fontSize,
lineHeight: 1.15, lineHeight: 1.15,
useFlowControl: true, useFlowControl: true,
rendererType: this.renderType // 'dom' // 'canvas' rendererType: this.renderType // 'dom' // 'canvas'
}) })
this.tick = AFRAME.utils.throttleLeadingAndTrailing( () => {
if( this.el.sceneEl.renderer.xr.isPresenting ){
// workaround
// xterm relies on window.requestAnimationFrame (which is not called WebXR immersive mode)
//this.term._core.viewport._innerRefresh()
this.term._core.renderer._renderDebouncer._innerRefresh()
}
}, this.data.canvasLatency)
this.term.open(terminalElement) this.term.open(terminalElement)
this.term.focus() this.term.focus()
this.setRenderType('dom') this.setRenderType('dom')