Resolve tocEntry for itemless resources - #242
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a gap in Timeline.tocEntryFor() when a single TOC entry spans multiple consecutive reading-order resources (so some resources have no TOC link referencing them), by adding a third-tier fallback that resolves those “itemless” resources to the nearest preceding resource’s TOC entry.
Changes:
- Add a tier-3 fallback in
Timeline.tocEntryFor()to walk backward in reading order when no TOC entry references the current resource. - Extend
Timeline – tocEntryFortests to cover the multi-resource-span scenario and renumber/clarify tier labels. - Bump
@readium/sharedand@readium/navigatorpatch versions and document the fix in both changelogs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| shared/src/publication/services/timeline/Timeline.ts | Adds tier-3 TOC fallback (previousResolvedTocEntry) and updates method documentation. |
| shared/test/Timeline.test.ts | Updates/extends tocEntryFor test cases to cover the new fallback behavior. |
| shared/package.json | Bumps @readium/shared version to 2.3.1. |
| shared/CHANGELOG.MD | Documents the tocEntryFor() fallback fix in 2.3.1. |
| navigator/package.json | Bumps @readium/navigator version to 2.7.2. |
| navigator/CHANGELOG.MD | Documents the shared timeline fix in 2.7.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ambiguous fragment-only coverage on a preceding resource was skipped instead of resolved (now picks the last fragment), and resource lookup matched by href instead of Link identity, which could hit the wrong occurrence when an href repeats in the reading order.
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.
When migrating Thorium web to the Timeline API for EPUB/WebPub, publication https://thorium-web.pages.dev/read/les-diaboliques exposed a gap in the tocEntry resolution: when the timeline item spans several resources,
undefinedwas returned for these resources, except the first one.