Files
FredApps e9b270eb94 web: ship the SBS library's bitmaps beside the wasm, not inside it (#263)
* web: ship the SBS library's bitmaps beside the wasm, not inside it

The SBS library import (#219) embeds every file under assets/sbs into
every build, the browser one included. Its resources/ bitmaps are already
compressed PNG/EXR/BMP (14.1 MB, deflate saves 1%), and with them the
release wasm grew from 14.3 MB to 33.3 MB, past the 24 MiB gate in
packaging/web/package.sh that guards Cloudflare Pages' 25 MiB file cap.
The nightly Release dry run has failed on Web (wasm) since.

For wasm32 the formats build script now leaves resources/ out of the
embedded library and lists it as EXTERNAL_ASSETS. index.html copies
assets/sbs/resources to sbs/resources in the dist, and the web app
downloads those files at startup (in parallel, before the session is
created) and hands them to library::install, so library::read serves
them as before. A failed download is logged and surfaces as a missing
asset on the nodes that use it; startup goes on. Native builds still
embed everything.

* web: bound the startup download of the library resources

A response that sends headers and then stalls would keep download_library,
and with it the loading screen, pending for good. One AbortController now
covers every request and body, aborted after two minutes; whatever is still
pending fails, is logged, and startup goes on without it.
2026-11-16 22:12:24 +01:00

52 lines
3.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="color-scheme" content="dark">
<title>MaterialCraft</title>
<link data-trunk rel="rust" data-bin="materialcraft-web" data-cargo-profile="wasm-release" data-wasm-opt="z" data-weak-refs />
<!-- The SBS library's bitmaps ship beside the wasm: embedded, they push it past Cloudflare Pages' 25 MiB file cap -->
<link data-trunk rel="copy-dir" href="../../assets/sbs/resources" data-target-path="sbs/resources" />
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: #1c1c1c; }
/* Touch and pen strokes paint and orbit; the browser must not scroll, zoom or select. */
#materialcraft_canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none;
touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#materialcraft_loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
gap: 12px; padding: 0 16px; text-align: center; color: #b8b8b8; font: 14px system-ui, sans-serif; pointer-events: none; background: #1c1c1c; }
#materialcraft_loading h1 { margin: 0; color: #f2f2f2; font-size: 20px; font-weight: 600; letter-spacing: 0.02em; }
#materialcraft_loading p { margin: 0; max-width: 420px; line-height: 1.5; }
#materialcraft_loading a { color: #e0e0e0; pointer-events: auto; }
/* Indeterminate while the WebAssembly downloads (the page has no script to measure it); the
app sets its value through the startup steps once it runs. */
#materialcraft_progress { width: min(280px, 70vw); height: 4px; border: 0; border-radius: 2px; background: #333; color: #178a9c; accent-color: #178a9c; }
#materialcraft_progress::-webkit-progress-bar { background: #333; border-radius: 2px; }
#materialcraft_progress::-webkit-progress-value { background: #178a9c; border-radius: 2px; }
#materialcraft_progress::-moz-progress-bar { background: #178a9c; border-radius: 2px; }
/* Styled progress bars lose the native "busy" animation: a sweep stands in while downloading. */
#materialcraft_progress:indeterminate { background: linear-gradient(90deg, #333 0%, #178a9c 50%, #333 100%) 0 0 / 300% 100%;
animation: materialcraft-busy 1.4s linear infinite; }
#materialcraft_progress:indeterminate::-webkit-progress-bar { background: transparent; }
#materialcraft_progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes materialcraft-busy { from { background-position: 100% 0; } to { background-position: -50% 0; } }
#materialcraft_status { font-size: 12px; color: #969696; }
/* The app removes this element once it runs. If the WebAssembly never downloads or doesn't match
this page, no Rust runs to say so, so the page itself shows what to do after a while. */
#materialcraft_stalled { color: #8c8c8c; visibility: hidden; animation: materialcraft-stalled 0s 30s forwards; }
@keyframes materialcraft-stalled { to { visibility: visible; } }
</style>
</head>
<body>
<canvas id="materialcraft_canvas"></canvas>
<div id="materialcraft_loading" role="status" aria-live="polite">
<h1>MaterialCraft</h1>
<progress id="materialcraft_progress" max="1" aria-label="Loading MaterialCraft"></progress>
<p id="materialcraft_status">Downloading&hellip;</p>
<p id="materialcraft_stalled">This is taking longer than usual. If MaterialCraft doesn't start, its files may have failed to
download or come from a different version of this page. <a href="">Reload</a> to try again; the browser
console lists what failed.</p>
</div>
</body>
</html>