improved upload-cmd
/ mirror_to_github (push) Successful in 21s Details
/ test (push) Successful in 4s Details

This commit is contained in:
Leon van Kammen 2025-01-17 18:00:49 +01:00
parent 938d1bc229
commit 1b5cf3febb
4 changed files with 41 additions and 8 deletions

View File

@ -351,6 +351,12 @@ if( typeof AFRAME != 'undefined '){
instance.setAttribute("dom", "") instance.setAttribute("dom", "")
instance.setAttribute("pastedrop", "") instance.setAttribute("pastedrop", "")
// *REMOVE* make a boot-plugin mechanism in feat/term.js
this.term.addEventListener('enable-console', () => {
instance.dom.classList.remove('blink')
})
this.term.addEventListener('ready', (e) => { this.term.addEventListener('ready', (e) => {
instance.dom.classList.remove('blink') instance.dom.classList.remove('blink')
this.term.emit('status',"running") this.term.emit('status',"running")

View File

@ -4,26 +4,52 @@ if( typeof emulator != 'undefined' ){
ISOTerminal.addEventListener('ready', function(e){ ISOTerminal.addEventListener('ready', function(e){
function getMimeType(file) {
const mimeTypes = {
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
png: 'image/png',
mp4: 'video/mp4',
gif: 'image/gif',
};
const extension = file.split('.').pop().toLowerCase();
return mimeTypes[extension] || 'application/octet-stream'; // Fallback
}
// listen for http request to the filesystem ( file://host/path ) // listen for http request to the filesystem ( file://host/path )
xhook.before( (request,callback) => { xhook.before( (request,callback) => {
console.log(request.url)
if (request.url.match(/^file:\/\/xrsh\/mnt\/.*/) ){ if (request.url.match(/^\/mnt\/.*/) ){
let response let response
let file = request.url.replace(/^file:\/\/xrsh\/mnt\//,'') let file = request.url.replace(/^\/mnt\//,'')
let mimetype = getMimeType(file)
this.worker.read_file_world(file) this.worker.read_file_world(file)
.then( (data) => { .then( (data) => {
response = new Response( new Blob( [data] ) ) // wrap Uint8Array into array if( data == null ) throw `/mnt/${file} does not exist in ISO filesystem`"
response.status = 200 let blob = new Blob( [data], {type: getMimeType(file) }) // wrap Uint8Array into array
response = {
headers: new Headers({ 'Content-Type': getMimeType(file) }),
data,
url: file,
status: 200,
blob: () => new Promise( (resolve,reject) => resolve(blob) ),
arrayBuffer: blob.arrayBuffer
}
console.log("serving from iso filesystem: "+file)
console.log("*TODO* large files being served partially")
callback(response) callback(response)
}) })
.catch( (e) => { .catch( (e) => {
console.error(e)
response = new Response() response = new Response()
response.status = 404 response.status = 404
callback(response) callback(response)
}) })
return return
}else{
callback()
} }
callback()
}) })
}) })

View File

@ -91,7 +91,7 @@ ISOTerminal.prototype.TermInit = function(){
}else{ }else{
if( (ch == "\n" || ch == "\r") && typeof this.console == 'undefined' ){ if( (ch == "\n" || ch == "\r") && typeof this.console == 'undefined' ){
switch( this.lastChar ){ switch( this.lastChar ){
case '1': this.bootISO(); break; case '1': this.bootISO(); break;
case '2': { case '2': {
this.emit('enable-console',{stdout:true}) this.emit('enable-console',{stdout:true})
this.emit('status',"javascript console") this.emit('status',"javascript console")

View File

@ -47,7 +47,8 @@ AFRAME.registerComponent('selfcontainer', {
cb(res) cb(res)
}else{ }else{
if( request.url.match(/(^file:\/\/xrsh)/) ) return cb(response) // never cache requests to filesystem
if( request.url.match(/(^\/mnt\/)/) ) return cb(response)
console.log("selfcontainer.js: caching "+request.url) console.log("selfcontainer.js: caching "+request.url)
if( response.text ){ if( response.text ){