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

@ridi/epub-parser

Package Overview
Dependencies
Maintainers
7
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ridi/epub-parser - npm Package Compare versions

Comparing version

to
0.7.1

lib/model/BaseEpubItem.js

256

lib/EpubParser.js

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

var _Book = _interopRequireDefault(require("./model/Book"));
var _EpubBook = _interopRequireDefault(require("./model/EpubBook"));

@@ -53,7 +53,7 @@ var _CssItem = _interopRequireDefault(require("./model/CssItem"));

var _Item = _interopRequireDefault(require("./model/Item"));
var _BaseEpubItem = _interopRequireDefault(require("./model/BaseEpubItem"));
var _NcxItem = _interopRequireDefault(require("./model/NcxItem"));
var _ReadContext = _interopRequireDefault(require("./model/ReadContext"));
var _EpubReadContext = _interopRequireDefault(require("./model/EpubReadContext"));

@@ -66,3 +66,3 @@ var _SpineItem = _interopRequireDefault(require("./model/SpineItem"));

var _ParseContext = _interopRequireDefault(require("./model/ParseContext"));
var _EpubParseContext = _interopRequireDefault(require("./model/EpubParseContext"));

@@ -79,3 +79,3 @@ var _xmlLoader4 = _interopRequireWildcard(require("./loader/xmlLoader"));

var EpubParser = /*#__PURE__*/function (_Parser) {
var EpubParser = function (_Parser) {
(0, _inherits2["default"])(EpubParser, _Parser);

@@ -87,31 +87,11 @@

key: "parseDefaultOptions",
/**
* Get default values of parse options
*/
get: function get() {
return _objectSpread(_objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(EpubParser), "parseDefaultOptions", this)), {}, {
// If true, validation package specifications in IDPF listed below. (used only if input is EPUB file.)
// - Zip header should not corrupt.
// - mimetype file must be first file in archive.
// - mimetype file should not compressed.
// - mimetype file should only contain string 'application/epub+zip'.
// - Shouldn't use extra field feature of ZIP format for mimetype file.
validatePackage: false,
// If false, stop parsing when NCX file not exists.
allowNcxFileMissing: true,
// If true, styles used for spine is described, and one namespace is given per CSS file or inline style.
// Otherwise it CssItem.namespace, SpineItem.styles is undefined.
// In any list, InlineCssItem is always positioned after CssItem. (Book.styles, Book.items, SpineItem.styles, ...)
parseStyle: true,
// Prepend given string to namespace for identification. (only available if parseStyle is true.)
styleNamespacePrefix: 'ridi_style',
// If specified, added inline styles to all spines. (only available if parseStyle is true.)
additionalInlineStyle: undefined
});
}
/**
* Get types of parse options
*/
}, {

@@ -128,6 +108,2 @@ key: "parseOptionTypes",

}
/**
* Get default values of read options
*/
}, {

@@ -137,27 +113,12 @@ key: "readDefaultOptions",

return _objectSpread(_objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(EpubParser), "readDefaultOptions", this)), {}, {
// If specified, change base path of paths used by spine and css.
// e.g. '../Images/cover.jpg' -> '{basePath}/OEBPS/Images/cover.jpg'
basePath: undefined,
// If true, extract body. Otherwise it returns a full string.
// If specify a function instead of true, use function to transform body.
// e.g. extractBody: (innerHTML, attrs) => `<body>${innerHTML}</body>`
extractBody: false,
// If true, replace file path of anchor in spine with spine index.
serializedAnchor: false,
// If true, ignore all scripts from within HTML.
ignoreScript: false,
// Remove at-rules.
removeAtrules: [],
// Remove selector that point to specified tags.
removeTagSelector: [],
// Remove selector that point to specified ids.
removeIdSelector: [],
// Remove selector that point to specified classes.
removeClassSelector: []
});
}
/**
* Get types of read option
*/
}, {

@@ -177,12 +138,2 @@ key: "readOptionTypes",

}
/**
* Create new EpubParser
* @param {string} input file or directory
* @param {?CryptoProvider} cryptoProvider en/decrypto provider
* @param {?string} logLevel logging level
* @throws {Errors.ENOENT} no such file or directory
* @throws {Errors.EINVAL} invalid input
* @example new EpubParser('./foo/bar.epub' or './foo/bar');
*/
}]);

