@internetarchive/bookreader 5.0.0-70 → 5.0.0-70-a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/BookReader/BookReader.js +1 -1
  2. package/BookReader/BookReader.js.map +1 -1
  3. package/BookReader/ia-bookreader-bundle.js +572 -293
  4. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  5. package/BookReader/plugins/plugin.chapters.js +2 -2
  6. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  7. package/BookReader/plugins/plugin.tts.js +1 -1
  8. package/BookReader/plugins/plugin.tts.js.map +1 -1
  9. package/BookReader/plugins/plugin.url.js +1 -1
  10. package/BookReader/plugins/plugin.url.js.map +1 -1
  11. package/CHANGELOG.md +0 -4
  12. package/package.json +2 -4
  13. package/src/BookNavigator/sharing.js +5 -5
  14. package/src/BookNavigator/volumes/volumes-provider.js +37 -53
  15. package/src/BookReader.js +5 -4
  16. package/src/ia-bookreader/ia-bookreader.js +5 -5
  17. package/src/plugins/tts/AbstractTTSEngine.js +3 -22
  18. package/src/plugins/url/UrlPlugin.js +7 -5
  19. package/tests/e2e/models/Navigation.js +1 -1
  20. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +1 -1
  21. package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +15 -119
  22. package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +0 -20
  23. package/tests/jest/plugins/url/UrlPlugin.test.js +0 -8
  24. package/src/BookNavigator/assets/icon_sort_asc.js +0 -5
  25. package/src/BookNavigator/assets/icon_sort_desc.js +0 -5
  26. package/src/BookNavigator/assets/icon_sort_neutral.js +0 -5
  27. package/src/BookNavigator/assets/icon_volumes.js +0 -11
  28. package/src/BookNavigator/volumes/volumes.js +0 -188
  29. package/tests/jest/BookNavigator/volumes/volumes.test.js +0 -97
