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

epubjs

Package Overview
Dependencies
Maintainers
2
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

epubjs - npm Package Compare versions

Comparing version 0.3.47 to 0.3.48

24

lib/contents.js

@@ -131,5 +131,6 @@ "use strict";

value: function textWidth() {
var width;
var width = void 0;
var range = this.document.createRange();
var content = this.content || this.document.body;
var border = (0, _core.borders)(content);

@@ -142,3 +143,7 @@ // Select the contents of frame

return width;
if (border && border.width) {
width += border.width;
}
return Math.round(width);
}

@@ -148,5 +153,6 @@ }, {

value: function textHeight() {
var height;
var height = void 0;
var range = this.document.createRange();
var content = this.content || this.document.body;
var border = (0, _core.borders)(content);

@@ -157,3 +163,7 @@ range.selectNodeContents(content);

return height;
if (height && border.height) {
height += border.height;
}
return Math.round(height);
}

@@ -361,3 +371,2 @@ }, {

var height = this.textHeight();
if (width != this._size.width || height != this._size.height) {

@@ -382,7 +391,4 @@

width = this.textWidth();
height = this.textHeight();
requestAnimationFrame(this.resizeCheck.bind(this));
this.resizeCheck();
this.expanding = setTimeout(this.resizeListeners.bind(this), 350);

@@ -389,0 +395,0 @@ }

@@ -147,4 +147,6 @@ "use strict";

colWidth = width / divisor - gap;
pageWidth = colWidth + gap;
} else {
colWidth = width;
pageWidth = width;
}

@@ -157,3 +159,2 @@

spreadWidth = colWidth * divisor + gap;
pageWidth = colWidth + gap / 2;

@@ -160,0 +161,0 @@ delta = width;

@@ -577,3 +577,3 @@ "use strict";

var start = left + container.left - position + used;
var end = start + _this2.layout.spreadWidth - used;
var end = start + _this2.layout.width - used;

@@ -798,3 +798,6 @@ var mapping = _this2.mapping.page(view.contents, view.section.cfiBase, start, end);

this.views.each(function (view) {
contents.push(view.contents);
var viewContents = view.contents;
if (viewContents) {
contents.push(viewContents);
}
});

@@ -801,0 +804,0 @@ return contents;

@@ -169,9 +169,6 @@ "use strict";

// Wait for formating to apply
return new Promise(function (resolve, reject) {
setTimeout(function () {
// Expand the iframe to the full size of the content
_this.expand();
resolve();
}, 1);
// Expand the iframe to the full size of the content
_this.expand();
resolve();
});

