Skip to content

v0.21.0

Choose a tag to compare

@PROVE1352 PROVE1352 released this 12 Nov 08:10
· 149 commits to main since this release

A minor release with one feature: a PDF attached to a page now shows its pages in the page, under the file name.
Web app only: no database migration (a 0.20 database stays at 62 applied migrations), no new setting, no header
change, no API change, and the stored file block, its HTML export and the document format are unchanged. New
dependency pdfjs-dist 6.5.438 (Apache-2.0, web only, loaded on the first PDF preview of a session, not precached).
The app uses pdf.js's legacy build, which carries polyfills for browsers without the newest built-ins; pdf.js
supports it in Firefox ESR, Chrome 125+ (Edge, Opera) and "mostly" Safari 18+. Its optional Node canvas
(@napi-rs/canvas) is not installed (ignoredOptionalDependencies in pnpm-workspace.yaml). The build now ships
pdf.js's licence and its data files with their licences; they are listed in
THIRD-PARTY-NOTICES.md. The MCP tool list is unchanged.

Checked in Chrome 157 only (desktop and a 390 px touch window, light and dark, and with the newest built-ins removed
on the page to exercise the legacy build's polyfills; the polyfills inside the worker were not exercised); not
tried in Safari, Firefox, Samsung Internet or on a real phone. The wasm image decoders (JPEG 2000, JBIG2, colour
profiles) compile in the worker, but no scanned PDF was decoded in the check
(docs/KNOWN-ISSUES.md, "Added in 0.21.0").

Upgrade notes

  • Nothing to do on the server: no migration, no setting, no header change. Reload open tabs to get the preview.
  • A page with a PDF asks for its ink strokes (GET /api/pages/:id/ink) when it opens and again every 60 s while it
    is open with pen mode off, because the preview is not shown on pages with ink (below) and the server does not
    announce ink changes.
  • The service worker keeps pdf.js's files in a cache of their own, inkling-pdfjs (60 entries, 30 days), next to
    inkling-lazy-assets. Neither is in the precache.
  • Proxies: the preview loads pdf.js, its worker (a .mjs file) and its data files from /assets/lazy/. A
    reverse proxy that blocks or rewrites those paths stops the preview: it shows "The preview could not be loaded."
    with a download link. A proxy that serves .mjs with a type other than JavaScript also stops it, with an error
    message and the download link (docs/OPERATIONS.md, "PDF preview (0.21)").

Added

  • PDF preview in the page (docs/adr/2480-* .. 2483-*). A PDF attached to a page (a file block whose file was
    uploaded to this server) shows its pages under the file name. The pages scroll inside an area at most 70% of the
    screen tall; type a page number to jump, zoom in steps (25–400%) or fit the width, open it full screen (Esc or the
    close button closes it), select and copy its text, and follow its web links (they open in a new tab; a link to
    another page of the same PDF scrolls the preview there). Files up to 10 MB load when the block comes near the
    screen; larger ones, and every file in a browser with the data saver on, show "Load preview (25.1 MB)" and load on
    a press, with a progress bar; a download that does not move for 30 s ends in "The file stopped loading." with
    "Try again". "Hide preview" is remembered per person and file in this browser. Works in editable and locked
    pages. In pen mode and on a page that has ink strokes there is no preview (PDFs show their name line as in 0.20),
    because ink is placed by the body's height; another member's first stroke hides an open tab's preview within a
    minute. Printing and "Export as PDF" keep the file name line only. A preview far from the screen lets go of its
    canvases and, after 10 s, of its document, and loads it again at the same page and zoom when you come back. The
    preview is view state: nothing is stored in the document, and a member who deletes or replaces the file block
    removes or replaces the preview in everyone's tab. Each person reads at their own page.

Security

  • PDFs are still never opened by the browser itself: /files/:id keeps Content-Disposition: attachment,
    nosniff and its sandbox CSP. The preview draws them with pdf.js from the app's own origin (no CDN), runs no
    JavaScript from the PDF, has no form fields, attachments or launch actions, and keeps only http:/https: links
    (opened with noopener noreferrer). Password-protected and broken PDFs show a message and the download link; the
    preview never asks for a password. The app's CSP is unchanged (docs/adr/2480-*).
  • Limits keep a hostile or huge PDF inside its own block (docs/adr/2483-*): at most 5,000 pages (more shows "This
    PDF has too many pages (N) to preview here." with the download link), a page box of at most 5,000 CSS px on its
    long side at 100%, one page canvas of at most 8,388,608 pixels and 8,192 px a side, at most 8 pages drawn per
    pass, and no image over 2^26 pixels. An error inside a preview turns only that block into an error message; the
    page and the editor go on.

Performance

  • The entry chunk is unchanged (449,412 → 449,394 B, build-id noise); entry plus modulepreload +3,701 B (+924 B
    gzip, the preview's strings among them), the editor chunk +5,142 B (+1,639 B gzip), the entry stylesheet +1,281 B.
    The preview UI (PdfPreview-*.js, 23,532 B, 8,331 B gzip, + 2,966 B CSS) is precached and loads when a PDF block
    comes near the screen; pdf.js (501,358 B, 150,974 B gzip) and its worker (1,327,591 B, 394,383 B gzip) when a
    preview loads a file; cMaps and fonts per need. None of pdf.js is in the PWA precache. Pages without a PDF fetch
    none of it (docs/PERFORMANCE.md).
  • A 5,000-page PDF: page 1 drawn 0.88 s after opening, a jump to page 5,000 drawn in 75 ms, 27 MB of JS heap. A
    page with 12 PDFs scrolled to the end holds 1 open document and 2 canvases 28 s later (docs/adr/2483-*,
    docs/PERFORMANCE.md).
  • Page 1 waits for the whole file, because /files/:id sends no byte ranges: about 4.2 s for 10 MB and 10.2 s for
    25 MB at 20 Mbit/s. The auto-load limit is 10 MB instead of the proposed 15 MB for that reason
    (docs/adr/2482-*, docs/PERFORMANCE.md).