@internetarchive/bookreader 5.0.0-51 → 5.0.0-52-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/CHANGELOG.md +3 -2
- package/package.json +1 -1
- package/src/BookReader.js +6 -0
- package/src/plugins/tts/WebTTSEngine.js +21 -2
- package/tests/jest/plugins/tts/WebTTSEngine.test.js +47 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# 5.0.0-52
|
1
2
|
# 5.0.0-51
|
2
|
-
- Fix: Bookmark with subfiles was broken
|
3
|
-
- Feature: Default 1up mode and options.defaults mode override exiting mode
|
3
|
+
- Fix: Bookmark with subfiles was broken @nsharma123
|
4
|
+
- Feature: Default 1up mode and options.defaults mode override exiting mode @nsharma123
|
4
5
|
|
5
6
|
# 5.0.0-50
|
6
7
|
Fix: Search results display @latonv
|
package/package.json
CHANGED
package/src/BookReader.js
CHANGED
@@ -1367,6 +1367,7 @@ BookReader.prototype.scrollDown = function() {
|
|
1367
1367
|
if ($.inArray(this.mode, [this.constMode1up, this.constModeThumb]) >= 0) {
|
1368
1368
|
if ( this.mode == this.constMode1up && (this.reduce >= this.onePageGetAutofitHeight()) ) {
|
1369
1369
|
// Whole pages are visible, scroll whole page only
|
1370
|
+
this.trigger('pageChanged');
|
1370
1371
|
return this.next();
|
1371
1372
|
}
|
1372
1373
|
|
@@ -1387,6 +1388,7 @@ BookReader.prototype.scrollUp = function() {
|
|
1387
1388
|
if ($.inArray(this.mode, [this.constMode1up, this.constModeThumb]) >= 0) {
|
1388
1389
|
if ( this.mode == this.constMode1up && (this.reduce >= this.onePageGetAutofitHeight()) ) {
|
1389
1390
|
// Whole pages are visible, scroll whole page only
|
1391
|
+
this.trigger('pageChanged');
|
1390
1392
|
return this.prev();
|
1391
1393
|
}
|
1392
1394
|
|
@@ -1636,6 +1638,10 @@ BookReader.prototype.bindNavigationHandlers = function() {
|
|
1636
1638
|
);
|
1637
1639
|
|
1638
1640
|
this.bindMozTouchHandlers();
|
1641
|
+
|
1642
|
+
$(document).on('BookReader:pageChanged', () => {
|
1643
|
+
console.log('here');
|
1644
|
+
})
|
1639
1645
|
};
|
1640
1646
|
|
1641
1647
|
/**
|
@@ -71,7 +71,22 @@ export default class WebTTSEngine extends AbstractTTSEngine {
|
|
71
71
|
}
|
72
72
|
|
73
73
|
/** @override */
|
74
|
-
getVoices() {
|
74
|
+
getVoices() {
|
75
|
+
const voices = speechSynthesis.getVoices();
|
76
|
+
if (voices.filter(v => v.default).length != 1) {
|
77
|
+
// iOS bug where the default system voice is sometimes
|
78
|
+
// missing from the list
|
79
|
+
voices.unshift({
|
80
|
+
voiceURI: 'bookreader.SystemDefault',
|
81
|
+
name: 'System Default',
|
82
|
+
// Not necessarily true, but very likely
|
83
|
+
lang: navigator.language,
|
84
|
+
default: true,
|
85
|
+
localService: true,
|
86
|
+
});
|
87
|
+
}
|
88
|
+
return voices;
|
89
|
+
}
|
75
90
|
|
76
91
|
/** @override */
|
77
92
|
createSound(chunk) {
|
@@ -122,7 +137,11 @@ export class WebTTSSound {
|
|
122
137
|
this.started = false;
|
123
138
|
|
124
139
|
this.utterance = new SpeechSynthesisUtterance(this.text.slice(this._charIndex));
|
125
|
-
|
140
|
+
// iOS bug where the default system voice is sometimes
|
141
|
+
// missing from the list
|
142
|
+
if (this.voice?.voiceURI !== 'bookreader.SystemDefault') {
|
143
|
+
this.utterance.voice = this.voice;
|
144
|
+
}
|
126
145
|
// Need to also set lang (for some reason); won't set voice on Chrome@Android otherwise
|
127
146
|
if (this.voice) this.utterance.lang = this.voice.lang;
|
128
147
|
this.utterance.rate = this.rate;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
|
-
import { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js';
|
2
|
+
import WebTTSEngine, { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js';
|
3
3
|
import { afterEventLoop, eventTargetMixin } from '../../utils.js';
|
4
4
|
|
5
5
|
beforeEach(() => {
|
@@ -8,6 +8,7 @@ beforeEach(() => {
|
|
8
8
|
speak: sinon.stub(),
|
9
9
|
pause: sinon.stub(),
|
10
10
|
resume: sinon.stub(),
|
11
|
+
|
11
12
|
...eventTargetMixin(),
|
12
13
|
};
|
13
14
|
window.SpeechSynthesisUtterance = function (text) {
|
@@ -21,6 +22,51 @@ afterEach(() => {
|
|
21
22
|
delete window.SpeechSynthesisUtterance;
|
22
23
|
});
|
23
24
|
|
25
|
+
describe('WebTTSEngine', () => {
|
26
|
+
test('getVoices should include default voice when no actual default', () => {
|
27
|
+
// iOS devices set all the voices to default -_-
|
28
|
+
speechSynthesis.getVoices = () => [
|
29
|
+
{
|
30
|
+
default: true,
|
31
|
+
lang: "ar-001",
|
32
|
+
localService: true,
|
33
|
+
name: "Majed",
|
34
|
+
voiceURI: "com.apple.voice.compact.ar-001.Maged",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
default: true,
|
38
|
+
lang: "bg-BG",
|
39
|
+
localService: true,
|
40
|
+
name: "Daria",
|
41
|
+
voiceURI: "com.apple.voice.compact.bg-BG.Daria",
|
42
|
+
}
|
43
|
+
];
|
44
|
+
const voices = WebTTSEngine.prototype.getVoices();
|
45
|
+
expect(voices.length).toBe(3);
|
46
|
+
expect(voices[0].voiceURI).toBe('bookreader.SystemDefault');
|
47
|
+
});
|
48
|
+
|
49
|
+
test('getVoices should not include default voice when there is a default', () => {
|
50
|
+
speechSynthesis.getVoices = () => [
|
51
|
+
{
|
52
|
+
default: true,
|
53
|
+
lang: "ar-001",
|
54
|
+
localService: true,
|
55
|
+
name: "Majed",
|
56
|
+
voiceURI: "com.apple.voice.compact.ar-001.Maged",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
default: false,
|
60
|
+
lang: "bg-BG",
|
61
|
+
localService: true,
|
62
|
+
name: "Daria",
|
63
|
+
voiceURI: "com.apple.voice.compact.bg-BG.Daria",
|
64
|
+
}
|
65
|
+
];
|
66
|
+
const voices = WebTTSEngine.prototype.getVoices();
|
67
|
+
expect(voices.length).toBe(2);
|
68
|
+
});
|
69
|
+
});
|
24
70
|
|
25
71
|
describe('WebTTSSound', () => {
|
26
72
|
describe('setPlaybackRate', () => {
|