@internetarchive/bookreader 5.0.0-47 → 5.0.0-48-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/ia-bookreader-bundle.js +89 -89
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/package.json +5 -5
- package/src/BookNavigator/downloads/downloads-provider.js +9 -41
- package/src/BookNavigator/downloads/downloads.js +83 -47
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-48-alpha1",
|
4
4
|
"description": "The Internet Archive BookReader.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -47,11 +47,11 @@
|
|
47
47
|
"@babel/plugin-proposal-decorators": "7.17.9",
|
48
48
|
"@babel/preset-env": "7.16.11",
|
49
49
|
"@open-wc/testing-helpers": "^2.1.3",
|
50
|
-
"@types/jest": "^29.
|
50
|
+
"@types/jest": "^29.1.1",
|
51
51
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
52
52
|
"babel-loader": "8.2.5",
|
53
53
|
"codecov": "^3.8.3",
|
54
|
-
"concurrently": "7.
|
54
|
+
"concurrently": "7.4.0",
|
55
55
|
"core-js": "3.22.3",
|
56
56
|
"cpx2": "4.2.0",
|
57
57
|
"eslint": "^7.32.0",
|
@@ -60,8 +60,8 @@
|
|
60
60
|
"hammerjs": "^2.0.8",
|
61
61
|
"http-server": "14.1.1",
|
62
62
|
"iso-language-codes": "1.1.0",
|
63
|
-
"jest": "^29.
|
64
|
-
"jest-environment-jsdom": "^29.
|
63
|
+
"jest": "^29.1.2",
|
64
|
+
"jest-environment-jsdom": "^29.1.2",
|
65
65
|
"jquery": "3.6.1",
|
66
66
|
"jquery-colorbox": "1.6.4",
|
67
67
|
"jquery-ui": "1.12.1",
|
@@ -2,41 +2,11 @@ import { html } from 'lit';
|
|
2
2
|
import '@internetarchive/icon-dl/icon-dl';
|
3
3
|
import './downloads';
|
4
4
|
|
5
|
-
const menuBase = {
|
6
|
-
pdf: {
|
7
|
-
type: 'Encrypted Adobe PDF',
|
8
|
-
url: '#',
|
9
|
-
note: 'PDF files contain high quality images of pages.',
|
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
|
-
},
|
21
|
-
epub: {
|
22
|
-
type: 'Encrypted Adobe ePub',
|
23
|
-
url: '#',
|
24
|
-
note: 'ePub files are smaller in size, but may contain errors.',
|
25
|
-
},
|
26
|
-
};
|
27
|
-
|
28
|
-
const publicMenuBase = {
|
29
|
-
pdf: "PDF",
|
30
|
-
epub: "ePub",
|
31
|
-
lcppdf: "LCP PDF",
|
32
|
-
lcpepub: "LCP ePub",
|
33
|
-
};
|
34
|
-
|
35
5
|
export default class DownloadsProvider {
|
36
6
|
|
37
7
|
constructor({ bookreader }) {
|
38
8
|
this.icon = html`<ia-icon-dl style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-dl>`;
|
39
|
-
this.label = '
|
9
|
+
this.label = 'Read offline';
|
40
10
|
this.menuDetails = '';
|
41
11
|
this.downloads = [];
|
42
12
|
this.id = 'downloads';
|
@@ -54,23 +24,21 @@ export default class DownloadsProvider {
|
|
54
24
|
}
|
55
25
|
|
56
26
|
/**
|
57
|
-
*
|
58
|
-
*
|
27
|
+
* Restructures available download type data for the renderer
|
28
|
+
* Sets global `downloads`
|
59
29
|
* @param availableTypes
|
60
30
|
*/
|
61
31
|
computeAvailableTypes(availableTypes = []) {
|
62
32
|
const menuData = availableTypes.reduce((found, incoming = []) => {
|
63
33
|
const [ type = '', link = '' ] = incoming;
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
const menuButtonText = this.isBookProtected ? menuBase[formattedType].type : publicMenuBase[formattedType];
|
69
|
-
const menuInfo = Object.assign({}, downloadOption, { url: link, type: menuButtonText});
|
70
|
-
found.push(menuInfo);
|
34
|
+
if (!type) return found;
|
35
|
+
let formattedType = type.toLowerCase();
|
36
|
+
if ((formattedType === 'pdf' || formattedType === 'epub') && this.isBookProtected) {
|
37
|
+
formattedType = `adobe${formattedType}`;
|
71
38
|
}
|
39
|
+
found[formattedType] = link;
|
72
40
|
return found;
|
73
|
-
},
|
41
|
+
}, {});
|
74
42
|
|
75
43
|
this.downloads = menuData;
|
76
44
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { css, html, LitElement, nothing } from 'lit';
|
2
2
|
import buttonStyles from '../assets/button-base.js';
|
3
|
+
|
3
4
|
export class IABookDownloads extends LitElement {
|
4
5
|
static get properties() {
|
5
6
|
return {
|
@@ -18,6 +19,26 @@ export class IABookDownloads extends LitElement {
|
|
18
19
|
this.isBookProtected = false;
|
19
20
|
}
|
20
21
|
|
22
|
+
render() {
|
23
|
+
return html`
|
24
|
+
${this.header}
|
25
|
+
${this.loanExpiryMessage}
|
26
|
+
${this.renderDownloadOptions()}
|
27
|
+
`;
|
28
|
+
}
|
29
|
+
|
30
|
+
get header() {
|
31
|
+
if (!this.renderHeader) {
|
32
|
+
return nothing;
|
33
|
+
}
|
34
|
+
return html`
|
35
|
+
<header>
|
36
|
+
<h3>Read offline</h3>
|
37
|
+
${this.formatsCount}
|
38
|
+
</header>
|
39
|
+
`;
|
40
|
+
}
|
41
|
+
|
21
42
|
get formatsCount() {
|
22
43
|
const count = this.downloads.length;
|
23
44
|
return count ? html`<p>${count} format${count > 1 ? 's' : ''}</p>` : html``;
|
@@ -30,65 +51,80 @@ export class IABookDownloads extends LitElement {
|
|
30
51
|
}
|
31
52
|
|
32
53
|
renderDownloadOptions() {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
`
|
40
|
-
));
|
41
|
-
}
|
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
|
-
|
53
|
-
get header() {
|
54
|
-
if (!this.renderHeader) {
|
55
|
-
return nothing;
|
56
|
-
}
|
54
|
+
const downloadOptions = [];
|
55
|
+
['pdf', 'epub', 'lcppdf', 'lcpepub', 'adobepdf', 'adobeepub'].forEach(format => {
|
56
|
+
if (this.downloads[format]) {
|
57
|
+
downloadOptions.push(this.downloadOption(format, this.downloads[format]));
|
58
|
+
}
|
59
|
+
});
|
57
60
|
return html`
|
58
|
-
<
|
59
|
-
|
60
|
-
|
61
|
-
</header>
|
61
|
+
<ul>
|
62
|
+
${downloadOptions}
|
63
|
+
</ul>
|
62
64
|
`;
|
63
65
|
}
|
64
66
|
|
65
|
-
|
67
|
+
downloadOption(format, link) {
|
68
|
+
if (/^adobe/.test(format)) {
|
69
|
+
return html`
|
70
|
+
<li>
|
71
|
+
<a
|
72
|
+
href="${link}"
|
73
|
+
data-event-click-tracking="BookReader|Download-${format}"
|
74
|
+
>${this.menuText[format].linkText}</a>
|
75
|
+
${this.menuText[format].message ?? nothing}
|
76
|
+
</li>
|
77
|
+
`;
|
78
|
+
}
|
66
79
|
return html`
|
67
|
-
<
|
68
|
-
|
80
|
+
<li>
|
81
|
+
<a class="ia-button link primary"
|
82
|
+
href="${link}"
|
83
|
+
data-event-click-tracking="BookReader|Download-${format}"
|
84
|
+
>${this.menuText[format].linkText}</a>
|
85
|
+
${this.menuText[format].message ? html`<p>${this.menuText[format].message}</p>` : nothing}
|
86
|
+
</li>
|
69
87
|
`;
|
70
88
|
}
|
71
89
|
|
72
|
-
get
|
90
|
+
get menuText() {
|
91
|
+
return {
|
92
|
+
pdf: {
|
93
|
+
linkText: 'Get high-resolution PDF',
|
94
|
+
message: html``,
|
95
|
+
},
|
96
|
+
epub: {
|
97
|
+
linkText: 'Get text-based ebook',
|
98
|
+
message: html`Smaller size. May contain some errors.`,
|
99
|
+
},
|
100
|
+
lcppdf: {
|
101
|
+
linkText: 'Get high-resolution PDF',
|
102
|
+
message: this.lcpNote,
|
103
|
+
},
|
104
|
+
lcpepub: {
|
105
|
+
linkText: 'Get text-based ebook',
|
106
|
+
message: html`Smaller size. May contain some errors. ${this.lcpNote}`,
|
107
|
+
},
|
108
|
+
adobepdf: {
|
109
|
+
linkText:'Get legacy Adobe DRM PDF version here.',
|
110
|
+
message: this.adobeNote,
|
111
|
+
},
|
112
|
+
adobeepub: {
|
113
|
+
linkText: 'Get legacy Adobe DRM EPUB version here.',
|
114
|
+
message: this.adobeNote,
|
115
|
+
},
|
116
|
+
};
|
117
|
+
};
|
118
|
+
|
119
|
+
get lcpNote() {
|
73
120
|
return html`
|
74
|
-
|
75
|
-
|
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
|
-
`;
|
121
|
+
Requires having an LCP-compatible e-reader installed like Aldiko Next (<a href="https://apps.apple.com/us/app/aldiko-next/id1476410111">iOS</a>, <a href="https://play.google.com/store/apps/details?id=com.aldiko.android">Android</a>) or <a href="https://www.edrlab.org/software/thorium-reader/">Thorium</a>.
|
122
|
+
`;
|
81
123
|
}
|
82
124
|
|
83
|
-
|
125
|
+
get adobeNote() {
|
84
126
|
return html`
|
85
|
-
|
86
|
-
${this.loanExpiryMessage}
|
87
|
-
<ul>${this.renderDownloadOptions()}</ul>
|
88
|
-
${this.hasLCPOption
|
89
|
-
? this.installSimplyEAldikoThoriumMsg
|
90
|
-
: (this.isBookProtected ? this.accessProtectedBook : nothing)
|
91
|
-
}
|
127
|
+
Requires a compatible e-reader like <a hef="https://www.adobe.com/solutions/ebook/digital-editions.html">Adobe Digital Editions</a>.
|
92
128
|
`;
|
93
129
|
}
|
94
130
|
|