mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-02 00:29:31 +08:00
252 lines
18 KiB
HTML
252 lines
18 KiB
HTML
<!doctype html>
|
|
<!-- SPDX-License-Identifier: MIT -->
|
|
<!-- Copyright (C) 2026 Pooya Parsa <pooya@pi0.io> -->
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
|
|
<meta name="theme-color" content="#000000">
|
|
<!-- Added to the home screen, iOS opens the page without Safari's bars (it has no element full screen on iPhone). -->
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="mobile-web-app-capable" content="yes">
|
|
<!-- Not black-translucent: iOS 26+ then gives the page a viewport short of the screen by the status bar and leaves a black band at the bottom (WebKit bug 301108). An opaque bar in the theme's colour instead: black, or default (white) in the light theme (the script below and src/ui.ts showTheme()). -->
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<meta name="apple-mobile-web-app-title" content="unkernel">
|
|
<meta name="color-scheme" content="dark">
|
|
<title>unkernel</title>
|
|
<meta name="description" content="A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.">
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:site_name" content="unkernel">
|
|
<meta property="og:title" content="unkernel: real Linux, in your browser">
|
|
<meta property="og:description" content="A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.">
|
|
<meta property="og:url" content="https://unkernel.dev/">
|
|
<meta property="og:image" content="https://unkernel.dev/og.png">
|
|
<meta property="og:image:width" content="1200">
|
|
<meta property="og:image:height" content="630">
|
|
<meta property="og:image:alt" content="unkernel: real Linux in your browser. ARM64, Debian or Alpine, up to 16 CPUs, and your tools.">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<!-- For agents: this site's llms.txt (public/llms.txt), which points to the docs. -->
|
|
<link rel="alternate" type="text/markdown" href="/llms.txt" title="llms.txt">
|
|
<link rel="stylesheet" href="/src/style.css">
|
|
<style>
|
|
/* The first paint is the desktop itself (the markup in #root below, which
|
|
React replaces with the same in one frame: same ids and classes, so
|
|
style.css lays both out alike), plus what both copies need here, where it
|
|
works without src/style.css too (its theme tokens, with their values as
|
|
fallbacks):
|
|
- the console window's frame where wm.ts centres it (Workspace.tsx's size:
|
|
74 % of the width, 720 to 1180 px, 84 % of the height less 64 px, at
|
|
most the workspace; the whole workspace in compact mode: phones, touch,
|
|
below 640 px);
|
|
- the console's placeholder while it has nothing to show (#app's
|
|
data-blank: before the first line, during a quiet resume);
|
|
- the boot indicator (#tb-boot, components/BootIndicator.tsx) in the top
|
|
bar's app slot: a ring filled to --p (0 to 1) and the step; red with the
|
|
failure's title on data-error; it fades out once user space prints;
|
|
- the wallpaper hint (desktop.ts HINT_KEY, applied by the script below)
|
|
until desktop.ts has drawn the wallpaper (data-wallpaper-kind);
|
|
- the failure card (#boot-error, outside the inert static desktop) for a
|
|
failure before the page module runs. */
|
|
:root[data-wp-hint]:not([data-wallpaper-kind]) #app { background: var(--wp-hint); }
|
|
:root[data-wp-hint]:not([data-wallpaper-kind]) #desktop { background: none; }
|
|
.sk-place { position: absolute; inset: 0; display: grid; place-items: center; }
|
|
.sk-win { position: relative; width: min(clamp(720px, 74vw, 1180px), 100%); height: min(max(420px, calc((100dvh - 64px) * .84)), 100%); }
|
|
@media (max-width: 639.98px), (pointer: coarse) {
|
|
.sk-win { width: 100%; height: 100%; border-width: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
|
|
.sk-win > .wm-title { height: var(--wm-strip, 30px); border-radius: 0; border-bottom-color: var(--color-line, #242424); background: var(--color-surface, #0a0a0a) !important; }
|
|
.sk-win > .wm-body { border-radius: 0; }
|
|
}
|
|
@media (pointer: coarse) { .sk-win > .wm-title { height: 40px; } }
|
|
:root.kw-mobile .sk-win { width: 100%; height: 100%; border-width: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
|
|
:root.kw-mobile .sk-win > .wm-title { height: 40px; border-radius: 0; border-bottom-color: var(--color-line, #242424); background: var(--color-surface, #0a0a0a) !important; }
|
|
:root.kw-mobile .sk-win > .wm-body { border-radius: 0; }
|
|
|
|
#app[data-blank] #win-terminal-1 > .wm-body::after {
|
|
position: absolute; top: 6px; left: 10px; z-index: 1; pointer-events: none;
|
|
font: 13px/1.4 var(--font-mono, ui-monospace, monospace); color: var(--color-faint, #7d7d7d); opacity: .7;
|
|
}
|
|
@media (max-width: 599.98px) { #app[data-blank] #win-terminal-1 > .wm-body::after { top: 4px; left: 8px; font-size: 12px; } }
|
|
#app[data-blank="start"] #win-terminal-1 > .wm-body::after { content: "Starting…"; }
|
|
#app[data-blank="resume"] #win-terminal-1 > .wm-body::after { content: "Resuming…"; }
|
|
|
|
.tb-boot { display: flex; flex: 0 1 auto; min-width: 0; height: 100%; align-items: center; transition: opacity .18s ease-out; }
|
|
.tb-boot[data-hide] { opacity: 0; pointer-events: none; }
|
|
.tb-boot-btn { flex: 0 1 auto; min-width: 0; justify-content: flex-start; gap: 7px; padding: 0 8px; }
|
|
.tb-boot-ring { flex: none; }
|
|
.tb-boot-track { stroke: color-mix(in srgb, var(--color-ink, #fff) 26%, transparent); }
|
|
.tb-boot-arc {
|
|
stroke: currentColor; stroke-dasharray: 100px; stroke-dashoffset: calc((1 - var(--p, 0)) * 100px);
|
|
transition: stroke-dashoffset .25s ease-out;
|
|
/* Breathes once the boot has taken a second: a fast one never shows it moving. */
|
|
animation: tb-boot-breathe 1.4s ease-in-out 1s infinite alternate;
|
|
}
|
|
@keyframes tb-boot-breathe { to { opacity: .45; } }
|
|
.tb-boot-msg, .tb-boot-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
.tb-boot-msg { color: color-mix(in srgb, var(--color-fg, #ededed) 72%, transparent); }
|
|
.tb-boot-detail { color: color-mix(in srgb, var(--color-fg, #ededed) 45%, transparent); font-variant-numeric: tabular-nums; }
|
|
.tb-boot-title { font-weight: 600; }
|
|
#tb-boot[data-error] { color: var(--color-err, #ff6166); }
|
|
#tb-boot[data-error] .tb-boot-arc { stroke-dashoffset: 0; animation: none; }
|
|
@media (max-width: 639.98px) { .tb-boot-detail { display: none; } }
|
|
|
|
#boot-error {
|
|
position: fixed; inset: 0; z-index: var(--z-boot-error, 30); display: grid; place-items: center; padding: 16px;
|
|
font: 13px/1.4 var(--font-sans, system-ui, sans-serif); color: var(--color-fg, #ededed);
|
|
}
|
|
#boot-error > section { background: var(--alert-bg, #111); border: 1px solid var(--alert-border, #333); border-radius: 16px; padding: 20px; text-align: center; }
|
|
#boot-error[hidden] { display: none; }
|
|
#boot-error .alert-detail { max-height: 10rem; white-space: pre-wrap; }
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.tb-boot, .tb-boot-arc { transition: none; animation: none; }
|
|
}
|
|
</style>
|
|
<script>
|
|
// Runs before the page module, so a module that fails to load or throw
|
|
// still ends up on screen: on the static desktop below (the markup React
|
|
// replaces once src/main.tsx runs) the boot indicator turns red and the
|
|
// failure card shows the message; src/ui.ts shows everything recorded here
|
|
// once it runs. Also what the first paint needs from storage: the colour
|
|
// themes, the saved wallpaper's hint (desktop.ts HINT_KEY) and compact mode for a mobile
|
|
// user agent without a touch screen (config.ts mobile).
|
|
(() => {
|
|
const KW = window.KW = { t0: Date.now(), errors: [], ui: null, started: false };
|
|
const root = document.documentElement;
|
|
try {
|
|
const p = localStorage.getItem("kw.theme");
|
|
const theme = p === "light" || (p !== "dark" && matchMedia("(prefers-color-scheme: light)").matches) ? "light" : "dark";
|
|
root.setAttribute("data-theme", theme);
|
|
document.querySelector('meta[name="theme-color"]').setAttribute("content", theme === "light" ? "#ffffff" : "#000000");
|
|
document.querySelector('meta[name="color-scheme"]').setAttribute("content", theme);
|
|
document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]').setAttribute("content", theme === "light" ? "default" : "black");
|
|
const t = localStorage.getItem("kw.termtheme");
|
|
root.setAttribute("data-term-theme", t === "light" || t === "dark" ? t : theme);
|
|
root.setAttribute("data-term-glass", localStorage.getItem("kw.termglass") === "off" ? "off" : "on");
|
|
const h = JSON.parse(localStorage.getItem("kw.wallpaper-hint") || "null");
|
|
if (h && typeof h.css === "string") {
|
|
root.style.setProperty("--wp-hint", h.css);
|
|
root.setAttribute("data-wp-hint", "");
|
|
root.setAttribute("data-wallpaper", h.light ? "light" : "dark");
|
|
}
|
|
} catch {}
|
|
if (/Android|iPhone|iPad|Mobi/i.test(navigator.userAgent)) root.classList.add("kw-mobile");
|
|
const el = (id) => document.getElementById(id);
|
|
// Before src/ui.ts takes over: the indicator and the card on the static desktop.
|
|
KW.early = (e) => {
|
|
if (!e.fatal || !el("tb-boot")) return;
|
|
el("tb-boot").setAttribute("data-error", "");
|
|
const title = el("tb-boot-title"), msg = el("tb-boot-msg"), card = el("boot-error");
|
|
if (title) { title.textContent = "Couldn't start"; title.hidden = false; }
|
|
if (msg) { msg.textContent = e.message; msg.className = "sr-only"; }
|
|
if (card) {
|
|
el("boot-error-msg").textContent = e.message;
|
|
el("boot-error-detail").textContent = e.detail || "";
|
|
el("boot-error-detail").hidden = !e.detail;
|
|
card.hidden = false;
|
|
}
|
|
};
|
|
KW.report = (kind, message, detail, fatal) => {
|
|
const e = { t: Date.now() - KW.t0, kind, message: String(message), detail: detail ? String(detail) : "", fatal: !!fatal };
|
|
KW.errors.push(e);
|
|
try { if (KW.ui) KW.ui.onError(e); else KW.early(e); } catch { KW.early(e); }
|
|
return e;
|
|
};
|
|
addEventListener("error", (ev) => {
|
|
const t = ev.target;
|
|
if (t && t !== window && t.tagName) {
|
|
const url = t.src || t.href || "";
|
|
// A failed script is fatal; a failed stylesheet only degrades the look.
|
|
KW.report("resource", "Failed to load " + (t.type === "module" ? "the page module " + url + " or a module it imports" : url),
|
|
"<" + t.tagName.toLowerCase() + "> load error (404, network or MIME type)", t.tagName === "SCRIPT");
|
|
return;
|
|
}
|
|
// Not a failure: a ResizeObserver callback changed a size an outer observer watches (a Wayland app's
|
|
// new size resizing its window, wayland/host.ts), and the browser delivers that one next frame instead.
|
|
if (!ev.error && /^ResizeObserver loop/.test(ev.message || "")) return;
|
|
// Scripts a browser or an extension injects (Brave's wallet touching window.ethereum, say) throw here too:
|
|
// drop an error that names no script of the page's origin (a blob: URL of it, or wasm), so it cannot fail the boot.
|
|
if (location.origin !== "null") {
|
|
let ours;
|
|
try {
|
|
const u = new URL(ev.filename);
|
|
ours = u.origin === location.origin || u.protocol === "wasm:";
|
|
} catch {
|
|
ours = String(ev.error?.stack || "").includes(location.origin);
|
|
}
|
|
if (!ours) return;
|
|
}
|
|
KW.report("exception", ev.message || "Script error", ev.error?.stack || (ev.filename ? ev.filename + ":" + ev.lineno + ":" + ev.colno : ""), !KW.started);
|
|
}, true);
|
|
addEventListener("unhandledrejection", (ev) => {
|
|
const r = ev.reason;
|
|
KW.report("rejection", "Unhandled promise rejection: " + (r?.message ?? String(r)), r?.stack ?? "", !KW.started);
|
|
});
|
|
setTimeout(() => {
|
|
if (!KW.ui) KW.report("watchdog", "The page script did not run",
|
|
"The page module failed to load or parse, or the browser is too old for it (Chrome/Edge 137+, Firefox 153+ or Safari 27+ is needed anyway). Check the network and the server log.", true);
|
|
}, 8000);
|
|
})();
|
|
</script>
|
|
<link rel="icon" type="image/svg+xml" href="../assets/logo.svg">
|
|
<!-- The home screen icon (iOS takes no SVG here): assets/logo.svg full bleed, inside its border, at 6x. -->
|
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
<!-- Installable as an app (public/manifest.webmanifest). -->
|
|
<link rel="manifest" href="/manifest.webmanifest">
|
|
</head>
|
|
<body>
|
|
<!-- React (src/main.tsx) renders the page here. Until then, and if the page
|
|
module never runs, this is what shows: the desktop as components/App.tsx
|
|
first draws it (inert): the console's window (Workspace.tsx) with its
|
|
placeholder, the Dock (Dock.tsx: Apps, dimmed until the system runs,
|
|
the console's tile, Settings) and the top bar (TopBar.tsx: the mark, the
|
|
boot indicator, the power button); the failure card is for a failure
|
|
before then. -->
|
|
<div id="root">
|
|
<div id="app" data-state="checking" data-blank="start" inert class="fixed inset-x-0 top-0 flex h-dvh flex-col">
|
|
<!-- Compact mode (Workspace.tsx useCompact()): the Dock's lower bar (style.css #app.compact). -->
|
|
<script>if (document.documentElement.classList.contains("kw-mobile") || matchMedia("(max-width: 639.98px), (pointer: coarse)").matches) document.getElementById("app").classList.add("compact");</script>
|
|
<div class="relative flex min-h-0 flex-1">
|
|
<main id="desktop" class="relative min-h-0 min-w-0 flex-1">
|
|
<div id="workspace" class="absolute isolate top-[calc(var(--st)+var(--tb-space,0px))] right-(--sr) bottom-0 left-(--sl)">
|
|
<div class="sk-place">
|
|
<section id="win-terminal-1" class="wm-win sk-win flex flex-col" data-focused>
|
|
<header class="wm-title flex flex-none items-center gap-2 pr-1 pl-3"><span class="flex text-faint"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 7 5 5-5 5M12.5 17H19" /></svg></span></header>
|
|
<div class="wm-body relative min-h-0 flex-1" data-app="terminal"></div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
<footer id="dock" class="relative flex flex-none items-center justify-center select-none">
|
|
<nav class="dock-pill">
|
|
<button type="button" class="dock-tile group relative flex-none" data-off aria-disabled="true"><span class="dock-face"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="4" width="4" height="4" rx="1" /><rect x="10" y="4" width="4" height="4" rx="1" /><rect x="16" y="4" width="4" height="4" rx="1" /><rect x="4" y="10" width="4" height="4" rx="1" /><rect x="10" y="10" width="4" height="4" rx="1" /><rect x="16" y="10" width="4" height="4" rx="1" /><rect x="4" y="16" width="4" height="4" rx="1" /><rect x="10" y="16" width="4" height="4" rx="1" /><rect x="16" y="16" width="4" height="4" rx="1" /></svg></span></button>
|
|
<div class="dock-apps"><button type="button" class="dock-tile group relative flex-none" aria-pressed="true"><span class="dock-face"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 7 5 5-5 5M12.5 17H19" /></svg></span><span aria-hidden="true" class="dock-dot" data-dot="on"></span></button><button type="button" class="dock-tile group relative flex-none"><span class="dock-face"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="6.5" /><circle cx="12" cy="12" r="2.5" /><path d="M18.5 12H21M12 18.5V21M5.5 12H3M12 5.5V3M16.6 16.6l1.8 1.8M7.4 16.6l-1.8 1.8M7.4 7.4 5.6 5.6M16.6 7.4l1.8-1.8" /></svg></span></button></div>
|
|
</nav>
|
|
</footer>
|
|
<header id="topbar">
|
|
<nav class="tb-left">
|
|
<div id="tb-boot" role="status" aria-live="polite" class="tb-boot">
|
|
<button type="button" class="tb-btn tb-boot-btn"><svg class="tb-boot-ring" width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" style="--p: 0"><circle cx="8" cy="8" r="6" stroke-width="2" class="tb-boot-track" /><circle cx="8" cy="8" r="6" stroke-width="2" pathLength="100" transform="rotate(-90 8 8)" class="tb-boot-arc" /></svg><span id="tb-boot-title" class="tb-boot-title" hidden></span><span id="tb-boot-msg" class="tb-boot-msg">Starting…</span></button>
|
|
</div>
|
|
</nav>
|
|
<div class="tb-right">
|
|
<button type="button" class="tb-btn"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v8" /><path d="M6.3 6.8a8 8 0 1 0 11.4 0" /></svg></button>
|
|
</div>
|
|
</header>
|
|
</div>
|
|
<div id="boot-error" hidden>
|
|
<section role="alert" aria-labelledby="boot-error-title" class="alert alert-wide">
|
|
<div aria-hidden="true" class="relative mx-auto" style="width: 48px; height: 48px"><svg width="48" height="48" viewBox="0 0 32 32"><rect x="0.5" y="0.5" width="31" height="31" rx="7.5" fill="#000" stroke="#333" /><path d="M9 11l5.5 5L9 21" stroke="#ededed" stroke-width="2.4" fill="none" stroke-linecap="round" stroke-linejoin="round" /><path d="M16.5 21.5H23" stroke="#ededed" stroke-width="2.4" stroke-linecap="round" /></svg><svg width="24" height="24" viewBox="0 0 24 24" class="absolute -right-1.5 -bottom-1.5" style="position: absolute; right: -6px; bottom: -6px"><circle cx="12" cy="12" r="10.2" fill="#e5484d" stroke="#111" stroke-width="1.6" /><path d="M12 6.8v6.4" stroke="#fff" stroke-width="2.2" stroke-linecap="round" /><circle cx="12" cy="16.9" r="1.3" fill="#fff" /></svg></div>
|
|
<h2 id="boot-error-title" class="alert-title">Couldn't start</h2>
|
|
<p id="boot-error-msg" class="alert-msg"></p>
|
|
<p id="boot-error-detail" class="alert-detail" hidden></p>
|
|
<div class="alert-actions"><button type="button" class="btn btn-alert btn-primary" onclick="location.reload()">Reload</button></div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
|
|
<noscript><div class="fixed inset-0 z-50 grid place-items-center bg-bg p-6 text-center"><div class="max-w-[420px]"><h1 class="mb-1.5 text-lg font-semibold">JavaScript is required</h1><p class="text-[13.5px] text-muted">This page boots a Linux kernel compiled to WebAssembly, which needs JavaScript. Enable it for this site and reload.</p></div></div></noscript>
|
|
|
|
<script type="module" src="/src/main.tsx"></script>
|
|
</body>
|
|
</html>
|