limit to 1 terminal + several fixes
/ mirror_to_github (push) Successful in 34s Details
/ test (push) Successful in 7s Details

This commit is contained in:
Leon van Kammen 2024-07-23 13:05:59 +00:00
parent c668a8ba8f
commit 157ec6da1f
4 changed files with 44 additions and 5 deletions

View File

@ -65,6 +65,7 @@ AFRAME.registerComponent('dom',{
if( !overlay ){ if( !overlay ){
overlay = document.createElement('div') overlay = document.createElement('div')
overlay.id = "overlay" overlay.id = "overlay"
overlay.setAttribute('style','position:fixed;top:0px;left:0px;right:0px;bottom:0px')
document.body.appendChild(overlay) document.body.appendChild(overlay)
// sceneEl.setAttribute("webxr","overlayElement:#overlay") // sceneEl.setAttribute("webxr","overlayElement:#overlay")
} }

View File

@ -45,6 +45,23 @@ AFRAME.registerComponent('isoterminal', {
.wb-body:has(> .isoterminal){ background: #000; } .wb-body:has(> .isoterminal){ background: #000; }
.isoterminal div{ display:block; } .isoterminal div{ display:block; }
.isoterminal span{ display: inline } .isoterminal span{ display: inline }
@keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.5; }
to { opacity: 1.0; }
}
@-webkit-keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.5; }
to { opacity: 1.0; }
}
.blink {
animation:fade 1000ms infinite;
-webkit-animation:fade 1000ms infinite;
}
` `
}, },
@ -65,7 +82,7 @@ AFRAME.registerComponent('isoterminal', {
url: this.data.iso, url: this.data.iso,
}, },
network_relay_url: "<UNUSED>", network_relay_url: "<UNUSED>",
cmdline: "rw root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose modules=virtio_pci tsc=reliable init_on_free=on", cmdline: "rw root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose modules=virtio_pci tsc=reliable init_on_free=on init=/bin/date",
//bzimage:{ //bzimage:{
// url: "com/isoterminal/images/buildroot-bzimage.bin" // url: "com/isoterminal/images/buildroot-bzimage.bin"
//}, //},
@ -74,7 +91,7 @@ AFRAME.registerComponent('isoterminal', {
// baseurl: "com/isoterminal/v86/images/alpine-rootfs-flat", // baseurl: "com/isoterminal/v86/images/alpine-rootfs-flat",
// basefs: "com/isoterminal/v86/images/alpine-fs.json", // basefs: "com/isoterminal/v86/images/alpine-fs.json",
// }, // },
screen_dummy: true, //screen_dummy: true,
autostart: true, autostart: true,
}); });
@ -97,9 +114,16 @@ AFRAME.registerComponent('isoterminal', {
}, },
launcher: async function(){ launcher: async function(){
if( this.instance ){
const el = document.querySelector('.isoterminal')
el.classList.add('blink')
setTimeout( () => el.classList.remove('blink'), 2000 )
return console.warn('TODO: allow multiple terminals (see v86 examples)')
}
let s = await AFRAME.utils.require(this.requires) let s = await AFRAME.utils.require(this.requires)
// instance this component // instance this component
const instance = this.el.cloneNode(false) const instance = this.instance = this.el.cloneNode(false)
this.el.sceneEl.appendChild( instance ) this.el.sceneEl.appendChild( instance )
instance.addEventListener('DOMready', () => { instance.addEventListener('DOMready', () => {
@ -108,6 +132,7 @@ AFRAME.registerComponent('isoterminal', {
}) })
instance.addEventListener('window.oncreate', (e) => { instance.addEventListener('window.oncreate', (e) => {
instance.dom.classList.add('blink')
// resize after the dom content has been rendered & updated // resize after the dom content has been rendered & updated
setTimeout( () => { setTimeout( () => {
let spans = [...instance.dom.querySelectorAll('span')] let spans = [...instance.dom.querySelectorAll('span')]
@ -116,6 +141,7 @@ AFRAME.registerComponent('isoterminal', {
((spans.length * spans[0].offsetHeight) ) +'px' ((spans.length * spans[0].offsetHeight) ) +'px'
) )
},1200) },1200)
setTimeout( () => instance.dom.classList.remove('blink'), 5000 )
}) })
instance.addEventListener('window.onclose', (e) => { instance.addEventListener('window.onclose', (e) => {

View File

@ -1,4 +1,4 @@
AFRAME.registerComponent('add', { AFRAME.registerComponent('launcher-optional', {
schema:{ schema:{
comps: {type:"array"} comps: {type:"array"}
}, },

View File

@ -24,11 +24,23 @@ AFRAME.registerComponent('save', {
r.remove() r.remove()
// *TODO* dont crash on hands // *TODO* dont crash on hands
this.inlineFiles() this.save_state()
.then( this.inlineFiles )
.then( () => this.download(document.documentElement.innerHTML,"xrsh.html") ) .then( () => this.download(document.documentElement.innerHTML,"xrsh.html") )
.catch(console.error) .catch(console.error)
}, },
save_state: async function(){
if( window.emulator ){
let binaryString = '';
const state = await emulator.restore_state(state);
uint8Array.forEach(byte => binaryString += String.fromCharCode(byte) );
let b64data = btoa(binaryString);
console.log(b64data)
}
},
download: function(content, filename, contentType){ download: function(content, filename, contentType){
const a = document.createElement('a'); const a = document.createElement('a');
const file = new Blob([document.documentElement.innerHTML], {type: "text/html"}); const file = new Blob([document.documentElement.innerHTML], {type: "text/html"});