New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@internetarchive/bookreader

Package Overview
Dependencies
Maintainers
11
Versions
311
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/bookreader - npm Package Compare versions

Comparing version 4.23.0-alpha-1 to 4.23.0-alpha-51422cf

src/js/BookReader/Mode1Up.js

2

BookReader/plugins/plugin.autoplay.js

@@ -1,2 +0,2 @@

(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[320],{6593:function(e,t,i){"use strict";i(7327),i(5827);var o,a=i(3609),n=i(3609);a.extend(BookReader.defaultOptions,{enableAutoPlayPlugin:!0}),BookReader.prototype.setup=(o=BookReader.prototype.setup,function(e){o.call(this,e),this.auto=!1,this.autoTimer=null,this.flipDelay=5e3}),BookReader.prototype.init=function(e){return function(t){var i=this;e.call(this,t),this.options.enableAutoPlayPlugin&&this.bind(BookReader.eventNames.stop,(function(){return i.autoStop()}))}}(BookReader.prototype.init),BookReader.prototype.bindNavigationHandlers=function(e){return function(){var t=this;if(e.call(this),this.options.enableAutoPlayPlugin){var i=this.$(".BRicon").add(".BRmobileMenu .BRicon");i.filter(".play").click((function(){return t.autoToggle(),!1})),i.filter(".pause").click((function(){return t.autoToggle(),!1}))}}}(BookReader.prototype.bindNavigationHandlers),BookReader.prototype.autoToggle=function(e){var t=this;if(this.options.enableAutoPlayPlugin){var i=n.extend({flipSpeed:this.flipSpeed,flipDelay:this.flipDelay},e);this.flipSpeed="number"==typeof i.flipSpeed?i.flipSpeed:this.flipSpeed,this.flipDelay="number"==typeof i.flipDelay?i.flipDelay:this.flipDelay,this.trigger(BookReader.eventNames.stop);var o=!1;this.constMode2up!=this.mode&&(o=!0,this.switchMode(this.constMode2up)),this.reduce<this.twoPageGetAutofitReduce()&&this.zoom2up("auto"),null==this.autoTimer?("rl"==this.pageProgression&&o||this.flipFwdToIndex(),this.$(".play").hide(),this.$(".pause").show(),this.autoTimer=setInterval((function(){t.animating||(Math.max(t.twoPage.currentIndexL,t.twoPage.currentIndexR)>=t.lastDisplayableIndex()?t.flipBackToIndex(1):t.flipFwdToIndex())}),this.flipDelay)):this.autoStop()}},BookReader.prototype.autoStop=function(){this.options.enableAutoPlayPlugin&&null!=this.autoTimer&&(clearInterval(this.autoTimer),this.flipSpeed="fast",this.$(".pause").hide(),this.$(".play").show(),this.autoTimer=null)}}},0,[[6593,898]]]);
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[320],{6593:function(e,t,i){"use strict";i(7327),i(5827);var o,a=i(3609),n=i(3609);a.extend(BookReader.defaultOptions,{enableAutoPlayPlugin:!0}),BookReader.prototype.setup=(o=BookReader.prototype.setup,function(e){o.call(this,e),this.auto=!1,this.autoTimer=null,this.flipDelay=5e3}),BookReader.prototype.init=function(e){return function(t){var i=this;e.call(this,t),this.options.enableAutoPlayPlugin&&this.bind(BookReader.eventNames.stop,(function(){return i.autoStop()}))}}(BookReader.prototype.init),BookReader.prototype.bindNavigationHandlers=function(e){return function(){var t=this;if(e.call(this),this.options.enableAutoPlayPlugin){var i=this.$(".BRicon").add(".BRmobileMenu .BRicon");i.filter(".play").click((function(){return t.autoToggle(),!1})),i.filter(".pause").click((function(){return t.autoToggle(),!1}))}}}(BookReader.prototype.bindNavigationHandlers),BookReader.prototype.autoToggle=function(e){var t=this;if(this.options.enableAutoPlayPlugin){var i=n.extend({flipSpeed:this.flipSpeed,flipDelay:this.flipDelay},e);this.flipSpeed="number"==typeof i.flipSpeed?i.flipSpeed:this.flipSpeed,this.flipDelay="number"==typeof i.flipDelay?i.flipDelay:this.flipDelay,this.trigger(BookReader.eventNames.stop);var o=!1;this.constMode2up!=this.mode&&(o=!0,this.switchMode(this.constMode2up)),this.reduce<this.twoPageGetAutofitReduce()&&this.zoom("auto"),null==this.autoTimer?("rl"==this.pageProgression&&o||this.flipFwdToIndex(),this.$(".play").hide(),this.$(".pause").show(),this.autoTimer=setInterval((function(){t.animating||(Math.max(t.twoPage.currentIndexL,t.twoPage.currentIndexR)>=t.lastDisplayableIndex()?t.flipBackToIndex(1):t.flipFwdToIndex())}),this.flipDelay)):this.autoStop()}},BookReader.prototype.autoStop=function(){this.options.enableAutoPlayPlugin&&null!=this.autoTimer&&(clearInterval(this.autoTimer),this.flipSpeed="fast",this.$(".pause").hide(),this.$(".play").show(),this.autoTimer=null)}}},0,[[6593,898]]]);
//# sourceMappingURL=plugin.autoplay.js.map