@@ -192,4 +143,2 @@

(0, _classCallCheck2["default"])(this, EpubParser);
/* istanbul ignore next */
logLevel = (0, _parserCore.isString)(cryptoProvider) ? cryptoProvider : logLevel;

@@ -202,43 +151,23 @@ cryptoProvider = (0, _parserCore.isString)(cryptoProvider) ? undefined : cryptoProvider;

}
/**
* @returns {ParseContext}
*/
(0, _createClass2["default"])(EpubParser, [{
key: "_getParseContextClass",
value: function _getParseContextClass() {
return _ParseContext["default"];
return _EpubParseContext["default"];
}
/**
* @returns {Book}
*/
}, {
key: "_getBookClass",
value: function _getBookClass() {
return _Book["default"];
return _EpubBook["default"];
}
/**
* @returns {ReadContext}
*/
}, {
key: "_getReadContextClass",
value: function _getReadContextClass() {
return _ReadContext["default"];
return _EpubReadContext["default"];
}
/**
* @returns {Item}
*/
}, {
key: "_getReadItemClass",
value: function _getReadItemClass() {
return _Item["default"];
return _BaseEpubItem["default"];
}
/**
* @returns {ParseTask[]} return before tasks
*/
}, {

@@ -258,6 +187,2 @@ key: "_parseBeforeTasks",

}
/**
* @returns {ParseTask[]} return tasks
*/
}, {

@@ -277,6 +202,2 @@ key: "_parseTasks",

}
/**
* @returns {ParseTask[]} return after tasks
*/
}, {

@@ -290,14 +211,6 @@ key: "_parseAfterTasks",

}
/**
* Validate package spec if zip source and validatePackage option specified
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context (no change at this step)
* @throws {Errors.EINVAL} invalid package
* @see EpubParser.parseDefaultOptions.validatePackage
*/
}, {
key: "_validatePackageIfNeeded",
value: function () {
var _validatePackageIfNeeded2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(context) {
var _validatePackageIfNeeded2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(context) {
var entries, options, firstEntry, signature, reason, _reason;

@@ -333,5 +246,3 @@

case 10:
if (!(firstEntry.method !== 0
/* STORED */
)) {
if (!(firstEntry.method !== 0)) {
_context.next = 14;

@@ -378,16 +289,6 @@ break;

}()
/**
* Locate OPF and base path in container.xml
* @param {ParseContext} context intermediate result
* @return {Promise.<ParseContext>} return Context containing OPF and base path
* @throws {Errors.ENOFILE} container.xml not found
* @throws {Errors.EINVAL} invalid XML
* @throws {Errors.ENOELMT} no such element in container.xml
* @throws {Errors.ENOATTR} no such attribute in element
*/
}, {
key: "_parseMetaInf",
value: function () {
var _parseMetaInf2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(context) {
var _parseMetaInf2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(context) {
var entryPath, containerEntry, _xmlLoader, container, rootfiles, rootfile, opfPath;

@@ -478,15 +379,6 @@

}()
/**
* OPF parsing
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context containing OPF parsing result
* @throws {Errors.EINVAL} invalid xml
* @throws {Errors.ENOFILE} OPF not found
* @throws {Errors.ENOELMT} no such element in OPF
*/
}, {
key: "_parseOpf",
value: function () {
var _parseOpf2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(context) {
var _parseOpf2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(context) {
var _context3, entries, opfPath, opfEntry, _xmlLoader2, root;

@@ -568,9 +460,2 @@

}()
/**
* Metadata parsing in OPF
* @param {object} metadata metadata AST
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context containing metadata
*/
}, {

@@ -624,16 +509,6 @@ key: "_parseMetadata",

}
/**
* Manifest and spine parsing in OPF
* @param {object} manifest manifest AST
* @param {object} spine spine AST
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context containing manifest and spine
* @see EpubParser.parseDefaultOptions.parseStyle
* @see EpubParser.parseDefaultOptions.styleNamespacePrefix
*/
}, {
key: "_parseManifestAndSpine",
value: function () {
var _parseManifestAndSpine2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(manifest, spine, context) {
var _parseManifestAndSpine2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(manifest, spine, context) {
var _this = this;

@@ -657,3 +532,3 @@

return items.reduce(function (prevPromise, item, idx) {
return prevPromise.then( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
return prevPromise.then((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
var rawItem, itemEntry, refIndex, ref, result;

@@ -668,3 +543,2 @@ return _regenerator["default"].wrap(function _callee4$(_context5) {

if ((0, _parserCore.isExists)(item.href)) {
// ../Text/Section0001.xhtml => {basePath}/Text/Section0001.xhtml
rawItem.href = (0, _parserCore.safePathJoin)(basePath, item.href);

@@ -692,3 +566,2 @@ }

if (rawItem.itemType === _SpineItem["default"]) {
// Checks if item is referenced in spine list.
refIndex = itemRefs.findIndex(function (itemRef) {

@@ -710,6 +583,2 @@ return itemRef.idref === rawItem.id;

if (!context.foundCover) {
// EPUB2 spec doesn't have cover image declaration, it founding for cover image in order listed below.
// 1. metadata.meta[name="cover"].content === imageItem.id
// 2. imageItem.id === 'cover'
// 3. guide.reference[type="cover"].href === imageItem.href (see _parseGuide)
if ((0, _parserCore.isExists)(coverMeta) && rawItem.id === coverMeta.content) {

@@ -724,3 +593,2 @@ rawItem.isCover = true;

} else if (rawItem.itemType === _NcxItem["default"]) {
// NCX is valid only if rawItem.id matches tocId.
if (rawItem.id !== tocId) {

@@ -818,21 +686,6 @@ rawItem.itemType = _DeadItem["default"];

}()
/**
* @typedef {object} StyleParseResult
* @property {string[]} styles path of styles linked to spine
* @property {object[]} inlineStyles inline styles included in Spine
*/
/**
* @param {object} rawItem
* @param {object} entry spine entry
* @param {object} options parse options
* @returns {StyleParseResult} returns styles and inline style from spine
* @see EpubParser.parseDefaultOptions.styleNamespacePrefix
* @see EpubParser.parseDefaultOptions.additionalInlineStyle
*/
}, {
key: "_parseSpineStyle",
value: function () {
var _parseSpineStyle2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(rawItem, entry, options) {
var _parseSpineStyle2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(rawItem, entry, options) {
var styles, inlineStyles, find, filter, document, html, head;

@@ -895,7 +748,4 @@ return _regenerator["default"].wrap(function _callee6$(_context7) {

case 17:
// <link rel="stylesheet" type="text/css" href="..." ... />
// ^~~
filter(head.children, 'tagName', 'link').forEach(function (link) {
var attrs = link.attributes;
/* istanbul ignore else */

@@ -905,10 +755,7 @@ if ((0, _parserCore.isExists)(attrs)) {

var type = find(attrs, 'key', 'type');
/* istanbul ignore else */
if ((0, _parserCore.isExists)(rel) && rel.value === 'stylesheet' || (0, _parserCore.isExists)(type) && type.value === 'text/css') {
var href = find(attrs, 'key', 'href');
/* istanbul ignore else */
if ((0, _parserCore.isExists)(href) && (0, _parserCore.isExists)(href.value) && !(0, _parserCore.isUrl)(href.value)) {
// href="../Styles/Style0001.css" => href="OEBPS/Styles/Style0001.css"
styles.push((0, _parserCore.safePathJoin)((0, _parserCore.safeDirname)(rawItem.href), href.value));

@@ -918,8 +765,5 @@ }

}
}); // <style ...>...</style>
// ^~~
});
filter(head.children, 'tagName', 'style').forEach(function (style, idx) {
var firstNode = style.children[0];
/* istanbul ignore else */

@@ -962,9 +806,2 @@ if ((0, _parserCore.isExists)(firstNode)) {

}()
/**
* Guide parsing in OPF
* @param {object} guide guide AST
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context containing guide
*/
}, {

@@ -982,3 +819,3 @@ key: "_parseGuide",

href: (0, _parserCore.safePathJoin)(context.basePath, reference.href)
}); // If reference.type equal 'cover' and there is an image item matching reference.href, it is cover image.
});

@@ -1003,17 +840,6 @@ if (!foundCover && (0, _parserCore.isExists)(reference.type) && reference.type.toLowerCase() === _Guide["default"].Types.COVER) {

}
/**
* NCX parsing
* @param {ParseContext} context intermediate result
* @returns {Promise.<ParseContext>} return Context containing ncx if exists
* @throws {Errors.EINVAL} invalid XML
* @throws {Errors.EINVAL} can not found ncx attribute OPF
* @throws {Errors.ENOFILE} NCX not found
* @throws {Errors.ENOELMT} no such element in NCX
* @see EpubParser.parseDefaultOptions.allowNcxFileMissing
*/
}, {
key: "_parseNcx",
value: function () {
var _parseNcx2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(context) {
var _parseNcx2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(context) {
var _this2 = this;

@@ -1038,19 +864,3 @@

ncxEntry = entries.find(ncxItem.href, false); // toc.ncx
// <?xml ... ?>
// <!DOCTYPE ncx ... >
// <ncx ... >
// ...
// <navMap>
// <navPoint id="..." playOrder="...">
// <navLabel><text>...</text></navLabel>
// <content src="..." />
// {<navPoint>...</navPoint>}
// </navPoint>
// ...
// </navMap>
// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ...
// </ncx>
ncxEntry = entries.find(ncxItem.href, false);
_context8.t0 = _xmlLoader4["default"];

@@ -1090,5 +900,4 @@ _context8.next = 8;

});
} // Text/Section0001.xhtml => {basePath}/Text/Section0001.xhtml
}
np.content.src = (0, _parserCore.safePathJoin)(context.basePath, np.content.src);

@@ -1152,6 +961,2 @@ return np;

}()
/**
* @param {Book} book
*/
}, {

@@ -1170,14 +975,6 @@ key: "_checkResult",

}
/**
* Contents is read using loader suitable for context
* @param {ReadContext} context properties required for reading
* @returns {(string[]|Buffer[])} reading results
* @throws {Errors.ENOFILE} no such file
* @see EpubParser.readDefaultOptions.force
*/
}, {
key: "_read",
value: function () {
var _read2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(context) {
var _read2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(context) {
var items, entries, options, results;

@@ -1192,3 +989,3 @@ return _regenerator["default"].wrap(function _callee9$(_context10) {

return items.reduce(function (prevPromise, item) {
return prevPromise.then( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
return prevPromise.then((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8() {
var entry, file;

@@ -1260,11 +1057,5 @@ return _regenerator["default"].wrap(function _callee8$(_context9) {

}()
/**
* @param {string} mediaType
* @return {*} item type by media-type
*/
}, {
key: "getItemTypeFromMediaType",
value: function getItemTypeFromMediaType(mediaType) {
// See: http://www.idpf.org/epub/20/spec/OPS_2.0.1_draft.htm#Section1.3.7
var types = {

@@ -1289,3 +1080,2 @@ 'application/font': _FontItem["default"],

'image/bmp': _ImageItem["default"],
// Not recommended in EPUB spec.
'image/svg+xml': _SvgItem["default"]

@@ -1292,0 +1082,0 @@ };

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

get: function get() {
return _Book["default"];
return _EpubBook["default"];
}

@@ -56,2 +56,2 @@ });

var _Book = _interopRequireDefault(require("./model/Book"));
var _EpubBook = _interopRequireDefault(require("./model/EpubBook"));

@@ -18,3 +18,2 @@ "use strict";

// Type reference: https://github.com/csstree/csstree/blob/master/docs/ast.md
var Types = {

@@ -28,4 +27,3 @@ SELECTOR_LIST: 'SelectorList',

URL: 'Url',
RAW: 'Raw' // See type reference for more types.
RAW: 'Raw'
};

@@ -57,3 +55,2 @@

selectorList.children.each(function (selector, item, list) {
// eslint-disable-line
var shouldRemove = false;

@@ -63,4 +60,3 @@ var shouldUnwrap = false;

_cssTree["default"].walk(selector, function (node) {
// eslint-disable-line
var context = this; // Ignore nodes in nested selectors
var context = this;

@@ -72,3 +68,2 @@ if (!(0, _parserCore.isExists)(context.selector) || context.selector === selectorList) {

if (type === Types.SELECTOR_LIST) {
// Ignore selectors inside :not()
if ((0, _parserCore.isExists)(context["function"]) && context["function"].name.toLowerCase() !== 'not') {

@@ -143,3 +138,2 @@ if (handleRulePrelude(node, options, cssItem)) {

if ((0, _parserCore.isExists)(options.basePath) && !(0, _parserCore.isUrl)(url)) {
// url(../Image/line.jpg) => url('{basePath}/OEBPS/Image/line.jpg')
url = (0, _parserCore.safePathJoin)(options.basePath, (0, _parserCore.safeDirname)(cssItem.href), url);

@@ -175,3 +169,2 @@ oldItem = item;

if (node.block) {
// Otherwise removed at-rule don't prevent @import for removal
this.stylesheet.firstAtrulesAllowed = false;

@@ -204,3 +197,2 @@

leave: function leave(node, item, list) {
// eslint-disable-line
var context = this;

@@ -207,0 +199,0 @@

@@ -22,3 +22,2 @@ "use strict";

// Type reference: https://github.com/andrejewski/himalaya/blob/master/text/ast-spec-v1.md
var Types = {

@@ -57,4 +56,3 @@ TEXT: 'text',

href: ''
}); // css-tree does not work unless style value is wrapped in a block.
});
var text = (0, _cssLoader["default"])(dummyItem, "tmp{".concat(value, "}"), options);

@@ -76,5 +74,2 @@ return "".concat(attrs, " ").concat(key, "=\"").concat(text.substring(4, text.length - 1), "\"");

if ((0, _parserCore.isExists)(spineIndex)) {
// href="#title" => href="#title"
// href="./Section00001" => href="0"
// href="./Section00001#title" => href="0#title"
return "".concat(attrs, " ").concat(key, "=\"").concat(spineIndex).concat(components[1] ? "#".concat(components[1]) : '', "\"");

@@ -85,5 +80,2 @@ }

if ((0, _parserCore.isExists)(basePath) && value.split('#')[0].length > 0) {
// href="#title" => href="#title"
// xlink:href="../Images/cover.jpg" => xlink:href="{basePath}/Images/cover.jpg"
// src="../Images/background.jpg" => src="{basePath}/OEBPS/Images/background.jpg"
return "".concat(attrs, " ").concat(key, "=\"").concat((0, _parserCore.safePathJoin)(basePath, value), "\"");

@@ -90,0 +82,0 @@ }

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

if ((0, _parserCore.isArray)(value)) {
value = getValues(value, keyTranslator); // eslint-disable-line no-use-before-define
value = getValues(value, keyTranslator);
} else if ((0, _parserCore.isObject)(value)) {

@@ -79,31 +79,16 @@ if (newKey === 'children') {

return _fastXmlParser["default"].parse(string, {
// Text node name for identification.
textNodeName: textNodeName,
// Prepend given string to attribute name for identification.
attributeNamePrefix: '',
// (Valid name) Group all the attributes as properties of given name.
attrNodeName: false,
// Ignore attributes to be parsed.
ignoreAttributes: false,
// Remove namespace string from tag and attribute names.
ignoreNameSpace: true,
// A tag can have attributes without any value.
allowBooleanAttributes: true,
// Parse the value of text node to float, integer, or boolean.
parseNodeValue: false,
// Parse the value of an attribute to float, integer, or boolean.
parseAttributeValue: false,
// Trim string values of an attribute or node
trimValues: true,
// If specified, parser parse CDATA as nested tag instead of adding it's value to parent tag.
cdataTagName: false,
// If true then values like "+123", or "0123" will not be parsed as number.
parseTrueNumberOnly: true,
// Process tag value during transformation. Like HTML decoding, word capitalization, etc.
// Applicable in case of string only.
tagValueProcessor: function tagValueProcessor(value) {
return _he["default"].decode(value);
},
// Process attribute value during transformation. Like HTML decoding, word capitalization, etc.
// Applicable in case of string only.
attrValueProcessor: function attrValueProcessor(value) {

@@ -110,0 +95,0 @@ return _he["default"].decode(value, {

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

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
// See http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.2.6 for a discussion of role.
var Roles = Object.freeze({

@@ -52,6 +53,9 @@ UNDEFINED: 'undefined',

var Author = /*#__PURE__*/function () {
var Author = function () {
function Author() {
var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, Author);
(0, _defineProperty2["default"])(this, "name", void 0);
(0, _defineProperty2["default"])(this, "fileAs", void 0);
(0, _defineProperty2["default"])(this, "role", void 0);

@@ -58,0 +62,0 @@ if ((0, _parserCore.isString)(rawObj)) {

@@ -24,5 +24,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -33,4 +35,4 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

var CssItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(CssItem, _Item);
var CssItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(CssItem, _BaseEpubItem);

@@ -53,2 +55,3 @@ var _super = _createSuper(CssItem);

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "namespace", void 0);

@@ -58,5 +61,3 @@ if ((0, _parserCore.isExists)(rawObj.namespace)) {

}
/* istanbul ignore else */
if (freeze && _this.constructor === CssItem) {

@@ -79,3 +80,3 @@ Object.freeze((0, _assertThisInitialized2["default"])(_this));

return CssItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -82,0 +83,0 @@ var _default = CssItem;

@@ -14,2 +14,4 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");

@@ -25,6 +27,8 @@

var DateTime = /*#__PURE__*/function () {
var DateTime = function () {
function DateTime() {
var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, DateTime);
(0, _defineProperty2["default"])(this, "value", void 0);
(0, _defineProperty2["default"])(this, "event", void 0);

@@ -31,0 +35,0 @@ if ((0, _parserCore.isString)(rawObj)) {

@@ -24,5 +24,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -42,4 +44,4 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

var DeadItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(DeadItem, _Item);
var DeadItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(DeadItem, _BaseEpubItem);

@@ -55,2 +57,4 @@ var _super = _createSuper(DeadItem);

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "reason", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "itemType", void 0);

@@ -66,5 +70,3 @@ if ((0, _parserCore.isExists)(rawObj.reason)) {

}
/* istanbul ignore else */
if (freeze) {

@@ -87,3 +89,3 @@ Object.freeze((0, _assertThisInitialized2["default"])(_this));

return DeadItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -90,0 +92,0 @@ DeadItem.Reason = Reason;

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

var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -33,8 +33,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

var FontItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(FontItem, _Item);
var FontItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(FontItem, _BaseEpubItem);
var _super = _createSuper(FontItem);
/* istanbul ignore next */
function FontItem() {

@@ -47,3 +46,2 @@ var _this;

_this = _super.call(this, rawObj, freeze);
/* istanbul ignore else */

@@ -66,3 +64,3 @@ if (freeze) {

return FontItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -69,0 +67,0 @@ var _default = FontItem;

@@ -20,9 +20,5 @@ "use strict";

COVER: 'cover',
// The book cover(s, jacket information, etc.
TITLE_PAGE: 'title-page',
// Page with possibly title, author, publisher, and other metadata.
TOC: 'toc',
// Table Of Contents.
INDEX: 'index',
// Back-of-book style index.
GLOSSARY: 'glossary',

@@ -37,12 +33,9 @@ ACKNOWLEDGEMENTS: 'acknowledgements',

LOI: 'loi',
// List Of Illustrations.
LOT: 'lot',
// List Of Tables.
NOTES: 'notes',
PREFACE: 'preface',
TEXT: 'text' // First "real" page of content. (e.g. "Chapter 1")
TEXT: 'text'
});
var Guide = /*#__PURE__*/function () {
var Guide = function () {
function Guide() {

@@ -49,0 +42,0 @@ var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

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

var Identifier = /*#__PURE__*/function () {
var Identifier = function () {
function Identifier() {

@@ -31,0 +31,0 @@ var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -24,5 +24,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -33,4 +35,4 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

var ImageItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(ImageItem, _Item);
var ImageItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(ImageItem, _BaseEpubItem);

@@ -46,4 +48,4 @@ var _super = _createSuper(ImageItem);

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isCover", void 0);
_this.isCover = rawObj.isCover || false;
/* istanbul ignore else */

@@ -67,3 +69,3 @@ if (freeze && _this.constructor === ImageItem) {

return ImageItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -70,0 +72,0 @@ var _default = ImageItem;

@@ -24,2 +24,4 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");

@@ -33,3 +35,3 @@

var InlineCssItem = /*#__PURE__*/function (_CssItem) {
var InlineCssItem = function (_CssItem) {
(0, _inherits2["default"])(InlineCssItem, _CssItem);

@@ -46,4 +48,4 @@

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "style", void 0);
_this.style = rawObj.style || '';
/* istanbul ignore else */

@@ -50,0 +52,0 @@ if (freeze) {

@@ -14,6 +14,10 @@ "use strict";

var Meta = /*#__PURE__*/function () {
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var Meta = function () {
function Meta() {
var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, Meta);
(0, _defineProperty2["default"])(this, "name", void 0);
(0, _defineProperty2["default"])(this, "content", void 0);
this.name = rawObj.name;

@@ -20,0 +24,0 @@ this.content = rawObj.content;

@@ -14,5 +14,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var NavPoint = /*#__PURE__*/function () {
var NavPoint = function () {
function NavPoint() {

@@ -24,2 +26,9 @@ var _this = this;

(0, _classCallCheck2["default"])(this, NavPoint);
(0, _defineProperty2["default"])(this, "id", void 0);
(0, _defineProperty2["default"])(this, "label", void 0);
(0, _defineProperty2["default"])(this, "src", void 0);
(0, _defineProperty2["default"])(this, "anchor", void 0);
(0, _defineProperty2["default"])(this, "depth", void 0);
(0, _defineProperty2["default"])(this, "children", void 0);
(0, _defineProperty2["default"])(this, "spine", void 0);
this.id = rawObj.id;

@@ -41,3 +50,2 @@ this.label = (rawObj.navLabel || {}).text;

this.spine = undefined;
/* istanbul ignore else */

@@ -44,0 +52,0 @@ if (freeze) {

@@ -24,5 +24,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -35,4 +37,4 @@ var _NavPoint = _interopRequireDefault(require("./NavPoint"));

var NcxItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(NcxItem, _Item);
var NcxItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(NcxItem, _BaseEpubItem);

@@ -55,6 +57,6 @@ var _super = _createSuper(NcxItem);

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "navPoints", void 0);
_this.navPoints = (rawObj.navPoints || []).map(function (navPoint) {
return new _NavPoint["default"](navPoint, freeze);
});
/* istanbul ignore else */

@@ -80,3 +82,3 @@ if (freeze) {

return NcxItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -83,0 +85,0 @@ var _default = NcxItem;

@@ -24,5 +24,7 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _parserCore = require("@ridi/parser-core");
var _Item2 = _interopRequireDefault(require("./Item"));
var _BaseEpubItem2 = _interopRequireDefault(require("./BaseEpubItem"));

@@ -33,4 +35,4 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

var SpineItem = /*#__PURE__*/function (_Item) {
(0, _inherits2["default"])(SpineItem, _Item);
var SpineItem = function (_BaseEpubItem) {
(0, _inherits2["default"])(SpineItem, _BaseEpubItem);

@@ -53,2 +55,8 @@ var _super = _createSuper(SpineItem);

_this = _super.call(this, rawObj, freeze);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "first", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "prev", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "next", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "index", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isLinear", void 0);
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "styles", void 0);
_this.index = rawObj.index;

@@ -72,5 +80,3 @@ _this.isLinear = (0, _parserCore.isExists)(rawObj.isLinear) ? rawObj.isLinear : true;

};
/* istanbul ignore else */
if (freeze) {

@@ -104,3 +110,3 @@ Object.freeze((0, _assertThisInitialized2["default"])(_this));

return SpineItem;
}(_Item2["default"]);
}(_BaseEpubItem2["default"]);

@@ -107,0 +113,0 @@ var _default = SpineItem;

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

var SvgItem = /*#__PURE__*/function (_ImageItem) {
var SvgItem = function (_ImageItem) {
(0, _inherits2["default"])(SvgItem, _ImageItem);

@@ -43,4 +43,2 @@

}
/* istanbul ignore next */
}]);

@@ -55,3 +53,2 @@

_this = _super.call(this, rawObj, freeze);
/* istanbul ignore else */

@@ -58,0 +55,0 @@ if (freeze) {

{
"name": "@ridi/epub-parser",
"version": "0.7.0",
"version": "0.7.1",
"description": "Common EPUB2 data parser for Ridibooks services",

@@ -27,7 +27,9 @@ "author": {

"files": [
"lib"
"lib",
"type"
],
"main": "lib/index.js",
"types": "type/index.d.ts",
"dependencies": {
"@ridi/parser-core": "0.7.0",
"@ridi/parser-core": "0.7.1",
"css-tree": "^1.0.0-alpha.39",

@@ -38,3 +40,4 @@ "fast-xml-parser": "3.12.17",

"himalaya": "^1.1.0"
}
},
"gitHead": "9ec93110b3040830b688cc1c29388a9a48d7a6ba"
}