File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 project :
66 default :
77 # Allow small drops in coverage
8- threshold : 0.005 # .5 %
8+ threshold : 0.5 # 0.5 %
99 if_not_found : failure
1010
1111coverage :
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ BookReader.PLUGINS = {
7474 resume : null ,
7575 /** @type {typeof import('./plugins/plugin.text_selection.js').TextSelectionPlugin | null }*/
7676 textSelection : null ,
77+ /** @type {typeof import('./plugins/tts/plugin.tts.js').TtsPlugin | null }*/
78+ tts : null ,
7779} ;
7880
7981/**
@@ -264,6 +266,7 @@ BookReader.prototype.setup = function(options) {
264266 autoplay : BookReader . PLUGINS . autoplay ? new BookReader . PLUGINS . autoplay ( this ) : null ,
265267 resume : BookReader . PLUGINS . resume ? new BookReader . PLUGINS . resume ( this ) : null ,
266268 textSelection : BookReader . PLUGINS . textSelection ? new BookReader . PLUGINS . textSelection ( this ) : null ,
269+ tts : BookReader . PLUGINS . tts ? new BookReader . PLUGINS . tts ( this ) : null ,
267270 } ;
268271
269272 // Delete anything that's null
@@ -590,7 +593,12 @@ BookReader.prototype.init = function() {
590593 this . initToolbar ( this . mode , this . ui ) ; // Build inside of toolbar div
591594 }
592595 if ( this . options . showNavbar ) { // default navigation
593- this . initNavbar ( ) ;
596+ const $navBar = this . initNavbar ( ) ;
597+
598+ // extend navbar with plugins
599+ for ( const plugin of Object . values ( this . _plugins ) ) {
600+ plugin . extendNavBar ( $navBar ) ;
601+ }
594602 }
595603
596604 // Switch navbar controls on mobile/desktop
Original file line number Diff line number Diff line change @@ -149,6 +149,8 @@ export const DEFAULT_OPTIONS = {
149149 resume : null ,
150150 /** @type {import('../plugins/plugin.text_selection.js').TextSelectionPlugin['options'] } */
151151 textSelection : null ,
152+ /** @type {import('../plugins/tts/plugin.tts.js').TtsPlugin['options'] } */
153+ tts : null ,
152154 } ,
153155
154156 /**
Original file line number Diff line number Diff line change @@ -36,4 +36,9 @@ export class BookReaderPlugin {
3636
3737 /** @abstract @protected */
3838 _bindNavigationHandlers ( ) { }
39+
40+ /**
41+ * @param {JQuery<HTMLElement> } $navBar
42+ */
43+ extendNavBar ( $navBar ) { }
3944}
Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ import { hasLocalStorage } from './utils.js';
66/**
77 * @export
88 * @typedef {Object } TTSEngineOptions
9- * @property {String } server
10- * @property {String } bookPath
9+ * @property {import('@/src/util/strings.js').StringWithVars } pageChunkUrl
1110 * @property {ISO6391 } bookLanguage
1211 * @property {Function } onLoadingStart
1312 * @property {Function } onLoadingComplete
@@ -85,8 +84,7 @@ export default class AbstractTTSEngine {
8584 this . opts . onLoadingStart ( ) ;
8685
8786 this . _chunkIterator = new PageChunkIterator ( numLeafs , leafIndex , {
88- server : this . opts . server ,
89- bookPath : this . opts . bookPath ,
87+ pageChunkUrl : this . opts . pageChunkUrl ,
9088 pageBufferSize : 5 ,
9189 } ) ;
9290
Original file line number Diff line number Diff line change 1+ import { applyVariables } from "../../util/strings.js" ;
2+
13/**
24 * Class to manage a 'chunk' (approximately a paragraph) of text on a page.
35 */
@@ -16,24 +18,18 @@ export default class PageChunk {
1618 }
1719
1820 /**
19- * @param {string } server
20- * @param {string } bookPath
21+ * @param {import('@/src/util/strings.js').StringWithVars } pageChunkUrl
2122 * @param {number } leafIndex
2223 * @return {Promise<PageChunk[]> }
2324 */
24- static async fetch ( server , bookPath , leafIndex ) {
25+ static async fetch ( pageChunkUrl , leafIndex ) {
2526 const chunks = await $ . ajax ( {
2627 type : 'GET' ,
27- url : `https:// ${ server } /BookReader/BookReaderGetTextWrapper.php` ,
28+ url : applyVariables ( pageChunkUrl , { pageIndex : leafIndex } ) ,
2829 cache : true ,
2930 xhrFields : {
3031 withCredentials : window . br . protected ,
3132 } ,
32- data : {
33- path : `${ bookPath } _djvu.xml` ,
34- page : leafIndex ,
35- callback : 'false' ,
36- } ,
3733 } ) ;
3834 return PageChunk . _fromTextWrapperResponse ( leafIndex , chunks ) ;
3935 }
Original file line number Diff line number Diff line change @@ -138,22 +138,20 @@ export default class PageChunkIterator {
138138 * @param {number } index
139139 */
140140 _fetchPageChunksDirect ( index ) {
141- return PageChunk . fetch ( this . opts . server , this . opts . bookPath , index ) ;
141+ return PageChunk . fetch ( this . opts . pageChunkUrl , index ) ;
142142 }
143143}
144144
145145PageChunkIterator . AT_END = "__PageChunkIterator.AT_END__" ;
146146
147147/** @type {PageChunkIteratorOptions } */
148148const DEFAULT_OPTS = {
149- server : null ,
150- bookPath : null ,
149+ pageChunkUrl : null ,
151150 pageBufferSize : 2 ,
152151} ;
153152
154153/**
155154 * @typedef {Object } PageChunkIteratorOptions
156- * @property {string } server
157- * @property {string } bookPath
155+ * @property {import('@/src/util/strings.js').StringWithVars } pageChunkUrl
158156 * @property {number } [pageBufferSize] number of pages to buffer before/after the current page
159157 */
You can’t perform that action at this time.
0 commit comments