Make converting a Link to a Locator synchronous - #892
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes Link → Locator conversion synchronous by moving the logic into Manifest and exposing a new Publication.locator(for:) API, then updates navigators, the test app, and tests accordingly.
Changes:
- Added
Manifest.locator(for:)andPublication.locator(for:), and marked the old asynclocate(_ link:)APIs unavailable. - Updated Navigator/TestApp call sites to use
publication.locator(for:)(and updated the EPUB viewport calculator fallback to use the manifest). - Updated/relocated tests (including migrating some suites from XCTest to Swift Testing) and added a changelog entry.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/SharedTests/Publication/Services/Locator/DefaultLocatorServiceTests.swift | Removes tests for async locate(Link) since conversion moved out of the service. |
| Tests/SharedTests/Publication/PublicationTests.swift | Migrates to Swift Testing and adds coverage for Publication.locator(for:). |
| Tests/SharedTests/Publication/ManifestTests.swift | Migrates to Swift Testing and adds coverage for Manifest.locator(for:). |
| Tests/NavigatorTests/EPUB/EPUBViewportAndLocationCalculatorTests.swift | Updates tests for sync compute() and manifest-based fallback locator construction. |
| TestApp/Sources/Reader/Common/VisualReaderViewController.swift | Replaces await publication.locate(link) with publication.locator(for:) for image preview and page list logic. |
| TestApp/Sources/Reader/Common/Outline/OutlineTableView.swift | Removes async Task wrapper by using synchronous publication.locator(for:). |
| Sources/Streamer/Parser/Audio/Services/AudioLocatorService.swift | Drops the locate(Link) delegation path now that link→locator conversion is synchronous elsewhere. |
| Sources/Shared/Publication/Services/Locator/LocatorService.swift | Removes locate(Link) from the service protocol and Publication helpers. |
| Sources/Shared/Publication/Services/Locator/DefaultLocatorService.swift | Marks locate(Link) unavailable (guiding callers to Publication.locator(for:)). |
| Sources/Shared/Publication/Services/Content/Iterators/PublicationContentIterator.swift | Removes awaiting link→locator conversion; uses the new synchronous API. |
| Sources/Shared/Publication/Publication.swift | Adds locator(for:) and marks old locate(_ link:) unavailable/renamed. |
| Sources/Shared/Publication/Manifest.swift | Implements the core synchronous locator(for:) conversion logic. |
| Sources/Navigator/PDF/PDFNavigatorViewController.swift | Updates link navigation to use publication.locator(for:). |
| Sources/Navigator/EPUB/EPUBViewportAndLocationCalculator.swift | Makes compute() synchronous, adds manifest parameter, and builds fallback locators via manifest.locator(for:). |
| Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | Wires the new compute() signature and uses publication.locator(for:) for link navigation. |
| Sources/Navigator/Audiobook/AudioNavigator.swift | Updates link navigation to use publication.locator(for:). |
| CHANGELOG.md | Documents the API change from await publication.locate(link) to publication.locator(for: link). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Changed
Shared
Linkto aLocatoris now synchronous:await publication.locate(link)becomespublication.locator(for: link). The logic moved toManifest, so it is also available asmanifest.locator(for: link)without aPublication.This aligns the API with the Kotlin toolkit, and simplifies validating a
Linkin synchronous context (e.g. reacting to an input event).