Nightly Build / build (push) Successful in 7m59s
On iOS the file viewer showed only the first page of a PDF, with no way to scroll to the rest — the document had to be downloaded and opened in another app. The cause was not ours: WebKit refuses to mount its PDF viewer inside an <iframe>/<object>/<embed> and paints a static first-page thumbnail instead. That hits Safari on iOS and every WKWebView, so the native shell too. The full viewer only exists for a top-level navigation. The desktop browsers do mount a viewer, but each mounts its own — Chrome's toolbar, Safari's page-index sidebar — so the same document also looked different on every machine. Both are answered by drawing the pages ourselves. New <pdf-view> (web/components/shared/pdf-view.js) renders a continuous scroll of canvas pages on the vendored pdf.js, with a zoom control and a page counter, and replaces the iframe for both native .pdf files and server-compiled LaTeX. Three properties are load-bearing: - pdf.js is imported lazily (~450 KB + a 1.2 MB worker), so a session that never opens a PDF never pays for it. - Canvases are created and destroyed as pages scroll. iOS caps the total canvas backing store a page may hold and silently blanks canvases past it, so an eager render would come out empty on exactly the platform this was written for. Off-screen pages keep only a correctly-sized box, which is also what keeps the scrollbar honest. - The text layer (selection, in-page find) is best-effort: it is transparent DOM over the pixels, so its failures are swallowed rather than surfaced. Vendored from pdfjs-dist 6.2.108: pdf.min.mjs, pdf.worker.min.mjs, the standard-font data (needed by PDFs that reference Helvetica/Times without embedding them) and the .textLayer block of pdf_viewer.css. CJK cmaps are deliberately left out. pdf.js 6 needs Safari/iOS 17.4+. Verified in headless Chromium against both a synthetic 12-page PDF using non-embedded Helvetica and a real 14-page paper with embedded fonts and figures: all pages present, last page renders after scrolling, page 1 released off-screen, text layer populated, zoom re-renders at the new scale, no JS errors.
98 lines
4.1 KiB
HTML
98 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
<meta name="apple-mobile-web-app-title" content="Agent" />
|
|
<meta name="theme-color" content="#faf7f2" media="(prefers-color-scheme: light)" />
|
|
<meta name="theme-color" content="#1c1814" media="(prefers-color-scheme: dark)" />
|
|
<title>Skald</title>
|
|
<link rel="icon" href="/assets/icons/favicon.ico" sizes="any" />
|
|
<link rel="icon" href="/assets/icons/icon-192.png" type="image/png" />
|
|
|
|
<link rel="manifest" href="/manifest.json" />
|
|
<link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png" />
|
|
|
|
<script>
|
|
(function () {
|
|
// Same chain as the desktop shell: a saved choice wins over the OS.
|
|
const saved = localStorage.getItem('theme');
|
|
const dark = saved ? saved === 'dark' : window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
document.documentElement.setAttribute('data-bs-theme', dark ? 'dark' : 'light');
|
|
window.matchMedia('(prefers-color-scheme: dark)')
|
|
.addEventListener('change', e => {
|
|
if (!localStorage.getItem('theme')) {
|
|
document.documentElement.setAttribute('data-bs-theme', e.matches ? 'dark' : 'light');
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
|
|
<!-- Font -->
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" />
|
|
|
|
<!-- Bootstrap -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" />
|
|
|
|
<link rel="stylesheet" href="css/variables.css" />
|
|
<link rel="stylesheet" href="css/setup-page.css" />
|
|
<link rel="stylesheet" href="css/copilot-messages.css" />
|
|
<link rel="stylesheet" href="css/agent-tasks.css" />
|
|
<link rel="stylesheet" href="css/inbox-cards.css" />
|
|
<link rel="stylesheet" href="css/file-viewer.css" />
|
|
<!-- pdf.js TextLayer's DOM contract (selectable text over the rendered pages). -->
|
|
<link rel="stylesheet" href="/vendor/pdf-text-layer.css" />
|
|
<link rel="stylesheet" href="css/mobile.css" />
|
|
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"lit": "/vendor/lit-all.min.js",
|
|
"lit/directives/unsafe-html.js": "/vendor/lit-all.min.js",
|
|
"lit/directives/keyed.js": "/vendor/lit-all.min.js",
|
|
"marked": "/vendor/marked.esm.js",
|
|
"dompurify": "/vendor/purify.es.mjs"
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
html, body { height: 100%; overflow: hidden; }
|
|
body { font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
|
|
mobile-app { display: flex; flex-direction: column; height: 100%; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<mobile-app id="mobile-app"></mobile-app>
|
|
<login-page id="login-page" style="display:none"></login-page>
|
|
|
|
<script>
|
|
(function () {
|
|
// Native shell handles auth in background — never gate it.
|
|
if (new URLSearchParams(location.search).get('native') === 'true') return;
|
|
|
|
var app = document.getElementById('mobile-app');
|
|
var login = document.getElementById('login-page');
|
|
|
|
fetch('/api/auth/me').then(function (res) {
|
|
if (res.ok) return; // logged in — show app
|
|
app.style.display = 'none'; // 401 — show login
|
|
login.style.display = '';
|
|
}).catch(function () {
|
|
app.style.display = 'none'; // network error — show login
|
|
login.style.display = '';
|
|
});
|
|
})();
|
|
</script>
|
|
|
|
<script type="module" src="components/mobile-app.js"></script>
|
|
</body>
|
|
</html>
|