Repository navigation
Conversation
A user scroll holds the navigation lock until 500 ms after its last move, then navigates to where the element is. A navigation made in that time, as a link, a bookmark or a page turn asks for, did not land, and the navigation of the scroll then replaced it and its target. A navigation that the scroll did not make now ends the scroll: the lock is released once every listener has heard of that navigation, and the scroll makes no navigation of its own. The published navigation carries its type, which tells a navigation that follows the scroll from the others.
The scroll ended one microtask after the navigation that ended it was told. In that time a layout or a change of page turn mode made in the same task still let the scroll navigate, and a request held while the container was hidden was replaced when the scroll was over. The scroll now ends when the reader has handled a request that the scroll did not make. The reader gives those requests as a stream, `requestedNavigation$`, and the navigation it publishes keeps its shape: the `type` field added one commit earlier is gone. The browser test now uses the EPUB scenario: it compares the reading position with the one the same navigation gives at rest.
The stream of requests gives what `navigate()` was given, not a navigation: it is `navigationRequest$`. It completes when the reader is destroyed, where it went on telling requests that no reader handled. Four unit cases hold the contract of the stream. Two cases of the scroll now assert that its lock is released, where a lock that stayed held gave the same navigation. The docs say which request is told first when a listener answers one, and what a lock does to a navigation made while it is held.
A request for a navigation is told before its navigation while the reader's container is hidden. The docs and the doc comment gave the other order for every case. One more unit case: during a user scroll, a request for the place the navigation already has takes the book there. No source code changes.
…d-scroll-on-navigation fix(core): end a user scroll when the app navigates
The browser job of `_test.yml` read the Playwright version, cached the browser builds and installed them in three steps. The new workflow that repeats the browser suite needs the same steps, so they move to the composite action `.github/actions/playwright-browsers`. Refs #763
`check` retries a failed browser test twice, so a test that fails once in a while leaves the job green. This workflow is started by hand. It runs the suite on macOS a number of times (20 by default), with no retry, and lists in the run summary each test that failed, with how many of its runs failed. Inputs choose the projects and the specs, to check a fix of one spec. Refs #763, item 2
An archive named `Batman #12.cbz`, with no declared type, resolved to `application/octet-stream`, and a comic page named `Batman #12 - 001.jpg` got no media type, so the reading order did not lay it out pre-paginated. `#` is the usual issue marker in comic file names. Both read the extension with `getUrlExtension`, which cut the name at its first `#` or `?`, as in a url. A file name and an archive path now read their extension with the new `getUriExtension`: what follows the last dot of the last segment, empty when there is none. `detectMimeTypeFromName` and `resolveArchiveMediaType` use it. A name without a dot no longer reads as its own extension: a file named `pdf` is no PDF. A url still loses its query and fragment first, through the new `detectMimeTypeFromUrl`. Core's fallbacks on a manifest item's `href` and `createArchiveFromUrls` use it, since the streamer writes a `#` or a `?` of a resource path as `%23` or `%3F`. `createArchiveFromUrls` detects each url's type once, not twice. Fixes #665 BREAKING CHANGE: `getUrlExtension` is no longer exported from @prose-reader/shared: use `getUriExtension` for a file name or an archive path. `detectMimeTypeFromName` keeps a `#` or a `?` in the name: use `detectMimeTypeFromUrl` for a url. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
fix(shared)!: read file name extensions after the last dot
`ReactiveEntity.watch(key)` compared the field's values with `isShallowEqual`, which compares two objects by their own enumerable keys. A DOM element has none, so any two elements compared equal: a field that held one element and then another emitted only the first. `context.rootElement`, `spine.element` and the scroll navigation controller's `element` are watched that way. Each is set once per reader today, so nothing broke yet, but mounting the reader into another container would leave their subscribers on the old element. `watch(key)` now compares a plain object or an array by its keys, so a copy still reports no change, and any other value by identity. `isShallowEqual` keeps its behaviour for its other callers. The annotations enhancer's `annotations$` setting, an observable, now reports a new observable as a change; the array comparison after it drops a repeat. Fixes #693 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
`isShallowEqual` compares two objects by their own enumerable keys. An object that keeps its state elsewhere has none, so any two compared equal: two DOM elements, two `Map`s, two `Date`s. That is the cause of #693, where `ReactiveEntity.watch(key)` never reported an element replaced by another. An object with no own enumerable keys, other than a plain object or an array, now equals only itself. Instances of a class still compare by their own fields, as the navigation positions need. `ReactiveEntity.watch(key)` goes back to `isShallowEqual` as it was: the previous commit taught it to tell DOM elements apart, a rule that belongs to the comparison every caller shares. Fixes #693 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
An agent took #693's proposed location for its fix as given, and put a DOM rule in `ReactiveEntity`. AGENTS.md now says that an issue's proposed fix is judged like any other design, and that a pull request says where it departs from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
A test written in a loop has the same file, line and title in each pass of the loop. Only its describe titles differ, so the summary merged the zoom-out tests of three scales into one row of 60 runs. Refs #763, item 2
The two swipe tests of `gestures/pan/touch.spec.ts` failed on CI now and then on Mobile Chrome. gesturx reads a swipe's speed from the page's clock, over the 100ms before the finger lifts. Each touch command waits for the page to take its touch, and under load two steps asked to be 16ms apart were up to 190ms apart. The move before the last then fell out of those 100ms, the speed read 0, and the page did not turn. `playTouchGesture` now pauses the page's clock for the gesture, and moves it only by the step delays, as `boundary.spec.ts` does for a tap. The lift comes at the time of the last move. Measured on Linux, Mobile Chrome, 10 workers on 4 cores, 100 runs of each test of the spec: - before: 5 of 200 swipe runs failed; - after: 0 of 200 failed. With a real 200ms wait added after each step, the swipes still pass. With slow flicks, both tests fail on their assertion. Refs #763, item 2
This replaces the two earlier attempts in this branch: the DOM rule in `ReactiveEntity`, then the heuristic in `isShallowEqual`. Both go, and `isShallowEqual` is as it was. `ReactiveEntity.watch(key)` compared the field's values with `isShallowEqual`, a comparison made for plain objects. A DOM element has no own enumerable keys, so any two compared equal, and a field that held one element and then another reported only the first. `watch([keys])` already compared each field with `Object.is` and had no such bug. `watch(key)` now compares with `Object.is` too, so both forms report the same changes. The watched element fields, `context.rootElement`, `spine.element`, the scroll navigation controller's `element` and a renderer's `documentContainer`, report an element replaced by another. The viewport wrote a new `pageSize` object at every layout, which `watch(key)` compared by its width and height. It now keeps the same object until a layout changes the size of a page, so `pageSize` reports only real changes, watched on its own or in a list. A layout still reports a state, as `state$` documents. Fixes #693 BREAKING CHANGE: `watch(key)` compares a field by identity: a field that gets a new object with equal contents is now reported. The viewport's `pageSize` keeps its object while the size is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
The flaw in #693 was the comparison `ReactiveEntity.watch(key)` used, not `isShallowEqual`, which is made for plain objects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
Core worked out the pages of a spine item in about 14 files: five helper files, two locators, a second item locator inside the navigation resolver, and six mirrored left and right page-turn resolvers. Each file handled LTR, RTL and vertical writing again, and the copies had drifted apart. `SpineItemPageGeometry` now answers every page question for an item: its page count, the page of a position, where a page starts, a position inside a page, and the closest page start. A spine item exposes it as `spineItem.pageGeometry`. The locators, the navigation resolver, the restoration and the pages call it. - The node lookups move to `spineItem/nodeLocation.ts`. The item locator and the item navigation resolver are deleted. - The six page-turn resolvers become `getNavigationForPageTurn`, with a `side` of "leftOrTop" or "rightOrBottom". - The two position clamps become `clampPositionInSpineItem`. A comparison over 200,000 random inputs gives the same results as the old helpers, with one exception. In an RTL book, a page of an item narrower than one page starts at x = 0, not at a negative x. After a layout, an item is at least one page wide, so a laid-out book shows no difference. BREAKING CHANGE: `SpineItem.numberOfPages` is removed. Read `spineItem.pageGeometry.numberOfPages`. `reader.spine.locator` no longer has `spineItemLocator` or `getSafeSpineItemPositionFromUnsafeSpineItemPosition`. `reader.navigation.navigationResolver` no longer has `spineItemNavigator`. The `Spine` and `Pages` constructors no longer take the item locator.
The viewport and spine pages each explained how `.state$` and `.watch()` behave, which is the same for every object that holds a state. The core API introduction now documents `.value`, `.state$` and `.watch()` once, in a Reactive state section, and says that `.watch()` compares a field by identity. Each page keeps its state, what is particular to it, and a link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyJ6EhfYdUHYAp9MhLk
fix(core)!: compare a watched field by identity
- Read the writing mode of an item once per page geometry, and only in the methods that need it. Snapping a position to the page grid reads no computed style. - Rename `getClosestPageStart` to `snapPositionToPageGrid`. It moves each axis back to the page grid, so "closest" was not true. - Export the `SpineItemPageGeometry` type. - Build the page geometry once per node lookup. - Reuse `getNavigationFromSpineItemPosition` in `getNavigationForPosition`, and `getNavigationForSpineItemPage` for the last page of an item. - Read the page turn direction from the settings in `getNavigationForPageTurn`. - Test each side of a page turn: in an item, past its edge, in vertical writing and in a spread, LTR and RTL. - Fix the `keepSpineItemLoaded` docs example, which used the removed `item.numberOfPages`. - Make the doc comments say what the code does.
The browser jobs ran `setup` with the libraries built, then the action that installs the pinned browsers, which needs `setup` before it. The action now runs `setup` itself, as `setup-browser-suite`, so the order holds by construction. Its description no longer claims the system libraries: `--with-deps` installs them on Linux and Windows only. Refs #763
A shard stopped at the job's time limit, or one that failed before its tests, left no report, and the summary of the others read as complete. An error outside a test, such as a web server that did not start, did not show either. - Playwright stops itself 10 minutes before the job's limit, so a shard still writes the report of the tests it ran. - The summary gives the runs, passes, failures and skips, the errors outside a test, and how many shards reported. The job fails when one is missing. - The HTML report is uploaded even when the summary step fails. - The test filters are split on spaces, and no longer glob-expanded. - `download-artifact` moves to v8, the release that goes with `upload-artifact@v7`. - One run of the suite takes about 22 minutes of shard time in `check`, not 17: the comment on the time limit says so. Refs #763, item 2
The page's clock held still during a gesture, but Chromium hands a touch move to the page at its next frame, after the command that sent it returns. A move was then often read at the time of the step after it: [0, 16, 48, 48, 48] where the gesture asked for [0, 16, 32, 48, 48]. Without a time between steps, the clock never moved, so the timer that starts a pan never ran, and the landscape drag reached no recognizer. - `playTouchGesture` waits for the page to take each touch before the clock moves on, and moves the clock before each step, by a frame unless the spec says otherwise. A cancelled pointer also ends the wait, so the landscape spec still fails on its own assertion. - `timeBetweenSteps` gives the gaps between steps, one fewer than the steps. The slow drag no longer has a stop of 60ms before its flick that its comment called a stop and the page never saw. - `holdPageClockDuring` in `tests/utils/clock.ts` holds the clock, and resumes it when the play ends or throws. The boundary spec uses it too, in place of its own copy. - The touch spec skips the profiles without a touch screen once, before the clock is installed. - `apps/tests/AGENTS.md` describes the held clock, and the workflow that shows a fix of a flaky spec holds. Measured on Linux, Mobile Chrome, 10 workers on 4 cores: the page read the exact times in 80 of 80 runs, and the touch spec passed 500 of 500. With slow flicks, both swipe tests fail on their assertion. With the touch-action rule of the gestures enhancer removed, the landscape test fails on its cancel count. Refs #763, item 2
Over a book's page, a touch lands in the page's frame. Core's events enhancer passes a copy of each of its pointer events to the reader's root element, and those copies are what the wait counts. The comments said the wait did not see a frame's events. Refs #763, item 2
ci: find flaky browser tests and fix two swipe tests
The browser suite had no reflowable book that reads right to left or in vertical writing, so no spec ran the code that tells those pages apart. The test server now rewrites `accessible_epub_3.epub` into both, and a new scenario, `tests/navigation/pages`, opens either one or the original. For a long chapter, the specs check: - where the reader places each page; - page turns in reading order, with one page or a spread; - `goToPageOfSpineItem`, to a page and to the last page; - the page of the first node shown; - the page and the position in it that `beforeTapGesture` hooks get. The vertical chapter stops at its first page: a navigation lower in it is held at the height of the last spine item (#793). Its specs cover only the page places and a tap on the first page. Each spec fails when one of these rules is broken in core: the RTL page order, the RTL page start, the RTL position in a page, the vertical page start, and the direction of a page turn.
…ht edge In a right-to-left book, `SpineItemLayout` places an item at the right edge of its page. For an item narrower than a page, develop's navigation gave the page start that follows from it, at a negative x. Its tap path clamped that start to 0, and the page geometry had taken the clamp. The page geometry now gives the unclamped start. Navigation then gives the same results as develop: a comparison with develop's helpers on 200,000 random inputs found no difference in page count, page index, grid snap or page start. The position in a page that `beforeTapGesture` hooks get changes for an RTL item narrower than a page, and now measures from that page's real start. An item is narrower than a page before its first layout, and between a page size change and its next layout. Two unit tests now show known bugs as expected failures: - a page turn out of a vertical-writing item in a right-to-left spread does not move (#794); - with a vertical page turn and horizontal writing, a page start does not map back to its page index (#788).
- One table of books holds what tells them apart: the page turns, where a page is in its item, and the half of a spread that shows the first page. Every spec runs for every book. - The vertical book runs the specs that need its later pages as expected failures (#793), so they turn red once that bug is fixed. - The first-node spec checks that the node is on the first page shown, not only that a round trip gives the page back. In a right-to-left spread whose frame is offset in its item, it is an expected failure (#795). - The specs assert that the reader reads each book in its direction and writing mode, and that the window shows one page or a spread. - The page list is read once the result has settled on the current layout, by each page's own index. - `readSettledPagination`, `readCfiPositionInWindow` and `navigateToPageOfSpineItem` join the shared test helpers. - A rewrite of a fixture fails when the fixture lacks its pattern.
…rdrail-specs test(core): pin the pages of a chapter in LTR, RTL and vertical writing
refactor(core)!: compute the pages of a spine item in one place
…nfo` `SpineLayout` derives the smallest box that holds every spine item from the items of its last completed pass. `reader.spine.layoutInfo` exposes it, in the coordinates of `getSpineItemSpineLayoutInfo`. Before the first pass completes, every edge is 0. The navigation clamp reads it in the next commit.
The clamp took the height of the spine from the last spine item. In a book of vertical writing, the items sit side by side and the pages of each item go down it. A chapter taller than the last item then stopped at its first page: a page turn or `goToPageOfSpineItem` came back at y = 0. The clamp now reads `reader.spine.layoutInfo`. Its x bounds keep their formulas: in a horizontal layout, the box's left and right edges are the edges of the last and first items it read before. The test fakes that mock the places of the items now also mock the box, through one helper, `mockSpineLayout`. A reader test with a first item three pages tall goes to its last page; on the old clamp it stays at y = 0. Fixes #793
…r spread The specs of the vertical book that needed its later pages ran as expected failures (#793). They now pass, except one: - In a spread, a page of vertical writing is as wide as the spread, so a spread shows one page of the vertical book. The specs expected two. The table of books now says what a spread shows of each. - The first-node spec of the vertical book fails on #713: the node lookups ignore the vertical axis. With one page, the reader finds the node on page 0; in a spread, the first page shown has no node. It runs as an expected failure.
…oundingBox` Review of the first commits: - `reader.spine.layoutInfo` became `reader.spine.boundingBox`. `layoutInfo` read as the value of `reader.layoutInfo$`, which emits the pages, and `spineItem.layoutInfo` is a size, not a box. - It is a `SpineBoundingBox`, branded like the other layouts of the spine. `SpineBoundingBox.fromSpineItemLayouts` computes it, for the spine layout and for the test fakes. - It is `undefined` until a layout has laid out an item, rather than a box of 0 by 0. The clamp then reads only the spine. Before the first layout, `getBoundaryForRectInSpine` reports no boundary. - The spine layout computes it once per completed pass, not on each read. - The clamp uses one formula for both reading directions. In a left-to-right book, the box starts at 0 on x, as the old `xMin` did. Unit tests pin two layouts where the box differs from the edges the old clamp read: a right-to-left book, and a right-to-left spread that scrolls. In that spread, the last item starts half a viewport from the left, and the old clamp moved the screen there.
…e turns The expected failure no longer covers the page turns, so a failure there still shows. The comments of the table move to the vertical book.
…rection With the bounds from the spine's box, `xMin` is never above `xMax` in a layout the spine produces: the box starts at or left of x = 0, and `xMax` is at least 0. The two orderings of the clamp then give the same result, so `clampRectInSpine` drops `isRTL`. `getBoundaryForRectInSpine` keeps it, to tell the start of the book from its end. The clamp tests name their groups by the box, not by the direction.
It compares a navigation with `reader.spine.boundingBox`, which is `undefined` until a layout has laid out a spine item. Until then, it emits nothing.
fix(core): reach every page of a vertical-writing chapter
The reader measured nodes in their frame and took the measures as positions in the frame's spine item. In a right-to-left spread, the renderer puts a blank page before the text, so the frame starts a page into its item. The anchor of a page then named text on the page before it, and a cfi saved from it went one page off once resolved (#795). - `DocumentFramePlacement` measures where a frame sits in its item, its offset and its scale, from their rendered boxes. It converts a point of the document to the item, and a box of the item to the document. - The page of a node comes from the first box the node lays out, in the item, through the page geometry. Its boxes as one rect started on the last page the node reaches when its pages run right to left. The page geometry reads `y` in vertical writing, where the lookup took 0, so every node was on the first page (#713). - The anchor of a page is searched with the page's box in the frame, and a rect is in the box when it overlaps it on both axes. Only the horizontal edges were compared. - `pageGeometry.pageSize` gives the size of each page of an item. A page of vertical writing is as wide as its item, both halves of a spread, and `Pages` builds each page's box from it. `Pages` no longer takes the viewport.
The restoration resolved the anchor of a navigation after every layout, except in items written right to left or vertically, where the reader could not tell the page of a node. It can now, so the exception goes. A font size change that keeps an item's page count moves its text, and the reader now follows the text in these items too.
…creen - The first-node spec runs as a plain spec for the right-to-left spread (#795) and the vertical-writing book (#713). - A new spec turns to a later page of each book, makes the font a little smaller in ten steps, and checks that the first node shown stays on screen. A step tests the restoration only if it keeps the chapter's page count and moves the node, and the spec checks that one does.
…unrounded Review of the first commits: - The locator's visible pages and the page of a tap take their size from `pageGeometry.pageSize`, as `Pages` does. A page of vertical writing had the item's width in `Pages` and half a spread in the locator, so a bookmark marker and its tap zone did not meet. - `DocumentFramePlacement` reads the layout size of the frame and of its item from their computed style. `offsetWidth` rounds it, and a page half of an odd window width made up a scale, which moved text at a column's edge to the page before. - It takes the item's element and its frame, and converts a point of the frame and a box of the item, `toFrameBox`. - `Pages` measures the placement once per item, not once per page. - The anchor lookup, `getFirstNodeInBox`, takes a document. In text written right to left, it reads the offset at the right edge of the first line box, where the line starts. - The page geometry's input is `viewportPageSize`, apart from its `pageSize`. - Unit tests cover the page size, the unrounded layout size, and the rule that a node must overlap a page on both axes, not touch its edge. - The gestures docs say what the page of a tap is.
… the old rule - The font scale spec runs in every window, a spread included, where a right-to-left chapter can have a blank page before its text, and in a spread of an odd width, whose pages are half a pixel off a whole size. - The restoration tests no longer set an item's direction or writing: no code reads them there. - The test harness no longer mocks `Range.getBoundingClientRect`, which nothing in core calls.
fix(core)!: find a node's page in RTL and vertical books
`getFirstNodeInBox` refines a page's anchor with a caret at the start of the first line box on the page: its right edge for horizontal text written right to left. For a line box under two pixels wide, `Math.floor(right) - 1` fell left of the box, so the caret could name a character outside it. The point is now held at or right of the box's left edge. Unit tests stub `caretPositionFromPoint` and check the point the lookup asks for: left to right, right to left, and a line box 1.2 px wide. The right-to-left test fails with the caret at the left edge, and the narrow box test fails on the point before this change.
…s right edge `Math.ceil(right) - 1` mirrors `Math.ceil(left)`: it lands inside every line box that spans a whole pixel, narrow ones included, so the clamp goes. The comments say what the point is and what the test stub does.
…t scale The restoration spec of #798 shrank the font in ten steps and needed one step that moved the first node shown to another page while the chapter kept its number of pages. Which step does depends on the browser's fonts: on develop, none did on Firefox for the vertical-writing book, nor on WebKit and Mobile Safari for the right-to-left book. The spec now puts a spacer before the chapter's text and one after it, two pages long. Moving the space from the one after to the one before moves the text exactly two pages on, and the chapter keeps its number of pages in every browser. The spec checks both, then that the reader shows the page two pages on, with the node on screen. It passes on Chromium, Firefox, WebKit, Mobile Safari and Mobile Chrome. With the restoration from before #798, it fails for the right-to-left and vertical-writing books in every window: the reader stays on its page.
fix(core): read a page anchor's caret inside its line box
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.