improved unixy urls

This commit is contained in:
Leon van Kammen 2025-04-08 15:25:20 +02:00
parent 9cded01543
commit 5261353fca
11 changed files with 67 additions and 12 deletions

View file

@ -31,7 +31,7 @@ test -f /root/.boot || {
touch /root/.boot # make sure we run below once
# add menu items
# add menu items https://xrsh.isvery.ninja/#Launcher%20menu
find /root/.config/launcher -type f | while read item; do
js '
let term = document.querySelector("[isoterminal]").components.isoterminal.term
@ -59,5 +59,7 @@ test -f /root/.boot || {
# uncomment to set location (3D scene file [with XR Fragments] )
#require https://xrfragment.org/index.glb
#require https://coderofsalvation.github.io/xrsh-media/assets/background.glb
#
}
# auto-load /mnt/.env (if passed via AFRAME's isoterminal="overlayfs: boot.sh" e.g.
test -f /mnt/.env && source /mnt/.env

View file

@ -1,14 +1,53 @@
#!/bin/sh
source /etc/profile.sh
javascript='
const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.term
isoterminal.save()
return "[OK] xrsh state saved\n"
'
state(){
javascript='
const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.term
isoterminal.save()
return "[OK] xrsh state saved\n"
'
echo "[i] triggering ~/hook.d/save/* scripts"
hook save
echo "[i] warning: do not resize the browserwindow"
echo "[i] please wait.."
js "$javascript"
exit
}
echo "[i] triggering ~/hook.d/save/* scripts"
hook save
echo "[i] warning: do not resize the browserwindow"
echo "[i] please wait.."
js "$javascript"
file(){
javascript='
filename='$1'
function saveUint8Array(uint8Array, filename = 'download.bin', mimeType = 'application/octet-stream') {
const blob = new Blob([uint8Array], { type: mimeType });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
// Programmatically trigger the click event
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
// Clean up the URL object
URL.revokeObjectURL(url);
}
let term = document.querySelector("[isoterminal]")
term.emit("read_file", [filename, (str,buf) > saveUint8Array(buf, filename) )
return ""
'
hook save
js "$javascript"
exit
}
test -z "$1" && state
test -n "$1" && file
echo "Usage: save [file] # pass no argument to save VM state to localStorage"

View file

@ -1,2 +1,4 @@
#!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading AFRAME glTF scene"
cp index.html /root/index.html

View file

@ -0,0 +1 @@
echo "" > /root/index.html # cleanup

View file

@ -1,3 +1,5 @@
#!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading THREE.js scene"
echo "" > /root/index.html # empty scene
cp index.js /root/index.js

View file

@ -0,0 +1,2 @@
echo "" > /root/index.html # empty scene
cp cleanup.js /root/index.js

View file

@ -0,0 +1,3 @@
const ascene = AFRAME.scenes[0]
const scene = ascene.object3D
scene.getObjectByName("cube").remove()

View file

@ -4,6 +4,7 @@ const object = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
new THREE.MeshBasicMaterial({ color: 0xff0000 })
);
object.name = "cube"
object.position.set(0.3, 1.4, -0.4)
object.scale.set(0.2,0.2,0.2)

View file

@ -1,2 +1,4 @@
#!/bin/sh
cd $(dirname $(readlink -f $0))
echo "loading AFRAME demo scene"
cp index.html /root/index.html

View file

@ -0,0 +1 @@
echo "" > /root/index.html # cleanup

BIN
dist/v86-linux.iso vendored

Binary file not shown.