V1.0.43 oss (#202)

* Added support for AI and Cloud credits in the Pro flavor.

* Implemented credit-based authentication and authorization for AI features and Cloud TTS.

* Updated AI feature access and purchase handling to a credit-based system.

* Refactored and enhanced the Text-to-Speech (TTS) system with persistent caching and a redesigned UI.

* Improved TTS cache management by organizing audio files by book title and adding a detailed cache storage UI.

* Refactored the TTS service to use a WebSocket-based Gemini Live connection for cloud audio generation.

* Removed the TTS cache settings tab and simplified voice sample playback by removing local caching logic.

* Implemented a low-latency streaming mechanism for Cloud TTS using a custom `ConcurrentInputStream` and `ExoPlayer` data source.

* Improved cloud TTS stability and prefetching logic in `TtsService` and `TtsPlaybackManager`.

* Implemented AI summarization caching and cost tracking in the EPUB reader.

* Enhanced chapter summary caching and UI feedback.

* limit summaries for pro users to 10 per day

* Implemented local caching for Cloud TTS audio chunks.

* Removed the Free tier tab from `ProScreen` and simplified the subscription interface. Updated tab logic to focus on Pro and Credits, including a new cost breakdown section for AI and Cloud TTS features.

* Refactored HTML parsing to include all child nodes during content chunking and semantic block parsing.

* Improved image rendering consistency in epub pagination reader

* Improved HTML parsing in `HtmlParser.kt` to better handle complex nested structures

* Improved CSS styling support in the epub paginated reader for word spacing and text decorations.

* Implemented scroll throttling in `epub_reader.js` to improve performance during scroll events

* Improved CFI resolution and scrolling reliability in EPUB reader

* Optimized PaginatedReader performance by caching text decorations.

* Implemented batching for recent file database operations to handle large datasets and introduced `RecentFileSummary` to optimize data retrieval by excluding heavy JSON columns.

* Improved navigation stability by wrapping `navController.navigate` and `popBackStack` calls in a try-catch block to handle `IllegalStateException` during concurrent transitions. Additionally, refined the backstack check for the main route to prevent redundant pops.

* feat(tts): redesign TTS controls with overlay UI and cache management

* Expanded and improved the TTS (Text-to-Speech) capabilities, particularly for Cloud voices.

* Improved TTS playback control and cache management.

* Integrated the TTS cache manager into the settings sheet and improved the TTS configuration UI.

* Updated `DeviceVoicesTab` to respect the current TTS mode, disabling voice selection when not in `BASE` mode.

* Improved error handling and state management for Cloud TTS in `TtsService` and `TtsPlaybackManager`.

* Improved TTS voice selection UI and sample playback logic.

* Updated `TtsUtils` and `TtsService` to remove `chunkIndex` from TTS cache filenames. Refined the cache file naming convention to rely on text and speaker hashes, and updated the cache file filter logic to correctly identify speakers in both legacy and new filename formats.

* Optimized tile rendering and state propagation in PDF viewer

* Added "Expand All", "Collapse All", and "Locate" functionality to the Table of Contents in both EPUB and PDF readers.

* Added sign-in requirement for credit purchases and improved purchase migration logic.

* Updated `EpubReaderTts` to support authenticated TTS requests by passing an auth token provider. The `ttsController.start` method now includes an `authToken` retrieved via `getAuthToken` and explicitly sets the `playbackSource` to "READER".

* feat(ai): replace summarization popup with a comprehensive AI Hub Bottom Sheet

* Improved locator logic and block traversal in `BookPaginator`.

* Updated AI features and Cloud TTS logic.

* Added manual clear and auto-reset functionality for AI summaries and recaps

* Optimized file importing, EPUB parsing, and TTS playback concurrency.

* Restricted TTS mode to BASE in OSS flavor and fixed TTS mode persistence in PDF viewer

* Bump version to 1.0.43(44)
This commit is contained in:
Aryan 2026-04-18 16:46:58 +05:30 committed by GitHub
parent e8f6be2800
commit 46620fa71a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 4412 additions and 2406 deletions

View file

@ -581,25 +581,22 @@
var scrollHeight = Math.round(Math.max(document.body.scrollHeight, document.documentElement.scrollHeight));
var clientHeight = Math.round(document.documentElement.clientHeight || window.innerHeight || 0);
if (clientHeight === 0) return;
if (clientHeight === 0) return;
var activeFragment = null;
var hasFoundAnyElementInDom = false;
var activeFragment = null;
var hasFoundVisible = false;
if (window.TOC_FRAGMENTS && window.TOC_FRAGMENTS.length > 0) {
// Adjust threshold to be slightly more forgiving (padding + 60px)
if (window.TOC_FRAGMENTS && window.TOC_FRAGMENTS.length > 0) {
var threshold = window.VIEWPORT_PADDING_TOP + 60;
for (var i = 0; i < window.TOC_FRAGMENTS.length; i++) {
var id = window.TOC_FRAGMENTS[i];
// FIX: Look for both 'id' and 'name' attributes
var el = document.getElementById(id) || document.querySelector('[name="' + id + '"]');
if (el) {
hasFoundVisible = true;
var rect = el.getBoundingClientRect();
// Log individual element positions so we can see them in your FRAG_NAV_DEBUG filter
console.log("FRAG_NAV_DEBUG: Checking #" + id + " | rect.top: " + Math.round(rect.top) + " | threshold: " + threshold);
if (rect.top <= threshold) {
@ -660,8 +657,24 @@
);
};
window.addEventListener("scroll", window.reportScrollState, { passive: true });
window.addEventListener("resize", window.reportScrollState);
let scrollThrottleTimeout = null;
let lastScrollTime = 0;
window.addEventListener("scroll", function() {
const now = Date.now();
if (now - lastScrollTime >= 100) {
window.reportScrollState();
lastScrollTime = now;
} else {
if (scrollThrottleTimeout) clearTimeout(scrollThrottleTimeout);
scrollThrottleTimeout = setTimeout(function() {
window.reportScrollState();
lastScrollTime = Date.now();
}, 100);
}
}, { passive: true });
window.addEventListener("resize", window.reportScrollState);
window.triggerInitialScrollStateReport = function () {
var attempts = 0;
@ -896,12 +909,8 @@
}
try {
console.log(`$ {
TTS_HIGHLIGHT_LOG_TAG
}
: Resolving CFI to node...`);
const location = window.getNodeAndOffsetFromCfi(cfi);
console.log(`${TTS_HIGHLIGHT_LOG_TAG}: Resolving CFI to node...`);
const location = window.getNodeAndOffsetFromCfi(cfi, true);
if (!location || !location.node) {
const errorMsg = "JS: Could not find node for CFI.";
@ -1404,7 +1413,7 @@
`);
}
function resolveCfiPath(rootElement, path) {
function resolveCfiPath(rootElement, path, requestChunkIfMissing = false) {
let currentNode = rootElement;
const steps = path.substring(1).split("/").map(Number);
@ -1420,12 +1429,26 @@
let chunkElement = currentNode.querySelector(`.chunk-container[data-chunk-index="${chunkIndex}"]`);
if (chunkElement) {
if (chunkElement.innerHTML === "" && window.virtualization && window.virtualization.chunksData[chunkIndex]) {
console.log("CFI_DIAGNOSIS: Chunk " + chunkIndex + " was empty, restoring content for CFI resolution.");
chunkElement.innerHTML = window.virtualization.chunksData[chunkIndex];
chunkElement.style.height = "";
if (window.CURRENT_HIGHLIGHTS) {
window.HighlightBridgeHelper.restoreHighlights(window.CURRENT_HIGHLIGHTS);
if (chunkElement.innerHTML === "") {
if (window.virtualization && window.virtualization.chunksData[chunkIndex]) {
console.log("CFI_DIAGNOSIS: Chunk " + chunkIndex + " was empty, restoring content for CFI resolution.");
chunkElement.innerHTML = window.virtualization.chunksData[chunkIndex];
chunkElement.style.height = "";
if (window.CURRENT_HIGHLIGHTS) {
window.HighlightBridgeHelper.restoreHighlights(window.CURRENT_HIGHLIGHTS);
}
} else {
if (requestChunkIfMissing) {
console.log("PosSaveDiag: Requesting missing chunk " + chunkIndex + " for CFI resolution.");
if (window.ContentBridge && window.ContentBridge.requestChunk) {
if (!window._requestedChunksForCfi) window._requestedChunksForCfi = {};
if (!window._requestedChunksForCfi[chunkIndex]) {
window._requestedChunksForCfi[chunkIndex] = true;
window.ContentBridge.requestChunk(chunkIndex);
}
}
}
return null;
}
}
@ -1450,7 +1473,7 @@
return currentNode;
}
window.getNodeAndOffsetFromCfi = function (cfi) {
window.getNodeAndOffsetFromCfi = function (cfi, requestChunkIfMissing = false) {
try {
var pathParts = cfi.split(":");
var nodePath = pathParts[0];
@ -1470,7 +1493,7 @@
return { node: cfiRoot, offset: charOffset };
}
let resolvedNode = resolveCfiPath(cfiRoot, pathToResolve);
let resolvedNode = resolveCfiPath(cfiRoot, pathToResolve, requestChunkIfMissing);
if (!resolvedNode) return null;
@ -1650,6 +1673,7 @@
}
console.log("NavDiag: JS scrollToCfi called with cleanCfi=" + cleanCfi);
window._requestedChunksForCfi = {}; // Reset the requested cache
if (!cleanCfi || !cleanCfi.startsWith('/')) {
if (window.CfiBridge && window.CfiBridge.onScrollFinished) {
@ -1659,7 +1683,7 @@
}
let attempts = 0;
const maxAttempts = 20;
const maxAttempts = 40; // Increased to 40 attempts (4 seconds) to give Kotlin time to inject chunks
let stabilizingFrames = 0;
const maxStabilizingFrames = 8;
@ -1667,7 +1691,8 @@
attempts++;
try {
const location = window.getNodeAndOffsetFromCfi(cleanCfi);
// Pass 'true' to dynamically request any missing chunks needed to resolve the position
const location = window.getNodeAndOffsetFromCfi(cleanCfi, true);
if (location && location.node) {
if (!document.body.contains(location.node)) {
@ -1700,9 +1725,24 @@
const range = document.createRange();
const validOffset = Math.min(remainingOffset, currentNode.nodeValue.length);
range.setStart(currentNode, validOffset);
range.collapse(true);
const rect = range.getBoundingClientRect();
const endOffset = Math.min(validOffset + 1, currentNode.nodeValue.length);
if (validOffset < endOffset) {
range.setStart(currentNode, validOffset);
range.setEnd(currentNode, endOffset);
} else if (validOffset > 0) {
range.setStart(currentNode, validOffset - 1);
range.setEnd(currentNode, validOffset);
} else {
range.setStart(currentNode, validOffset);
range.collapse(true);
}
let rect = range.getBoundingClientRect();
const rects = range.getClientRects();
if (rects && rects.length > 0) {
rect = rects[0];
}
if (rect.top !== 0 || rect.bottom !== 0) {
targetScrollY = window.scrollY + rect.top - (window.VIEWPORT_PADDING_TOP + 5);
@ -1739,12 +1779,14 @@
if (attempts < maxAttempts) {
setTimeout(attemptScroll, 100);
} else {
console.log("PosSaveDiag: attemptScroll failed after " + maxAttempts + " attempts for CFI: " + cleanCfi);
if (window.CfiBridge && window.CfiBridge.onScrollFinished) {
window.CfiBridge.onScrollFinished(false);
}
}
}
} catch (e) {
console.log("PosSaveDiag: attemptScroll exception: " + e.message);
if (window.CfiBridge && window.CfiBridge.onScrollFinished) {
window.CfiBridge.onScrollFinished(false);
}