readest/packages
leehuazhong 1775243427
fix(reader): show each Curl and Page Flip sheet's own page number and chapter (#8068) (#8069)
* fix(reader): preview target page counters and header during native page-turn captures

Pre-captured adjacent sheets in NativePageTurn and PageTurnBuffer use paginator.previewPage(), which intentionally skips relocate events. Because ProgressBar and SectionInfo overlay the full renderer bounds, PixelCopy/snapshot captures previously baked the current page's page number and remaining-page count onto neighbouring sheets.

Add a lightweight display-only pageTurnPreview store (subscribed only by ProgressBar and SectionInfo) that previews the target page's progress, remaining pages, and section label while previewPage() captures an adjacent sheet, and releases only after previewPage() restores containerPosition so live readouts never sample the previewed renderer.page.

Co-Authored-By: Antigravity (Gemini) <noreply@google.com>

* fix(reader): show each Curl and Page Flip sheet's own page number and chapter (#8068)

Native Curl and Page Flip capture the next and previous pages ahead of a
turn with paginator previewPage(), which paints the page without
relocating. The running header and footer sit over the renderer box, so
the captures took them in still showing the page being read: page number,
pages left, progress fill and, at a chapter boundary, the chapter title.
They caught up only once the turn landed.

This reworks the first version, which estimated the neighbour's numbers
in Readest (pageTurnPreview.ts) from section fractions and the renderer's
page count, through hooks in NativePageTurn and PageTurnBuffer. That
estimate can disagree with what foliate reports after the turn (two-column
spreads, lead pages, chunked chapters, which it skipped), and with no
range for the page, the chapter title inside a multi-entry chapter and the
printed page label stayed stale. Now foliate names the previewed page
itself (readest/foliate-js#204, pinned at fb174ec): `preview` carries what
a relocate there reports, then null once the reading position is back.
FoliateViewer keeps it as a display-only PagePreview in readerProgressStore,
built the way setProgress builds progress. ProgressBar, SectionInfo and the
screen-page pair read it; reading progress, history and sync never see it.

Verified:
- Fails without the change: the paginator-paginated browser test
  "previews the location a turn then reaches" (360 and 800 px) fails on
  the old foliate pin with "expected [] to have a length of 2". The new
  ProgressBar, SectionInfo and foliate-viewer-relocate tests fail on
  main's components with "expected '3 / 10' to be '4 / 10'", "expected
  'Chapter 1' to be 'Chapter 2'" and "expected undefined to match object".
  All pass with it.
- 39 paginator and page-turn browser files (464 tests), the 5 browser
  files that mock the progress store, and 92 related unit files (1434
  tests) pass. pnpm lint and pnpm format:check pass.
- Android emulator (API 35, debug x86_64 build of this branch, the Alice
  EPUB, Show Remaining Pages on), each turn held mid-way:
  Curl forward: the revealed page reads 16 / 112 while the outgoing page
  reads 15 / 112. Curl backward: the incoming page reads "11 pages left in
  chapter", as after the turn. At a chapter boundary the next chapter's
  first page shows its own count ("pages left", 19 after the turn) and
  the trace shows its chapter title in the header during the capture.
  Page Flip backward: the incoming half reads "11 pages left in chapter",
  as after the turn.
  With foliate's preview event dropped over CDP (main's behaviour) the
  same curls show 29 / 112 for a page that is 30 / 112, "8 pages left"
  where the turn lands on 9, and "1 page left" on the next chapter's
  first page.
- Not run: iOS (same JS path; WKWebView snapshots).

Reported by leehuazhong on GitHub.

Co-Authored-By: Claude Code (Claude Opus 5.5) <noreply@anthropic.com>

---------

Co-authored-by: Antigravity (Gemini) <noreply@google.com>
Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Code (Claude Opus 5.5) <noreply@anthropic.com>
2026-11-28 18:28:52 +01:00
..
foliate-js@fb174ec01c fix(reader): show each Curl and Page Flip sheet's own page number and chapter (#8068) (#8069) 2026-11-28 18:28:52 +01:00
js-mdict@d01bf62af8 feat(dict): faster MDict/StarDict import + lazy lookup; raw .dict; UX (#4334) 2026-05-28 07:48:16 +02:00
qcms@fc23a407f1 chore(fdroid): get rid of wasm binaries in fdroid build (#3677) 2026-03-29 18:31:46 +02:00
simplecc-wasm@5e5b56f5b8 chore(fdroid): get rid of wasm binaries in fdroid build (#3677) 2026-03-29 18:31:46 +02:00
swift-rs feat(reader): Page Flip page-turn style on Android, iOS and desktop (#7160) 2026-10-30 12:57:43 +01:00
tauri@382ea858bd fix(android): stop the app freezing at launch on a page load deadlock (#6240) 2026-09-17 17:43:36 +08:00
tauri-runtime-cef-stub chore(linux): catch up the CEF runtime with upstream feat/cef, closes #6397 (#6487) 2026-09-30 04:07:58 +08:00