@@ -1,2 +0,2 @@

(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[336],{5894:function(t,o,e){"use strict";var a;e(2222),e(6992),e(5827),e(1539),e(4916),e(8783),e(5306),e(3948),e(285),e(3609).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight"],urlTrackIndex0:!1}),BookReader.prototype.setup=(a=BookReader.prototype.setup,function(t){a.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var o=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,(function(){var t=o.options,e=t.updateWindowTitle,a=t.urlMode;e&&(document.title=o.shortTitle(50)),"hash"===a&&o.urlStartLocationPolling()})),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollID),this.locationPollId=null),this.locationPollId=setInterval((function(){var o=t.urlReadFragment();if(o!=t.oldLocationHash&&o!=t.oldUserHash){var e=t.paramsFromFragment(o),a=function(){return t.updateFromParams(e)};t.trigger(BookReader.eventNames.stop),t.animating?(t.autoStop&&t.autoStop(),t.animationFinishedCallback=a):a(),t.oldUserHash=o}}),500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),o=this.options,e=o.urlMode,a=o.urlTrackIndex0,r=o.urlTrackedParams;a||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var i=r.reduce((function(o,e){return e in t&&(o[e]=t[e]),o}),{}),n=this.fragmentFromParams(i,e),s=this.urlReadFragment(),l=this.getLocationSearch(),h=this.queryStringFromParams(i,l,e);if(s!==n||l!==h)if("history"===e){if(window.history&&window.history.replaceState){var d=this.options.urlHistoryBasePath.replace(/\/+$/,""),u=""===n?"":"/".concat(n),c="".concat(d).concat(u).concat(h);window.history.replaceState({},null,c),this.oldLocationHash=n+h}}else{var p=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+n+p),this.oldLocationHash=n+p}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var o=new URLSearchParams(t);return o.has("q")?"?".concat(new URLSearchParams({q:o.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,o=t.urlMode,e=t.urlHistoryBasePath;return"history"===o?window.location.pathname.substr(e.length):window.location.hash.substr(1)}}},0,[[5894,898]]]);
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[336],{5894:function(t,o,e){"use strict";var a;e(2222),e(6992),e(5827),e(1539),e(4916),e(8783),e(5306),e(3948),e(285),e(3609).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight"],urlTrackIndex0:!1}),BookReader.prototype.setup=(a=BookReader.prototype.setup,function(t){a.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var o=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,(function(){var t=o.options,e=t.updateWindowTitle,a=t.urlMode;e&&(document.title=o.shortTitle(50)),"hash"===a&&o.urlStartLocationPolling()})),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollID),this.locationPollId=null),this.locationPollId=setInterval((function(){var o=t.urlReadFragment();if(o!=t.oldLocationHash&&o!=t.oldUserHash){var e=t.paramsFromFragment(o),a=function(){return t.updateFromParams(e)};t.trigger(BookReader.eventNames.stop),t.animating?(t.autoStop&&t.autoStop(),t.animationFinishedCallback=a):a(),t.oldUserHash=o}}),500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),o=this.options,e=o.urlMode,a=o.urlTrackIndex0,r=o.urlTrackedParams;a||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var i=r.reduce((function(o,e){return e in t&&(o[e]=t[e]),o}),{}),n=this.fragmentFromParams(i,e),s=this.urlReadFragment(),l=this.getLocationSearch(),h=this.queryStringFromParams(i,l,e);if(s!==n||l!==h)if("history"===e){if(window.history&&window.history.replaceState){var d=this.options.urlHistoryBasePath.replace(/\/+$/,""),u=""===n?"":"/".concat(n),c="".concat(d).concat(u).concat(h);window.history.replaceState({},null,c),this.oldLocationHash=n+h}}else{var p=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+n+p),this.oldLocationHash=n+p}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var o=new URLSearchParams(t);return o.has("q")?"?".concat(new URLSearchParams({q:o.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,o=t.urlMode,e=t.urlHistoryBasePath;return"history"===o?window.location.pathname.substr(e.length):window.location.hash.substr(1)},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)}}},0,[[5894,898]]]);
//# sourceMappingURL=plugin.url.js.map
{
"name": "@internetarchive/bookreader",
"version": "4.23.0-alpha-1",
"version": "4.23.0-alpha-51422cf",
"description": "The Internet Archive BookReader.",

@@ -28,15 +28,15 @@ "repository": {

"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@babel/core": "7.12.9",
"@babel/preset-env": "7.12.7",
"@types/jest": "26.0.15",
"babel-loader": "8.1.0",
"codecov": "3.7.2",
"babel-loader": "8.2.2",
"codecov": "3.8.1",
"concurrently": "5.3.0",
"core-js": "3.6.5",
"core-js": "3.8.0",
"cpx2": "3.0.0",
"eslint": "7.12.1",
"eslint": "7.14.0",
"eslint-plugin-testcafe": "^0.2.1",
"http-server": "0.12.3",
"iso-language-codes": "1.0.7",
"jest": "26.6.2",
"jest": "26.6.3",
"jquery": "1.11.3",

@@ -51,8 +51,8 @@ "jquery-colorbox": "1.6.4",

"regenerator-runtime": "0.13.7",
"sass": "1.28.0",
"sass": "1.29.0",
"sinon": "9.2.1",
"svgo": "1.3.2",
"testcafe": "1.9.3",
"webpack": "5.3.2",
"webpack-cli": "4.1.0"
"webpack": "5.9.0",
"webpack-cli": "4.2.0"
},

@@ -63,4 +63,8 @@ "jest": {

],
"roots": [
"<rootDir>/src/",
"<rootDir>/tests/"
],
"testPathIgnorePatterns": [
"tests/e2e"
"<rootDir>/tests/e2e/"
]

@@ -76,3 +80,3 @@ },

"build-js": "npx webpack && node scripts/copy-modules.js",
"build-js:watch": "npx webpack --watch",
"build-js:watch": "npx webpack --mode=development --watch",
"build-css": "npx sass --no-source-map ./src/css/BookReader.scss ./BookReader/BookReader.css",

@@ -83,3 +87,3 @@ "build-css:watch": "npx sass --watch --no-source-map ./src/css/BookReader.scss ./BookReader/BookReader.css",

"serve": "npx http-server . --port 8000",
"serve-live": "npx live-server . --port 8000 --ignore=coverage,tests,src",
"serve-live": "npx live-server . --port 8000 --watch=index.html,BookReader,BookReaderDemo",
"serve-dev": "npx concurrently --kill-others npm:serve-live npm:build-*:watch",

@@ -86,0 +90,0 @@ "test": "npx jest",

@@ -36,3 +36,6 @@ /** @typedef {import("../../BookReader.js").default} BookReader */

_viewModeControls() {
return ['onePage', 'twoPage', 'thumbnail', 'viewmode'].map((mode) => (
if (this.br.options.controls.viewmode.visible) {
return this.controlFor('viewmode');
}
return ['onePage', 'twoPage', 'thumbnail'].map((mode) => (
this.controlFor(mode)

@@ -39,0 +42,0 @@ )).join('');

@@ -50,3 +50,3 @@ /** @typedef {import('./BookModel.js').PageNumString} PageNumString */

* Zoom levels
* @type {Array<{reduce: number, autofit: AutoFitValues}}
* @type {ReductionFactor[]}
* $$$ provide finer grained zooming, {reduce: 8, autofit: null}, {reduce: 16, autofit: null}

@@ -214,3 +214,3 @@ * The autofit code ensures that fit to width and fit to height will be available

visible: true,
className: 'onepg hide-mobile',
className: 'onepg',
},

@@ -220,3 +220,3 @@ twoPage: {

visible: true,
className: 'twopg hide-mobile',
className: 'twopg',
},

@@ -226,6 +226,6 @@ thumbnail: {

visible: true,
className: 'thumb hide-mobile',
className: 'thumb',
},
viewmode: {
visible: true,
visible: false,
className: 'viewmode',

@@ -246,2 +246,9 @@ excludedModes: [],

/**
* @typedef {object} ReductionFactor
* @property {number} reduce
* @property {AutoFitValues} [autofit] If set, the corresponding reduction factors
* are what will be used when the user tries to autofit by width/height.
*/
/**
* @typedef {Object} PageData

@@ -248,0 +255,0 @@ * @property {number} width

@@ -85,3 +85,3 @@ /*global BookReader */

if (this.reduce < this.twoPageGetAutofitReduce()) {
this.zoom2up('auto');
this.zoom('auto');
}

@@ -88,0 +88,0 @@

@@ -191,1 +191,9 @@ /* global BookReader */

};
/**
* Will read the hash return the bookreader fragment
* @return {string}
*/
BookReader.prototype.urlReadHashFragment = function() {
return window.location.hash.substr(1);
};

@@ -192,1 +192,109 @@ import '../src/js/jquery-ui-wrapper.js';

});
describe('quantizeReduce', () => {
const quantizeReduce = BookReader.prototype.quantizeReduce;
const SAMPLE_FACTORS = [
{ reduce: 0.5 },
{ reduce: 1 },
{ reduce: 2 },
{ reduce: 3 },
{ reduce: 4 },
{ reduce: 6 },
];
test('Number larger than max', () => {
expect(quantizeReduce(10, SAMPLE_FACTORS)).toBe(6);
});
test('Number lower than max', () => {
expect(quantizeReduce(0.25, SAMPLE_FACTORS)).toBe(0.5);
});
test('Number directly between two reduction factors chooses first factor', () => {
expect(quantizeReduce(5, SAMPLE_FACTORS)).toBe(4);
});
test('Exact match', () => {
expect(quantizeReduce(2, SAMPLE_FACTORS)).toBe(2);
});
test('Closer to a lower boundary', () => {
expect(quantizeReduce(1.115, SAMPLE_FACTORS)).toBe(1);
});
test('Closer to an upper bound', () => {
expect(quantizeReduce(1.95, SAMPLE_FACTORS)).toBe(2);
});
test('Only one reduction factor', () => {
expect(quantizeReduce(17, [{reduce: 10}])).toBe(10);
});
});
describe('nextReduce', () => {
describe('Test matrix', () => {
const nextReduce = BookReader.prototype.nextReduce;
const SAMPLE_FACTORS = [
{ reduce: 0.5 },
{ reduce: 1 },
{ reduce: 2 },
{ reduce: 3 },
{ reduce: 3.3, autofit: "width" },
{ reduce: 4 },
{ reduce: 6 },
{ reduce: 6.1, autofit: "height" },
// auto doesn't get read by nextReduce (bug)
// It looks like width/height are set for 1up, and auto is set for 2up,
// and neither is set for thumb
{ reduce: 6.2, autofit: "auto" }
];
const currentReduces = [
{ name: 'Exact match', value: 2 },
{ name: 'In-between', value: 4.5 },
{ name: '< Min', value: 0.25 },
{ name: '> Max', value: 10 },
{ name: '= Min', value: 0.5 },
{ name: '= Max', value: 6.2 },
];
const directions = [ 'in', 'out', 'width', 'height', 'auto' ];
const expectations = [
// currentReduces <->
// v^ directions
/* 2, 4.5, 0.25, 10, 0.5, 6.2 */
/* in */ [ 1, 4, 0.5, 6.2, 0.5, 6.1 ],
/* out */ [ 3, 6, 0.5, 6.2, 1, 6.2 ],
/* width */ [ 3.3, 3.3, 3.3, 3.3, 3.3, 3.3 ],
/* height */ [ 6.1, 6.1, 6.1, 6.1, 6.1, 6.1 ],
/* auto */ [ 6.2, 6.2, 6.2, 6.2, 6.2, 6.2 ],
];
for (const [y, row] of expectations.entries()) {
for (const [x, expectedValue] of row.entries()) {
test(`${currentReduces[x].name} ${directions[y]}`, () => {
expect(nextReduce(currentReduces[x].value, directions[y], SAMPLE_FACTORS).reduce)
.toBe(expectedValue);
});
}
}
});
describe('No matching reduction', () => {
const nextReduce = BookReader.prototype.nextReduce;
const SAMPLE_FACTORS = [
{ reduce: 0.5 },
{ reduce: 1 },
{ reduce: 2 },
{ reduce: 3 },
];
test('Returns first reduction when no match found', () => {
expect(nextReduce(2, 'width', SAMPLE_FACTORS).reduce).toBe(0.5);
expect(nextReduce(2, 'height', SAMPLE_FACTORS).reduce).toBe(0.5);
expect(nextReduce(2, 'auto', SAMPLE_FACTORS).reduce).toBe(0.5);
});
});
});

@@ -5,6 +5,29 @@ // @ts-check

/** @type {webpack.Configuration} */
const shared = {
mode: 'production',
watchOptions: {
ignored: ['BookReader/**', 'node_modules/**', 'tests/**']
},
target: ['web', 'es5'],
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
output: {
filename: '[name]',
path: path.resolve(__dirname, 'BookReader'),
},
};
/** @type {webpack.Configuration[]} */
module.exports = [
{
mode: 'production',
...shared,
// Output file -> srcfile

@@ -45,8 +68,2 @@ entry: {

module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
output: {

@@ -57,4 +74,2 @@ filename: '[name]',

target: ['web', 'es5'],
// Accurate source maps at the expense of build time.

@@ -69,19 +84,7 @@ // The source map is intentionally exposed

{
mode: 'production',
...shared,
entry: {
'jquery-1.10.1.js': { import: './src/js/jquery-wrapper.js' },
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
output: {
filename: '[name]',
path: path.resolve(__dirname, 'BookReader'),
},
target: ['web', 'es5'],
},

@@ -92,3 +95,4 @@

{
mode: 'production',
...shared,
// Output file -> srcfile

@@ -115,16 +119,3 @@ entry: {

],
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
output: {
filename: '[name]',
path: path.resolve(__dirname, 'BookReader'),
},
target: ['web', 'es5'],
},
];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc