066ee331e9
A service worker caches the app shell and the current build's glue and wasm so the site starts without a connection; a new build stamp drops the old ones. Sign-in, relay and library routes are never cached. The toolbar shows an Offline chip while the server is unreachable; edits stay in the local store and the existing sync uploads them when it returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.9 KiB
HTML
40 lines
1.9 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
|
<link rel="manifest" href="manifest.webmanifest">
|
|
<meta name="theme-color" content="#2b2b2d">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<link rel="icon" type="image/svg+xml" href="icons/papercraft.svg">
|
|
<link rel="icon" type="image/png" sizes="512x512" href="icons/papercraft-512.png">
|
|
<link rel="apple-touch-icon" href="icons/papercraft-512.png">
|
|
<title>PaperCraft</title>
|
|
<style>
|
|
html, body { margin: 0; height: 100%; overflow: hidden; background: #1e1e20; }
|
|
/* Read at startup for the safe-area insets (notch, home bar). */
|
|
#safe-area { position: fixed; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
|
|
canvas { display: block; width: 100vw; height: 100vh; touch-action: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="safe-area"></div>
|
|
<canvas id="papercraft"></canvas>
|
|
<script type="module">
|
|
// Lets the app start offline; a failure only means no offline start.
|
|
navigator.serviceWorker?.register("./sw.js").catch((e) => console.warn("service worker:", e));
|
|
// The glue and the wasm must come from the same build: a browser that kept an older
|
|
// papercraft.js fails to link the new wasm. pkg/build.txt names the build, so each deploy
|
|
// loads both under new URLs.
|
|
const build = await fetch("./pkg/build.txt", { cache: "no-store" })
|
|
.then((r) => (r.ok ? r.text() : ""))
|
|
.catch(() => "");
|
|
const v = encodeURIComponent(build.trim() || Date.now());
|
|
const { default: init } = await import(`./pkg/papercraft.js?v=${v}`);
|
|
init({ module_or_path: `./pkg/papercraft_bg.wasm?v=${v}` });
|
|
</script>
|
|
</body>
|
|
</html>
|