js-file-downloader
Advanced tools
Comparing version 1.1.24 to 1.1.25
@@ -99,779 +99,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ "./node_modules/@babel/runtime/regenerator/index.js": | ||
/*!**********************************************************!*\ | ||
!*** ./node_modules/@babel/runtime/regenerator/index.js ***! | ||
\**********************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(/*! regenerator-runtime */ "./node_modules/regenerator-runtime/runtime.js"); | ||
/***/ }), | ||
/***/ "./node_modules/regenerator-runtime/runtime.js": | ||
/*!*****************************************************!*\ | ||
!*** ./node_modules/regenerator-runtime/runtime.js ***! | ||
\*****************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var runtime = (function (exports) { | ||
"use strict"; | ||
var Op = Object.prototype; | ||
var hasOwn = Op.hasOwnProperty; | ||
var undefined; // More compressible than void 0. | ||
var $Symbol = typeof Symbol === "function" ? Symbol : {}; | ||
var iteratorSymbol = $Symbol.iterator || "@@iterator"; | ||
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; | ||
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
return obj[key]; | ||
} | ||
try { | ||
// IE 8 has a broken Object.defineProperty that only works on DOM objects. | ||
define({}, ""); | ||
} catch (err) { | ||
define = function(obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; | ||
var generator = Object.create(protoGenerator.prototype); | ||
var context = new Context(tryLocsList || []); | ||
// The ._invoke method unifies the implementations of the .next, | ||
// .throw, and .return methods. | ||
generator._invoke = makeInvokeMethod(innerFn, self, context); | ||
return generator; | ||
} | ||
exports.wrap = wrap; | ||
// Try/catch helper to minimize deoptimizations. Returns a completion | ||
// record like context.tryEntries[i].completion. This interface could | ||
// have been (and was previously) designed to take a closure to be | ||
// invoked without arguments, but in all the cases we care about we | ||
// already have an existing method we want to call, so there's no need | ||
// to create a new function object. We can even get away with assuming | ||
// the method takes exactly one argument, since that happens to be true | ||
// in every case, so we don't have to touch the arguments object. The | ||
// only additional allocation required is the completion record, which | ||
// has a stable shape and so hopefully should be cheap to allocate. | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { type: "normal", arg: fn.call(obj, arg) }; | ||
} catch (err) { | ||
return { type: "throw", arg: err }; | ||
} | ||
} | ||
var GenStateSuspendedStart = "suspendedStart"; | ||
var GenStateSuspendedYield = "suspendedYield"; | ||
var GenStateExecuting = "executing"; | ||
var GenStateCompleted = "completed"; | ||
// Returning this object from the innerFn has the same effect as | ||
// breaking out of the dispatch switch statement. | ||
var ContinueSentinel = {}; | ||
// Dummy constructor functions that we use as the .constructor and | ||
// .constructor.prototype properties for functions that return Generator | ||
// objects. For full spec compliance, you may wish to configure your | ||
// minifier not to mangle the names of these two functions. | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
// This is a polyfill for %IteratorPrototype% for environments that | ||
// don't natively support it. | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf; | ||
var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
if (NativeIteratorPrototype && | ||
NativeIteratorPrototype !== Op && | ||
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { | ||
// This environment has a native %IteratorPrototype%; use it instead | ||
// of the polyfill. | ||
IteratorPrototype = NativeIteratorPrototype; | ||
} | ||
var Gp = GeneratorFunctionPrototype.prototype = | ||
Generator.prototype = Object.create(IteratorPrototype); | ||
GeneratorFunction.prototype = GeneratorFunctionPrototype; | ||
define(Gp, "constructor", GeneratorFunctionPrototype); | ||
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); | ||
GeneratorFunction.displayName = define( | ||
GeneratorFunctionPrototype, | ||
toStringTagSymbol, | ||
"GeneratorFunction" | ||
); | ||
// Helper for defining the .next, .throw, and .return methods of the | ||
// Iterator interface in terms of a single ._invoke method. | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function(method) { | ||
define(prototype, method, function(arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
exports.isGeneratorFunction = function(genFun) { | ||
var ctor = typeof genFun === "function" && genFun.constructor; | ||
return ctor | ||
? ctor === GeneratorFunction || | ||
// For the native GeneratorFunction constructor, the best we can | ||
// do is to check its .name property. | ||
(ctor.displayName || ctor.name) === "GeneratorFunction" | ||
: false; | ||
}; | ||
exports.mark = function(genFun) { | ||
if (Object.setPrototypeOf) { | ||
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); | ||
} else { | ||
genFun.__proto__ = GeneratorFunctionPrototype; | ||
define(genFun, toStringTagSymbol, "GeneratorFunction"); | ||
} | ||
genFun.prototype = Object.create(Gp); | ||
return genFun; | ||
}; | ||
// Within the body of any async function, `await x` is transformed to | ||
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test | ||
// `hasOwn.call(value, "__await")` to determine if the yielded value is | ||
// meant to be awaited. | ||
exports.awrap = function(arg) { | ||
return { __await: arg }; | ||
}; | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if (record.type === "throw") { | ||
reject(record.arg); | ||
} else { | ||
var result = record.arg; | ||
var value = result.value; | ||
if (value && | ||
typeof value === "object" && | ||
hasOwn.call(value, "__await")) { | ||
return PromiseImpl.resolve(value.__await).then(function(value) { | ||
invoke("next", value, resolve, reject); | ||
}, function(err) { | ||
invoke("throw", err, resolve, reject); | ||
}); | ||
} | ||
return PromiseImpl.resolve(value).then(function(unwrapped) { | ||
// When a yielded Promise is resolved, its final value becomes | ||
// the .value of the Promise<{value,done}> result for the | ||
// current iteration. | ||
result.value = unwrapped; | ||
resolve(result); | ||
}, function(error) { | ||
// If a rejected Promise was yielded, throw the rejection back | ||
// into the async generator function so it can be handled there. | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
} | ||
var previousPromise; | ||
function enqueue(method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function(resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = | ||
// If enqueue has been called before, then we want to wait until | ||
// all previous Promises have been resolved before calling invoke, | ||
// so that results are always delivered in the correct order. If | ||
// enqueue has not been called before, then it is important to | ||
// call invoke immediately, without waiting on a callback to fire, | ||
// so that the async generator function has the opportunity to do | ||
// any necessary setup in a predictable way. This predictability | ||
// is why the Promise constructor synchronously invokes its | ||
// executor callback, and why async functions synchronously | ||
// execute code before the first await. Since we implement simple | ||
// async functions in terms of async generators, it is especially | ||
// important to get this right, even though it requires care. | ||
previousPromise ? previousPromise.then( | ||
callInvokeWithMethodAndArg, | ||
// Avoid propagating failures to Promises returned by later | ||
// invocations of the iterator. | ||
callInvokeWithMethodAndArg | ||
) : callInvokeWithMethodAndArg(); | ||
} | ||
// Define the unified helper method that is used to implement .next, | ||
// .throw, and .return (see defineIteratorMethods). | ||
this._invoke = enqueue; | ||
} | ||
defineIteratorMethods(AsyncIterator.prototype); | ||
define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}); | ||
exports.AsyncIterator = AsyncIterator; | ||
// Note that simple async functions are implemented on top of | ||
// AsyncIterator objects; they just return a Promise for the value of | ||
// the final result produced by the iterator. | ||
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
if (PromiseImpl === void 0) PromiseImpl = Promise; | ||
var iter = new AsyncIterator( | ||
wrap(innerFn, outerFn, self, tryLocsList), | ||
PromiseImpl | ||
); | ||
return exports.isGeneratorFunction(outerFn) | ||
? iter // If outerFn is a generator, return the full iterator. | ||
: iter.next().then(function(result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}; | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = GenStateSuspendedStart; | ||
return function invoke(method, arg) { | ||
if (state === GenStateExecuting) { | ||
throw new Error("Generator is already running"); | ||
} | ||
if (state === GenStateCompleted) { | ||
if (method === "throw") { | ||
throw arg; | ||
} | ||
// Be forgiving, per 25.3.3.3.3 of the spec: | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume | ||
return doneResult(); | ||
} | ||
context.method = method; | ||
context.arg = arg; | ||
while (true) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if (context.method === "next") { | ||
// Setting context._sent for legacy support of Babel's | ||
// function.sent implementation. | ||
context.sent = context._sent = context.arg; | ||
} else if (context.method === "throw") { | ||
if (state === GenStateSuspendedStart) { | ||
state = GenStateCompleted; | ||
throw context.arg; | ||
} | ||
context.dispatchException(context.arg); | ||
} else if (context.method === "return") { | ||
context.abrupt("return", context.arg); | ||
} | ||
state = GenStateExecuting; | ||
var record = tryCatch(innerFn, self, context); | ||
if (record.type === "normal") { | ||
// If an exception is thrown from innerFn, we leave state === | ||
// GenStateExecuting and loop back for another invocation. | ||
state = context.done | ||
? GenStateCompleted | ||
: GenStateSuspendedYield; | ||
if (record.arg === ContinueSentinel) { | ||
continue; | ||
} | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} else if (record.type === "throw") { | ||
state = GenStateCompleted; | ||
// Dispatch the exception by looping back around to the | ||
// context.dispatchException(context.arg) call above. | ||
context.method = "throw"; | ||
context.arg = record.arg; | ||
} | ||
} | ||
}; | ||
} | ||
// Call delegate.iterator[context.method](context.arg) and handle the | ||
// result, either by returning a { value, done } result from the | ||
// delegate iterator, or by modifying context.method and context.arg, | ||
// setting context.delegate to null, and returning the ContinueSentinel. | ||
function maybeInvokeDelegate(delegate, context) { | ||
var method = delegate.iterator[context.method]; | ||
if (method === undefined) { | ||
// A .throw or .return when the delegate iterator has no .throw | ||
// method always terminates the yield* loop. | ||
context.delegate = null; | ||
if (context.method === "throw") { | ||
// Note: ["return"] must be used for ES3 parsing compatibility. | ||
if (delegate.iterator["return"]) { | ||
// If the delegate iterator has a return method, give it a | ||
// chance to clean up. | ||
context.method = "return"; | ||
context.arg = undefined; | ||
maybeInvokeDelegate(delegate, context); | ||
if (context.method === "throw") { | ||
// If maybeInvokeDelegate(context) changed context.method from | ||
// "return" to "throw", let that override the TypeError below. | ||
return ContinueSentinel; | ||
} | ||
} | ||
context.method = "throw"; | ||
context.arg = new TypeError( | ||
"The iterator does not provide a 'throw' method"); | ||
} | ||
return ContinueSentinel; | ||
} | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if (record.type === "throw") { | ||
context.method = "throw"; | ||
context.arg = record.arg; | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
var info = record.arg; | ||
if (! info) { | ||
context.method = "throw"; | ||
context.arg = new TypeError("iterator result is not an object"); | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
if (info.done) { | ||
// Assign the result of the finished delegate to the temporary | ||
// variable specified by delegate.resultName (see delegateYield). | ||
context[delegate.resultName] = info.value; | ||
// Resume execution at the desired location (see delegateYield). | ||
context.next = delegate.nextLoc; | ||
// If context.method was "throw" but the delegate handled the | ||
// exception, let the outer generator proceed normally. If | ||
// context.method was "next", forget context.arg since it has been | ||
// "consumed" by the delegate iterator. If context.method was | ||
// "return", allow the original .return call to continue in the | ||
// outer generator. | ||
if (context.method !== "return") { | ||
context.method = "next"; | ||
context.arg = undefined; | ||
} | ||
} else { | ||
// Re-yield the result returned by the delegate method. | ||
return info; | ||
} | ||
// The delegate iterator is finished, so forget it and continue with | ||
// the outer generator. | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
// Define Generator.prototype.{next,throw,return} in terms of the | ||
// unified ._invoke helper method. | ||
defineIteratorMethods(Gp); | ||
define(Gp, toStringTagSymbol, "Generator"); | ||
// A Generator should always return itself as the iterator object when the | ||
// @@iterator function is called on it. Some browsers' implementations of the | ||
// iterator prototype chain incorrectly implement this, causing the Generator | ||
// object to not be returned from this call. This ensures that doesn't happen. | ||
// See https://github.com/facebook/regenerator/issues/274 for more details. | ||
define(Gp, iteratorSymbol, function() { | ||
return this; | ||
}); | ||
define(Gp, "toString", function() { | ||
return "[object Generator]"; | ||
}); | ||
function pushTryEntry(locs) { | ||
var entry = { tryLoc: locs[0] }; | ||
if (1 in locs) { | ||
entry.catchLoc = locs[1]; | ||
} | ||
if (2 in locs) { | ||
entry.finallyLoc = locs[2]; | ||
entry.afterLoc = locs[3]; | ||
} | ||
this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal"; | ||
delete record.arg; | ||
entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
// The root entry object (effectively a try statement without a catch | ||
// or a finally block) gives us a place to store values thrown from | ||
// locations where there is no enclosing try statement. | ||
this.tryEntries = [{ tryLoc: "root" }]; | ||
tryLocsList.forEach(pushTryEntry, this); | ||
this.reset(true); | ||
} | ||
exports.keys = function(object) { | ||
var keys = []; | ||
for (var key in object) { | ||
keys.push(key); | ||
} | ||
keys.reverse(); | ||
// Rather than returning an object with a next method, we keep | ||
// things simple and return the next function itself. | ||
return function next() { | ||
while (keys.length) { | ||
var key = keys.pop(); | ||
if (key in object) { | ||
next.value = key; | ||
next.done = false; | ||
return next; | ||
} | ||
} | ||
// To avoid creating an additional object, we just hang the .value | ||
// and .done properties off the next function object itself. This | ||
// also ensures that the minifier will not anonymize the function. | ||
next.done = true; | ||
return next; | ||
}; | ||
}; | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) { | ||
return iteratorMethod.call(iterable); | ||
} | ||
if (typeof iterable.next === "function") { | ||
return iterable; | ||
} | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, next = function next() { | ||
while (++i < iterable.length) { | ||
if (hasOwn.call(iterable, i)) { | ||
next.value = iterable[i]; | ||
next.done = false; | ||
return next; | ||
} | ||
} | ||
next.value = undefined; | ||
next.done = true; | ||
return next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
// Return an iterator with no values. | ||
return { next: doneResult }; | ||
} | ||
exports.values = values; | ||
function doneResult() { | ||
return { value: undefined, done: true }; | ||
} | ||
Context.prototype = { | ||
constructor: Context, | ||
reset: function(skipTempReset) { | ||
this.prev = 0; | ||
this.next = 0; | ||
// Resetting context._sent for legacy support of Babel's | ||
// function.sent implementation. | ||
this.sent = this._sent = undefined; | ||
this.done = false; | ||
this.delegate = null; | ||
this.method = "next"; | ||
this.arg = undefined; | ||
this.tryEntries.forEach(resetTryEntry); | ||
if (!skipTempReset) { | ||
for (var name in this) { | ||
// Not sure about the optimal order of these conditions: | ||
if (name.charAt(0) === "t" && | ||
hasOwn.call(this, name) && | ||
!isNaN(+name.slice(1))) { | ||
this[name] = undefined; | ||
} | ||
} | ||
} | ||
}, | ||
stop: function() { | ||
this.done = true; | ||
var rootEntry = this.tryEntries[0]; | ||
var rootRecord = rootEntry.completion; | ||
if (rootRecord.type === "throw") { | ||
throw rootRecord.arg; | ||
} | ||
return this.rval; | ||
}, | ||
dispatchException: function(exception) { | ||
if (this.done) { | ||
throw exception; | ||
} | ||
var context = this; | ||
function handle(loc, caught) { | ||
record.type = "throw"; | ||
record.arg = exception; | ||
context.next = loc; | ||
if (caught) { | ||
// If the dispatched exception was caught by a catch block, | ||
// then let that catch block handle the exception normally. | ||
context.method = "next"; | ||
context.arg = undefined; | ||
} | ||
return !! caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
var record = entry.completion; | ||
if (entry.tryLoc === "root") { | ||
// Exception thrown outside of any try block that could handle | ||
// it, so set the completion value of the entire function to | ||
// throw the exception. | ||
return handle("end"); | ||
} | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"); | ||
var hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
} else if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
} | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
} | ||
} else if (hasFinally) { | ||
if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
} | ||
} else { | ||
throw new Error("try statement without catch or finally"); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function(type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && | ||
hasOwn.call(entry, "finallyLoc") && | ||
this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
if (finallyEntry && | ||
(type === "break" || | ||
type === "continue") && | ||
finallyEntry.tryLoc <= arg && | ||
arg <= finallyEntry.finallyLoc) { | ||
// Ignore the finally entry if control is not jumping to a | ||
// location outside the try/catch block. | ||
finallyEntry = null; | ||
} | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
record.type = type; | ||
record.arg = arg; | ||
if (finallyEntry) { | ||
this.method = "next"; | ||
this.next = finallyEntry.finallyLoc; | ||
return ContinueSentinel; | ||
} | ||
return this.complete(record); | ||
}, | ||
complete: function(record, afterLoc) { | ||
if (record.type === "throw") { | ||
throw record.arg; | ||
} | ||
if (record.type === "break" || | ||
record.type === "continue") { | ||
this.next = record.arg; | ||
} else if (record.type === "return") { | ||
this.rval = this.arg = record.arg; | ||
this.method = "return"; | ||
this.next = "end"; | ||
} else if (record.type === "normal" && afterLoc) { | ||
this.next = afterLoc; | ||
} | ||
return ContinueSentinel; | ||
}, | ||
finish: function(finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) { | ||
this.complete(entry.completion, entry.afterLoc); | ||
resetTryEntry(entry); | ||
return ContinueSentinel; | ||
} | ||
} | ||
}, | ||
"catch": function(tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if (record.type === "throw") { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
// The context.catch method must only be called with a location | ||
// argument that corresponds to a known catch block. | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function(iterable, resultName, nextLoc) { | ||
this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}; | ||
if (this.method === "next") { | ||
// Deliberately forget the last sent value so that we don't | ||
// accidentally pass it on to the delegate. | ||
this.arg = undefined; | ||
} | ||
return ContinueSentinel; | ||
} | ||
}; | ||
// Regardless of whether this script is executing as a CommonJS module | ||
// or not, return the runtime object so that we can declare the variable | ||
// regeneratorRuntime in the outer scope, which allows this module to be | ||
// injected easily by `bin/regenerator --include-runtime script.js`. | ||
return exports; | ||
}( | ||
// If this script is executing as a CommonJS module, use module.exports | ||
// as the regeneratorRuntime namespace. Otherwise create a new empty | ||
// object. Either way, the resulting object will be used to initialize | ||
// the regeneratorRuntime variable at the top of this file. | ||
true ? module.exports : undefined | ||
)); | ||
try { | ||
regeneratorRuntime = runtime; | ||
} catch (accidentalStrictMode) { | ||
// This module should not be running in strict mode, so the above | ||
// assignment should always work unless something is misconfigured. Just | ||
// in case runtime.js accidentally runs in strict mode, in modern engines | ||
// we can explicitly access globalThis. In older engines we can escape | ||
// strict mode using a global Function call. This could conceivably fail | ||
// if a Content Security Policy forbids using Function, but in that case | ||
// the proper solution is to fix the accidental strict mode problem. If | ||
// you've misconfigured your bundler to force strict mode and applied a | ||
// CSP to forbid Function, and you're not willing to fix either of those | ||
// problems, please detail your unique predicament in a GitHub issue. | ||
if (typeof globalThis === "object") { | ||
globalThis.regeneratorRuntime = runtime; | ||
} else { | ||
Function("r", "regeneratorRuntime = r")(runtime); | ||
} | ||
} | ||
/***/ }), | ||
/***/ "./src/exception.js": | ||
@@ -888,36 +111,24 @@ /*!**************************!*\ | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "downloadException", function() { return downloadException; }); | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var DownloadException = /*#__PURE__*/function (_Error) { | ||
_inherits(DownloadException, _Error); | ||
var _super = _createSuper(DownloadException); | ||
function DownloadException(message, request) { | ||
var _this; | ||
_classCallCheck(this, DownloadException); | ||
_this = _super.call(this, "Downloader error: ".concat(message)); | ||
@@ -928,10 +139,9 @@ _this.request = request; | ||
} | ||
return DownloadException; | ||
return _createClass(DownloadException); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
; | ||
/** | ||
* @deprecated use DownloadException instead, it will be removed in next releases! | ||
*/ | ||
var downloadException = DownloadException; | ||
@@ -950,8 +160,6 @@ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); | ||
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); | ||
/* harmony import */ var _exception__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./exception */ "./src/exception.js"); | ||
/* harmony import */ var _signatures__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./signatures */ "./src/signatures.js"); | ||
/* harmony import */ var _exception__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./exception */ "./src/exception.js"); | ||
/* harmony import */ var _signatures__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./signatures */ "./src/signatures.js"); | ||
/*! | ||
* JS File Downloader v 1.1.24 | ||
* JS File Downloader v 1.1.25 | ||
* https://github.com/AleeeKoi/js-file-downloader | ||
@@ -966,15 +174,13 @@ * | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var DEFAULT_PARAMS = { | ||
@@ -995,3 +201,2 @@ timeout: 40000, | ||
}; | ||
var JsFileDownloader = /*#__PURE__*/function () { | ||
@@ -1005,5 +210,3 @@ /** | ||
var customParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, JsFileDownloader); | ||
this.params = Object.assign({}, DEFAULT_PARAMS, customParams); | ||
@@ -1013,6 +216,6 @@ this.link = this.createLink(); | ||
this.downloadedFile = null; | ||
this.abortController = undefined; | ||
if (this.params.autoStart) return this.downloadFile(); | ||
return this; | ||
} | ||
_createClass(JsFileDownloader, [{ | ||
@@ -1024,6 +227,13 @@ key: "start", | ||
}, { | ||
key: "abort", | ||
value: function abort(reason) { | ||
if (!this.abortController) { | ||
return; | ||
} | ||
this.abortController.abort(reason || 'Download cancelled'); | ||
} | ||
}, { | ||
key: "downloadFile", | ||
value: function downloadFile() { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -1034,14 +244,28 @@ _this.initDownload(resolve, reject); | ||
}, { | ||
key: "setAbortListner", | ||
value: function setAbortListner(abortListener) { | ||
if (!this.abortController) { | ||
return; | ||
} | ||
this.abortController.signal.addEventListener('abort', abortListener); | ||
} | ||
}, { | ||
key: "unsetAbortListner", | ||
value: function unsetAbortListner(abortListener) { | ||
if (!this.abortController) { | ||
return; | ||
} | ||
this.abortController.signal.removeEventListener('abort', abortListener); | ||
} | ||
}, { | ||
key: "initDownload", | ||
value: function initDownload(resolve, reject) { | ||
var _this2 = this; | ||
var fallback = function fallback() { | ||
_this2.link.target = '_blank'; | ||
_this2.link.href = _this2.params.url; | ||
_this2.clickLink(); | ||
}; // fallback for old browsers | ||
}; | ||
// fallback for old browsers | ||
if (!('download' in this.link) || this.isMobile()) { | ||
@@ -1051,41 +275,41 @@ fallback(); | ||
} | ||
this.request = this.createRequest(); | ||
this.abortController = 'AbortController' in window ? new AbortController() : null; | ||
var abortListener = function abortListener(_ref) { | ||
var target = _ref.target; | ||
_this2.unsetAbortListner(abortListener); | ||
!!_this2.request && _this2.request.abort(); | ||
reject(target.reason); | ||
}; | ||
this.setAbortListner(abortListener); | ||
if (!this.params.url) { | ||
return reject(new _exception__WEBPACK_IMPORTED_MODULE_1__["DownloadException"]('url param not defined!', this.request)); | ||
return reject(new _exception__WEBPACK_IMPORTED_MODULE_0__["DownloadException"]('url param not defined!', this.request)); | ||
} | ||
this.request.onload = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee() { | ||
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!(parseInt(_this2.request.status, 10) !== 200)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
return _context.abrupt("return", reject(new _exception__WEBPACK_IMPORTED_MODULE_1__["DownloadException"]("status code [".concat(_this2.request.status, "]"), _this2.request))); | ||
case 2: | ||
_context.next = 4; | ||
return _this2.startDownload(); | ||
case 4: | ||
return _context.abrupt("return", resolve(_this2)); | ||
case 5: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
this.request.onload = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
_this2.unsetAbortListner(abortListener); | ||
if (!(parseInt(_this2.request.status, 10) !== 200)) { | ||
_context.next = 3; | ||
break; | ||
} | ||
return _context.abrupt("return", reject(new _exception__WEBPACK_IMPORTED_MODULE_0__["DownloadException"]("status code [".concat(_this2.request.status, "]"), _this2.request))); | ||
case 3: | ||
_context.next = 5; | ||
return _this2.startDownload(); | ||
case 5: | ||
return _context.abrupt("return", resolve(_this2)); | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
})); | ||
this.request.ontimeout = function () { | ||
reject(new _exception__WEBPACK_IMPORTED_MODULE_1__["DownloadException"]('request timeout', _this2.request)); | ||
_this2.unsetAbortListner(abortListener); | ||
reject(new _exception__WEBPACK_IMPORTED_MODULE_0__["DownloadException"]('request timeout', _this2.request)); | ||
}; | ||
this.request.onerror = function () { | ||
_this2.unsetAbortListner(abortListener); | ||
if (_this2.params.nativeFallbackOnError) { | ||
@@ -1095,6 +319,5 @@ fallback(); | ||
} else { | ||
reject(new _exception__WEBPACK_IMPORTED_MODULE_1__["DownloadException"]('network error', _this2.request)); | ||
reject(new _exception__WEBPACK_IMPORTED_MODULE_0__["DownloadException"]('network error', _this2.request)); | ||
} | ||
}; | ||
this.request.send(this.params.body); | ||
@@ -1113,7 +336,5 @@ return this; | ||
request.open(this.params.method, this.params.url, true); | ||
if (this.params.contentType !== false) { | ||
request.setRequestHeader('Content-type', this.params.contentType); | ||
} | ||
this.params.headers.forEach(function (header) { | ||
@@ -1123,11 +344,8 @@ request.setRequestHeader(header.name, header.value); | ||
request.responseType = 'arraybuffer'; | ||
if (this.params.process && typeof this.params.process === 'function') { | ||
request.addEventListener('progress', this.params.process); | ||
} | ||
if (this.params.onloadstart && typeof this.params.onloadstart === 'function') { | ||
request.onloadstart = this.params.onloadstart; | ||
} | ||
request.timeout = this.params.timeout; | ||
@@ -1143,12 +361,9 @@ request.withCredentials = !!this.params.withCredentials || !!this.params.includeCredentials; | ||
return this.params.filename; | ||
} // Trying to get file name from response header | ||
} | ||
// Trying to get file name from response header | ||
var content = this.request.getResponseHeader('Content-Disposition'); | ||
var contentParts = []; | ||
if (content) { | ||
contentParts = content.replace(/["']/g, '').match(/filename\*?=([^;]+)/); | ||
} | ||
var extractedName = contentParts && contentParts.length >= 1 ? contentParts[1] : this.params.url.split('/').pop().split('?')[0]; | ||
@@ -1160,7 +375,6 @@ return this.params.nameCallback(extractedName); | ||
value: function getContentTypeFromFileSignature(file) { | ||
var signatures = Object.assign({}, _signatures__WEBPACK_IMPORTED_MODULE_2__["fileSignatures"], this.params.customFileSignatures); | ||
var signatures = Object.assign({}, _signatures__WEBPACK_IMPORTED_MODULE_1__["fileSignatures"], this.params.customFileSignatures); | ||
return new Promise(function (resolve, reject) { | ||
var reader = new FileReader(); | ||
var first4BytesOfFile = file.slice(0, 4); | ||
reader.onloadend = function (evt) { | ||
@@ -1170,6 +384,5 @@ if (evt.target.readyState !== FileReader.DONE) { | ||
return; | ||
} // Since an array buffer is just a generic way to represent a binary buffer | ||
} | ||
// Since an array buffer is just a generic way to represent a binary buffer | ||
// we need to create a TypedArray, in this case an Uint8Array | ||
var uint = new Uint8Array(evt.target.result); | ||
@@ -1184,5 +397,5 @@ var bytes = []; | ||
}; | ||
reader.onerror = reject; | ||
reader.onerror = reject; // read first 4 bytes of sliced file as an array buffer | ||
// read first 4 bytes of sliced file as an array buffer | ||
reader.readAsArrayBuffer(first4BytesOfFile); | ||
@@ -1200,50 +413,39 @@ }); | ||
var _this3 = this; | ||
return new Promise( /*#__PURE__*/function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee2(resolve) { | ||
var contentTypeDetermination, defaultContentType, headerContentType, signatureContentType, _headerContentType, _signatureContentType, _ref3, _signatureContentType2; | ||
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
contentTypeDetermination = _this3.params.contentTypeDetermination; | ||
defaultContentType = 'application/octet-stream'; | ||
if (contentTypeDetermination === 'header' || contentTypeDetermination === 'full') { | ||
headerContentType = _this3.getContentTypeFromResponseHeader(); | ||
} | ||
if (!(contentTypeDetermination === 'signature' || contentTypeDetermination === 'full')) { | ||
_context2.next = 7; | ||
break; | ||
} | ||
_context2.next = 6; | ||
return _this3.getContentTypeFromFileSignature(new Blob([response])); | ||
case 6: | ||
signatureContentType = _context2.sent; | ||
case 7: | ||
if (contentTypeDetermination === 'header') { | ||
resolve((_headerContentType = headerContentType) !== null && _headerContentType !== void 0 ? _headerContentType : defaultContentType); | ||
} else if (contentTypeDetermination === 'signature') { | ||
resolve((_signatureContentType = signatureContentType) !== null && _signatureContentType !== void 0 ? _signatureContentType : defaultContentType); | ||
} else if (contentTypeDetermination === 'full') { | ||
resolve((_ref3 = (_signatureContentType2 = signatureContentType) !== null && _signatureContentType2 !== void 0 ? _signatureContentType2 : headerContentType) !== null && _ref3 !== void 0 ? _ref3 : defaultContentType); | ||
} else { | ||
resolve(defaultContentType); | ||
} | ||
case 8: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) { | ||
var contentTypeDetermination, defaultContentType, headerContentType, signatureContentType, _headerContentType, _signatureContentType, _ref4, _signatureContentType2; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
contentTypeDetermination = _this3.params.contentTypeDetermination; | ||
defaultContentType = 'application/octet-stream'; | ||
if (contentTypeDetermination === 'header' || contentTypeDetermination === 'full') { | ||
headerContentType = _this3.getContentTypeFromResponseHeader(); | ||
} | ||
if (!(contentTypeDetermination === 'signature' || contentTypeDetermination === 'full')) { | ||
_context2.next = 7; | ||
break; | ||
} | ||
_context2.next = 6; | ||
return _this3.getContentTypeFromFileSignature(new Blob([response])); | ||
case 6: | ||
signatureContentType = _context2.sent; | ||
case 7: | ||
if (contentTypeDetermination === 'header') { | ||
resolve((_headerContentType = headerContentType) !== null && _headerContentType !== void 0 ? _headerContentType : defaultContentType); | ||
} else if (contentTypeDetermination === 'signature') { | ||
resolve((_signatureContentType = signatureContentType) !== null && _signatureContentType !== void 0 ? _signatureContentType : defaultContentType); | ||
} else if (contentTypeDetermination === 'full') { | ||
resolve((_ref4 = (_signatureContentType2 = signatureContentType) !== null && _signatureContentType2 !== void 0 ? _signatureContentType2 : headerContentType) !== null && _ref4 !== void 0 ? _ref4 : defaultContentType); | ||
} else { | ||
resolve(defaultContentType); | ||
} | ||
case 8: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
return function (_x) { | ||
return _ref2.apply(this, arguments); | ||
return _ref3.apply(this, arguments); | ||
}; | ||
@@ -1263,3 +465,2 @@ }()); | ||
var event; | ||
try { | ||
@@ -1271,3 +472,2 @@ event = new MouseEvent('click'); | ||
} | ||
this.link.dispatchEvent(event); | ||
@@ -1278,39 +478,31 @@ } | ||
value: function () { | ||
var _getFile = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee3(response, fileName) { | ||
var _getFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(response, fileName) { | ||
var type, file, options; | ||
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return this.getContentType(response); | ||
case 2: | ||
type = _context3.sent; | ||
options = { | ||
type: type | ||
}; | ||
try { | ||
file = new File([response], fileName, options); | ||
} catch (e) { | ||
file = new Blob([response], options); | ||
file.name = fileName; | ||
file.lastModifiedDate = new Date(); | ||
} | ||
return _context3.abrupt("return", file); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
_context3.next = 2; | ||
return this.getContentType(response); | ||
case 2: | ||
type = _context3.sent; | ||
options = { | ||
type: type | ||
}; | ||
try { | ||
file = new File([response], fileName, options); | ||
} catch (e) { | ||
file = new Blob([response], options); | ||
file.name = fileName; | ||
file.lastModifiedDate = new Date(); | ||
} | ||
return _context3.abrupt("return", file); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3, this); | ||
})); | ||
function getFile(_x2, _x3) { | ||
return _getFile.apply(this, arguments); | ||
} | ||
return getFile; | ||
@@ -1321,51 +513,40 @@ }() | ||
value: function () { | ||
var _startDownload = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee4() { | ||
var _startDownload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
var fileName, objectUrl; | ||
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fileName = this.getFileName(); | ||
_context4.next = 3; | ||
return this.getFile(this.request.response, fileName); | ||
case 3: | ||
this.downloadedFile = _context4.sent; | ||
if (!('msSaveOrOpenBlob' in window.navigator)) { | ||
_context4.next = 6; | ||
break; | ||
} | ||
return _context4.abrupt("return", window.navigator.msSaveOrOpenBlob(this.downloadedFile, fileName)); | ||
case 6: | ||
objectUrl = window.URL.createObjectURL(this.downloadedFile); | ||
this.link.href = objectUrl; | ||
this.link.download = fileName; | ||
this.clickLink(); | ||
setTimeout(function () { | ||
(window.URL || window.webkitURL || window).revokeObjectURL(objectUrl); | ||
}, 1000 * 40); | ||
return _context4.abrupt("return", this.downloadedFile); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fileName = this.getFileName(); | ||
_context4.next = 3; | ||
return this.getFile(this.request.response, fileName); | ||
case 3: | ||
this.downloadedFile = _context4.sent; | ||
if (!('msSaveOrOpenBlob' in window.navigator)) { | ||
_context4.next = 6; | ||
break; | ||
} | ||
return _context4.abrupt("return", window.navigator.msSaveOrOpenBlob(this.downloadedFile, fileName)); | ||
case 6: | ||
objectUrl = window.URL.createObjectURL(this.downloadedFile); | ||
this.link.href = objectUrl; | ||
this.link.download = fileName; | ||
this.clickLink(); | ||
setTimeout(function () { | ||
(window.URL || window.webkitURL || window).revokeObjectURL(objectUrl); | ||
}, 1000 * 40); | ||
return _context4.abrupt("return", this.downloadedFile); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4, this); | ||
})); | ||
function startDownload() { | ||
return _startDownload.apply(this, arguments); | ||
} | ||
return startDownload; | ||
}() | ||
}]); | ||
return JsFileDownloader; | ||
}(); | ||
/* harmony default export */ __webpack_exports__["default"] = (JsFileDownloader); | ||
@@ -1372,0 +553,0 @@ |
@@ -1,4 +0,4 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.jsFileDownloader=e():t.jsFileDownloader=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){t.exports=r(1)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new E(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return L()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=b(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function p(){}function h(){}var d={};u(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==e&&r.call(v,o)&&(d=v);var m=h.prototype=f.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=h,u(m,"constructor",h),u(h,"constructor",p),p.displayName=u(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(g.prototype),u(g.prototype,i,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,a,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(0),o=r.n(n);function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){if(e&&("object"===i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return c(t,arguments,f(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,t)})(t)}function c(t,e,r){return(c=s()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&l(o,r.prototype),o}).apply(null,arguments)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var p=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(o,t);var e,r,n=(e=o,r=s(),function(){var t,n=f(e);if(r){var o=f(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return a(this,t)});function o(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(r=n.call(this,"Downloader error: ".concat(t))).request=e,r.name="DownloadException",r}return o}(u(Error)),h={"89504E47":"image/png",25504446:"application/pdf"}; | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.jsFileDownloader=e():t.jsFileDownloader=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,a=void 0,a=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===n(a)?a:String(a)),o)}var i,a}function i(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,l(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,t)})(t)}function u(t,e,r){return(u=c()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function s(t,e){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}r.r(e);var f=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(p,t);var e,r,n,a,u,f=(e=p,r=c(),function(){var t,n=l(e);if(r){var o=l(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return i(this,t)});function p(t,e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,p),(r=f.call(this,"Downloader error: ".concat(t))).request=e,r.name="DownloadException",r}return n=p,a&&o(n.prototype,a),u&&o(n,u),Object.defineProperty(n,"prototype",{writable:!1}),n}(a(Error)),p={"89504E47":"image/png",25504446:"application/pdf"}; | ||
/*! | ||
* JS File Downloader v 1.1.24 | ||
* JS File Downloader v 1.1.25 | ||
* https://github.com/AleeeKoi/js-file-downloader | ||
@@ -10,3 +10,3 @@ * | ||
*/ | ||
function d(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function y(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){d(i,n,o,a,u,"next",t)}function u(t){d(i,n,o,a,u,"throw",t)}a(void 0)}))}}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var w={timeout:4e4,headers:[],forceDesktopMode:!1,autoStart:!0,withCredentials:!1,method:"GET",nameCallback:function(t){return t},contentType:"application/x-www-form-urlencoded",body:null,nativeFallbackOnError:!1,contentTypeDetermination:!1},g=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this,t),this.params=Object.assign({},w,e),this.link=this.createLink(),this.request=null,this.downloadedFile=null,this.params.autoStart?this.downloadFile():this}var e,r,n,i,a;return e=t,(r=[{key:"start",value:function(){return this.downloadFile()}},{key:"downloadFile",value:function(){var t=this;return new Promise((function(e,r){t.initDownload(e,r)}))}},{key:"initDownload",value:function(t,e){var r=this,n=function(){r.link.target="_blank",r.link.href=r.params.url,r.clickLink()};return!("download"in this.link)||this.isMobile()?(n(),t()):(this.request=this.createRequest(),this.params.url?(this.request.onload=y(o.a.mark((function n(){return o.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(200===parseInt(r.request.status,10)){n.next=2;break}return n.abrupt("return",e(new p("status code [".concat(r.request.status,"]"),r.request)));case 2:return n.next=4,r.startDownload();case 4:return n.abrupt("return",t(r));case 5:case"end":return n.stop()}}),n)}))),this.request.ontimeout=function(){e(new p("request timeout",r.request))},this.request.onerror=function(){r.params.nativeFallbackOnError?(n(),t(r)):e(new p("network error",r.request))},this.request.send(this.params.body),this):e(new p("url param not defined!",this.request)))}},{key:"isMobile",value:function(){return!this.params.forceDesktopMode&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},{key:"createRequest",value:function(){var t=new XMLHttpRequest;return t.open(this.params.method,this.params.url,!0),!1!==this.params.contentType&&t.setRequestHeader("Content-type",this.params.contentType),this.params.headers.forEach((function(e){t.setRequestHeader(e.name,e.value)})),t.responseType="arraybuffer",this.params.process&&"function"==typeof this.params.process&&t.addEventListener("progress",this.params.process),this.params.onloadstart&&"function"==typeof this.params.onloadstart&&(t.onloadstart=this.params.onloadstart),t.timeout=this.params.timeout,t.withCredentials=!!this.params.withCredentials||!!this.params.includeCredentials,t}},{key:"getFileName",value:function(){if("string"==typeof this.params.filename)return this.params.filename;var t=this.request.getResponseHeader("Content-Disposition"),e=[];t&&(e=t.replace(/["']/g,"").match(/filename\*?=([^;]+)/));var r=e&&e.length>=1?e[1]:this.params.url.split("/").pop().split("?")[0];return this.params.nameCallback(r)}},{key:"getContentTypeFromFileSignature",value:function(t){var e=Object.assign({},h,this.params.customFileSignatures);return new Promise((function(r,n){var o=new FileReader,i=t.slice(0,4);o.onloadend=function(t){if(t.target.readyState===FileReader.DONE){var o=new Uint8Array(t.target.result),i=[];o.forEach((function(t){i.push(t.toString(16))}));var a=i.join("").toUpperCase();r(e[a])}else n()},o.onerror=n,o.readAsArrayBuffer(i)}))}},{key:"getContentTypeFromResponseHeader",value:function(){return this.request.getResponseHeader("content-type")}},{key:"getContentType",value:function(t){var e=this;return new Promise(function(){var r=y(o.a.mark((function r(n){var i,a,u,c,s,l,f,p;return o.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=e.params.contentTypeDetermination,a="application/octet-stream","header"!==i&&"full"!==i||(u=e.getContentTypeFromResponseHeader()),"signature"!==i&&"full"!==i){r.next=7;break}return r.next=6,e.getContentTypeFromFileSignature(new Blob([t]));case 6:c=r.sent;case 7:n("header"===i?null!==(s=u)&&void 0!==s?s:a:"signature"===i?null!==(l=c)&&void 0!==l?l:a:"full"===i&&null!==(f=null!==(p=c)&&void 0!==p?p:u)&&void 0!==f?f:a);case 8:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}())}},{key:"createLink",value:function(){var t=document.createElement("a");return t.style.display="none",t}},{key:"clickLink",value:function(){var t;try{t=new MouseEvent("click")}catch(e){(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null)}this.link.dispatchEvent(t)}},{key:"getFile",value:(a=y(o.a.mark((function t(e,r){var n,i,a;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getContentType(e);case 2:n=t.sent,a={type:n};try{i=new File([e],r,a)}catch(t){(i=new Blob([e],a)).name=r,i.lastModifiedDate=new Date}return t.abrupt("return",i);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"startDownload",value:(i=y(o.a.mark((function t(){var e,r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getFileName(),t.next=3,this.getFile(this.request.response,e);case 3:if(this.downloadedFile=t.sent,!("msSaveOrOpenBlob"in window.navigator)){t.next=6;break}return t.abrupt("return",window.navigator.msSaveOrOpenBlob(this.downloadedFile,e));case 6:return r=window.URL.createObjectURL(this.downloadedFile),this.link.href=r,this.link.download=e,this.clickLink(),setTimeout((function(){(window.URL||window.webkitURL||window).revokeObjectURL(r)}),4e4),t.abrupt("return",this.downloadedFile);case 12:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})}])&&m(e.prototype,r),n&&m(e,n),t}();e.default=g}]).default})); | ||
function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */d=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function s(t,e,r,o){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),u=new S(o||[]);return n(a,"_invoke",{value:O(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function p(){}function y(){}function v(){}var m={};c(m,i,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(P([])));w&&w!==e&&r.call(w,i)&&(m=w);var g=v.prototype=p.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var o;n(this,"_invoke",{value:function(n,i){function a(){return new e((function(o,a){!function n(o,i,a,u){var c=l(t[o],t,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==h(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(n,i,o,a)}))}return o=o?o.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return F()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function P(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:F}}function F(){return{value:void 0,done:!0}}return y.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:y,configurable:!0}),y.displayName=c(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},k(x.prototype),c(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(g),c(g,u,"Generator"),c(g,i,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function y(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function v(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){y(i,n,o,a,u,"next",t)}function u(t){y(i,n,o,a,u,"throw",t)}a(void 0)}))}}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==h(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===h(i)?i:String(i)),n)}var o,i}var w={timeout:4e4,headers:[],forceDesktopMode:!1,autoStart:!0,withCredentials:!1,method:"GET",nameCallback:function(t){return t},contentType:"application/x-www-form-urlencoded",body:null,nativeFallbackOnError:!1,contentTypeDetermination:!1},g=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return m(this,t),this.params=Object.assign({},w,e),this.link=this.createLink(),this.request=null,this.downloadedFile=null,this.abortController=void 0,this.params.autoStart?this.downloadFile():this}var e,r,n,o,i;return e=t,(r=[{key:"start",value:function(){return this.downloadFile()}},{key:"abort",value:function(t){this.abortController&&this.abortController.abort(t||"Download cancelled")}},{key:"downloadFile",value:function(){var t=this;return new Promise((function(e,r){t.initDownload(e,r)}))}},{key:"setAbortListner",value:function(t){this.abortController&&this.abortController.signal.addEventListener("abort",t)}},{key:"unsetAbortListner",value:function(t){this.abortController&&this.abortController.signal.removeEventListener("abort",t)}},{key:"initDownload",value:function(t,e){var r=this,n=function(){r.link.target="_blank",r.link.href=r.params.url,r.clickLink()};if(!("download"in this.link)||this.isMobile())return n(),t();this.request=this.createRequest(),this.abortController="AbortController"in window?new AbortController:null;var o=function t(n){var o=n.target;r.unsetAbortListner(t),r.request&&r.request.abort(),e(o.reason)};return this.setAbortListner(o),this.params.url?(this.request.onload=v(d().mark((function n(){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r.unsetAbortListner(o),200===parseInt(r.request.status,10)){n.next=3;break}return n.abrupt("return",e(new f("status code [".concat(r.request.status,"]"),r.request)));case 3:return n.next=5,r.startDownload();case 5:return n.abrupt("return",t(r));case 6:case"end":return n.stop()}}),n)}))),this.request.ontimeout=function(){r.unsetAbortListner(o),e(new f("request timeout",r.request))},this.request.onerror=function(){r.unsetAbortListner(o),r.params.nativeFallbackOnError?(n(),t(r)):e(new f("network error",r.request))},this.request.send(this.params.body),this):e(new f("url param not defined!",this.request))}},{key:"isMobile",value:function(){return!this.params.forceDesktopMode&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},{key:"createRequest",value:function(){var t=new XMLHttpRequest;return t.open(this.params.method,this.params.url,!0),!1!==this.params.contentType&&t.setRequestHeader("Content-type",this.params.contentType),this.params.headers.forEach((function(e){t.setRequestHeader(e.name,e.value)})),t.responseType="arraybuffer",this.params.process&&"function"==typeof this.params.process&&t.addEventListener("progress",this.params.process),this.params.onloadstart&&"function"==typeof this.params.onloadstart&&(t.onloadstart=this.params.onloadstart),t.timeout=this.params.timeout,t.withCredentials=!!this.params.withCredentials||!!this.params.includeCredentials,t}},{key:"getFileName",value:function(){if("string"==typeof this.params.filename)return this.params.filename;var t=this.request.getResponseHeader("Content-Disposition"),e=[];t&&(e=t.replace(/["']/g,"").match(/filename\*?=([^;]+)/));var r=e&&e.length>=1?e[1]:this.params.url.split("/").pop().split("?")[0];return this.params.nameCallback(r)}},{key:"getContentTypeFromFileSignature",value:function(t){var e=Object.assign({},p,this.params.customFileSignatures);return new Promise((function(r,n){var o=new FileReader,i=t.slice(0,4);o.onloadend=function(t){if(t.target.readyState===FileReader.DONE){var o=new Uint8Array(t.target.result),i=[];o.forEach((function(t){i.push(t.toString(16))}));var a=i.join("").toUpperCase();r(e[a])}else n()},o.onerror=n,o.readAsArrayBuffer(i)}))}},{key:"getContentTypeFromResponseHeader",value:function(){return this.request.getResponseHeader("content-type")}},{key:"getContentType",value:function(t){var e=this;return new Promise(function(){var r=v(d().mark((function r(n){var o,i,a,u,c,s,l,f;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(o=e.params.contentTypeDetermination,i="application/octet-stream","header"!==o&&"full"!==o||(a=e.getContentTypeFromResponseHeader()),"signature"!==o&&"full"!==o){r.next=7;break}return r.next=6,e.getContentTypeFromFileSignature(new Blob([t]));case 6:u=r.sent;case 7:n("header"===o?null!==(c=a)&&void 0!==c?c:i:"signature"===o?null!==(s=u)&&void 0!==s?s:i:"full"===o&&null!==(l=null!==(f=u)&&void 0!==f?f:a)&&void 0!==l?l:i);case 8:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}())}},{key:"createLink",value:function(){var t=document.createElement("a");return t.style.display="none",t}},{key:"clickLink",value:function(){var t;try{t=new MouseEvent("click")}catch(e){(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null)}this.link.dispatchEvent(t)}},{key:"getFile",value:(i=v(d().mark((function t(e,r){var n,o,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getContentType(e);case 2:n=t.sent,i={type:n};try{o=new File([e],r,i)}catch(t){(o=new Blob([e],i)).name=r,o.lastModifiedDate=new Date}return t.abrupt("return",o);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"startDownload",value:(o=v(d().mark((function t(){var e,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getFileName(),t.next=3,this.getFile(this.request.response,e);case 3:if(this.downloadedFile=t.sent,!("msSaveOrOpenBlob"in window.navigator)){t.next=6;break}return t.abrupt("return",window.navigator.msSaveOrOpenBlob(this.downloadedFile,e));case 6:return r=window.URL.createObjectURL(this.downloadedFile),this.link.href=r,this.link.download=e,this.clickLink(),setTimeout((function(){(window.URL||window.webkitURL||window).revokeObjectURL(r)}),4e4),t.abrupt("return",this.downloadedFile);case 12:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})}])&&b(e.prototype,r),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.default=g}]).default})); | ||
//# sourceMappingURL=js-file-downloader.min.js.map |
@@ -27,2 +27,3 @@ declare module 'js-file-downloader' { | ||
downloadedFile: null | Blob | File; | ||
abort(reason: any): void; | ||
} | ||
@@ -29,0 +30,0 @@ interface JsFileDownloaderContructor { |
{ | ||
"name": "js-file-downloader", | ||
"version": "1.1.24", | ||
"version": "1.1.25", | ||
"description": "Small lib for a cool download experience", | ||
@@ -5,0 +5,0 @@ "main": "dist/js-file-downloader.js", |
@@ -22,2 +22,22 @@ <p align="center"> | ||
- [Install](#installing-with-package-manager) | ||
- [Basic usage](#basic-usage) | ||
- [Options](#options) | ||
- [process, check download status](#process-for-checking-download-status) | ||
- [onloadstart](#onloadstart-loadstart-event-listener) | ||
- [headers](#headers-of-request) | ||
- [filename](#filename) | ||
- [timeout](#timeout) | ||
- [autoStart](#autostart) | ||
- [forceDesktopMode](#forcedesktopmode) | ||
- [withCredentials](#withcredentials) | ||
- [method, GET/POST/...](#method) | ||
- [nameCallback, custom at runtime](#namecallback) | ||
- [contentType](#contenttype) | ||
- [nativeFallbackOnError](#nativefallbackonerror) | ||
- [body, of the request](#body) | ||
- [contentTypeDetermination](#contenttypedetermination) | ||
- [customFileSignatures](#customfilesignatures) | ||
- [abort, to stop pending downloading request](#abort) | ||
### Browser Compatibility | ||
@@ -76,3 +96,2 @@ | ||
### Options: | ||
@@ -267,3 +286,22 @@ | ||
``` | ||
___ | ||
### Abort: | ||
Setting `autoStart` option to `false` the process can be aborted calling the related method `abort`. The download promise is rejected, the reason can be customized passing is as the 1st param of the abort function. | ||
```js | ||
const download = new JsFileDownloader({ | ||
url: '...', | ||
autoStart: false | ||
}); | ||
download.start() | ||
.catch(function(reason){ | ||
// handle errors | ||
}); | ||
download.abort(/** reason */); | ||
``` | ||
___ | ||
### License | ||
@@ -270,0 +308,0 @@ |
@@ -41,2 +41,3 @@ /*! | ||
this.downloadedFile = null; | ||
this.abortController = undefined; | ||
@@ -52,2 +53,7 @@ if (this.params.autoStart) return this.downloadFile(); | ||
abort (reason) { | ||
if (!this.abortController) { return; } | ||
this.abortController.abort(reason || 'Download cancelled'); | ||
} | ||
downloadFile () { | ||
@@ -59,2 +65,12 @@ return new Promise((resolve, reject) => { | ||
setAbortListner (abortListener) { | ||
if (!this.abortController) { return; } | ||
this.abortController.signal.addEventListener('abort', abortListener); | ||
} | ||
unsetAbortListner (abortListener) { | ||
if (!this.abortController) { return; } | ||
this.abortController.signal.removeEventListener('abort', abortListener); | ||
} | ||
initDownload (resolve, reject) { | ||
@@ -76,2 +92,12 @@ | ||
this.abortController = 'AbortController' in window ? new AbortController() : null; | ||
const abortListener = ({target}) => { | ||
this.unsetAbortListner(abortListener); | ||
!!this.request && this.request.abort(); | ||
reject(target.reason); | ||
}; | ||
this.setAbortListner(abortListener); | ||
if (!this.params.url) { | ||
@@ -82,2 +108,3 @@ return reject(new DownloadException('url param not defined!', this.request)); | ||
this.request.onload = async () => { | ||
this.unsetAbortListner(abortListener); | ||
if (parseInt(this.request.status, 10) !== 200) { | ||
@@ -91,2 +118,3 @@ return reject(new DownloadException(`status code [${this.request.status}]`, this.request)); | ||
this.request.ontimeout = () => { | ||
this.unsetAbortListner(abortListener); | ||
reject(new DownloadException('request timeout', this.request)); | ||
@@ -96,2 +124,3 @@ }; | ||
this.request.onerror = () => { | ||
this.unsetAbortListner(abortListener); | ||
if (this.params.nativeFallbackOnError) { | ||
@@ -98,0 +127,0 @@ fallback(); |
@@ -241,1 +241,34 @@ import chai from 'chai'; | ||
}); | ||
describe('Shoud abort', () => { | ||
let instance; | ||
before(() => { | ||
instance = new Downloader({ | ||
url: 'https://cdn.apedesign.net/github/logo.png', | ||
autoStart: false | ||
}); | ||
}); | ||
it('should be rejected', done => { | ||
const promise = instance.start() | ||
.catch(e => { | ||
describe('Checking exception', () => { | ||
it('should be and exception', () => { | ||
e.should.be.equal('Download cancelled'); | ||
}); | ||
}); | ||
done(); | ||
}); | ||
instance.abort(); | ||
promise | ||
.catch(e => { done(e); }); | ||
}); | ||
}); |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
23
311
176842
1
80
1237