Skip to content

Commit 2d5ce78

Browse files
committed
merge from main
1 parent 77c8677 commit 2d5ce78

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

packages/runtime/index.html

+24-23
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
document.getElementById("terminal").style = "";
3535
}
3636

37-
const bzimageUrl = "./filesystem/123ccf58.bin";
37+
const bzimageUrl = "./filesystem/27d6e559.bin";
3838
const options = {
3939
...baseOptions,
4040
...(boot
@@ -58,31 +58,32 @@
5858

5959
var emulator = new V86Starter(options);
6060

61+
function initTerm() {
62+
const fitAddon = new FitAddon.FitAddon();
63+
emulator.serial_adapter.term.loadAddon(fitAddon);
64+
fitAddon.fit();
65+
window.addEventListener("resize", () => fitAddon.fit());
66+
}
67+
68+
function sendBackgroundCommands(commands) {
69+
const filename = `${(Math.random() + 1).toString(36).substring(7)}.sh`;
70+
emulator.create_file(
71+
`/inbox/${filename}`,
72+
new TextEncoder("UTF-8").encode(commands.join("\n"))
73+
);
74+
}
75+
6176
if (!boot) {
6277
emulator.add_listener("emulator-ready", function () {
63-
const fitAddon = new FitAddon.FitAddon();
64-
emulator.serial_adapter.term.loadAddon(fitAddon);
65-
fitAddon.fit();
66-
window.addEventListener("resize", () => fitAddon.fit());
67-
// emulator.serial_adapter.term.setOption("allowTransparency", true);
68-
// emulator.serial_adapter.term.setOption("theme", { background: "transparent" });
78+
initTerm();
6979
setTimeout(() => {
70-
emulator.serial0_send("/etc/init.d/S40network restart\n");
71-
emulator.serial0_send("psql -U postgres\n");
72-
emulator.serial0_send('\\! echo "boot_completed"; reset\n');
80+
sendBackgroundCommands(["/etc/init.d/S40network restart"]);
81+
emulator.serial0_send(
82+
`\\! stty rows ${emulator.serial_adapter.term.rows} cols ${emulator.serial_adapter.term.cols} && reset\n`
83+
);
84+
emulator.serial_adapter.term.focus();
7385
}, 0);
7486
});
75-
76-
function handleBoot(line) {
77-
if (line.startsWith("postgres=# boot_completed")) {
78-
emulator.remove_listener(handleBoot);
79-
setTimeout(() => {
80-
document.getElementById("terminal").style = "filter: none;";
81-
emulator.serial_adapter.term.focus();
82-
}, 300);
83-
}
84-
}
85-
emulator.add_listener("serial0-output-line", handleBoot);
8687
}
8788

8889
var state;
@@ -182,8 +183,8 @@
182183
</div>
183184
</div>
184185
<div class="container">
185-
<div class="xterminal" style="margin-right: 25px">
186-
<div id="terminal" style="filter: blur(3px)"></div>
186+
<div class="xterminal">
187+
<div id="terminal"></div>
187188
</div>
188189
</div>
189190
</body>

0 commit comments

Comments
 (0)