Skip to content

Commit

Permalink
added iso-agnostic single-file AFRAME lib
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofsalvation committed Jan 27, 2025
1 parent ef890c8 commit 6c7667c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
2 changes: 2 additions & 0 deletions com/isoterminal/ISOTerminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ ISOTerminal.prototype.start = function(opts){

ISOTerminal.prototype.setupWorker = function(opts){

if( typeof window.PromiseWorker == 'undefined' ) return this

/*
* the WebWorker (which runs v86)
*
Expand Down
26 changes: 15 additions & 11 deletions com/isoterminal/feat/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,29 @@ ISOTerminal.prototype.boot = async function(e){
ISOTerminal.prototype.boot.menu = []

// REPL: iso
ISOTerminal.prototype.boot.menu.push(
{
key: "1",
title: (opts) => `boot ${String(opts.iso || "").replace(/.*\//,'')} Linux ❤️ `,
init: function(){ this.bootISO() },
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
}
)
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 ❤️ `,
init: function(){ this.bootISO() },
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
}
)
}

// REPL: jsconsole
ISOTerminal.prototype.boot.menu.push(
{
key: "2",
key: "j",
title: (opts) => "just give me an javascript-console in WebXR instantly",
init: function(){
this.prompt = "\r> "
this.emit('enable-console',{stdout:true})
this.emit('status',"javascript console")
this.console = ""
setTimeout( () => {
if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt)
this.emit('serial-output-string', this.prompt)
}, 100 )
},
keyHandler: function(ch){
Expand All @@ -72,7 +74,9 @@ ISOTerminal.prototype.boot.menu.push(
this.emit('serial-output-string', ch)
const reset = () => {
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") ){
try{
Expand Down
2 changes: 1 addition & 1 deletion com/isoterminal/feat/jsconsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ISOTerminal.prototype.redirectConsole = function(handler){
const dir = console.dir;
const err = console.error;
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)=>{
const textArg = args[0];
Expand Down
7 changes: 4 additions & 3 deletions com/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ AFRAME.utils.require = function(arr_or_obj,opts){
opts = opts || {}
let i = 0
let deps = []
AFRAME.required = AFRAME.required || {}
let packagesArr = arr_or_obj.map ? arr_or_obj : Object.values(arr_or_obj)

const parseURI = function(uri){
Expand All @@ -36,8 +35,8 @@ AFRAME.utils.require = function(arr_or_obj,opts){
}

// prevent duplicate requests
if( AFRAME.required[id] ) return // already loaded before
AFRAME.required[id] = true
if( AFRAME.utils.require.required[id] ) return // already loaded before
AFRAME.utils.require.required[id] = true

if( !document.body.querySelector(`script#${id}`) &&
!document.body.querySelector(`link#${id}`) ){
Expand Down Expand Up @@ -72,4 +71,6 @@ AFRAME.utils.require = function(arr_or_obj,opts){
return Promise.all(deps)
}

AFRAME.utils.require.required = {}

AFRAME.utils.require.baseURL = './com/'
3 changes: 1 addition & 2 deletions com/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ AFRAME.registerComponent('window', {

dependencies:{
dom: "com/dom.js",
winboxjs: "https://unpkg.com/[email protected]/dist/winbox.bundle.min.js", // deadsimple windows: https://nextapps-de.github.io/winbox
//winboxcss: "https://unpkg.com/[email protected]/dist/css/winbox.min.css", // main theme
winboxjs: "../assets/winbox.bundle.min.js", // deadsimple windows: https://nextapps-de.github.io/winbox
},

init: function(){
Expand Down

0 comments on commit 6c7667c

Please sign in to comment.