@internetarchive/bookreader 5.0.0-56 → 5.0.0-58

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 5.0.0-58
2
+ - Fix BookReader sometimes failing to load when starting in Mode1Up @cdrini
3
+ - Update testing dependencies @cdrini
4
+
5
+ # 5.0.0-57
6
+ - Fix - do not show Download pane when there aren't any available @iisa
7
+
1
8
  # 5.0.0-56
2
9
  - Fix DOMException in sandboxed iframe in chrome @cdrini
3
10
 
package/babel.config.js CHANGED
@@ -2,8 +2,11 @@ module.exports = {
2
2
  presets: [
3
3
  [
4
4
  "@babel/preset-env",
5
- process.env.NODE_ENV == 'test' ? { targets: {esmodules: true} } : {
6
- targets: "> 2%, ie 11, edge 14, samsung > 9, OperaMini all, UCAndroid > 12, Safari >= 9",
5
+ {
6
+ targets: (
7
+ process.env.NODE_ENV == 'test' ? {node: process.version} :
8
+ "> 2%, ie 11, edge 14, samsung > 9, OperaMini all, UCAndroid > 12, Safari >= 9"
9
+ ),
7
10
  useBuiltIns: "usage",
8
11
  corejs: 3
9
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-56",
3
+ "version": "5.0.0-58",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,12 +42,12 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/core": "7.17.9",
45
- "@babel/eslint-parser": "7.17.0",
45
+ "@babel/eslint-parser": "7.21.3",
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-helpers": "^2.1.4",
50
- "@types/jest": "^29.4.0",
49
+ "@open-wc/testing-helpers": "^2.2.0",
50
+ "@types/jest": "^29.5.0",
51
51
  "@webcomponents/webcomponentsjs": "^2.6.0",
52
52
  "babel-loader": "8.2.5",
53
53
  "codecov": "^3.8.3",
@@ -60,7 +60,7 @@
60
60
  "hammerjs": "^2.0.8",
61
61
  "http-server": "14.1.1",
62
62
  "iso-language-codes": "1.1.0",
63
- "jest": "^29.4.3",
63
+ "jest": "29.5.0",
64
64
  "jest-environment-jsdom": "^29.4.3",
65
65
  "jquery": "3.6.1",
66
66
  "jquery-colorbox": "1.6.4",
@@ -72,10 +72,10 @@
72
72
  "node-fetch": "3.2.10",
73
73
  "regenerator-runtime": "0.13.9",
74
74
  "sass": "1.52.1",
75
- "sinon": "^15.0.1",
75
+ "sinon": "15.0.3",
76
76
  "soundmanager2": "2.97.20170602",
77
77
  "svgo": "2.8.0",
78
- "testcafe": "^2.0.1",
78
+ "testcafe": "2.4.0",
79
79
  "testcafe-browser-provider-browserstack": "^1.13.2-alpha.1",
80
80
  "webpack": "5.51.1",
81
81
  "webpack-cli": "4.9.2"
@@ -89,7 +89,8 @@
89
89
  "^@/(.*)$": "<rootDir>/$1"
90
90
  },
91
91
  "setupFiles": [
92
- "./src/jquery-wrapper.js"
92
+ "./src/jquery-wrapper.js",
93
+ "./tests/jest/setup.js"
93
94
  ],
94
95
  "roots": [
95
96
  "<rootDir>/src/",
@@ -118,7 +119,7 @@
118
119
  "test:e2e": "npm run build && npx testcafe",
119
120
  "test:e2e:dev": "npx testcafe --live --dev",
120
121
  "DOCS:update:test-deps": "If CI succeeds, these should be good to update",
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",
122
+ "update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing-helpers@latest @types/jest@latest codecov@latest eslint@7 eslint-plugin-testcafe@latest jest@latest sinon@latest testcafe@latest",
122
123
  "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",
123
124
  "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",
124
125
  "codecov": "npx codecov"
@@ -164,7 +164,6 @@ export class BookNavigator extends LitElement {
164
164
  */
165
165
  initializeBookSubmenus() {
166
166
  const providers = {
167
- downloads: new DownloadProvider(this.baseProviderConfig),
168
167
  share: new SharingProvider(this.baseProviderConfig),
169
168
  visualAdjustments: new VisualAdjustmentProvider({
170
169
  ...this.baseProviderConfig,
@@ -175,6 +174,10 @@ export class BookNavigator extends LitElement {
175
174
  }),
176
175
  };
177
176
 
177
+ if (this.shouldShowDownloadsMenu()) {
178
+ providers.downloads = new DownloadProvider(this.baseProviderConfig);
179
+ }
180
+
178
181
  if (this.bookreader.options.enableSearch) {
179
182
  providers.search = new SearchProvider({
180
183
  ...this.baseProviderConfig,
@@ -325,6 +328,7 @@ export class BookNavigator extends LitElement {
325
328
  * @returns {bool}
326
329
  */
327
330
  shouldShowDownloadsMenu() {
331
+ if (!this.downloadableTypes.length) { return false; }
328
332
  if (this.bookIsRestricted === false) { return true; }
329
333
  if (this.isAdmin) { return true; }
330
334
  const { user_loan_record = {} } = this.lendingStatus;
@@ -58,6 +58,11 @@ export class Mode1Up {
58
58
  });
59
59
  }
60
60
  this.mode1UpLit.jumpToIndex(startLeaf);
61
+ setTimeout(() => {
62
+ // Must explicitly call updateVisibleRegion, since no
63
+ // scroll event seems to fire.
64
+ this.mode1UpLit.updateVisibleRegion();
65
+ });
61
66
  });
62
67
  this.br.updateBrClasses();
63
68
  }
@@ -203,9 +203,12 @@ export class Mode1UpLit extends LitElement {
203
203
  }
204
204
  if (changedProps.has('visiblePages')) {
205
205
  this.throttledUpdateRenderedPages();
206
- this.br.displayedIndices = this.visiblePages.map(p => p.index);
207
- this.br.updateFirstIndex(this.br.displayedIndices[0]);
208
- this.br._components.navbar.updateNavIndexThrottled();
206
+ if (this.visiblePages.length) {
207
+ // unclear why this is ever really happening
208
+ this.br.displayedIndices = this.visiblePages.map(p => p.index);
209
+ this.br.updateFirstIndex(this.br.displayedIndices[0]);
210
+ this.br._components.navbar.updateNavIndexThrottled();
211
+ }
209
212
  }
210
213
  if (changedProps.has('scale')) {
211
214
  const oldVal = changedProps.get('scale');
@@ -148,6 +148,9 @@ describe('<book-navigator>', () => {
148
148
  el.bookreader = brStub;
149
149
  await el.elementUpdated;
150
150
 
151
+ el.downloadableTypes = ['foo/bar'];
152
+ await el.elementUpdated;
153
+
151
154
  el.initializeBookSubmenus();
152
155
  await el.elementUpdated;
153
156
  const defaultMenus = Object.keys(el.menuProviders);
@@ -229,6 +232,27 @@ describe('<book-navigator>', () => {
229
232
  expect(baseConfigKeys).toContain('isAdmin');
230
233
  expect(baseConfigKeys).toContain('onProviderChange');
231
234
  });
235
+
236
+ test('Downloads panel - does not show if no available `downloadableTypes`', async () => {
237
+ const el = fixtureSync(container());
238
+ const $brContainer = document.createElement('div');
239
+ const brStub = {
240
+ resize: sinon.fake(),
241
+ currentIndex: sinon.fake(),
242
+ jumpToIndex: sinon.fake(),
243
+ options: {},
244
+ refs: {
245
+ $brContainer
246
+ }
247
+ };
248
+ el.bookreader = brStub;
249
+ await el.elementUpdated;
250
+
251
+ el.initializeBookSubmenus();
252
+ await el.elementUpdated;
253
+ const defaultMenus = Object.keys(el.menuProviders);
254
+ expect(defaultMenus.find(menu => menu === 'downloads')).toBeUndefined;
255
+ });
232
256
  });
233
257
 
234
258
  describe('Controlling Menu Side Panel & Shortcuts', () => {
@@ -0,0 +1,3 @@
1
+ process.on("unhandledRejection", (error) => {
2
+ throw error;
3
+ });