added iso-agnostic single-file AFRAME lib

This commit is contained in:
Leon van Kammen 2025-01-27 16:03:37 +01:00
parent ef890c8c34
commit 6c7667cd80
5 changed files with 23 additions and 17 deletions

View File

@ -150,6 +150,8 @@ ISOTerminal.prototype.start = function(opts){
ISOTerminal.prototype.setupWorker = function(opts){ ISOTerminal.prototype.setupWorker = function(opts){
if( typeof window.PromiseWorker == 'undefined' ) return this
/* /*
* the WebWorker (which runs v86) * the WebWorker (which runs v86)
* *

View File

@ -40,19 +40,21 @@ ISOTerminal.prototype.boot = async function(e){
ISOTerminal.prototype.boot.menu = [] ISOTerminal.prototype.boot.menu = []
// REPL: iso // REPL: iso
ISOTerminal.prototype.boot.menu.push( 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 ${String(opts.iso || "").replace(/.*\//,'')} Linux ❤️ `, key: "1",
init: function(){ this.bootISO() }, title: (opts) => `boot ${String(opts.iso || "").replace(/.*\//,'')} Linux ❤️ `,
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker init: function(){ this.bootISO() },
} keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
) }
)
}
// REPL: jsconsole // REPL: jsconsole
ISOTerminal.prototype.boot.menu.push( ISOTerminal.prototype.boot.menu.push(
{ {
key: "2", key: "j",
title: (opts) => "just give me an javascript-console in WebXR instantly", title: (opts) => "just give me an javascript-console in WebXR instantly",
init: function(){ init: function(){
this.prompt = "\r> " this.prompt = "\r> "
@ -60,7 +62,7 @@ ISOTerminal.prototype.boot.menu.push(
this.emit('status',"javascript console") this.emit('status',"javascript console")
this.console = "" this.console = ""
setTimeout( () => { setTimeout( () => {
if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt) this.emit('serial-output-string', this.prompt)
}, 100 ) }, 100 )
}, },
keyHandler: function(ch){ keyHandler: function(ch){
@ -72,7 +74,9 @@ ISOTerminal.prototype.boot.menu.push(
this.emit('serial-output-string', ch) this.emit('serial-output-string', ch)
const reset = () => { const reset = () => {
this.console = "" this.console = ""
setTimeout( () => "\n\r"+this.emit('serial-output-string', this.prompt),100) setTimeout( () => {
if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt)
},100)
} }
if( (ch == "\n" || ch == "\r") ){ if( (ch == "\n" || ch == "\r") ){
try{ try{

View File

@ -3,7 +3,7 @@ ISOTerminal.prototype.redirectConsole = function(handler){
const dir = console.dir; const dir = console.dir;
const err = console.error; const err = console.error;
const warn = console.warn; const warn = console.warn;
const addLineFeeds = (str) => typeof str == 'string' ? str.replace(/\n/g,"\n\r") : str const addLineFeeds = (str) => typeof str == 'string' ? str.replace(/\n/g,"\r\n") : str
console.log = (...args)=>{ console.log = (...args)=>{
const textArg = args[0]; const textArg = args[0];

View File

@ -16,7 +16,6 @@ AFRAME.utils.require = function(arr_or_obj,opts){
opts = opts || {} opts = opts || {}
let i = 0 let i = 0
let deps = [] let deps = []
AFRAME.required = AFRAME.required || {}
let packagesArr = arr_or_obj.map ? arr_or_obj : Object.values(arr_or_obj) let packagesArr = arr_or_obj.map ? arr_or_obj : Object.values(arr_or_obj)
const parseURI = function(uri){ const parseURI = function(uri){
@ -36,8 +35,8 @@ AFRAME.utils.require = function(arr_or_obj,opts){
} }
// prevent duplicate requests // prevent duplicate requests
if( AFRAME.required[id] ) return // already loaded before if( AFRAME.utils.require.required[id] ) return // already loaded before
AFRAME.required[id] = true AFRAME.utils.require.required[id] = true
if( !document.body.querySelector(`script#${id}`) && if( !document.body.querySelector(`script#${id}`) &&
!document.body.querySelector(`link#${id}`) ){ !document.body.querySelector(`link#${id}`) ){
@ -72,4 +71,6 @@ AFRAME.utils.require = function(arr_or_obj,opts){
return Promise.all(deps) return Promise.all(deps)
} }
AFRAME.utils.require.required = {}
AFRAME.utils.require.baseURL = './com/' AFRAME.utils.require.baseURL = './com/'

View File

@ -41,8 +41,7 @@ AFRAME.registerComponent('window', {
dependencies:{ dependencies:{
dom: "com/dom.js", dom: "com/dom.js",
winboxjs: "https://unpkg.com/winbox@0.2.82/dist/winbox.bundle.min.js", // deadsimple windows: https://nextapps-de.github.io/winbox winboxjs: "../assets/winbox.bundle.min.js", // deadsimple windows: https://nextapps-de.github.io/winbox
//winboxcss: "https://unpkg.com/winbox@0.2.82/dist/css/winbox.min.css", // main theme
}, },
init: function(){ init: function(){