@ridi/epub-parser
Advanced tools
Comparing version 0.2.0-alpha.3 to 0.2.0-alpha.4
@@ -38,2 +38,5 @@ 'use strict'; | ||
} | ||
// ex) | ||
// const key = ...; | ||
// this.cryptor = new Cryptor(Modes.ECB, { key }); | ||
} | ||
@@ -63,13 +66,13 @@ | ||
* @param {Buffer} data | ||
* @param {string} filename | ||
* @param {string} filePath | ||
*/ | ||
; | ||
CryptoProvider.prototype.run = function run(data, filename) { | ||
CryptoProvider.prototype.run = function run(data, filePath) { | ||
// eslint-disable-line | ||
// ex) | ||
// if (condition1) { | ||
// return this.encrypt(data, filename) | ||
// return this.encrypt(data, filePath) | ||
// } else if (condition2) { | ||
// return this.decrypt(data, filename) | ||
// return this.decrypt(data, filePath) | ||
// } | ||
@@ -83,7 +86,7 @@ // return data; | ||
* @param {Buffer} data | ||
* @param {string} filename | ||
* @param {string} filePath | ||
*/ | ||
CryptoProvider.prototype.encrypt = function encrypt(data, filename) { | ||
CryptoProvider.prototype.encrypt = function encrypt(data, filePath) { | ||
// eslint-disable-line | ||
@@ -102,7 +105,7 @@ // ex) | ||
* @param {Buffer} data | ||
* @param {string} filename | ||
* @param {string} filePath | ||
*/ | ||
CryptoProvider.prototype.decrypt = function decrypt(data, filename) { | ||
CryptoProvider.prototype.decrypt = function decrypt(data, filePath) { | ||
// eslint-disable-line | ||
@@ -109,0 +112,0 @@ // ex) |
@@ -6,3 +6,2 @@ 'use strict'; | ||
}); | ||
exports.Padding = exports.Counter = exports.Modes = exports.utf8 = exports.hex = undefined; | ||
@@ -196,7 +195,9 @@ var _keys = require('babel-runtime/core-js/object/keys'); | ||
exports.hex = hex; | ||
exports.utf8 = utf8; | ||
exports.Modes = Modes; | ||
exports.Counter = Counter; | ||
exports.Padding = Padding; | ||
exports.default = Cryptor; | ||
Cryptor.hex = hex; | ||
Cryptor.utf8 = utf8; | ||
Cryptor.Modes = Modes; | ||
Cryptor.Counter = Counter; | ||
Cryptor.Padding = Padding; | ||
exports.default = Cryptor; | ||
module.exports = exports.default; |
@@ -135,6 +135,6 @@ 'use strict'; | ||
function cssLoader(cssItem, file) { | ||
function cssLoader(cssItem, string) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var ast = _cssTree2.default.parse(file); | ||
var ast = _cssTree2.default.parse(string); | ||
_cssTree2.default.walk(ast, { | ||
@@ -141,0 +141,0 @@ leave: function leave(node, item, list) { |
@@ -91,4 +91,4 @@ 'use strict'; | ||
function stringify(tree, options) { | ||
return tree.map(function (node) { | ||
function stringify(ast, options) { | ||
return ast.map(function (node) { | ||
if (node.type === Types.TEXT) { | ||
@@ -115,6 +115,6 @@ return node.content; | ||
function spineLoader(spineItem, file) { | ||
function spineLoader(spineItem, string) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var document = (0, _himalaya.parse)(file); | ||
var ast = (0, _himalaya.parse)(string); | ||
var stringifyOptions = (0, _util.mergeObjects)(_himalaya.parseDefaults, (0, _util.mergeObjects)(options, { | ||
@@ -131,3 +131,3 @@ basePath: (0, _util.isExists)(options.basePath) ? (0, _util.safePathJoin)(options.basePath, (0, _util.safeDirname)(spineItem.href)) : undefined, | ||
if (options.extractBody) { | ||
var html = document.find(function (child) { | ||
var html = ast.find(function (child) { | ||
return child.tagName === 'html'; | ||
@@ -156,4 +156,4 @@ }); | ||
return stringify(document, stringifyOptions); | ||
return stringify(ast, stringifyOptions); | ||
} | ||
module.exports = exports.default; |
@@ -76,4 +76,4 @@ 'use strict'; | ||
exports.textNodeName = textNodeName; | ||
function xmlLoader(file) { | ||
return _fastXmlParser2.default.parse(file, { | ||
function xmlLoader(string) { | ||
return _fastXmlParser2.default.parse(string, { | ||
// Text node name for identification. | ||
@@ -80,0 +80,0 @@ textNodeName: textNodeName, |
@@ -6,6 +6,4 @@ 'use strict'; | ||
}); | ||
exports.isUrl = exports.isString = exports.isObject = exports.isFunc = exports.isExists = exports.isBool = exports.isArray = exports.getType = exports.openZip = exports.validateOptions = exports.stringContains = exports.parseBool = exports.getPathes = exports.safePathJoin = exports.safePath = exports.safeDirname = exports.mergeObjects = exports.readEntries = exports.getItemType = exports.getItemEncoding = exports.removeDirectory = exports.createDirectory = undefined; | ||
exports.isUrl = exports.isString = exports.isObject = exports.isFunc = exports.isExists = exports.isBool = exports.isArray = exports.getType = exports.openZip = exports.validateOptions = exports.stringContains = exports.parseBool = exports.getPathes = exports.safePathJoin = exports.safePath = exports.safeDirname = exports.mergeObjects = exports.readEntries = exports.getItemType = exports.getItemEncoding = undefined; | ||
var _directory = require('./directory'); | ||
var _itemUtil = require('./itemUtil'); | ||
@@ -43,4 +41,2 @@ | ||
exports.createDirectory = _directory.createDirectory; | ||
exports.removeDirectory = _directory.removeDirectory; | ||
exports.getItemEncoding = _itemUtil.getItemEncoding; | ||
@@ -47,0 +43,0 @@ exports.getItemType = _itemUtil.getItemType; |
@@ -91,3 +91,3 @@ 'use strict'; | ||
file = (0, _typecheck.isExists)(cryptoProvider) ? cryptoProvider.run(file, _path2.default.basename(fullPath)) : file; | ||
file = (0, _typecheck.isExists)(cryptoProvider) ? cryptoProvider.run(file, fullPath) : file; | ||
@@ -136,3 +136,3 @@ if (!(0, _typecheck.isExists)(encoding)) { | ||
if ((0, _typecheck.isExists)(cryptoProvider)) { | ||
input = cryptoProvider.run(_fsExtra2.default.readFileSync(input), _path2.default.basename(input)); | ||
input = cryptoProvider.run(_fsExtra2.default.readFileSync(input), input); | ||
} | ||
@@ -139,0 +139,0 @@ _context2.next = 4; |
@@ -37,3 +37,3 @@ 'use strict'; | ||
if ((0, _typecheck.isExists)(this.cryptoProvider)) { | ||
buffer = this.cryptoProvider.run(buffer, _path2.default.basename(entry.path)); | ||
buffer = this.cryptoProvider.run(buffer, entry.path); | ||
} | ||
@@ -75,5 +75,5 @@ | ||
if (overwrite) { | ||
(0, _directory.removeDirectory)(unzipPath); | ||
_fsExtra2.default.removeSync(unzipPath); | ||
} | ||
(0, _directory.createDirectory)(unzipPath); | ||
_fsExtra2.default.mkdirpSync(unzipPath); | ||
@@ -83,3 +83,3 @@ writeFile = function writeFile(entry, output) { | ||
return new _promise2.default(function (resolve, reject) { | ||
var writeStream = _fs2.default.createWriteStream(output); | ||
var writeStream = _fsExtra2.default.createWriteStream(output); | ||
var onError = function onError() { | ||
@@ -91,3 +91,3 @@ reject(); | ||
if ((0, _typecheck.isExists)(_this.cryptoProvider)) { | ||
writeStream.write(_this.cryptoProvider.run(data, _path2.default.basename(entry.path))); | ||
writeStream.write(_this.cryptoProvider.run(data, entry.path)); | ||
} else { | ||
@@ -120,4 +120,4 @@ writeStream.write(data); | ||
if (!_fs2.default.existsSync(dir)) { | ||
(0, _directory.createDirectory)(dir); | ||
if (!_fsExtra2.default.existsSync(dir)) { | ||
_fsExtra2.default.mkdirpSync(dir); | ||
} | ||
@@ -150,5 +150,5 @@ } | ||
var _fs = require('fs'); | ||
var _fsExtra = require('fs-extra'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _fsExtra2 = _interopRequireDefault(_fsExtra); | ||
@@ -163,4 +163,2 @@ var _path = require('path'); | ||
var _directory = require('./directory'); | ||
var _pathUtil = require('./pathUtil'); | ||
@@ -167,0 +165,0 @@ |
{ | ||
"name": "@ridi/epub-parser", | ||
"version": "0.2.0-alpha.3", | ||
"version": "0.2.0-alpha.4", | ||
"description": "Common EPUB2 data parser for Ridibooks services written in ES6", | ||
@@ -23,3 +23,4 @@ "author": { | ||
"unzip", | ||
"read" | ||
"read", | ||
"crypto" | ||
], | ||
@@ -26,0 +27,0 @@ "files": [ |
4
154019
41
3438