@red-code-mp/mp-builder
Version:
* [Structure](#Structure) * [Route](#Route) * [Endpoints](#Endpoints) * [Table](#Table) * [Lang](#Lang) * [Menu](#Menu) * [Toast](#Toast)
142 lines (128 loc) • 1.14 MB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./webpack/vendors/custom/uppy.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./node_modules/@uppy/aws-s3-multipart/lib/MultipartUploader.js":
/*!**********************************************************************!*\
!*** ./node_modules/@uppy/aws-s3-multipart/lib/MultipartUploader.js ***!
\**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nvar MB = 1024 * 1024;\nvar defaultOptions = {\n limit: 1,\n onStart: function onStart() {},\n onProgress: function onProgress() {},\n onPartComplete: function onPartComplete() {},\n onSuccess: function onSuccess() {},\n onError: function onError(err) {\n throw err;\n }\n};\n\nfunction remove(arr, el) {\n var i = arr.indexOf(el);\n if (i !== -1) arr.splice(i, 1);\n}\n\nvar MultipartUploader =\n/*#__PURE__*/\nfunction () {\n function MultipartUploader(file, options) {\n this.options = _extends({}, defaultOptions, {}, options);\n this.file = file;\n this.key = this.options.key || null;\n this.uploadId = this.options.uploadId || null;\n this.parts = this.options.parts || []; // Do `this.createdPromise.then(OP)` to execute an operation `OP` _only_ if the\n // upload was created already. That also ensures that the sequencing is right\n // (so the `OP` definitely happens if the upload is created).\n //\n // This mostly exists to make `_abortUpload` work well: only sending the abort request if\n // the upload was already created, and if the createMultipartUpload request is still in flight,\n // aborting it immediately after it finishes.\n\n this.createdPromise = Promise.reject(); // eslint-disable-line prefer-promise-reject-errors\n\n this.isPaused = false;\n this.chunks = null;\n this.chunkState = null;\n this.uploading = [];\n\n this._initChunks();\n\n this.createdPromise.catch(function () {}); // silence uncaught rejection warning\n }\n\n var _proto = MultipartUploader.prototype;\n\n _proto._initChunks = function _initChunks() {\n var chunks = [];\n var chunkSize = Math.max(Math.ceil(this.file.size / 10000), 5 * MB);\n\n for (var i = 0; i < this.file.size; i += chunkSize) {\n var end = Math.min(this.file.size, i + chunkSize);\n chunks.push(this.file.slice(i, end));\n }\n\n this.chunks = chunks;\n this.chunkState = chunks.map(function () {\n return {\n uploaded: 0,\n busy: false,\n done: false\n };\n });\n };\n\n _proto._createUpload = function _createUpload() {\n var _this = this;\n\n this.createdPromise = Promise.resolve().then(function () {\n return _this.options.createMultipartUpload();\n });\n return this.createdPromise.then(function (result) {\n var valid = typeof result === 'object' && result && typeof result.uploadId === 'string' && typeof result.key === 'string';\n\n if (!valid) {\n throw new TypeError('AwsS3/Multipart: Got incorrect result from `createMultipartUpload()`, expected an object `{ uploadId, key }`.');\n }\n\n _this.key = result.key;\n _this.uploadId = result.uploadId;\n\n _this.options.onStart(result);\n\n _this._uploadParts();\n }).catch(function (err) {\n _this._onError(err);\n });\n };\n\n _proto._resumeUpload = function _resumeUpload() {\n var _this2 = this;\n\n return Promise.resolve().then(function () {\n return _this2.options.listParts({\n uploadId: _this2.uploadId,\n key: _this2.key\n });\n }).then(function (parts) {\n parts.forEach(function (part) {\n var i = part.PartNumber - 1;\n _this2.chunkState[i] = {\n uploaded: part.Size,\n etag: part.ETag,\n done: true // Only add if we did not yet know about this part.\n\n };\n\n if (!_this2.parts.some(function (p) {\n return p.PartNumber === part.PartNumber;\n })) {\n _this2.parts.push({\n PartNumber: part.PartNumber,\n ETag: part.ETag\n });\n }\n });\n\n _this2._uploadParts();\n }).catch(function (err) {\n _this2._onError(err);\n });\n };\n\n _proto._uploadParts = function _uploadParts() {\n var _this3 = this;\n\n if (this.isPaused) return;\n var need = this.options.limit - this.uploading.length;\n if (need === 0) return; // All parts are uploaded.\n\n if (this.chunkState.every(function (state) {\n return state.done;\n })) {\n this._completeUpload();\n\n return;\n }\n\n var candidates = [];\n\n for (var i = 0; i < this.chunkState.length; i++) {\n var state = this.chunkState[i];\n if (state.done || state.busy) continue;\n candidates.push(i);\n\n if (candidates.length >= need) {\n break;\n }\n }\n\n candidates.forEach(function (index) {\n _this3._uploadPart(index);\n });\n };\n\n _proto._uploadPart = function _uploadPart(index) {\n var _this4 = this;\n\n var body = this.chunks[index];\n this.chunkState[index].busy = true;\n return Promise.resolve().then(function () {\n return _this4.options.prepareUploadPart({\n key: _this4.key,\n uploadId: _this4.uploadId,\n body: body,\n number: index + 1\n });\n }).then(function (result) {\n var valid = typeof result === 'object' && result && typeof result.url === 'string';\n\n if (!valid) {\n throw new TypeError('AwsS3/Multipart: Got incorrect result from `prepareUploadPart()`, expected an object `{ url }`.');\n }\n\n return result;\n }).then(function (_ref) {\n var url = _ref.url;\n\n _this4._uploadPartBytes(index, url);\n }, function (err) {\n _this4._onError(err);\n });\n };\n\n _proto._onPartProgress = function _onPartProgress(index, sent, total) {\n this.chunkState[index].uploaded = sent;\n var totalUploaded = this.chunkState.reduce(function (n, c) {\n return n + c.uploaded;\n }, 0);\n this.options.onProgress(totalUploaded, this.file.size);\n };\n\n _proto._onPartComplete = function _onPartComplete(index, etag) {\n this.chunkState[index].etag = etag;\n this.chunkState[index].done = true;\n var part = {\n PartNumber: index + 1,\n ETag: etag\n };\n this.parts.push(part);\n this.options.onPartComplete(part);\n\n this._uploadParts();\n };\n\n _proto._uploadPartBytes = function _uploadPartBytes(index, url) {\n var _this5 = this;\n\n var body = this.chunks[index];\n var xhr = new XMLHttpRequest();\n xhr.open('PUT', url, true);\n xhr.responseType = 'text';\n this.uploading.push(xhr);\n xhr.upload.addEventListener('progress', function (ev) {\n if (!ev.lengthComputable) return;\n\n _this5._onPartProgress(index, ev.loaded, ev.total);\n });\n xhr.addEventListener('abort', function (ev) {\n remove(_this5.uploading, ev.target);\n _this5.chunkState[index].busy = false;\n });\n xhr.addEventListener('load', function (ev) {\n remove(_this5.uploading, ev.target);\n _this5.chunkState[index].busy = false;\n\n if (ev.target.status < 200 || ev.target.status >= 300) {\n _this5._onError(new Error('Non 2xx'));\n\n return;\n }\n\n _this5._onPartProgress(index, body.size, body.size); // NOTE This must be allowed by CORS.\n\n\n var etag = ev.target.getResponseHeader('ETag');\n\n if (etag === null) {\n _this5._onError(new Error('AwsS3/Multipart: Could not read the ETag header. This likely means CORS is not configured correctly on the S3 Bucket. Seee https://uppy.io/docs/aws-s3-multipart#S3-Bucket-Configuration for instructions.'));\n\n return;\n }\n\n _this5._onPartComplete(index, etag);\n });\n xhr.addEventListener('error', function (ev) {\n remove(_this5.uploading, ev.target);\n _this5.chunkState[index].busy = false;\n var error = new Error('Unknown error');\n error.source = ev.target;\n\n _this5._onError(error);\n });\n xhr.send(body);\n };\n\n _proto._completeUpload = function _completeUpload() {\n var _this6 = this;\n\n // Parts may not have completed uploading in sorted order, if limit > 1.\n this.parts.sort(function (a, b) {\n return a.PartNumber - b.PartNumber;\n });\n return Promise.resolve().then(function () {\n return _this6.options.completeMultipartUpload({\n key: _this6.key,\n uploadId: _this6.uploadId,\n parts: _this6.parts\n });\n }).then(function (result) {\n _this6.options.onSuccess(result);\n }, function (err) {\n _this6._onError(err);\n });\n };\n\n _proto._abortUpload = function _abortUpload() {\n var _this7 = this;\n\n this.uploading.slice().forEach(function (xhr) {\n xhr.abort();\n });\n this.createdPromise.then(function () {\n _this7.options.abortMultipartUpload({\n key: _this7.key,\n uploadId: _this7.uploadId\n });\n }, function () {// if the creation failed we do not need to abort\n });\n this.uploading = [];\n };\n\n _proto._onError = function _onError(err) {\n this.options.onError(err);\n };\n\n _proto.start = function start() {\n this.isPaused = false;\n\n if (this.uploadId) {\n this._resumeUpload();\n } else {\n this._createUpload();\n }\n };\n\n _proto.pause = function pause() {\n var inProgress = this.uploading.slice();\n inProgress.forEach(function (xhr) {\n xhr.abort();\n });\n this.isPaused = true;\n };\n\n _proto.abort = function abort(opts) {\n if (opts === void 0) {\n opts = {};\n }\n\n var really = opts.really || false;\n if (!really) return this.pause();\n\n this._abortUpload();\n };\n\n return MultipartUploader;\n}();\n\nmodule.exports = MultipartUploader;\n\n//# sourceURL=webpack:///./node_modules/@uppy/aws-s3-multipart/lib/MultipartUploader.js?");
/***/ }),
/***/ "./node_modules/@uppy/aws-s3-multipart/lib/index.js":
/*!**********************************************************!*\
!*** ./node_modules/@uppy/aws-s3-multipart/lib/index.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var _class, _temp;\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nvar _require = __webpack_require__(/*! @uppy/core */ \"./node_modules/@uppy/core/lib/index.js\"),\n Plugin = _require.Plugin;\n\nvar _require2 = __webpack_require__(/*! @uppy/companion-client */ \"./node_modules/@uppy/companion-client/lib/index.js\"),\n Socket = _require2.Socket,\n Provider = _require2.Provider,\n RequestClient = _require2.RequestClient;\n\nvar EventTracker = __webpack_require__(/*! @uppy/utils/lib/EventTracker */ \"./node_modules/@uppy/utils/lib/EventTracker.js\");\n\nvar emitSocketProgress = __webpack_require__(/*! @uppy/utils/lib/emitSocketProgress */ \"./node_modules/@uppy/utils/lib/emitSocketProgress.js\");\n\nvar getSocketHost = __webpack_require__(/*! @uppy/utils/lib/getSocketHost */ \"./node_modules/@uppy/utils/lib/getSocketHost.js\");\n\nvar RateLimitedQueue = __webpack_require__(/*! @uppy/utils/lib/RateLimitedQueue */ \"./node_modules/@uppy/utils/lib/RateLimitedQueue.js\");\n\nvar Uploader = __webpack_require__(/*! ./MultipartUploader */ \"./node_modules/@uppy/aws-s3-multipart/lib/MultipartUploader.js\");\n\nfunction assertServerError(res) {\n if (res && res.error) {\n var error = new Error(res.message);\n\n _extends(error, res.error);\n\n throw error;\n }\n\n return res;\n}\n\nmodule.exports = (_temp = _class =\n/*#__PURE__*/\nfunction (_Plugin) {\n _inheritsLoose(AwsS3Multipart, _Plugin);\n\n function AwsS3Multipart(uppy, opts) {\n var _this;\n\n _this = _Plugin.call(this, uppy, opts) || this;\n _this.type = 'uploader';\n _this.id = _this.opts.id || 'AwsS3Multipart';\n _this.title = 'AWS S3 Multipart';\n _this.client = new RequestClient(uppy, opts);\n var defaultOptions = {\n timeout: 30 * 1000,\n limit: 0,\n createMultipartUpload: _this.createMultipartUpload.bind(_assertThisInitialized(_this)),\n listParts: _this.listParts.bind(_assertThisInitialized(_this)),\n prepareUploadPart: _this.prepareUploadPart.bind(_assertThisInitialized(_this)),\n abortMultipartUpload: _this.abortMultipartUpload.bind(_assertThisInitialized(_this)),\n completeMultipartUpload: _this.completeMultipartUpload.bind(_assertThisInitialized(_this))\n };\n _this.opts = _extends({}, defaultOptions, {}, opts);\n _this.upload = _this.upload.bind(_assertThisInitialized(_this));\n _this.requests = new RateLimitedQueue(_this.opts.limit);\n _this.uploaders = Object.create(null);\n _this.uploaderEvents = Object.create(null);\n _this.uploaderSockets = Object.create(null);\n return _this;\n }\n /**\n * Clean up all references for a file's upload: the MultipartUploader instance,\n * any events related to the file, and the Companion WebSocket connection.\n *\n * Set `opts.abort` to tell S3 that the multipart upload is cancelled and must be removed.\n * This should be done when the user cancels the upload, not when the upload is completed or errored.\n */\n\n\n var _proto = AwsS3Multipart.prototype;\n\n _proto.resetUploaderReferences = function resetUploaderReferences(fileID, opts) {\n if (opts === void 0) {\n opts = {};\n }\n\n if (this.uploaders[fileID]) {\n this.uploaders[fileID].abort({\n really: opts.abort || false\n });\n this.uploaders[fileID] = null;\n }\n\n if (this.uploaderEvents[fileID]) {\n this.uploaderEvents[fileID].remove();\n this.uploaderEvents[fileID] = null;\n }\n\n if (this.uploaderSockets[fileID]) {\n this.uploaderSockets[fileID].close();\n this.uploaderSockets[fileID] = null;\n }\n };\n\n _proto.assertHost = function assertHost() {\n if (!this.opts.companionUrl) {\n throw new Error('Expected a `companionUrl` option containing a Companion address.');\n }\n };\n\n _proto.createMultipartUpload = function createMultipartUpload(file) {\n this.assertHost();\n var metadata = {};\n Object.keys(file.meta).map(function (key) {\n if (file.meta[key] != null) {\n metadata[key] = file.meta[key].toString();\n }\n });\n return this.client.post('s3/multipart', {\n filename: file.name,\n type: file.type,\n metadata: metadata\n }).then(assertServerError);\n };\n\n _proto.listParts = function listParts(file, _ref) {\n var key = _ref.key,\n uploadId = _ref.uploadId;\n this.assertHost();\n var filename = encodeURIComponent(key);\n return this.client.get(\"s3/multipart/\" + uploadId + \"?key=\" + filename).then(assertServerError);\n };\n\n _proto.prepareUploadPart = function prepareUploadPart(file, _ref2) {\n var key = _ref2.key,\n uploadId = _ref2.uploadId,\n number = _ref2.number;\n this.assertHost();\n var filename = encodeURIComponent(key);\n return this.client.get(\"s3/multipart/\" + uploadId + \"/\" + number + \"?key=\" + filename).then(assertServerError);\n };\n\n _proto.completeMultipartUpload = function completeMultipartUpload(file, _ref3) {\n var key = _ref3.key,\n uploadId = _ref3.uploadId,\n parts = _ref3.parts;\n this.assertHost();\n var filename = encodeURIComponent(key);\n var uploadIdEnc = encodeURIComponent(uploadId);\n return this.client.post(\"s3/multipart/\" + uploadIdEnc + \"/complete?key=\" + filename, {\n parts: parts\n }).then(assertServerError);\n };\n\n _proto.abortMultipartUpload = function abortMultipartUpload(file, _ref4) {\n var key = _ref4.key,\n uploadId = _ref4.uploadId;\n this.assertHost();\n var filename = encodeURIComponent(key);\n var uploadIdEnc = encodeURIComponent(uploadId);\n return this.client.delete(\"s3/multipart/\" + uploadIdEnc + \"?key=\" + filename).then(assertServerError);\n };\n\n _proto.uploadFile = function uploadFile(file) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n var onStart = function onStart(data) {\n var cFile = _this2.uppy.getFile(file.id);\n\n _this2.uppy.setFileState(file.id, {\n s3Multipart: _extends({}, cFile.s3Multipart, {\n key: data.key,\n uploadId: data.uploadId,\n parts: []\n })\n });\n };\n\n var onProgress = function onProgress(bytesUploaded, bytesTotal) {\n _this2.uppy.emit('upload-progress', file, {\n uploader: _this2,\n bytesUploaded: bytesUploaded,\n bytesTotal: bytesTotal\n });\n };\n\n var onError = function onError(err) {\n _this2.uppy.log(err);\n\n _this2.uppy.emit('upload-error', file, err);\n\n err.message = \"Failed because: \" + err.message;\n queuedRequest.done();\n\n _this2.resetUploaderReferences(file.id);\n\n reject(err);\n };\n\n var onSuccess = function onSuccess(result) {\n var uploadResp = {\n uploadURL: result.location\n };\n queuedRequest.done();\n\n _this2.resetUploaderReferences(file.id);\n\n _this2.uppy.emit('upload-success', file, uploadResp);\n\n if (result.location) {\n _this2.uppy.log('Download ' + upload.file.name + ' from ' + result.location);\n }\n\n resolve(upload);\n };\n\n var onPartComplete = function onPartComplete(part) {\n // Store completed parts in state.\n var cFile = _this2.uppy.getFile(file.id);\n\n if (!cFile) {\n return;\n }\n\n _this2.uppy.setFileState(file.id, {\n s3Multipart: _extends({}, cFile.s3Multipart, {\n parts: [].concat(cFile.s3Multipart.parts, [part])\n })\n });\n\n _this2.uppy.emit('s3-multipart:part-uploaded', cFile, part);\n };\n\n var upload = new Uploader(file.data, _extends({\n // .bind to pass the file object to each handler.\n createMultipartUpload: _this2.opts.createMultipartUpload.bind(_this2, file),\n listParts: _this2.opts.listParts.bind(_this2, file),\n prepareUploadPart: _this2.opts.prepareUploadPart.bind(_this2, file),\n completeMultipartUpload: _this2.opts.completeMultipartUpload.bind(_this2, file),\n abortMultipartUpload: _this2.opts.abortMultipartUpload.bind(_this2, file),\n onStart: onStart,\n onProgress: onProgress,\n onError: onError,\n onSuccess: onSuccess,\n onPartComplete: onPartComplete,\n limit: _this2.opts.limit || 5\n }, file.s3Multipart));\n _this2.uploaders[file.id] = upload;\n _this2.uploaderEvents[file.id] = new EventTracker(_this2.uppy);\n\n var queuedRequest = _this2.requests.run(function () {\n if (!file.isPaused) {\n upload.start();\n } // Don't do anything here, the caller will take care of cancelling the upload itself\n // using resetUploaderReferences(). This is because resetUploaderReferences() has to be\n // called when this request is still in the queue, and has not been started yet, too. At\n // that point this cancellation function is not going to be called.\n\n\n return function () {};\n });\n\n _this2.onFileRemove(file.id, function (removed) {\n queuedRequest.abort();\n\n _this2.resetUploaderReferences(file.id, {\n abort: true\n });\n\n resolve(\"upload \" + removed.id + \" was removed\");\n });\n\n _this2.onCancelAll(file.id, function () {\n queuedRequest.abort();\n\n _this2.resetUploaderReferences(file.id, {\n abort: true\n });\n\n resolve(\"upload \" + file.id + \" was canceled\");\n });\n\n _this2.onFilePause(file.id, function (isPaused) {\n if (isPaused) {\n // Remove this file from the queue so another file can start in its place.\n queuedRequest.abort();\n upload.pause();\n } else {\n // Resuming an upload should be queued, else you could pause and then resume a queued upload to make it skip the queue.\n queuedRequest.abort();\n queuedRequest = _this2.requests.run(function () {\n upload.start();\n return function () {};\n });\n }\n });\n\n _this2.onPauseAll(file.id, function () {\n queuedRequest.abort();\n upload.pause();\n });\n\n _this2.onResumeAll(file.id, function () {\n queuedRequest.abort();\n\n if (file.error) {\n upload.abort();\n }\n\n queuedRequest = _this2.requests.run(function () {\n upload.start();\n return function () {};\n });\n });\n\n if (!file.isRestored) {\n _this2.uppy.emit('upload-started', file, upload);\n }\n });\n };\n\n _proto.uploadRemote = function uploadRemote(file) {\n var _this3 = this;\n\n this.resetUploaderReferences(file.id);\n this.uppy.emit('upload-started', file);\n\n if (file.serverToken) {\n return this.connectToServerSocket(file);\n }\n\n return new Promise(function (resolve, reject) {\n var Client = file.remote.providerOptions.provider ? Provider : RequestClient;\n var client = new Client(_this3.uppy, file.remote.providerOptions);\n client.post(file.remote.url, _extends({}, file.remote.body, {\n protocol: 's3-multipart',\n size: file.data.size,\n metadata: file.meta\n })).then(function (res) {\n _this3.uppy.setFileState(file.id, {\n serverToken: res.token\n });\n\n file = _this3.uppy.getFile(file.id);\n return file;\n }).then(function (file) {\n return _this3.connectToServerSocket(file);\n }).then(function () {\n resolve();\n }).catch(function (err) {\n reject(new Error(err));\n });\n });\n };\n\n _proto.connectToServerSocket = function connectToServerSocket(file) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n var token = file.serverToken;\n var host = getSocketHost(file.remote.companionUrl);\n var socket = new Socket({\n target: host + \"/api/\" + token,\n autoOpen: false\n });\n _this4.uploaderSockets[file.id] = socket;\n _this4.uploaderEvents[file.id] = new EventTracker(_this4.uppy);\n\n _this4.onFileRemove(file.id, function (removed) {\n queuedRequest.abort();\n socket.send('pause', {});\n\n _this4.resetUploaderReferences(file.id, {\n abort: true\n });\n\n resolve(\"upload \" + file.id + \" was removed\");\n });\n\n _this4.onFilePause(file.id, function (isPaused) {\n if (isPaused) {\n // Remove this file from the queue so another file can start in its place.\n queuedRequest.abort();\n socket.send('pause', {});\n } else {\n // Resuming an upload should be queued, else you could pause and then resume a queued upload to make it skip the queue.\n queuedRequest.abort();\n queuedRequest = _this4.requests.run(function () {\n socket.send('resume', {});\n return function () {};\n });\n }\n });\n\n _this4.onPauseAll(file.id, function () {\n queuedRequest.abort();\n socket.send('pause', {});\n });\n\n _this4.onCancelAll(file.id, function () {\n queuedRequest.abort();\n socket.send('pause', {});\n\n _this4.resetUploaderReferences(file.id);\n\n resolve(\"upload \" + file.id + \" was canceled\");\n });\n\n _this4.onResumeAll(file.id, function () {\n queuedRequest.abort();\n\n if (file.error) {\n socket.send('pause', {});\n }\n\n queuedRequest = _this4.requests.run(function () {\n socket.send('resume', {});\n });\n });\n\n _this4.onRetry(file.id, function () {\n // Only do the retry if the upload is actually in progress;\n // else we could try to send these messages when the upload is still queued.\n // We may need a better check for this since the socket may also be closed\n // for other reasons, like network failures.\n if (socket.isOpen) {\n socket.send('pause', {});\n socket.send('resume', {});\n }\n });\n\n _this4.onRetryAll(file.id, function () {\n if (socket.isOpen) {\n socket.send('pause', {});\n socket.send('resume', {});\n }\n });\n\n socket.on('progress', function (progressData) {\n return emitSocketProgress(_this4, progressData, file);\n });\n socket.on('error', function (errData) {\n _this4.uppy.emit('upload-error', file, new Error(errData.error));\n\n _this4.resetUploaderReferences(file.id);\n\n queuedRequest.done();\n reject(new Error(errData.error));\n });\n socket.on('success', function (data) {\n var uploadResp = {\n uploadURL: data.url\n };\n\n _this4.uppy.emit('upload-success', file, uploadResp);\n\n _this4.resetUploaderReferences(file.id);\n\n queuedRequest.done();\n resolve();\n });\n\n var queuedRequest = _this4.requests.run(function () {\n socket.open();\n\n if (file.isPaused) {\n socket.send('pause', {});\n }\n\n return function () {};\n });\n });\n };\n\n _proto.upload = function upload(fileIDs) {\n var _this5 = this;\n\n if (fileIDs.length === 0) return Promise.resolve();\n var promises = fileIDs.map(function (id) {\n var file = _this5.uppy.getFile(id);\n\n if (file.isRemote) {\n return _this5.uploadRemote(file);\n }\n\n return _this5.uploadFile(file);\n });\n return Promise.all(promises);\n };\n\n _proto.onFileRemove = function onFileRemove(fileID, cb) {\n this.uploaderEvents[fileID].on('file-removed', function (file) {\n if (fileID === file.id) cb(file.id);\n });\n };\n\n _proto.onFilePause = function onFilePause(fileID, cb) {\n this.uploaderEvents[fileID].on('upload-pause', function (targetFileID, isPaused) {\n if (fileID === targetFileID) {\n // const isPaused = this.uppy.pauseResume(fileID)\n cb(isPaused);\n }\n });\n };\n\n _proto.onRetry = function onRetry(fileID, cb) {\n this.uploaderEvents[fileID].on('upload-retry', function (targetFileID) {\n if (fileID === targetFileID) {\n cb();\n }\n });\n };\n\n _proto.onRetryAll = function onRetryAll(fileID, cb) {\n var _this6 = this;\n\n this.uploaderEvents[fileID].on('retry-all', function (filesToRetry) {\n if (!_this6.uppy.getFile(fileID)) return;\n cb();\n });\n };\n\n _proto.onPauseAll = function onPauseAll(fileID, cb) {\n var _this7 = this;\n\n this.uploaderEvents[fileID].on('pause-all', function () {\n if (!_this7.uppy.getFile(fileID)) return;\n cb();\n });\n };\n\n _proto.onCancelAll = function onCancelAll(fileID, cb) {\n var _this8 = this;\n\n this.uploaderEvents[fileID].on('cancel-all', function () {\n if (!_this8.uppy.getFile(fileID)) return;\n cb();\n });\n };\n\n _proto.onResumeAll = function onResumeAll(fileID, cb) {\n var _this9 = this;\n\n this.uploaderEvents[fileID].on('resume-all', function () {\n if (!_this9.uppy.getFile(fileID)) return;\n cb();\n });\n };\n\n _proto.install = function install() {\n var _this$uppy$getState = this.uppy.getState(),\n capabilities = _this$uppy$getState.capabilities;\n\n this.uppy.setState({\n capabilities: _extends({}, capabilities, {\n resumableUploads: true\n })\n });\n this.uppy.addUploader(this.upload);\n };\n\n _proto.uninstall = function uninstall() {\n var _this$uppy$getState2 = this.uppy.getState(),\n capabilities = _this$uppy$getState2.capabilities;\n\n this.uppy.setState({\n capabilities: _extends({}, capabilities, {\n resumableUploads: false\n })\n });\n this.uppy.removeUploader(this.upload);\n };\n\n return AwsS3Multipart;\n}(Plugin), _class.VERSION = \"1.3.4\", _temp);\n\n//# sourceURL=webpack:///./node_modules/@uppy/aws-s3-multipart/lib/index.js?");
/***/ }),
/***/ "./node_modules/@uppy/aws-s3/lib/index.js":
/*!************************************************!*\
!*** ./node_modules/@uppy/aws-s3/lib/index.js ***!
\************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var _class, _temp;\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\n// If global `URL` constructor is available, use it\nvar URL_ = typeof URL === 'function' ? URL : __webpack_require__(/*! url-parse */ \"./node_modules/url-parse/index.js\");\n\nvar _require = __webpack_require__(/*! @uppy/core */ \"./node_modules/@uppy/core/lib/index.js\"),\n Plugin = _require.Plugin;\n\nvar Translator = __webpack_require__(/*! @uppy/utils/lib/Translator */ \"./node_modules/@uppy/utils/lib/Translator.js\");\n\nvar RateLimitedQueue = __webpack_require__(/*! @uppy/utils/lib/RateLimitedQueue */ \"./node_modules/@uppy/utils/lib/RateLimitedQueue.js\");\n\nvar _require2 = __webpack_require__(/*! @uppy/companion-client */ \"./node_modules/@uppy/companion-client/lib/index.js\"),\n RequestClient = _require2.RequestClient;\n\nvar XHRUpload = __webpack_require__(/*! @uppy/xhr-upload */ \"./node_modules/@uppy/xhr-upload/lib/index.js\");\n\nfunction resolveUrl(origin, link) {\n return new URL_(link, origin).toString();\n}\n\nfunction isXml(xhr) {\n var contentType = xhr.headers ? xhr.headers['content-type'] : xhr.getResponseHeader('Content-Type');\n return typeof contentType === 'string' && contentType.toLowerCase() === 'application/xml';\n}\n\nfunction getXmlValue(source, key) {\n var start = source.indexOf(\"<\" + key + \">\");\n var end = source.indexOf(\"</\" + key + \">\", start);\n return start !== -1 && end !== -1 ? source.slice(start + key.length + 2, end) : '';\n}\n\nfunction assertServerError(res) {\n if (res && res.error) {\n var error = new Error(res.message);\n\n _extends(error, res.error);\n\n throw error;\n }\n\n return res;\n}\n\nmodule.exports = (_temp = _class =\n/*#__PURE__*/\nfunction (_Plugin) {\n _inheritsLoose(AwsS3, _Plugin);\n\n function AwsS3(uppy, opts) {\n var _this;\n\n _this = _Plugin.call(this, uppy, opts) || this;\n _this.type = 'uploader';\n _this.id = _this.opts.id || 'AwsS3';\n _this.title = 'AWS S3';\n _this.defaultLocale = {\n strings: {\n preparingUpload: 'Preparing upload...'\n }\n };\n var defaultOptions = {\n timeout: 30 * 1000,\n limit: 0,\n getUploadParameters: _this.getUploadParameters.bind(_assertThisInitialized(_this))\n };\n _this.opts = _extends({}, defaultOptions, {}, opts);\n\n _this.i18nInit();\n\n _this.client = new RequestClient(uppy, opts);\n _this.prepareUpload = _this.prepareUpload.bind(_assertThisInitialized(_this));\n _this.requests = new RateLimitedQueue(_this.opts.limit);\n return _this;\n }\n\n var _proto = AwsS3.prototype;\n\n _proto.setOptions = function setOptions(newOpts) {\n _Plugin.prototype.setOptions.call(this, newOpts);\n\n this.i18nInit();\n };\n\n _proto.i18nInit = function i18nInit() {\n this.translator = new Translator([this.defaultLocale, this.uppy.locale, this.opts.locale]);\n this.i18n = this.translator.translate.bind(this.translator);\n this.setPluginState(); // so that UI re-renders and we see the updated locale\n };\n\n _proto.getUploadParameters = function getUploadParameters(file) {\n if (!this.opts.companionUrl) {\n throw new Error('Expected a `companionUrl` option containing a Companion address.');\n }\n\n var filename = encodeURIComponent(file.meta.name);\n var type = encodeURIComponent(file.meta.type);\n return this.client.get(\"s3/params?filename=\" + filename + \"&type=\" + type).then(assertServerError);\n };\n\n _proto.validateParameters = function validateParameters(file, params) {\n var valid = typeof params === 'object' && params && typeof params.url === 'string' && (typeof params.fields === 'object' || params.fields == null) && (params.method == null || /^(put|post)$/i.test(params.method));\n\n if (!valid) {\n var err = new TypeError(\"AwsS3: got incorrect result from 'getUploadParameters()' for file '\" + file.name + \"', expected an object '{ url, method, fields, headers }'.\\nSee https://uppy.io/docs/aws-s3/#getUploadParameters-file for more on the expected format.\");\n console.error(err);\n throw err;\n }\n\n return params;\n };\n\n _proto.prepareUpload = function prepareUpload(fileIDs) {\n var _this2 = this;\n\n fileIDs.forEach(function (id) {\n var file = _this2.uppy.getFile(id);\n\n _this2.uppy.emit('preprocess-progress', file, {\n mode: 'determinate',\n message: _this2.i18n('preparingUpload'),\n value: 0\n });\n }); // Wrapping rate-limited opts.getUploadParameters in a Promise takes some boilerplate!\n\n var getUploadParameters = this.requests.wrapPromiseFunction(function (file) {\n return _this2.opts.getUploadParameters(file);\n });\n return Promise.all(fileIDs.map(function (id) {\n var file = _this2.uppy.getFile(id);\n\n return getUploadParameters(file).then(function (params) {\n return _this2.validateParameters(file, params);\n }).then(function (params) {\n _this2.uppy.emit('preprocess-progress', file, {\n mode: 'determinate',\n message: _this2.i18n('preparingUpload'),\n value: 1\n });\n\n return params;\n }).catch(function (error) {\n _this2.uppy.emit('upload-error', file, error);\n });\n })).then(function (responses) {\n var updatedFiles = {};\n fileIDs.forEach(function (id, index) {\n var file = _this2.uppy.getFile(id);\n\n if (!file || file.error) {\n return;\n }\n\n var _responses$index = responses[index],\n _responses$index$meth = _responses$index.method,\n method = _responses$index$meth === void 0 ? 'post' : _responses$index$meth,\n url = _responses$index.url,\n fields = _responses$index.fields,\n headers = _responses$index.headers;\n var xhrOpts = {\n method: method,\n formData: method.toLowerCase() === 'post',\n endpoint: url,\n metaFields: fields ? Object.keys(fields) : []\n };\n\n if (headers) {\n xhrOpts.headers = headers;\n }\n\n var updatedFile = _extends({}, file, {\n meta: _extends({}, file.meta, {}, fields),\n xhrUpload: xhrOpts\n });\n\n updatedFiles[id] = updatedFile;\n });\n\n var _this2$uppy$getState = _this2.uppy.getState(),\n files = _this2$uppy$getState.files;\n\n _this2.uppy.setState({\n files: _extends({}, files, {}, updatedFiles)\n });\n\n fileIDs.forEach(function (id) {\n var file = _this2.uppy.getFile(id);\n\n _this2.uppy.emit('preprocess-complete', file);\n });\n });\n };\n\n _proto.install = function install() {\n var log = this.uppy.log;\n this.uppy.addPreProcessor(this.prepareUpload);\n var warnedSuccessActionStatus = false;\n var xhrUploadOpts = {\n fieldName: 'file',\n responseUrlFieldName: 'location',\n timeout: this.opts.timeout,\n __queue: this.requests,\n responseType: 'text',\n // Get the response data from a successful XMLHttpRequest instance.\n // `content` is the S3 response as a string.\n // `xhr` is the XMLHttpRequest instance.\n getResponseData: function getResponseData(content, xhr) {\n var opts = this; // If no response, we've hopefully done a PUT request to the file\n // in the bucket on its full URL.\n\n if (!isXml(xhr)) {\n if (opts.method.toUpperCase() === 'POST') {\n if (!warnedSuccessActionStatus) {\n log('[AwsS3] No response data found, make sure to set the success_action_status AWS SDK option to 201. See https://uppy.io/docs/aws-s3/#POST-Uploads', 'warning');\n warnedSuccessActionStatus = true;\n } // The responseURL won't contain the object key. Give up.\n\n\n return {\n location: null\n };\n } // responseURL is not available in older browsers.\n\n\n if (!xhr.responseURL) {\n return {\n location: null\n };\n } // Trim the query string because it's going to be a bunch of presign\n // parameters for a PUT request—doing a GET request with those will\n // always result in an error\n\n\n return {\n location: xhr.responseURL.replace(/\\?.*$/, '')\n };\n }\n\n return {\n // Some S3 alternatives do not reply with an absolute URL.\n // Eg DigitalOcean Spaces uses /$bucketName/xyz\n location: resolveUrl(xhr.responseURL, getXmlValue(content, 'Location')),\n bucket: getXmlValue(content, 'Bucket'),\n key: getXmlValue(content, 'Key'),\n etag: getXmlValue(content, 'ETag')\n };\n },\n // Get the error data from a failed XMLHttpRequest instance.\n // `content` is the S3 response as a string.\n // `xhr` is the XMLHttpRequest instance.\n getResponseError: function getResponseError(content, xhr) {\n // If no response, we don't have a specific error message, use the default.\n if (!isXml(xhr)) {\n return;\n }\n\n var error = getXmlValue(content, 'Message');\n return new Error(error);\n }\n }; // Replace getResponseData() with overwritten version.\n\n if (this.opts.getResponseData) {\n xhrUploadOpts.getResponseData = this.opts.getResponseData;\n }\n\n this.uppy.use(XHRUpload, xhrUploadOpts);\n };\n\n _proto.uninstall = function uninstall() {\n var uploader = this.uppy.getPlugin('XHRUpload');\n this.uppy.removePlugin(uploader);\n this.uppy.removePreProcessor(this.prepareUpload);\n };\n\n return AwsS3;\n}(Plugin), _class.VERSION = \"1.3.3\", _temp);\n\n//# sourceURL=webpack:///./node_modules/@uppy/aws-s3/lib/index.js?");
/***/ }),
/***/ "./node_modules/@uppy/companion-client/lib/AuthError.js":
/*!**************************************************************!*\
!*** ./node_modules/@uppy/companion-client/lib/AuthError.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nfunction _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); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _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); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar AuthError =\n/*#__PURE__*/\nfunction (_Error) {\n _inheritsLoose(AuthError, _Error);\n\n function AuthError() {\n var _this;\n\n _this = _Error.call(this, 'Authorization required') || this;\n _this.name = 'AuthError';\n _this.isAuthError = true;\n return _this;\n }\n\n return AuthError;\n}(_wrapNativeSuper(Error));\n\nmodule.exports = AuthError;\n\n//# sourceURL=webpack:///./node_modules/@uppy/companion-client/lib/AuthError.js?");
/***/ }),
/***/ "./node_modules/@uppy/companion-client/lib/Provider.js":
/*!*************************************************************!*\
!*** ./node_modules/@uppy/companion-client/lib/Provider.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nvar RequestClient = __webpack_require__(/*! ./RequestClient */ \"./node_modules/@uppy/companion-client/lib/RequestClient.js\");\n\nvar tokenStorage = __webpack_require__(/*! ./tokenStorage */ \"./node_modules/@uppy/companion-client/lib/tokenStorage.js\");\n\nvar _getName = function _getName(id) {\n return id.split('-').map(function (s) {\n return s.charAt(0).toUpperCase() + s.slice(1);\n }).join(' ');\n};\n\nmodule.exports =\n/*#__PURE__*/\nfunction (_RequestClient) {\n _inheritsLoose(Provider, _RequestClient);\n\n function Provider(uppy, opts) {\n var _this;\n\n _this = _RequestClient.call(this, uppy, opts) || this;\n _this.provider = opts.provider;\n _this.id = _this.provider;\n _this.authProvider = opts.authProvider || _this.provider;\n _this.name = _this.opts.name || _getName(_this.id);\n _this.pluginId = _this.opts.pluginId;\n _this.tokenKey = \"companion-\" + _this.pluginId + \"-auth-token\";\n return _this;\n }\n\n var _proto = Provider.prototype;\n\n _proto.headers = function headers() {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n _RequestClient.prototype.headers.call(_this2).then(function (headers) {\n _this2.getAuthToken().then(function (token) {\n resolve(_extends({}, headers, {\n 'uppy-auth-token': token\n }));\n });\n }).catch(reject);\n });\n };\n\n _proto.onReceiveResponse = function onReceiveResponse(response) {\n response = _RequestClient.prototype.onReceiveResponse.call(this, response);\n var plugin = this.uppy.getPlugin(this.pluginId);\n var oldAuthenticated = plugin.getPluginState().authenticated;\n var authenticated = oldAuthenticated ? response.status !== 401 : response.status < 400;\n plugin.setPluginState({\n authenticated: authenticated\n });\n return response;\n } // @todo(i.olarewaju) consider whether or not this method should be exposed\n ;\n\n _proto.setAuthToken = function setAuthToken(token) {\n return this.uppy.getPlugin(this.pluginId).storage.se