@@ -271,47 +268,24 @@ }.bind(this)).then(function () {

this._expanding = true;
// Expand Horizontally
// if(height && !width) {
if (this.settings.axis === "horizontal") {
// Get the width of the text
textWidth = this.contents.textWidth();
width = this.contentWidth(textWidth);
width = this.contents.textWidth();
// Check if the textWidth has changed
if (width != this._width) {
// Get the contentWidth by resizing the iframe
// Check with a min reset of the textWidth
if (width % this.layout.pageWidth > 0) {
width = Math.ceil(width / this.layout.pageWidth) * this.layout.pageWidth;
}
// Add padding back
if (width % this.layout.width > 0) {
width += this.layout.gap / 2;
}
/*
columns = Math.ceil(width / this.settings.layout.delta);
if ( this.settings.layout.divisor > 1 &&
this.settings.layout.name === "reflowable" &&
(columns % 2 > 0)) {
// add a blank page
width += this.settings.layout.gap + this.settings.layout.columnWidth;
}
*/
// Save the textWdith
this._textWidth = textWidth;
// Save the contentWidth
this._contentWidth = width;
} else {
// Otherwise assume content height hasn't changed
width = this._contentWidth;
}
/*
columns = Math.ceil(width / this.settings.layout.delta);
if ( this.settings.layout.divisor > 1 &&
this.settings.layout.name === "reflowable" &&
(columns % 2 > 0)) {
// add a blank page
width += this.settings.layout.gap + this.settings.layout.columnWidth;
}
*/
} // Expand Vertically
else if (this.settings.axis === "vertical") {
textHeight = this.contents.textHeight();
if (textHeight != this._textHeight) {
height = this.contentHeight(textHeight);
this._textHeight = textHeight;
this._contentHeight = height;
} else {
height = this._contentHeight;
}
height = this.contents.textHeight();
}

@@ -322,3 +296,3 @@

if (this._needsReframe || width != this._width || height != this._height) {
this.resize(width, height);
this.reframe(width, height);
}

@@ -329,52 +303,2 @@

}, {
key: "contentWidth",
value: function contentWidth(min) {
var prev;
var width;
// Save previous width
prev = this.iframe.style.width;
// Set the iframe size to min, width will only ever be greater
// Will preserve the aspect ratio
this.iframe.style.width = (min || 0) + "px";
// Get the scroll overflow width
width = this.contents.scrollWidth();
// Reset iframe size back
this.iframe.style.width = prev;
return width;
}
}, {
key: "contentHeight",
value: function contentHeight(min) {
var prev;
var height;
prev = this.iframe.style.height;
this.iframe.style.height = (min || 0) + "px";
height = this.contents.scrollHeight();
this.iframe.style.height = prev;
return height;
}
}, {
key: "resize",
value: function resize(width, height) {
if (!this.iframe) return;
if ((0, _core.isNumber)(width)) {
this.iframe.style.width = width + "px";
this._width = width;
}
if ((0, _core.isNumber)(height)) {
this.iframe.style.height = height + "px";
this._height = height;
}
this.iframeBounds = (0, _core.bounds)(this.iframe);
this.reframe(this.iframeBounds.width, this.iframeBounds.height);
}
}, {
key: "reframe",

@@ -384,9 +308,6 @@ value: function reframe(width, height) {

// if(!this.displayed) {
// this._needsReframe = true;
// return;
// }
if ((0, _core.isNumber)(width)) {
this.element.style.width = width + "px";
this.iframe.style.width = width + "px";
this._width = width;
}

@@ -396,12 +317,12 @@

this.element.style.height = height + "px";
this.iframe.style.height = height + "px";
this._height = height;
}
this.elementBounds = (0, _core.bounds)(this.element);
var widthDelta = this.prevBounds ? width - this.prevBounds.width : width;
var heightDelta = this.prevBounds ? height - this.prevBounds.height : height;
var widthDelta = this.prevBounds ? this.elementBounds.width - this.prevBounds.width : this.elementBounds.width;
var heightDelta = this.prevBounds ? this.elementBounds.height - this.prevBounds.height : this.elementBounds.height;
size = {
width: this.elementBounds.width,
height: this.elementBounds.height,
width: width,
height: height,
widthDelta: widthDelta,

@@ -413,9 +334,5 @@ heightDelta: heightDelta

if (this.contents) {
this.settings.layout.format(this.contents);
}
this.emit("resized", size);
this.prevBounds = this.elementBounds;
this.prevBounds = size;
}

@@ -481,2 +398,5 @@ }, {

_this2.expand();
if (_this2.contents) {
_this2.settings.layout.format(_this2.contents);
}
}

@@ -488,2 +408,5 @@ });

_this2.expand();
if (_this2.contents) {
_this2.settings.layout.format(_this2.contents);
}
}

