@epubjs-react-native/core
Version:
A digital book reader in .opf .epub format for react native using epub.js library inside a webview.
1,477 lines (1,470 loc) • 227 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/*
CDN url https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js
*/
var _default = exports.default = `
/*!
JSZip v3.1.5 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/master/LICENSE
*/
!(function (a) {
if ('object' == typeof exports && 'undefined' != typeof module)
module.exports = a();
else if ('function' == typeof define && define.amd) define([], a);
else {
var b;
(b =
'undefined' != typeof window
? window
: 'undefined' != typeof global
? global
: 'undefined' != typeof self
? self
: this),
(b.JSZip = a());
}
})(function () {
return (function a(b, c, d) {
function e(g, h) {
if (!c[g]) {
if (!b[g]) {
var i = 'function' == typeof require && require;
if (!h && i) return i(g, !0);
if (f) return f(g, !0);
var j = new Error("Cannot find module '" + g + "'");
throw ((j.code = 'MODULE_NOT_FOUND'), j);
}
var k = (c[g] = { exports: {} });
b[g][0].call(
k.exports,
function (a) {
var c = b[g][1][a];
return e(c ? c : a);
},
k,
k.exports,
a,
b,
c,
d
);
}
return c[g].exports;
}
for (
var f = 'function' == typeof require && require, g = 0;
g < d.length;
g++
)
e(d[g]);
return e;
})(
{
1: [
function (a, b, c) {
'use strict';
var d = a('./utils'),
e = a('./support'),
f =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
(c.encode = function (a) {
for (
var b,
c,
e,
g,
h,
i,
j,
k = [],
l = 0,
m = a.length,
n = m,
o = 'string' !== d.getTypeOf(a);
l < a.length;
)
(n = m - l),
o
? ((b = a[l++]),
(c = l < m ? a[l++] : 0),
(e = l < m ? a[l++] : 0))
: ((b = a.charCodeAt(l++)),
(c = l < m ? a.charCodeAt(l++) : 0),
(e = l < m ? a.charCodeAt(l++) : 0)),
(g = b >> 2),
(h = ((3 & b) << 4) | (c >> 4)),
(i = n > 1 ? ((15 & c) << 2) | (e >> 6) : 64),
(j = n > 2 ? 63 & e : 64),
k.push(f.charAt(g) + f.charAt(h) + f.charAt(i) + f.charAt(j));
return k.join('');
}),
(c.decode = function (a) {
var b,
c,
d,
g,
h,
i,
j,
k = 0,
l = 0,
m = 'data:';
if (a.substr(0, m.length) === m)
throw new Error(
'Invalid base64 input, it looks like a data url.'
);
a = a.replace(/[^A-Za-z0-9\\+\\/\\=]/g, '');
var n = (3 * a.length) / 4;
if (
(a.charAt(a.length - 1) === f.charAt(64) && n--,
a.charAt(a.length - 2) === f.charAt(64) && n--,
n % 1 !== 0)
)
throw new Error('Invalid base64 input, bad content length.');
var o;
for (
o = e.uint8array ? new Uint8Array(0 | n) : new Array(0 | n);
k < a.length;
)
(g = f.indexOf(a.charAt(k++))),
(h = f.indexOf(a.charAt(k++))),
(i = f.indexOf(a.charAt(k++))),
(j = f.indexOf(a.charAt(k++))),
(b = (g << 2) | (h >> 4)),
(c = ((15 & h) << 4) | (i >> 2)),
(d = ((3 & i) << 6) | j),
(o[l++] = b),
64 !== i && (o[l++] = c),
64 !== j && (o[l++] = d);
return o;
});
},
{ './support': 30, './utils': 32 },
],
2: [
function (a, b, c) {
'use strict';
function d(a, b, c, d, e) {
(this.compressedSize = a),
(this.uncompressedSize = b),
(this.crc32 = c),
(this.compression = d),
(this.compressedContent = e);
}
var e = a('./external'),
f = a('./stream/DataWorker'),
g = a('./stream/DataLengthProbe'),
h = a('./stream/Crc32Probe'),
g = a('./stream/DataLengthProbe');
(d.prototype = {
getContentWorker: function () {
var a = new f(e.Promise.resolve(this.compressedContent))
.pipe(this.compression.uncompressWorker())
.pipe(new g('data_length')),
b = this;
return (
a.on('end', function () {
if (this.streamInfo.data_length !== b.uncompressedSize)
throw new Error('Bug : uncompressed data size mismatch');
}),
a
);
},
getCompressedWorker: function () {
return new f(e.Promise.resolve(this.compressedContent))
.withStreamInfo('compressedSize', this.compressedSize)
.withStreamInfo('uncompressedSize', this.uncompressedSize)
.withStreamInfo('crc32', this.crc32)
.withStreamInfo('compression', this.compression);
},
}),
(d.createWorkerFrom = function (a, b, c) {
return a
.pipe(new h())
.pipe(new g('uncompressedSize'))
.pipe(b.compressWorker(c))
.pipe(new g('compressedSize'))
.withStreamInfo('compression', b);
}),
(b.exports = d);
},
{
'./external': 6,
'./stream/Crc32Probe': 25,
'./stream/DataLengthProbe': 26,
'./stream/DataWorker': 27,
},
],
3: [
function (a, b, c) {
'use strict';
var d = a('./stream/GenericWorker');
(c.STORE = {
magic: '\\0\\0',
compressWorker: function (a) {
return new d('STORE compression');
},
uncompressWorker: function () {
return new d('STORE decompression');
},
}),
(c.DEFLATE = a('./flate'));
},
{ './flate': 7, './stream/GenericWorker': 28 },
],
4: [
function (a, b, c) {
'use strict';
function d() {
for (var a, b = [], c = 0; c < 256; c++) {
a = c;
for (var d = 0; d < 8; d++)
a = 1 & a ? 3988292384 ^ (a >>> 1) : a >>> 1;
b[c] = a;
}
return b;
}
function e(a, b, c, d) {
var e = h,
f = d + c;
a ^= -1;
for (var g = d; g < f; g++) a = (a >>> 8) ^ e[255 & (a ^ b[g])];
return a ^ -1;
}
function f(a, b, c, d) {
var e = h,
f = d + c;
a ^= -1;
for (var g = d; g < f; g++)
a = (a >>> 8) ^ e[255 & (a ^ b.charCodeAt(g))];
return a ^ -1;
}
var g = a('./utils'),
h = d();
b.exports = function (a, b) {
if ('undefined' == typeof a || !a.length) return 0;
var c = 'string' !== g.getTypeOf(a);
return c ? e(0 | b, a, a.length, 0) : f(0 | b, a, a.length, 0);
};
},
{ './utils': 32 },
],
5: [
function (a, b, c) {
'use strict';
(c.base64 = !1),
(c.binary = !1),
(c.dir = !1),
(c.createFolders = !0),
(c.date = null),
(c.compression = null),
(c.compressionOptions = null),
(c.comment = null),
(c.unixPermissions = null),
(c.dosPermissions = null);
},
{},
],
6: [
function (a, b, c) {
'use strict';
var d = null;
(d = 'undefined' != typeof Promise ? Promise : a('lie')),
(b.exports = { Promise: d });
},
{ lie: 58 },
],
7: [
function (a, b, c) {
'use strict';
function d(a, b) {
h.call(this, 'FlateWorker/' + a),
(this._pako = null),
(this._pakoAction = a),
(this._pakoOptions = b),
(this.meta = {});
}
var e =
'undefined' != typeof Uint8Array &&
'undefined' != typeof Uint16Array &&
'undefined' != typeof Uint32Array,
f = a('pako'),
g = a('./utils'),
h = a('./stream/GenericWorker'),
i = e ? 'uint8array' : 'array';
(c.magic = '\\b\\0'),
g.inherits(d, h),
(d.prototype.processChunk = function (a) {
(this.meta = a.meta),
null === this._pako && this._createPako(),
this._pako.push(g.transformTo(i, a.data), !1);
}),
(d.prototype.flush = function () {
h.prototype.flush.call(this),
null === this._pako && this._createPako(),
this._pako.push([], !0);
}),
(d.prototype.cleanUp = function () {
h.prototype.cleanUp.call(this), (this._pako = null);
}),
(d.prototype._createPako = function () {
this._pako = new f[this._pakoAction]({
raw: !0,
level: this._pakoOptions.level || -1,
});
var a = this;
this._pako.onData = function (b) {
a.push({ data: b, meta: a.meta });
};
}),
(c.compressWorker = function (a) {
return new d('Deflate', a);
}),
(c.uncompressWorker = function () {
return new d('Inflate', {});
});
},
{ './stream/GenericWorker': 28, './utils': 32, pako: 59 },
],
8: [
function (a, b, c) {
'use strict';
function d(a, b, c, d) {
f.call(this, 'ZipFileWorker'),
(this.bytesWritten = 0),
(this.zipComment = b),
(this.zipPlatform = c),
(this.encodeFileName = d),
(this.streamFiles = a),
(this.accumulate = !1),
(this.contentBuffer = []),
(this.dirRecords = []),
(this.currentSourceOffset = 0),
(this.entriesCount = 0),
(this.currentFile = null),
(this._sources = []);
}
var e = a('../utils'),
f = a('../stream/GenericWorker'),
g = a('../utf8'),
h = a('../crc32'),
i = a('../signature'),
j = function (a, b) {
var c,
d = '';
for (c = 0; c < b; c++)
(d += String.fromCharCode(255 & a)), (a >>>= 8);
return d;
},
k = function (a, b) {
var c = a;
return a || (c = b ? 16893 : 33204), (65535 & c) << 16;
},
l = function (a, b) {
return 63 & (a || 0);
},
m = function (a, b, c, d, f, m) {
var n,
o,
p = a.file,
q = a.compression,
r = m !== g.utf8encode,
s = e.transformTo('string', m(p.name)),
t = e.transformTo('string', g.utf8encode(p.name)),
u = p.comment,
v = e.transformTo('string', m(u)),
w = e.transformTo('string', g.utf8encode(u)),
x = t.length !== p.name.length,
y = w.length !== u.length,
z = '',
A = '',
B = '',
C = p.dir,
D = p.date,
E = { crc32: 0, compressedSize: 0, uncompressedSize: 0 };
(b && !c) ||
((E.crc32 = a.crc32),
(E.compressedSize = a.compressedSize),
(E.uncompressedSize = a.uncompressedSize));
var F = 0;
b && (F |= 8), r || (!x && !y) || (F |= 2048);
var G = 0,
H = 0;
C && (G |= 16),
'UNIX' === f
? ((H = 798), (G |= k(p.unixPermissions, C)))
: ((H = 20), (G |= l(p.dosPermissions, C))),
(n = D.getUTCHours()),
(n <<= 6),
(n |= D.getUTCMinutes()),
(n <<= 5),
(n |= D.getUTCSeconds() / 2),
(o = D.getUTCFullYear() - 1980),
(o <<= 4),
(o |= D.getUTCMonth() + 1),
(o <<= 5),
(o |= D.getUTCDate()),
x &&
((A = j(1, 1) + j(h(s), 4) + t),
(z += 'up' + j(A.length, 2) + A)),
y &&
((B = j(1, 1) + j(h(v), 4) + w),
(z += 'uc' + j(B.length, 2) + B));
var I = '';
(I += '\\n\\0'),
(I += j(F, 2)),
(I += q.magic),
(I += j(n, 2)),
(I += j(o, 2)),
(I += j(E.crc32, 4)),
(I += j(E.compressedSize, 4)),
(I += j(E.uncompressedSize, 4)),
(I += j(s.length, 2)),
(I += j(z.length, 2));
var J = i.LOCAL_FILE_HEADER + I + s + z,
K =
i.CENTRAL_FILE_HEADER +
j(H, 2) +
I +
j(v.length, 2) +
'\\0\\0\\0\\0' +
j(G, 4) +
j(d, 4) +
s +
z +
v;
return { fileRecord: J, dirRecord: K };
},
n = function (a, b, c, d, f) {
var g = '',
h = e.transformTo('string', f(d));
return (g =
i.CENTRAL_DIRECTORY_END +
'\\0\\0\\0\\0' +
j(a, 2) +
j(a, 2) +
j(b, 4) +
j(c, 4) +
j(h.length, 2) +
h);
},
o = function (a) {
var b = '';
return (b =
i.DATA_DESCRIPTOR +
j(a.crc32, 4) +
j(a.compressedSize, 4) +
j(a.uncompressedSize, 4));
};
e.inherits(d, f),
(d.prototype.push = function (a) {
var b = a.meta.percent || 0,
c = this.entriesCount,
d = this._sources.length;
this.accumulate
? this.contentBuffer.push(a)
: ((this.bytesWritten += a.data.length),
f.prototype.push.call(this, {
data: a.data,
meta: {
currentFile: this.currentFile,
percent: c ? (b + 100 * (c - d - 1)) / c : 100,
},
}));
}),
(d.prototype.openedSource = function (a) {
(this.currentSourceOffset = this.bytesWritten),
(this.currentFile = a.file.name);
var b = this.streamFiles && !a.file.dir;
if (b) {
var c = m(
a,
b,
!1,
this.currentSourceOffset,
this.zipPlatform,
this.encodeFileName
);
this.push({ data: c.fileRecord, meta: { percent: 0 } });
} else this.accumulate = !0;
}),
(d.prototype.closedSource = function (a) {
this.accumulate = !1;
var b = this.streamFiles && !a.file.dir,
c = m(
a,
b,
!0,
this.currentSourceOffset,
this.zipPlatform,
this.encodeFileName
);
if ((this.dirRecords.push(c.dirRecord), b))
this.push({ data: o(a), meta: { percent: 100 } });
else
for (
this.push({ data: c.fileRecord, meta: { percent: 0 } });
this.contentBuffer.length;
)
this.push(this.contentBuffer.shift());
this.currentFile = null;
}),
(d.prototype.flush = function () {
for (
var a = this.bytesWritten, b = 0;
b < this.dirRecords.length;
b++
)
this.push({ data: this.dirRecords[b], meta: { percent: 100 } });
var c = this.bytesWritten - a,
d = n(
this.dirRecords.length,
c,
a,
this.zipComment,
this.encodeFileName
);
this.push({ data: d, meta: { percent: 100 } });
}),
(d.prototype.prepareNextSource = function () {
(this.previous = this._sources.shift()),
this.openedSource(this.previous.streamInfo),
this.isPaused ? this.previous.pause() : this.previous.resume();
}),
(d.prototype.registerPrevious = function (a) {
this._sources.push(a);
var b = this;
return (
a.on('data', function (a) {
b.processChunk(a);
}),
a.on('end', function () {
b.closedSource(b.previous.streamInfo),
b._sources.length ? b.prepareNextSource() : b.end();
}),
a.on('error', function (a) {
b.error(a);
}),
this
);
}),
(d.prototype.resume = function () {
return (
!!f.prototype.resume.call(this) &&
(!this.previous && this._sources.length
? (this.prepareNextSource(), !0)
: this.previous || this._sources.length || this.generatedError
? void 0
: (this.end(), !0))
);
}),
(d.prototype.error = function (a) {
var b = this._sources;
if (!f.prototype.error.call(this, a)) return !1;
for (var c = 0; c < b.length; c++)
try {
b[c].error(a);
} catch (a) {}
return !0;
}),
(d.prototype.lock = function () {
f.prototype.lock.call(this);
for (var a = this._sources, b = 0; b < a.length; b++) a[b].lock();
}),
(b.exports = d);
},
{
'../crc32': 4,
'../signature': 23,
'../stream/GenericWorker': 28,
'../utf8': 31,
'../utils': 32,
},
],
9: [
function (a, b, c) {
'use strict';
var d = a('../compressions'),
e = a('./ZipFileWorker'),
f = function (a, b) {
var c = a || b,
e = d[c];
if (!e)
throw new Error(c + ' is not a valid compression method !');
return e;
};
c.generateWorker = function (a, b, c) {
var d = new e(b.streamFiles, c, b.platform, b.encodeFileName),
g = 0;
try {
a.forEach(function (a, c) {
g++;
var e = f(c.options.compression, b.compression),
h =
c.options.compressionOptions || b.compressionOptions || {},
i = c.dir,
j = c.date;
c._compressWorker(e, h)
.withStreamInfo('file', {
name: a,
dir: i,
date: j,
comment: c.comment || '',
unixPermissions: c.unixPermissions,
dosPermissions: c.dosPermissions,
})
.pipe(d);
}),
(d.entriesCount = g);
} catch (h) {
d.error(h);
}
return d;
};
},
{ '../compressions': 3, './ZipFileWorker': 8 },
],
10: [
function (a, b, c) {
'use strict';
function d() {
if (!(this instanceof d)) return new d();
if (arguments.length)
throw new Error(
'The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.'
);
(this.files = {}),
(this.comment = null),
(this.root = ''),
(this.clone = function () {
var a = new d();
for (var b in this)
'function' != typeof this[b] && (a[b] = this[b]);
return a;
});
}
(d.prototype = a('./object')),
(d.prototype.loadAsync = a('./load')),
(d.support = a('./support')),
(d.defaults = a('./defaults')),
(d.version = '3.1.5'),
(d.loadAsync = function (a, b) {
return new d().loadAsync(a, b);
}),
(d.external = a('./external')),
(b.exports = d);
},
{
'./defaults': 5,
'./external': 6,
'./load': 11,
'./object': 15,
'./support': 30,
},
],
11: [
function (a, b, c) {
'use strict';
function d(a) {
return new f.Promise(function (b, c) {
var d = a.decompressed.getContentWorker().pipe(new i());
d.on('error', function (a) {
c(a);
})
.on('end', function () {
d.streamInfo.crc32 !== a.decompressed.crc32
? c(new Error('Corrupted zip : CRC32 mismatch'))
: b();
})
.resume();
});
}
var e = a('./utils'),
f = a('./external'),
g = a('./utf8'),
e = a('./utils'),
h = a('./zipEntries'),
i = a('./stream/Crc32Probe'),
j = a('./nodejsUtils');
b.exports = function (a, b) {
var c = this;
return (
(b = e.extend(b || {}, {
base64: !1,
checkCRC32: !1,
optimizedBinaryString: !1,
createFolders: !1,
decodeFileName: g.utf8decode,
})),
j.isNode && j.isStream(a)
? f.Promise.reject(
new Error(
"JSZip can't accept a stream when loading a zip file."
)
)
: e
.prepareContent(
'the loaded zip file',
a,
!0,
b.optimizedBinaryString,
b.base64
)
.then(function (a) {
var c = new h(b);
return c.load(a), c;
})
.then(function (a) {
var c = [f.Promise.resolve(a)],
e = a.files;
if (b.checkCRC32)
for (var g = 0; g < e.length; g++) c.push(d(e[g]));
return f.Promise.all(c);
})
.then(function (a) {
for (
var d = a.shift(), e = d.files, f = 0;
f < e.length;
f++
) {
var g = e[f];
c.file(g.fileNameStr, g.decompressed, {
binary: !0,
optimizedBinaryString: !0,
date: g.date,
dir: g.dir,
comment: g.fileCommentStr.length
? g.fileCommentStr
: null,
unixPermissions: g.unixPermissions,
dosPermissions: g.dosPermissions,
createFolders: b.createFolders,
});
}
return (
d.zipComment.length && (c.comment = d.zipComment), c
);
})
);
};
},
{
'./external': 6,
'./nodejsUtils': 14,
'./stream/Crc32Probe': 25,
'./utf8': 31,
'./utils': 32,
'./zipEntries': 33,
},
],
12: [
function (a, b, c) {
'use strict';
function d(a, b) {
f.call(this, 'Nodejs stream input adapter for ' + a),
(this._upstreamEnded = !1),
this._bindStream(b);
}
var e = a('../utils'),
f = a('../stream/GenericWorker');
e.inherits(d, f),
(d.prototype._bindStream = function (a) {
var b = this;
(this._stream = a),
a.pause(),
a
.on('data', function (a) {
b.push({ data: a, meta: { percent: 0 } });
})
.on('error', function (a) {
b.isPaused ? (this.generatedError = a) : b.error(a);
})
.on('end', function () {
b.isPaused ? (b._upstreamEnded = !0) : b.end();
});
}),
(d.prototype.pause = function () {
return (
!!f.prototype.pause.call(this) && (this._stream.pause(), !0)
);
}),
(d.prototype.resume = function () {
return (
!!f.prototype.resume.call(this) &&
(this._upstreamEnded ? this.end() : this._stream.resume(), !0)
);
}),
(b.exports = d);
},
{ '../stream/GenericWorker': 28, '../utils': 32 },
],
13: [
function (a, b, c) {
'use strict';
function d(a, b, c) {
e.call(this, b), (this._helper = a);
var d = this;
a.on('data', function (a, b) {
d.push(a) || d._helper.pause(), c && c(b);
})
.on('error', function (a) {
d.emit('error', a);
})
.on('end', function () {
d.push(null);
});
}
var e = a('readable-stream').Readable,
f = a('../utils');
f.inherits(d, e),
(d.prototype._read = function () {
this._helper.resume();
}),
(b.exports = d);
},
{ '../utils': 32, 'readable-stream': 16 },
],
14: [
function (a, b, c) {
'use strict';
b.exports = {
isNode: 'undefined' != typeof Buffer,
newBufferFrom: function (a, b) {
return new Buffer(a, b);
},
allocBuffer: function (a) {
return Buffer.alloc ? Buffer.alloc(a) : new Buffer(a);
},
isBuffer: function (a) {
return Buffer.isBuffer(a);
},
isStream: function (a) {
return (
a &&
'function' == typeof a.on &&
'function' == typeof a.pause &&
'function' == typeof a.resume
);
},
};
},
{},
],
15: [
function (a, b, c) {
'use strict';
function d(a) {
return '[object RegExp]' === Object.prototype.toString.call(a);
}
var e = a('./utf8'),
f = a('./utils'),
g = a('./stream/GenericWorker'),
h = a('./stream/StreamHelper'),
i = a('./defaults'),
j = a('./compressedObject'),
k = a('./zipObject'),
l = a('./generate'),
m = a('./nodejsUtils'),
n = a('./nodejs/NodejsStreamInputAdapter'),
o = function (a, b, c) {
var d,
e = f.getTypeOf(b),
h = f.extend(c || {}, i);
(h.date = h.date || new Date()),
null !== h.compression &&
(h.compression = h.compression.toUpperCase()),
'string' == typeof h.unixPermissions &&
(h.unixPermissions = parseInt(h.unixPermissions, 8)),
h.unixPermissions && 16384 & h.unixPermissions && (h.dir = !0),
h.dosPermissions && 16 & h.dosPermissions && (h.dir = !0),
h.dir && (a = q(a)),
h.createFolders && (d = p(a)) && r.call(this, d, !0);
var l = 'string' === e && h.binary === !1 && h.base64 === !1;
(c && 'undefined' != typeof c.binary) || (h.binary = !l);
var o = b instanceof j && 0 === b.uncompressedSize;
(o || h.dir || !b || 0 === b.length) &&
((h.base64 = !1),
(h.binary = !0),
(b = ''),
(h.compression = 'STORE'),
(e = 'string'));
var s = null;
s =
b instanceof j || b instanceof g
? b
: m.isNode && m.isStream(b)
? new n(a, b)
: f.prepareContent(
a,
b,
h.binary,
h.optimizedBinaryString,
h.base64
);
var t = new k(a, s, h);
this.files[a] = t;
},
p = function (a) {
'/' === a.slice(-1) && (a = a.substring(0, a.length - 1));
var b = a.lastIndexOf('/');
return b > 0 ? a.substring(0, b) : '';
},
q = function (a) {
return '/' !== a.slice(-1) && (a += '/'), a;
},
r = function (a, b) {
return (
(b = 'undefined' != typeof b ? b : i.createFolders),
(a = q(a)),
this.files[a] ||
o.call(this, a, null, { dir: !0, createFolders: b }),
this.files[a]
);
},
s = {
load: function () {
throw new Error(
'This method has been removed in JSZip 3.0, please check the upgrade guide.'
);
},
forEach: function (a) {
var b, c, d;
for (b in this.files)
this.files.hasOwnProperty(b) &&
((d = this.files[b]),
(c = b.slice(this.root.length, b.length)),
c && b.slice(0, this.root.length) === this.root && a(c, d));
},
filter: function (a) {
var b = [];
return (
this.forEach(function (c, d) {
a(c, d) && b.push(d);
}),
b
);
},
file: function (a, b, c) {
if (1 === arguments.length) {
if (d(a)) {
var e = a;
return this.filter(function (a, b) {
return !b.dir && e.test(a);
});
}
var f = this.files[this.root + a];
return f && !f.dir ? f : null;
}
return (a = this.root + a), o.call(this, a, b, c), this;
},
folder: function (a) {
if (!a) return this;
if (d(a))
return this.filter(function (b, c) {
return c.dir && a.test(b);
});
var b = this.root + a,
c = r.call(this, b),
e = this.clone();
return (e.root = c.name), e;
},
remove: function (a) {
a = this.root + a;
var b = this.files[a];
if (
(b ||
('/' !== a.slice(-1) && (a += '/'), (b = this.files[a])),
b && !b.dir)
)
delete this.files[a];
else
for (
var c = this.filter(function (b, c) {
return c.name.slice(0, a.length) === a;
}),
d = 0;
d < c.length;
d++
)
delete this.files[c[d].name];
return this;
},
generate: function (a) {
throw new Error(
'This method has been removed in JSZip 3.0, please check the upgrade guide.'
);
},
generateInternalStream: function (a) {
var b,
c = {};
try {
if (
((c = f.extend(a || {}, {
streamFiles: !1,
compression: 'STORE',
compressionOptions: null,
type: '',
platform: 'DOS',
comment: null,
mimeType: 'application/zip',
encodeFileName: e.utf8encode,
})),
(c.type = c.type.toLowerCase()),
(c.compression = c.compression.toUpperCase()),
'binarystring' === c.type && (c.type = 'string'),
!c.type)
)
throw new Error('No output type specified.');
f.checkSupport(c.type),
('darwin' !== c.platform &&
'freebsd' !== c.platform &&
'linux' !== c.platform &&
'sunos' !== c.platform) ||
(c.platform = 'UNIX'),
'win32' === c.platform && (c.platform = 'DOS');
var d = c.comment || this.comment || '';
b = l.generateWorker(this, c, d);
} catch (i) {
(b = new g('error')), b.error(i);
}
return new h(b, c.type || 'string', c.mimeType);
},
generateAsync: function (a, b) {
return this.generateInternalStream(a).accumulate(b);
},
generateNodeStream: function (a, b) {
return (
(a = a || {}),
a.type || (a.type = 'nodebuffer'),
this.generateInternalStream(a).toNodejsStream(b)
);
},
};
b.exports = s;
},
{
'./compressedObject': 2,
'./defaults': 5,
'./generate': 9,
'./nodejs/NodejsStreamInputAdapter': 12,
'./nodejsUtils': 14,
'./stream/GenericWorker': 28,
'./stream/StreamHelper': 29,
'./utf8': 31,
'./utils': 32,
'./zipObject': 35,
},
],
16: [
function (a, b, c) {
b.exports = a('stream');
},
{ stream: void 0 },
],
17: [
function (a, b, c) {
'use strict';
function d(a) {
e.call(this, a);
for (var b = 0; b < this.data.length; b++) a[b] = 255 & a[b];
}
var e = a('./DataReader'),
f = a('../utils');
f.inherits(d, e),
(d.prototype.byteAt = function (a) {
return this.data[this.zero + a];
}),
(d.prototype.lastIndexOfSignature = function (a) {
for (
var b = a.charCodeAt(0),
c = a.charCodeAt(1),
d = a.charCodeAt(2),
e = a.charCodeAt(3),
f = this.length - 4;
f >= 0;
--f
)
if (
this.data[f] === b &&
this.data[f + 1] === c &&
this.data[f + 2] === d &&
this.data[f + 3] === e
)
return f - this.zero;
return -1;
}),
(d.prototype.readAndCheckSignature = function (a) {
var b = a.charCodeAt(0),
c = a.charCodeAt(1),
d = a.charCodeAt(2),
e = a.charCodeAt(3),
f = this.readData(4);
return b === f[0] && c === f[1] && d === f[2] && e === f[3];
}),
(d.prototype.readData = function (a) {
if ((this.checkOffset(a), 0 === a)) return [];
var b = this.data.slice(
this.zero + this.index,
this.zero + this.index + a
);
return (this.index += a), b;
}),
(b.exports = d);
},
{ '../utils': 32, './DataReader': 18 },
],
18: [
function (a, b, c) {
'use strict';
function d(a) {
(this.data = a),
(this.length = a.length),
(this.index = 0),
(this.zero = 0);
}
var e = a('../utils');
(d.prototype = {
checkOffset: function (a) {
this.checkIndex(this.index + a);
},
checkIndex: function (a) {
if (this.length < this.zero + a || a < 0)
throw new Error(
'End of data reached (data length = ' +
this.length +
', asked index = ' +
a +
'). Corrupted zip ?'
);
},
setIndex: function (a) {
this.checkIndex(a), (this.index = a);
},
skip: function (a) {
this.setIndex(this.index + a);
},
byteAt: function (a) {},
readInt: function (a) {
var b,
c = 0;
for (
this.checkOffset(a), b = this.index + a - 1;
b >= this.index;
b--
)
c = (c << 8) + this.byteAt(b);
return (this.index += a), c;
},
readString: function (a) {
return e.transformTo('string', this.readData(a));
},
readData: function (a) {},
lastIndexOfSignature: function (a) {},
readAndCheckSignature: function (a) {},
readDate: function () {
var a = this.readInt(4);
return new Date(
Date.UTC(
((a >> 25) & 127) + 1980,
((a >> 21) & 15) - 1,
(a >> 16) & 31,
(a >> 11) & 31,
(a >> 5) & 63,
(31 & a) << 1
)
);
},
}),
(b.exports = d);
},
{ '../utils': 32 },
],
19: [
function (a, b, c) {
'use strict';
function d(a) {
e.call(this, a);
}
var e = a('./Uint8ArrayReader'),
f = a('../utils');
f.inherits(d, e),
(d.prototype.readData = function (a) {
this.checkOffset(a);
var b = this.data.slice(
this.zero + this.index,
this.zero + this.index + a
);
return (this.index += a), b;
}),
(b.exports = d);
},
{ '../utils': 32, './Uint8ArrayReader': 21 },
],
20: [
function (a, b, c) {
'use strict';
function d(a) {
e.call(this, a);
}
var e = a('./DataReader'),
f = a('../utils');
f.inherits(d, e),
(d.prototype.byteAt = function (a) {
return this.data.charCodeAt(this.zero + a);
}),
(d.prototype.lastIndexOfSignature = function (a) {
return this.data.lastIndexOf(a) - this.zero;
}),
(d.prototype.readAndCheckSignature = function (a) {
var b = this.readData(4);
return a === b;
}),
(d.prototype.readData = function (a) {
this.checkOffset(a);
var b = this.data.slice(
this.zero + this.index,
this.zero + this.index + a
);
return (this.index += a), b;
}),
(b.exports = d);
},
{ '../utils': 32, './DataReader': 18 },
],
21: [
function (a, b, c) {
'use strict';
function d(a) {
e.call(this, a);
}
var e = a('./ArrayReader'),
f = a('../utils');
f.inherits(d, e),
(d.prototype.readData = function (a) {
if ((this.checkOffset(a), 0 === a)) return new Uint8Array(0);
var b = this.data.subarray(
this.zero + this.index,
this.zero + this.index + a
);
return (this.index += a), b;
}),
(b.exports = d);
},
{ '../utils': 32, './ArrayReader': 17 },
],
22: [
function (a, b, c) {
'use strict';
var d = a('../utils'),
e = a('../support'),
f = a('./ArrayReader'),
g = a('./StringReader'),
h = a('./NodeBufferReader'),
i = a('./Uint8ArrayReader');
b.exports = function (a) {
var b = d.getTypeOf(a);
return (
d.checkSupport(b),
'string' !== b || e.uint8array
? 'nodebuffer' === b
? new h(a)
: e.uint8array
? new i(d.transformTo('uint8array', a))
: new f(d.transformTo('array', a))
: new g(a)
);
};
},
{
'../support': 30,
'../utils': 32,
'./ArrayReader': 17,
'./NodeBufferReader': 19,
'./StringReader': 20,
'./Uint8ArrayReader': 21,
},
],
23: [
function (a, b, c) {
'use strict';
(c.LOCAL_FILE_HEADER = 'PK'),
(c.CENTRAL_FILE_HEADER = 'PK'),
(c.CENTRAL_DIRECTORY_END = 'PK'),
(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR = 'PK'),
(c.ZIP64_CENTRAL_DIRECTORY_END = 'PK'),
(c.DATA_DESCRIPTOR = 'PK\\b');
},
{},
],
24: [
function (a, b, c) {
'use strict';
function d(a) {
e.call(this, 'ConvertWorker to ' + a), (this.destType = a);
}
var e = a('./GenericWorker'),
f = a('../utils');
f.inherits(d, e),
(d.prototype.processChunk = function (a) {
this.push({
data: f.transformTo(this.destType, a.data),
meta: a.meta,
});
}),
(b.exports = d);
},
{ '../utils': 32, './GenericWorker': 28 },
],
25: [
function (a, b, c) {
'use strict';
function d() {
e.call(this, 'Crc32Probe'), this.withStreamInfo('crc32', 0);
}
var e = a('./GenericWorker'),
f = a('../crc32'),
g = a('../utils');
g.inherits(d, e),
(d.prototype.processChunk = function (a) {
(this.streamInfo.crc32 = f(a.data, this.streamInfo.crc32 || 0)),
this.push(a);
}),
(b.exports = d);
},
{ '../crc32': 4, '../utils': 32, './GenericWorker': 28 },
],
26: [
function (a, b, c) {
'use strict';
function d(a) {
f.call(this, 'DataLengthProbe for ' + a),
(this.propName = a),
this.withStreamInfo(a, 0);
}
var e = a('../utils'),
f = a('./GenericWorker');
e.inherits(d, f),
(d.prototype.processChunk = function (a) {
if (a) {
var b = this.streamInfo[this.propName] || 0;
this.streamInfo[this.propName] = b + a.data.length;
}
f.prototype.processChunk.call(this, a);
}),
(b.exports = d);
},
{ '../utils': 32, './GenericWorker': 28 },
],
27: [
function (a, b, c) {
'use strict';
function d(a) {
f.call(this, 'DataWorker');
var b = this;
(this.dataIsReady = !1),
(this.index = 0),
(this.max = 0),
(this.data = null),
(this.type = ''),
(this._tickScheduled = !1),
a.then(
function (a) {
(b.dataIsReady = !0),
(b.data = a),
(b.max = (a && a.length) || 0),
(b.type = e.getTypeOf(a)),
b.isPaused || b._tickAndRepeat();
},
function (a) {
b.error(a);
}
);
}
var e = a('../utils'),
f = a('./GenericWorker'),
g = 16384;
e.inherits(d, f),
(d.prototype.cleanUp = function () {
f.prototype.cleanUp.call(this), (this.data = null);
}),
(d.prototype.resume = function () {
return (
!!f.prototype.resume.call(this) &&
(!this._tickScheduled &&
this.dataIsReady &&
((this._tickScheduled = !0),
e.delay(this._tickAndRepeat, [], this)),
!0)
);
}),
(d.prototype._tickAndRepeat = function () {
(this._tickScheduled = !1),
this.isPaused ||
this.isFinished ||
(this._tick(),
this.isFinished ||
(e.delay(this._tickAndRepeat, [], this),
(this._tickScheduled = !0)));
}),
(d.prototype._tick = function () {
if (this.isPaused || this.isFinished) return !1;
var a = g,
b = null,
c = Math.min(this.max, this.index + a);
if (this.index >= this.max) return this.end();
switch (this.type) {
case 'string':
b = this.data.substring(this.index, c);
break;
case 'uint8array':
b = this.data.subarray(this.index, c);
break;
case 'array':
case 'nodebuffer':
b = this.data.slice(this.index, c);
}
return (
(this.index = c),
this.push({
data: b,
meta: {
percent: this.max ? (this.index / this.max) * 100 : 0,
},
})
);
}),
(b.exports = d);
},
{ '../utils': 32, './GenericWorker': 28 },
],
28: [
function (a, b, c) {
'use strict';
function d(a) {
(this.name = a || 'default'),
(this.streamInfo = {}),
(this.generatedError = null),
(this.extraStreamInfo = {}),
(this.isPaused = !0),
(this.isFinished = !1),
(this.isLocked = !1),
(this._listeners = { data: [], end: [], error: [] }),
(this.previous = null);
}
(d.prototype = {
push: function (a) {
this.emit('data', a);
},
end: function () {
if (this.isFinished) return !1;
this.flush();
try {
this.emit('end