2024-09-17 18:59:38 +02:00
|
|
|
|
ISOTerminal.addEventListener('ready', function(e){
|
|
|
|
|
setTimeout( () => this.boot(), 50 ) // because of autorestore.js
|
2024-09-03 18:33:35 +02:00
|
|
|
|
})
|
|
|
|
|
|
2025-01-27 12:00:16 +01:00
|
|
|
|
ISOTerminal.prototype.bootMenu = function(e){
|
|
|
|
|
this.boot.menu.selected = false // reset
|
2025-01-24 17:21:26 +01:00
|
|
|
|
let msg = '\n\r'
|
|
|
|
|
this.boot.menu.map( (m) => {
|
|
|
|
|
msg += `\r[36m ${m.key})[0m ${m.title(this.opts)}\n`
|
|
|
|
|
})
|
|
|
|
|
msg += `\n\r enter choice> `
|
|
|
|
|
this.emit('serial-output-string', msg)
|
2025-01-27 12:00:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ISOTerminal.addEventListener('bootmenu', function(e){ this.bootMenu() })
|
2025-01-24 17:21:26 +01:00
|
|
|
|
|
2024-09-17 18:59:38 +02:00
|
|
|
|
ISOTerminal.prototype.boot = async function(e){
|
2024-09-03 18:33:35 +02:00
|
|
|
|
// set environment
|
2024-10-23 18:50:07 +02:00
|
|
|
|
let env = [
|
|
|
|
|
`export LINES=${this.opts.rows}`,
|
|
|
|
|
`export COLUMNS=${this.opts.cols}`,
|
|
|
|
|
'export BROWSER=1',
|
|
|
|
|
]
|
2024-09-03 18:33:35 +02:00
|
|
|
|
for ( let i in document.location ){
|
2024-10-01 19:07:03 +02:00
|
|
|
|
if( typeof document.location[i] == 'string' ){
|
2024-09-23 18:01:40 +02:00
|
|
|
|
env.push( 'export '+String(i).toUpperCase()+'="'+decodeURIComponent( document.location[i]+'"') )
|
2024-10-01 19:07:03 +02:00
|
|
|
|
}
|
2024-09-03 18:33:35 +02:00
|
|
|
|
}
|
2025-01-15 18:02:30 +01:00
|
|
|
|
await this.worker.create_file("profile.browser", this.convert.toUint8Array( env.join('\n') ) )
|
2024-09-17 18:59:38 +02:00
|
|
|
|
|
2024-09-16 13:28:28 +02:00
|
|
|
|
if( this.serial_input == 0 ){
|
2024-09-17 18:59:38 +02:00
|
|
|
|
if( !this.noboot ){
|
2024-10-04 17:49:15 +02:00
|
|
|
|
this.send("source /etc/profile # \\o/ FOSS powa!\n")
|
2024-09-17 18:59:38 +02:00
|
|
|
|
}
|
2024-09-16 13:28:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-03 18:33:35 +02:00
|
|
|
|
}
|
2025-01-24 17:21:26 +01:00
|
|
|
|
|
2025-01-27 12:00:16 +01:00
|
|
|
|
// here REPL's can be defined
|
|
|
|
|
ISOTerminal.prototype.boot.menu = []
|
|
|
|
|
|
|
|
|
|
// REPL: iso
|
2025-01-27 16:03:37 +01:00
|
|
|
|
if( typeof window.PromiseWorker != 'undefined' ){ // if xrsh v86 is able to run in in worker
|
|
|
|
|
ISOTerminal.prototype.boot.menu.push(
|
|
|
|
|
{
|
|
|
|
|
key: "1",
|
|
|
|
|
title: (opts) => `boot [31m${String(opts.iso || "").replace(/.*\//,'')}[0m Linux ❤️ `,
|
|
|
|
|
init: function(){ this.bootISO() },
|
|
|
|
|
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-09-03 18:33:35 +02:00
|
|
|
|
|
2025-01-27 12:00:16 +01:00
|
|
|
|
// REPL: jsconsole
|
|
|
|
|
ISOTerminal.prototype.boot.menu.push(
|
2025-01-24 17:21:26 +01:00
|
|
|
|
{
|
2025-01-27 16:03:37 +01:00
|
|
|
|
key: "j",
|
2025-01-24 17:21:26 +01:00
|
|
|
|
title: (opts) => "just give me an javascript-console in WebXR instantly",
|
|
|
|
|
init: function(){
|
|
|
|
|
this.prompt = "\r[36m>[0m "
|
|
|
|
|
this.emit('enable-console',{stdout:true})
|
|
|
|
|
this.emit('status',"javascript console")
|
|
|
|
|
this.console = ""
|
2025-01-27 12:00:16 +01:00
|
|
|
|
setTimeout( () => {
|
2025-01-27 16:03:37 +01:00
|
|
|
|
this.emit('serial-output-string', this.prompt)
|
2025-01-27 12:00:16 +01:00
|
|
|
|
}, 100 )
|
2025-01-24 17:21:26 +01:00
|
|
|
|
},
|
|
|
|
|
keyHandler: function(ch){
|
|
|
|
|
let erase = false
|
|
|
|
|
if( ch == '\x7F' ){
|
|
|
|
|
ch = "\b \b" // why does write() not just support \x7F ?
|
|
|
|
|
erase = true
|
|
|
|
|
}
|
|
|
|
|
this.emit('serial-output-string', ch)
|
|
|
|
|
const reset = () => {
|
|
|
|
|
this.console = ""
|
2025-01-27 16:03:37 +01:00
|
|
|
|
setTimeout( () => {
|
|
|
|
|
if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt)
|
|
|
|
|
},100)
|
2025-01-24 17:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
if( (ch == "\n" || ch == "\r") ){
|
|
|
|
|
try{
|
|
|
|
|
this.emit('serial-output-string', "\n\r")
|
|
|
|
|
if( this.console ) eval(this.console)
|
|
|
|
|
reset()
|
|
|
|
|
}catch(e){
|
|
|
|
|
reset()
|
|
|
|
|
throw e // re throw
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if( erase ){
|
|
|
|
|
this.console = this.console.split('').slice(0,-1).join('')
|
|
|
|
|
}else{
|
|
|
|
|
this.console += ch
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-27 12:00:16 +01:00
|
|
|
|
)
|