1
1
//@ts -ignore
2
2
import V86Starter from "../v86/libv86.js"
3
- //@ts -ignore
4
- import wasmPath from "../v86/v86.wasm?url"
5
- //@ts -ignore
6
- import biosPath from "../v86/seabios.bin?url"
7
- //@ts -ignore
8
- import vgaBiosPath from "../v86/vgabios.bin?url"
9
- //@ts -ignore
10
- import cdromPath from "../v86/image.iso.zst?url"
11
- //@ts -ignore
12
- import bootedStatePath from "../v86/booted-state.bin.zst?url"
13
3
14
4
import { Mutex } from "async-mutex"
15
5
16
- class WebShell {
6
+ class LinuxBrowserShell {
17
7
private mutex : Mutex
18
8
private mutex2 : Mutex
19
9
private emulator : any
20
10
21
- // Whether or not to restore the VM state from a file. Set to false to perform a regular boot.
22
- private restoreState = true
23
11
private config : any = {
24
- wasm_path : wasmPath ,
25
12
memory_size : 64 * 1024 * 1024 ,
26
13
vga_memory_size : 2 * 1024 * 1024 ,
27
- bios : { url : biosPath } ,
28
- vga_bios : { url : vgaBiosPath } ,
29
- cdrom : { url : cdromPath } ,
30
14
disable_mouse : true ,
31
15
autostart : true ,
32
16
}
@@ -36,14 +20,29 @@ class WebShell {
36
20
37
21
//private serialBuffer = ""
38
22
39
- constructor ( screen ?: HTMLDivElement , serial ?: HTMLDivElement ) {
23
+ constructor (
24
+ paths : {
25
+ wasm : string
26
+ bios : string
27
+ vga_bios : string
28
+ cdrom : string
29
+ initial_state ?: string
30
+ } ,
31
+ screen ?: HTMLDivElement ,
32
+ serial ?: HTMLDivElement ,
33
+ ) {
40
34
this . mutex = new Mutex ( )
41
35
this . mutex2 = new Mutex ( )
42
36
37
+ this . config [ "wasm_path" ] = paths . wasm
38
+ this . config [ "bios" ] = { url : paths . bios }
39
+ this . config [ "vga_bios" ] = { url : paths . vga_bios }
40
+ this . config [ "cdrom" ] = { url : paths . cdrom }
41
+
43
42
if ( screen ) {
44
43
let screenDiv = screen
45
44
screenDiv . style . whiteSpace = "pre"
46
- screenDiv . style . fontFamily = "Iosevka "
45
+ screenDiv . style . fontFamily = "monospace "
47
46
screenDiv . style . fontSize = "18px"
48
47
screenDiv . style . lineHeight = "20px"
49
48
@@ -61,11 +60,10 @@ class WebShell {
61
60
this . serialDiv = serial
62
61
}
63
62
64
- if ( this . restoreState ) {
65
- this . config [ "initial_state" ] = {
66
- url : bootedStatePath ,
67
- }
63
+ if ( typeof paths . initial_state !== "undefined" ) {
64
+ this . config [ "initial_state" ] = { url : paths . initial_state }
68
65
}
66
+ console . log ( "constructor done" )
69
67
}
70
68
71
69
private appendToSerialDiv ( _ : string ) {
@@ -205,6 +203,9 @@ class WebShell {
205
203
206
204
boot ( ) : Promise < void > {
207
205
return new Promise ( ( resolve , _ ) => {
206
+ console . log ( "booting" )
207
+ console . log ( this . config )
208
+
208
209
// Start the this.emulator!
209
210
//@ts -ignore
210
211
this . emulator = new V86Starter ( this . config )
@@ -248,4 +249,4 @@ class WebShell {
248
249
}
249
250
}
250
251
251
- export default WebShell
252
+ export default LinuxBrowserShell
0 commit comments