2024-10-01 19:07:03 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* css/html template
|
|
|
|
*
|
|
|
|
* ┌─────────┐ ┌────────────┐ ┌─────────────┐ exit-AR
|
|
|
|
* ┌───────►│ com/dom ┼──►│ com/window ├─►│ domrenderer │◄────────── exit-VR ◄─┐
|
|
|
|
* │ └─────────┘ └────────────┘ └─────▲───────┘ │
|
2024-10-18 13:50:56 +02:00
|
|
|
* │ │ ┌───────────────┐ │
|
2024-10-01 19:07:03 +02:00
|
|
|
* ┌──────────┴────────┐ ┌─────┴──────┐ │ xterm.js │ ┌─────────────────────────────┐
|
|
|
|
* │ com/isoterminal ├────────────────────────────►│com/xterm.js│◄─┤ │ │com/html-as-texture-in-XR.js │
|
|
|
|
* └────────┬─┬────────┘ └──┬──────┬▲─┘ │ xterm.css │ └─────────────────────────────┘
|
|
|
|
* │ │ ┌────────┐ ┌─────────▼──┐ ││ └───────────────┘ │ ▲
|
|
|
|
* │ └───────►│ plane ├─────►text───┼►canvas │◄────────────────── enter-VR │ │
|
2024-10-18 13:50:56 +02:00
|
|
|
* │ └────────┘ └────────────┘ ││ enter-AR ◄─┘ │
|
|
|
|
* │ renderer=canvas ││ │
|
2024-10-01 19:07:03 +02:00
|
|
|
* │ ││ │
|
|
|
|
* │ ISOTerminal.js ││ │
|
|
|
|
* │ ┌───────────────────────────┐◄────┘│ │
|
|
|
|
* │ │ com/isoterminal/worker.js ├──────┘ │
|
|
|
|
* │ └──────────────┌────────────┤ │
|
|
|
|
* │ │ v86.js │ │
|
|
|
|
* │ │ feat/*.js │ │
|
|
|
|
* │ │ libv86.js │ │
|
|
|
|
* │ └────────────┘ │
|
|
|
|
* │ │
|
|
|
|
* └────────────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
*
|
|
|
|
* NOTE: For convenience reasons, events are forwarded between com/isoterminal.js, worker.js and ISOTerminal
|
|
|
|
* Instead of a melting pot of different functionnames, events are flowing through everything (ISOTerminal.emit())
|
|
|
|
*/
|
2024-09-03 18:33:35 +02:00
|
|
|
|
|
|
|
if( typeof AFRAME != 'undefined '){
|
|
|
|
|
|
|
|
AFRAME.registerComponent('isoterminal', {
|
|
|
|
schema: {
|
2024-10-04 17:49:15 +02:00
|
|
|
iso: { type:"string", "default":"https://forgejo.isvery.ninja/assets/xrsh-buildroot/main/xrsh.iso" },
|
|
|
|
overlayfs: { type:"string"},
|
2024-10-22 08:59:53 +02:00
|
|
|
width: { type: 'number',"default": -1 },
|
|
|
|
height: { type: 'number',"default": -1 },
|
2024-10-23 18:50:07 +02:00
|
|
|
depth: { type: 'number',"default": 0.03 },
|
2024-10-22 08:59:53 +02:00
|
|
|
lineHeight: { type: 'number',"default": 18 },
|
2024-10-04 17:49:15 +02:00
|
|
|
padding: { type: 'number',"default": 18 },
|
2024-10-22 08:59:53 +02:00
|
|
|
maximized: { type: 'boolean',"default":true},
|
2024-10-15 12:32:16 +02:00
|
|
|
muteUntilPrompt:{ type: 'boolean',"default":true}, // mute stdout until a prompt is detected in ISO
|
|
|
|
HUD: { type: 'boolean',"default":false}, // link to camera movement
|
|
|
|
transparent: { type:'boolean', "default":false }, // need good gpu
|
2024-10-23 18:50:07 +02:00
|
|
|
memory: { type: 'number', "default":40 }, // VM memory (in MB) [NOTE: quest or smartphone might crash > 40mb ]
|
|
|
|
bufferLatency: { type: 'number', "default":1 }, // in ms: bufferlatency from webworker to xterm (batch-update every char to texture)
|
2024-10-15 12:32:16 +02:00
|
|
|
debug: { type: 'boolean', "default":false }
|
2024-09-17 18:59:38 +02:00
|
|
|
},
|
2024-08-27 20:40:05 +02:00
|
|
|
|
2024-09-23 22:31:28 +02:00
|
|
|
init: function(){
|
2024-09-03 18:33:35 +02:00
|
|
|
this.el.object3D.visible = false
|
2024-10-22 08:59:53 +02:00
|
|
|
|
2024-10-23 18:50:07 +02:00
|
|
|
this.calculateDimension()
|
2024-10-04 17:49:15 +02:00
|
|
|
this.initHud()
|
2024-10-23 18:50:07 +02:00
|
|
|
this.setupBox()
|
2024-11-15 10:23:06 +01:00
|
|
|
this.setupPasteDrop()
|
2024-10-23 18:50:07 +02:00
|
|
|
|
2024-09-16 13:38:55 +02:00
|
|
|
fetch(this.data.iso,{method: 'HEAD'})
|
|
|
|
.then( (res) => {
|
|
|
|
if( res.status != 200 ) throw 'not found'
|
|
|
|
})
|
|
|
|
.catch( (e) => {
|
|
|
|
console.warn(this.data.iso+" could not be loaded, loading fallback ISO URL:")
|
|
|
|
console.warn(this.schema.iso.default)
|
|
|
|
this.data.iso = this.schema.iso.default
|
|
|
|
})
|
|
|
|
.finally( () => this.initTerminal(true) )
|
2024-09-03 18:33:35 +02:00
|
|
|
},
|
2024-08-13 18:08:03 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
requires:{
|
2024-10-15 12:32:16 +02:00
|
|
|
com: "com/dom.js",
|
|
|
|
window: "com/window.js",
|
2024-11-15 10:23:06 +01:00
|
|
|
pastedrop: "com/pastedrop.js",
|
2024-10-15 12:32:16 +02:00
|
|
|
v86: "com/isoterminal/libv86.js",
|
2024-10-22 08:59:53 +02:00
|
|
|
vt100: "com/isoterminal/VT100.js",
|
2024-09-06 18:02:54 +02:00
|
|
|
// allow xrsh to selfcontain scene + itself
|
2024-11-15 10:23:06 +01:00
|
|
|
xhook: "com/lib/xhook.min.js",
|
2024-10-15 12:32:16 +02:00
|
|
|
selfcontain: "com/selfcontainer.js",
|
2024-09-04 20:44:49 +02:00
|
|
|
// html to texture
|
2024-10-15 12:32:16 +02:00
|
|
|
htmlinxr: "com/html-as-texture-in-xr.js",
|
2024-10-23 18:50:07 +02:00
|
|
|
// isoterminal global features
|
2024-10-15 12:32:16 +02:00
|
|
|
PromiseWorker: "com/isoterminal/PromiseWorker.js",
|
|
|
|
ISOTerminal: "com/isoterminal/ISOTerminal.js",
|
2024-10-23 18:50:07 +02:00
|
|
|
localforage: "com/isoterminal/localforage.js",
|
2024-09-03 18:33:35 +02:00
|
|
|
},
|
2024-08-13 18:08:03 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
dom: {
|
2024-10-23 18:50:07 +02:00
|
|
|
scale: 0.66,
|
2024-09-03 18:33:35 +02:00
|
|
|
events: ['click','keydown'],
|
2024-09-16 13:28:28 +02:00
|
|
|
html: (me) => `<div class="isoterminal">
|
2024-10-23 18:50:07 +02:00
|
|
|
<div id="term" tabindex="0">
|
2024-10-22 08:59:53 +02:00
|
|
|
<pre></pre>
|
|
|
|
</div>
|
2024-09-16 13:28:28 +02:00
|
|
|
</div>`,
|
2024-09-03 18:33:35 +02:00
|
|
|
|
|
|
|
css: (me) => `.isoterminal{
|
|
|
|
padding: ${me.com.data.padding}px;
|
|
|
|
width:100%;
|
2024-10-24 16:24:51 +02:00
|
|
|
height:90%;
|
2024-10-21 14:03:16 +02:00
|
|
|
position:relative;
|
2024-09-03 18:33:35 +02:00
|
|
|
}
|
2024-10-02 21:03:04 +02:00
|
|
|
.isoterminal div{
|
2024-10-24 16:36:41 +02:00
|
|
|
display:block;
|
2024-10-02 21:03:04 +02:00
|
|
|
position:relative;
|
2024-10-22 08:59:53 +02:00
|
|
|
line-height: ${me.com.data.lineHeight}px;
|
|
|
|
}
|
2024-10-23 18:50:07 +02:00
|
|
|
#term {
|
2024-10-22 08:59:53 +02:00
|
|
|
outline: none !important;
|
2024-10-02 21:03:04 +02:00
|
|
|
}
|
2024-09-17 18:59:38 +02:00
|
|
|
@font-face {
|
|
|
|
font-family: 'Cousine';
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: 400;
|
2024-09-23 18:01:40 +02:00
|
|
|
src: url(./com/isoterminal/assets/Cousine.ttf) format('truetype');
|
|
|
|
}
|
|
|
|
@font-face {
|
|
|
|
font-family: 'Cousine';
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: 700;
|
|
|
|
src: url(./com/isoterminal/assets/CousineBold.ttf) format('truetype');
|
2024-09-17 18:59:38 +02:00
|
|
|
}
|
2024-09-03 18:33:35 +02:00
|
|
|
|
|
|
|
.isoterminal style{ display:none }
|
|
|
|
|
2024-10-22 08:59:53 +02:00
|
|
|
blink{
|
|
|
|
border:none;
|
|
|
|
padding:none;
|
|
|
|
}
|
|
|
|
|
2024-10-01 19:07:03 +02:00
|
|
|
#overlay .winbox:has(> .isoterminal){
|
|
|
|
background:transparent;
|
|
|
|
box-shadow:none;
|
|
|
|
}
|
|
|
|
|
2024-10-24 16:24:51 +02:00
|
|
|
.cursor {
|
|
|
|
background: #70F !important;
|
|
|
|
animation:fade 1000ms infinite;
|
|
|
|
-webkit-animation:fade 1000ms infinite;
|
|
|
|
}
|
|
|
|
|
|
|
|
.XR .cursor {
|
|
|
|
animation:none;
|
|
|
|
-webkit-animation:none;
|
|
|
|
}
|
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
.wb-body:has(> .isoterminal){
|
2024-10-15 12:32:16 +02:00
|
|
|
background: #000C;
|
2024-09-03 18:33:35 +02:00
|
|
|
overflow:hidden;
|
|
|
|
}
|
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
.XR .wb-body:has(> .isoterminal){
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.XR .isoterminal{
|
2024-09-17 18:59:38 +02:00
|
|
|
background: #000;
|
|
|
|
}
|
2024-10-22 08:59:53 +02:00
|
|
|
.isoterminal *{
|
|
|
|
font-size: 14px;
|
|
|
|
font-family: "Cousine",Liberation Mono,DejaVu Sans Mono,Courier New,monospace;
|
|
|
|
font-weight:500 !important;
|
|
|
|
text-shadow: 0px 0px 10px #F075;
|
2024-10-01 19:07:03 +02:00
|
|
|
}
|
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
@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; }
|
|
|
|
}
|
|
|
|
|
2024-10-02 21:03:04 +02:00
|
|
|
.blink{
|
2024-09-03 18:33:35 +02:00
|
|
|
animation:fade 1000ms infinite;
|
|
|
|
-webkit-animation:fade 1000ms infinite;
|
|
|
|
}
|
2024-09-25 15:58:40 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
`
|
|
|
|
},
|
2024-08-29 17:18:14 +02:00
|
|
|
|
2024-09-06 18:02:54 +02:00
|
|
|
initTerminal: async function(singleton){
|
2024-09-06 10:30:24 +02:00
|
|
|
|
2024-10-22 08:59:53 +02:00
|
|
|
// why not latest xterm or v3.12 with builtin-canvas support?
|
|
|
|
// first versions used 1.5.4, a typescript rewrite which:
|
|
|
|
// * 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 allow switching between dom/canvas
|
|
|
|
// * only allows a standalone WebGL addon (conflicts with THREE)
|
|
|
|
// * heavily dependent on requestAnimationFrame (conflicts with THREE)
|
|
|
|
// * typescript-rewrite results in ~300k lib (instead of 96k)
|
|
|
|
// * v3.12 had slightly better performance but still very heavy
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-01 19:07:03 +02:00
|
|
|
await AFRAME.utils.require(this.requires)
|
|
|
|
await AFRAME.utils.require({ // ISOTerminal plugins
|
|
|
|
boot: "com/isoterminal/feat/boot.js",
|
|
|
|
javascript: "com/isoterminal/feat/javascript.js",
|
|
|
|
jsconsole: "com/isoterminal/feat/jsconsole.js",
|
2024-10-02 21:03:04 +02:00
|
|
|
indexhtml: "com/isoterminal/feat/index.html.js",
|
|
|
|
indexjs: "com/isoterminal/feat/index.js.js",
|
2024-11-15 10:23:06 +01:00
|
|
|
autorestore: "com/isoterminal/feat/autorestore.js",
|
|
|
|
pastedropFeat: "com/isoterminal/feat/pastedrop.js",
|
2024-11-18 21:18:33 +01:00
|
|
|
httpfs: "com/isoterminal/feat/httpfs.js",
|
2024-10-01 19:07:03 +02:00
|
|
|
})
|
2024-09-06 10:30:24 +02:00
|
|
|
|
2024-09-06 18:02:54 +02:00
|
|
|
this.el.setAttribute("selfcontainer","")
|
|
|
|
|
|
|
|
// *DISABLED* instance this component
|
|
|
|
// rason: we only need one term for now (more = too cpu heavy)
|
|
|
|
let instance
|
|
|
|
if( singleton ){
|
|
|
|
instance = this.el
|
|
|
|
}else{
|
|
|
|
if( this.instance ){
|
|
|
|
const el = document.querySelector('.isoterminal')
|
|
|
|
return console.warn('TODO: allow multiple terminals for future beefy devices(see v86 examples)')
|
|
|
|
}
|
|
|
|
instance = this.instance = this.el.cloneNode(false)
|
|
|
|
this.el.sceneEl.appendChild( instance )
|
|
|
|
}
|
2024-09-06 10:30:24 +02:00
|
|
|
|
|
|
|
// init isoterminal
|
2024-10-15 12:32:16 +02:00
|
|
|
this.term = new ISOTerminal(instance,this.data)
|
2024-09-06 10:30:24 +02:00
|
|
|
|
|
|
|
instance.addEventListener('DOMready', () => {
|
2024-10-23 18:50:07 +02:00
|
|
|
this.setupVT100(instance)
|
|
|
|
setTimeout( () => {
|
|
|
|
instance.setAttribute("html-as-texture-in-xr", `domid: #term; faceuser: true`)
|
|
|
|
},100)
|
2024-09-16 13:28:28 +02:00
|
|
|
//instance.winbox.resize(720,380)
|
2024-10-22 08:59:53 +02:00
|
|
|
let size = `width: ${this.data.width}; height: ${this.data.height}`
|
2024-09-17 18:59:38 +02:00
|
|
|
instance.setAttribute("window", `title: xrsh.iso; uid: ${instance.uid}; attach: #overlay; dom: #${instance.dom.id}; ${size}; min: ${this.data.minimized}; max: ${this.data.maximized}`)
|
2024-09-06 10:30:24 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
instance.addEventListener('window.oncreate', (e) => {
|
|
|
|
instance.dom.classList.add('blink')
|
2024-10-21 14:03:16 +02:00
|
|
|
|
2024-09-06 10:30:24 +02:00
|
|
|
// run iso
|
|
|
|
let opts = {dom:instance.dom}
|
|
|
|
for( let i in this.data ) opts[i] = this.data[i]
|
2024-10-23 18:50:07 +02:00
|
|
|
opts.cols = this.cols
|
|
|
|
opts.rows = this.rows
|
2024-10-15 12:32:16 +02:00
|
|
|
this.term.start(opts)
|
2024-09-06 10:30:24 +02:00
|
|
|
})
|
|
|
|
|
2024-11-15 10:23:06 +01:00
|
|
|
instance.setAttribute("dom", "")
|
|
|
|
instance.setAttribute("pastedrop", "")
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
this.term.addEventListener('ready', (e) => {
|
2024-09-06 10:30:24 +02:00
|
|
|
instance.dom.classList.remove('blink')
|
2024-10-15 12:32:16 +02:00
|
|
|
this.term.emit('status',"running")
|
|
|
|
if( this.data.debug ) this.runTests()
|
2024-09-06 10:30:24 +02:00
|
|
|
})
|
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
this.term.addEventListener('status', function(e){
|
2024-09-06 10:30:24 +02:00
|
|
|
let msg = e.detail
|
|
|
|
const w = instance.winbox
|
|
|
|
if(!w) return
|
|
|
|
w.titleBak = w.titleBak || w.title
|
2024-09-16 13:28:28 +02:00
|
|
|
w.setTitle( `${w.titleBak} [${msg}]` )
|
2024-09-06 10:30:24 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
instance.addEventListener('window.onclose', (e) => {
|
|
|
|
if( !confirm('do you want to kill this virtual machine and all its processes?') ) e.halt = true
|
|
|
|
})
|
|
|
|
|
2024-09-16 13:28:28 +02:00
|
|
|
const resize = (w,h) => { }
|
2024-09-06 10:30:24 +02:00
|
|
|
instance.addEventListener('window.onresize', resize )
|
|
|
|
instance.addEventListener('window.onmaximize', resize )
|
|
|
|
|
2024-10-03 12:41:53 +02:00
|
|
|
const focus = (showdom) => (e) => {
|
2024-10-24 16:24:51 +02:00
|
|
|
this.el.emit('focus',e.detail)
|
2024-10-15 12:32:16 +02:00
|
|
|
if( this.el.components.window && this.data.renderer == 'canvas'){
|
2024-10-03 12:41:53 +02:00
|
|
|
this.el.components.window.show( showdom )
|
|
|
|
}
|
2024-09-06 18:02:54 +02:00
|
|
|
}
|
2024-09-17 18:59:38 +02:00
|
|
|
|
2024-10-04 17:49:15 +02:00
|
|
|
this.el.addEventListener('obbcollisionstarted', focus(false) )
|
2024-10-03 12:41:53 +02:00
|
|
|
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) )
|
2024-09-17 18:59:38 +02:00
|
|
|
|
2024-09-06 10:30:24 +02:00
|
|
|
instance.object3D.quaternion.copy( AFRAME.scenes[0].camera.quaternion ) // face towards camera
|
|
|
|
},
|
|
|
|
|
2024-10-04 17:49:15 +02:00
|
|
|
initHud: function(){
|
|
|
|
if( AFRAME.utils.device.isMobile() ) this.data.HUD = true
|
|
|
|
if( this.data.HUD ){
|
|
|
|
document.querySelector('[camera]').appendChild( this.el )
|
|
|
|
this.el.setAttribute("position","0 -0.03 -0.4")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
runTests: async function(){
|
|
|
|
await AFRAME.utils.require({
|
|
|
|
"test_util": "tests/util.js",
|
|
|
|
"test_isoterminal":"tests/ISOTerminal.js"
|
|
|
|
})
|
|
|
|
console.test.run()
|
|
|
|
},
|
|
|
|
|
2024-10-21 14:03:16 +02:00
|
|
|
setupVT100: function(instance){
|
2024-10-23 18:50:07 +02:00
|
|
|
const el = this.el.dom.querySelector('#term')
|
2024-11-15 10:23:06 +01:00
|
|
|
this.term.opts.vt100 = {
|
2024-10-23 18:50:07 +02:00
|
|
|
cols: this.cols,
|
|
|
|
rows: this.rows,
|
|
|
|
el_or_id: el,
|
2024-10-24 16:24:51 +02:00
|
|
|
max_scroll_lines: this.rows,
|
|
|
|
nodim: true,
|
|
|
|
rainbow: [VT100.COLOR_MAGENTA, VT100.COLOR_CYAN ],
|
|
|
|
xr: AFRAME.scenes[0].renderer.xr
|
2024-10-23 18:50:07 +02:00
|
|
|
}
|
2024-11-15 10:23:06 +01:00
|
|
|
this.term.emit('initVT100',this)
|
|
|
|
this.vt100 = new VT100( this.term.opts.vt100 )
|
2024-10-23 18:50:07 +02:00
|
|
|
this.vt100.el = el
|
2024-10-22 08:59:53 +02:00
|
|
|
this.vt100.curs_set( 1, true)
|
2024-10-24 16:24:51 +02:00
|
|
|
this.vt100.focus()
|
|
|
|
this.el.addEventListener('focus', () => this.vt100.focus() )
|
2024-10-22 08:59:53 +02:00
|
|
|
this.vt100.getch( (ch,t) => {
|
|
|
|
this.term.send( ch )
|
|
|
|
})
|
|
|
|
|
2024-10-21 14:03:16 +02:00
|
|
|
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)
|
|
|
|
})
|
2024-11-15 10:23:06 +01:00
|
|
|
|
|
|
|
// translate file upload into pasteFile
|
|
|
|
this.vt100.upload.addEventListener('change', (e) => {
|
|
|
|
const file = this.vt100.upload.files[0];
|
|
|
|
const item = {...file, getAsFile: () => file }
|
|
|
|
this.el.emit('pasteFile', { item, type: file.type });
|
|
|
|
})
|
|
|
|
|
|
|
|
return this
|
|
|
|
},
|
|
|
|
|
|
|
|
setupPasteDrop: function(){
|
|
|
|
this.el.addEventListener('pasteFile', (e) => {
|
|
|
|
e.preventDefault() // prevent bubbling up to window (which is triggering this initially)
|
|
|
|
if( !this.term.pasteFile ) return // skip if feat/pastedrop.js is not loaded
|
|
|
|
this.term.pasteFile(e.detail)
|
|
|
|
})
|
|
|
|
return this
|
2024-10-21 14:03:16 +02:00
|
|
|
},
|
|
|
|
|
2024-10-23 18:50:07 +02:00
|
|
|
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(){
|
2024-10-24 16:24:51 +02:00
|
|
|
if( this.data.width == -1 ) this.data.width = document.body.offsetWidth;
|
|
|
|
if( this.data.height == -1 ) this.data.height = Math.floor( document.body.offsetHeight - 30 )
|
2024-10-23 18:50:07 +02:00
|
|
|
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
|
2024-10-24 16:24:51 +02:00
|
|
|
this.cols = Math.floor(this.data.width/this.data.lineHeight*2)
|
|
|
|
this.rows = Math.floor(this.data.height*0.53/this.data.lineHeight*1.7)
|
2024-10-23 18:50:07 +02:00
|
|
|
},
|
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
events:{
|
2024-08-13 18:08:03 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
// combined AFRAME+DOM reactive events
|
|
|
|
click: function(e){ }, //
|
|
|
|
keydown: function(e){ },
|
2024-07-23 17:19:38 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
// reactive events for this.data updates
|
|
|
|
myvalue: function(e){ this.el.dom.querySelector('b').innerText = this.data.myvalue },
|
2024-07-23 17:19:38 +02:00
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
launcher: async function(){
|
2024-09-06 10:30:24 +02:00
|
|
|
this.initTerminal()
|
2024-08-13 18:08:03 +02:00
|
|
|
}
|
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
manifest: { // HTML5 manifest to identify app to xrsh
|
|
|
|
"iso": "linux-x64-4.15.iso",
|
|
|
|
"short_name": "ISOTerm",
|
|
|
|
"name": "terminal",
|
|
|
|
"icons": [
|
|
|
|
{
|
|
|
|
"src": "https://css.gg/terminal.svg",
|
|
|
|
"src": "data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIyNCIKICBoZWlnaHQ9IjI0IgogIHZpZXdCb3g9IjAgMCAyNCAyNCIKICBmaWxsPSJub25lIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKPgogIDxwYXRoCiAgICBkPSJNNS4wMzMzIDE0LjgyODRMNi40NDc1MSAxNi4yNDI2TDEwLjY5MDIgMTJMNi40NDc1MSA3Ljc1NzMzTDUuMDMzMyA5LjE3MTU1TDcuODYxNzIgMTJMNS4wMzMzIDE0LjgyODRaIgogICAgZmlsbD0iY3VycmVudENvbG9yIgogIC8+CiAgPHBhdGggZD0iTTE1IDE0SDExVjE2SDE1VjE0WiIgZmlsbD0iY3VycmVudENvbG9yIiAvPgogIDxwYXRoCiAgICBmaWxsLXJ1bGU9ImV2ZW5vZGQiCiAgICBjbGlwLXJ1bGU9ImV2ZW5vZGQiCiAgICBkPSJNMiAyQzAuODk1NDMxIDIgMCAyLjg5NTQzIDAgNFYyMEMwIDIxLjEwNDYgMC44OTU0MyAyMiAyIDIySDIyQzIzLjEwNDYgMjIgMjQgMjEuMTA0NiAyNCAyMFY0QzI0IDIuODk1NDMgMjMuMTA0NiAyIDIyIDJIMlpNMjIgNEgyTDIgMjBIMjJWNFoiCiAgICBmaWxsPSJjdXJyZW50Q29sb3IiCiAgLz4KPC9zdmc+",
|
|
|
|
"type": "image/svg+xml",
|
|
|
|
"sizes": "512x512"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"id": "/?source=pwa",
|
|
|
|
"start_url": "/?source=pwa",
|
|
|
|
"background_color": "#3367D6",
|
|
|
|
"display": "standalone",
|
|
|
|
"scope": "/",
|
|
|
|
"theme_color": "#3367D6",
|
|
|
|
"shortcuts": [
|
|
|
|
{
|
|
|
|
"name": "What is the latest news?",
|
|
|
|
"cli":{
|
|
|
|
"usage": "helloworld <type> [options]",
|
|
|
|
"example": "helloworld news",
|
|
|
|
"args":{
|
|
|
|
"--latest": {type:"string"}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"short_name": "Today",
|
|
|
|
"description": "View weather information for today",
|
|
|
|
"url": "/today?source=pwa",
|
|
|
|
"icons": [{ "src": "/images/today.png", "sizes": "192x192" }]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "Hello world information",
|
|
|
|
"screenshots": [
|
|
|
|
{
|
|
|
|
"src": "/images/screenshot1.png",
|
|
|
|
"type": "image/png",
|
|
|
|
"sizes": "540x720",
|
|
|
|
"form_factor": "narrow"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"help":`
|
|
|
|
Helloworld application
|
|
|
|
|
|
|
|
This is a help file which describes the application.
|
|
|
|
It will be rendered thru troika text, and will contain
|
|
|
|
headers based on non-punctualized lines separated by linebreaks,
|
|
|
|
in above's case "\nHelloworld application\n" will qualify as header.
|
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|