Skip to content

Resolve tocEntry for itemless resources - #242

Merged
JayPanoz merged 4 commits into
developfrom
timeline-tocEntry-resolution
Jul 16, 2026
Merged

Resolve tocEntry for itemless resources#242
JayPanoz merged 4 commits into
developfrom
timeline-tocEntry-resolution

Conversation

@JayPanoz

Copy link
Copy Markdown
Contributor

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, undefined was returned for these resources, except the first one.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 – tocEntryFor tests to cover the multi-resource-span scenario and renumber/clarify tier labels.
  • Bump @readium/shared and @readium/navigator patch 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.

Comment thread shared/src/publication/services/timeline/Timeline.ts Outdated
Comment thread shared/test/Timeline.test.ts
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread shared/src/publication/services/timeline/Timeline.ts
@JayPanoz
JayPanoz added this pull request to the merge queue Jul 16, 2026
Merged via the queue into develop with commit 622ad48 Jul 16, 2026
6 checks passed
@JayPanoz
JayPanoz deleted the timeline-tocEntry-resolution branch July 16, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants