Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-epub

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-epub - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

36

extract/smil-data.js

@@ -6,2 +6,4 @@ 'use strict';

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

@@ -17,2 +19,6 @@

var _pathBrowserify = require('path-browserify');
var path = _interopRequireWildcard(_pathBrowserify);
var AUDIO = 'audio';

@@ -29,4 +35,4 @@ var BODY = 'body';

function smilData(xml, id, _ref) {
var clockValue = _ref.clockValue;
function smilData(xml, id, refinement, baseUri) {
if (refinement === undefined) refinement = {};

@@ -36,3 +42,3 @@ var smilXml = xml.querySelector(TAG);

var ret = {
body: parse(smilXml.querySelector(BODY)),
body: parse(smilXml.querySelector(BODY), baseUri),
id: id,

@@ -42,4 +48,4 @@ version: smilXml.getAttribute(VERSION)

if (clockValue) {
ret.duration = _parseClockValue2['default'](clockValue);
if (refinement.clockValue) {
ret.duration = _parseClockValue2['default'](refinement.clockValue);
}

@@ -84,3 +90,7 @@ return ret;

function parse(xml) {
function resolvePath(baseUri, relativePath) {
return path.resolve(baseUri, relativePath);
}
function parse(xml, baseUri) {
var ret = undefined;

@@ -91,2 +101,5 @@

ret = attrs(xml);
if (ret.src && !path.isAbsolute(ret.src)) {
ret.src = resolvePath(baseUri, ret.src);
}
ret.clipBegin = ret.clipBegin && _parseClockValue2['default'](ret.clipBegin);

@@ -98,5 +111,5 @@ ret.clipEnd = ret.clipEnd && _parseClockValue2['default'](ret.clipEnd);

ret = attrs(xml);
ret.audio = parse(xml.querySelector(AUDIO));
ret.audio = parse(xml.querySelector(AUDIO), baseUri);
ret.isPar = true;
ret.text = parse(xml.querySelector(TEXT));
ret.text = parse(xml.querySelector(TEXT), baseUri);
break;

@@ -107,3 +120,5 @@

ret = attrs(xml);
ret.childNodes = getValidChildNodes(xml).map(parse);
ret.childNodes = getValidChildNodes(xml).map(function (arr) {
return parse(arr, baseUri);
});
ret.isPar = false;

@@ -114,2 +129,5 @@ break;

ret = attrs(xml);
if (ret.src && !path.isAbsolute(ret.src)) {
ret.src = resolvePath(baseUri, ret.src);
}

@@ -116,0 +134,0 @@ var _ret$src$split = ret.src.split('#'),

'use strict';
exports.__esModule = true;
exports.getSmilFromManifest = getSmilFromManifest;
exports.getMediaOverlayItems = getMediaOverlayItems;
exports.fetchAll = fetchAll;

@@ -11,4 +11,10 @@ exports.parseAll = parseAll;

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
require('core-js/modules/es6.array.find');
var _pathBrowserify = require('path-browserify');
var path = _interopRequireWildcard(_pathBrowserify);
var _fetch = require('../fetch');

@@ -22,5 +28,8 @@

function getSmilFromManifest(manifest) {
// this filters and gets the spine items that have a media overlay associated
// with it.
function getMediaOverlayItems(manifest) {
return manifest.items.filter(function (id) {
return manifest.byId[id].mediaType === SMIL_MEDIA_TYPE;
return manifest.byId[id].mediaOverlay;
});

@@ -30,8 +39,10 @@ }

function fetchAll(uri, items, manifest) {
return Promise.all(items.map(function (id) {
return _fetch.manifestItemXml(uri, manifest.byId[id].href);
return Promise.all(items.map(function (spineId) {
var smilId = manifest.byId[spineId].mediaOverlay;
var smilItem = manifest.byId[smilId];
return _fetch.manifestItemXml(uri, smilItem.href);
}));
}
function parseAll(items, manifest, metadata) {
function parseAll(items, manifest, metadata, uri) {
return function parseAllThunk(manifestItemsXml) {

@@ -42,7 +53,9 @@ var byId = {};

manifestItemsXml.forEach(function (xml, i) {
var id = items[i];
var spineId = items[i];
var smilId = manifest.byId[spineId].mediaOverlay;
var refinement = metadata.mediaOverlayDurations.find(function (mod) {
return mod.refines === '#' + id;
return mod.refines === '#' + smilId;
});
byId[id] = _smilData2['default'](xml, id, refinement);
var baseUri = path.dirname(manifest.byId[spineId].href);
byId[smilId] = _smilData2['default'](xml, smilId, refinement, baseUri);
});

@@ -58,6 +71,5 @@

function smil(uri, manifest, metadata) {
var items = getSmilFromManifest(manifest);
var items = getMediaOverlayItems(manifest);
return fetchAll(uri, items, manifest).then(function (values) {
return parseAll(items, manifest, metadata)(values);
return parseAll(items, manifest, metadata, uri)(values);
})['catch'](function (error) {

@@ -64,0 +76,0 @@ return console.error(error);

{
"name": "parse-epub",
"version": "2.1.1",
"version": "2.1.2",
"description": "A modern and modular ePub parser",

@@ -48,2 +48,3 @@ "main": "index.js",

"lodash": "^3.10.1",
"path-browserify": "0.0.0",
"whatwg-fetch": "^0.9.0"

@@ -50,0 +51,0 @@ },

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