@loaders.gl/zip
Advanced tools
Comparing version 3.4.14 to 3.4.15
"use strict"; | ||
var moduleExports = require('./index'); | ||
const moduleExports = require('./index'); | ||
globalThis.loaders = globalThis.loaders || {}; | ||
module.exports = Object.assign(globalThis.loaders, moduleExports); | ||
//# sourceMappingURL=bundle.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _tarBuilder.default; | ||
@@ -16,3 +16,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _zipLoader.ZipLoader; | ||
@@ -23,3 +23,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _zipWriter.ZipWriter; | ||
@@ -26,0 +26,0 @@ } |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,7 +7,6 @@ value: true | ||
exports.format = format; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var utils = _interopRequireWildcard(require("./utils")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var structure = { | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
const structure = { | ||
fileName: 100, | ||
@@ -33,11 +30,9 @@ fileMode: 8, | ||
function format(data, cb) { | ||
var buffer = utils.clean(512); | ||
var offset = 0; | ||
Object.entries(structure).forEach(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2.default)(_ref, 2), | ||
field = _ref2[0], | ||
length = _ref2[1]; | ||
var str = data[field] || ''; | ||
var i; | ||
var fieldLength; | ||
const buffer = utils.clean(512); | ||
let offset = 0; | ||
Object.entries(structure).forEach(_ref => { | ||
let [field, length] = _ref; | ||
const str = data[field] || ''; | ||
let i; | ||
let fieldLength; | ||
for (i = 0, fieldLength = str.length; i < fieldLength; i += 1) { | ||
@@ -44,0 +39,0 @@ buffer[offset] = str.charCodeAt(i); |
@@ -8,14 +8,11 @@ "use strict"; | ||
exports.default = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _utils = require("./utils"); | ||
var _header = require("./header"); | ||
var blockSize; | ||
var headerLength; | ||
var inputLength; | ||
var recordSize = 512; | ||
var Tar = function () { | ||
function Tar(recordsPerBlock) { | ||
(0, _classCallCheck2.default)(this, Tar); | ||
let blockSize; | ||
let headerLength; | ||
let inputLength; | ||
const recordSize = 512; | ||
class Tar { | ||
constructor(recordsPerBlock) { | ||
(0, _defineProperty2.default)(this, "written", void 0); | ||
@@ -34,106 +31,98 @@ (0, _defineProperty2.default)(this, "out", void 0); | ||
} | ||
(0, _createClass2.default)(Tar, [{ | ||
key: "append", | ||
value: function append(filepath, input, opts) { | ||
var checksum; | ||
if (typeof input === 'string') { | ||
input = (0, _utils.stringToUint8)(input); | ||
} else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) { | ||
var errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(input.constructor.toString()); | ||
var errorInput = errorInputMatch && errorInputMatch[1]; | ||
var errorMessage = "Invalid input type. You gave me: ".concat(errorInput); | ||
throw errorMessage; | ||
append(filepath, input, opts) { | ||
let checksum; | ||
if (typeof input === 'string') { | ||
input = (0, _utils.stringToUint8)(input); | ||
} else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) { | ||
const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(input.constructor.toString()); | ||
const errorInput = errorInputMatch && errorInputMatch[1]; | ||
const errorMessage = "Invalid input type. You gave me: ".concat(errorInput); | ||
throw errorMessage; | ||
} | ||
opts = opts || {}; | ||
const mode = opts.mode || parseInt('777', 8) & 0xfff; | ||
const mtime = opts.mtime || Math.floor(Number(new Date()) / 1000); | ||
const uid = opts.uid || 0; | ||
const gid = opts.gid || 0; | ||
const data = { | ||
fileName: filepath, | ||
fileMode: (0, _utils.pad)(mode, 7), | ||
uid: (0, _utils.pad)(uid, 7), | ||
gid: (0, _utils.pad)(gid, 7), | ||
fileSize: (0, _utils.pad)(input.length, 11), | ||
mtime: (0, _utils.pad)(mtime, 11), | ||
checksum: ' ', | ||
type: '0', | ||
ustar: 'ustar ', | ||
owner: opts.owner || '', | ||
group: opts.group || '' | ||
}; | ||
checksum = 0; | ||
Object.keys(data).forEach(key => { | ||
let i; | ||
const value = data[key]; | ||
let length; | ||
for (i = 0, length = value.length; i < length; i += 1) { | ||
checksum += value.charCodeAt(i); | ||
} | ||
opts = opts || {}; | ||
var mode = opts.mode || parseInt('777', 8) & 0xfff; | ||
var mtime = opts.mtime || Math.floor(Number(new Date()) / 1000); | ||
var uid = opts.uid || 0; | ||
var gid = opts.gid || 0; | ||
var data = { | ||
fileName: filepath, | ||
fileMode: (0, _utils.pad)(mode, 7), | ||
uid: (0, _utils.pad)(uid, 7), | ||
gid: (0, _utils.pad)(gid, 7), | ||
fileSize: (0, _utils.pad)(input.length, 11), | ||
mtime: (0, _utils.pad)(mtime, 11), | ||
checksum: ' ', | ||
type: '0', | ||
ustar: 'ustar ', | ||
owner: opts.owner || '', | ||
group: opts.group || '' | ||
}; | ||
checksum = 0; | ||
Object.keys(data).forEach(function (key) { | ||
var i; | ||
var value = data[key]; | ||
var length; | ||
for (i = 0, length = value.length; i < length; i += 1) { | ||
checksum += value.charCodeAt(i); | ||
} | ||
}); | ||
data.checksum = "".concat((0, _utils.pad)(checksum, 6), "\0 "); | ||
var headerArr = (0, _header.format)(data); | ||
headerLength = Math.ceil(headerArr.length / recordSize) * recordSize; | ||
inputLength = Math.ceil(input.length / recordSize) * recordSize; | ||
this.blocks.push({ | ||
header: headerArr, | ||
input: input, | ||
headerLength: headerLength, | ||
inputLength: inputLength | ||
}); | ||
} | ||
}, { | ||
key: "save", | ||
value: function save() { | ||
var buffers = []; | ||
var chunks = new Array(); | ||
var length = 0; | ||
var max = Math.pow(2, 20); | ||
var chunk = new Array(); | ||
this.blocks.forEach(function () { | ||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (length + b.headerLength + b.inputLength > max) { | ||
chunks.push({ | ||
blocks: chunk, | ||
length: length | ||
}); | ||
chunk = []; | ||
length = 0; | ||
} | ||
chunk.push(b); | ||
length += b.headerLength + b.inputLength; | ||
}); | ||
chunks.push({ | ||
blocks: chunk, | ||
length: length | ||
}); | ||
chunks.forEach(function () { | ||
var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var buffer = new Uint8Array(c.length); | ||
var written = 0; | ||
c.blocks.forEach(function () { | ||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
buffer.set(b.header, written); | ||
written += b.headerLength; | ||
buffer.set(b.input, written); | ||
written += b.inputLength; | ||
}); | ||
data.checksum = "".concat((0, _utils.pad)(checksum, 6), "\0 "); | ||
const headerArr = (0, _header.format)(data); | ||
headerLength = Math.ceil(headerArr.length / recordSize) * recordSize; | ||
inputLength = Math.ceil(input.length / recordSize) * recordSize; | ||
this.blocks.push({ | ||
header: headerArr, | ||
input, | ||
headerLength, | ||
inputLength | ||
}); | ||
} | ||
save() { | ||
const buffers = []; | ||
const chunks = new Array(); | ||
let length = 0; | ||
const max = Math.pow(2, 20); | ||
let chunk = new Array(); | ||
this.blocks.forEach(function () { | ||
let b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (length + b.headerLength + b.inputLength > max) { | ||
chunks.push({ | ||
blocks: chunk, | ||
length | ||
}); | ||
buffers.push(buffer); | ||
chunk = []; | ||
length = 0; | ||
} | ||
chunk.push(b); | ||
length += b.headerLength + b.inputLength; | ||
}); | ||
chunks.push({ | ||
blocks: chunk, | ||
length | ||
}); | ||
chunks.forEach(function () { | ||
let c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
const buffer = new Uint8Array(c.length); | ||
let written = 0; | ||
c.blocks.forEach(function () { | ||
let b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
buffer.set(b.header, written); | ||
written += b.headerLength; | ||
buffer.set(b.input, written); | ||
written += b.inputLength; | ||
}); | ||
buffers.push(new Uint8Array(2 * recordSize)); | ||
return new Blob(buffers, { | ||
type: 'octet/stream' | ||
}); | ||
} | ||
}, { | ||
key: "clear", | ||
value: function clear() { | ||
this.written = 0; | ||
this.out = (0, _utils.clean)(blockSize); | ||
} | ||
}]); | ||
return Tar; | ||
}(); | ||
buffers.push(buffer); | ||
}); | ||
buffers.push(new Uint8Array(2 * recordSize)); | ||
return new Blob(buffers, { | ||
type: 'octet/stream' | ||
}); | ||
} | ||
clear() { | ||
this.written = 0; | ||
this.out = (0, _utils.clean)(blockSize); | ||
} | ||
} | ||
var _default = Tar; | ||
exports.default = _default; | ||
//# sourceMappingURL=tar.js.map |
@@ -10,4 +10,4 @@ "use strict"; | ||
function clean(length) { | ||
var i; | ||
var buffer = new Uint8Array(length); | ||
let i; | ||
const buffer = new Uint8Array(length); | ||
for (i = 0; i < length; i += 1) { | ||
@@ -19,8 +19,8 @@ buffer[i] = 0; | ||
function pad(num, bytes, base) { | ||
var numStr = num.toString(base || 8); | ||
const numStr = num.toString(base || 8); | ||
return '000000000000'.substr(numStr.length + 12 - bytes) + numStr; | ||
} | ||
function stringToUint8(input, out, offset) { | ||
var i; | ||
var length; | ||
let i; | ||
let length; | ||
out = out || clean(input.length); | ||
@@ -27,0 +27,0 @@ offset = offset || 0; |
@@ -8,63 +8,37 @@ "use strict"; | ||
exports.default = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _tar = _interopRequireDefault(require("./lib/tar/tar")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var TAR_BUILDER_OPTIONS = { | ||
const TAR_BUILDER_OPTIONS = { | ||
recordsPerBlock: 20 | ||
}; | ||
var TARBuilder = function () { | ||
function TARBuilder(options) { | ||
(0, _classCallCheck2.default)(this, TARBuilder); | ||
class TARBuilder { | ||
static get properties() { | ||
return { | ||
id: 'tar', | ||
name: 'TAR', | ||
extensions: ['tar'], | ||
mimeTypes: ['application/x-tar'], | ||
builder: TARBuilder, | ||
options: TAR_BUILDER_OPTIONS | ||
}; | ||
} | ||
constructor(options) { | ||
(0, _defineProperty2.default)(this, "options", void 0); | ||
(0, _defineProperty2.default)(this, "tape", void 0); | ||
(0, _defineProperty2.default)(this, "count", 0); | ||
this.options = _objectSpread(_objectSpread({}, TAR_BUILDER_OPTIONS), options); | ||
this.options = { | ||
...TAR_BUILDER_OPTIONS, | ||
...options | ||
}; | ||
this.tape = new _tar.default(this.options.recordsPerBlock); | ||
} | ||
(0, _createClass2.default)(TARBuilder, [{ | ||
key: "addFile", | ||
value: function addFile(filename, buffer) { | ||
this.tape.append(filename, new Uint8Array(buffer)); | ||
this.count++; | ||
} | ||
}, { | ||
key: "build", | ||
value: function () { | ||
var _build = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() { | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", new Response(this.tape.save()).arrayBuffer()); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function build() { | ||
return _build.apply(this, arguments); | ||
} | ||
return build; | ||
}() | ||
}], [{ | ||
key: "properties", | ||
get: function get() { | ||
return { | ||
id: 'tar', | ||
name: 'TAR', | ||
extensions: ['tar'], | ||
mimeTypes: ['application/x-tar'], | ||
builder: TARBuilder, | ||
options: TAR_BUILDER_OPTIONS | ||
}; | ||
} | ||
}]); | ||
return TARBuilder; | ||
}(); | ||
addFile(filename, buffer) { | ||
this.tape.append(filename, new Uint8Array(buffer)); | ||
this.count++; | ||
} | ||
async build() { | ||
return new Response(this.tape.save()).arrayBuffer(); | ||
} | ||
} | ||
exports.default = TARBuilder; | ||
//# sourceMappingURL=tar-builder.js.map |
@@ -8,7 +8,5 @@ "use strict"; | ||
exports._typecheckZipLoader = exports.ZipLoader = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _jszip = _interopRequireDefault(require("jszip")); | ||
var VERSION = typeof "3.4.14" !== 'undefined' ? "3.4.14" : 'latest'; | ||
var ZipLoader = { | ||
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 'latest'; | ||
const ZipLoader = { | ||
id: 'zip', | ||
@@ -26,82 +24,35 @@ module: 'zip', | ||
exports.ZipLoader = ZipLoader; | ||
function parseZipAsync(_x) { | ||
return _parseZipAsync.apply(this, arguments); | ||
async function parseZipAsync(data) { | ||
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const promises = []; | ||
const fileMap = {}; | ||
try { | ||
const jsZip = new _jszip.default(); | ||
const zip = await jsZip.loadAsync(data, options); | ||
zip.forEach((relativePath, zipEntry) => { | ||
const subFilename = zipEntry.name; | ||
const promise = loadZipEntry(jsZip, subFilename, options).then(arrayBufferOrError => { | ||
fileMap[relativePath] = arrayBufferOrError; | ||
}); | ||
promises.push(promise); | ||
}); | ||
await Promise.all(promises); | ||
return fileMap; | ||
} catch (error) { | ||
options.log.error("Unable to read zip archive: ".concat(error)); | ||
throw error; | ||
} | ||
} | ||
function _parseZipAsync() { | ||
_parseZipAsync = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) { | ||
var options, | ||
promises, | ||
fileMap, | ||
jsZip, | ||
zip, | ||
_args = arguments; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
promises = []; | ||
fileMap = {}; | ||
_context.prev = 3; | ||
jsZip = new _jszip.default(); | ||
_context.next = 7; | ||
return jsZip.loadAsync(data, options); | ||
case 7: | ||
zip = _context.sent; | ||
zip.forEach(function (relativePath, zipEntry) { | ||
var subFilename = zipEntry.name; | ||
var promise = loadZipEntry(jsZip, subFilename, options).then(function (arrayBufferOrError) { | ||
fileMap[relativePath] = arrayBufferOrError; | ||
}); | ||
promises.push(promise); | ||
}); | ||
_context.next = 11; | ||
return Promise.all(promises); | ||
case 11: | ||
return _context.abrupt("return", fileMap); | ||
case 14: | ||
_context.prev = 14; | ||
_context.t0 = _context["catch"](3); | ||
options.log.error("Unable to read zip archive: ".concat(_context.t0)); | ||
throw _context.t0; | ||
case 18: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, null, [[3, 14]]); | ||
})); | ||
return _parseZipAsync.apply(this, arguments); | ||
async function loadZipEntry(jsZip, subFilename) { | ||
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
try { | ||
const arrayBuffer = await jsZip.file(subFilename).async(options.dataType || 'arraybuffer'); | ||
return arrayBuffer; | ||
} catch (error) { | ||
options.log.error("Unable to read ".concat(subFilename, " from zip archive: ").concat(error)); | ||
return error; | ||
} | ||
} | ||
function loadZipEntry(_x2, _x3) { | ||
return _loadZipEntry.apply(this, arguments); | ||
} | ||
function _loadZipEntry() { | ||
_loadZipEntry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(jsZip, subFilename) { | ||
var options, | ||
arrayBuffer, | ||
_args2 = arguments; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {}; | ||
_context2.prev = 1; | ||
_context2.next = 4; | ||
return jsZip.file(subFilename).async(options.dataType || 'arraybuffer'); | ||
case 4: | ||
arrayBuffer = _context2.sent; | ||
return _context2.abrupt("return", arrayBuffer); | ||
case 8: | ||
_context2.prev = 8; | ||
_context2.t0 = _context2["catch"](1); | ||
options.log.error("Unable to read ".concat(subFilename, " from zip archive: ").concat(_context2.t0)); | ||
return _context2.abrupt("return", _context2.t0); | ||
case 12: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, null, [[1, 8]]); | ||
})); | ||
return _loadZipEntry.apply(this, arguments); | ||
} | ||
var _typecheckZipLoader = ZipLoader; | ||
const _typecheckZipLoader = ZipLoader; | ||
exports._typecheckZipLoader = _typecheckZipLoader; | ||
//# sourceMappingURL=zip-loader.js.map |
@@ -8,6 +8,4 @@ "use strict"; | ||
exports.ZipWriter = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _jszip = _interopRequireDefault(require("jszip")); | ||
var ZipWriter = { | ||
const ZipWriter = { | ||
name: 'Zip Archive', | ||
@@ -20,40 +18,20 @@ extensions: ['zip'], | ||
exports.ZipWriter = ZipWriter; | ||
function encodeZipAsync(_x) { | ||
return _encodeZipAsync.apply(this, arguments); | ||
async function encodeZipAsync(fileMap) { | ||
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const jsZip = new _jszip.default(); | ||
for (const subFileName in fileMap) { | ||
const subFileData = fileMap[subFileName]; | ||
jsZip.file(subFileName, subFileData, options); | ||
} | ||
options = Object.assign({}, options, { | ||
type: 'arraybuffer' | ||
}); | ||
const { | ||
onUpdate = () => {} | ||
} = options; | ||
return jsZip.generateAsync(options, onUpdate).catch(error => { | ||
options.log.error("Unable to write zip archive: ".concat(error)); | ||
throw error; | ||
}); | ||
} | ||
function _encodeZipAsync() { | ||
_encodeZipAsync = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(fileMap) { | ||
var options, | ||
jsZip, | ||
subFileName, | ||
subFileData, | ||
_options, | ||
_options$onUpdate, | ||
onUpdate, | ||
_args = arguments; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
jsZip = new _jszip.default(); | ||
for (subFileName in fileMap) { | ||
subFileData = fileMap[subFileName]; | ||
jsZip.file(subFileName, subFileData, options); | ||
} | ||
options = Object.assign({}, options, { | ||
type: 'arraybuffer' | ||
}); | ||
_options = options, _options$onUpdate = _options.onUpdate, onUpdate = _options$onUpdate === void 0 ? function () {} : _options$onUpdate; | ||
return _context.abrupt("return", jsZip.generateAsync(options, onUpdate).catch(function (error) { | ||
options.log.error("Unable to write zip archive: ".concat(error)); | ||
throw error; | ||
})); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
})); | ||
return _encodeZipAsync.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=zip-writer.js.map |
import JSZip from 'jszip'; | ||
const VERSION = typeof "3.4.14" !== 'undefined' ? "3.4.14" : 'latest'; | ||
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 'latest'; | ||
export const ZipLoader = { | ||
@@ -4,0 +4,0 @@ id: 'zip', |
{ | ||
"name": "@loaders.gl/zip", | ||
"version": "3.4.14", | ||
"version": "3.4.15", | ||
"description": "Zip Archive Loader", | ||
@@ -35,3 +35,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "dffa197c6ae79bac5277d5e8a132f4cd274e74e5" | ||
"gitHead": "19e941d5805568e449ef9092490d6568a4853298" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273351
4347