Files
chitai/frontend/src/lib/vendor/foliate-js
patrick dd65e34869 chore: vendor foliate-js
foliate-js has no npm release and no build step; upstream recommends a git
submodule. Copy it instead: this repo has no submodules and already vendors
pdf.js the same way under static/pdfjs, and a submodule would pull in 231
files / 13 MB of which 191 files / 12 MB is a bundled pdf.js build that
Chitai does not use.

Only the import closure reachable from view.js is vendored — 15 files, 584K.
pdf.js is replaced by a stub that throws: view.js reaches it through a
static-string dynamic import inside makeBook, which Rollup resolves at build
time even though Chitai serves PDFs from static/pdfjs/web/viewer.html, and
upstream's version opens with a bare `import '@pdfjs/pdf.min.mjs'` that does
not resolve here.

scripts/vendor-foliate.sh pins the commit and makes the next update a one-line
change. fixed-layout.js needs construct-style-sheets-polyfill, so add it.
2026-08-11 21:59:33 -04:00
..
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00
2026-08-11 21:59:33 -04:00

Vendored foliate-js

Do not edit these files. They are copied verbatim from upstream by frontend/scripts/vendor-foliate.sh; local changes are lost on the next run.

Upstream https://github.com/readest/foliate-js (Readest's fork of johnfactotum/foliate-js)
Pinned commit 63a2eb1fc1e4813c4e849ccdb3d4be2c54a35869
Licence MIT — see LICENSE

Readest's fork is used rather than upstream for its paginator work: touch/swipe turn handling, fixed-layout spread centring, and a malformed-XHTML fallback in loadDocument.

What is here

Only the import closure reachable from view.js. Not vendored, because nothing reaches them: dict.js, opds.js, footnotes.js, quote-image.js, uri-template.js, reader.js (upstream's demo), and the build configs.

pdf.js is ours, not upstream's

pdf.js in this directory is a stub that throws. Upstream's version imports @pdfjs/pdf.min.mjs — a bare specifier backed by a 12 MB vendored pdf.js build — and view.js reaches it through await import('./pdf.js'), which Rollup resolves at build time even though Chitai never takes that path. Chitai serves PDFs from static/pdfjs/web/viewer.html instead.

To enable foliate's PDF backend, add pdf.js and vendor/pdfjs/ to the file list in the vendor script and drop the stub.

Updating

Bump FOLIATE_SHA in frontend/scripts/vendor-foliate.sh, re-run it, review the diff, and smoke-test the reader — paginator.js is ~3800 lines of gesture and animation code and this fork is pushed to frequently.