CasaOS/web/js/5.js
link f99f49dd7e
V0.3.3 (#330)
* switch branches

* update user interface

* switch branch

* switch branch

* change branch

* submit 0.3.3
2022-06-29 11:09:58 +08:00

21 lines
No EOL
47 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[5],{"./node_modules/simple-uploader.js/src/chunk.js":
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/chunk.js ***!
\******************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\n\nfunction Chunk (uploader, file, offset) {\n utils.defineNonEnumerable(this, 'uploader', uploader)\n utils.defineNonEnumerable(this, 'file', file)\n utils.defineNonEnumerable(this, 'bytes', null)\n this.offset = offset\n this.tested = false\n this.retries = 0\n this.pendingRetry = false\n this.preprocessState = 0\n this.readState = 0\n this.loaded = 0\n this.total = 0\n this.chunkSize = this.uploader.opts.chunkSize\n this.startByte = this.offset * this.chunkSize\n this.endByte = this.computeEndByte()\n this.xhr = null\n}\n\nvar STATUS = Chunk.STATUS = {\n PENDING: 'pending',\n UPLOADING: 'uploading',\n READING: 'reading',\n SUCCESS: 'success',\n ERROR: 'error',\n COMPLETE: 'complete',\n PROGRESS: 'progress',\n RETRY: 'retry'\n}\n\nutils.extend(Chunk.prototype, {\n\n _event: function (evt, args) {\n args = utils.toArray(arguments)\n args.unshift(this)\n this.file._chunkEvent.apply(this.file, args)\n },\n\n computeEndByte: function () {\n var endByte = Math.min(this.file.size, (this.offset + 1) * this.chunkSize)\n if (this.file.size - endByte < this.chunkSize && !this.uploader.opts.forceChunkSize) {\n // The last chunk will be bigger than the chunk size,\n // but less than 2 * this.chunkSize\n endByte = this.file.size\n }\n return endByte\n },\n\n getParams: function () {\n return {\n chunkNumber: this.offset + 1,\n chunkSize: this.uploader.opts.chunkSize,\n currentChunkSize: this.endByte - this.startByte,\n totalSize: this.file.size,\n identifier: this.file.uniqueIdentifier,\n filename: this.file.name,\n relativePath: this.file.relativePath,\n totalChunks: this.file.chunks.length\n }\n },\n\n getTarget: function (target, params) {\n if (!params.length) {\n return target\n }\n if (target.indexOf('?') < 0) {\n target += '?'\n } else {\n target += '&'\n }\n return target + params.join('&')\n },\n\n test: function () {\n this.xhr = new XMLHttpRequest()\n this.xhr.addEventListener('load', testHandler, false)\n this.xhr.addEventListener('error', testHandler, false)\n var testMethod = utils.evalOpts(this.uploader.opts.testMethod, this.file, this)\n var data = this.prepareXhrRequest(testMethod, true)\n this.xhr.send(data)\n\n var $ = this\n function testHandler (event) {\n var status = $.status(true)\n if (status === STATUS.ERROR) {\n $._event(status, $.message())\n $.uploader.uploadNextChunk()\n } else if (status === STATUS.SUCCESS) {\n $._event(status, $.message())\n $.tested = true\n } else if (!$.file.paused) {\n // Error might be caused by file pause method\n // Chunks does not exist on the server side\n $.tested = true\n $.send()\n }\n }\n },\n\n preprocessFinished: function () {\n // Compute the endByte after the preprocess function to allow an\n // implementer of preprocess to set the fileObj size\n this.endByte = this.computeEndByte()\n this.preprocessState = 2\n this.send()\n },\n\n readFinished: function (bytes) {\n this.readState = 2\n this.bytes = bytes\n this.send()\n },\n\n send: function () {\n var preprocess = this.uploader.opts.preprocess\n var read = this.uploader.opts.readFileFn\n if (utils.isFunction(preprocess)) {\n switch (this.preprocessState) {\n case 0:\n this.preprocessState = 1\n preprocess(this)\n return\n case 1:\n return\n }\n }\n switch (this.readState) {\n case 0:\n this.readState = 1\n read(this.file, this.file.fileType, this.startByte, this.endByte, this)\n return\n case 1:\n return\n }\n if (this.uploader.opts.testChunks && !this.tested) {\n this.test()\n return\n }\n\n this.loaded = 0\n this.total = 0\n this.pendingRetry = false\n\n // Set up request and listen for event\n this.xhr = new XMLHttpRequest()\n this.xhr.upload.addEventListener('progress', progressHandler, false)\n this.xhr.addEventListener('load', doneHandler, false)\n this.xhr.addEventListener('error', doneHandler, false)\n\n var uploadMethod = utils.evalOpts(this.uploader.opts.uploadMethod, this.file, this)\n var data = this.prepareXhrRequest(uploadMethod, false, this.uploader.opts.method, this.bytes)\n this.xhr.send(data)\n\n var $ = this\n function progressHandler (event) {\n if (event.lengthComputable) {\n $.loaded = event.loaded\n $.total = event.total\n }\n $._event(STATUS.PROGRESS, event)\n }\n\n function doneHandler (event) {\n var msg = $.message()\n $.processingResponse = true\n $.uploader.opts.processResponse(msg, function (err, res) {\n $.processingResponse = false\n if (!$.xhr) {\n return\n }\n $.processedState = {\n err: err,\n res: res\n }\n var status = $.status()\n if (status === STATUS.SUCCESS || status === STATUS.ERROR) {\n // delete this.data\n $._event(status, res)\n status === STATUS.ERROR && $.uploader.uploadNextChunk()\n } else {\n $._event(STATUS.RETRY, res)\n $.pendingRetry = true\n $.abort()\n $.retries++\n var retryInterval = $.uploader.opts.chunkRetryInterval\n if (retryInterval !== null) {\n setTimeout(function () {\n $.send()\n }, retryInterval)\n } else {\n $.send()\n }\n }\n }, $.file, $)\n }\n },\n\n abort: function () {\n var xhr = this.xhr\n this.xhr = null\n this.processingResponse = false\n this.processedState = null\n if (xhr) {\n xhr.abort()\n }\n },\n\n status: function (isTest) {\n if (this.readState === 1) {\n return STATUS.READING\n } else if (this.pendingRetry || this.preprocessState === 1) {\n // if pending retry then that's effectively the same as actively uploading,\n // there might just be a slight delay before the retry starts\n return STATUS.UPLOADING\n } else if (!this.xhr) {\n return STATUS.PENDING\n } else if (this.xhr.readyState < 4 || this.processingResponse) {\n // Status is really 'OPENED', 'HEADERS_RECEIVED'\n // or 'LOADING' - meaning that stuff is happening\n return STATUS.UPLOADING\n } else {\n var _status\n if (this.uploader.opts.successStatuses.indexOf(this.xhr.status) > -1) {\n // HTTP 200, perfect\n // HTTP 202 Accepted - The request has been accepted for processing, but the processing has not been completed.\n _status = STATUS.SUCCESS\n } else if (this.uploader.opts.permanentErrors.indexOf(this.xhr.status) > -1 ||\n !isTest && this.retries >= this.uploader.opts.maxChunkRetries) {\n // HTTP 415/500/501, permanent error\n _status = STATUS.ERROR\n } else {\n // this should never happen, but we'll reset and queue a retry\n // a likely case for this would be 503 service unavailable\n this.abort()\n _status = STATUS.PENDING\n }\n var processedState = this.processedState\n if (processedState && processedState.err) {\n _status = STATUS.ERROR\n }\n return _status\n }\n },\n\n message: function () {\n return this.xhr ? this.xhr.responseText : ''\n },\n\n progress: function () {\n if (this.pendingRetry) {\n return 0\n }\n var s = this.status()\n if (s === STATUS.SUCCESS || s === STATUS.ERROR) {\n return 1\n } else if (s === STATUS.PENDING) {\n return 0\n } else {\n return this.total > 0 ? this.loaded / this.total : 0\n }\n },\n\n sizeUploaded: function () {\n var size = this.endByte - this.startByte\n // can't return only chunk.loaded value, because it is bigger than chunk size\n if (this.status() !== STATUS.SUCCESS) {\n size = this.progress() * size\n }\n return size\n },\n\n prepareXhrRequest: function (method, isTest, paramsMethod, blob) {\n // Add data from the query options\n var query = utils.evalOpts(this.uploader.opts.query, this.file, this, isTest)\n query = utils.extend(this.getParams(), query)\n\n // processParams\n query = this.uploader.opts.processParams(query, this.file, this, isTest)\n\n var target = utils.evalOpts(this.uploader.opts.target, this.file, this, isTest)\n var data = null\n if (method === 'GET' || paramsMethod === 'octet') {\n // Add data from the query options\n var params = []\n utils.each(query, function (v, k) {\n params.push([encodeURIComponent(k), encodeURIComponent(v)].join('='))\n })\n target = this.getTarget(target, params)\n data = blob || null\n } else {\n // Add data from the query options\n data = new FormData()\n utils.each(query, function (v, k) {\n data.append(k, v)\n })\n if (typeof blob !== 'undefined') {\n data.append(this.uploader.opts.fileParameterName, blob, this.file.name)\n }\n }\n\n this.xhr.open(method, target, true)\n this.xhr.withCredentials = this.uploader.opts.withCredentials\n\n // Add data from header options\n utils.each(utils.evalOpts(this.uploader.opts.headers, this.file, this, isTest), function (v, k) {\n this.xhr.setRequestHeader(k, v)\n }, this)\n\n return data\n }\n\n})\n\nmodule.exports = Chunk\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/chunk.js?")},"./node_modules/simple-uploader.js/src/event.js":
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/event.js ***!
\******************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval('var each = __webpack_require__(/*! ./utils */ "./node_modules/simple-uploader.js/src/utils.js").each\n\nvar event = {\n\n _eventData: null,\n\n on: function (name, func) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name]) this._eventData[name] = []\n var listened = false\n each(this._eventData[name], function (fuc) {\n if (fuc === func) {\n listened = true\n return false\n }\n })\n if (!listened) {\n this._eventData[name].push(func)\n }\n },\n\n off: function (name, func) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name] || !this._eventData[name].length) return\n if (func) {\n each(this._eventData[name], function (fuc, i) {\n if (fuc === func) {\n this._eventData[name].splice(i, 1)\n return false\n }\n }, this)\n } else {\n this._eventData[name] = []\n }\n },\n\n trigger: function (name) {\n if (!this._eventData) this._eventData = {}\n if (!this._eventData[name]) return true\n var args = this._eventData[name].slice.call(arguments, 1)\n var preventDefault = false\n each(this._eventData[name], function (fuc) {\n preventDefault = fuc.apply(this, args) === false || preventDefault\n }, this)\n return !preventDefault\n }\n}\n\nmodule.exports = event\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/event.js?')},"./node_modules/simple-uploader.js/src/file.js":
/*!*****************************************************!*\
!*** ./node_modules/simple-uploader.js/src/file.js ***!
\*****************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\nvar Chunk = __webpack_require__(/*! ./chunk */ \"./node_modules/simple-uploader.js/src/chunk.js\")\n\nfunction File (uploader, file, parent) {\n utils.defineNonEnumerable(this, 'uploader', uploader)\n this.isRoot = this.isFolder = uploader === this\n utils.defineNonEnumerable(this, 'parent', parent || null)\n utils.defineNonEnumerable(this, 'files', [])\n utils.defineNonEnumerable(this, 'fileList', [])\n utils.defineNonEnumerable(this, 'chunks', [])\n utils.defineNonEnumerable(this, '_errorFiles', [])\n utils.defineNonEnumerable(this, 'file', null)\n this.id = utils.uid()\n\n if (this.isRoot || !file) {\n this.file = null\n } else {\n if (utils.isString(file)) {\n // folder\n this.isFolder = true\n this.file = null\n this.path = file\n if (this.parent.path) {\n file = file.substr(this.parent.path.length)\n }\n this.name = file.charAt(file.length - 1) === '/' ? file.substr(0, file.length - 1) : file\n } else {\n this.file = file\n this.fileType = this.file.type\n this.name = file.fileName || file.name\n this.size = file.size\n this.relativePath = file.relativePath || file.webkitRelativePath || this.name\n this._parseFile()\n }\n }\n\n this.paused = uploader.opts.initialPaused\n this.error = false\n this.allError = false\n this.aborted = false\n this.completed = false\n this.averageSpeed = 0\n this.currentSpeed = 0\n this._lastProgressCallback = Date.now()\n this._prevUploadedSize = 0\n this._prevProgress = 0\n\n this.bootstrap()\n}\n\nutils.extend(File.prototype, {\n\n _parseFile: function () {\n var ppaths = parsePaths(this.relativePath)\n if (ppaths.length) {\n var filePaths = this.uploader.filePaths\n utils.each(ppaths, function (path, i) {\n var folderFile = filePaths[path]\n if (!folderFile) {\n folderFile = new File(this.uploader, path, this.parent)\n filePaths[path] = folderFile\n this._updateParentFileList(folderFile)\n }\n this.parent = folderFile\n folderFile.files.push(this)\n if (!ppaths[i + 1]) {\n folderFile.fileList.push(this)\n }\n }, this)\n } else {\n this._updateParentFileList()\n }\n },\n\n _updateParentFileList: function (file) {\n if (!file) {\n file = this\n }\n var p = this.parent\n if (p) {\n p.fileList.push(file)\n }\n },\n\n _eachAccess: function (eachFn, fileFn) {\n if (this.isFolder) {\n utils.each(this.files, function (f, i) {\n return eachFn.call(this, f, i)\n }, this)\n return\n }\n fileFn.call(this, this)\n },\n\n bootstrap: function () {\n if (this.isFolder) return\n var opts = this.uploader.opts\n if (utils.isFunction(opts.initFileFn)) {\n opts.initFileFn.call(this, this)\n }\n\n this.abort(true)\n this._resetError()\n // Rebuild stack of chunks from file\n this._prevProgress = 0\n var round = opts.forceChunkSize ? Math.ceil : Math.floor\n var chunks = Math.max(round(this.size / opts.chunkSize), 1)\n for (var offset = 0; offset < chunks; offset++) {\n this.chunks.push(new Chunk(this.uploader, this, offset))\n }\n },\n\n _measureSpeed: function () {\n var smoothingFactor = this.uploader.opts.speedSmoothingFactor\n var timeSpan = Date.now() - this._lastProgressCallback\n if (!timeSpan) {\n return\n }\n var uploaded = this.sizeUploaded()\n // Prevent negative upload speed after file upload resume\n this.currentSpeed = Math.max((uploaded - this._prevUploadedSize) / timeSpan * 1000, 0)\n this.averageSpeed = smoothingFactor * this.currentSpeed + (1 - smoothingFactor) * this.averageSpeed\n this._prevUploadedSize = uploaded\n if (this.parent && this.parent._checkProgress()) {\n this.parent._measureSpeed()\n }\n },\n\n _checkProgress: function (file) {\n return Date.now() - this._lastProgressCallback >= this.uploader.opts.progressCallbacksInterval\n },\n\n _chunkEvent: function (chunk, evt, message) {\n var uploader = this.uploader\n var STATUS = Chunk.STATUS\n var that = this\n var rootFile = this.getRoot()\n var triggerProgress = function () {\n that._measureSpeed()\n uploader._trigger('fileProgress', rootFile, that, chunk)\n that._lastProgressCallback = Date.now()\n }\n switch (evt) {\n case STATUS.PROGRESS:\n if (this._checkProgress()) {\n triggerProgress()\n }\n break\n case STATUS.ERROR:\n this._error()\n this.abort(true)\n uploader._trigger('fileError', rootFile, this, message, chunk)\n break\n case STATUS.SUCCESS:\n this._updateUploadedChunks(message, chunk)\n if (this.error) {\n return\n }\n clearTimeout(this._progeressId)\n this._progeressId = 0\n var timeDiff = Date.now() - this._lastProgressCallback\n if (timeDiff < uploader.opts.progressCallbacksInterval) {\n this._progeressId = setTimeout(triggerProgress, uploader.opts.progressCallbacksInterval - timeDiff)\n }\n if (this.isComplete()) {\n clearTimeout(this._progeressId)\n triggerProgress()\n this.currentSpeed = 0\n this.averageSpeed = 0\n uploader._trigger('fileSuccess', rootFile, this, message, chunk)\n if (rootFile.isComplete()) {\n uploader._trigger('fileComplete', rootFile, this)\n }\n } else if (!this._progeressId) {\n triggerProgress()\n }\n break\n case STATUS.RETRY:\n uploader._trigger('fileRetry', rootFile, this, chunk)\n break\n }\n },\n\n _updateUploadedChunks: function (message, chunk) {\n var checkChunkUploaded = this.uploader.opts.checkChunkUploadedByResponse\n if (checkChunkUploaded) {\n var xhr = chunk.xhr\n utils.each(this.chunks, function (_chunk) {\n if (!_chunk.tested) {\n var uploaded = checkChunkUploaded.call(this, _chunk, message)\n if (_chunk === chunk && !uploaded) {\n // fix the first chunk xhr status\n // treated as success but checkChunkUploaded is false\n // so the current chunk should be uploaded again\n _chunk.xhr = null\n }\n if (uploaded) {\n // first success and other chunks are uploaded\n // then set xhr, so the uploaded chunks\n // will be treated as success too\n _chunk.xhr = xhr\n }\n _chunk.tested = true\n }\n }, this)\n if (!this._firstResponse) {\n this._firstResponse = true\n this.uploader.upload(true)\n } else {\n this.uploader.uploadNextChunk()\n }\n } else {\n this.uploader.uploadNextChunk()\n }\n },\n\n _error: function () {\n this.error = this.allError = true\n var parent = this.parent\n while (parent && parent !== this.uploader) {\n parent._errorFiles.push(this)\n parent.error = true\n if (parent._errorFiles.length === parent.files.length) {\n parent.allError = true\n }\n parent = parent.parent\n }\n },\n\n _resetError: function () {\n this.error = this.allError = false\n var parent = this.parent\n var index = -1\n while (parent && parent !== this.uploader) {\n index = parent._errorFiles.indexOf(this)\n parent._errorFiles.splice(index, 1)\n parent.allError = false\n if (!parent._errorFiles.length) {\n parent.error = false\n }\n parent = parent.parent\n }\n },\n\n isComplete: function () {\n if (!this.completed) {\n var outstanding = false\n this._eachAccess(function (file) {\n if (!file.isComplete()) {\n outstanding = true\n return false\n }\n }, function () {\n if (this.error) {\n outstanding = true\n } else {\n var STATUS = Chunk.STATUS\n utils.each(this.chunks, function (chunk) {\n var status = chunk.status()\n if (status === STATUS.ERROR || status === STATUS.PENDING || status === STATUS.UPLOADING || status === STATUS.READING || chunk.preprocessState === 1 || chunk.readState === 1) {\n outstanding = true\n return false\n }\n })\n }\n })\n this.completed = !outstanding\n }\n return this.completed\n },\n\n isUploading: function () {\n var uploading = false\n this._eachAccess(function (file) {\n if (file.isUploading()) {\n uploading = true\n return false\n }\n }, function () {\n var uploadingStatus = Chunk.STATUS.UPLOADING\n utils.each(this.chunks, function (chunk) {\n if (chunk.status() === uploadingStatus) {\n uploading = true\n return false\n }\n })\n })\n return uploading\n },\n\n resume: function () {\n this._eachAccess(function (f) {\n f.resume()\n }, function () {\n this.paused = false\n this.aborted = false\n this.uploader.upload()\n })\n this.paused = false\n this.aborted = false\n },\n\n pause: function () {\n this._eachAccess(function (f) {\n f.pause()\n }, function () {\n this.paused = true\n this.abort()\n })\n this.paused = true\n },\n\n cancel: function () {\n this.uploader.removeFile(this)\n },\n\n retry: function (file) {\n var fileRetry = function (file) {\n if (file.error) {\n file.bootstrap()\n }\n }\n if (file) {\n file.bootstrap()\n } else {\n this._eachAccess(fileRetry, function () {\n this.bootstrap()\n })\n }\n this.uploader.upload()\n },\n\n abort: function (reset) {\n if (this.aborted) {\n return\n }\n this.currentSpeed = 0\n this.averageSpeed = 0\n this.aborted = !reset\n var chunks = this.chunks\n if (reset) {\n this.chunks = []\n }\n var uploadingStatus = Chunk.STATUS.UPLOADING\n utils.each(chunks, function (c) {\n if (c.status() === uploadingStatus) {\n c.abort()\n this.uploader.uploadNextChunk()\n }\n }, this)\n },\n\n progress: function () {\n var totalDone = 0\n var totalSize = 0\n var ret = 0\n this._eachAccess(function (file, index) {\n totalDone += file.progress() * file.size\n totalSize += file.size\n if (index === this.files.length - 1) {\n ret = totalSize > 0 ? totalDone / totalSize : this.isComplete() ? 1 : 0\n }\n }, function () {\n if (this.error) {\n ret = 1\n return\n }\n if (this.chunks.length === 1) {\n this._prevProgress = Math.max(this._prevProgress, this.chunks[0].progress())\n ret = this._prevProgress\n return\n }\n // Sum up progress across everything\n var bytesLoaded = 0\n utils.each(this.chunks, function (c) {\n // get chunk progress relative to entire file\n bytesLoaded += c.progress() * (c.endByte - c.startByte)\n })\n var percent = bytesLoaded / this.size\n // We don't want to lose percentages when an upload is paused\n this._prevProgress = Math.max(this._prevProgress, percent > 0.9999 ? 1 : percent)\n ret = this._prevProgress\n })\n return ret\n },\n\n getSize: function () {\n var size = 0\n this._eachAccess(function (file) {\n size += file.size\n }, function () {\n size += this.size\n })\n return size\n },\n\n getFormatSize: function () {\n var size = this.getSize()\n return utils.formatSize(size)\n },\n\n getRoot: function () {\n if (this.isRoot) {\n return this\n }\n var parent = this.parent\n while (parent) {\n if (parent.parent === this.uploader) {\n // find it\n return parent\n }\n parent = parent.parent\n }\n return this\n },\n\n sizeUploaded: function () {\n var size = 0\n this._eachAccess(function (file) {\n size += file.sizeUploaded()\n }, function () {\n utils.each(this.chunks, function (chunk) {\n size += chunk.sizeUploaded()\n })\n })\n return size\n },\n\n timeRemaining: function () {\n var ret = 0\n var sizeDelta = 0\n var averageSpeed = 0\n this._eachAccess(function (file, i) {\n if (!file.paused && !file.error) {\n sizeDelta += file.size - file.sizeUploaded()\n averageSpeed += file.averageSpeed\n }\n if (i === this.files.length - 1) {\n ret = calRet(sizeDelta, averageSpeed)\n }\n }, function () {\n if (this.paused || this.error) {\n ret = 0\n return\n }\n var delta = this.size - this.sizeUploaded()\n ret = calRet(delta, this.averageSpeed)\n })\n return ret\n function calRet (delta, averageSpeed) {\n if (delta && !averageSpeed) {\n return Number.POSITIVE_INFINITY\n }\n if (!delta && !averageSpeed) {\n return 0\n }\n return Math.floor(delta / averageSpeed)\n }\n },\n\n removeFile: function (file) {\n if (file.isFolder) {\n while (file.files.length) {\n var f = file.files[file.files.length - 1]\n this._removeFile(f)\n }\n }\n this._removeFile(file)\n },\n\n _delFilePath: function (file) {\n if (file.path && this.filePaths) {\n delete this.filePaths[file.path]\n }\n utils.each(file.fileList, function (file) {\n this._delFilePath(file)\n }, this)\n },\n\n _removeFile: function (file) {\n if (!file.isFolder) {\n utils.each(this.files, function (f, i) {\n if (f === file) {\n this.files.splice(i, 1)\n return false\n }\n }, this)\n file.abort()\n var parent = file.parent\n var newParent\n while (parent && parent !== this) {\n newParent = parent.parent\n parent._removeFile(file)\n parent = newParent\n }\n }\n file.parent === this && utils.each(this.fileList, function (f, i) {\n if (f === file) {\n this.fileList.splice(i, 1)\n return false\n }\n }, this)\n if (!this.isRoot && this.isFolder && !this.files.length) {\n this.parent._removeFile(this)\n this.uploader._delFilePath(this)\n }\n file.parent = null\n },\n\n getType: function () {\n if (this.isFolder) {\n return 'folder'\n }\n return this.file.type && this.file.type.split('/')[1]\n },\n\n getExtension: function () {\n if (this.isFolder) {\n return ''\n }\n return this.name.substr((~-this.name.lastIndexOf('.') >>> 0) + 2).toLowerCase()\n }\n\n})\n\nmodule.exports = File\n\nfunction parsePaths (path) {\n var ret = []\n var paths = path.split('/')\n var len = paths.length\n var i = 1\n paths.splice(len - 1, 1)\n len--\n if (paths.length) {\n while (i <= len) {\n ret.push(paths.slice(0, i++).join('/') + '/')\n }\n }\n return ret\n}\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/file.js?")},"./node_modules/simple-uploader.js/src/uploader.js":
/*!*********************************************************!*\
!*** ./node_modules/simple-uploader.js/src/uploader.js ***!
\*********************************************************/
/*! no static exports found */function(module,exports,__webpack_require__){eval("var utils = __webpack_require__(/*! ./utils */ \"./node_modules/simple-uploader.js/src/utils.js\")\nvar event = __webpack_require__(/*! ./event */ \"./node_modules/simple-uploader.js/src/event.js\")\nvar File = __webpack_require__(/*! ./file */ \"./node_modules/simple-uploader.js/src/file.js\")\nvar Chunk = __webpack_require__(/*! ./chunk */ \"./node_modules/simple-uploader.js/src/chunk.js\")\n\nvar version = '__VERSION__'\n\nvar isServer = typeof window === 'undefined'\n\n// ie10+\nvar ie10plus = isServer ? false : window.navigator.msPointerEnabled\nvar support = (function () {\n if (isServer) {\n return false\n }\n var sliceName = 'slice'\n var _support = utils.isDefined(window.File) && utils.isDefined(window.Blob) &&\n utils.isDefined(window.FileList)\n var bproto = null\n if (_support) {\n bproto = window.Blob.prototype\n utils.each(['slice', 'webkitSlice', 'mozSlice'], function (n) {\n if (bproto[n]) {\n sliceName = n\n return false\n }\n })\n _support = !!bproto[sliceName]\n }\n if (_support) Uploader.sliceName = sliceName\n bproto = null\n return _support\n})()\n\nvar supportDirectory = (function () {\n if (isServer) {\n return false\n }\n var input = window.document.createElement('input')\n input.type = 'file'\n var sd = 'webkitdirectory' in input || 'directory' in input\n input = null\n return sd\n})()\n\nfunction Uploader (opts) {\n this.support = support\n /* istanbul ignore if */\n if (!this.support) {\n return\n }\n this.supportDirectory = supportDirectory\n utils.defineNonEnumerable(this, 'filePaths', {})\n this.opts = utils.extend({}, Uploader.defaults, opts || {})\n\n this.preventEvent = utils.bind(this._preventEvent, this)\n\n File.call(this, this)\n}\n\n/**\n * Default read function using the webAPI\n *\n * @function webAPIFileRead(fileObj, fileType, startByte, endByte, chunk)\n *\n */\nvar webAPIFileRead = function (fileObj, fileType, startByte, endByte, chunk) {\n chunk.readFinished(fileObj.file[Uploader.sliceName](startByte, endByte, fileType))\n}\n\nUploader.version = version\n\nUploader.defaults = {\n chunkSize: 1024 * 1024,\n forceChunkSize: false,\n simultaneousUploads: 3,\n singleFile: false,\n fileParameterName: 'file',\n progressCallbacksInterval: 500,\n speedSmoothingFactor: 0.1,\n query: {},\n headers: {},\n withCredentials: false,\n preprocess: null,\n method: 'multipart',\n testMethod: 'GET',\n uploadMethod: 'POST',\n prioritizeFirstAndLastChunk: false,\n allowDuplicateUploads: false,\n target: '/',\n testChunks: true,\n generateUniqueIdentifier: null,\n maxChunkRetries: 0,\n chunkRetryInterval: null,\n permanentErrors: [404, 415, 500, 501],\n successStatuses: [200, 201, 202],\n onDropStopPropagation: false,\n initFileFn: null,\n readFileFn: webAPIFileRead,\n checkChunkUploadedByResponse: null,\n initialPaused: false,\n processResponse: function (response, cb) {\n cb(null, response)\n },\n processParams: function (params) {\n return params\n }\n}\n\nUploader.utils = utils\nUploader.event = event\nUploader.File = File\nUploader.Chunk = Chunk\n\n// inherit file\nUploader.prototype = utils.extend({}, File.prototype)\n// inherit event\nutils.extend(Uploader.prototype, event)\nutils.extend(Uploader.prototype, {\n\n constructor: Uploader,\n\n _trigger: function (name) {\n var args = utils.toArray(arguments)\n var preventDefault = !this.trigger.apply(this, arguments)\n if (name !== 'catchAll') {\n args.unshift('catchAll')\n preventDefault = !this.trigger.apply(this, args) || preventDefault\n }\n return !preventDefault\n },\n\n _triggerAsync: function () {\n var args = arguments\n utils.nextTick(function () {\n this._trigger.apply(this, args)\n }, this)\n },\n\n addFiles: function (files, evt) {\n var _files = []\n var oldFileListLen = this.fileList.length\n utils.each(files, function (file) {\n // Uploading empty file IE10/IE11 hangs indefinitely\n // Directories have size `0` and name `.`\n // Ignore already added files if opts.allowDuplicateUploads is set to false\n if ((!ie10plus || ie10plus && file.size > 0) && !(file.size % 4096 === 0 && (file.name === '.' || file.fileName === '.'))) {\n var uniqueIdentifier = this.generateUniqueIdentifier(file)\n if (this.opts.allowDuplicateUploads || !this.getFromUniqueIdentifier(uniqueIdentifier)) {\n var _file = new File(this, file, this)\n _file.uniqueIdentifier = uniqueIdentifier\n if (this._trigger('fileAdded', _file, evt)) {\n _files.push(_file)\n } else {\n File.prototype.removeFile.call(this, _file)\n }\n }\n }\n }, this)\n // get new fileList\n var newFileList = this.fileList.slice(oldFileListLen)\n if (this._trigger('filesAdded', _files, newFileList, evt)) {\n utils.each(_files, function (file) {\n if (this.opts.singleFile && this.files.length > 0) {\n this.removeFile(this.files[0])\n }\n this.files.push(file)\n }, this)\n this._trigger('filesSubmitted', _files, newFileList, evt)\n } else {\n utils.each(newFileList, function (file) {\n File.prototype.removeFile.call(this, file)\n }, this)\n }\n },\n\n addFile: function (file, evt) {\n this.addFiles([file], evt)\n },\n\n cancel: function () {\n for (var i = this.fileList.length - 1; i >= 0; i--) {\n this.fileList[i].cancel()\n }\n },\n\n removeFile: function (file) {\n File.prototype.removeFile.call(this, file)\n this._trigger('fileRemoved', file)\n },\n\n generateUniqueIdentifier: function (file) {\n var custom = this.opts.generateUniqueIdentifier\n if (utils.isFunction(custom)) {\n return custom(file)\n }\n /* istanbul ignore next */\n // Some confusion in different versions of Firefox\n var relativePath = file.relativePath || file.webkitRelativePath || file.fileName || file.name\n /* istanbul ignore next */\n return file.size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/img, '')\n },\n\n getFromUniqueIdentifier: function (uniqueIdentifier) {\n var ret = false\n utils.each(this.files, function (file) {\n if (file.uniqueIdentifier === uniqueIdentifier) {\n ret = file\n return false\n }\n })\n return ret\n },\n\n uploadNextChunk: function (preventEvents) {\n var found = false\n var pendingStatus = Chunk.STATUS.PENDING\n var checkChunkUploaded = this.uploader.opts.checkChunkUploadedByResponse\n if (this.opts.prioritizeFirstAndLastChunk) {\n utils.each(this.files, function (file) {\n if (file.paused) {\n return\n }\n if (checkChunkUploaded && !file._firstResponse && file.isUploading()) {\n // waiting for current file's first chunk response\n return\n }\n if (file.chunks.length && file.chunks[0].status() === pendingStatus) {\n file.chunks[0].send()\n found = true\n return false\n }\n if (file.chunks.length > 1 && file.chunks[file.chunks.length - 1].status() === pendingStatus) {\n file.chunks[file.chunks.length - 1].send()\n found = true\n return false\n }\n })\n if (found) {\n return found\n }\n }\n\n // Now, simply look for the next, best thing to upload\n utils.each(this.files, function (file) {\n if (!file.paused) {\n if (checkChunkUploaded && !file._firstResponse && file.isUploading()) {\n // waiting for current file's first chunk response\n return\n }\n utils.each(file.chunks, function (chunk) {\n if (chunk.status() === pendingStatus) {\n chunk.send()\n found = true\n return false\n }\n })\n }\n if (found) {\n return false\n }\n })\n if (found) {\n return true\n }\n\n // The are no more outstanding chunks to upload, check is everything is done\n var outstanding = false\n utils.each(this.files, function (file) {\n if (!file.isComplete()) {\n outstanding = true\n return false\n }\n })\n // should check files now\n // if now files in list\n // should not trigger complete event\n if (!outstanding && !preventEvents && this.files.length) {\n // All chunks have been uploaded, complete\n this._triggerAsync('complete')\n }\n return outstanding\n },\n\n upload: function (preventEvents) {\n // Make sure we don't start too many uploads at once\n var ret = this._shouldUploadNext()\n if (ret === false) {\n return\n }\n !preventEvents && this._trigger('uploadStart')\n var started = false\n for (var num = 1; num <= this.opts.simultaneousUploads - ret; num++) {\n started = this.uploadNextChunk(!preventEvents) || started\n if (!started && preventEvents) {\n // completed\n break\n }\n }\n if (!started && !preventEvents) {\n this._triggerAsync('complete')\n }\n },\n\n /**\n * should upload next chunk\n * @function\n * @returns {Boolean|Number}\n */\n _shouldUploadNext: function () {\n var num = 0\n var should = true\n var simultaneousUploads = this.opts.simultaneousUploads\n var uploadingStatus = Chunk.STATUS.UPLOADING\n utils.each(this.files, function (file) {\n utils.each(file.chunks, function (chunk) {\n if (chunk.status() === uploadingStatus) {\n num++\n if (num >= simultaneousUploads) {\n should = false\n return false\n }\n }\n })\n return should\n })\n // if should is true then return uploading chunks's length\n return should && num\n },\n\n /**\n * Assign a browse action to one or more DOM nodes.\n * @function\n * @param {Element|Array.<Element>} domNodes\n * @param {boolean} isDirectory Pass in true to allow directories to\n * @param {boolean} singleFile prevent multi file upload\n * @param {Object} attributes set custom attributes:\n * http://www.w3.org/TR/html-markup/input.file.html#input.file-attributes\n * eg: accept: 'image/*'\n * be selected (Chrome only).\n */\n assignBrowse: function (domNodes, isDirectory, singleFile, attributes) {\n if (typeof domNodes.length === 'undefined') {\n domNodes = [domNodes]\n }\n\n utils.each(domNodes, function (domNode) {\n var input\n if (domNode.tagName === 'INPUT' && domNode.type === 'file') {\n input = domNode\n } else {\n input = document.createElement('input')\n input.setAttribute('type', 'file')\n // display:none - not working in opera 12\n utils.extend(input.style, {\n visibility: 'hidden',\n position: 'absolute',\n width: '1px',\n height: '1px'\n })\n // for opera 12 browser, input must be assigned to a document\n domNode.appendChild(input)\n // https://developer.mozilla.org/en/using_files_from_web_applications)\n // event listener is executed two times\n // first one - original mouse click event\n // second - input.click(), input is inside domNode\n domNode.addEventListener('click', function (e) {\n if (domNode.tagName.toLowerCase() === 'label') {\n return\n }\n input.click()\n }, false)\n }\n if (!this.opts.singleFile && !singleFile) {\n input.setAttribute('multiple', 'multiple')\n }\n if (isDirectory) {\n input.setAttribute('webkitdirectory', 'webkitdirectory')\n }\n attributes && utils.each(attributes, function (value, key) {\n input.setAttribute(key, value)\n })\n // When new files are added, simply append them to the overall list\n var that = this\n input.addEventListener('change', function (e) {\n that._trigger(e.type, e)\n if (e.target.value) {\n that.addFiles(e.target.files, e)\n e.target.value = ''\n }\n }, false)\n }, this)\n },\n\n onDrop: function (evt) {\n this._trigger(evt.type, evt)\n if (this.opts.onDropStopPropagation) {\n evt.stopPropagation()\n }\n evt.preventDefault()\n this._parseDataTransfer(evt.dataTransfer, evt)\n },\n\n _parseDataTransfer: function (dataTransfer, evt) {\n if (dataTransfer.items && dataTransfer.items[0] &&\n dataTransfer.items[0].webkitGetAsEntry) {\n this.webkitReadDataTransfer(dataTransfer, evt)\n } else {\n this.addFiles(dataTransfer.files, evt)\n }\n },\n\n webkitReadDataTransfer: function (dataTransfer, evt) {\n var self = this\n var queue = dataTransfer.items.length\n var files = []\n utils.each(dataTransfer.items, function (item) {\n var entry = item.webkitGetAsEntry()\n if (!entry) {\n decrement()\n return\n }\n if (entry.isFile) {\n // due to a bug in Chrome's File System API impl - #149735\n fileReadSuccess(item.getAsFile(), entry.fullPath)\n } else {\n readDirectory(entry.createReader())\n }\n })\n function readDirectory (reader) {\n reader.readEntries(function (entries) {\n if (entries.length) {\n queue += entries.length\n utils.each(entries, function (entry) {\n if (entry.isFile) {\n var fullPath = entry.fullPath\n entry.file(function (file) {\n fileReadSuccess(file, fullPath)\n }, readError)\n } else if (entry.isDirectory) {\n readDirectory(entry.createReader())\n }\n })\n readDirectory(reader)\n } else {\n decrement()\n }\n }, readError)\n }\n function fileReadSuccess (file, fullPath) {\n // relative path should not start with \"/\"\n file.relativePath = fullPath.substring(1)\n files.push(file)\n decrement()\n }\n function readError (fileError) {\n throw fileError\n }\n function decrement () {\n if (--queue === 0) {\n self.addFiles(files, evt)\n }\n }\n },\n\n _assignHelper: function (domNodes, handles, remove) {\n if (typeof domNodes.length === 'undefined') {\n domNodes = [domNodes]\n }\n var evtMethod = remove ? 'removeEventListener' : 'addEventListener'\n utils.each(domNodes, function (domNode) {\n utils.each(handles, function (handler, name) {\n domNode[evtMethod](name, handler, false)\n }, this)\n }, this)\n },\n\n _preventEvent: function (e) {\n utils.preventEvent(e)\n this._trigger(e.type, e)\n },\n\n /**\n * Assign one or more DOM nodes as a drop target.\n * @function\n * @param {Element|Array.<Element>} domNodes\n */\n assignDrop: function (domNodes) {\n this._onDrop = utils.bind(this.onDrop, this)\n this._assignHelper(domNodes, {\n dragover: this.preventEvent,\n dragenter: this.preventEvent,\n dragleave: this.preventEvent,\n drop: this._onDrop\n })\n },\n\n /**\n * Un-assign drop event from DOM nodes\n * @function\n * @param domNodes\n */\n unAssignDrop: function (domNodes) {\n this._assignHelper(domNodes, {\n dragover: this.preventEvent,\n dragenter: this.preventEvent,\n dragleave: this.preventEvent,\n drop: this._onDrop\n }, true)\n this._onDrop = null\n }\n})\n\nmodule.exports = Uploader\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/uploader.js?")},"./node_modules/simple-uploader.js/src/utils.js":
/*!******************************************************!*\
!*** ./node_modules/simple-uploader.js/src/utils.js ***!
\******************************************************/
/*! no static exports found */function(module,exports){eval("var oproto = Object.prototype\nvar aproto = Array.prototype\nvar serialize = oproto.toString\n\nvar isFunction = function (fn) {\n return serialize.call(fn) === '[object Function]'\n}\n\nvar isArray = Array.isArray || /* istanbul ignore next */ function (ary) {\n return serialize.call(ary) === '[object Array]'\n}\n\nvar isPlainObject = function (obj) {\n return serialize.call(obj) === '[object Object]' && Object.getPrototypeOf(obj) === oproto\n}\n\nvar i = 0\nvar utils = {\n uid: function () {\n return ++i\n },\n noop: function () {},\n bind: function (fn, context) {\n return function () {\n return fn.apply(context, arguments)\n }\n },\n preventEvent: function (evt) {\n evt.preventDefault()\n },\n stop: function (evt) {\n evt.preventDefault()\n evt.stopPropagation()\n },\n nextTick: function (fn, context) {\n setTimeout(utils.bind(fn, context), 0)\n },\n toArray: function (ary, start, end) {\n if (start === undefined) start = 0\n if (end === undefined) end = ary.length\n return aproto.slice.call(ary, start, end)\n },\n\n isPlainObject: isPlainObject,\n isFunction: isFunction,\n isArray: isArray,\n isObject: function (obj) {\n return Object(obj) === obj\n },\n isString: function (s) {\n return typeof s === 'string'\n },\n isUndefined: function (a) {\n return typeof a === 'undefined'\n },\n isDefined: function (a) {\n return typeof a !== 'undefined'\n },\n\n each: function (ary, func, context) {\n if (utils.isDefined(ary.length)) {\n for (var i = 0, len = ary.length; i < len; i++) {\n if (func.call(context, ary[i], i, ary) === false) {\n break\n }\n }\n } else {\n for (var k in ary) {\n if (func.call(context, ary[k], k, ary) === false) {\n break\n }\n }\n }\n },\n\n /**\n * If option is a function, evaluate it with given params\n * @param {*} data\n * @param {...} args arguments of a callback\n * @returns {*}\n */\n evalOpts: function (data, args) {\n if (utils.isFunction(data)) {\n // `arguments` is an object, not array, in FF, so:\n args = utils.toArray(arguments)\n data = data.apply(null, args.slice(1))\n }\n return data\n },\n\n extend: function () {\n var options\n var name\n var src\n var copy\n var copyIsArray\n var clone\n var target = arguments[0] || {}\n var i = 1\n var length = arguments.length\n var force = false\n\n // 如果第一个参数为布尔,判定是否深拷贝\n if (typeof target === 'boolean') {\n force = target\n target = arguments[1] || {}\n i++\n }\n\n // 确保接受方为一个复杂的数据类型\n if (typeof target !== 'object' && !isFunction(target)) {\n target = {}\n }\n\n // 如果只有一个参数,那么新成员添加于 extend 所在的对象上\n if (i === length) {\n target = this\n i--\n }\n\n for (; i < length; i++) {\n // 只处理非空参数\n if ((options = arguments[i]) != null) {\n for (name in options) {\n src = target[name]\n copy = options[name]\n\n // 防止环引用\n if (target === copy) {\n continue\n }\n if (force && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {\n if (copyIsArray) {\n copyIsArray = false\n clone = src && isArray(src) ? src : []\n } else {\n clone = src && isPlainObject(src) ? src : {}\n }\n target[name] = utils.extend(force, clone, copy)\n } else if (copy !== undefined) {\n target[name] = copy\n }\n }\n }\n }\n return target\n },\n\n formatSize: function (size) {\n if (size < 1024) {\n return size.toFixed(0) + ' bytes'\n } else if (size < 1024 * 1024) {\n return (size / 1024.0).toFixed(0) + ' KB'\n } else if (size < 1024 * 1024 * 1024) {\n return (size / 1024.0 / 1024.0).toFixed(1) + ' MB'\n } else {\n return (size / 1024.0 / 1024.0 / 1024.0).toFixed(1) + ' GB'\n }\n },\n\n defineNonEnumerable: function (target, key, value) {\n Object.defineProperty(target, key, {\n enumerable: false,\n configurable: true,\n writable: true,\n value: value\n })\n }\n}\n\nmodule.exports = utils\n\n\n//# sourceURL=webpack:///./node_modules/simple-uploader.js/src/utils.js?")}}]);