@@ -505,9 +428,2 @@ });

}, {
key: "resizeListenters",
value: function resizeListenters() {
// Test size again
clearTimeout(this.expanding);
this.expanding = setTimeout(this.expand.bind(this), 350);
}
}, {
key: "addListeners",

@@ -514,0 +430,0 @@ value: function addListeners() {

@@ -144,10 +144,10 @@ "use strict";

return this.load(contents);
}.bind(this)
}.bind(this))
// .then(function(doc){
// return this.hooks.content.trigger(view, this);
// }.bind(this))
).then(function () {
.then(function () {
// this.settings.layout.format(view.contents);
// return this.hooks.layout.trigger(view, this);
}.bind(this)
}.bind(this))
// .then(function(){

@@ -159,3 +159,3 @@ // return this.display();

// }.bind(this))
).then(function () {
.then(function () {

@@ -162,0 +162,0 @@ // apply the layout function to the contents

{
"name": "epubjs",
"version": "0.3.47",
"version": "0.3.48",
"description": "Parse and Render Epubs",

@@ -27,19 +27,19 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "1.1.8",
"babel-preset-es2015": "^6.22.0",
"babili-webpack-plugin": "0.0.10",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "1.6.0",
"babel-preset-es2015": "^6.24.1",
"babili-webpack-plugin": "0.1.2",
"colors": "^1.1.2",
"connect": "^3.5.0",
"eslint": "^3.15.0",
"express": "^4.14.1",
"connect": "^3.6.3",
"eslint": "^4.5.0",
"express": "^4.15.4",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-connect": "~5.0.0",
"gulp-documentation": "fchasen/gulp-documentation",
"gulp-documentation": "github:fchasen/gulp-documentation",
"gulp-jshint": "^2.0.4",

@@ -49,30 +49,30 @@ "gulp-plumber": "^1.1.0",

"gulp-size": "^2.1.0",
"gulp-sourcemaps": "^2.4.1",
"gulp-uglify": "^2.0.1",
"gulp-sourcemaps": "^2.6.1",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"jquery": "^3.1.1",
"jshint": "^2.9.4",
"karma": "^1.4.1",
"jquery": "^3.2.1",
"jshint": "^2.9.5",
"karma": "^1.7.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-mocha-reporter": "^2.2.4",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.2",
"mocha": "^3.2.0",
"mocha-loader": "^1.1.0",
"morgan": "^1.8.0",
"karma-webpack": "^2.0.4",
"mocha": "^3.5.0",
"mocha-loader": "^1.1.1",
"morgan": "^1.8.2",
"optimist": "^0.6.1",
"portfinder": "^1.0.13",
"raw-loader": "^0.5.1",
"serve-static": "^1.11.2",
"serve-static": "^1.12.4",
"uglify": "^0.1.5",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^v2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.6.1"
"webpack": "^v3.5.5",
"webpack-dev-middleware": "^1.12.0",
"webpack-dev-server": "^2.7.1"
},
"dependencies": {
"event-emitter": "^0.3.5",
"jszip": "^3.1.3",
"jszip": "^3.1.4",
"lodash": "^4.17.4",

@@ -79,0 +79,0 @@ "marks-pane": "^1.0.2",

import EventEmitter from "event-emitter";
import {isNumber, prefixed} from "./utils/core";
import {isNumber, prefixed, borders} from "./utils/core";
import EpubCFI from "./epubcfi";

@@ -110,5 +110,6 @@ import Mapping from "./mapping";

textWidth() {
var width;
var range = this.document.createRange();
var content = this.content || this.document.body;
let width;
let range = this.document.createRange();
let content = this.content || this.document.body;
let border = borders(content);

@@ -121,10 +122,14 @@ // Select the contents of frame

return width;
if (border && border.width) {
width += border.width;
}
return Math.round(width);
}
textHeight() {
var height;
var range = this.document.createRange();
var content = this.content || this.document.body;
let height;
let range = this.document.createRange();
let content = this.content || this.document.body;
let border = borders(content);

@@ -135,3 +140,7 @@ range.selectNodeContents(content);

return height;
if (height && border.height) {
height += border.height;
}
return Math.round(height);
}

@@ -329,3 +338,2 @@

let height = this.textHeight();
if (width != this._size.width || height != this._size.height) {

@@ -349,7 +357,4 @@

width = this.textWidth();
height = this.textHeight();
requestAnimationFrame(this.resizeCheck.bind(this));
this.resizeCheck();
this.expanding = setTimeout(this.resizeListeners.bind(this), 350);

@@ -356,0 +361,0 @@ }

@@ -131,4 +131,6 @@ /**

colWidth = (width / divisor) - gap;
pageWidth = colWidth + gap;
} else {
colWidth = width;
pageWidth = width;
}

@@ -141,3 +143,2 @@

spreadWidth = (colWidth * divisor) + gap;
pageWidth = colWidth + (gap / 2);

@@ -144,0 +145,0 @@ delta = width;

@@ -532,3 +532,3 @@ import EventEmitter from "event-emitter";

let start = left + container.left - position + used;
let end = start + this.layout.spreadWidth - used;
let end = start + this.layout.width - used;

@@ -761,3 +761,6 @@ let mapping = this.mapping.page(view.contents, view.section.cfiBase, start, end);

this.views.each(function(view){
contents.push(view.contents);
const viewContents = view.contents;
if (viewContents) {
contents.push(viewContents);
}
});

@@ -764,0 +767,0 @@ return contents;

@@ -143,9 +143,6 @@ import EventEmitter from "event-emitter";

// Wait for formating to apply
return new Promise((resolve, reject) => {
setTimeout(() => {
// Expand the iframe to the full size of the content
this.expand();
resolve();
}, 1);
// Expand the iframe to the full size of the content
this.expand();
resolve();
});

@@ -225,3 +222,2 @@

this.expand();
}

@@ -246,48 +242,24 @@

this._expanding = true;
// Expand Horizontally
// if(height && !width) {
if(this.settings.axis === "horizontal") {
// Get the width of the text
textWidth = this.contents.textWidth();
width = this.contentWidth(textWidth);
width = this.contents.textWidth();
// Check if the textWidth has changed
if(width != this._width){
// Get the contentWidth by resizing the iframe
// Check with a min reset of the textWidth
if (width % this.layout.pageWidth > 0) {
width = Math.ceil(width / this.layout.pageWidth) * this.layout.pageWidth;
}
// Add padding back
if (width % this.layout.width > 0) {
width += this.layout.gap / 2;
}
/*
columns = Math.ceil(width / this.settings.layout.delta);
if ( this.settings.layout.divisor > 1 &&
this.settings.layout.name === "reflowable" &&
(columns % 2 > 0)) {
// add a blank page
width += this.settings.layout.gap + this.settings.layout.columnWidth;
}
*/
// Save the textWdith
this._textWidth = textWidth;
// Save the contentWidth
this._contentWidth = width;
} else {
// Otherwise assume content height hasn't changed
width = this._contentWidth;
/*
columns = Math.ceil(width / this.settings.layout.delta);
if ( this.settings.layout.divisor > 1 &&
this.settings.layout.name === "reflowable" &&
(columns % 2 > 0)) {
// add a blank page
width += this.settings.layout.gap + this.settings.layout.columnWidth;
}
*/
} // Expand Vertically
else if(this.settings.axis === "vertical") {
textHeight = this.contents.textHeight();
if(textHeight != this._textHeight){
height = this.contentHeight(textHeight);
this._textHeight = textHeight;
this._contentHeight = height;
} else {
height = this._contentHeight;
}
height = this.contents.textHeight();
}

@@ -298,3 +270,3 @@

if(this._needsReframe || width != this._width || height != this._height){
this.resize(width, height);
this.reframe(width, height);
}

@@ -305,36 +277,7 @@

contentWidth(min) {
var prev;
var width;
reframe(width, height) {
var size;
// Save previous width
prev = this.iframe.style.width;
// Set the iframe size to min, width will only ever be greater
// Will preserve the aspect ratio
this.iframe.style.width = (min || 0) + "px";
// Get the scroll overflow width
width = this.contents.scrollWidth();
// Reset iframe size back
this.iframe.style.width = prev;
return width;
}
contentHeight(min) {
var prev;
var height;
prev = this.iframe.style.height;
this.iframe.style.height = (min || 0) + "px";
height = this.contents.scrollHeight();
this.iframe.style.height = prev;
return height;
}
resize(width, height) {
if(!this.iframe) return;
if(isNumber(width)){
this.element.style.width = width + "px";
this.iframe.style.width = width + "px";

@@ -345,2 +288,3 @@ this._width = width;

if(isNumber(height)){
this.element.style.height = height + "px";
this.iframe.style.height = height + "px";

@@ -350,32 +294,8 @@ this._height = height;

this.iframeBounds = bounds(this.iframe);
let widthDelta = this.prevBounds ? width - this.prevBounds.width : width;
let heightDelta = this.prevBounds ? height - this.prevBounds.height : height;
this.reframe(this.iframeBounds.width, this.iframeBounds.height);
}
reframe(width, height) {
var size;
// if(!this.displayed) {
// this._needsReframe = true;
// return;
// }
if(isNumber(width)){
this.element.style.width = width + "px";
}
if(isNumber(height)){
this.element.style.height = height + "px";
}
this.elementBounds = bounds(this.element);
let widthDelta = this.prevBounds ? this.elementBounds.width - this.prevBounds.width : this.elementBounds.width;
let heightDelta = this.prevBounds ? this.elementBounds.height - this.prevBounds.height : this.elementBounds.height;
size = {
width: this.elementBounds.width,
height: this.elementBounds.height,
width: width,
height: height,
widthDelta: widthDelta,

@@ -387,9 +307,5 @@ heightDelta: heightDelta,

if (this.contents) {
this.settings.layout.format(this.contents);
}
this.emit("resized", size);
this.prevBounds = this.elementBounds;
this.prevBounds = size;

@@ -456,2 +372,5 @@ }

this.expand();
if (this.contents) {
this.settings.layout.format(this.contents);
}
}

@@ -463,2 +382,5 @@ });

this.expand();
if (this.contents) {
this.settings.layout.format(this.contents);
}
}

@@ -478,8 +400,2 @@ });

resizeListenters() {
// Test size again
clearTimeout(this.expanding);
this.expanding = setTimeout(this.expand.bind(this), 350);
}
addListeners() {

@@ -486,0 +402,0 @@ //TODO: Add content listeners for expanding

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 too big to display

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

Sorry, the diff of this file is not supported yet

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