@@ -1,188 +0,0 @@
1
- import { css, html, LitElement, nothing } from 'lit';
2
- import { repeat } from 'lit/directives/repeat.js';
3
-
4
- export class Volumes extends LitElement {
5
- static get properties() {
6
- return {
7
- subPrefix: { type: String },
8
- hostUrl: { type: String },
9
- viewableFiles: { type: Array },
10
- sortOrderBy: { type: String },
11
- };
12
- }
13
-
14
- constructor() {
15
- super();
16
- this.hostUrl = '';
17
- this.sortOrderBy = '';
18
- this.subPrefix = '';
19
- this.viewableFiles = [];
20
- }
21
-
22
- firstUpdated() {
23
- const activeFile = this.shadowRoot.querySelector('.content.active');
24
- // allow for css animations to run before scrolling to active file
25
- setTimeout(() => {
26
- // scroll active file into view if needed
27
- // note: `scrollIntoViewIfNeeded` handles auto-scroll gracefully for Chrome, Safari
28
- // Firefox does not have this capability yet as it does not support `scrollIntoViewIfNeeded`
29
- if (activeFile?.scrollIntoViewIfNeeded) {
30
- activeFile?.scrollIntoViewIfNeeded(true);
31
- return;
32
- }
33
-
34
- // Todo: support `scrollIntoView` or `parentContainer.crollTop = x` for FF & "IE 11"
35
- // currently, the hard `position: absolutes` misaligns subpanel when `scrollIntoView` is applied :(
36
- }, 350);
37
- }
38
-
39
- volumeItemWithImageTitle(item) {
40
- const hrefUrl = this.sortOrderBy === 'default'
41
- ? `${this.hostUrl}${item.url_path}`
42
- : `${this.hostUrl}${item.url_path}?sort=${this.sortOrderBy}`;
43
-
44
- return html`
45
- <li class="content active">
46
- <div class="separator"></div>
47
- <a class="container" href="${hrefUrl}">
48
- <div class="image">
49
- <img src="${item.image}">
50
- </div>
51
- <div class="text">
52
- <p class="item-title">${item.title}</p>
53
- <small>by: ${item.author}</small>
54
- </div>
55
- </a>
56
- </li>
57
- `;
58
- }
59
-
60
- volumeItem(item) {
61
- const activeClass = this.subPrefix === item.file_subprefix ? ' active' : '';
62
-
63
- const hrefUrl = this.sortOrderBy === 'default'
64
- ? `${this.hostUrl}${item.url_path}`
65
- : `${this.hostUrl}${item.url_path}?sort=${this.sortOrderBy}`;
66
-
67
- return html`
68
- <li>
69
- <div class="separator"></div>
70
- <div class="content${activeClass}">
71
- <a href="https://${hrefUrl}">
72
- <p class="item-title">${item.title}</p>
73
- </a>
74
- </div>
75
- </li>
76
- `;
77
- }
78
-
79
- get volumesList() {
80
- const volumes = repeat(this.viewableFiles, volume => volume?.file_prefix, this.volumeItem.bind(this));
81
- return html`
82
- <ul>
83
- ${volumes}
84
- <div class="separator"></div>
85
- </ul>
86
- `;
87
- }
88
-
89
- render() {
90
- return html`
91
- ${this.viewableFiles.length ? this.volumesList : nothing}
92
- `;
93
- }
94
-
95
- static get styles() {
96
- return css`
97
- :host {
98
- display: block;
99
- overflow-y: auto;
100
- box-sizing: border-box;
101
- color: var(--primaryTextColor);
102
- margin-top: 14px;
103
- margin-bottom: 2rem;
104
- --activeBorderWidth: 2px;
105
- }
106
-
107
- a {
108
- color: #ffffff;
109
- text-decoration: none
110
- }
111
-
112
- img {
113
- width: 35px;
114
- height: 45px;
115
- }
116
-
117
- ul {
118
- padding: 0;
119
- list-style: none;
120
- margin: var(--activeBorderWidth) 0.5rem 1rem 0;
121
- }
122
-
123
- ul > li:first-child .separator {
124
- display: none;
125
- }
126
-
127
- li {
128
- cursor: pointer;
129
- outline: none;
130
- position: relative;
131
- }
132
-
133
- li .content {
134
- padding: 2px 0 4px 2px;
135
- border: var(--activeBorderWidth) solid transparent;
136
- padding: .2rem 0 .4rem .2rem;
137
- }
138
-
139
- li .content.active {
140
- border: var(--activeBorderWidth) solid #538bc5;
141
- }
142
-
143
- small {
144
- font-style: italic;
145
- white-space: initial;
146
- }
147
-
148
- .container {
149
- display: flex;
150
- align-items: center;
151
- justify-content: center
152
- }
153
-
154
- .item-title {
155
- margin-block-start: 0em;
156
- margin-block-end: 0em;
157
- font-size: 14px;
158
- font-weight: bold;
159
- word-wrap: break-word;
160
- padding-left: 5px;
161
- }
162
-
163
- .separator {
164
- background-color: var(--secondaryBGColor);
165
- width: 98%;
166
- margin: 1px auto;
167
- height: 1px;
168
- }
169
-
170
- .text {
171
- padding-left: 10px;
172
- }
173
-
174
- .icon {
175
- display: inline-block;
176
- width: 14px;
177
- height: 14px;
178
- margin-left: .7rem;
179
- border: 1px solid var(--primaryTextColor);
180
- border-radius: 2px;
181
- background: var(--activeButtonBg) 50% 50% no-repeat;
182
- }
183
-
184
- `;
185
- }
186
- }
187
-
188
- customElements.define('viewable-files', Volumes);
@@ -1,97 +0,0 @@
1
- import {
2
- html,
3
- fixture,
4
- fixtureCleanup,
5
- } from '@open-wc/testing-helpers';
6
- import sinon from 'sinon';
7
- import '@/src/BookNavigator/volumes/volumes.js';
8
-
9
-
10
- const brOptions = {
11
- "options": {
12
- "enableMultipleBooks": true,
13
- "multipleBooksList": {
14
- "by_subprefix": {
15
- "/details/SubBookTest": {
16
- "url_path": "/details/SubBookTest",
17
- "file_subprefix": "book1/GPORFP",
18
- "orig_sort": 0,
19
- "title": "book1/GPORFP.pdf",
20
- "file_source": "/book1/GPORFP_jp2.zip"
21
- },
22
- "/details/SubBookTest/subdir/book2/brewster_kahle_internet_archive": {
23
- "url_path": "/details/SubBookTest/subdir/book2/brewster_kahle_internet_archive",
24
- "file_subprefix": "subdir/book2/brewster_kahle_internet_archive",
25
- "orig_sort": 1,
26
- "title": "subdir/book2/brewster_kahle_internet_archive.pdf",
27
- "file_source": "/subdir/book2/brewster_kahle_internet_archive_jp2.zip"
28
- },
29
- "/details/SubBookTest/subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume": {
30
- "url_path": "/details/SubBookTest/subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume",
31
- "file_subprefix": "subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume",
32
- "orig_sort": 2,
33
- "title": "subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume.pdf",
34
- "file_source": "/subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume_jp2.zip"
35
- }
36
- }
37
- }
38
- }
39
- };
40
-
41
- const container = (brOptions, prefix) => (
42
- html`
43
- <viewable-files .viewableFiles=${brOptions} .hostUrl="https://archive.org" .subPrefix=${prefix}></viewable-files>
44
- `
45
- );
46
-
47
- beforeEach(() => {
48
- const body = document.querySelector('body');
49
- const brHook = document.createElement('div');
50
- brHook.setAttribute('id', 'BookReader');
51
- body.appendChild(brHook);
52
- });
53
-
54
- afterEach(() => {
55
- sinon.restore();
56
- fixtureCleanup();
57
- });
58
-
59
- describe('<viewable-files>', () => {
60
- test('sets default properties', async () => {
61
- const files = brOptions.options.multipleBooksList?.by_subprefix;
62
- const viewableFiles = Object.keys(files).map(item => files[item]);
63
- const el = await fixture(container(viewableFiles));
64
- await el.updateComplete;
65
-
66
- expect(el.viewableFiles).toEqual(viewableFiles);
67
- expect(el.viewableFiles.length).toEqual(3);
68
- expect(el.shadowRoot.querySelectorAll("ul li").length).toEqual(3);
69
-
70
- expect(el.shadowRoot.querySelector(".item-title").textContent).toContain(`${viewableFiles[0].title}`);
71
- });
72
-
73
- test('render empty volumes', async () => {
74
- const viewableFiles = [];
75
- const el = await fixture(container(viewableFiles));
76
- await el.updateComplete;
77
-
78
- expect(el.viewableFiles).toEqual(viewableFiles);
79
- expect(el.viewableFiles.length).toEqual(0);
80
- expect(el.shadowRoot.childElementCount).not.toEqual(0);
81
- });
82
-
83
- test('render active volume item set as first viewable item ', async () => {
84
- const files = brOptions.options.multipleBooksList?.by_subprefix;
85
- const viewableFiles = Object.keys(files).map(item => files[item]);
86
- const prefix = viewableFiles[0].file_subprefix;
87
-
88
- const el = await fixture(container(viewableFiles, prefix));
89
- await el.updateComplete;
90
-
91
- expect(el.viewableFiles).toEqual(viewableFiles);
92
- expect(el.viewableFiles.length).toEqual(3);
93
-
94
- expect(el.shadowRoot.querySelectorAll("ul li div")[1].className).toEqual("content active");
95
- });
96
-
97
- });