@ridi/epub-parser
Advanced tools
Comparing version 0.3.0-alpha.5 to 0.3.0-alpha-10
@@ -7,10 +7,2 @@ 'use strict'; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _promise = require('babel-runtime/core-js/promise'); | ||
@@ -28,2 +20,10 @@ | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -33,2 +33,6 @@ | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
@@ -38,5 +42,5 @@ | ||
var _weakMap = require('babel-runtime/core-js/weak-map'); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _weakMap2 = _interopRequireDefault(_weakMap); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
@@ -47,6 +51,2 @@ var _parserCore = require('@ridi/parser-core'); | ||
var _fs = require('fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _Book = require('./model/Book'); | ||
@@ -56,6 +56,2 @@ | ||
var _Context = require('./model/Context'); | ||
var _Context2 = _interopRequireDefault(_Context); | ||
var _CssItem = require('./model/CssItem'); | ||
@@ -97,2 +93,6 @@ | ||
var _ReadContext = require('./model/ReadContext'); | ||
var _ReadContext2 = _interopRequireDefault(_ReadContext); | ||
var _SpineItem = require('./model/SpineItem'); | ||
@@ -110,2 +110,6 @@ | ||
var _ParseContext = require('./model/ParseContext'); | ||
var _ParseContext2 = _interopRequireDefault(_ParseContext); | ||
var _xmlLoader4 = require('./loader/xmlLoader'); | ||
@@ -117,36 +121,5 @@ | ||
var privateProps = new _weakMap2.default(); | ||
var EpubParser = function () { | ||
(0, _createClass3.default)(EpubParser, [{ | ||
key: 'input', | ||
/** | ||
* Get file or directory | ||
*/ | ||
get: function get() { | ||
return privateProps.get(this).input; | ||
} | ||
/** | ||
* Get en/decrypto provider | ||
*/ | ||
}, { | ||
key: 'cryptoProvider', | ||
get: function get() { | ||
return privateProps.get(this).cryptoProvider; | ||
} | ||
/** | ||
* Create new EpubParser | ||
* @param {string} input file or directory | ||
* @param {CryptoProvider} cryptoProvider en/decrypto provider | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @throws {Errors.EINVAL} invalid input | ||
* @example new EpubParser('./foo/bar.epub' or './foo/bar'); | ||
*/ | ||
}], [{ | ||
var EpubParser = function (_Parser) { | ||
(0, _inherits3.default)(EpubParser, _Parser); | ||
(0, _createClass3.default)(EpubParser, null, [{ | ||
key: 'parseDefaultOptions', | ||
@@ -158,3 +131,3 @@ | ||
get: function get() { | ||
return { | ||
return (0, _extends3.default)({}, _Parser.parseDefaultOptions, { | ||
// If true, validation package specifications in IDPF listed below. (only using if input is EPUB file.) | ||
@@ -169,13 +142,2 @@ // - Zip header should not corrupt. | ||
allowNcxFileMissing: true, | ||
// If specified, uncompress to that path. (only using if input is EPUB file.) | ||
unzipPath: undefined, | ||
// If true, overwrite to unzipPath when uncompress. (only using if unzipPath specified.) | ||
overwrite: true, | ||
// If true, ignore index difference caused by isLinear property of SpineItem. | ||
// e.g. If left is true, right is false. | ||
// [{ index: 0, isLinear: true, ... }, [{ index: 0, isLinear: true, ... }, | ||
// { index: 1, isLinear: true, ... }, { index: 1, isLinear: true, ... }, | ||
// { index: 2, isLinear: false, ... }, { index: -1, isLinear: false, ... }, | ||
// { index: 3, isLinear: true, ... }] { index: 2, isLinear: true, ... }] | ||
ignoreLinear: false, | ||
// If true, styles used for spine is described, and one namespace is given per CSS file or inline style. | ||
@@ -187,3 +149,3 @@ // Otherwise it CssItem.namespace, SpineItem.styles is undefined. | ||
styleNamespacePrefix: 'ridi_style' | ||
}; | ||
}); | ||
} | ||
@@ -198,11 +160,8 @@ | ||
get: function get() { | ||
return { | ||
return (0, _extends3.default)({}, _Parser.parseOptionTypes, { | ||
validatePackage: 'Boolean', | ||
allowNcxFileMissing: 'Boolean', | ||
unzipPath: 'String|Undefined', | ||
overwrite: 'Boolean', | ||
ignoreLinear: 'Boolean', | ||
parseStyle: 'Boolean', | ||
styleNamespacePrefix: 'String' | ||
}; | ||
}); | ||
} | ||
@@ -217,3 +176,3 @@ | ||
get: function get() { | ||
return { | ||
return (0, _extends3.default)({}, _Parser.readDefaultOptions, { | ||
// If specified, change base path of paths used by spine and css. | ||
@@ -236,3 +195,3 @@ // e.g. '../Images/cover.jpg' -> '{basePath}/OEBPS/Images/cover.jpg' | ||
removeClasses: [] | ||
}; | ||
}); | ||
} | ||
@@ -247,3 +206,3 @@ | ||
get: function get() { | ||
return { | ||
return (0, _extends3.default)({}, _Parser.readOptionTypes, { | ||
basePath: 'String|Undefined', | ||
@@ -256,4 +215,14 @@ extractBody: 'Boolean|Function', | ||
removeClasses: 'Array' | ||
}; | ||
}); | ||
} | ||
/** | ||
* Create new EpubParser | ||
* @param {string} input file or directory | ||
* @param {CryptoProvider} cryptoProvider en/decrypto provider | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @throws {Errors.EINVAL} invalid input | ||
* @example new EpubParser('./foo/bar.epub' or './foo/bar'); | ||
*/ | ||
}]); | ||
@@ -263,139 +232,63 @@ | ||
(0, _classCallCheck3.default)(this, EpubParser); | ||
if ((0, _parserCore.isString)(input)) { | ||
if (!_fs2.default.existsSync(input)) { | ||
throw (0, _parserCore.createError)(_parserCore.Errors.ENOENT, input); | ||
} | ||
} else { | ||
throw (0, _parserCore.createError)(_parserCore.Errors.EINVAL, 'input', 'input', input); | ||
} | ||
privateProps.set(this, { input: input, cryptoProvider: cryptoProvider }); | ||
return (0, _possibleConstructorReturn3.default)(this, _Parser.call(this, input, cryptoProvider, 'EpubParser')); | ||
} | ||
/** | ||
* EPUB Parsing | ||
* @param {?object} options parse options | ||
* @returns {Promise.<Book>} return Book | ||
* @see EpubParser.parseDefaultOptions | ||
* @see EpubParser.parseOptionTypes | ||
* @example | ||
* const options = { validatePackage: true, unzipPath: './foo/bar' }; | ||
* parser.parse(options).then((book) => { | ||
* ... | ||
* }); | ||
* @returns {ParseContext} | ||
*/ | ||
EpubParser.prototype.parse = function () { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var context, book; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return this._prepareParse(options); | ||
EpubParser.prototype._getParseContextClass = function _getParseContextClass() { | ||
return _ParseContext2.default; | ||
}; | ||
case 2: | ||
context = _context.sent; | ||
_context.next = 5; | ||
return this._validatePackageIfNeeded(context); | ||
/** | ||
* @returns {Book} | ||
*/ | ||
case 5: | ||
context = _context.sent; | ||
_context.next = 8; | ||
return this._parseMetaInf(context); | ||
case 8: | ||
context = _context.sent; | ||
_context.next = 11; | ||
return this._parseOpf(context); | ||
EpubParser.prototype._getBookClass = function _getBookClass() { | ||
return _Book2.default; | ||
}; | ||
case 11: | ||
context = _context.sent; | ||
_context.next = 14; | ||
return this._parseNcx(context); | ||
/** | ||
* @returns {ReadContext} | ||
*/ | ||
case 14: | ||
context = _context.sent; | ||
_context.next = 17; | ||
return this._unzipIfNeeded(context); | ||
case 17: | ||
context = _context.sent; | ||
EpubParser.prototype._getReadContextClass = function _getReadContextClass() { | ||
return _ReadContext2.default; | ||
}; | ||
_parserCore.Logger.warn('Cover image not found in EPUB.'); | ||
_context.next = 21; | ||
return this._createBook(context); | ||
/** | ||
* @returns {Item} | ||
*/ | ||
case 21: | ||
book = _context.sent; | ||
return _context.abrupt('return', book); | ||
case 23: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
EpubParser.prototype._getReadItemClass = function _getReadItemClass() { | ||
return _Item2.default; | ||
}; | ||
function parse() { | ||
return _ref.apply(this, arguments); | ||
} | ||
return parse; | ||
}(); | ||
/** | ||
* Validate parse options and get entries from input | ||
* @param {?object} options parse options | ||
* @returns {Promise.<Context>} return Context containing parse options, entries | ||
* @throws {Errors.EINVAL} invalid options or value type | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @throws {Errors.ENOFILE} no such file | ||
* @see EpubParser.parseDefaultOptions | ||
* @see EpubParser.parseOptionTypes | ||
* @returns {ParseTask[]} return tasks | ||
*/ | ||
EpubParser.prototype._prepareParse = function () { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var context; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
(0, _parserCore.validateOptions)(options, EpubParser.parseOptionTypes); | ||
context = new _Context2.default(); | ||
EpubParser.prototype._parseTasks = function _parseTasks() { | ||
return [].concat((0, _toConsumableArray3.default)(_Parser.prototype._parseTasks.call(this)), [{ func: this._validatePackageIfNeeded, name: 'validatePackageIfNeeded' }, { func: this._parseMetaInf, name: 'parseMetaInf' }, { func: this._parseOpf, name: 'parseOpf' }, { func: this._parseNcx, name: 'parseNcx' }]); | ||
}; | ||
context.options = (0, _parserCore.mergeObjects)(EpubParser.parseDefaultOptions, options); | ||
_context2.next = 5; | ||
return (0, _parserCore.readEntries)(this.input, this.cryptoProvider); | ||
/** | ||
* @returns {ParseTask[]} return after tasks | ||
*/ | ||
case 5: | ||
context.entries = _context2.sent; | ||
return _context2.abrupt('return', context); | ||
case 7: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
EpubParser.prototype._parseAfterTasks = function _parseAfterTasks() { | ||
return [].concat((0, _toConsumableArray3.default)(_Parser.prototype._parseAfterTasks.call(this)), [{ func: this._checkResult, name: 'checkResult' }]); | ||
}; | ||
function _prepareParse() { | ||
return _ref2.apply(this, arguments); | ||
} | ||
return _prepareParse; | ||
}(); | ||
/** | ||
* Validate package spec if zip source and validatePackage option specified | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context (no change at this step) | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context (no change at this step) | ||
* @throws {Errors.EINVAL} invalid package | ||
@@ -407,8 +300,8 @@ * @see EpubParser.parseDefaultOptions.validatePackage | ||
EpubParser.prototype._validatePackageIfNeeded = function () { | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(context) { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(context) { | ||
var entries, options, firstEntry, signature, reason, _reason; | ||
return _regenerator2.default.wrap(function _callee3$(_context3) { | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
@@ -418,3 +311,3 @@ entries = context.entries, options = context.options; | ||
if (!(!(0, _parserCore.isString)(entries.source) && options.validatePackage)) { | ||
_context3.next = 22; | ||
_context.next = 22; | ||
break; | ||
@@ -425,10 +318,10 @@ } | ||
_context3.next = 5; | ||
_context.next = 5; | ||
return firstEntry.getFile('utf8'); | ||
case 5: | ||
signature = _context3.sent; | ||
signature = _context.sent; | ||
if (!(firstEntry.entryPath !== 'mimetype')) { | ||
_context3.next = 10; | ||
_context.next = 10; | ||
break; | ||
@@ -441,3 +334,3 @@ } | ||
if (!(firstEntry.method !== 0 /* STORED */)) { | ||
_context3.next = 14; | ||
_context.next = 14; | ||
break; | ||
@@ -450,3 +343,3 @@ } | ||
if (!(signature !== 'application/epub+zip')) { | ||
_context3.next = 19; | ||
_context.next = 19; | ||
break; | ||
@@ -460,3 +353,3 @@ } | ||
if (!(firstEntry.extraFieldLength > 0)) { | ||
_context3.next = 22; | ||
_context.next = 22; | ||
break; | ||
@@ -469,14 +362,14 @@ } | ||
case 22: | ||
return _context3.abrupt('return', context); | ||
return _context.abrupt('return', context); | ||
case 23: | ||
case 'end': | ||
return _context3.stop(); | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee, this); | ||
})); | ||
function _validatePackageIfNeeded(_x3) { | ||
return _ref3.apply(this, arguments); | ||
function _validatePackageIfNeeded(_x) { | ||
return _ref.apply(this, arguments); | ||
} | ||
@@ -489,4 +382,4 @@ | ||
* Locate OPF and base path in container.xml | ||
* @param {Context} context intermediate result | ||
* @return {Promise.<Context>} return Context containing OPF and base path | ||
* @param {ParseContext} context intermediate result | ||
* @return {Promise.<ParseContext>} return Context containing OPF and base path | ||
* @throws {Errors.ENOFILE} container.xml not found | ||
@@ -500,8 +393,8 @@ * @throws {Errors.EINVAL} invalid XML | ||
EpubParser.prototype._parseMetaInf = function () { | ||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(context) { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(context) { | ||
var entryPath, containerEntry, _xmlLoader, container, rootfiles, rootfile, opfPath; | ||
return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
@@ -512,3 +405,3 @@ entryPath = 'META-INF/container.xml'; | ||
if ((0, _parserCore.isExists)(containerEntry)) { | ||
_context4.next = 4; | ||
_context2.next = 4; | ||
break; | ||
@@ -520,13 +413,13 @@ } | ||
case 4: | ||
_context4.t0 = _xmlLoader5.default; | ||
_context4.next = 7; | ||
_context2.t0 = _xmlLoader5.default; | ||
_context2.next = 7; | ||
return containerEntry.getFile('utf8'); | ||
case 7: | ||
_context4.t1 = _context4.sent; | ||
_xmlLoader = (0, _context4.t0)(_context4.t1); | ||
_context2.t1 = _context2.sent; | ||
_xmlLoader = (0, _context2.t0)(_context2.t1); | ||
container = _xmlLoader.container; | ||
if ((0, _parserCore.isExists)(container)) { | ||
_context4.next = 12; | ||
_context2.next = 12; | ||
break; | ||
@@ -539,3 +432,3 @@ } | ||
if ((0, _parserCore.isExists)(container.rootfiles)) { | ||
_context4.next = 14; | ||
_context2.next = 14; | ||
break; | ||
@@ -555,3 +448,3 @@ } | ||
if ((0, _parserCore.isExists)(rootfile)) { | ||
_context4.next = 18; | ||
_context2.next = 18; | ||
break; | ||
@@ -566,3 +459,3 @@ } | ||
if ((0, _parserCore.isExists)(opfPath)) { | ||
_context4.next = 21; | ||
_context2.next = 21; | ||
break; | ||
@@ -578,14 +471,14 @@ } | ||
return _context4.abrupt('return', context); | ||
return _context2.abrupt('return', context); | ||
case 24: | ||
case 'end': | ||
return _context4.stop(); | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee2, this); | ||
})); | ||
function _parseMetaInf(_x4) { | ||
return _ref4.apply(this, arguments); | ||
function _parseMetaInf(_x2) { | ||
return _ref2.apply(this, arguments); | ||
} | ||
@@ -598,4 +491,4 @@ | ||
* OPF parsing | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context containing OPF parsing result | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context containing OPF parsing result | ||
* @throws {Errors.EINVAL} invalid xml | ||
@@ -608,14 +501,14 @@ * @throws {Errors.ENOFILE} OPF not found | ||
EpubParser.prototype._parseOpf = function () { | ||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(context) { | ||
var _context5, entries, opfPath, opfEntry, _xmlLoader2, root; | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(context) { | ||
var _context3, entries, opfPath, opfEntry, _xmlLoader2, root; | ||
return _regenerator2.default.wrap(function _callee5$(_context6) { | ||
return _regenerator2.default.wrap(function _callee3$(_context4) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context5 = context, entries = _context5.entries, opfPath = _context5.opfPath; | ||
_context3 = context, entries = _context3.entries, opfPath = _context3.opfPath; | ||
opfEntry = entries.find(opfPath); | ||
if ((0, _parserCore.isExists)(opfEntry)) { | ||
_context6.next = 4; | ||
_context4.next = 4; | ||
break; | ||
@@ -627,13 +520,13 @@ } | ||
case 4: | ||
_context6.t0 = _xmlLoader5.default; | ||
_context6.next = 7; | ||
_context4.t0 = _xmlLoader5.default; | ||
_context4.next = 7; | ||
return opfEntry.getFile('utf8'); | ||
case 7: | ||
_context6.t1 = _context6.sent; | ||
_xmlLoader2 = (0, _context6.t0)(_context6.t1); | ||
_context4.t1 = _context4.sent; | ||
_xmlLoader2 = (0, _context4.t0)(_context4.t1); | ||
root = _xmlLoader2.package; | ||
if ((0, _parserCore.isExists)(root)) { | ||
_context6.next = 12; | ||
_context4.next = 12; | ||
break; | ||
@@ -646,3 +539,3 @@ } | ||
if (!(!(0, _parserCore.isExists)(root.metadata) || !(0, _parserCore.isExists)(root.manifest) || !(0, _parserCore.isExists)(root.spine))) { | ||
_context6.next = 14; | ||
_context4.next = 14; | ||
break; | ||
@@ -656,29 +549,29 @@ } | ||
context.rawBook.version = root.version; | ||
_context6.next = 17; | ||
_context4.next = 17; | ||
return this._parseMetadata(root.metadata, context); | ||
case 17: | ||
context = _context6.sent; | ||
_context6.next = 20; | ||
context = _context4.sent; | ||
_context4.next = 20; | ||
return this._parseManifestAndSpine(root.manifest, root.spine, context); | ||
case 20: | ||
context = _context6.sent; | ||
_context6.next = 23; | ||
context = _context4.sent; | ||
_context4.next = 23; | ||
return this._parseGuide(root.guide, context); | ||
case 23: | ||
context = _context6.sent; | ||
return _context6.abrupt('return', context); | ||
context = _context4.sent; | ||
return _context4.abrupt('return', context); | ||
case 25: | ||
case 'end': | ||
return _context6.stop(); | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee5, this); | ||
}, _callee3, this); | ||
})); | ||
function _parseOpf(_x5) { | ||
return _ref5.apply(this, arguments); | ||
function _parseOpf(_x3) { | ||
return _ref3.apply(this, arguments); | ||
} | ||
@@ -692,4 +585,4 @@ | ||
* @param {object} metadata metadata AST | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context containing metadata | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context containing metadata | ||
*/ | ||
@@ -750,4 +643,4 @@ | ||
* @param {object} spine spine AST | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context containing manifest and spine | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context containing manifest and spine | ||
* @see EpubParser.parseDefaultOptions.parseStyle | ||
@@ -759,9 +652,9 @@ * @see EpubParser.parseDefaultOptions.styleNamespacePrefix | ||
EpubParser.prototype._parseManifestAndSpine = function () { | ||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(manifest, spine, context) { | ||
var _this = this; | ||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(manifest, spine, context) { | ||
var _this2 = this; | ||
var rawBook, basePath, options, entries, tocId, items, itemRefs, coverMeta, inlineStyles; | ||
return _regenerator2.default.wrap(function _callee7$(_context8) { | ||
return _regenerator2.default.wrap(function _callee5$(_context6) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
@@ -779,10 +672,10 @@ rawBook = context.rawBook, basePath = context.basePath, options = context.options, entries = context.entries; | ||
rawBook.items = []; | ||
_context8.next = 9; | ||
_context6.next = 9; | ||
return items.reduce(function (prevPromise, item, idx) { | ||
// eslint-disable-line arrow-body-style | ||
return prevPromise.then((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() { | ||
return prevPromise.then((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() { | ||
var rawItem, itemEntry, refIndex, ref, result; | ||
return _regenerator2.default.wrap(function _callee6$(_context7) { | ||
return _regenerator2.default.wrap(function _callee4$(_context5) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -797,6 +690,6 @@ rawItem = {}; | ||
rawItem.mediaType = item['media-type']; | ||
rawItem.itemType = _this.getItemTypeFromMediaType(rawItem.mediaType); | ||
rawItem.itemType = _this2.getItemTypeFromMediaType(rawItem.mediaType); | ||
if (rawItem.itemType === _DeadItem2.default) { | ||
rawItem.reason = _DeadItem2.default.Reason.NOT_SUPPORT_TYPE; | ||
_parserCore.Logger.warn('Referenced resource \'' + rawItem.id + '\' ignored. (reason: ' + rawItem.reason + ')'); | ||
_this2.logger.warn('Referenced resource \'%s\' ignored. (reason: %s)', rawItem.id, rawItem.reason); | ||
} | ||
@@ -807,3 +700,3 @@ | ||
if (!(0, _parserCore.isExists)(itemEntry)) { | ||
_context7.next = 23; | ||
_context5.next = 23; | ||
break; | ||
@@ -826,9 +719,7 @@ } | ||
rawItem.isLinear = (0, _parserCore.isExists)(ref.linear) ? (0, _parserCore.parseBool)(ref.linear) : true; | ||
if (options.ignoreLinear || rawItem.isLinear) { | ||
rawItem.index = refIndex; | ||
} | ||
rawItem.index = refIndex; | ||
} else { | ||
rawItem.itemType = _DeadItem2.default; | ||
rawItem.reason = _DeadItem2.default.Reason.NOT_SPINE; | ||
_parserCore.Logger.warn('Referenced resource \'' + rawItem.id + '\' ignored. (reason: ' + rawItem.reason + ')'); | ||
_this2.logger.warn('Referenced resource \'%s\' ignored. (reason: %s)', rawItem.id, rawItem.reason); | ||
} | ||
@@ -854,3 +745,3 @@ } else if (rawItem.itemType === _ImageItem2.default) { | ||
rawItem.reason = _DeadItem2.default.Reason.NOT_NCX; | ||
_parserCore.Logger.warn('Referenced resource \'' + rawItem.id + '\' ignored. (reason: ' + rawItem.reason + ')'); | ||
_this2.logger.warn('Referenced resource \'%s\' ignored. (reason: %s)', rawItem.id, rawItem.reason); | ||
} | ||
@@ -860,3 +751,3 @@ } | ||
if (!options.parseStyle) { | ||
_context7.next = 21; | ||
_context5.next = 21; | ||
break; | ||
@@ -866,3 +757,3 @@ } | ||
if (!(rawItem.itemType === _CssItem2.default)) { | ||
_context7.next = 15; | ||
_context5.next = 15; | ||
break; | ||
@@ -872,3 +763,3 @@ } | ||
rawItem.namespace = '' + options.styleNamespacePrefix + idx; | ||
_context7.next = 21; | ||
_context5.next = 21; | ||
break; | ||
@@ -878,11 +769,11 @@ | ||
if (!(rawItem.itemType === _SpineItem2.default)) { | ||
_context7.next = 21; | ||
_context5.next = 21; | ||
break; | ||
} | ||
_context7.next = 18; | ||
return _this._parseSpineStyle(rawItem, itemEntry, options); | ||
_context5.next = 18; | ||
return _this2._parseSpineStyle(rawItem, itemEntry, options); | ||
case 18: | ||
result = _context7.sent; | ||
result = _context5.sent; | ||
@@ -893,3 +784,3 @@ rawItem.styles = result.styles; | ||
case 21: | ||
_context7.next = 26; | ||
_context5.next = 26; | ||
break; | ||
@@ -900,3 +791,3 @@ | ||
rawItem.reason = _DeadItem2.default.Reason.NOT_EXISTS; | ||
_parserCore.Logger.warn('Referenced resource \'' + rawItem.id + '\' ignored. (reason: ' + rawItem.reason + ')'); | ||
_this2.logger.warn('Referenced resource \'%s\' ignored. (reason: %s)', rawItem.id, rawItem.reason); | ||
@@ -908,6 +799,6 @@ case 26: | ||
case 'end': | ||
return _context7.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee6, _this); | ||
}, _callee4, _this2); | ||
}))); | ||
@@ -920,14 +811,14 @@ }, _promise2.default.resolve()); | ||
return _context8.abrupt('return', context); | ||
return _context6.abrupt('return', context); | ||
case 11: | ||
case 'end': | ||
return _context8.stop(); | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
}, _callee5, this); | ||
})); | ||
function _parseManifestAndSpine(_x6, _x7, _x8) { | ||
return _ref6.apply(this, arguments); | ||
function _parseManifestAndSpine(_x4, _x5, _x6) { | ||
return _ref4.apply(this, arguments); | ||
} | ||
@@ -953,7 +844,7 @@ | ||
EpubParser.prototype._parseSpineStyle = function () { | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(rawItem, entry, options) { | ||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(rawItem, entry, options) { | ||
var styles, inlineStyles, find, filter, document, html, head; | ||
return _regenerator2.default.wrap(function _callee8$(_context9) { | ||
return _regenerator2.default.wrap(function _callee6$(_context7) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
@@ -975,9 +866,9 @@ styles = []; | ||
_context9.t0 = _himalaya.parse; | ||
_context9.next = 7; | ||
_context7.t0 = _himalaya.parse; | ||
_context7.next = 7; | ||
return entry.getFile('utf8'); | ||
case 7: | ||
_context9.t1 = _context9.sent; | ||
document = (0, _context9.t0)(_context9.t1); | ||
_context7.t1 = _context7.sent; | ||
document = (0, _context7.t0)(_context7.t1); | ||
html = find(document, 'tagName', 'html'); | ||
@@ -1027,14 +918,14 @@ head = find(html.children, 'tagName', 'head'); | ||
return _context9.abrupt('return', { styles: styles, inlineStyles: inlineStyles }); | ||
return _context7.abrupt('return', { styles: styles, inlineStyles: inlineStyles }); | ||
case 14: | ||
case 'end': | ||
return _context9.stop(); | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee8, this); | ||
}, _callee6, this); | ||
})); | ||
function _parseSpineStyle(_x9, _x10, _x11) { | ||
return _ref8.apply(this, arguments); | ||
function _parseSpineStyle(_x7, _x8, _x9) { | ||
return _ref6.apply(this, arguments); | ||
} | ||
@@ -1048,4 +939,4 @@ | ||
* @param {object} guide guide AST | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context containing guide | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context containing guide | ||
*/ | ||
@@ -1081,4 +972,4 @@ | ||
* NCX parsing | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context containing ncx if exists | ||
* @param {ParseContext} context intermediate result | ||
* @returns {Promise.<ParseContext>} return Context containing ncx if exists | ||
* @throws {Errors.EINVAL} invalid XML | ||
@@ -1093,8 +984,8 @@ * @throws {Errors.EINVAL} can not found ncx attribute OPF | ||
EpubParser.prototype._parseNcx = function () { | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(context) { | ||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(context) { | ||
var rawBook, entries, options, allowNcxFileMissing, ncxItem, ncxEntry, _xmlLoader3, ncx, normalizeSrc, keyTranslator; | ||
return _regenerator2.default.wrap(function _callee9$(_context10) { | ||
return _regenerator2.default.wrap(function _callee7$(_context8) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
@@ -1108,3 +999,3 @@ rawBook = context.rawBook, entries = context.entries, options = context.options; | ||
if (!(0, _parserCore.isExists)(ncxItem)) { | ||
_context10.next = 23; | ||
_context8.next = 23; | ||
break; | ||
@@ -1116,3 +1007,3 @@ } | ||
if (!(!allowNcxFileMissing && !(0, _parserCore.isExists)(ncxEntry))) { | ||
_context10.next = 7; | ||
_context8.next = 7; | ||
break; | ||
@@ -1124,13 +1015,13 @@ } | ||
case 7: | ||
_context10.t0 = _xmlLoader5.default; | ||
_context10.next = 10; | ||
_context8.t0 = _xmlLoader5.default; | ||
_context8.next = 10; | ||
return ncxEntry.getFile('utf8'); | ||
case 10: | ||
_context10.t1 = _context10.sent; | ||
_xmlLoader3 = (0, _context10.t0)(_context10.t1); | ||
_context8.t1 = _context8.sent; | ||
_xmlLoader3 = (0, _context8.t0)(_context8.t1); | ||
ncx = _xmlLoader3.ncx; | ||
if ((0, _parserCore.isExists)(ncx)) { | ||
_context10.next = 15; | ||
_context8.next = 15; | ||
break; | ||
@@ -1143,3 +1034,3 @@ } | ||
if ((0, _parserCore.isExists)(ncx.navMap)) { | ||
_context10.next = 17; | ||
_context8.next = 17; | ||
break; | ||
@@ -1175,3 +1066,3 @@ } | ||
}); | ||
_context10.next = 25; | ||
_context8.next = 25; | ||
break; | ||
@@ -1181,3 +1072,3 @@ | ||
if (allowNcxFileMissing) { | ||
_context10.next = 25; | ||
_context8.next = 25; | ||
break; | ||
@@ -1189,14 +1080,14 @@ } | ||
case 25: | ||
return _context10.abrupt('return', context); | ||
return _context8.abrupt('return', context); | ||
case 26: | ||
case 'end': | ||
return _context10.stop(); | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee9, this); | ||
}, _callee7, this); | ||
})); | ||
function _parseNcx(_x12) { | ||
return _ref9.apply(this, arguments); | ||
function _parseNcx(_x10) { | ||
return _ref7.apply(this, arguments); | ||
} | ||
@@ -1208,224 +1099,14 @@ | ||
/** | ||
* Unzipping if zip source and unzipPath option specified | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Context>} return Context (no change at this step) | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @see EpubParser.parseDefaultOptions.unzipPath | ||
* @see EpubParser.parseDefaultOptions.overwrite | ||
* @param {Book} book | ||
*/ | ||
EpubParser.prototype._unzipIfNeeded = function () { | ||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(context) { | ||
var options, entries, unzipPath, overwrite; | ||
return _regenerator2.default.wrap(function _callee10$(_context11) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
options = context.options, entries = context.entries; | ||
unzipPath = options.unzipPath, overwrite = options.overwrite; | ||
if (!(!(0, _parserCore.isString)(entries.source) && (0, _parserCore.isExists)(unzipPath))) { | ||
_context11.next = 6; | ||
break; | ||
} | ||
_context11.next = 5; | ||
return entries.source.extractAll(unzipPath, overwrite); | ||
case 5: | ||
privateProps.set(this, (0, _extends3.default)({}, privateProps.get(this), { input: unzipPath })); | ||
case 6: | ||
return _context11.abrupt('return', context); | ||
case 7: | ||
case 'end': | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee10, this); | ||
})); | ||
function _unzipIfNeeded(_x13) { | ||
return _ref10.apply(this, arguments); | ||
EpubParser.prototype._checkResult = function _checkResult(book) { | ||
if (!(0, _parserCore.isExists)(book.cover)) { | ||
this.logger.warn('Cover image not found in EPUB.'); | ||
} | ||
return _unzipIfNeeded; | ||
}(); | ||
/** | ||
* Create new Book from context | ||
* @param {Context} context intermediate result | ||
* @returns {Promise.<Book>} return Book | ||
*/ | ||
EpubParser.prototype._createBook = function _createBook(context) { | ||
return new _promise2.default(function (resolve) { | ||
resolve(new _Book2.default(context.rawBook)); | ||
}); | ||
return book; | ||
}; | ||
/** | ||
* Reading contents of Item | ||
* @param {Item} item target | ||
* @param {?object} options read options | ||
* @returns {(string|Buffer)} reading result | ||
* @see EpubParser.readDefaultOptions | ||
* @see EpubParser.readOptionTypes | ||
* @example | ||
* const options = { ... }; | ||
* parse.readItem(book.spine[0], options).then((result) => { | ||
* ... | ||
* }); | ||
*/ | ||
EpubParser.prototype.readItem = function () { | ||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(item) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var results; | ||
return _regenerator2.default.wrap(function _callee11$(_context12) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
_context12.next = 2; | ||
return this.readItems([item], options); | ||
case 2: | ||
results = _context12.sent; | ||
return _context12.abrupt('return', results[0]); | ||
case 4: | ||
case 'end': | ||
return _context12.stop(); | ||
} | ||
} | ||
}, _callee11, this); | ||
})); | ||
function readItem(_x15) { | ||
return _ref11.apply(this, arguments); | ||
} | ||
return readItem; | ||
}(); | ||
/** | ||
* Reading contents of Items | ||
* @param {Item[]} items targets | ||
* @param {?object} options read options | ||
* @returns {(string|Buffer)[]} reading results | ||
* @see EpubParser.readDefaultOptions | ||
* @see EpubParser.readOptionTypes | ||
* @example | ||
* const options = { ... }; | ||
* parse.readItems(book.styles, options).then((results) => { | ||
* ... | ||
* }); | ||
*/ | ||
EpubParser.prototype.readItems = function () { | ||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(items) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var context, results; | ||
return _regenerator2.default.wrap(function _callee12$(_context13) { | ||
while (1) { | ||
switch (_context13.prev = _context13.next) { | ||
case 0: | ||
_context13.next = 2; | ||
return this._prepareRead(items, options); | ||
case 2: | ||
context = _context13.sent; | ||
_context13.next = 5; | ||
return this._read(context); | ||
case 5: | ||
results = _context13.sent; | ||
return _context13.abrupt('return', results); | ||
case 7: | ||
case 'end': | ||
return _context13.stop(); | ||
} | ||
} | ||
}, _callee12, this); | ||
})); | ||
function readItems(_x17) { | ||
return _ref12.apply(this, arguments); | ||
} | ||
return readItems; | ||
}(); | ||
/** | ||
* @typedef ReadContext | ||
* @property {Item[]} items targets | ||
* @property {object} entries from input | ||
* @property {object} options read options | ||
*/ | ||
/** | ||
* Validate read options and get entries from input | ||
* @param {Item[]} items targets | ||
* @param {?object} options read options | ||
* @returns {Promise.<ReadContext>} | ||
* returns ReadContext containing target items, read options, entries | ||
* @throws {Errors.EINVAL} invalid options or value type | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @throws {Errors.ENOFILE} no such file | ||
* @see EpubParser.readDefaultOptions | ||
* @see EpubParser.readOptionTypes | ||
*/ | ||
EpubParser.prototype._prepareRead = function () { | ||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(items) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var entries; | ||
return _regenerator2.default.wrap(function _callee13$(_context14) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
if (!items.find(function (item) { | ||
return !(item instanceof _Item2.default); | ||
})) { | ||
_context14.next = 2; | ||
break; | ||
} | ||
throw (0, _parserCore.createError)(_parserCore.Errors.EINVAL, 'item', 'reason', 'item must be Item type'); | ||
case 2: | ||
(0, _parserCore.validateOptions)(options, EpubParser.readOptionTypes); | ||
_context14.next = 5; | ||
return (0, _parserCore.readEntries)(this.input, this.cryptoProvider); | ||
case 5: | ||
entries = _context14.sent; | ||
return _context14.abrupt('return', { | ||
items: items, | ||
entries: entries, | ||
options: (0, _parserCore.mergeObjects)(EpubParser.readDefaultOptions, options) | ||
}); | ||
case 7: | ||
case 'end': | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee13, this); | ||
})); | ||
function _prepareRead(_x19) { | ||
return _ref13.apply(this, arguments); | ||
} | ||
return _prepareRead; | ||
}(); | ||
/** | ||
* Contents is read using loader suitable for context | ||
@@ -1439,23 +1120,23 @@ * @param {ReadContext} context properties required for reading | ||
EpubParser.prototype._read = function () { | ||
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15(context) { | ||
var _this2 = this; | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(context) { | ||
var _this3 = this; | ||
var items, entries, options, results; | ||
return _regenerator2.default.wrap(function _callee15$(_context16) { | ||
return _regenerator2.default.wrap(function _callee9$(_context10) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
items = context.items, entries = context.entries, options = context.options; | ||
results = []; | ||
_context16.next = 4; | ||
_context10.next = 4; | ||
return items.reduce(function (prevPromise, item) { | ||
// eslint-disable-line arrow-body-style | ||
return prevPromise.then((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() { | ||
return prevPromise.then((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8() { | ||
var entry, file; | ||
return _regenerator2.default.wrap(function _callee14$(_context15) { | ||
return _regenerator2.default.wrap(function _callee8$(_context9) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
if (!(item instanceof _InlineCssItem2.default)) { | ||
_context15.next = 3; | ||
_context9.next = 3; | ||
break; | ||
@@ -1465,3 +1146,3 @@ } | ||
results.push((0, _cssLoader2.default)(item, item.text, options)); | ||
return _context15.abrupt('return'); | ||
return _context9.abrupt('return'); | ||
@@ -1472,3 +1153,3 @@ case 3: | ||
if ((0, _parserCore.isExists)(entry)) { | ||
_context15.next = 6; | ||
_context9.next = 6; | ||
break; | ||
@@ -1480,7 +1161,7 @@ } | ||
case 6: | ||
_context15.next = 8; | ||
_context9.next = 8; | ||
return entry.getFile(item.defaultEncoding); | ||
case 8: | ||
file = _context15.sent; | ||
file = _context9.sent; | ||
@@ -1497,6 +1178,6 @@ if (item instanceof _SpineItem2.default) { | ||
case 'end': | ||
return _context15.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee14, _this2); | ||
}, _callee8, _this3); | ||
}))); | ||
@@ -1506,14 +1187,14 @@ }, _promise2.default.resolve()); | ||
case 4: | ||
return _context16.abrupt('return', results); | ||
return _context10.abrupt('return', results); | ||
case 5: | ||
case 'end': | ||
return _context16.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee15, this); | ||
}, _callee9, this); | ||
})); | ||
function _read(_x20) { | ||
return _ref14.apply(this, arguments); | ||
function _read(_x11) { | ||
return _ref8.apply(this, arguments); | ||
} | ||
@@ -1564,5 +1245,5 @@ | ||
return EpubParser; | ||
}(); | ||
}(_parserCore.Parser); | ||
exports.default = EpubParser; | ||
module.exports = exports.default; |
@@ -13,2 +13,8 @@ 'use strict'; | ||
var _Book = require('./model/Book'); | ||
var EpubBook = _interopRequireWildcard(_Book); | ||
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 }; } | ||
@@ -19,6 +25,7 @@ | ||
Errors: _parserCore.Errors, | ||
Logger: _parserCore.Logger, | ||
LogLevel: _parserCore.LogLevel, | ||
CryptoProvider: _parserCore.CryptoProvider, | ||
Cryptor: _parserCore.Cryptor | ||
Cryptor: _parserCore.Cryptor, | ||
EpubBook: EpubBook | ||
}; | ||
module.exports = exports.default; |
@@ -78,3 +78,3 @@ 'use strict'; | ||
spines.sort(function (s1, s2) { | ||
return s1.index < 0 || s2.index < 0 ? 0 : s1.index - s2.index; | ||
return s1.index - s2.index; | ||
}).forEach(function (spine, idx, list) { | ||
@@ -81,0 +81,0 @@ var prevSpine = list[idx - 1]; |
@@ -35,4 +35,2 @@ 'use strict'; | ||
var ignoredIndex = -1; | ||
var SpineItem = function (_Item) { | ||
@@ -54,3 +52,3 @@ (0, _inherits3.default)(SpineItem, _Item); | ||
_this.index = (0, _parserCore.isExists)(rawObj.index) ? rawObj.index : ignoredIndex; | ||
_this.index = rawObj.index; | ||
_this.isLinear = (0, _parserCore.isExists)(rawObj.isLinear) ? rawObj.isLinear : true; | ||
@@ -95,5 +93,3 @@ if ((0, _parserCore.isExists)(rawObj.styles)) { | ||
SpineItem.IGNORED_INDEX = ignoredIndex; | ||
exports.default = SpineItem; | ||
module.exports = exports.default; |
{ | ||
"name": "@ridi/epub-parser", | ||
"version": "0.3.0-alpha.5", | ||
"version": "0.3.0-alpha-10", | ||
"description": "Common EPUB2 data parser for Ridibooks services", | ||
@@ -31,3 +31,3 @@ "author": { | ||
"dependencies": { | ||
"@ridi/parser-core": "^0.3.0-alpha.5", | ||
"@ridi/parser-core": "^0.3.0-alpha-10", | ||
"css-tree": "^1.0.0-alpha.29", | ||
@@ -34,0 +34,0 @@ "fast-xml-parser": "^3.11.2", |
@@ -314,3 +314,2 @@ # @ridi/epub-parser | ||
* [overwrite](#overwrite) | ||
* [ignoreLinear](#ignoreLinear) | ||
* [parseStyle](#parseStyle) | ||
@@ -351,3 +350,3 @@ * [styleNamespacePrefix](#styleNamespacePrefix) | ||
If specified, uncompress to that path. | ||
If specified, unzip to that path. | ||
> only using if input is EPUB file. | ||
@@ -363,3 +362,3 @@ | ||
If true, overwrite to [unzipPath](#unzipPath) when uncompress. | ||
If true, overwrite to [unzipPath](#unzipPath) when unzip. | ||
> only using if unzipPath specified. | ||
@@ -371,20 +370,2 @@ | ||
<a id="ignoreLinear"></a> | ||
### ignoreLinear: *`boolean`* | ||
If true, ignore `index` difference caused by `isLinear` property of [SpineItem](#spineItem). | ||
```js | ||
// e.g. If left is false, right is true. | ||
[{ index: 0, isLinear: true, ... }, [{ index: 0, isLinear: true, ... }, | ||
{ index: 1, isLinear: true, ... }, { index: 1, isLinear: true, ... }, | ||
{ index: -2, isLinear: false, ... }, { index: 2, isLinear: false, ... }, | ||
{ index: 3, isLinear: true, ... }] { index: 3, isLinear: true, ... }] | ||
``` | ||
**Default:** `false` | ||
--- | ||
<a id="parseStyle"></a> | ||
@@ -391,0 +372,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
27
0
110522
2355
549