@internetarchive/bookreader 5.0.0-43 → 5.0.0-44-a3
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.css +1 -2
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +36 -36
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReaderDemo/IADemoBr.js +22 -0
- package/BookReaderDemo/demo-internetarchive.html +3 -0
- package/babel.config.js +1 -1
- package/package.json +15 -21
- package/renovate.json +7 -4
- package/src/BookNavigator/book-navigator.js +4 -0
- package/src/BookNavigator/downloads/downloads-provider.js +14 -5
- package/src/BookNavigator/downloads/downloads.js +25 -1
- package/src/BookNavigator/search/search-provider.js +1 -0
- package/src/BookNavigator/search/search-results.js +4 -0
- package/src/css/_controls.scss +1 -2
- package/src/plugins/search/plugin.search.js +8 -0
- package/src/plugins/tts/plugin.tts.js +15 -3
- package/tests/{karma → jest}/BookNavigator/book-navigator.test.js +119 -104
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-button.test.js +13 -14
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/{karma → jest}/BookNavigator/downloads/downloads-provider.test.js +18 -18
- package/tests/{karma → jest}/BookNavigator/downloads/downloads.test.js +7 -8
- package/tests/{karma → jest}/BookNavigator/sharing/sharing-provider.test.js +8 -8
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/{karma → jest}/BookNavigator/volumes/volumes-provider.test.js +38 -38
- package/tests/{karma → jest}/BookNavigator/volumes/volumes.test.js +15 -16
- package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +3 -3
- package/karma.conf.js +0 -23
- package/tests/karma/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -57
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
@@ -14,6 +14,17 @@ const searchTerm = urlParams.get('q');
|
|
14
14
|
|
15
15
|
const iaBookReader = document.querySelector('ia-bookreader');
|
16
16
|
|
17
|
+
const downloadListWithLCP = [
|
18
|
+
[
|
19
|
+
"lcpPDF",
|
20
|
+
"link to lcp pdf"
|
21
|
+
],
|
22
|
+
[
|
23
|
+
"lcpEPUB",
|
24
|
+
"link to lcp epub"
|
25
|
+
]
|
26
|
+
];
|
27
|
+
|
17
28
|
if (openFullImmersionTheater) {
|
18
29
|
$(document.body).addClass('BRfullscreenActive');
|
19
30
|
iaBookReader.fullscreen = openFullImmersionTheater;
|
@@ -78,6 +89,17 @@ const initializeBookReader = (brManifest) => {
|
|
78
89
|
|
79
90
|
window.initializeBookReader = initializeBookReader;
|
80
91
|
|
92
|
+
const showLCP = document.querySelector('#show-lcp');
|
93
|
+
showLCP.addEventListener('click', async () => {
|
94
|
+
const iaBr = document.querySelector('ia-bookreader');
|
95
|
+
const bookNav = iaBr.shadowRoot.querySelector('book-navigator');
|
96
|
+
|
97
|
+
bookNav.downloadableTypes = downloadListWithLCP;
|
98
|
+
|
99
|
+
bookNav.updateMenuContents();
|
100
|
+
await bookNav.updateComplete;
|
101
|
+
});
|
102
|
+
|
81
103
|
const multiVolume = document.querySelector('#multi-volume');
|
82
104
|
multiVolume.addEventListener('click', () => {
|
83
105
|
// remove everything
|
@@ -77,6 +77,9 @@
|
|
77
77
|
<p>Features behind signed in gate: Bookmarks</p>
|
78
78
|
<p>Logged In Status: <span id="logged-in-status">Logged Out</span></p>
|
79
79
|
</div>
|
80
|
+
<div class="demo">
|
81
|
+
<button id="show-lcp">LCP Download option</button>
|
82
|
+
</div>
|
80
83
|
<div class="demo">
|
81
84
|
<button id="multi-volume">Multiple books</button>
|
82
85
|
</div>
|
package/babel.config.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@internetarchive/bookreader",
|
3
|
-
"version": "5.0.0-
|
3
|
+
"version": "5.0.0-44-a3",
|
4
4
|
"description": "The Internet Archive BookReader.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -46,38 +46,36 @@
|
|
46
46
|
"@babel/plugin-proposal-class-properties": "7.16.7",
|
47
47
|
"@babel/plugin-proposal-decorators": "7.17.9",
|
48
48
|
"@babel/preset-env": "7.16.11",
|
49
|
-
"@open-wc/testing": "^
|
50
|
-
"@
|
51
|
-
"@types/jest": "^27.4.1",
|
49
|
+
"@open-wc/testing-helpers": "^2.1.2",
|
50
|
+
"@types/jest": "^27.5.1",
|
52
51
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
53
52
|
"babel-loader": "8.2.5",
|
54
53
|
"codecov": "^3.8.3",
|
55
|
-
"concurrently": "7.
|
54
|
+
"concurrently": "7.2.2",
|
56
55
|
"core-js": "3.22.3",
|
57
56
|
"cpx2": "4.2.0",
|
58
57
|
"eslint": "^7.32.0",
|
59
58
|
"eslint-plugin-no-jquery": "^2.7.0",
|
60
59
|
"eslint-plugin-testcafe": "^0.2.1",
|
61
60
|
"hammerjs": "^2.0.8",
|
62
|
-
"http-server": "14.1.
|
61
|
+
"http-server": "14.1.1",
|
63
62
|
"iso-language-codes": "1.1.0",
|
64
|
-
"jest": "^28.0
|
65
|
-
"jest-environment-jsdom": "^28.0
|
63
|
+
"jest": "^28.1.0",
|
64
|
+
"jest-environment-jsdom": "^28.1.0",
|
66
65
|
"jquery": "1.12.4",
|
67
66
|
"jquery-colorbox": "1.6.4",
|
68
67
|
"jquery-ui": "1.12.1",
|
69
68
|
"jquery-ui-touch-punch": "0.2.3",
|
70
69
|
"jquery.browser": "0.1.0",
|
71
70
|
"jquery.mmenu": "5.6.5",
|
72
|
-
"karma-coverage": "^2.1.0",
|
73
71
|
"live-server": "1.2.2",
|
74
|
-
"node-fetch": "3.2.
|
72
|
+
"node-fetch": "3.2.10",
|
75
73
|
"regenerator-runtime": "0.13.9",
|
76
|
-
"sass": "1.
|
77
|
-
"sinon": "^
|
74
|
+
"sass": "1.52.1",
|
75
|
+
"sinon": "^14.0.0",
|
78
76
|
"soundmanager2": "2.97.20170602",
|
79
77
|
"svgo": "2.8.0",
|
80
|
-
"testcafe": "^1.
|
78
|
+
"testcafe": "^1.19.0",
|
81
79
|
"testcafe-browser-provider-browserstack": "^1.13.2-alpha.1",
|
82
80
|
"webpack": "5.51.1",
|
83
81
|
"webpack-cli": "4.9.2"
|
@@ -96,8 +94,7 @@
|
|
96
94
|
"roots": [
|
97
95
|
"<rootDir>/src/",
|
98
96
|
"<rootDir>/tests/jest/"
|
99
|
-
]
|
100
|
-
"coverageDirectory": "<rootDir>/coverage-jest"
|
97
|
+
]
|
101
98
|
},
|
102
99
|
"scripts": {
|
103
100
|
"preversion": "npm run test && node scripts/preversion.js",
|
@@ -116,15 +113,12 @@
|
|
116
113
|
"serve": "npx http-server . --port 8000",
|
117
114
|
"serve-live": "npx live-server . --port 8000 --watch=index.html,BookReader,BookReaderDemo",
|
118
115
|
"serve-dev": "npm run build-css && npx concurrently --kill-others npm:serve-live npm:build-*:watch",
|
119
|
-
"test": "npx
|
116
|
+
"test": "npx jest --coverage --colors",
|
117
|
+
"test:watch": "npx jest --watch",
|
120
118
|
"test:e2e": "npm run build && npx testcafe",
|
121
119
|
"test:e2e:dev": "npx testcafe --live --dev",
|
122
|
-
"test-jest:watch": "npx jest --watch",
|
123
|
-
"test-jest": "npx jest --coverage --colors",
|
124
|
-
"test-karma": "npx karma start --coverage",
|
125
|
-
"test-karma:watch": "npx karma start --auto-watch=true --single-run=false",
|
126
120
|
"DOCS:update:test-deps": "If CI succeeds, these should be good to update",
|
127
|
-
"update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing
|
121
|
+
"update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing-helpers@latest @types/jest@latest codecov@latest eslint@latest eslint-plugin-testcafe@latest jest@latest sinon@latest testcafe@latest",
|
128
122
|
"DOCS:update:build-deps": "These can cause strange changes, so do an npm run build + check file size (git diff --stat), and check the site is as expected",
|
129
123
|
"update:build-deps": "npm i @babel/core@latest @babel/preset-env@latest babel-loader@latest core-js@latest regenerator-runtime@latest sass@latest svgo@latest webpack@latest webpack-cli@latest",
|
130
124
|
"codecov": "npx codecov"
|
package/renovate.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"extends": [
|
3
|
-
"config:base"
|
3
|
+
"config:base",
|
4
|
+
"schedule:monthly"
|
4
5
|
],
|
5
6
|
"packageRules": [
|
6
7
|
{
|
7
8
|
"matchPackageNames": [
|
8
9
|
"@babel/eslint-parser",
|
9
|
-
"@open-wc/testing",
|
10
|
-
"@open-wc/testing-karma",
|
10
|
+
"@open-wc/testing-helpers",
|
11
11
|
"@types/jest",
|
12
12
|
"codecov",
|
13
13
|
"eslint",
|
@@ -15,7 +15,6 @@
|
|
15
15
|
"eslint-plugin-testcafe",
|
16
16
|
"jest",
|
17
17
|
"jest-environment-jsdom",
|
18
|
-
"karma-coverage",
|
19
18
|
"sinon",
|
20
19
|
"testcafe"
|
21
20
|
],
|
@@ -44,6 +43,10 @@
|
|
44
43
|
"matchPackagePatterns": ["^actions/"],
|
45
44
|
"groupName": "GitHub Actions",
|
46
45
|
"automerge": true
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"matchPackagePatterns": ["^@internetarchive"],
|
49
|
+
"schedule": ["at any time"]
|
47
50
|
}
|
48
51
|
]
|
49
52
|
}
|
@@ -8,16 +8,28 @@ const menuBase = {
|
|
8
8
|
url: '#',
|
9
9
|
note: 'PDF files contain high quality images of pages.',
|
10
10
|
},
|
11
|
+
lcppdf: {
|
12
|
+
type: 'Get LCP PDF',
|
13
|
+
url: '#',
|
14
|
+
note: 'PDF files contain high quality images of pages.',
|
15
|
+
},
|
16
|
+
lcpepub: {
|
17
|
+
type: 'Get LCP ePub',
|
18
|
+
url: '#',
|
19
|
+
note: 'ePub files are smaller in size, but may contain errors.',
|
20
|
+
},
|
11
21
|
epub: {
|
12
22
|
type: 'Encrypted Adobe ePub',
|
13
23
|
url: '#',
|
14
24
|
note: 'ePub files are smaller in size, but may contain errors.',
|
15
|
-
}
|
25
|
+
},
|
16
26
|
};
|
17
27
|
|
18
28
|
const publicMenuBase = {
|
19
29
|
pdf: "PDF",
|
20
|
-
epub: "ePub"
|
30
|
+
epub: "ePub",
|
31
|
+
lcppdf: "LCP PDF",
|
32
|
+
lcpepub: "LCP ePub",
|
21
33
|
};
|
22
34
|
|
23
35
|
export default class DownloadsProvider {
|
@@ -30,9 +42,6 @@ export default class DownloadsProvider {
|
|
30
42
|
this.id = 'downloads';
|
31
43
|
this.component = '';
|
32
44
|
this.isBookProtected = bookreader?.options?.isProtected || false;
|
33
|
-
|
34
|
-
this.computeAvailableTypes = this.computeAvailableTypes.bind(this);
|
35
|
-
this.update = this.update.bind(this);
|
36
45
|
}
|
37
46
|
|
38
47
|
update(downloadTypes) {
|
@@ -40,6 +40,16 @@ export class IABookDownloads extends LitElement {
|
|
40
40
|
));
|
41
41
|
}
|
42
42
|
|
43
|
+
/**
|
44
|
+
* checks if downloads list contains an LCP option
|
45
|
+
* @return {boolean}
|
46
|
+
*/
|
47
|
+
get hasLCPOption() {
|
48
|
+
const regex = /^(LCP)/g;
|
49
|
+
const lcpAvailable = this.downloads.some(option => option.type?.match(regex));
|
50
|
+
return lcpAvailable;
|
51
|
+
}
|
52
|
+
|
43
53
|
get header() {
|
44
54
|
if (!this.renderHeader) {
|
45
55
|
return nothing;
|
@@ -59,12 +69,26 @@ export class IABookDownloads extends LitElement {
|
|
59
69
|
`;
|
60
70
|
}
|
61
71
|
|
72
|
+
get installSimplyEAldikoThoriumMsg() {
|
73
|
+
return html`
|
74
|
+
<p>For LCP downloads, make sure you have SimplyE or Aldiko Next installed on mobile or Thorium on desktop.</p>
|
75
|
+
<ul>
|
76
|
+
<li><a href="https://librarysimplified.org/simplye/" rel="noopener noreferrer nofollow" target="_blank">Install SimplyE</a></li>
|
77
|
+
<li><a href="https://www.demarque.com/en-aldiko" rel="noopener noreferrer nofollow" target="_blank">Install Aldiko</a></li>
|
78
|
+
<li><a href="https://www.edrlab.org/software/thorium-reader/" rel="noopener noreferrer nofollow" target="_blank">Install Thorium</a></li>
|
79
|
+
</ul>
|
80
|
+
`;
|
81
|
+
}
|
82
|
+
|
62
83
|
render() {
|
63
84
|
return html`
|
64
85
|
${this.header}
|
65
86
|
${this.loanExpiryMessage}
|
66
87
|
<ul>${this.renderDownloadOptions()}</ul>
|
67
|
-
${this.
|
88
|
+
${this.hasLCPOption
|
89
|
+
? this.installSimplyEAldikoThoriumMsg
|
90
|
+
: (this.isBookProtected ? this.accessProtectedBook : nothing)
|
91
|
+
}
|
68
92
|
`;
|
69
93
|
}
|
70
94
|
|
@@ -60,6 +60,9 @@ export class IABookSearchResults extends LitElement {
|
|
60
60
|
|
61
61
|
setQuery(e) {
|
62
62
|
this.query = e.currentTarget.value;
|
63
|
+
if (!this.query) {
|
64
|
+
this.cancelSearch();
|
65
|
+
}
|
63
66
|
}
|
64
67
|
|
65
68
|
performSearch(e) {
|
@@ -148,6 +151,7 @@ export class IABookSearchResults extends LitElement {
|
|
148
151
|
name="query"
|
149
152
|
alt="Search inside this book."
|
150
153
|
@keyup=${this.setQuery}
|
154
|
+
@search=${this.setQuery}
|
151
155
|
.value=${this.query}
|
152
156
|
/>
|
153
157
|
</fieldset>
|
package/src/css/_controls.scss
CHANGED
@@ -34,12 +34,11 @@
|
|
34
34
|
-webkit-appearance: none;
|
35
35
|
appearance: none;
|
36
36
|
font-size: 10px;
|
37
|
-
text-align: center;
|
38
37
|
text-align-last: center;
|
39
38
|
color: $controlsText;
|
40
39
|
border: none;
|
41
40
|
cursor: pointer;
|
42
|
-
option {
|
41
|
+
option, optgroup {
|
43
42
|
background: $controlsBG;
|
44
43
|
}
|
45
44
|
}
|
@@ -217,6 +217,12 @@ BookReader.prototype.search = async function(term = '', overrides = {}) {
|
|
217
217
|
cache: true,
|
218
218
|
beforeSend: xhr => { this.searchXHR = xhr; },
|
219
219
|
}));
|
220
|
+
|
221
|
+
if (!this.searchTerm) {
|
222
|
+
this.bookreader?.urlPlugin?.removeUrlParam('q');
|
223
|
+
} else {
|
224
|
+
this.bookreader?.urlPlugin?.setUrlParam('q', this.searchTerm);
|
225
|
+
}
|
220
226
|
};
|
221
227
|
|
222
228
|
/**
|
@@ -230,6 +236,7 @@ BookReader.prototype._cancelSearch = function () {
|
|
230
236
|
this.searchXHR = null;
|
231
237
|
this.searchCancelled = true;
|
232
238
|
this.searchResults = [];
|
239
|
+
this.bookreader?.urlPlugin?.removeUrlParam('q');
|
233
240
|
};
|
234
241
|
|
235
242
|
/**
|
@@ -243,6 +250,7 @@ BookReader.prototype.cancelSearchRequest = function () {
|
|
243
250
|
this.searchView.toggleSearchPending();
|
244
251
|
this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });
|
245
252
|
}
|
253
|
+
this?.urlPlugin?.removeUrlParam('q');
|
246
254
|
};
|
247
255
|
|
248
256
|
/**
|
@@ -158,18 +158,30 @@ BookReader.prototype.initNavbar = (function (super_) {
|
|
158
158
|
|
159
159
|
$el.find('.BRcontrols').prepend(this.refs.$BRReadAloudToolbar);
|
160
160
|
|
161
|
+
const renderVoiceOption = (voices) => {
|
162
|
+
return voices.map(voice =>
|
163
|
+
`<option value="${voice.voiceURI}">${voice.lang} - ${voice.name}</option>`).join('');
|
164
|
+
};
|
165
|
+
|
166
|
+
const voiceSortOrder = (a,b) => `${a.lang} - ${a.name}`.localeCompare(`${b.lang} - ${b.name}`);
|
167
|
+
|
161
168
|
const renderVoicesMenu = (voicesMenu) => {
|
162
169
|
voicesMenu.empty();
|
170
|
+
const bookLanguage = this.ttsEngine.opts.bookLanguage;
|
171
|
+
const bookLanguages = this.ttsEngine.getVoices().filter(v => v.lang.startsWith(bookLanguage)).sort(voiceSortOrder);
|
172
|
+
const otherLanguages = this.ttsEngine.getVoices().filter(v => !v.lang.startsWith(bookLanguage)).sort(voiceSortOrder);
|
173
|
+
|
163
174
|
if (this.ttsEngine.getVoices().length > 1) {
|
164
|
-
voicesMenu.append(
|
165
|
-
|
166
|
-
|
175
|
+
voicesMenu.append($(`<optgroup label="Book Language (${bookLanguage})"> ${renderVoiceOption(bookLanguages)} </optgroup>`));
|
176
|
+
voicesMenu.append($(`<optgroup label="Other Languages"> ${renderVoiceOption(otherLanguages)} </optgroup>`));
|
177
|
+
|
167
178
|
voicesMenu.val(this.ttsEngine.voice.voiceURI);
|
168
179
|
voicesMenu.show();
|
169
180
|
} else {
|
170
181
|
voicesMenu.hide();
|
171
182
|
}
|
172
183
|
};
|
184
|
+
|
173
185
|
const voicesMenu = this.refs.$BRReadAloudToolbar.find('[name=playback-voice]');
|
174
186
|
renderVoicesMenu(voicesMenu);
|
175
187
|
voicesMenu.on("change", ev => this.ttsEngine.setVoice(voicesMenu.val()));
|