Skip to content

Commit

Permalink
[#66502] Use new hterm, import hterm as module
Browse files Browse the repository at this point in the history
  • Loading branch information
k-juszczyk committed Oct 22, 2024
1 parent 9c2e944 commit 8b0220d
Show file tree
Hide file tree
Showing 5 changed files with 8,233 additions and 9,525 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ VERSION := $(shell cat $(project_dir)/src/VERSION)


.PHONY: standalone
standalone: embed $(resources_dist) $(index_dist) $(third_party_dist_dir)/hterm_all.js
standalone: embed $(resources_dist) $(index_dist) $(third_party_dist_dir)/hterm.js

.PHONY: embed
embed: $(if $(MINIFY),$(dist_dir)/jswasi.js,$(subst $(work_dir),$(dist_dir),$(jswasi_compiled)) $(third_party_dist_dir)/vfs.js $(third_party_dist_dir)/idb-keyval.js $(third_party_dist_dir)/js-untar.js)
Expand Down
12 changes: 5 additions & 7 deletions src/assets/index-module.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</head>
<body style="margin: 0px; background: black">
<script type="module">
import { hterm, lib } from "../third_party/hterm.js"
import { Jswasi } from "./jswasi.js";

window.buffer = "";
Expand All @@ -21,11 +22,9 @@
}
return null;
};
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "./third_party/hterm_all.js";
script.onload = async () => {
await lib.init();
Promise.all([hterm.initPromise, lib.initPromise]).then(async () => {
lib.antmicroStyle["screen-padding-size"] = "8";
lib.setAntmicroStyle();
// hterm prints warnings that we don't really care about
let tempWarnlog = console.warn;
console.warn = () => {};
Expand All @@ -35,8 +34,7 @@
const jswasi = new Jswasi();
await jswasi.attachDevice({terminal}, 1);
await jswasi.init();
};
document.body.appendChild(script);
});
</script>
<div id="terminal"></div>
</body>
Expand Down
13 changes: 6 additions & 7 deletions src/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<body style="margin: 0px; background: black">
<script src="./jswasi.js"></script>
<script>
import { hterm, lib } from "../third_party/hterm.js"

window.buffer = "";
window.alive = true;
window.exitCode = 0;
Expand All @@ -20,11 +22,9 @@
}
return null;
};
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "./third_party/hterm_all.js";
script.onload = async () => {
await lib.init();
Promise.all([hterm.initPromise, lib.initPromise]).then(async () => {
lib.antmicroStyle["screen-padding-size"] = "8";
lib.setAntmicroStyle();
// hterm prints warnings that we don't really care about
let tempWarnlog = console.warn;
console.warn = () => {};
Expand All @@ -34,8 +34,7 @@
const jswasi = new Jswasi();
await jswasi.attachDevice({terminal}, 1);
await jswasi.init();
};
document.body.appendChild(script);
});
</script>
<div id="terminal"></div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const urlsToCache = [
"./jswasi.js",
"./constants.js",
"./service-worker.js",
"./third_party/hterm_all.js",
"./third_party/hterm.js",
"./third_party/vfs.js",
"./third_party/idb-keyval.js",
];
Expand Down
Loading

0 comments on commit 8b0220d

Please sign in to comment.