Initialize CheerpX disk backend for the main image
This commit is contained in:
parent
74e18f2b38
commit
f586c4bcf2
2 changed files with 43 additions and 2 deletions
|
@ -1 +1,2 @@
|
||||||
export const imageUrl = "wss://disks-staging.webvm.io/debian_large_20230522_5044875331.ext2";
|
export const diskImageUrl = "wss://disks-staging.webvm.io/debian_large_20230522_5044875331.ext2";
|
||||||
|
export const diskImageType = "cloud";
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import Nav from 'labs/packages/global-navbar/src/Nav.svelte';
|
import Nav from 'labs/packages/global-navbar/src/Nav.svelte';
|
||||||
import SideBar from './SideBar.svelte';
|
import SideBar from './SideBar.svelte';
|
||||||
import * as CheerpX from '@leaningtech/cheerpx';
|
import * as CheerpX from '@leaningtech/cheerpx';
|
||||||
import { imageUrl } from 'diskConfig'
|
import { diskImageUrl, diskImageType } from 'diskConfig'
|
||||||
|
|
||||||
var term = new Terminal({cursorBlink:true, convertEol:true, fontFamily:"monospace", fontWeight: 400, fontWeightBold: 700});
|
var term = new Terminal({cursorBlink:true, convertEol:true, fontFamily:"monospace", fontWeight: 400, fontWeightBold: 700});
|
||||||
var fitAddon = new FitAddon();
|
var fitAddon = new FitAddon();
|
||||||
|
@ -21,6 +21,46 @@
|
||||||
fitAddon.fit();
|
fitAddon.fit();
|
||||||
window.addEventListener("resize", function(ev){ fitAddon.fit(); });
|
window.addEventListener("resize", function(ev){ fitAddon.fit(); });
|
||||||
term.focus();
|
term.focus();
|
||||||
|
initCheerpX();
|
||||||
|
}
|
||||||
|
async function initCheerpX()
|
||||||
|
{
|
||||||
|
// TODO: Check for SAB support
|
||||||
|
// TODO: Initialize network
|
||||||
|
var blockDevice = null;
|
||||||
|
switch(diskImageType)
|
||||||
|
{
|
||||||
|
case "cloud":
|
||||||
|
try
|
||||||
|
{
|
||||||
|
blockDevice = await CheerpX.CloudDevice.create(diskImageUrl);
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
// Report the failure and try again with plain HTTP
|
||||||
|
var wssProtocol = "wss:";
|
||||||
|
if(diskImageUrl.startsWith(wssProtocol))
|
||||||
|
{
|
||||||
|
// WebSocket protocol failed, try agin using plain HTTP
|
||||||
|
plausible("WS Disk failure");
|
||||||
|
blockDevice = await CheerpX.CloudDevice.create("https:" + diskImageUrl.substr(wssProtocol.length));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No other recovery option
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "bytes":
|
||||||
|
blockDevice = await CheerpX.HttpBytesDevice.create(diskImageUrl);
|
||||||
|
break;
|
||||||
|
case "github":
|
||||||
|
blockDevice = await CheerpX.GitHubDevice.create(diskImageUrl);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unrecognized device type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onMount(initTerminal);
|
onMount(initTerminal);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue