mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00

Fix header rewriting, revamp html rewriting, add types to bare-mux from bare-client, prefetch scramjet scripts for faster load
44 lines
No EOL
1.5 KiB
HTML
44 lines
No EOL
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<link rel="prefetch" href="./scramjet.worker.js">
|
|
<link rel="prefetch" href="./scramjet.bundle.js">
|
|
<script src="./bare-mux.js" defer></script>
|
|
<script src="./bare-client.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<script src="https://unpkg.com/dreamland"></script>
|
|
<script src="./scramjet.codecs.js"></script>
|
|
<script src="./scramjet.config.js"></script>
|
|
<script>
|
|
function App() {
|
|
return html`
|
|
<input placeholder="Enter URL Here" on:keydown=${async (e) => {
|
|
if (e.key === "Enter") {
|
|
const url = __scramjet$config.codec.encode(e.target.value);
|
|
try {
|
|
await registerSw();
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
location = __scramjet$config.prefix + url;
|
|
}
|
|
}} />
|
|
`
|
|
}
|
|
|
|
async function registerSw() {
|
|
await navigator.serviceWorker.register("./sw.js", {
|
|
scope: __scramjet$config.prefix
|
|
})
|
|
let bareUrl = (location.protocol === "https:" ? "https" : "http") + "://" + location.host + "/bare/";
|
|
await BareMux.SetTransport("BareMod.BareClient", bareUrl);
|
|
}
|
|
|
|
document.body.appendChild(h(App));
|
|
</script>
|
|
</body>
|
|
</html> |