New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-upload-component

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-upload-component - npm Package Compare versions

Comparing version 2.8.20 to 3.0.36

.browserslistrc

83

.eslintrc.js

@@ -1,39 +0,58 @@

// http://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
jest: true
node: true
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends: "standard",
extends: [
'alloy',
'alloy/typescript',
'plugin:vue/essential',
'@vue/typescript',
// required to lint *.vue files
plugins: [
'html'
'prettier',
'plugin:prettier/recommended',
'prettier/react',
'prettier/standard',
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
rules: {
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'complexity': ["error", 40],
'max-params': ["error", 10],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'guard-for-in': 'off',
"@typescript-eslint/explicit-member-accessibility": "off"
},
parserOptions: {
parser: '@typescript-eslint/parser'
},
plugins: ['@typescript-eslint', 'prettier'],
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
},
// {
// // enable the rule specifically for TypeScript files
// "files": ["*.ts", "*.tsx"],
// "rules": {
// "@typescript-eslint/explicit-member-accessibility": ["error"]
// }
// },
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-member-accessibility": ["error"]
}
},
]
}
'no-control-regex': 0,
'no-useless-escape': 0,
'comma-dangle': 0,
'space-before-function-paren': 0,
'no-multiple-empty-lines': 0,
'no-multi-spaces': 0,
'padded-blocks': 0,
'prefer-promise-reject-errors': 0,
'operator-linebreak': 0
}
}
/*!
* Name: vue-upload-component
* Version: 2.8.20
* Author: LianYue
Name: vue-upload-component
Component URI: https://github.com/lian-yue/vue-upload-component#readme
Version: 3.0.35
Author: LianYue
License: Apache-2.0
Description: Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.VueUploadComponent = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vue')) :
typeof define === 'function' && define.amd ? define(['vue'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VueUploadComponent = factory(global.Vue));
}(this, (function (vue) { 'use strict';
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { _ownKeys(Object(source), true).forEach(function (key) { _defineProperty2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { _ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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 _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, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
/**

@@ -17,2 +110,4 @@ * Creates a XHR request

*/
var createRequest = function createRequest(options) {

@@ -22,2 +117,3 @@ var xhr = new XMLHttpRequest();

xhr.responseType = 'json';
if (options.headers) {

@@ -31,3 +127,2 @@ Object.keys(options.headers).forEach(function (key) {

};
/**

@@ -39,2 +134,4 @@ * Sends a XHR request with certain body

*/
var sendRequest = function sendRequest(xhr, body) {

@@ -45,2 +142,3 @@ return new Promise(function (resolve, reject) {

var response;
try {

@@ -51,2 +149,3 @@ response = JSON.parse(xhr.response);

}
resolve(response);

@@ -57,9 +156,10 @@ } else {

};
xhr.onerror = function () {
return reject(xhr.response);
};
xhr.send(JSON.stringify(body));
});
};
/**

@@ -71,4 +171,7 @@ * Sends a XHR request with certain form data

*/
var sendFormRequest = function sendFormRequest(xhr, data) {
var body = new FormData();
for (var name in data) {

@@ -82,2 +185,3 @@ body.append(name, data[name]);

var response;
try {

@@ -88,2 +192,3 @@ response = JSON.parse(xhr.response);

}
resolve(response);

@@ -94,9 +199,10 @@ } else {

};
xhr.onerror = function () {
return reject(xhr.response);
};
xhr.send(body);
});
};
/**

@@ -109,13 +215,10 @@ * Creates and sends XHR request

*/
function request (options) {
function request(options) {
var xhr = createRequest(options);
return sendRequest(xhr, options.body);
}
var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ChunkUploadHandler = function () {
var ChunkUploadHandler = /*#__PURE__*/function () {
/**

@@ -132,4 +235,6 @@ * Constructor

this.options = options;
this.chunks = [];
this.sessionId = null;
this.chunkSize = null;
}
/**

@@ -141,5 +246,4 @@ * Gets the max retries from options

_createClass(ChunkUploadHandler, [{
key: 'createChunks',
key: "createChunks",
/**

@@ -150,5 +254,5 @@ * Creates all the chunks in the initial state

this.chunks = [];
var start = 0;
var end = this.chunkSize;
while (start < this.fileSize) {

@@ -165,3 +269,2 @@ this.chunks.push({

}
/**

@@ -172,7 +275,6 @@ * Updates the progress of the file with the handler's progress

}, {
key: 'updateFileProgress',
key: "updateFileProgress",
value: function updateFileProgress() {
this.file.progress = this.progress;
}
/**

@@ -185,3 +287,3 @@ * Paues the upload process

}, {
key: 'pause',
key: "pause",
value: function pause() {

@@ -191,3 +293,2 @@ this.file.active = false;

}
/**

@@ -198,3 +299,3 @@ * Stops all the current chunks

}, {
key: 'stopChunks',
key: "stopChunks",
value: function stopChunks() {

@@ -206,3 +307,2 @@ this.chunksUploading.forEach(function (chunk) {

}
/**

@@ -215,3 +315,3 @@ * Resumes the file upload

}, {
key: 'resume',
key: "resume",
value: function resume() {

@@ -221,3 +321,2 @@ this.file.active = true;

}
/**

@@ -232,3 +331,3 @@ * Starts the file upload

}, {
key: 'upload',
key: "upload",
value: function upload() {

@@ -242,6 +341,4 @@ var _this = this;

this.start();
return this.promise;
}
/**

@@ -253,3 +350,3 @@ * Start phase

}, {
key: 'start',
key: "start",
value: function start() {

@@ -260,7 +357,7 @@ var _this2 = this;

method: 'POST',
headers: Object.assign({}, this.headers, {
headers: _objectSpread2(_objectSpread2({}, this.headers), {}, {
'Content-Type': 'application/json'
}),
url: this.action,
body: Object.assign(this.startBody, {
body: _objectSpread2(_objectSpread2({}, this.startBody), {}, {
phase: 'start',

@@ -281,9 +378,10 @@ mime_type: this.fileType,

_this2.createChunks();
_this2.startChunking();
}).catch(function (res) {
_this2.file.response = res;
_this2.reject('server');
});
}
/**

@@ -294,3 +392,3 @@ * Starts to upload chunks

}, {
key: 'startChunking',
key: "startChunking",
value: function startChunking() {

@@ -301,3 +399,2 @@ for (var i = 0; i < this.maxActiveChunks; i++) {

}
/**

@@ -310,3 +407,3 @@ * Uploads the next chunk

}, {
key: 'uploadNextChunk',
key: "uploadNextChunk",
value: function uploadNextChunk() {

@@ -323,3 +420,2 @@ if (this.file.active) {

}
/**

@@ -336,3 +432,3 @@ * Uploads a chunk

}, {
key: 'uploadChunk',
key: "uploadChunk",
value: function uploadChunk(chunk) {

@@ -349,3 +445,2 @@ var _this3 = this;

});
chunk.xhr.upload.addEventListener('progress', function (evt) {

@@ -356,4 +451,3 @@ if (evt.lengthComputable) {

}, false);
sendFormRequest(chunk.xhr, Object.assign(this.uploadBody, {
sendFormRequest(chunk.xhr, _objectSpread2(_objectSpread2({}, this.uploadBody), {}, {
phase: 'upload',

@@ -365,2 +459,3 @@ session_id: this.sessionId,

chunk.active = false;
if (res.status === 'success') {

@@ -371,2 +466,3 @@ chunk.uploaded = true;

_this3.stopChunks();
return _this3.reject('upload');

@@ -379,4 +475,6 @@ }

chunk.active = false;
if (chunk.retries-- <= 0) {
_this3.stopChunks();
return _this3.reject('upload');

@@ -388,3 +486,2 @@ }

}
/**

@@ -396,3 +493,3 @@ * Finish phase

}, {
key: 'finish',
key: "finish",
value: function finish() {

@@ -402,10 +499,9 @@ var _this4 = this;

this.updateFileProgress();
request({
method: 'POST',
headers: Object.assign({}, this.headers, {
headers: _objectSpread2(_objectSpread2({}, this.headers), {}, {
'Content-Type': 'application/json'
}),
url: this.action,
body: Object.assign(this.finishBody, {
body: _objectSpread2(_objectSpread2({}, this.finishBody), {}, {
phase: 'finish',

@@ -416,2 +512,3 @@ session_id: this.sessionId

_this4.file.response = res;
if (res.status !== 'success') {

@@ -424,2 +521,3 @@ return _this4.reject('server');

_this4.file.response = res;
_this4.reject('server');

@@ -429,7 +527,6 @@ });

}, {
key: 'maxRetries',
key: "maxRetries",
get: function get() {
return parseInt(this.options.maxRetries);
return parseInt(this.options.maxRetries, 10);
}
/**

@@ -440,7 +537,6 @@ * Gets the max number of active chunks being uploaded at once from options

}, {
key: 'maxActiveChunks',
key: "maxActiveChunks",
get: function get() {
return parseInt(this.options.maxActive);
return parseInt(this.options.maxActive, 10);
}
/**

@@ -451,7 +547,6 @@ * Gets the file type

}, {
key: 'fileType',
key: "fileType",
get: function get() {
return this.file.type;
}
/**

@@ -462,7 +557,6 @@ * Gets the file size

}, {
key: 'fileSize',
key: "fileSize",
get: function get() {
return this.file.size;
}
/**

@@ -473,7 +567,6 @@ * Gets the file name

}, {
key: 'fileName',
key: "fileName",
get: function get() {
return this.file.name;
}
/**

@@ -484,7 +577,6 @@ * Gets action (url) to upload the file

}, {
key: 'action',
key: "action",
get: function get() {
return this.options.action || null;
}
/**

@@ -495,7 +587,6 @@ * Gets the body to be merged when sending the request in start phase

}, {
key: 'startBody',
key: "startBody",
get: function get() {
return this.options.startBody || {};
}
/**

@@ -506,7 +597,6 @@ * Gets the body to be merged when sending the request in upload phase

}, {
key: 'uploadBody',
key: "uploadBody",
get: function get() {
return this.options.uploadBody || {};
}
/**

@@ -517,7 +607,6 @@ * Gets the body to be merged when sending the request in finish phase

}, {
key: 'finishBody',
key: "finishBody",
get: function get() {
return this.options.finishBody || {};
}
/**

@@ -528,7 +617,6 @@ * Gets the headers of the requests from options

}, {
key: 'headers',
key: "headers",
get: function get() {
return this.options.headers || {};
}
/**

@@ -539,7 +627,6 @@ * Whether it's ready to upload files or not

}, {
key: 'readyToUpload',
key: "readyToUpload",
get: function get() {
return !!this.chunks;
}
/**

@@ -552,3 +639,3 @@ * Gets the progress of the chunk upload

}, {
key: 'progress',
key: "progress",
get: function get() {

@@ -561,6 +648,4 @@ var _this5 = this;

}, 0);
return Math.min(completedProgress + uploadingProgress, 100);
}
/**

@@ -571,4 +656,5 @@ * Gets all the chunks that are pending to be uploaded

}, {
key: 'chunksToUpload',
key: "chunksToUpload",
get: function get() {
console.log(this.chunks);
return this.chunks.filter(function (chunk) {

@@ -578,3 +664,2 @@ return !chunk.active && !chunk.uploaded;

}
/**

@@ -585,7 +670,6 @@ * Whether there are chunks to upload or not

}, {
key: 'hasChunksToUpload',
key: "hasChunksToUpload",
get: function get() {
return this.chunksToUpload.length > 0;
}
/**

@@ -596,3 +680,3 @@ * Gets all the chunks that are uploading

}, {
key: 'chunksUploading',
key: "chunksUploading",
get: function get() {

@@ -603,3 +687,2 @@ return this.chunks.filter(function (chunk) {

}
/**

@@ -610,3 +693,3 @@ * Gets all the chunks that have finished uploading

}, {
key: 'chunksUploaded',
key: "chunksUploaded",
get: function get() {

@@ -622,143 +705,2 @@ return this.chunks.filter(function (chunk) {

//
//
//
//
//
//
//
//
//
//
//
//
//
//
var script = {
methods: {
change: function change(e) {
this.$parent.addInputFile(e.target);
if (e.target.files) {
e.target.value = '';
if (e.target.files.length && !/safari/i.test(navigator.userAgent)) {
e.target.type = '';
e.target.type = 'file';
}
} else {
// ie9 fix #219
this.$destroy();
// eslint-disable-next-line
new this.constructor({
parent: this.$parent,
el: this.$el
});
}
}
}
};
/* script */
var __vue_script__ = script;
/* template */
var __vue_render__ = function __vue_render__() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('input', { attrs: { "type": "file", "name": _vm.$parent.name, "id": _vm.$parent.inputId || _vm.$parent.name, "accept": _vm.$parent.accept, "capture": _vm.$parent.capture, "disabled": _vm.$parent.disabled, "webkitdirectory": _vm.$parent.directory && _vm.$parent.features.directory, "directory": _vm.$parent.directory && _vm.$parent.features.directory, "multiple": _vm.$parent.multiple && _vm.$parent.features.html5 }, on: { "change": _vm.change } });
};
var __vue_staticRenderFns__ = [];
/* style */
var __vue_inject_styles__ = undefined;
/* scoped */
var __vue_scope_id__ = undefined;
/* module identifier */
var __vue_module_identifier__ = undefined;
/* functional template */
var __vue_is_functional_template__ = false;
/* component normalizer */
function __vue_normalize__(template, style, script$$1, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
var component = (typeof script$$1 === 'function' ? script$$1.options : script$$1) || {};
if (!component.render) {
component.render = template.render;
component.staticRenderFns = template.staticRenderFns;
component._compiled = true;
if (functional) component.functional = true;
}
component._scopeId = scope;
return component;
}
/* style inject */
function __vue_create_injector__() {
var head = document.head || document.getElementsByTagName('head')[0];
var styles = __vue_create_injector__.styles || (__vue_create_injector__.styles = {});
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
return function addStyle(id, css) {
if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present.
var group = isOldIE ? css.media || 'default' : id;
var style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined });
if (!style.ids.includes(id)) {
var code = css.source;
var index = style.ids.length;
style.ids.push(id);
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
}
if (isOldIE) {
style.element = style.element || document.querySelector('style[data-group=' + group + ']');
}
if (!style.element) {
var el = style.element = document.createElement('style');
el.type = 'text/css';
if (css.media) el.setAttribute('media', css.media);
if (isOldIE) {
el.setAttribute('data-group', group);
el.setAttribute('data-next-index', '0');
}
head.appendChild(el);
}
if (isOldIE) {
index = parseInt(style.element.getAttribute('data-next-index'));
style.element.setAttribute('data-next-index', index + 1);
}
if (style.element.styleSheet) {
style.parts.push(code);
style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n');
} else {
var textNode = document.createTextNode(code);
var nodes = style.element.childNodes;
if (nodes[index]) style.element.removeChild(nodes[index]);
if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
}
}
};
}
/* style inject SSR */
var InputFile = __vue_normalize__({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, __vue_create_injector__, undefined);
var _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; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var CHUNK_DEFAULT_OPTIONS = {

@@ -770,10 +712,5 @@ headers: {},

maxRetries: 5,
handler: ChunkUploadHandler
};
var script$1 = {
components: {
InputFile: InputFile
},
var script = vue.defineComponent({
props: {

@@ -783,3 +720,2 @@ inputId: {

},
name: {

@@ -789,52 +725,47 @@ type: String,

},
accept: {
type: String
},
capture: {},
disabled: {},
disabled: {
default: false
},
multiple: {
type: Boolean
type: Boolean,
default: false
},
maximum: {
type: Number,
default: function _default() {
return this.multiple ? 0 : 1;
}
type: Number
},
addIndex: {
type: [Boolean, Number]
},
directory: {
type: Boolean
},
createDirectory: {
type: Boolean,
default: false
},
postAction: {
type: String
},
putAction: {
type: String
},
customAction: {
type: Function
},
headers: {
type: Object,
default: Object
default: function _default() {
return {};
}
},
data: {
type: Object,
default: Object
default: function _default() {
return {};
}
},
timeout: {

@@ -844,7 +775,5 @@ type: Number,

},
drop: {
default: false
},
dropDirectory: {

@@ -854,3 +783,2 @@ type: Boolean,

},
size: {

@@ -860,12 +788,14 @@ type: Number,

},
extensions: {
default: Array
type: [RegExp, String, Array],
default: function _default() {
return [];
}
},
value: {
modelValue: {
type: Array,
default: Array
default: function _default() {
return [];
}
},
thread: {

@@ -875,3 +805,2 @@ type: Number,

},
// Chunk upload enabled

@@ -882,3 +811,2 @@ chunkEnabled: {

},
// Chunk upload properties

@@ -892,22 +820,20 @@ chunk: {

},
emits: ['update:modelValue', 'input-filter', 'input-file'],
data: function data() {
return {
files: this.value,
files: this.modelValue,
features: {
html5: true,
directory: false,
drag: false
drop: false
},
active: false,
dropActive: false,
uploading: 0,
destroy: false
destroy: false,
maps: {},
dropElement: null
};
},
/**

@@ -918,14 +844,16 @@ * mounted

mounted: function mounted() {
var _this6 = this;
var input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.multiple = true; // html5 特征
// html5 特征
if (window.FormData && input.files) {
// 上传目录特征
// @ts-ignore
if (typeof input.webkitdirectory === 'boolean' || typeof input.directory === 'boolean') {
this.features.directory = true;
}
} // 拖拽特征
// 拖拽特征
if (this.features.html5 && typeof input.ondrop !== 'undefined') {

@@ -936,6 +864,7 @@ this.features.drop = true;

this.features.html5 = false;
}
} // files 定位缓存
// files 定位缓存
this.maps = {};
if (this.files) {

@@ -946,30 +875,33 @@ for (var i = 0; i < this.files.length; i++) {

}
}
} // @ts-ignore
this.$nextTick(function () {
// 更新下父级
if (_this6.$parent) {
_this6.$parent.$forceUpdate(); // 拖拽渲染
// 更新下父级
if (this.$parent) {
this.$parent.$forceUpdate();
_this6.$parent.$nextTick(function () {
_this6.watchDrop(_this6.drop);
});
} else {
// 拖拽渲染
_this6.watchDrop(_this6.drop);
}
// 拖拽渲染
this.watchDrop(this.drop);
});
},
/**
* beforeDestroy
* beforeUnmount
* @return {[type]} [description]
*/
beforeDestroy: function beforeDestroy() {
beforeUnmount: function beforeUnmount() {
// 已销毁
this.destroy = true;
this.destroy = true; // 设置成不激活
// 设置成不激活
this.active = false;
this.active = false; // 销毁拖拽事件
this.watchDrop(false);
},
computed: {

@@ -986,5 +918,7 @@ /**

uploaded: function uploaded() {
var file = void 0;
var file;
for (var i = 0; i < this.files.length; i++) {
file = this.files[i];
if (file.fileObject && !file.error && !file.success) {

@@ -994,2 +928,3 @@ return false;

}
return true;

@@ -1002,5 +937,38 @@ },

return ['file-uploads', this.features.html5 ? 'file-uploads-html5' : 'file-uploads-html4', this.features.directory && this.directory ? 'file-uploads-directory' : undefined, this.features.drop && this.drop ? 'file-uploads-drop' : undefined, this.disabled ? 'file-uploads-disabled' : undefined];
},
forId: function forId() {
return this.inputId || this.name;
},
iMaximum: function iMaximum() {
if (this.maximum === undefined) {
return this.multiple ? 0 : 1;
}
return this.maximum;
},
iExtensions: function iExtensions() {
if (!this.extensions) {
return;
}
if (this.extensions instanceof RegExp) {
return this.extensions;
}
var exts = [];
if (typeof this.extensions === 'string') {
exts = this.extensions.split(',');
} else {
exts = this.extensions;
}
exts = exts.map(function (value) {
return value.trim();
}).filter(function (value) {
return value;
});
return new RegExp('\\.(' + exts.join('|').replace(/\./g, '\\.') + ')$', 'i');
}
},
watch: {

@@ -1018,27 +986,28 @@ active: function active(_active) {

},
value: function value(files) {
modelValue: function modelValue(files) {
if (this.files === files) {
return;
}
this.files = files;
var oldMaps = this.maps; // 重写 maps 缓存
var oldMaps = this.maps;
this.maps = {};
// 重写 maps 缓存
this.maps = {};
for (var i = 0; i < this.files.length; i++) {
var file = this.files[i];
this.maps[file.id] = file;
}
} // add, update
// add, update
for (var key in this.maps) {
var newFile = this.maps[key];
var oldFile = oldMaps[key];
if (newFile !== oldFile) {
this.emitFile(newFile, oldFile);
}
}
} // delete
// delete
for (var _key in oldMaps) {

@@ -1051,5 +1020,6 @@ if (!this.maps[_key]) {

},
methods: {
newId: function newId() {
return Math.random().toString(36).substr(2);
},
// 清空

@@ -1059,9 +1029,8 @@ clear: function clear() {

var files = this.files;
this.files = [];
this.files = []; // 定位
// 定位
this.maps = {};
this.maps = {}; // 事件
// 事件
this.emitInput();
for (var i = 0; i < files.length; i++) {

@@ -1071,6 +1040,5 @@ this.emitFile(undefined, files[i]);

}
return true;
},
// 选择

@@ -1082,4 +1050,4 @@ get: function get(id) {

if ((typeof id === 'undefined' ? 'undefined' : _typeof(id)) === 'object') {
return this.maps[id.id] || false;
if (_typeof(id) === 'object') {
return this.maps[id.id || ''] || false;
}

@@ -1089,24 +1057,30 @@

},
// 添加
add: function add(_files, index) {
// 不是数组整理成数组
var files;
if (_files instanceof Array) {
files = _files;
} else {
files = [_files];
}
// 添加
add: function add(_files) {
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.addIndex;
if (index === undefined) {
// eslint-disable-next-line
index = this.addIndex;
} // 遍历规范对象
var files = _files;
var isArray = files instanceof Array;
// 不是数组整理成数组
if (!isArray) {
files = [files];
}
var addFiles = [];
// 遍历规范对象
var addFiles = [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (this.features.html5 && file instanceof Blob) {
file = {
id: '',
file: file,
size: file.size,
// @ts-ignore
name: file.webkitRelativePath || file.relativePath || file.name || 'unknown',

@@ -1116,6 +1090,8 @@ type: file.type

}
file = file;
var fileObject = false;
if (file.fileObject === false) ; else if (file.fileObject) {
if (file.fileObject === false) ;else if (file.fileObject) {
fileObject = true;
} else if (typeof Element !== 'undefined' && file.el instanceof Element) {
} else if (typeof Element !== 'undefined' && file.el instanceof HTMLInputElement) {
fileObject = true;

@@ -1125,4 +1101,5 @@ } else if (typeof Blob !== 'undefined' && file.file instanceof Blob) {

}
if (fileObject) {
file = _extends({
file = _objectSpread(_objectSpread({
fileObject: true,

@@ -1138,19 +1115,14 @@ size: -1,

timeout: this.timeout
}, file, {
}, file), {}, {
response: {},
progress: '0.00', // 只读
speed: 0 // 只读
// xhr: false, // 只读
// iframe: false, // 只读
progress: '0.00',
speed: 0
});
file.data = _objectSpread(_objectSpread({}, this.data), file.data ? file.data : {});
file.headers = _objectSpread(_objectSpread({}, this.headers), file.headers ? file.headers : {});
} // 必须包含 id
file.data = _extends({}, this.data, file.data ? file.data : {});
file.headers = _extends({}, this.headers, file.headers ? file.headers : {});
}
// 必须包含 id
if (!file.id) {
file.id = Math.random().toString(36).substr(2);
file.id = this.newId();
}

@@ -1160,29 +1132,29 @@

continue;
}
} // 最大数量限制
// 最大数量限制
if (this.maximum > 1 && addFiles.length + this.files.length >= this.maximum) {
if (this.iMaximum > 1 && addFiles.length + this.files.length >= this.iMaximum) {
break;
}
addFiles.push(file);
addFiles.push(file); // 最大数量限制
// 最大数量限制
if (this.maximum === 1) {
if (this.iMaximum === 1) {
break;
}
}
} // 没有文件
// 没有文件
if (!addFiles.length) {
return false;
}
return;
} // 如果是 1 清空
// 如果是 1 清空
if (this.maximum === 1) {
if (this.iMaximum === 1) {
this.clear();
}
} // 添加进去 files
// 添加进去 files
var newFiles = void 0;
var newFiles;
if (index === true || index === 0) {

@@ -1194,2 +1166,3 @@ newFiles = addFiles.concat(this.files);

newFiles = this.files.concat([]);
(_newFiles = newFiles).splice.apply(_newFiles, [index, 0].concat(addFiles));

@@ -1200,12 +1173,12 @@ } else {

this.files = newFiles;
this.files = newFiles; // 定位
// 定位
for (var _i = 0; _i < addFiles.length; _i++) {
var _file2 = addFiles[_i];
this.maps[_file2.id] = _file2;
}
var _file = addFiles[_i];
this.maps[_file.id] = _file;
} // 事件
// 事件
this.emitInput();
for (var _i2 = 0; _i2 < addFiles.length; _i2++) {

@@ -1215,9 +1188,19 @@ this.emitFile(addFiles[_i2], undefined);

return isArray ? addFiles : addFiles[0];
return _files instanceof Array ? addFiles : addFiles[0];
},
// 添加表单文件
addInputFile: function addInputFile(el) {
var _this7 = this;
var files = [];
var maximumValue = this.iMaximum; // @ts-ignore
var entrys = el.webkitEntries || el.entries || undefined;
if (entrys && entrys.length) {
return this.getFileSystemEntry(entrys).then(function (files) {
return _this7.add(files);
});
}
if (el.files) {

@@ -1227,3 +1210,5 @@ for (var i = 0; i < el.files.length; i++) {

files.push({
id: '',
size: file.size,
// @ts-ignore
name: file.webkitRelativePath || file.relativePath || file.name,

@@ -1236,4 +1221,11 @@ type: file.type,

var names = el.value.replace(/\\/g, '/').split('/');
if (!names || !names.length) {
names = [el.value];
} // @ts-ignore
delete el.__vuex__;
files.push({
id: '',
name: names[names.length - 1],

@@ -1243,50 +1235,50 @@ el: el

}
return this.add(files);
return Promise.resolve(this.add(files));
},
// 添加 DataTransfer
addDataTransfer: function addDataTransfer(dataTransfer) {
var _this = this;
var _dataTransfer$items,
_this8 = this;
var files = [];
if (dataTransfer.items && dataTransfer.items.length) {
var items = [];
// dataTransfer.items 支持
if (dataTransfer !== null && dataTransfer !== void 0 && (_dataTransfer$items = dataTransfer.items) !== null && _dataTransfer$items !== void 0 && _dataTransfer$items.length) {
var entrys = []; // 遍历出所有 dataTransferVueUploadItem
for (var i = 0; i < dataTransfer.items.length; i++) {
var item = dataTransfer.items[i];
if (item.getAsEntry) {
item = item.getAsEntry() || item.getAsFile();
} else if (item.webkitGetAsEntry) {
item = item.webkitGetAsEntry() || item.getAsFile();
var dataTransferTtem = dataTransfer.items[i];
var entry = void 0; // @ts-ignore
if (dataTransferTtem.getAsEntry) {
// @ts-ignore
entry = dataTransferTtem.getAsEntry() || dataTransferTtem.getAsFile();
} else if (dataTransferTtem.webkitGetAsEntry) {
entry = dataTransferTtem.webkitGetAsEntry() || dataTransferTtem.getAsFile();
} else {
item = item.getAsFile();
entry = dataTransferTtem.getAsFile();
}
if (item) {
items.push(item);
if (entry) {
entrys.push(entry);
}
}
return new Promise(function (resolve, reject) {
var forEach = function forEach(i) {
var item = items[i];
// 结束 文件数量大于 最大数量
if (!item || _this.maximum > 0 && files.length >= _this.maximum) {
return resolve(_this.add(files));
}
_this.getEntry(item).then(function (results) {
files.push.apply(files, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
return this.getFileSystemEntry(entrys).then(function (files) {
return _this8.add(files);
});
}
} // dataTransfer.files 支持
var maximumValue = this.iMaximum;
var files = [];
if (dataTransfer.files.length) {
for (var _i3 = 0; _i3 < dataTransfer.files.length; _i3++) {
files.push(dataTransfer.files[_i3]);
if (this.maximum > 0 && files.length >= this.maximum) {
if (maximumValue > 0 && files.length >= maximumValue) {
break;
}
}
return Promise.resolve(this.add(files));

@@ -1297,14 +1289,50 @@ }

},
// 获得 entrys
getFileSystemEntry: function getFileSystemEntry(entry) {
var _this9 = this;
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return new Promise(function (resolve) {
var maximumValue = _this9.iMaximum;
// 获得 entry
getEntry: function getEntry(entry) {
var _this2 = this;
if (!entry) {
return resolve([]);
}
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
if (entry instanceof Array) {
// 多个
var uploadFiles = [];
return new Promise(function (resolve, reject) {
var forEach = function forEach(i) {
var v = entry[i];
if (!v || maximumValue > 0 && uploadFiles.length >= maximumValue) {
return resolve(uploadFiles);
}
_this9.getFileSystemEntry(v, path).then(function (results) {
uploadFiles.push.apply(uploadFiles, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
return;
}
if (entry instanceof Blob) {
resolve([{
id: '',
size: entry.size,
name: path + entry.name,
type: entry.type,
file: entry
}]);
return;
}
if (entry.isFile) {
entry.file(function (file) {
resolve([{
id: '',
size: file.size,

@@ -1316,40 +1344,68 @@ name: path + file.name,

});
} else if (entry.isDirectory && _this2.dropDirectory) {
var files = [];
return;
}
if (entry.isDirectory && _this9.dropDirectory) {
var _uploadFiles = []; // 目录也要添加到文件列表
if (_this9.createDirectory) {
_uploadFiles.push({
id: '',
name: path + entry.name,
size: 0,
type: 'text/directory',
file: new File([], path + entry.name, {
type: 'text/directory'
})
});
}
var dirReader = entry.createReader();
var readEntries = function readEntries() {
dirReader.readEntries(function (entries) {
var forEach = function forEach(i) {
if (!entries[i] && i === 0 || _this2.maximum > 0 && files.length >= _this2.maximum) {
return resolve(files);
if (!entries[i] && i === 0 || maximumValue > 0 && _uploadFiles.length >= maximumValue) {
return resolve(_uploadFiles);
}
if (!entries[i]) {
return readEntries();
}
_this2.getEntry(entries[i], path + entry.name + '/').then(function (results) {
files.push.apply(files, _toConsumableArray(results));
_this9.getFileSystemEntry(entries[i], path + entry.name + '/').then(function (results) {
_uploadFiles.push.apply(_uploadFiles, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
});
};
readEntries();
} else {
resolve([]);
return;
}
resolve([]);
});
},
// 替换
replace: function replace(id1, id2) {
var file1 = this.get(id1);
var file2 = this.get(id2);
if (!file1 || !file2 || file1 === file2) {
return false;
}
var files = this.files.concat([]);
var index1 = files.indexOf(file1);
var index2 = files.indexOf(file2);
if (index1 === -1 || index2 === -1) {
return false;
}
files[index1] = file2;

@@ -1361,7 +1417,6 @@ files[index2] = file1;

},
// 移除
remove: function remove(id) {
var file = this.get(id);
if (file) {

@@ -1371,4 +1426,6 @@ if (this.emitFilter(undefined, file)) {

}
var files = this.files.concat([]);
var index = files.indexOf(file);
if (index === -1) {

@@ -1378,22 +1435,22 @@ console.error('remove', file);

}
files.splice(index, 1);
this.files = files;
this.files = files; // 定位
// 定位
delete this.maps[file.id];
delete this.maps[file.id]; // 事件
// 事件
this.emitInput();
this.emitFile(undefined, file);
}
return file;
},
// 更新
update: function update(id, data) {
var file = this.get(id);
if (file) {
var newFile = _extends({}, file, data);
// 停用必须加上错误
var newFile = _objectSpread(_objectSpread({}, file), data); // 停用必须加上错误
if (file.fileObject && file.active && !newFile.active && !newFile.error && !newFile.success) {

@@ -1409,2 +1466,3 @@ newFile.error = 'abort';

var index = files.indexOf(file);
if (index === -1) {

@@ -1414,10 +1472,9 @@ console.error('update', file);

}
files.splice(index, 1, newFile);
this.files = files;
this.files = files; // 删除 旧定位 写入 新定位 (已便支持修改id)
// 删除 旧定位 写入 新定位 (已便支持修改id)
delete this.maps[file.id];
this.maps[newFile.id] = newFile;
this.maps[newFile.id] = newFile; // 事件
// 事件
this.emitInput();

@@ -1427,6 +1484,5 @@ this.emitFile(newFile, file);

}
return false;
},
// 预处理 事件 过滤器

@@ -1436,3 +1492,4 @@ emitFilter: function emitFilter(newFile, oldFile) {

this.$emit('input-filter', newFile, oldFile, function () {
isPrevent = true;
var prevent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
isPrevent = prevent;
return isPrevent;

@@ -1442,19 +1499,25 @@ });

},
// 处理后 事件 分发
emitFile: function emitFile(newFile, oldFile) {
var _newFile,
_this10 = this;
this.$emit('input-file', newFile, oldFile);
if (newFile && newFile.fileObject && newFile.active && (!oldFile || !oldFile.active)) {
this.uploading++;
// 激活
if ((_newFile = newFile) !== null && _newFile !== void 0 && _newFile.fileObject && newFile.active && (!oldFile || !oldFile.active)) {
this.uploading++; // 激活
// @ts-ignore
this.$nextTick(function () {
var _this3 = this;
setTimeout(function () {
newFile && _this10.upload(newFile).then(function () {
var _newFile2;
setTimeout(function () {
_this3.upload(newFile).then(function () {
// eslint-disable-next-line
newFile = _this3.get(newFile);
if (newFile && newFile.fileObject) {
_this3.update(newFile, {
if (newFile) {
// eslint-disable-next-line
newFile = _this10.get(newFile) || undefined;
}
if ((_newFile2 = newFile) !== null && _newFile2 !== void 0 && _newFile2.fileObject) {
_this10.update(newFile, {
active: false,

@@ -1465,3 +1528,3 @@ success: !newFile.error

}).catch(function (e) {
_this3.update(newFile, {
newFile && _this10.update(newFile, {
active: false,

@@ -1472,3 +1535,3 @@ success: false,

});
}, parseInt(Math.random() * 50 + 50, 10));
}, Math.ceil(Math.random() * 50 + 50));
});

@@ -1478,5 +1541,6 @@ } else if ((!newFile || !newFile.fileObject || !newFile.active) && oldFile && oldFile.fileObject && oldFile.active) {

this.uploading--;
}
} // 自动延续激活
// @ts-ignore
// 自动延续激活
if (this.active && (Boolean(newFile) !== Boolean(oldFile) || newFile.active !== oldFile.active)) {

@@ -1487,51 +1551,43 @@ this.watchActive(true);

emitInput: function emitInput() {
this.$emit('input', this.files);
this.$emit('update:modelValue', this.files);
},
// 上传
upload: function upload(id) {
var file = this.get(id);
var file = this.get(id); // 被删除
// 被删除
if (!file) {
return Promise.reject('not_exists');
}
return Promise.reject(new Error('not_exists'));
} // 不是文件对象
// 不是文件对象
if (!file.fileObject) {
return Promise.reject('file_object');
}
return Promise.reject(new Error('file_object'));
} // 有错误直接响应
// 有错误直接响应
if (file.error) {
return Promise.reject(file.error);
}
if (file.error instanceof Error) {
return Promise.reject(file.error);
}
// 已完成直接响应
return Promise.reject(new Error(file.error));
} // 已完成直接响应
if (file.success) {
return Promise.resolve(file);
}
} // 后缀
// 后缀
var extensions = this.extensions;
if (extensions && (extensions.length || typeof extensions.length === 'undefined')) {
if ((typeof extensions === 'undefined' ? 'undefined' : _typeof(extensions)) !== 'object' || !(extensions instanceof RegExp)) {
if (typeof extensions === 'string') {
extensions = extensions.split(',').map(function (value) {
return value.trim();
}).filter(function (value) {
return value;
});
}
extensions = new RegExp('\\.(' + extensions.join('|').replace(/\./g, '\\.') + ')$', 'i');
if (file.name && this.iExtensions) {
if (file.name.search(this.iExtensions) === -1) {
return Promise.reject(new Error('extension'));
}
if (file.name.search(extensions) === -1) {
return Promise.reject('extension');
}
}
} // 大小
// 大小
if (this.size > 0 && file.size >= 0 && file.size > this.size) {
return Promise.reject('size');
if (this.size > 0 && file.size !== undefined && file.size >= 0 && file.size > this.size) {
return Promise.reject(new Error('size'));
}

@@ -1547,5 +1603,7 @@

}
if (file.putAction) {
return this.uploadPut(file);
}
if (file.postAction) {

@@ -1555,9 +1613,10 @@ return this.uploadHtml5(file);

}
if (file.postAction) {
return this.uploadHtml4(file);
}
return Promise.reject('No action configured');
return Promise.reject(new Error('No action configured'));
},
/**

@@ -1569,6 +1628,5 @@ * Whether this file should be uploaded using chunk upload or not

shouldUseChunkUpload: function shouldUseChunkUpload(file) {
return this.chunkEnabled && !!this.chunkOptions.handler && file.size > this.chunkOptions.minSize;
return this.chunkEnabled && !!this.chunkOptions.handler && file.size && file.size > this.chunkOptions.minSize;
},
/**

@@ -1582,10 +1640,13 @@ * Upload a file using Chunk method

file.chunk = new HandlerClass(file, this.chunkOptions);
return file.chunk.upload();
return file.chunk.upload().then(function (res) {
return file;
});
},
uploadPut: function uploadPut(file) {
var querys = [];
var value = void 0;
var value;
for (var key in file.data) {
value = file.data[key];
if (value !== null && value !== undefined) {

@@ -1595,5 +1656,7 @@ querys.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));

}
var queryString = querys.length ? (file.putAction.indexOf('?') === -1 ? '?' : '&') + querys.join('&') : '';
var putAction = file.putAction || '';
var queryString = querys.length ? (putAction.indexOf('?') === -1 ? '?' : '&') + querys.join('&') : '';
var xhr = new XMLHttpRequest();
xhr.open('PUT', file.putAction + queryString);
xhr.open('PUT', putAction + queryString);
return this.uploadXhr(xhr, file, file.file);

@@ -1603,6 +1666,8 @@ },

var form = new window.FormData();
var value = void 0;
var value;
for (var key in file.data) {
value = file.data[key];
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toString !== 'function') {
if (value && _typeof(value) === 'object' && typeof value.toString !== 'function') {
if (value instanceof File) {

@@ -1616,31 +1681,38 @@ form.append(key, value, value.name);

}
}
form.append(this.name, file.file, file.file.filename || file.name);
} // @ts-ignore
form.append(this.name, file.file, file.file.name || file.file.filename || file.name);
var xhr = new XMLHttpRequest();
xhr.open('POST', file.postAction);
xhr.open('POST', file.postAction || '');
return this.uploadXhr(xhr, file, form);
},
uploadXhr: function uploadXhr(xhr, _file, body) {
var _this4 = this;
uploadXhr: function uploadXhr(xhr, ufile, body) {
var _this11 = this;
var file = _file;
var file = ufile;
var speedTime = 0;
var speedLoaded = 0;
var speedLoaded = 0; // 进度条
// 进度条
xhr.upload.onprogress = function (e) {
// 还未开始上传 已删除 未激活
file = _this4.get(file);
if (!e.lengthComputable || !file || !file.fileObject || !file.active) {
if (!file) {
return;
}
// 进度 速度 每秒更新一次
file = _this11.get(file);
if (!e.lengthComputable || !file || !file.fileObject || !file.active) {
return;
} // 进度 速度 每秒更新一次
var speedTime2 = Math.round(Date.now() / 1000);
if (speedTime2 === speedTime) {
return;
}
speedTime = speedTime2;
file = _this4.update(file, {
file = _this11.update(file, {
progress: (e.loaded / e.total * 100).toFixed(2),

@@ -1650,9 +1722,14 @@ speed: e.loaded - speedLoaded

speedLoaded = e.loaded;
};
}; // 检查激活状态
// 检查激活状态
var interval = setInterval(function () {
file = _this4.get(file);
if (file && file.fileObject && !file.success && !file.error && file.active) {
return;
var interval = window.setInterval(function () {
if (file) {
var _file2;
file = _this11.get(file);
if (file && (_file2 = file) !== null && _file2 !== void 0 && _file2.fileObject && !file.success && !file.error && file.active) {
return;
}
}

@@ -1662,3 +1739,3 @@

clearInterval(interval);
interval = false;
interval = undefined;
}

@@ -1671,5 +1748,9 @@

}, 100);
return new Promise(function (resolve, reject) {
if (!file) {
return reject(new Error('not_exists'));
}
return new Promise(function (resolve, reject) {
var complete = void 0;
var complete;
var fn = function fn(e) {

@@ -1680,31 +1761,40 @@ // 已经处理过了

}
complete = true;
if (interval) {
clearInterval(interval);
interval = false;
interval = undefined;
}
file = _this4.get(file);
// 不存在直接响应
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 不是文件对象
file = _this11.get(file); // 不存在直接响应
if (!file) {
return reject(new Error('not_exists'));
} // 不是文件对象
if (!file.fileObject) {
return reject('file_object');
}
return reject(new Error('file_object'));
} // 有错误自动响应
// 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 未激活
return reject(new Error(file.error));
} // 未激活
if (!file.active) {
return reject('abort');
}
return reject(new Error('abort'));
} // 已完成 直接相应
// 已完成 直接相应
if (file.success) {

@@ -1721,2 +1811,3 @@ return resolve(file);

break;
case 'error':

@@ -1730,3 +1821,5 @@ if (!xhr.status) {

}
break;
default:

@@ -1740,2 +1833,3 @@ if (xhr.status >= 500) {

}
}

@@ -1745,2 +1839,3 @@

var contentType = xhr.getResponseHeader('Content-Type');
if (contentType && contentType.indexOf('/json') !== -1) {

@@ -1751,43 +1846,58 @@ data.response = JSON.parse(xhr.responseText);

}
}
} // 更新
// @ts-ignore
// 更新
file = _this4.update(file, data);
// 相应错误
file = _this11.update(file, data);
if (!file) {
return reject(new Error('abort'));
} // 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 响应
return reject(new Error(file.error));
} // 响应
return resolve(file);
};
}; // 事件
// 事件
xhr.onload = fn;
xhr.onerror = fn;
xhr.onabort = fn;
xhr.ontimeout = fn;
xhr.ontimeout = fn; // 超时
// 超时
if (file.timeout) {
xhr.timeout = file.timeout;
}
} // headers
// headers
for (var key in file.headers) {
xhr.setRequestHeader(key, file.headers[key]);
}
} // 更新 xhr
// @ts-ignore
// 更新 xhr
file = _this4.update(file, { xhr: xhr });
// 开始上传
xhr.send(body);
file = _this11.update(file, {
xhr: xhr
}); // 开始上传
file && xhr.send(body);
});
},
uploadHtml4: function uploadHtml4(_file) {
var _this5 = this;
uploadHtml4: function uploadHtml4(ufile) {
var _this12 = this;
var file = _file;
var file = ufile;
if (!file) {
return Promise.reject(new Error('not_exists'));
}
var onKeydown = function onKeydown(e) {

@@ -1804,9 +1914,5 @@ if (e.keyCode === 27) {

iframe.setAttribute('style', 'width:1px;height:1px;top:-999em;position:absolute; margin-top:-999em;');
var form = document.createElement('form');
form.action = file.postAction;
form.setAttribute('action', file.postAction || '');
form.name = 'upload-form-' + file.id;
form.setAttribute('method', 'POST');

@@ -1816,23 +1922,26 @@ form.setAttribute('target', 'upload-iframe-' + file.id);

var value = void 0;
var input = void 0;
for (var key in file.data) {
value = file.data[key];
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toString !== 'function') {
var value = file.data[key];
if (value && _typeof(value) === 'object' && typeof value.toString !== 'function') {
value = JSON.stringify(value);
}
if (value !== null && value !== undefined) {
input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
form.appendChild(input);
var el = document.createElement('input');
el.type = 'hidden';
el.name = key;
el.value = value;
form.appendChild(el);
}
}
form.appendChild(file.el);
document.body.appendChild(iframe).appendChild(form);
var getResponseData = function getResponseData() {
var doc = void 0;
var _doc;
var doc;
try {

@@ -1843,12 +1952,18 @@ if (iframe.contentWindow) {

} catch (err) {}
if (!doc) {
try {
// @ts-ignore
doc = iframe.contentDocument ? iframe.contentDocument : iframe.document;
} catch (err) {
// @ts-ignore
doc = iframe.document;
}
}
if (doc && doc.body) {
} // @ts-ignore
if ((_doc = doc) !== null && _doc !== void 0 && _doc.body) {
return doc.body.innerHTML;
}
return null;

@@ -1859,14 +1974,24 @@ };

setTimeout(function () {
file = _this5.update(file, { iframe: iframe });
// 不存在
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 定时检查
var interval = setInterval(function () {
file = _this5.get(file);
if (file && file.fileObject && !file.success && !file.error && file.active) {
return;
file = _this12.update(file, {
iframe: iframe
}); // 不存在
if (!file) {
return reject(new Error('not_exists'));
} // 定时检查
var interval = window.setInterval(function () {
if (file) {
var _file3;
file = _this12.get(file);
if (file && (_file3 = file) !== null && _file3 !== void 0 && _file3.fileObject && !file.success && !file.error && file.active) {
return;
}
}

@@ -1876,10 +2001,15 @@

clearInterval(interval);
interval = false;
}
interval = undefined;
} // @ts-ignore
iframe.onabort({ type: file ? 'abort' : 'not_exists' });
iframe.onabort({
type: file ? 'abort' : 'not_exists'
});
}, 100);
var complete;
var complete = void 0;
var fn = function fn(e) {
var _file4;
// 已经处理过了

@@ -1889,2 +2019,3 @@ if (complete) {

}
complete = true;

@@ -1894,31 +2025,38 @@

clearInterval(interval);
interval = false;
}
interval = undefined;
} // 关闭 esc 事件
// 关闭 esc 事件
document.body.removeEventListener('keydown', onKeydown);
file = _this5.get(file);
// 不存在直接响应
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 不是文件对象
file = _this12.get(file); // 不存在直接响应
if (!file) {
return reject(new Error('not_exists'));
} // 不是文件对象
if (!file.fileObject) {
return reject('file_object');
}
return reject(new Error('file_object'));
} // 有错误自动响应
// 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 未激活
return reject(new Error(file.error));
} // 未激活
if (!file.active) {
return reject('abort');
}
return reject(new Error('abort'));
} // 已完成 直接相应
// 已完成 直接相应
if (file.success) {

@@ -1930,2 +2068,7 @@ return resolve(file);

var data = {};
if (typeof e === 'string') {
return reject(new Error(e));
}
switch (e.type) {

@@ -1935,2 +2078,3 @@ case 'abort':

break;
case 'error':

@@ -1944,7 +2088,9 @@ if (file.error) {

}
break;
default:
if (file.error) {
data.error = file.error;
} else if (data === null) {
} else if (response === null) {
data.error = 'network';

@@ -1954,2 +2100,3 @@ } else {

}
}

@@ -1963,32 +2110,43 @@

}
data.response = response;
}
} // 更新
// 更新
file = _this5.update(file, data);
if (file.error) {
return reject(file.error);
file = _this12.update(file, data);
if (!file) {
return reject(new Error('not_exists'));
}
// 响应
if ((_file4 = file) !== null && _file4 !== void 0 && _file4.error) {
if (file.error instanceof Error) {
return reject(file.error);
}
return reject(new Error(file.error));
} // 响应
return resolve(file);
};
}; // 添加事件
// 添加事件
iframe.onload = fn;
iframe.onerror = fn;
iframe.onabort = fn;
iframe.onabort = fn; // 禁止 esc 键
// 禁止 esc 键
document.body.addEventListener('keydown', onKeydown);
document.body.addEventListener('keydown', onKeydown); // 提交
// 提交
form.submit();
}, 50);
}).then(function (res) {
iframe.parentNode && iframe.parentNode.removeChild(iframe);
var _iframe$parentNode;
iframe === null || iframe === void 0 ? void 0 : (_iframe$parentNode = iframe.parentNode) === null || _iframe$parentNode === void 0 ? void 0 : _iframe$parentNode.removeChild(iframe);
return res;
}).catch(function (res) {
iframe.parentNode && iframe.parentNode.removeChild(iframe);
var _iframe$parentNode2;
iframe === null || iframe === void 0 ? void 0 : (_iframe$parentNode2 = iframe.parentNode) === null || _iframe$parentNode2 === void 0 ? void 0 : _iframe$parentNode2.removeChild(iframe);
return res;

@@ -1998,19 +2156,26 @@ });

watchActive: function watchActive(active) {
var file = void 0;
var file;
var index = 0;
while (file = this.files[index]) {
index++;
if (!file.fileObject) ; else if (active && !this.destroy) {
if (!file.fileObject) ;else if (active && !this.destroy) {
if (this.uploading >= this.thread || this.uploading && !this.features.html5) {
break;
}
if (!file.active && !file.error && !file.success) {
this.update(file, { active: true });
this.update(file, {
active: true
});
}
} else {
if (file.active) {
this.update(file, { active: false });
this.update(file, {
active: false
});
}
}
}
if (this.uploading === 0) {

@@ -2020,4 +2185,5 @@ this.active = false;

},
watchDrop: function watchDrop(_el) {
var el = _el;
watchDrop: function watchDrop(newDrop) {
var oldDrop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
if (!this.features.drop) {

@@ -2027,3 +2193,7 @@ return;

// 移除挂载
if (newDrop === oldDrop) {
return;
} // 移除挂载
if (this.dropElement) {

@@ -2039,10 +2209,12 @@ try {

if (!el) {
el = false;
} else if (typeof el === 'string') {
el = document.querySelector(el) || this.$root.$el.querySelector(el);
} else if (el === true) {
var el = null;
if (!newDrop) ;else if (typeof newDrop === 'string') {
// @ts-ignore
var _el = document.querySelector(newDrop) || this.$root.$el.querySelector(newDrop);
} else if (newDrop === true) {
// @ts-ignore
el = this.$parent.$el;
} else {
el = newDrop;
}
this.dropElement = el;

@@ -2059,11 +2231,17 @@

onDragenter: function onDragenter(e) {
var _dt$files, _dt$types;
e.preventDefault();
if (this.dropActive) {
return;
}
if (!e.dataTransfer) {
return;
}
var dt = e.dataTransfer;
if (dt.files && dt.files.length) {
if (dt !== null && dt !== void 0 && (_dt$files = dt.files) !== null && _dt$files !== void 0 && _dt$files.length) {
this.dropActive = true;

@@ -2073,5 +2251,5 @@ } else if (!dt.types) {

} else if (dt.types.indexOf && dt.types.indexOf('Files') !== -1) {
this.dropActive = true; // @ts-ignore
} else if ((_dt$types = dt.types) !== null && _dt$types !== void 0 && _dt$types.contains && dt.types.contains('Files')) {
this.dropActive = true;
} else if (dt.types.contains && dt.types.contains('Files')) {
this.dropActive = true;
}

@@ -2081,5 +2259,8 @@ },

e.preventDefault();
if (!this.dropActive) {
return;
}
} // @ts-ignore
if (e.target.nodeName === 'HTML' || e.target === e.explicitOriginalTarget || !e.fromElement && (e.clientX <= 0 || e.clientY <= 0 || e.clientX >= window.innerWidth || e.clientY >= window.innerHeight)) {

@@ -2097,142 +2278,112 @@ this.dropActive = false;

e.preventDefault();
this.addDataTransfer(e.dataTransfer);
}
}
};
e.dataTransfer && this.addDataTransfer(e.dataTransfer);
},
inputOnChange: function (_inputOnChange) {
function inputOnChange(_x) {
return _inputOnChange.apply(this, arguments);
}
/* script */
var __vue_script__$1 = script$1;
inputOnChange.toString = function () {
return _inputOnChange.toString();
};
/* template */
var __vue_render__$1 = function __vue_render__() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('span', { class: _vm.className }, [_vm._t("default"), _vm._v(" "), _c('label', { attrs: { "for": _vm.inputId || _vm.name } }), _vm._v(" "), _c('input-file')], 2);
};
var __vue_staticRenderFns__$1 = [];
return inputOnChange;
}(async function (e) {
var _this13 = this;
/* style */
var __vue_inject_styles__$1 = function (inject) {
if (!inject) return;
inject("data-v-595958af_0", { source: "\n.file-uploads{overflow:hidden;position:relative;text-align:center;display:inline-block\n}\n.file-uploads.file-uploads-html4 input,.file-uploads.file-uploads-html5 label{background:#fff;opacity:0;font-size:20em;z-index:1;top:0;left:0;right:0;bottom:0;position:absolute;width:100%;height:100%\n}\n.file-uploads.file-uploads-html4 label,.file-uploads.file-uploads-html5 input{background:rgba(255,255,255,0);overflow:hidden;position:fixed;width:1px;height:1px;z-index:-1;opacity:0\n}", map: undefined, media: undefined });
};
/* scoped */
var __vue_scope_id__$1 = undefined;
/* module identifier */
var __vue_module_identifier__$1 = undefined;
/* functional template */
var __vue_is_functional_template__$1 = false;
/* component normalizer */
function __vue_normalize__$1(template, style, script, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
var component = (typeof script === 'function' ? script.options : script) || {};
if (!(e.target instanceof HTMLInputElement)) {
return Promise.reject(new Error("not HTMLInputElement"));
}
if (!component.render) {
component.render = template.render;
component.staticRenderFns = template.staticRenderFns;
component._compiled = true;
var target = e.target;
if (functional) component.functional = true;
}
var reinput = function reinput(res) {
if (target.files) {
target.value = '';
component._scopeId = scope;
if (target.files.length && !/safari/i.test(navigator.userAgent)) {
target.type = '';
target.type = 'file';
}
} else {
var _oldInput$parentNode;
{
var hook = void 0;
if (style) {
hook = function hook(context) {
style.call(this, createInjector(context));
// ie9 fix #219
var oldInput = document.getElementById(_this13.forId);
var newInput = oldInput.cloneNode(true);
newInput.value = '';
newInput.type = 'file'; // @ts-ignore
newInput.onChange = inputOnChange;
(_oldInput$parentNode = oldInput.parentNode) === null || _oldInput$parentNode === void 0 ? void 0 : _oldInput$parentNode.replaceChild(newInput, oldInput);
_this13.$refs.input = newInput;
}
return res;
};
}
if (hook !== undefined) {
if (component.functional) {
// register for functional component in vue file
var originalRender = component.render;
component.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
} else {
// inject component registration as beforeCreate hook
var existing = component.beforeCreate;
component.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return this.addInputFile(e.target).then(reinput).catch(reinput);
})
}
});
return component;
function render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createBlock("span", {
class: _ctx.className
}, [vue.renderSlot(_ctx.$slots, "default"), vue.createVNode("label", {
for: _ctx.forId
}, null, 8, ["for"]), vue.createVNode("input", {
ref: "input",
type: "file",
name: _ctx.name,
id: _ctx.forId,
accept: _ctx.accept,
capture: _ctx.capture,
disabled: _ctx.disabled,
webkitdirectory: _ctx.directory && _ctx.features.directory,
allowdirs: _ctx.directory && _ctx.features.directory,
directory: _ctx.directory && _ctx.features.directory,
multiple: _ctx.multiple && _ctx.features.html5,
onChange: _cache[1] || (_cache[1] = function () {
return _ctx.inputOnChange && _ctx.inputOnChange.apply(_ctx, arguments);
})
}, null, 40, ["name", "id", "accept", "capture", "disabled", "webkitdirectory", "allowdirs", "directory", "multiple"])], 2);
}
/* style inject */
function __vue_create_injector__$1() {
var head = document.head || document.getElementsByTagName('head')[0];
var styles = __vue_create_injector__$1.styles || (__vue_create_injector__$1.styles = {});
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
return function addStyle(id, css) {
if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present.
function styleInject(css, ref) {
if (ref === void 0) ref = {};
var insertAt = ref.insertAt;
var group = isOldIE ? css.media || 'default' : id;
var style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined });
if (!css || typeof document === 'undefined') {
return;
}
if (!style.ids.includes(id)) {
var code = css.source;
var index = style.ids.length;
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.ids.push(id);
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
}
if (isOldIE) {
style.element = style.element || document.querySelector('style[data-group=' + group + ']');
}
if (!style.element) {
var el = style.element = document.createElement('style');
el.type = 'text/css';
if (css.media) el.setAttribute('media', css.media);
if (isOldIE) {
el.setAttribute('data-group', group);
el.setAttribute('data-next-index', '0');
}
head.appendChild(el);
}
if (isOldIE) {
index = parseInt(style.element.getAttribute('data-next-index'));
style.element.setAttribute('data-next-index', index + 1);
}
if (style.element.styleSheet) {
style.parts.push(code);
style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n');
} else {
var textNode = document.createTextNode(code);
var nodes = style.element.childNodes;
if (nodes[index]) style.element.removeChild(nodes[index]);
if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
}
}
};
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
/* style inject SSR */
var FileUpload = __vue_normalize__$1({ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, __vue_create_injector__$1, undefined);
var css_248z = "\n.file-uploads {\n overflow: hidden;\n position: relative;\n text-align: center;\n display: inline-block;\n}\n.file-uploads.file-uploads-html4 input, .file-uploads.file-uploads-html5 label {\n /* background fix ie click */\n background: #fff;\n opacity: 0;\n font-size: 20em;\n z-index: 1;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n.file-uploads.file-uploads-html5 input, .file-uploads.file-uploads-html4 label {\n /* background fix ie click */\n background: rgba(255, 255, 255, 0);\n overflow: hidden;\n position: fixed;\n width: 1px;\n height: 1px;\n z-index: -1;\n opacity: 0;\n}\n";
styleInject(css_248z);
script.render = render;
var FileUpload$1 = /*#__PURE__*/Object.freeze({
default: FileUpload
});
return script;
var require$$0 = ( FileUpload$1 && FileUpload ) || FileUpload$1;
var src = require$$0;
return src;
})));
//# sourceMappingURL=vue-upload-component.js.map
/*!
* Name: vue-upload-component
* Version: 2.8.20
* Author: LianYue
Name: vue-upload-component
Component URI: https://github.com/lian-yue/vue-upload-component#readme
Version: 3.0.35
Author: LianYue
License: Apache-2.0
Description: Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueUploadComponent=t()}(this,function(){"use strict";var r=function(t){var i=new XMLHttpRequest;return i.open(t.method||"GET",t.url),i.responseType="json",t.headers&&Object.keys(t.headers).forEach(function(e){i.setRequestHeader(e,t.headers[e])}),i};function e(e){var n,t,i=r(e);return n=i,t=e.body,new Promise(function(e,i){n.onload=function(){if(200<=n.status&&n.status<300){var t;try{t=JSON.parse(n.response)}catch(e){t=n.response}e(t)}else i(n.response)},n.onerror=function(){return i(n.response)},n.send(JSON.stringify(t))})}var t=function(){function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}}();var i=function(){function i(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),this.file=e,this.options=t}return t(i,[{key:"createChunks",value:function(){this.chunks=[];for(var e=0,t=this.chunkSize;e<this.fileSize;)this.chunks.push({blob:this.file.file.slice(e,t),startOffset:e,active:!1,retries:this.maxRetries}),t=(e=t)+this.chunkSize}},{key:"updateFileProgress",value:function(){this.file.progress=this.progress}},{key:"pause",value:function(){this.file.active=!1,this.stopChunks()}},{key:"stopChunks",value:function(){this.chunksUploading.forEach(function(e){e.xhr.abort(),e.active=!1})}},{key:"resume",value:function(){this.file.active=!0,this.startChunking()}},{key:"upload",value:function(){var i=this;return this.promise=new Promise(function(e,t){i.resolve=e,i.reject=t}),this.start(),this.promise}},{key:"start",value:function(){var t=this;e({method:"POST",headers:Object.assign({},this.headers,{"Content-Type":"application/json"}),url:this.action,body:Object.assign(this.startBody,{phase:"start",mime_type:this.fileType,size:this.fileSize,name:this.fileName})}).then(function(e){if("success"!==e.status)return t.file.response=e,t.reject("server");t.sessionId=e.data.session_id,t.chunkSize=e.data.end_offset,t.createChunks(),t.startChunking()}).catch(function(e){t.file.response=e,t.reject("server")})}},{key:"startChunking",value:function(){for(var e=0;e<this.maxActiveChunks;e++)this.uploadNextChunk()}},{key:"uploadNextChunk",value:function(){if(this.file.active){if(this.hasChunksToUpload)return this.uploadChunk(this.chunksToUpload[0]);if(0===this.chunksUploading.length)return this.finish()}}},{key:"uploadChunk",value:function(t){var i=this;t.progress=0,t.active=!0,this.updateFileProgress(),t.xhr=r({method:"POST",headers:this.headers,url:this.action}),t.xhr.upload.addEventListener("progress",function(e){e.lengthComputable&&(t.progress=Math.round(e.loaded/e.total*100))},!1),function(n,e){var t=new FormData;for(var i in e)t.append(i,e[i]);return new Promise(function(e,i){n.onload=function(){if(200<=n.status&&n.status<300){var t;try{t=JSON.parse(n.response)}catch(e){t=n.response}e(t)}else i(n.response)},n.onerror=function(){return i(n.response)},n.send(t)})}(t.xhr,Object.assign(this.uploadBody,{phase:"upload",session_id:this.sessionId,start_offset:t.startOffset,chunk:t.blob})).then(function(e){if(t.active=!1,"success"===e.status)t.uploaded=!0;else if(t.retries--<=0)return i.stopChunks(),i.reject("upload");i.uploadNextChunk()}).catch(function(){if(t.active=!1,t.retries--<=0)return i.stopChunks(),i.reject("upload");i.uploadNextChunk()})}},{key:"finish",value:function(){var t=this;this.updateFileProgress(),e({method:"POST",headers:Object.assign({},this.headers,{"Content-Type":"application/json"}),url:this.action,body:Object.assign(this.finishBody,{phase:"finish",session_id:this.sessionId})}).then(function(e){if("success"!==(t.file.response=e).status)return t.reject("server");t.resolve(e)}).catch(function(e){t.file.response=e,t.reject("server")})}},{key:"maxRetries",get:function(){return parseInt(this.options.maxRetries)}},{key:"maxActiveChunks",get:function(){return parseInt(this.options.maxActive)}},{key:"fileType",get:function(){return this.file.type}},{key:"fileSize",get:function(){return this.file.size}},{key:"fileName",get:function(){return this.file.name}},{key:"action",get:function(){return this.options.action||null}},{key:"startBody",get:function(){return this.options.startBody||{}}},{key:"uploadBody",get:function(){return this.options.uploadBody||{}}},{key:"finishBody",get:function(){return this.options.finishBody||{}}},{key:"headers",get:function(){return this.options.headers||{}}},{key:"readyToUpload",get:function(){return!!this.chunks}},{key:"progress",get:function(){var i=this,e=this.chunksUploaded.length/this.chunks.length*100,t=this.chunksUploading.reduce(function(e,t){return e+(0|t.progress)/i.chunks.length},0);return Math.min(e+t,100)}},{key:"chunksToUpload",get:function(){return this.chunks.filter(function(e){return!e.active&&!e.uploaded})}},{key:"hasChunksToUpload",get:function(){return 0<this.chunksToUpload.length}},{key:"chunksUploading",get:function(){return this.chunks.filter(function(e){return!!e.xhr&&!!e.active})}},{key:"chunksUploaded",get:function(){return this.chunks.filter(function(e){return!!e.uploaded})}}]),i}();var n,s,o,a,u,c=(o=void 0,a=!(n={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("input",{attrs:{type:"file",name:e.$parent.name,id:e.$parent.inputId||e.$parent.name,accept:e.$parent.accept,capture:e.$parent.capture,disabled:e.$parent.disabled,webkitdirectory:e.$parent.directory&&e.$parent.features.directory,directory:e.$parent.directory&&e.$parent.features.directory,multiple:e.$parent.multiple&&e.$parent.features.html5},on:{change:e.change}})},staticRenderFns:[]}),(u=("function"==typeof(s={methods:{change:function(e){this.$parent.addInputFile(e.target),e.target.files?(e.target.value="",e.target.files.length&&!/safari/i.test(navigator.userAgent)&&(e.target.type="",e.target.type="file")):(this.$destroy(),new this.constructor({parent:this.$parent,el:this.$el}))}}})?s.options:s)||{}).render||(u.render=n.render,u.staticRenderFns=n.staticRenderFns,u._compiled=!0,a&&(u.functional=!0)),u._scopeId=o,u),h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function l(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}var f={headers:{},action:"",minSize:1048576,maxActive:3,maxRetries:5,handler:i};var p=function(e,t,i,n,r,s,o,a){var u=("function"==typeof i?i.options:i)||{};u.render||(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=n;var c=void 0;if(t&&(c=function(e){t.call(this,o(e))}),void 0!==c)if(u.functional){var l=u.render;u.render=function(e,t){return c.call(t),l(e,t)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,c):[c]}return u}({render:function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("span",{class:e.className},[e._t("default"),e._v(" "),i("label",{attrs:{for:e.inputId||e.name}}),e._v(" "),i("input-file")],2)},staticRenderFns:[]},function(e){e&&e("data-v-595958af_0",{source:"\n.file-uploads{overflow:hidden;position:relative;text-align:center;display:inline-block\n}\n.file-uploads.file-uploads-html4 input,.file-uploads.file-uploads-html5 label{background:#fff;opacity:0;font-size:20em;z-index:1;top:0;left:0;right:0;bottom:0;position:absolute;width:100%;height:100%\n}\n.file-uploads.file-uploads-html4 label,.file-uploads.file-uploads-html5 input{background:rgba(255,255,255,0);overflow:hidden;position:fixed;width:1px;height:1px;z-index:-1;opacity:0\n}",map:void 0,media:void 0})},{components:{InputFile:c},props:{inputId:{type:String},name:{type:String,default:"file"},accept:{type:String},capture:{},disabled:{},multiple:{type:Boolean},maximum:{type:Number,default:function(){return this.multiple?0:1}},addIndex:{type:[Boolean,Number]},directory:{type:Boolean},postAction:{type:String},putAction:{type:String},customAction:{type:Function},headers:{type:Object,default:Object},data:{type:Object,default:Object},timeout:{type:Number,default:0},drop:{default:!1},dropDirectory:{type:Boolean,default:!0},size:{type:Number,default:0},extensions:{default:Array},value:{type:Array,default:Array},thread:{type:Number,default:1},chunkEnabled:{type:Boolean,default:!1},chunk:{type:Object,default:function(){return f}}},data:function(){return{files:this.value,features:{html5:!0,directory:!1,drag:!1},active:!1,dropActive:!1,uploading:0,destroy:!1}},mounted:function(){var e=document.createElement("input");if(e.type="file",e.multiple=!0,window.FormData&&e.files?("boolean"!=typeof e.webkitdirectory&&"boolean"!=typeof e.directory||(this.features.directory=!0),this.features.html5&&void 0!==e.ondrop&&(this.features.drop=!0)):this.features.html5=!1,this.maps={},this.files)for(var t=0;t<this.files.length;t++){var i=this.files[t];this.maps[i.id]=i}this.$nextTick(function(){this.$parent&&this.$parent.$forceUpdate(),this.watchDrop(this.drop)})},beforeDestroy:function(){this.destroy=!0,this.active=!1},computed:{uploaded:function(){for(var e=void 0,t=0;t<this.files.length;t++)if((e=this.files[t]).fileObject&&!e.error&&!e.success)return!1;return!0},chunkOptions:function(){return Object.assign(f,this.chunk)},className:function(){return["file-uploads",this.features.html5?"file-uploads-html5":"file-uploads-html4",this.features.directory&&this.directory?"file-uploads-directory":void 0,this.features.drop&&this.drop?"file-uploads-drop":void 0,this.disabled?"file-uploads-disabled":void 0]}},watch:{active:function(e){this.watchActive(e)},dropActive:function(){this.$parent&&this.$parent.$forceUpdate()},drop:function(e){this.watchDrop(e)},value:function(e){if(this.files!==e){this.files=e;var t=this.maps;this.maps={};for(var i=0;i<this.files.length;i++){var n=this.files[i];this.maps[n.id]=n}for(var r in this.maps){var s=this.maps[r],o=t[r];s!==o&&this.emitFile(s,o)}for(var a in t)this.maps[a]||this.emitFile(void 0,t[a])}}},methods:{clear:function(){if(this.files.length){var e=this.files;this.files=[],this.maps={},this.emitInput();for(var t=0;t<e.length;t++)this.emitFile(void 0,e[t])}return!0},get:function(e){return!!e&&("object"===(void 0===e?"undefined":d(e))?this.maps[e.id]||!1:this.maps[e]||!1)},add:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.addIndex,i=e,n=i instanceof Array;n||(i=[i]);for(var r=[],s=0;s<i.length;s++){var o=i[s];this.features.html5&&o instanceof Blob&&(o={file:o,size:o.size,name:o.webkitRelativePath||o.relativePath||o.name||"unknown",type:o.type});var a=!1;if(!1===o.fileObject||(o.fileObject?a=!0:"undefined"!=typeof Element&&o.el instanceof Element?a=!0:"undefined"!=typeof Blob&&o.file instanceof Blob&&(a=!0)),a&&((o=h({fileObject:!0,size:-1,name:"Filename",type:"",active:!1,error:"",success:!1,putAction:this.putAction,postAction:this.postAction,timeout:this.timeout},o,{response:{},progress:"0.00",speed:0})).data=h({},this.data,o.data?o.data:{}),o.headers=h({},this.headers,o.headers?o.headers:{})),o.id||(o.id=Math.random().toString(36).substr(2)),!this.emitFilter(o,void 0)){if(1<this.maximum&&r.length+this.files.length>=this.maximum)break;if(r.push(o),1===this.maximum)break}}if(!r.length)return!1;1===this.maximum&&this.clear();var u=void 0;if(!0===t||0===t)u=r.concat(this.files);else if(t){var c;(c=u=this.files.concat([])).splice.apply(c,[t,0].concat(r))}else u=this.files.concat(r);this.files=u;for(var l=0;l<r.length;l++){var d=r[l];this.maps[d.id]=d}this.emitInput();for(var f=0;f<r.length;f++)this.emitFile(r[f],void 0);return n?r:r[0]},addInputFile:function(e){var t=[];if(e.files)for(var i=0;i<e.files.length;i++){var n=e.files[i];t.push({size:n.size,name:n.webkitRelativePath||n.relativePath||n.name,type:n.type,file:n})}else{var r=e.value.replace(/\\/g,"/").split("/");delete e.__vuex__,t.push({name:r[r.length-1],el:e})}return this.add(t)},addDataTransfer:function(e){var r=this,s=[];if(e.items&&e.items.length){for(var o=[],t=0;t<e.items.length;t++){var i=e.items[t];(i=i.getAsEntry?i.getAsEntry()||i.getAsFile():i.webkitGetAsEntry&&i.webkitGetAsEntry()||i.getAsFile())&&o.push(i)}return new Promise(function(n,e){!function t(i){var e=o[i];if(!e||0<r.maximum&&s.length>=r.maximum)return n(r.add(s));r.getEntry(e).then(function(e){s.push.apply(s,l(e)),t(i+1)})}(0)})}if(e.files.length){for(var n=0;n<e.files.length&&(s.push(e.files[n]),!(0<this.maximum&&s.length>=this.maximum));n++);return Promise.resolve(this.add(s))}return Promise.resolve([])},getEntry:function(o){var a=this,u=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return new Promise(function(r,e){if(o.isFile)o.file(function(e){r([{size:e.size,name:u+e.name,type:e.type,file:e}])});else if(o.isDirectory&&a.dropDirectory){var s=[],t=o.createReader();!function n(){t.readEntries(function(e){!function t(i){return!e[i]&&0===i||0<a.maximum&&s.length>=a.maximum?r(s):e[i]?void a.getEntry(e[i],u+o.name+"/").then(function(e){s.push.apply(s,l(e)),t(i+1)}):n()}(0)})}()}else r([])})},replace:function(e,t){var i=this.get(e),n=this.get(t);if(!i||!n||i===n)return!1;var r=this.files.concat([]),s=r.indexOf(i),o=r.indexOf(n);return-1!==s&&-1!==o&&(r[s]=n,r[o]=i,this.files=r,this.emitInput(),!0)},remove:function(e){var t=this.get(e);if(t){if(this.emitFilter(void 0,t))return!1;var i=this.files.concat([]),n=i.indexOf(t);if(-1===n)return console.error("remove",t),!1;i.splice(n,1),this.files=i,delete this.maps[t.id],this.emitInput(),this.emitFile(void 0,t)}return t},update:function(e,t){var i=this.get(e);if(i){var n=h({},i,t);if(!i.fileObject||!i.active||n.active||n.error||n.success||(n.error="abort"),this.emitFilter(n,i))return!1;var r=this.files.concat([]),s=r.indexOf(i);return-1===s?(console.error("update",i),!1):(r.splice(s,1,n),this.files=r,delete this.maps[i.id],this.maps[n.id]=n,this.emitInput(),this.emitFile(n,i),n)}return!1},emitFilter:function(e,t){var i=!1;return this.$emit("input-filter",e,t,function(){return i=!0}),i},emitFile:function(i,e){this.$emit("input-file",i,e),!(i&&i.fileObject&&i.active)||e&&e.active?i&&i.fileObject&&i.active||!e||!e.fileObject||!e.active||this.uploading--:(this.uploading++,this.$nextTick(function(){var t=this;setTimeout(function(){t.upload(i).then(function(){(i=t.get(i))&&i.fileObject&&t.update(i,{active:!1,success:!i.error})}).catch(function(e){t.update(i,{active:!1,success:!1,error:e.code||e.error||e.message||e})})},parseInt(50*Math.random()+50,10))})),!this.active||Boolean(i)===Boolean(e)&&i.active===e.active||this.watchActive(!0)},emitInput:function(){this.$emit("input",this.files)},upload:function(e){var t=this.get(e);if(!t)return Promise.reject("not_exists");if(!t.fileObject)return Promise.reject("file_object");if(t.error)return Promise.reject(t.error);if(t.success)return Promise.resolve(t);var i=this.extensions;if(i&&(i.length||void 0===i.length)&&("object"===(void 0===i?"undefined":d(i))&&i instanceof RegExp||("string"==typeof i&&(i=i.split(",").map(function(e){return e.trim()}).filter(function(e){return e})),i=new RegExp("\\.("+i.join("|").replace(/\./g,"\\.")+")$","i")),-1===t.name.search(i)))return Promise.reject("extension");if(0<this.size&&0<=t.size&&t.size>this.size)return Promise.reject("size");if(this.customAction)return this.customAction(t,this);if(this.features.html5){if(this.shouldUseChunkUpload(t))return this.uploadChunk(t);if(t.putAction)return this.uploadPut(t);if(t.postAction)return this.uploadHtml5(t)}return t.postAction?this.uploadHtml4(t):Promise.reject("No action configured")},shouldUseChunkUpload:function(e){return this.chunkEnabled&&!!this.chunkOptions.handler&&e.size>this.chunkOptions.minSize},uploadChunk:function(e){var t=this.chunkOptions.handler;return e.chunk=new t(e,this.chunkOptions),e.chunk.upload()},uploadPut:function(e){var t=[],i=void 0;for(var n in e.data)null!=(i=e.data[n])&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(i));var r=t.length?(-1===e.putAction.indexOf("?")?"?":"&")+t.join("&"):"",s=new XMLHttpRequest;return s.open("PUT",e.putAction+r),this.uploadXhr(s,e,e.file)},uploadHtml5:function(e){var t=new window.FormData,i=void 0;for(var n in e.data)(i=e.data[n])&&"object"===(void 0===i?"undefined":d(i))&&"function"!=typeof i.toString?i instanceof File?t.append(n,i,i.name):t.append(n,JSON.stringify(i)):null!=i&&t.append(n,i);t.append(this.name,e.file,e.file.filename||e.name);var r=new XMLHttpRequest;return r.open("POST",e.postAction),this.uploadXhr(r,e,t)},uploadXhr:function(o,e,i){var a=this,u=e,n=0,r=0;o.upload.onprogress=function(e){if(u=a.get(u),e.lengthComputable&&u&&u.fileObject&&u.active){var t=Math.round(Date.now()/1e3);t!==n&&(n=t,u=a.update(u,{progress:(e.loaded/e.total*100).toFixed(2),speed:e.loaded-r}),r=e.loaded)}};var c=setInterval(function(){if(!(u=a.get(u))||!u.fileObject||u.success||u.error||!u.active){c&&(clearInterval(c),c=!1);try{o.abort(),o.timeout=1}catch(e){}}},100);return new Promise(function(n,r){var s=void 0,e=function(e){if(!s){if(s=!0,c&&(clearInterval(c),c=!1),!(u=a.get(u)))return r("not_exists");if(!u.fileObject)return r("file_object");if(u.error)return r(u.error);if(!u.active)return r("abort");if(u.success)return n(u);var t={};switch(e.type){case"timeout":case"abort":t.error=e.type;break;case"error":o.status?500<=o.status?t.error="server":400<=o.status&&(t.error="denied"):t.error="network";break;default:500<=o.status?t.error="server":400<=o.status?t.error="denied":t.progress="100.00"}if(o.responseText){var i=o.getResponseHeader("Content-Type");i&&-1!==i.indexOf("/json")?t.response=JSON.parse(o.responseText):t.response=o.responseText}return(u=a.update(u,t)).error?r(u.error):n(u)}};for(var t in o.onload=e,o.onerror=e,o.onabort=e,o.ontimeout=e,u.timeout&&(o.timeout=u.timeout),u.headers)o.setRequestHeader(t,u.headers[t]);u=a.update(u,{xhr:o}),o.send(i)})},uploadHtml4:function(e){var a=this,u=e,c=function(e){27===e.keyCode&&e.preventDefault()},l=document.createElement("iframe");l.id="upload-iframe-"+u.id,l.name="upload-iframe-"+u.id,l.src="about:blank",l.setAttribute("style","width:1px;height:1px;top:-999em;position:absolute; margin-top:-999em;");var t=document.createElement("form");t.action=u.postAction,t.name="upload-form-"+u.id,t.setAttribute("method","POST"),t.setAttribute("target","upload-iframe-"+u.id),t.setAttribute("enctype","multipart/form-data");var i=void 0,n=void 0;for(var r in u.data)(i=u.data[r])&&"object"===(void 0===i?"undefined":d(i))&&"function"!=typeof i.toString&&(i=JSON.stringify(i)),null!=i&&((n=document.createElement("input")).type="hidden",n.name=r,n.value=i,t.appendChild(n));t.appendChild(u.el),document.body.appendChild(l).appendChild(t);return new Promise(function(s,o){setTimeout(function(){if(!(u=a.update(u,{iframe:l})))return o("not_exists");var n=setInterval(function(){(u=a.get(u))&&u.fileObject&&!u.success&&!u.error&&u.active||(n&&(clearInterval(n),n=!1),l.onabort({type:u?"abort":"not_exists"}))},100),r=void 0,e=function(e){if(!r){if(r=!0,n&&(clearInterval(n),n=!1),document.body.removeEventListener("keydown",c),!(u=a.get(u)))return o("not_exists");if(!u.fileObject)return o("file_object");if(u.error)return o(u.error);if(!u.active)return o("abort");if(u.success)return s(u);var t=function(){var t=void 0;try{l.contentWindow&&(t=l.contentWindow.document)}catch(e){}if(!t)try{t=l.contentDocument?l.contentDocument:l.document}catch(e){t=l.document}return t&&t.body?t.body.innerHTML:null}(),i={};switch(e.type){case"abort":i.error="abort";break;case"error":u.error?i.error=u.error:i.error=null===t?"network":"denied";break;default:u.error?i.error=u.error:null===i?i.error="network":i.progress="100.00"}if(null!==t){if(t&&"{"===t.substr(0,1)&&"}"===t.substr(t.length-1,1))try{t=JSON.parse(t)}catch(e){}i.response=t}return(u=a.update(u,i)).error?o(u.error):s(u)}};l.onload=e,l.onerror=e,l.onabort=e,document.body.addEventListener("keydown",c),t.submit()},50)}).then(function(e){return l.parentNode&&l.parentNode.removeChild(l),e}).catch(function(e){return l.parentNode&&l.parentNode.removeChild(l),e})},watchActive:function(e){for(var t=void 0,i=0;t=this.files[i];)if(i++,t.fileObject)if(e&&!this.destroy){if(this.uploading>=this.thread||this.uploading&&!this.features.html5)break;t.active||t.error||t.success||this.update(t,{active:!0})}else t.active&&this.update(t,{active:!1});else;0===this.uploading&&(this.active=!1)},watchDrop:function(e){var t=e;if(this.features.drop){if(this.dropElement)try{document.removeEventListener("dragenter",this.onDragenter,!1),document.removeEventListener("dragleave",this.onDragleave,!1),document.removeEventListener("drop",this.onDocumentDrop,!1),this.dropElement.removeEventListener("dragover",this.onDragover,!1),this.dropElement.removeEventListener("drop",this.onDrop,!1)}catch(e){}t?"string"==typeof t?t=document.querySelector(t)||this.$root.$el.querySelector(t):!0===t&&(t=this.$parent.$el):t=!1,this.dropElement=t,this.dropElement&&(document.addEventListener("dragenter",this.onDragenter,!1),document.addEventListener("dragleave",this.onDragleave,!1),document.addEventListener("drop",this.onDocumentDrop,!1),this.dropElement.addEventListener("dragover",this.onDragover,!1),this.dropElement.addEventListener("drop",this.onDrop,!1))}},onDragenter:function(e){if(e.preventDefault(),!this.dropActive&&e.dataTransfer){var t=e.dataTransfer;t.files&&t.files.length?this.dropActive=!0:t.types?t.types.indexOf&&-1!==t.types.indexOf("Files")?this.dropActive=!0:t.types.contains&&t.types.contains("Files")&&(this.dropActive=!0):this.dropActive=!0}},onDragleave:function(e){e.preventDefault(),this.dropActive&&("HTML"===e.target.nodeName||e.target===e.explicitOriginalTarget||!e.fromElement&&(e.clientX<=0||e.clientY<=0||e.clientX>=window.innerWidth||e.clientY>=window.innerHeight))&&(this.dropActive=!1)},onDragover:function(e){e.preventDefault()},onDocumentDrop:function(){this.dropActive=!1},onDrop:function(e){e.preventDefault(),this.addDataTransfer(e.dataTransfer)}}},void 0,!1,0,function e(){var c=document.head||document.getElementsByTagName("head")[0],l=e.styles||(e.styles={}),d="undefined"!=typeof navigator&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(e,t){if(!document.querySelector('style[data-vue-ssr-id~="'+e+'"]')){var i=d?t.media||"default":e,n=l[i]||(l[i]={ids:[],parts:[],element:void 0});if(!n.ids.includes(e)){var r=t.source,s=n.ids.length;if(n.ids.push(e),t.map&&(r+="\n/*# sourceURL="+t.map.sources[0]+" */",r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t.map))))+" */"),d&&(n.element=n.element||document.querySelector("style[data-group="+i+"]")),!n.element){var o=n.element=document.createElement("style");o.type="text/css",t.media&&o.setAttribute("media",t.media),d&&(o.setAttribute("data-group",i),o.setAttribute("data-next-index","0")),c.appendChild(o)}if(d&&(s=parseInt(n.element.getAttribute("data-next-index")),n.element.setAttribute("data-next-index",s+1)),n.element.styleSheet)n.parts.push(r),n.element.styleSheet.cssText=n.parts.filter(Boolean).join("\n");else{var a=document.createTextNode(r),u=n.element.childNodes;u[s]&&n.element.removeChild(u[s]),u.length?n.element.insertBefore(a,u[s]):n.element.appendChild(a)}}}}}),m=Object.freeze({default:p});return m&&p||m});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueUploadComponent=t(e.Vue)}(this,function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r,h=t(e);return function(e){function c(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function f(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,r;t=n,e=i[r=e],r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function s(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach(function(e){var t,r;t=n,e=i[r=e],r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}function a(e){var n,t,r=l(e);return n=r,t=e.body,new Promise(function(e,r){n.onload=function(){if(200<=n.status&&n.status<300){var t;try{t=JSON.parse(n.response)}catch(e){t=n.response}e(t)}else r(n.response)},n.onerror=function(){return r(n.response)},n.send(JSON.stringify(t))})}var u,l,d;e.exports=(u=h.default,l=function(t){var r=new XMLHttpRequest;return r.open(t.method||"GET",t.url),r.responseType="json",t.headers&&Object.keys(t.headers).forEach(function(e){r.setRequestHeader(e,t.headers[e])}),r},d={headers:{},action:"",minSize:1048576,maxActive:3,maxRetries:5,handler:function(){function r(e,t){!function(e){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this),this.file=e,this.options=t,this.chunks=[],this.sessionId=null,this.chunkSize=null}var e,t,n;return e=r,(t=[{key:"createChunks",value:function(){this.chunks=[];for(var e=0,t=this.chunkSize;e<this.fileSize;)this.chunks.push({blob:this.file.file.slice(e,t),startOffset:e,active:!1,retries:this.maxRetries}),t=(e=t)+this.chunkSize}},{key:"updateFileProgress",value:function(){this.file.progress=this.progress}},{key:"pause",value:function(){this.file.active=!1,this.stopChunks()}},{key:"stopChunks",value:function(){this.chunksUploading.forEach(function(e){e.xhr.abort(),e.active=!1})}},{key:"resume",value:function(){this.file.active=!0,this.startChunking()}},{key:"upload",value:function(){var r=this;return this.promise=new Promise(function(e,t){r.resolve=e,r.reject=t}),this.start(),this.promise}},{key:"start",value:function(){var t=this;a({method:"POST",headers:s(s({},this.headers),{},{"Content-Type":"application/json"}),url:this.action,body:s(s({},this.startBody),{},{phase:"start",mime_type:this.fileType,size:this.fileSize,name:this.fileName})}).then(function(e){return"success"!==e.status?(t.file.response=e,t.reject("server")):(t.sessionId=e.data.session_id,t.chunkSize=e.data.end_offset,t.createChunks(),void t.startChunking())}).catch(function(e){t.file.response=e,t.reject("server")})}},{key:"startChunking",value:function(){for(var e=0;e<this.maxActiveChunks;e++)this.uploadNextChunk()}},{key:"uploadNextChunk",value:function(){if(this.file.active)return this.hasChunksToUpload?this.uploadChunk(this.chunksToUpload[0]):0===this.chunksUploading.length?this.finish():void 0}},{key:"uploadChunk",value:function(t){var r=this;t.progress=0,t.active=!0,this.updateFileProgress(),t.xhr=l({method:"POST",headers:this.headers,url:this.action}),t.xhr.upload.addEventListener("progress",function(e){e.lengthComputable&&(t.progress=Math.round(e.loaded/e.total*100))},!1),function(n,e){var t,i=new FormData;for(t in e)i.append(t,e[t]);return new Promise(function(e,r){n.onload=function(){if(200<=n.status&&n.status<300){var t;try{t=JSON.parse(n.response)}catch(e){t=n.response}e(t)}else r(n.response)},n.onerror=function(){return r(n.response)},n.send(i)})}(t.xhr,s(s({},this.uploadBody),{},{phase:"upload",session_id:this.sessionId,start_offset:t.startOffset,chunk:t.blob})).then(function(e){if(t.active=!1,"success"===e.status)t.uploaded=!0;else if(t.retries--<=0)return r.stopChunks(),r.reject("upload");r.uploadNextChunk()}).catch(function(){return t.active=!1,t.retries--<=0?(r.stopChunks(),r.reject("upload")):void r.uploadNextChunk()})}},{key:"finish",value:function(){var t=this;this.updateFileProgress(),a({method:"POST",headers:s(s({},this.headers),{},{"Content-Type":"application/json"}),url:this.action,body:s(s({},this.finishBody),{},{phase:"finish",session_id:this.sessionId})}).then(function(e){return"success"!==(t.file.response=e).status?t.reject("server"):void t.resolve(e)}).catch(function(e){t.file.response=e,t.reject("server")})}},{key:"maxRetries",get:function(){return parseInt(this.options.maxRetries,10)}},{key:"maxActiveChunks",get:function(){return parseInt(this.options.maxActive,10)}},{key:"fileType",get:function(){return this.file.type}},{key:"fileSize",get:function(){return this.file.size}},{key:"fileName",get:function(){return this.file.name}},{key:"action",get:function(){return this.options.action||null}},{key:"startBody",get:function(){return this.options.startBody||{}}},{key:"uploadBody",get:function(){return this.options.uploadBody||{}}},{key:"finishBody",get:function(){return this.options.finishBody||{}}},{key:"headers",get:function(){return this.options.headers||{}}},{key:"readyToUpload",get:function(){return!!this.chunks}},{key:"progress",get:function(){var r=this,e=this.chunksUploaded.length/this.chunks.length*100,t=this.chunksUploading.reduce(function(e,t){return e+(0|t.progress)/r.chunks.length},0);return Math.min(e+t,100)}},{key:"chunksToUpload",get:function(){return console.log(this.chunks),this.chunks.filter(function(e){return!e.active&&!e.uploaded})}},{key:"hasChunksToUpload",get:function(){return 0<this.chunksToUpload.length}},{key:"chunksUploading",get:function(){return this.chunks.filter(function(e){return!!e.xhr&&!!e.active})}},{key:"chunksUploaded",get:function(){return this.chunks.filter(function(e){return!!e.uploaded})}}])&&i(e.prototype,t),n&&i(e,n),r}()},e=u.defineComponent({props:{inputId:{type:String},name:{type:String,default:"file"},accept:{type:String},capture:{},disabled:{default:!1},multiple:{type:Boolean,default:!1},maximum:{type:Number},addIndex:{type:[Boolean,Number]},directory:{type:Boolean},createDirectory:{type:Boolean,default:!1},postAction:{type:String},putAction:{type:String},customAction:{type:Function},headers:{type:Object,default:function(){return{}}},data:{type:Object,default:function(){return{}}},timeout:{type:Number,default:0},drop:{default:!1},dropDirectory:{type:Boolean,default:!0},size:{type:Number,default:0},extensions:{type:[RegExp,String,Array],default:function(){return[]}},modelValue:{type:Array,default:function(){return[]}},thread:{type:Number,default:1},chunkEnabled:{type:Boolean,default:!1},chunk:{type:Object,default:function(){return d}}},emits:["update:modelValue","input-filter","input-file"],data:function(){return{files:this.modelValue,features:{html5:!0,directory:!1,drop:!1},active:!1,dropActive:!1,uploading:0,destroy:!1,maps:{},dropElement:null}},mounted:function(){var e=this,t=document.createElement("input");if(t.type="file",t.multiple=!0,window.FormData&&t.files?("boolean"!=typeof t.webkitdirectory&&"boolean"!=typeof t.directory||(this.features.directory=!0),this.features.html5&&void 0!==t.ondrop&&(this.features.drop=!0)):this.features.html5=!1,this.maps={},this.files)for(var r=0;r<this.files.length;r++){var n=this.files[r];this.maps[n.id]=n}this.$nextTick(function(){e.$parent?(e.$parent.$forceUpdate(),e.$parent.$nextTick(function(){e.watchDrop(e.drop)})):e.watchDrop(e.drop)})},beforeUnmount:function(){this.destroy=!0,this.active=!1,this.watchDrop(!1)},computed:{uploaded:function(){for(var e,t=0;t<this.files.length;t++)if((e=this.files[t]).fileObject&&!e.error&&!e.success)return!1;return!0},chunkOptions:function(){return Object.assign(d,this.chunk)},className:function(){return["file-uploads",this.features.html5?"file-uploads-html5":"file-uploads-html4",this.features.directory&&this.directory?"file-uploads-directory":void 0,this.features.drop&&this.drop?"file-uploads-drop":void 0,this.disabled?"file-uploads-disabled":void 0]},forId:function(){return this.inputId||this.name},iMaximum:function(){return void 0===this.maximum?this.multiple?0:1:this.maximum},iExtensions:function(){if(this.extensions){if(this.extensions instanceof RegExp)return this.extensions;var e=[];return e=(e="string"==typeof this.extensions?this.extensions.split(","):this.extensions).map(function(e){return e.trim()}).filter(function(e){return e}),new RegExp("\\.("+e.join("|").replace(/\./g,"\\.")+")$","i")}}},watch:{active:function(e){this.watchActive(e)},dropActive:function(){this.$parent&&this.$parent.$forceUpdate()},drop:function(e){this.watchDrop(e)},modelValue:function(e){if(this.files!==e){this.files=e;var t=this.maps;this.maps={};for(var r,n,i=0;i<this.files.length;i++){var o=this.files[i];this.maps[o.id]=o}for(r in this.maps){var s=this.maps[r],a=t[r];s!==a&&this.emitFile(s,a)}for(n in t)this.maps[n]||this.emitFile(void 0,t[n])}}},methods:{newId:function(){return Math.random().toString(36).substr(2)},clear:function(){if(this.files.length){var e=this.files;this.files=[],this.maps={},this.emitInput();for(var t=0;t<e.length;t++)this.emitFile(void 0,e[t])}return!0},get:function(e){return!!e&&("object"===o(e)?this.maps[e.id||""]||!1:this.maps[e]||!1)},add:function(e,t){var r=e instanceof Array?e:[e];void 0===t&&(t=this.addIndex);for(var n,i=[],o=0;o<r.length;o++){var s=r[o];this.features.html5&&s instanceof Blob&&(s={id:"",file:s,size:s.size,name:s.webkitRelativePath||s.relativePath||s.name||"unknown",type:s.type});var a=!1;if(!1===s.fileObject||(s.fileObject||"undefined"!=typeof Element&&s.el instanceof HTMLInputElement||"undefined"!=typeof Blob&&s.file instanceof Blob)&&(a=!0),a&&((s=f(f({fileObject:!0,size:-1,name:"Filename",type:"",active:!1,error:"",success:!1,putAction:this.putAction,postAction:this.postAction,timeout:this.timeout},s),{},{response:{},progress:"0.00",speed:0})).data=f(f({},this.data),s.data||{}),s.headers=f(f({},this.headers),s.headers||{})),s.id||(s.id=this.newId()),!this.emitFilter(s,void 0)){if(1<this.iMaximum&&i.length+this.files.length>=this.iMaximum)break;if(i.push(s),1===this.iMaximum)break}}if(i.length){1===this.iMaximum&&this.clear(),!0===t||0===t?n=i.concat(this.files):t?(n=this.files.concat([])).splice.apply(n,[t,0].concat(i)):n=this.files.concat(i),this.files=n;for(var u=0;u<i.length;u++){var l=i[u];this.maps[l.id]=l}this.emitInput();for(var c=0;c<i.length;c++)this.emitFile(i[c],void 0);return e instanceof Array?i:i[0]}},addInputFile:function(e){var t=this,r=[],n=(this.iMaximum,e.webkitEntries||e.entries||void 0);if(n&&n.length)return this.getFileSystemEntry(n).then(function(e){return t.add(e)});if(e.files)for(var i=0;i<e.files.length;i++){var o=e.files[i];r.push({id:"",size:o.size,name:o.webkitRelativePath||o.relativePath||o.name,type:o.type,file:o})}else{n=e.value.replace(/\\/g,"/").split("/");n&&n.length||(n=[e.value]),delete e.__vuex__,r.push({id:"",name:n[n.length-1],el:e})}return Promise.resolve(this.add(r))},addDataTransfer:function(e){var t,r=this;if(null!=e&&null!==(t=e.items)&&void 0!==t&&t.length){for(var n=[],i=0;i<e.items.length;i++){var o=e.items[i],s=void 0;(s=o.getAsEntry?o.getAsEntry()||o.getAsFile():o.webkitGetAsEntry&&o.webkitGetAsEntry()||o.getAsFile())&&n.push(s)}return this.getFileSystemEntry(n).then(function(e){return r.add(e)})}var a=this.iMaximum,u=[];if(e.files.length){for(var l=0;l<e.files.length&&(u.push(e.files[l]),!(0<a&&u.length>=a));l++);return Promise.resolve(this.add(u))}return Promise.resolve([])},getFileSystemEntry:function(a){var u=this,l=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return new Promise(function(i){var n,o,e,s=u.iMaximum;if(!a)return i([]);a instanceof Array?(n=[],function t(r){var e=a[r];if(!e||0<s&&n.length>=s)return i(n);u.getFileSystemEntry(e,l).then(function(e){n.push.apply(n,c(e)),t(r+1)})}(0)):a instanceof Blob?i([{id:"",size:a.size,name:l+a.name,type:a.type,file:a}]):a.isFile?a.file(function(e){i([{id:"",size:e.size,name:l+e.name,type:e.type,file:e}])}):a.isDirectory&&u.dropDirectory?(o=[],u.createDirectory&&o.push({id:"",name:l+a.name,size:0,type:"text/directory",file:new File([],l+a.name,{type:"text/directory"})}),e=a.createReader(),function n(){e.readEntries(function(e){(function t(r){return!e[r]&&0===r||0<s&&o.length>=s?i(o):e[r]?void u.getFileSystemEntry(e[r],l+a.name+"/").then(function(e){o.push.apply(o,c(e)),t(r+1)}):n()})(0)})}()):i([])})},replace:function(e,t){var r=this.get(e),n=this.get(t);if(!r||!n||r===n)return!1;var i=this.files.concat([]),e=i.indexOf(r),t=i.indexOf(n);return-1!==e&&-1!==t&&(i[e]=n,i[t]=r,this.files=i,this.emitInput(),!0)},remove:function(e){var t=this.get(e);if(t){if(this.emitFilter(void 0,t))return!1;var r=this.files.concat([]),e=r.indexOf(t);if(-1===e)return console.error("remove",t),!1;r.splice(e,1),this.files=r,delete this.maps[t.id],this.emitInput(),this.emitFile(void 0,t)}return t},update:function(e,t){var r=this.get(e);if(r){var n=f(f({},r),t);if(!r.fileObject||!r.active||n.active||n.error||n.success||(n.error="abort"),this.emitFilter(n,r))return!1;e=this.files.concat([]),t=e.indexOf(r);return-1===t?(console.error("update",r),!1):(e.splice(t,1,n),this.files=e,delete this.maps[r.id],this.maps[n.id]=n,this.emitInput(),this.emitFile(n,r),n)}return!1},emitFilter:function(e,t){var r=!1;return this.$emit("input-filter",e,t,function(){return r=!(0<arguments.length&&void 0!==arguments[0])||arguments[0]}),r},emitFile:function(t,e){var r=this;this.$emit("input-file",t,e),null==t||!t.fileObject||!t.active||e&&e.active?t&&t.fileObject&&t.active||!e||!e.fileObject||!e.active||this.uploading--:(this.uploading++,this.$nextTick(function(){setTimeout(function(){t&&r.upload(t).then(function(){null!==(t=t&&(r.get(t)||void 0))&&void 0!==t&&t.fileObject&&r.update(t,{active:!1,success:!t.error})}).catch(function(e){t&&r.update(t,{active:!1,success:!1,error:e.code||e.error||e.message||e})})},Math.ceil(50*Math.random()+50))})),!this.active||Boolean(t)===Boolean(e)&&t.active===e.active||this.watchActive(!0)},emitInput:function(){this.$emit("update:modelValue",this.files)},upload:function(e){e=this.get(e);if(!e)return Promise.reject(new Error("not_exists"));if(!e.fileObject)return Promise.reject(new Error("file_object"));if(e.error)return e.error instanceof Error?Promise.reject(e.error):Promise.reject(new Error(e.error));if(e.success)return Promise.resolve(e);this.extensions;if(e.name&&this.iExtensions&&-1===e.name.search(this.iExtensions))return Promise.reject(new Error("extension"));if(0<this.size&&void 0!==e.size&&0<=e.size&&e.size>this.size)return Promise.reject(new Error("size"));if(this.customAction)return this.customAction(e,this);if(this.features.html5){if(this.shouldUseChunkUpload(e))return this.uploadChunk(e);if(e.putAction)return this.uploadPut(e);if(e.postAction)return this.uploadHtml5(e)}return e.postAction?this.uploadHtml4(e):Promise.reject(new Error("No action configured"))},shouldUseChunkUpload:function(e){return this.chunkEnabled&&!!this.chunkOptions.handler&&e.size&&e.size>this.chunkOptions.minSize},uploadChunk:function(t){var e=this.chunkOptions.handler;return t.chunk=new e(t,this.chunkOptions),t.chunk.upload().then(function(e){return t})},uploadPut:function(e){var t,r,n=[];for(r in e.data)null!=(t=e.data[r])&&n.push(encodeURIComponent(r)+"="+encodeURIComponent(t));var i=e.putAction||"",o=n.length?(-1===i.indexOf("?")?"?":"&")+n.join("&"):"",s=new XMLHttpRequest;return s.open("PUT",i+o),this.uploadXhr(s,e,e.file)},uploadHtml5:function(e){var t,r,n=new window.FormData;for(r in e.data)(t=e.data[r])&&"object"===o(t)&&"function"!=typeof t.toString?t instanceof File?n.append(r,t,t.name):n.append(r,JSON.stringify(t)):null!=t&&n.append(r,t);n.append(this.name,e.file,e.file.name||e.file.filename||e.name);var i=new XMLHttpRequest;return i.open("POST",e.postAction||""),this.uploadXhr(i,e,n)},uploadXhr:function(s,e,r){var a=this,u=e,n=0,i=0;s.upload.onprogress=function(e){var t;u&&(u=a.get(u),e.lengthComputable&&u&&u.fileObject&&u.active&&((t=Math.round(Date.now()/1e3))!==n&&(n=t,u=a.update(u,{progress:(e.loaded/e.total*100).toFixed(2),speed:e.loaded-i}),i=e.loaded)))};var l=window.setInterval(function(){if(u&&((u=a.get(u))&&null!==u&&void 0!==u&&u.fileObject&&!u.success&&!u.error&&u.active))return;l&&(clearInterval(l),l=void 0);try{s.abort(),s.timeout=1}catch(e){}},100);return new Promise(function(n,i){if(!u)return i(new Error("not_exists"));function e(e){if(!o){if(o=!0,l&&(clearInterval(l),l=void 0),!u)return i(new Error("not_exists"));if(!(u=a.get(u)))return i(new Error("not_exists"));if(!u.fileObject)return i(new Error("file_object"));if(u.error)return u.error instanceof Error?i(u.error):i(new Error(u.error));if(!u.active)return i(new Error("abort"));if(u.success)return n(u);var t,r={};switch(e.type){case"timeout":case"abort":r.error=e.type;break;case"error":s.status?500<=s.status?r.error="server":400<=s.status&&(r.error="denied"):r.error="network";break;default:500<=s.status?r.error="server":400<=s.status?r.error="denied":r.progress="100.00"}return s.responseText&&((t=s.getResponseHeader("Content-Type"))&&-1!==t.indexOf("/json")?r.response=JSON.parse(s.responseText):r.response=s.responseText),(u=a.update(u,r))?u.error?u.error instanceof Error?i(u.error):i(new Error(u.error)):n(u):i(new Error("abort"))}}var o,t;for(t in s.onload=e,s.onerror=e,s.onabort=e,s.ontimeout=e,u.timeout&&(s.timeout=u.timeout),u.headers)s.setRequestHeader(t,u.headers[t]);(u=a.update(u,{xhr:s}))&&s.send(r)})},uploadHtml4:function(e){var a=this,u=e;if(!u)return Promise.reject(new Error("not_exists"));function l(e){27===e.keyCode&&e.preventDefault()}var c=document.createElement("iframe");c.id="upload-iframe-"+u.id,c.name="upload-iframe-"+u.id,c.src="about:blank",c.setAttribute("style","width:1px;height:1px;top:-999em;position:absolute; margin-top:-999em;");var t,r=document.createElement("form");for(t in r.setAttribute("action",u.postAction||""),r.name="upload-form-"+u.id,r.setAttribute("method","POST"),r.setAttribute("target","upload-iframe-"+u.id),r.setAttribute("enctype","multipart/form-data"),u.data){var n,i=u.data[t];i&&"object"===o(i)&&"function"!=typeof i.toString&&(i=JSON.stringify(i)),null!=i&&((n=document.createElement("input")).type="hidden",n.name=t,n.value=i,r.appendChild(n))}r.appendChild(u.el),document.body.appendChild(c).appendChild(r);return new Promise(function(o,s){setTimeout(function(){if(!u)return s(new Error("not_exists"));if(!(u=a.update(u,{iframe:c})))return s(new Error("not_exists"));function e(e){if(!n){if(n=!0,i&&(clearInterval(i),i=void 0),document.body.removeEventListener("keydown",l),!u)return s(new Error("not_exists"));if(!(u=a.get(u)))return s(new Error("not_exists"));if(!u.fileObject)return s(new Error("file_object"));if(u.error)return u.error instanceof Error?s(u.error):s(new Error(u.error));if(!u.active)return s(new Error("abort"));if(u.success)return o(u);var t=function(){var t;try{c.contentWindow&&(t=c.contentWindow.document)}catch(e){}if(!t)try{t=c.contentDocument||c.document}catch(e){t=c.document}return null!==t&&void 0!==t&&t.body?t.body.innerHTML:null}(),r={};if("string"==typeof e)return s(new Error(e));switch(e.type){case"abort":r.error="abort";break;case"error":u.error?r.error=u.error:r.error=null===t?"network":"denied";break;default:u.error?r.error=u.error:null===t?r.error="network":r.progress="100.00"}if(null!==t){if(t&&"{"===t.substr(0,1)&&"}"===t.substr(t.length-1,1))try{t=JSON.parse(t)}catch(e){}r.response=t}return(u=a.update(u,r))?null!==u&&void 0!==u&&u.error?u.error instanceof Error?s(u.error):s(new Error(u.error)):o(u):s(new Error("not_exists"))}}var n,i=window.setInterval(function(){if(u&&((u=a.get(u))&&null!==u&&void 0!==u&&u.fileObject&&!u.success&&!u.error&&u.active))return;i&&(clearInterval(i),i=void 0),c.onabort({type:u?"abort":"not_exists"})},100);c.onload=e,c.onerror=e,c.onabort=e,document.body.addEventListener("keydown",l),r.submit()},50)}).then(function(e){var t;return null==c||null!==(t=c.parentNode)&&void 0!==t&&t.removeChild(c),e}).catch(function(e){var t;return null==c||null!==(t=c.parentNode)&&void 0!==t&&t.removeChild(c),e})},watchActive:function(e){for(var t,r=0;t=this.files[r];)if(r++,t.fileObject)if(e&&!this.destroy){if(this.uploading>=this.thread||this.uploading&&!this.features.html5)break;t.active||t.error||t.success||this.update(t,{active:!0})}else t.active&&this.update(t,{active:!1});else;0===this.uploading&&(this.active=!1)},watchDrop:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;if(this.features.drop&&e!==t){if(this.dropElement)try{document.removeEventListener("dragenter",this.onDragenter,!1),document.removeEventListener("dragleave",this.onDragleave,!1),document.removeEventListener("drop",this.onDocumentDrop,!1),this.dropElement.removeEventListener("dragover",this.onDragover,!1),this.dropElement.removeEventListener("drop",this.onDrop,!1)}catch(e){}t=null;e&&("string"==typeof e?document.querySelector(e)||this.$root.$el.querySelector(e):t=!0===e?this.$parent.$el:e),this.dropElement=t,this.dropElement&&(document.addEventListener("dragenter",this.onDragenter,!1),document.addEventListener("dragleave",this.onDragleave,!1),document.addEventListener("drop",this.onDocumentDrop,!1),this.dropElement.addEventListener("dragover",this.onDragover,!1),this.dropElement.addEventListener("drop",this.onDrop,!1))}},onDragenter:function(e){var t;e.preventDefault(),this.dropActive||!e.dataTransfer||(null!=(e=e.dataTransfer)&&null!==(t=e.files)&&void 0!==t&&t.length||!e.types||e.types.indexOf&&-1!==e.types.indexOf("Files")||null!==(t=e.types)&&void 0!==t&&t.contains&&e.types.contains("Files"))&&(this.dropActive=!0)},onDragleave:function(e){e.preventDefault(),this.dropActive&&("HTML"===e.target.nodeName||e.target===e.explicitOriginalTarget||!e.fromElement&&(e.clientX<=0||e.clientY<=0||e.clientX>=window.innerWidth||e.clientY>=window.innerHeight))&&(this.dropActive=!1)},onDragover:function(e){e.preventDefault()},onDocumentDrop:function(){this.dropActive=!1},onDrop:function(e){e.preventDefault(),e.dataTransfer&&this.addDataTransfer(e.dataTransfer)},inputOnChange:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(async function(e){var i=this;if(!(e.target instanceof HTMLInputElement))return Promise.reject(new Error("not HTMLInputElement"));function t(e){var t,r,n;return o.files?(o.value="",o.files.length&&!/safari/i.test(navigator.userAgent)&&(o.type="",o.type="file")):((n=(r=document.getElementById(i.forId)).cloneNode(!0)).value="",n.type="file",n.onChange=inputOnChange,null!==(t=r.parentNode)&&void 0!==t&&t.replaceChild(n,r),i.$refs.input=n),e}var o=e.target;return this.addInputFile(e.target).then(t).catch(t)})}}),function(e,t){void 0===t&&(t={});var r,n=t.insertAt;e&&"undefined"!=typeof document&&(r=document.head||document.getElementsByTagName("head")[0],(t=document.createElement("style")).type="text/css","top"===n&&r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)))}("\n.file-uploads {\n overflow: hidden;\n position: relative;\n text-align: center;\n display: inline-block;\n}\n.file-uploads.file-uploads-html4 input, .file-uploads.file-uploads-html5 label {\n /* background fix ie click */\n background: #fff;\n opacity: 0;\n font-size: 20em;\n z-index: 1;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n.file-uploads.file-uploads-html5 input, .file-uploads.file-uploads-html4 label {\n /* background fix ie click */\n background: rgba(255, 255, 255, 0);\n overflow: hidden;\n position: fixed;\n width: 1px;\n height: 1px;\n z-index: -1;\n opacity: 0;\n}\n"),e.render=function(e,t,r,n,i,o){return u.openBlock(),u.createBlock("span",{class:e.className},[u.renderSlot(e.$slots,"default"),u.createVNode("label",{for:e.forId},null,8,["for"]),u.createVNode("input",{ref:"input",type:"file",name:e.name,id:e.forId,accept:e.accept,capture:e.capture,disabled:e.disabled,webkitdirectory:e.directory&&e.features.directory,allowdirs:e.directory&&e.features.directory,directory:e.directory&&e.features.directory,multiple:e.multiple&&e.features.html5,onChange:t[1]||(t[1]=function(){return e.inputOnChange&&e.inputOnChange.apply(e,arguments)})},null,40,["name","id","accept","capture","disabled","webkitdirectory","allowdirs","directory","multiple"])],2)},e)}(r={exports:{}}),r.exports});
//# sourceMappingURL=vue-upload-component.min.js.map
/*!
* Name: vue-upload-component
* Version: 2.8.20
* Author: LianYue
Name: vue-upload-component
Component URI: https://github.com/lian-yue/vue-upload-component#readme
Version: 3.0.35
Author: LianYue
License: Apache-2.0
Description: Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.VueUploadComponent = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vue')) :
typeof define === 'function' && define.amd ? define(['vue'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VueUploadComponent = factory(global.Vue));
}(this, (function (vue) { 'use strict';
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { _ownKeys(Object(source), true).forEach(function (key) { _defineProperty2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { _ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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 _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, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
/**

@@ -17,2 +110,4 @@ * Creates a XHR request

*/
var createRequest = function createRequest(options) {

@@ -22,2 +117,3 @@ var xhr = new XMLHttpRequest();

xhr.responseType = 'json';
if (options.headers) {

@@ -31,3 +127,2 @@ Object.keys(options.headers).forEach(function (key) {

};
/**

@@ -39,2 +134,4 @@ * Sends a XHR request with certain body

*/
var sendRequest = function sendRequest(xhr, body) {

@@ -45,2 +142,3 @@ return new Promise(function (resolve, reject) {

var response;
try {

@@ -51,2 +149,3 @@ response = JSON.parse(xhr.response);

}
resolve(response);

@@ -57,9 +156,10 @@ } else {

};
xhr.onerror = function () {
return reject(xhr.response);
};
xhr.send(JSON.stringify(body));
});
};
/**

@@ -71,4 +171,7 @@ * Sends a XHR request with certain form data

*/
var sendFormRequest = function sendFormRequest(xhr, data) {
var body = new FormData();
for (var name in data) {

@@ -82,2 +185,3 @@ body.append(name, data[name]);

var response;
try {

@@ -88,2 +192,3 @@ response = JSON.parse(xhr.response);

}
resolve(response);

@@ -94,9 +199,10 @@ } else {

};
xhr.onerror = function () {
return reject(xhr.response);
};
xhr.send(body);
});
};
/**

@@ -109,13 +215,10 @@ * Creates and sends XHR request

*/
function request (options) {
function request(options) {
var xhr = createRequest(options);
return sendRequest(xhr, options.body);
}
var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ChunkUploadHandler = function () {
var ChunkUploadHandler = /*#__PURE__*/function () {
/**

@@ -132,4 +235,6 @@ * Constructor

this.options = options;
this.chunks = [];
this.sessionId = null;
this.chunkSize = null;
}
/**

@@ -141,5 +246,4 @@ * Gets the max retries from options

_createClass(ChunkUploadHandler, [{
key: 'createChunks',
key: "createChunks",
/**

@@ -150,5 +254,5 @@ * Creates all the chunks in the initial state

this.chunks = [];
var start = 0;
var end = this.chunkSize;
while (start < this.fileSize) {

@@ -165,3 +269,2 @@ this.chunks.push({

}
/**

@@ -172,7 +275,6 @@ * Updates the progress of the file with the handler's progress

}, {
key: 'updateFileProgress',
key: "updateFileProgress",
value: function updateFileProgress() {
this.file.progress = this.progress;
}
/**

@@ -185,3 +287,3 @@ * Paues the upload process

}, {
key: 'pause',
key: "pause",
value: function pause() {

@@ -191,3 +293,2 @@ this.file.active = false;

}
/**

@@ -198,3 +299,3 @@ * Stops all the current chunks

}, {
key: 'stopChunks',
key: "stopChunks",
value: function stopChunks() {

@@ -206,3 +307,2 @@ this.chunksUploading.forEach(function (chunk) {

}
/**

@@ -215,3 +315,3 @@ * Resumes the file upload

}, {
key: 'resume',
key: "resume",
value: function resume() {

@@ -221,3 +321,2 @@ this.file.active = true;

}
/**

@@ -232,3 +331,3 @@ * Starts the file upload

}, {
key: 'upload',
key: "upload",
value: function upload() {

@@ -242,6 +341,4 @@ var _this = this;

this.start();
return this.promise;
}
/**

@@ -253,3 +350,3 @@ * Start phase

}, {
key: 'start',
key: "start",
value: function start() {

@@ -260,7 +357,7 @@ var _this2 = this;

method: 'POST',
headers: Object.assign({}, this.headers, {
headers: _objectSpread2(_objectSpread2({}, this.headers), {}, {
'Content-Type': 'application/json'
}),
url: this.action,
body: Object.assign(this.startBody, {
body: _objectSpread2(_objectSpread2({}, this.startBody), {}, {
phase: 'start',

@@ -281,9 +378,10 @@ mime_type: this.fileType,

_this2.createChunks();
_this2.startChunking();
}).catch(function (res) {
_this2.file.response = res;
_this2.reject('server');
});
}
/**

@@ -294,3 +392,3 @@ * Starts to upload chunks

}, {
key: 'startChunking',
key: "startChunking",
value: function startChunking() {

@@ -301,3 +399,2 @@ for (var i = 0; i < this.maxActiveChunks; i++) {

}
/**

@@ -310,3 +407,3 @@ * Uploads the next chunk

}, {
key: 'uploadNextChunk',
key: "uploadNextChunk",
value: function uploadNextChunk() {

@@ -323,3 +420,2 @@ if (this.file.active) {

}
/**

@@ -336,3 +432,3 @@ * Uploads a chunk

}, {
key: 'uploadChunk',
key: "uploadChunk",
value: function uploadChunk(chunk) {

@@ -349,3 +445,2 @@ var _this3 = this;

});
chunk.xhr.upload.addEventListener('progress', function (evt) {

@@ -356,4 +451,3 @@ if (evt.lengthComputable) {

}, false);
sendFormRequest(chunk.xhr, Object.assign(this.uploadBody, {
sendFormRequest(chunk.xhr, _objectSpread2(_objectSpread2({}, this.uploadBody), {}, {
phase: 'upload',

@@ -365,2 +459,3 @@ session_id: this.sessionId,

chunk.active = false;
if (res.status === 'success') {

@@ -371,2 +466,3 @@ chunk.uploaded = true;

_this3.stopChunks();
return _this3.reject('upload');

@@ -379,4 +475,6 @@ }

chunk.active = false;
if (chunk.retries-- <= 0) {
_this3.stopChunks();
return _this3.reject('upload');

@@ -388,3 +486,2 @@ }

}
/**

@@ -396,3 +493,3 @@ * Finish phase

}, {
key: 'finish',
key: "finish",
value: function finish() {

@@ -402,10 +499,9 @@ var _this4 = this;

this.updateFileProgress();
request({
method: 'POST',
headers: Object.assign({}, this.headers, {
headers: _objectSpread2(_objectSpread2({}, this.headers), {}, {
'Content-Type': 'application/json'
}),
url: this.action,
body: Object.assign(this.finishBody, {
body: _objectSpread2(_objectSpread2({}, this.finishBody), {}, {
phase: 'finish',

@@ -416,2 +512,3 @@ session_id: this.sessionId

_this4.file.response = res;
if (res.status !== 'success') {

@@ -424,2 +521,3 @@ return _this4.reject('server');

_this4.file.response = res;
_this4.reject('server');

@@ -429,7 +527,6 @@ });

}, {
key: 'maxRetries',
key: "maxRetries",
get: function get() {
return parseInt(this.options.maxRetries);
return parseInt(this.options.maxRetries, 10);
}
/**

@@ -440,7 +537,6 @@ * Gets the max number of active chunks being uploaded at once from options

}, {
key: 'maxActiveChunks',
key: "maxActiveChunks",
get: function get() {
return parseInt(this.options.maxActive);
return parseInt(this.options.maxActive, 10);
}
/**

@@ -451,7 +547,6 @@ * Gets the file type

}, {
key: 'fileType',
key: "fileType",
get: function get() {
return this.file.type;
}
/**

@@ -462,7 +557,6 @@ * Gets the file size

}, {
key: 'fileSize',
key: "fileSize",
get: function get() {
return this.file.size;
}
/**

@@ -473,7 +567,6 @@ * Gets the file name

}, {
key: 'fileName',
key: "fileName",
get: function get() {
return this.file.name;
}
/**

@@ -484,7 +577,6 @@ * Gets action (url) to upload the file

}, {
key: 'action',
key: "action",
get: function get() {
return this.options.action || null;
}
/**

@@ -495,7 +587,6 @@ * Gets the body to be merged when sending the request in start phase

}, {
key: 'startBody',
key: "startBody",
get: function get() {
return this.options.startBody || {};
}
/**

@@ -506,7 +597,6 @@ * Gets the body to be merged when sending the request in upload phase

}, {
key: 'uploadBody',
key: "uploadBody",
get: function get() {
return this.options.uploadBody || {};
}
/**

@@ -517,7 +607,6 @@ * Gets the body to be merged when sending the request in finish phase

}, {
key: 'finishBody',
key: "finishBody",
get: function get() {
return this.options.finishBody || {};
}
/**

@@ -528,7 +617,6 @@ * Gets the headers of the requests from options

}, {
key: 'headers',
key: "headers",
get: function get() {
return this.options.headers || {};
}
/**

@@ -539,7 +627,6 @@ * Whether it's ready to upload files or not

}, {
key: 'readyToUpload',
key: "readyToUpload",
get: function get() {
return !!this.chunks;
}
/**

@@ -552,3 +639,3 @@ * Gets the progress of the chunk upload

}, {
key: 'progress',
key: "progress",
get: function get() {

@@ -561,6 +648,4 @@ var _this5 = this;

}, 0);
return Math.min(completedProgress + uploadingProgress, 100);
}
/**

@@ -571,4 +656,5 @@ * Gets all the chunks that are pending to be uploaded

}, {
key: 'chunksToUpload',
key: "chunksToUpload",
get: function get() {
console.log(this.chunks);
return this.chunks.filter(function (chunk) {

@@ -578,3 +664,2 @@ return !chunk.active && !chunk.uploaded;

}
/**

@@ -585,7 +670,6 @@ * Whether there are chunks to upload or not

}, {
key: 'hasChunksToUpload',
key: "hasChunksToUpload",
get: function get() {
return this.chunksToUpload.length > 0;
}
/**

@@ -596,3 +680,3 @@ * Gets all the chunks that are uploading

}, {
key: 'chunksUploading',
key: "chunksUploading",
get: function get() {

@@ -603,3 +687,2 @@ return this.chunks.filter(function (chunk) {

}
/**

@@ -610,3 +693,3 @@ * Gets all the chunks that have finished uploading

}, {
key: 'chunksUploaded',
key: "chunksUploaded",
get: function get() {

@@ -622,143 +705,2 @@ return this.chunks.filter(function (chunk) {

//
//
//
//
//
//
//
//
//
//
//
//
//
//
var script = {
methods: {
change: function change(e) {
this.$parent.addInputFile(e.target);
if (e.target.files) {
e.target.value = '';
if (e.target.files.length && !/safari/i.test(navigator.userAgent)) {
e.target.type = '';
e.target.type = 'file';
}
} else {
// ie9 fix #219
this.$destroy();
// eslint-disable-next-line
new this.constructor({
parent: this.$parent,
el: this.$el
});
}
}
}
};
/* script */
var __vue_script__ = script;
/* template */
var __vue_render__ = function __vue_render__() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('input', { attrs: { "type": "file", "name": _vm.$parent.name, "id": _vm.$parent.inputId || _vm.$parent.name, "accept": _vm.$parent.accept, "capture": _vm.$parent.capture, "disabled": _vm.$parent.disabled, "webkitdirectory": _vm.$parent.directory && _vm.$parent.features.directory, "directory": _vm.$parent.directory && _vm.$parent.features.directory, "multiple": _vm.$parent.multiple && _vm.$parent.features.html5 }, on: { "change": _vm.change } });
};
var __vue_staticRenderFns__ = [];
/* style */
var __vue_inject_styles__ = undefined;
/* scoped */
var __vue_scope_id__ = undefined;
/* module identifier */
var __vue_module_identifier__ = undefined;
/* functional template */
var __vue_is_functional_template__ = false;
/* component normalizer */
function __vue_normalize__(template, style, script$$1, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
var component = (typeof script$$1 === 'function' ? script$$1.options : script$$1) || {};
if (!component.render) {
component.render = template.render;
component.staticRenderFns = template.staticRenderFns;
component._compiled = true;
if (functional) component.functional = true;
}
component._scopeId = scope;
return component;
}
/* style inject */
function __vue_create_injector__() {
var head = document.head || document.getElementsByTagName('head')[0];
var styles = __vue_create_injector__.styles || (__vue_create_injector__.styles = {});
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
return function addStyle(id, css) {
if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present.
var group = isOldIE ? css.media || 'default' : id;
var style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined });
if (!style.ids.includes(id)) {
var code = css.source;
var index = style.ids.length;
style.ids.push(id);
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
}
if (isOldIE) {
style.element = style.element || document.querySelector('style[data-group=' + group + ']');
}
if (!style.element) {
var el = style.element = document.createElement('style');
el.type = 'text/css';
if (css.media) el.setAttribute('media', css.media);
if (isOldIE) {
el.setAttribute('data-group', group);
el.setAttribute('data-next-index', '0');
}
head.appendChild(el);
}
if (isOldIE) {
index = parseInt(style.element.getAttribute('data-next-index'));
style.element.setAttribute('data-next-index', index + 1);
}
if (style.element.styleSheet) {
style.parts.push(code);
style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n');
} else {
var textNode = document.createTextNode(code);
var nodes = style.element.childNodes;
if (nodes[index]) style.element.removeChild(nodes[index]);
if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
}
}
};
}
/* style inject SSR */
var InputFile = __vue_normalize__({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, __vue_create_injector__, undefined);
var _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; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var CHUNK_DEFAULT_OPTIONS = {

@@ -770,10 +712,5 @@ headers: {},

maxRetries: 5,
handler: ChunkUploadHandler
};
var script$1 = {
components: {
InputFile: InputFile
},
var script = vue.defineComponent({
props: {

@@ -783,3 +720,2 @@ inputId: {

},
name: {

@@ -789,52 +725,47 @@ type: String,

},
accept: {
type: String
},
capture: {},
disabled: {},
disabled: {
default: false
},
multiple: {
type: Boolean
type: Boolean,
default: false
},
maximum: {
type: Number,
default: function _default() {
return this.multiple ? 0 : 1;
}
type: Number
},
addIndex: {
type: [Boolean, Number]
},
directory: {
type: Boolean
},
createDirectory: {
type: Boolean,
default: false
},
postAction: {
type: String
},
putAction: {
type: String
},
customAction: {
type: Function
},
headers: {
type: Object,
default: Object
default: function _default() {
return {};
}
},
data: {
type: Object,
default: Object
default: function _default() {
return {};
}
},
timeout: {

@@ -844,7 +775,5 @@ type: Number,

},
drop: {
default: false
},
dropDirectory: {

@@ -854,3 +783,2 @@ type: Boolean,

},
size: {

@@ -860,12 +788,14 @@ type: Number,

},
extensions: {
default: Array
type: [RegExp, String, Array],
default: function _default() {
return [];
}
},
value: {
modelValue: {
type: Array,
default: Array
default: function _default() {
return [];
}
},
thread: {

@@ -875,3 +805,2 @@ type: Number,

},
// Chunk upload enabled

@@ -882,3 +811,2 @@ chunkEnabled: {

},
// Chunk upload properties

@@ -892,22 +820,20 @@ chunk: {

},
emits: ['update:modelValue', 'input-filter', 'input-file'],
data: function data() {
return {
files: this.value,
files: this.modelValue,
features: {
html5: true,
directory: false,
drag: false
drop: false
},
active: false,
dropActive: false,
uploading: 0,
destroy: false
destroy: false,
maps: {},
dropElement: null
};
},
/**

@@ -918,14 +844,16 @@ * mounted

mounted: function mounted() {
var _this6 = this;
var input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.multiple = true; // html5 特征
// html5 特征
if (window.FormData && input.files) {
// 上传目录特征
// @ts-ignore
if (typeof input.webkitdirectory === 'boolean' || typeof input.directory === 'boolean') {
this.features.directory = true;
}
} // 拖拽特征
// 拖拽特征
if (this.features.html5 && typeof input.ondrop !== 'undefined') {

@@ -936,6 +864,7 @@ this.features.drop = true;

this.features.html5 = false;
}
} // files 定位缓存
// files 定位缓存
this.maps = {};
if (this.files) {

@@ -946,30 +875,33 @@ for (var i = 0; i < this.files.length; i++) {

}
}
} // @ts-ignore
this.$nextTick(function () {
// 更新下父级
if (_this6.$parent) {
_this6.$parent.$forceUpdate(); // 拖拽渲染
// 更新下父级
if (this.$parent) {
this.$parent.$forceUpdate();
_this6.$parent.$nextTick(function () {
_this6.watchDrop(_this6.drop);
});
} else {
// 拖拽渲染
_this6.watchDrop(_this6.drop);
}
// 拖拽渲染
this.watchDrop(this.drop);
});
},
/**
* beforeDestroy
* beforeUnmount
* @return {[type]} [description]
*/
beforeDestroy: function beforeDestroy() {
beforeUnmount: function beforeUnmount() {
// 已销毁
this.destroy = true;
this.destroy = true; // 设置成不激活
// 设置成不激活
this.active = false;
this.active = false; // 销毁拖拽事件
this.watchDrop(false);
},
computed: {

@@ -986,5 +918,7 @@ /**

uploaded: function uploaded() {
var file = void 0;
var file;
for (var i = 0; i < this.files.length; i++) {
file = this.files[i];
if (file.fileObject && !file.error && !file.success) {

@@ -994,2 +928,3 @@ return false;

}
return true;

@@ -1002,5 +937,38 @@ },

return ['file-uploads', this.features.html5 ? 'file-uploads-html5' : 'file-uploads-html4', this.features.directory && this.directory ? 'file-uploads-directory' : undefined, this.features.drop && this.drop ? 'file-uploads-drop' : undefined, this.disabled ? 'file-uploads-disabled' : undefined];
},
forId: function forId() {
return this.inputId || this.name;
},
iMaximum: function iMaximum() {
if (this.maximum === undefined) {
return this.multiple ? 0 : 1;
}
return this.maximum;
},
iExtensions: function iExtensions() {
if (!this.extensions) {
return;
}
if (this.extensions instanceof RegExp) {
return this.extensions;
}
var exts = [];
if (typeof this.extensions === 'string') {
exts = this.extensions.split(',');
} else {
exts = this.extensions;
}
exts = exts.map(function (value) {
return value.trim();
}).filter(function (value) {
return value;
});
return new RegExp('\\.(' + exts.join('|').replace(/\./g, '\\.') + ')$', 'i');
}
},
watch: {

@@ -1018,27 +986,28 @@ active: function active(_active) {

},
value: function value(files) {
modelValue: function modelValue(files) {
if (this.files === files) {
return;
}
this.files = files;
var oldMaps = this.maps; // 重写 maps 缓存
var oldMaps = this.maps;
this.maps = {};
// 重写 maps 缓存
this.maps = {};
for (var i = 0; i < this.files.length; i++) {
var file = this.files[i];
this.maps[file.id] = file;
}
} // add, update
// add, update
for (var key in this.maps) {
var newFile = this.maps[key];
var oldFile = oldMaps[key];
if (newFile !== oldFile) {
this.emitFile(newFile, oldFile);
}
}
} // delete
// delete
for (var _key in oldMaps) {

@@ -1051,5 +1020,6 @@ if (!this.maps[_key]) {

},
methods: {
newId: function newId() {
return Math.random().toString(36).substr(2);
},
// 清空

@@ -1059,9 +1029,8 @@ clear: function clear() {

var files = this.files;
this.files = [];
this.files = []; // 定位
// 定位
this.maps = {};
this.maps = {}; // 事件
// 事件
this.emitInput();
for (var i = 0; i < files.length; i++) {

@@ -1071,6 +1040,5 @@ this.emitFile(undefined, files[i]);

}
return true;
},
// 选择

@@ -1082,4 +1050,4 @@ get: function get(id) {

if ((typeof id === 'undefined' ? 'undefined' : _typeof(id)) === 'object') {
return this.maps[id.id] || false;
if (_typeof(id) === 'object') {
return this.maps[id.id || ''] || false;
}

@@ -1089,24 +1057,30 @@

},
// 添加
add: function add(_files, index) {
// 不是数组整理成数组
var files;
if (_files instanceof Array) {
files = _files;
} else {
files = [_files];
}
// 添加
add: function add(_files) {
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.addIndex;
if (index === undefined) {
// eslint-disable-next-line
index = this.addIndex;
} // 遍历规范对象
var files = _files;
var isArray = files instanceof Array;
// 不是数组整理成数组
if (!isArray) {
files = [files];
}
var addFiles = [];
// 遍历规范对象
var addFiles = [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (this.features.html5 && file instanceof Blob) {
file = {
id: '',
file: file,
size: file.size,
// @ts-ignore
name: file.webkitRelativePath || file.relativePath || file.name || 'unknown',

@@ -1116,6 +1090,8 @@ type: file.type

}
file = file;
var fileObject = false;
if (file.fileObject === false) ; else if (file.fileObject) {
if (file.fileObject === false) ;else if (file.fileObject) {
fileObject = true;
} else if (typeof Element !== 'undefined' && file.el instanceof Element) {
} else if (typeof Element !== 'undefined' && file.el instanceof HTMLInputElement) {
fileObject = true;

@@ -1125,4 +1101,5 @@ } else if (typeof Blob !== 'undefined' && file.file instanceof Blob) {

}
if (fileObject) {
file = _extends({
file = _objectSpread(_objectSpread({
fileObject: true,

@@ -1138,19 +1115,14 @@ size: -1,

timeout: this.timeout
}, file, {
}, file), {}, {
response: {},
progress: '0.00', // 只读
speed: 0 // 只读
// xhr: false, // 只读
// iframe: false, // 只读
progress: '0.00',
speed: 0
});
file.data = _objectSpread(_objectSpread({}, this.data), file.data ? file.data : {});
file.headers = _objectSpread(_objectSpread({}, this.headers), file.headers ? file.headers : {});
} // 必须包含 id
file.data = _extends({}, this.data, file.data ? file.data : {});
file.headers = _extends({}, this.headers, file.headers ? file.headers : {});
}
// 必须包含 id
if (!file.id) {
file.id = Math.random().toString(36).substr(2);
file.id = this.newId();
}

@@ -1160,29 +1132,29 @@

continue;
}
} // 最大数量限制
// 最大数量限制
if (this.maximum > 1 && addFiles.length + this.files.length >= this.maximum) {
if (this.iMaximum > 1 && addFiles.length + this.files.length >= this.iMaximum) {
break;
}
addFiles.push(file);
addFiles.push(file); // 最大数量限制
// 最大数量限制
if (this.maximum === 1) {
if (this.iMaximum === 1) {
break;
}
}
} // 没有文件
// 没有文件
if (!addFiles.length) {
return false;
}
return;
} // 如果是 1 清空
// 如果是 1 清空
if (this.maximum === 1) {
if (this.iMaximum === 1) {
this.clear();
}
} // 添加进去 files
// 添加进去 files
var newFiles = void 0;
var newFiles;
if (index === true || index === 0) {

@@ -1194,2 +1166,3 @@ newFiles = addFiles.concat(this.files);

newFiles = this.files.concat([]);
(_newFiles = newFiles).splice.apply(_newFiles, [index, 0].concat(addFiles));

@@ -1200,12 +1173,12 @@ } else {

this.files = newFiles;
this.files = newFiles; // 定位
// 定位
for (var _i = 0; _i < addFiles.length; _i++) {
var _file2 = addFiles[_i];
this.maps[_file2.id] = _file2;
}
var _file = addFiles[_i];
this.maps[_file.id] = _file;
} // 事件
// 事件
this.emitInput();
for (var _i2 = 0; _i2 < addFiles.length; _i2++) {

@@ -1215,9 +1188,19 @@ this.emitFile(addFiles[_i2], undefined);

return isArray ? addFiles : addFiles[0];
return _files instanceof Array ? addFiles : addFiles[0];
},
// 添加表单文件
addInputFile: function addInputFile(el) {
var _this7 = this;
var files = [];
var maximumValue = this.iMaximum; // @ts-ignore
var entrys = el.webkitEntries || el.entries || undefined;
if (entrys && entrys.length) {
return this.getFileSystemEntry(entrys).then(function (files) {
return _this7.add(files);
});
}
if (el.files) {

@@ -1227,3 +1210,5 @@ for (var i = 0; i < el.files.length; i++) {

files.push({
id: '',
size: file.size,
// @ts-ignore
name: file.webkitRelativePath || file.relativePath || file.name,

@@ -1236,4 +1221,11 @@ type: file.type,

var names = el.value.replace(/\\/g, '/').split('/');
if (!names || !names.length) {
names = [el.value];
} // @ts-ignore
delete el.__vuex__;
files.push({
id: '',
name: names[names.length - 1],

@@ -1243,50 +1235,50 @@ el: el

}
return this.add(files);
return Promise.resolve(this.add(files));
},
// 添加 DataTransfer
addDataTransfer: function addDataTransfer(dataTransfer) {
var _this = this;
var _dataTransfer$items,
_this8 = this;
var files = [];
if (dataTransfer.items && dataTransfer.items.length) {
var items = [];
// dataTransfer.items 支持
if (dataTransfer !== null && dataTransfer !== void 0 && (_dataTransfer$items = dataTransfer.items) !== null && _dataTransfer$items !== void 0 && _dataTransfer$items.length) {
var entrys = []; // 遍历出所有 dataTransferVueUploadItem
for (var i = 0; i < dataTransfer.items.length; i++) {
var item = dataTransfer.items[i];
if (item.getAsEntry) {
item = item.getAsEntry() || item.getAsFile();
} else if (item.webkitGetAsEntry) {
item = item.webkitGetAsEntry() || item.getAsFile();
var dataTransferTtem = dataTransfer.items[i];
var entry = void 0; // @ts-ignore
if (dataTransferTtem.getAsEntry) {
// @ts-ignore
entry = dataTransferTtem.getAsEntry() || dataTransferTtem.getAsFile();
} else if (dataTransferTtem.webkitGetAsEntry) {
entry = dataTransferTtem.webkitGetAsEntry() || dataTransferTtem.getAsFile();
} else {
item = item.getAsFile();
entry = dataTransferTtem.getAsFile();
}
if (item) {
items.push(item);
if (entry) {
entrys.push(entry);
}
}
return new Promise(function (resolve, reject) {
var forEach = function forEach(i) {
var item = items[i];
// 结束 文件数量大于 最大数量
if (!item || _this.maximum > 0 && files.length >= _this.maximum) {
return resolve(_this.add(files));
}
_this.getEntry(item).then(function (results) {
files.push.apply(files, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
return this.getFileSystemEntry(entrys).then(function (files) {
return _this8.add(files);
});
}
} // dataTransfer.files 支持
var maximumValue = this.iMaximum;
var files = [];
if (dataTransfer.files.length) {
for (var _i3 = 0; _i3 < dataTransfer.files.length; _i3++) {
files.push(dataTransfer.files[_i3]);
if (this.maximum > 0 && files.length >= this.maximum) {
if (maximumValue > 0 && files.length >= maximumValue) {
break;
}
}
return Promise.resolve(this.add(files));

@@ -1297,14 +1289,50 @@ }

},
// 获得 entrys
getFileSystemEntry: function getFileSystemEntry(entry) {
var _this9 = this;
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return new Promise(function (resolve) {
var maximumValue = _this9.iMaximum;
// 获得 entry
getEntry: function getEntry(entry) {
var _this2 = this;
if (!entry) {
return resolve([]);
}
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
if (entry instanceof Array) {
// 多个
var uploadFiles = [];
return new Promise(function (resolve, reject) {
var forEach = function forEach(i) {
var v = entry[i];
if (!v || maximumValue > 0 && uploadFiles.length >= maximumValue) {
return resolve(uploadFiles);
}
_this9.getFileSystemEntry(v, path).then(function (results) {
uploadFiles.push.apply(uploadFiles, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
return;
}
if (entry instanceof Blob) {
resolve([{
id: '',
size: entry.size,
name: path + entry.name,
type: entry.type,
file: entry
}]);
return;
}
if (entry.isFile) {
entry.file(function (file) {
resolve([{
id: '',
size: file.size,

@@ -1316,40 +1344,68 @@ name: path + file.name,

});
} else if (entry.isDirectory && _this2.dropDirectory) {
var files = [];
return;
}
if (entry.isDirectory && _this9.dropDirectory) {
var _uploadFiles = []; // 目录也要添加到文件列表
if (_this9.createDirectory) {
_uploadFiles.push({
id: '',
name: path + entry.name,
size: 0,
type: 'text/directory',
file: new File([], path + entry.name, {
type: 'text/directory'
})
});
}
var dirReader = entry.createReader();
var readEntries = function readEntries() {
dirReader.readEntries(function (entries) {
var forEach = function forEach(i) {
if (!entries[i] && i === 0 || _this2.maximum > 0 && files.length >= _this2.maximum) {
return resolve(files);
if (!entries[i] && i === 0 || maximumValue > 0 && _uploadFiles.length >= maximumValue) {
return resolve(_uploadFiles);
}
if (!entries[i]) {
return readEntries();
}
_this2.getEntry(entries[i], path + entry.name + '/').then(function (results) {
files.push.apply(files, _toConsumableArray(results));
_this9.getFileSystemEntry(entries[i], path + entry.name + '/').then(function (results) {
_uploadFiles.push.apply(_uploadFiles, _toConsumableArray(results));
forEach(i + 1);
});
};
forEach(0);
});
};
readEntries();
} else {
resolve([]);
return;
}
resolve([]);
});
},
// 替换
replace: function replace(id1, id2) {
var file1 = this.get(id1);
var file2 = this.get(id2);
if (!file1 || !file2 || file1 === file2) {
return false;
}
var files = this.files.concat([]);
var index1 = files.indexOf(file1);
var index2 = files.indexOf(file2);
if (index1 === -1 || index2 === -1) {
return false;
}
files[index1] = file2;

@@ -1361,7 +1417,6 @@ files[index2] = file1;

},
// 移除
remove: function remove(id) {
var file = this.get(id);
if (file) {

@@ -1371,4 +1426,6 @@ if (this.emitFilter(undefined, file)) {

}
var files = this.files.concat([]);
var index = files.indexOf(file);
if (index === -1) {

@@ -1378,22 +1435,22 @@ console.error('remove', file);

}
files.splice(index, 1);
this.files = files;
this.files = files; // 定位
// 定位
delete this.maps[file.id];
delete this.maps[file.id]; // 事件
// 事件
this.emitInput();
this.emitFile(undefined, file);
}
return file;
},
// 更新
update: function update(id, data) {
var file = this.get(id);
if (file) {
var newFile = _extends({}, file, data);
// 停用必须加上错误
var newFile = _objectSpread(_objectSpread({}, file), data); // 停用必须加上错误
if (file.fileObject && file.active && !newFile.active && !newFile.error && !newFile.success) {

@@ -1409,2 +1466,3 @@ newFile.error = 'abort';

var index = files.indexOf(file);
if (index === -1) {

@@ -1414,10 +1472,9 @@ console.error('update', file);

}
files.splice(index, 1, newFile);
this.files = files;
this.files = files; // 删除 旧定位 写入 新定位 (已便支持修改id)
// 删除 旧定位 写入 新定位 (已便支持修改id)
delete this.maps[file.id];
this.maps[newFile.id] = newFile;
this.maps[newFile.id] = newFile; // 事件
// 事件
this.emitInput();

@@ -1427,6 +1484,5 @@ this.emitFile(newFile, file);

}
return false;
},
// 预处理 事件 过滤器

@@ -1436,3 +1492,4 @@ emitFilter: function emitFilter(newFile, oldFile) {

this.$emit('input-filter', newFile, oldFile, function () {
isPrevent = true;
var prevent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
isPrevent = prevent;
return isPrevent;

@@ -1442,19 +1499,25 @@ });

},
// 处理后 事件 分发
emitFile: function emitFile(newFile, oldFile) {
var _newFile,
_this10 = this;
this.$emit('input-file', newFile, oldFile);
if (newFile && newFile.fileObject && newFile.active && (!oldFile || !oldFile.active)) {
this.uploading++;
// 激活
if ((_newFile = newFile) !== null && _newFile !== void 0 && _newFile.fileObject && newFile.active && (!oldFile || !oldFile.active)) {
this.uploading++; // 激活
// @ts-ignore
this.$nextTick(function () {
var _this3 = this;
setTimeout(function () {
newFile && _this10.upload(newFile).then(function () {
var _newFile2;
setTimeout(function () {
_this3.upload(newFile).then(function () {
// eslint-disable-next-line
newFile = _this3.get(newFile);
if (newFile && newFile.fileObject) {
_this3.update(newFile, {
if (newFile) {
// eslint-disable-next-line
newFile = _this10.get(newFile) || undefined;
}
if ((_newFile2 = newFile) !== null && _newFile2 !== void 0 && _newFile2.fileObject) {
_this10.update(newFile, {
active: false,

@@ -1465,3 +1528,3 @@ success: !newFile.error

}).catch(function (e) {
_this3.update(newFile, {
newFile && _this10.update(newFile, {
active: false,

@@ -1472,3 +1535,3 @@ success: false,

});
}, parseInt(Math.random() * 50 + 50, 10));
}, Math.ceil(Math.random() * 50 + 50));
});

@@ -1478,5 +1541,6 @@ } else if ((!newFile || !newFile.fileObject || !newFile.active) && oldFile && oldFile.fileObject && oldFile.active) {

this.uploading--;
}
} // 自动延续激活
// @ts-ignore
// 自动延续激活
if (this.active && (Boolean(newFile) !== Boolean(oldFile) || newFile.active !== oldFile.active)) {

@@ -1487,51 +1551,43 @@ this.watchActive(true);

emitInput: function emitInput() {
this.$emit('input', this.files);
this.$emit('update:modelValue', this.files);
},
// 上传
upload: function upload(id) {
var file = this.get(id);
var file = this.get(id); // 被删除
// 被删除
if (!file) {
return Promise.reject('not_exists');
}
return Promise.reject(new Error('not_exists'));
} // 不是文件对象
// 不是文件对象
if (!file.fileObject) {
return Promise.reject('file_object');
}
return Promise.reject(new Error('file_object'));
} // 有错误直接响应
// 有错误直接响应
if (file.error) {
return Promise.reject(file.error);
}
if (file.error instanceof Error) {
return Promise.reject(file.error);
}
// 已完成直接响应
return Promise.reject(new Error(file.error));
} // 已完成直接响应
if (file.success) {
return Promise.resolve(file);
}
} // 后缀
// 后缀
var extensions = this.extensions;
if (extensions && (extensions.length || typeof extensions.length === 'undefined')) {
if ((typeof extensions === 'undefined' ? 'undefined' : _typeof(extensions)) !== 'object' || !(extensions instanceof RegExp)) {
if (typeof extensions === 'string') {
extensions = extensions.split(',').map(function (value) {
return value.trim();
}).filter(function (value) {
return value;
});
}
extensions = new RegExp('\\.(' + extensions.join('|').replace(/\./g, '\\.') + ')$', 'i');
if (file.name && this.iExtensions) {
if (file.name.search(this.iExtensions) === -1) {
return Promise.reject(new Error('extension'));
}
if (file.name.search(extensions) === -1) {
return Promise.reject('extension');
}
}
} // 大小
// 大小
if (this.size > 0 && file.size >= 0 && file.size > this.size) {
return Promise.reject('size');
if (this.size > 0 && file.size !== undefined && file.size >= 0 && file.size > this.size) {
return Promise.reject(new Error('size'));
}

@@ -1547,5 +1603,7 @@

}
if (file.putAction) {
return this.uploadPut(file);
}
if (file.postAction) {

@@ -1555,9 +1613,10 @@ return this.uploadHtml5(file);

}
if (file.postAction) {
return this.uploadHtml4(file);
}
return Promise.reject('No action configured');
return Promise.reject(new Error('No action configured'));
},
/**

@@ -1569,6 +1628,5 @@ * Whether this file should be uploaded using chunk upload or not

shouldUseChunkUpload: function shouldUseChunkUpload(file) {
return this.chunkEnabled && !!this.chunkOptions.handler && file.size > this.chunkOptions.minSize;
return this.chunkEnabled && !!this.chunkOptions.handler && file.size && file.size > this.chunkOptions.minSize;
},
/**

@@ -1582,10 +1640,13 @@ * Upload a file using Chunk method

file.chunk = new HandlerClass(file, this.chunkOptions);
return file.chunk.upload();
return file.chunk.upload().then(function (res) {
return file;
});
},
uploadPut: function uploadPut(file) {
var querys = [];
var value = void 0;
var value;
for (var key in file.data) {
value = file.data[key];
if (value !== null && value !== undefined) {

@@ -1595,5 +1656,7 @@ querys.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));

}
var queryString = querys.length ? (file.putAction.indexOf('?') === -1 ? '?' : '&') + querys.join('&') : '';
var putAction = file.putAction || '';
var queryString = querys.length ? (putAction.indexOf('?') === -1 ? '?' : '&') + querys.join('&') : '';
var xhr = new XMLHttpRequest();
xhr.open('PUT', file.putAction + queryString);
xhr.open('PUT', putAction + queryString);
return this.uploadXhr(xhr, file, file.file);

@@ -1603,6 +1666,8 @@ },

var form = new window.FormData();
var value = void 0;
var value;
for (var key in file.data) {
value = file.data[key];
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toString !== 'function') {
if (value && _typeof(value) === 'object' && typeof value.toString !== 'function') {
if (value instanceof File) {

@@ -1616,31 +1681,38 @@ form.append(key, value, value.name);

}
}
form.append(this.name, file.file, file.file.filename || file.name);
} // @ts-ignore
form.append(this.name, file.file, file.file.name || file.file.filename || file.name);
var xhr = new XMLHttpRequest();
xhr.open('POST', file.postAction);
xhr.open('POST', file.postAction || '');
return this.uploadXhr(xhr, file, form);
},
uploadXhr: function uploadXhr(xhr, _file, body) {
var _this4 = this;
uploadXhr: function uploadXhr(xhr, ufile, body) {
var _this11 = this;
var file = _file;
var file = ufile;
var speedTime = 0;
var speedLoaded = 0;
var speedLoaded = 0; // 进度条
// 进度条
xhr.upload.onprogress = function (e) {
// 还未开始上传 已删除 未激活
file = _this4.get(file);
if (!e.lengthComputable || !file || !file.fileObject || !file.active) {
if (!file) {
return;
}
// 进度 速度 每秒更新一次
file = _this11.get(file);
if (!e.lengthComputable || !file || !file.fileObject || !file.active) {
return;
} // 进度 速度 每秒更新一次
var speedTime2 = Math.round(Date.now() / 1000);
if (speedTime2 === speedTime) {
return;
}
speedTime = speedTime2;
file = _this4.update(file, {
file = _this11.update(file, {
progress: (e.loaded / e.total * 100).toFixed(2),

@@ -1650,9 +1722,14 @@ speed: e.loaded - speedLoaded

speedLoaded = e.loaded;
};
}; // 检查激活状态
// 检查激活状态
var interval = setInterval(function () {
file = _this4.get(file);
if (file && file.fileObject && !file.success && !file.error && file.active) {
return;
var interval = window.setInterval(function () {
if (file) {
var _file2;
file = _this11.get(file);
if (file && (_file2 = file) !== null && _file2 !== void 0 && _file2.fileObject && !file.success && !file.error && file.active) {
return;
}
}

@@ -1662,3 +1739,3 @@

clearInterval(interval);
interval = false;
interval = undefined;
}

@@ -1671,5 +1748,9 @@

}, 100);
return new Promise(function (resolve, reject) {
if (!file) {
return reject(new Error('not_exists'));
}
return new Promise(function (resolve, reject) {
var complete = void 0;
var complete;
var fn = function fn(e) {

@@ -1680,31 +1761,40 @@ // 已经处理过了

}
complete = true;
if (interval) {
clearInterval(interval);
interval = false;
interval = undefined;
}
file = _this4.get(file);
// 不存在直接响应
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 不是文件对象
file = _this11.get(file); // 不存在直接响应
if (!file) {
return reject(new Error('not_exists'));
} // 不是文件对象
if (!file.fileObject) {
return reject('file_object');
}
return reject(new Error('file_object'));
} // 有错误自动响应
// 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 未激活
return reject(new Error(file.error));
} // 未激活
if (!file.active) {
return reject('abort');
}
return reject(new Error('abort'));
} // 已完成 直接相应
// 已完成 直接相应
if (file.success) {

@@ -1721,2 +1811,3 @@ return resolve(file);

break;
case 'error':

@@ -1730,3 +1821,5 @@ if (!xhr.status) {

}
break;
default:

@@ -1740,2 +1833,3 @@ if (xhr.status >= 500) {

}
}

@@ -1745,2 +1839,3 @@

var contentType = xhr.getResponseHeader('Content-Type');
if (contentType && contentType.indexOf('/json') !== -1) {

@@ -1751,43 +1846,58 @@ data.response = JSON.parse(xhr.responseText);

}
}
} // 更新
// @ts-ignore
// 更新
file = _this4.update(file, data);
// 相应错误
file = _this11.update(file, data);
if (!file) {
return reject(new Error('abort'));
} // 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 响应
return reject(new Error(file.error));
} // 响应
return resolve(file);
};
}; // 事件
// 事件
xhr.onload = fn;
xhr.onerror = fn;
xhr.onabort = fn;
xhr.ontimeout = fn;
xhr.ontimeout = fn; // 超时
// 超时
if (file.timeout) {
xhr.timeout = file.timeout;
}
} // headers
// headers
for (var key in file.headers) {
xhr.setRequestHeader(key, file.headers[key]);
}
} // 更新 xhr
// @ts-ignore
// 更新 xhr
file = _this4.update(file, { xhr: xhr });
// 开始上传
xhr.send(body);
file = _this11.update(file, {
xhr: xhr
}); // 开始上传
file && xhr.send(body);
});
},
uploadHtml4: function uploadHtml4(_file) {
var _this5 = this;
uploadHtml4: function uploadHtml4(ufile) {
var _this12 = this;
var file = _file;
var file = ufile;
if (!file) {
return Promise.reject(new Error('not_exists'));
}
var onKeydown = function onKeydown(e) {

@@ -1804,9 +1914,5 @@ if (e.keyCode === 27) {

iframe.setAttribute('style', 'width:1px;height:1px;top:-999em;position:absolute; margin-top:-999em;');
var form = document.createElement('form');
form.action = file.postAction;
form.setAttribute('action', file.postAction || '');
form.name = 'upload-form-' + file.id;
form.setAttribute('method', 'POST');

@@ -1816,23 +1922,26 @@ form.setAttribute('target', 'upload-iframe-' + file.id);

var value = void 0;
var input = void 0;
for (var key in file.data) {
value = file.data[key];
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toString !== 'function') {
var value = file.data[key];
if (value && _typeof(value) === 'object' && typeof value.toString !== 'function') {
value = JSON.stringify(value);
}
if (value !== null && value !== undefined) {
input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
form.appendChild(input);
var el = document.createElement('input');
el.type = 'hidden';
el.name = key;
el.value = value;
form.appendChild(el);
}
}
form.appendChild(file.el);
document.body.appendChild(iframe).appendChild(form);
var getResponseData = function getResponseData() {
var doc = void 0;
var _doc;
var doc;
try {

@@ -1843,12 +1952,18 @@ if (iframe.contentWindow) {

} catch (err) {}
if (!doc) {
try {
// @ts-ignore
doc = iframe.contentDocument ? iframe.contentDocument : iframe.document;
} catch (err) {
// @ts-ignore
doc = iframe.document;
}
}
if (doc && doc.body) {
} // @ts-ignore
if ((_doc = doc) !== null && _doc !== void 0 && _doc.body) {
return doc.body.innerHTML;
}
return null;

@@ -1859,14 +1974,24 @@ };

setTimeout(function () {
file = _this5.update(file, { iframe: iframe });
// 不存在
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 定时检查
var interval = setInterval(function () {
file = _this5.get(file);
if (file && file.fileObject && !file.success && !file.error && file.active) {
return;
file = _this12.update(file, {
iframe: iframe
}); // 不存在
if (!file) {
return reject(new Error('not_exists'));
} // 定时检查
var interval = window.setInterval(function () {
if (file) {
var _file3;
file = _this12.get(file);
if (file && (_file3 = file) !== null && _file3 !== void 0 && _file3.fileObject && !file.success && !file.error && file.active) {
return;
}
}

@@ -1876,10 +2001,15 @@

clearInterval(interval);
interval = false;
}
interval = undefined;
} // @ts-ignore
iframe.onabort({ type: file ? 'abort' : 'not_exists' });
iframe.onabort({
type: file ? 'abort' : 'not_exists'
});
}, 100);
var complete;
var complete = void 0;
var fn = function fn(e) {
var _file4;
// 已经处理过了

@@ -1889,2 +2019,3 @@ if (complete) {

}
complete = true;

@@ -1894,31 +2025,38 @@

clearInterval(interval);
interval = false;
}
interval = undefined;
} // 关闭 esc 事件
// 关闭 esc 事件
document.body.removeEventListener('keydown', onKeydown);
file = _this5.get(file);
// 不存在直接响应
if (!file) {
return reject('not_exists');
return reject(new Error('not_exists'));
}
// 不是文件对象
file = _this12.get(file); // 不存在直接响应
if (!file) {
return reject(new Error('not_exists'));
} // 不是文件对象
if (!file.fileObject) {
return reject('file_object');
}
return reject(new Error('file_object'));
} // 有错误自动响应
// 有错误自动响应
if (file.error) {
return reject(file.error);
}
if (file.error instanceof Error) {
return reject(file.error);
}
// 未激活
return reject(new Error(file.error));
} // 未激活
if (!file.active) {
return reject('abort');
}
return reject(new Error('abort'));
} // 已完成 直接相应
// 已完成 直接相应
if (file.success) {

@@ -1930,2 +2068,7 @@ return resolve(file);

var data = {};
if (typeof e === 'string') {
return reject(new Error(e));
}
switch (e.type) {

@@ -1935,2 +2078,3 @@ case 'abort':

break;
case 'error':

@@ -1944,7 +2088,9 @@ if (file.error) {

}
break;
default:
if (file.error) {
data.error = file.error;
} else if (data === null) {
} else if (response === null) {
data.error = 'network';

@@ -1954,2 +2100,3 @@ } else {

}
}

@@ -1963,32 +2110,43 @@

}
data.response = response;
}
} // 更新
// 更新
file = _this5.update(file, data);
if (file.error) {
return reject(file.error);
file = _this12.update(file, data);
if (!file) {
return reject(new Error('not_exists'));
}
// 响应
if ((_file4 = file) !== null && _file4 !== void 0 && _file4.error) {
if (file.error instanceof Error) {
return reject(file.error);
}
return reject(new Error(file.error));
} // 响应
return resolve(file);
};
}; // 添加事件
// 添加事件
iframe.onload = fn;
iframe.onerror = fn;
iframe.onabort = fn;
iframe.onabort = fn; // 禁止 esc 键
// 禁止 esc 键
document.body.addEventListener('keydown', onKeydown);
document.body.addEventListener('keydown', onKeydown); // 提交
// 提交
form.submit();
}, 50);
}).then(function (res) {
iframe.parentNode && iframe.parentNode.removeChild(iframe);
var _iframe$parentNode;
iframe === null || iframe === void 0 ? void 0 : (_iframe$parentNode = iframe.parentNode) === null || _iframe$parentNode === void 0 ? void 0 : _iframe$parentNode.removeChild(iframe);
return res;
}).catch(function (res) {
iframe.parentNode && iframe.parentNode.removeChild(iframe);
var _iframe$parentNode2;
iframe === null || iframe === void 0 ? void 0 : (_iframe$parentNode2 = iframe.parentNode) === null || _iframe$parentNode2 === void 0 ? void 0 : _iframe$parentNode2.removeChild(iframe);
return res;

@@ -1998,19 +2156,26 @@ });

watchActive: function watchActive(active) {
var file = void 0;
var file;
var index = 0;
while (file = this.files[index]) {
index++;
if (!file.fileObject) ; else if (active && !this.destroy) {
if (!file.fileObject) ;else if (active && !this.destroy) {
if (this.uploading >= this.thread || this.uploading && !this.features.html5) {
break;
}
if (!file.active && !file.error && !file.success) {
this.update(file, { active: true });
this.update(file, {
active: true
});
}
} else {
if (file.active) {
this.update(file, { active: false });
this.update(file, {
active: false
});
}
}
}
if (this.uploading === 0) {

@@ -2020,4 +2185,5 @@ this.active = false;

},
watchDrop: function watchDrop(_el) {
var el = _el;
watchDrop: function watchDrop(newDrop) {
var oldDrop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
if (!this.features.drop) {

@@ -2027,3 +2193,7 @@ return;

// 移除挂载
if (newDrop === oldDrop) {
return;
} // 移除挂载
if (this.dropElement) {

@@ -2039,10 +2209,12 @@ try {

if (!el) {
el = false;
} else if (typeof el === 'string') {
el = document.querySelector(el) || this.$root.$el.querySelector(el);
} else if (el === true) {
var el = null;
if (!newDrop) ;else if (typeof newDrop === 'string') {
// @ts-ignore
var _el = document.querySelector(newDrop) || this.$root.$el.querySelector(newDrop);
} else if (newDrop === true) {
// @ts-ignore
el = this.$parent.$el;
} else {
el = newDrop;
}
this.dropElement = el;

@@ -2059,11 +2231,17 @@

onDragenter: function onDragenter(e) {
var _dt$files, _dt$types;
e.preventDefault();
if (this.dropActive) {
return;
}
if (!e.dataTransfer) {
return;
}
var dt = e.dataTransfer;
if (dt.files && dt.files.length) {
if (dt !== null && dt !== void 0 && (_dt$files = dt.files) !== null && _dt$files !== void 0 && _dt$files.length) {
this.dropActive = true;

@@ -2073,5 +2251,5 @@ } else if (!dt.types) {

} else if (dt.types.indexOf && dt.types.indexOf('Files') !== -1) {
this.dropActive = true; // @ts-ignore
} else if ((_dt$types = dt.types) !== null && _dt$types !== void 0 && _dt$types.contains && dt.types.contains('Files')) {
this.dropActive = true;
} else if (dt.types.contains && dt.types.contains('Files')) {
this.dropActive = true;
}

@@ -2081,5 +2259,8 @@ },

e.preventDefault();
if (!this.dropActive) {
return;
}
} // @ts-ignore
if (e.target.nodeName === 'HTML' || e.target === e.explicitOriginalTarget || !e.fromElement && (e.clientX <= 0 || e.clientY <= 0 || e.clientX >= window.innerWidth || e.clientY >= window.innerHeight)) {

@@ -2097,114 +2278,112 @@ this.dropActive = false;

e.preventDefault();
this.addDataTransfer(e.dataTransfer);
}
}
};
e.dataTransfer && this.addDataTransfer(e.dataTransfer);
},
inputOnChange: function (_inputOnChange) {
function inputOnChange(_x) {
return _inputOnChange.apply(this, arguments);
}
/* script */
var __vue_script__$1 = script$1;
/* template */
var __vue_render__$1 = function __vue_render__() {
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('span', { class: _vm.className }, [_vm._t("default"), _vm._v(" "), _c('label', { attrs: { "for": _vm.inputId || _vm.name } }), _vm._v(" "), _c('input-file')], 2);
};
var __vue_staticRenderFns__$1 = [];
inputOnChange.toString = function () {
return _inputOnChange.toString();
};
/* style */
var __vue_inject_styles__$1 = undefined;
/* scoped */
var __vue_scope_id__$1 = undefined;
/* module identifier */
var __vue_module_identifier__$1 = undefined;
/* functional template */
var __vue_is_functional_template__$1 = false;
/* component normalizer */
function __vue_normalize__$1(template, style, script, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
var component = (typeof script === 'function' ? script.options : script) || {};
return inputOnChange;
}(async function (e) {
var _this13 = this;
if (!component.render) {
component.render = template.render;
component.staticRenderFns = template.staticRenderFns;
component._compiled = true;
if (!(e.target instanceof HTMLInputElement)) {
return Promise.reject(new Error("not HTMLInputElement"));
}
if (functional) component.functional = true;
}
var target = e.target;
component._scopeId = scope;
var reinput = function reinput(res) {
if (target.files) {
target.value = '';
return component;
}
/* style inject */
function __vue_create_injector__$1() {
var head = document.head || document.getElementsByTagName('head')[0];
var styles = __vue_create_injector__$1.styles || (__vue_create_injector__$1.styles = {});
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
if (target.files.length && !/safari/i.test(navigator.userAgent)) {
target.type = '';
target.type = 'file';
}
} else {
var _oldInput$parentNode;
return function addStyle(id, css) {
if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present.
// ie9 fix #219
var oldInput = document.getElementById(_this13.forId);
var newInput = oldInput.cloneNode(true);
newInput.value = '';
newInput.type = 'file'; // @ts-ignore
var group = isOldIE ? css.media || 'default' : id;
var style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined });
newInput.onChange = inputOnChange;
(_oldInput$parentNode = oldInput.parentNode) === null || _oldInput$parentNode === void 0 ? void 0 : _oldInput$parentNode.replaceChild(newInput, oldInput);
_this13.$refs.input = newInput;
}
if (!style.ids.includes(id)) {
var code = css.source;
var index = style.ids.length;
return res;
};
style.ids.push(id);
return this.addInputFile(e.target).then(reinput).catch(reinput);
})
}
});
if (css.map) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
}
function render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createBlock("span", {
class: _ctx.className
}, [vue.renderSlot(_ctx.$slots, "default"), vue.createVNode("label", {
for: _ctx.forId
}, null, 8, ["for"]), vue.createVNode("input", {
ref: "input",
type: "file",
name: _ctx.name,
id: _ctx.forId,
accept: _ctx.accept,
capture: _ctx.capture,
disabled: _ctx.disabled,
webkitdirectory: _ctx.directory && _ctx.features.directory,
allowdirs: _ctx.directory && _ctx.features.directory,
directory: _ctx.directory && _ctx.features.directory,
multiple: _ctx.multiple && _ctx.features.html5,
onChange: _cache[1] || (_cache[1] = function () {
return _ctx.inputOnChange && _ctx.inputOnChange.apply(_ctx, arguments);
})
}, null, 40, ["name", "id", "accept", "capture", "disabled", "webkitdirectory", "allowdirs", "directory", "multiple"])], 2);
}
if (isOldIE) {
style.element = style.element || document.querySelector('style[data-group=' + group + ']');
}
function styleInject(css, ref) {
if (ref === void 0) ref = {};
var insertAt = ref.insertAt;
if (!style.element) {
var el = style.element = document.createElement('style');
el.type = 'text/css';
if (!css || typeof document === 'undefined') {
return;
}
if (css.media) el.setAttribute('media', css.media);
if (isOldIE) {
el.setAttribute('data-group', group);
el.setAttribute('data-next-index', '0');
}
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
head.appendChild(el);
}
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (isOldIE) {
index = parseInt(style.element.getAttribute('data-next-index'));
style.element.setAttribute('data-next-index', index + 1);
}
if (style.element.styleSheet) {
style.parts.push(code);
style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n');
} else {
var textNode = document.createTextNode(code);
var nodes = style.element.childNodes;
if (nodes[index]) style.element.removeChild(nodes[index]);
if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
}
}
};
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
/* style inject SSR */
var FileUpload = __vue_normalize__$1({ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, __vue_create_injector__$1, undefined);
var css_248z = "";
styleInject(css_248z);
script.render = render;
var FileUpload$1 = /*#__PURE__*/Object.freeze({
default: FileUpload
});
return script;
var require$$0 = ( FileUpload$1 && FileUpload ) || FileUpload$1;
var src = require$$0;
return src;
})));
//# sourceMappingURL=vue-upload-component.part.js.map

@@ -17,2 +17,24 @@

#### Vue3
``` bash
npm install vue-upload-component@next --save
```
``` js
const VueUploadComponent = require('vue-upload-component')
app.component('file-upload', VueUploadComponent)
// or
import VueUploadComponent from 'vue-upload-component'
app.component('file-upload', VueUploadComponent)
```
### Typescript
``` js
import VueUploadComponent from 'vue-upload-component/src/FileUpload.vue'
// vue-upload-component/src/types.d.ts
app.component('file-upload', VueUploadComponent)
```
### Curated

@@ -1068,3 +1090,3 @@

* **Default:** `{ html5: true, directory: false, drag: false }`
* **Default:** `{ html5: true, directory: false, drop: false }`

@@ -1075,3 +1097,3 @@ * **Usage:**

<file-upload ref="upload"></file-upload>
<span v-show="$refs.upload && $refs.upload.features.drag">Support drag and drop upload</span>
<span v-show="$refs.upload && $refs.upload.features.drop">Support drag and drop upload</span>
<span v-show="$refs.upload && $refs.upload.features.directory">Support folder upload</span>

@@ -1218,5 +1240,11 @@ <span v-show="$refs.upload && $refs.upload.features.html5">Support for HTML5</span>

* **Result:** `Promise<Array<File>>` Added list of files
* **Version:** : `>=3.0.0`
The results of Vue 2. X
* **Result:** `Array<File>` Added list of files
* **Version:** : `>=2.5.1`
* **Version:** : `<3.0.0`

@@ -1223,0 +1251,0 @@

@@ -9,7 +9,23 @@ ## 入门开始

#### Vue3
``` bash
npm install vue-upload-component@next --save
```
``` js
const VueUploadComponent = require('vue-upload-component')
Vue.component('file-upload', VueUploadComponent)
app.component('file-upload', VueUploadComponent)
// or
import VueUploadComponent from 'vue-upload-component'
app.component('file-upload', VueUploadComponent)
```
### Typescript
``` js
import VueUploadComponent from 'vue-upload-component/src/FileUpload.vue'
// vue-upload-component/src/types.d.ts
app.component('file-upload', VueUploadComponent)
```
### Curated

@@ -221,3 +237,47 @@

### 扩展分片上传
**CustomUpload.js**
```js
// import axios from 'axios'
// import VueUploadComponent from 'vue-upload-component'
// import { STORAGE_CREATE, STORAGE_UPDATE, STORAGE_UPLOAD } from 'src/urls'
//
// VueUploadComponent.props.partThread = {
// type: Number,
// default: 2,
// }
// VueUploadComponent.props.partTimeout = {
// type: String,
// default: '',
// }
//
// VueUploadComponent.Methods.partInit = async functuon (file) {
// let data = await axios({
// method: 'post',
// size: file.size,
// name: file.name,
// })
// return data
// }
// VueUploadComponent.props.customAction.default = async function (_file, component) {
// let file = _file
// let fileObject = file.file
//
// // 创建 文件
// let data = await axios({
// method: 'post',
// })
// component.partMethod, component.partAction, { user: 'me' }, {}, { size: fileObject.size, name: file.name }, {}, 2)
// file = component.update(file, { storage })
// if (!file || !file.fileObject || !file.active) {
// throw new Error('abort')
// }
// if (file.error) {
// throw new Error(file.error)
// }
//
// }
```
## 选项 / 属性

@@ -823,3 +883,3 @@

* **默认值:** `{ html5: true, directory: false, drag: false }`
* **默认值:** `{ html5: true, directory: false, drop: false }`

@@ -830,3 +890,3 @@ * **示例:**

<file-upload ref="upload"></file-upload>
<span v-show="$refs.upload && $refs.upload.features.drag">支持拖拽上传</span>
<span v-show="$refs.upload && $refs.upload.features.drop">支持拖拽上传</span>
<span v-show="$refs.upload && $refs.upload.features.directory">支持文件夹上传</span>

@@ -973,5 +1033,13 @@ <span v-show="$refs.upload && $refs.upload.features.html5">支持HTML5</span>

* **结果:** `Promise<Array<File>>` 返回已添加的文件列表
* **版本:** : `>=3.0.0`
* **结果:** `Promise<Array<File>>` 返回已添加的文件列表
vue 2.x 的结果
* **结果:** `Array<File>` 返回已添加的文件列表
* **版本:** : `>=2.5.1`
* **版本:** : `<=3.0.0`

@@ -978,0 +1046,0 @@

@@ -1,10 +0,8 @@

// import Vue from 'vue'
import VueI18n from 'vue-i18n'
import {createI18n} from 'vue-i18n'
import en from './en'
import zhCN from './zh-cn'
// Vue.use(VueI18n)
export default new VueI18n({
export default createI18n({
locale: 'en',
fallbackLocale: 'en',
messages: {

@@ -11,0 +9,0 @@ 'zh-cn': zhCN,

@@ -1,3 +0,2 @@

// import Vue from 'vue'
import VueRouter from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'

@@ -18,6 +17,5 @@ import i18n from './i18n'

// console.log(i18n)
// Vue.use(VueRouter)
let examples = [

@@ -33,2 +31,6 @@ {

{
path: '',
component: SimpleExampleComponent,
},
{
path: 'simple',

@@ -60,6 +62,4 @@ component: SimpleExampleComponent,

const router = new VueRouter({
mode: 'hash',
fallback: false,
const router = createRouter({
history: createWebHashHistory(),
scrollBehavior(to, from, savedPosition) {

@@ -69,4 +69,3 @@ if (savedPosition) {

} else if (to.hash) {
let el = document.querySelector(to.hash)
return { x: 0, y: el ? el.offsetTop : 0 }
return { el: to.hash, top: document.querySelector('#header').offsetHeight }
} else {

@@ -78,3 +77,3 @@ return { x: 0, y: 0 }

{
path: '/:locale(' + Object.keys(i18n.messages).join('|') + ')?',
path: '/:locale(' + i18n.global.availableLocales.join('|') + ')?',
component: RouterComponent,

@@ -81,0 +80,0 @@ children: [

@@ -1,5 +0,2 @@

// import Vue from 'vue'
import Vuex from 'vuex'
//
// Vue.use(Vuex)
import { createStore } from 'vuex'

@@ -16,3 +13,3 @@

}
export default new Vuex.Store({
export default createStore({
strict: true,

@@ -19,0 +16,0 @@ state,

{
"name": "vue-upload-component",
"description": "Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter",
"version": "2.8.20",
"version": "3.0.36",
"author": "LianYue",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server",
"build": "npm run build-webpack && npm run build-rollup",
"build-webpack": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"build-rollup": "cross-env NODE_ENV=production rollup --config"
"dev": "cross-env NODE_ENV=development webpack serve --hot",
"build": "npm run build-rollup && npm run build-webpack",
"build-webpack": "cross-env NODE_ENV=production webpack --progress",
"build-rollup": "cross-env NODE_ENV=production rollup --config && mv ./dist/dist/vue-upload-component.part.css ./dist/vue-upload-component.part.css && rmdir ./dist/dist"
},

@@ -16,3 +16,3 @@ "main": "dist/vue-upload-component.js",

"jsdelivr": "dist/vue-upload-component.js",
"typings": "index.d.ts",
"typings": "src/types.d.ts",
"repository": {

@@ -24,2 +24,4 @@ "type": "git",

"javascript",
"vue3",
"vue 3",
"vue",

@@ -48,40 +50,52 @@ "vue.js",

"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-loader": "^7.1.5",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.26.0",
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"eslint": "^5.1.0",
"eslint-config-standard": "^11.0.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-html": "^4.0.5",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.7.0",
"postcss": "^7.0.0",
"raw-loader": "^0.5.1",
"rollup": "^0.63.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-css-only": "^0.4.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^4.0.0",
"rollup-plugin-vue": "^4.3.1",
"vue-hot-reload-api": "^2.3.0",
"vue-loader": "^15.2.5",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.16.1",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.9",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.7",
"@babel/runtime": "^7.12.5",
"@babel/runtime-corejs2": "^7.12.5",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"@vue/compiler-sfc": "^3.0.4",
"@vue/eslint-config-typescript": "^7.0.0",
"babel-loader": "^8.2.2",
"cross-env": "^7.0.2",
"css-loader": "^5.0.1",
"eslint": "^7.14.0",
"eslint-config-alloy": "^3.8.2",
"eslint-config-prettier": "^6.15.0",
"eslint-config-standard": "^16.0.2",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^7.1.0",
"html-loader": "^1.3.2",
"html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.3.3",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"prettier": "^2.2.1",
"raw-loader": "^4.0.2",
"rollup": "^2.35.1",
"rollup-plugin-css-only": "^3.0.0",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-uglify": "^6.0.4",
"rollup-plugin-vue": "^6.0.0",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.12",
"typescript": "^4.1.3",
"vue": "^3.0.4",
"vue-i18n": "^9.0.0-beta.12",
"vue-loader": "^16.1.1",
"vue-router": "^4.0.1",
"vuex": "^4.0.0-rc.2",
"webpack": "^5.10.0",
"webpack-body-parser": "^1.11.110",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-merge": "^4.1.3"
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0",
"webpack-env": "^0.8.0"
}
}
}

@@ -31,2 +31,6 @@ # vue-upload-component

```
## Vue3
``` bash
npm install vue-upload-component@next --save
```

@@ -43,3 +47,3 @@ # Documentation

> Vue.js 文件上传组建
> Vue.js 文件上传组件
> 组件只是一个按钮

@@ -68,2 +72,6 @@

```
## Vue3
``` bash
npm install vue-upload-component@next --save
```

@@ -70,0 +78,0 @@ # 文档

@@ -1,20 +0,27 @@

import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import path from 'path'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { babel, getBabelOutputPlugin } from '@rollup/plugin-babel';
import { uglify } from 'rollup-plugin-uglify'
import postcss from 'rollup-plugin-postcss'
import vue from 'rollup-plugin-vue'
import packageInfo from './package.json'
import typescript from 'rollup-plugin-typescript2';
const pluginCSS = require('rollup-plugin-css-only')
// const isDev = process.env.NODE_ENV === 'development'
function baseConfig() {
return {
function baseConfig(css, ssr, umd, min) {
let res = {
input: 'src/FileUpload.vue',
output: {
format: 'umd',
format: umd ? 'umd' : 'esm',
// format: 'iife',
sourcemap: true,
banner: `/*!\n * Name: ${packageInfo.name}\n * Version: ${packageInfo.version}\n * Author: ${packageInfo.author}\n */`,
banner: umd ? `/*!\n Name: ${ packageInfo.name } \nComponent URI: ${ packageInfo.homepage } \nVersion: ${ packageInfo.version } \nAuthor: ${ packageInfo.author } \nLicense: ${ packageInfo.license } \nDescription: ${ packageInfo.description } \n */` : '',
globals: {
vue: 'Vue',
},
name: "VueUploadComponent",
},
external: ['vue'],
plugins: [

@@ -26,8 +33,36 @@ resolve({

}),
css && pluginCSS(),
vue({
preprocessStyles: true,
css: css,
target: ssr ? 'node' : 'browser',
}),
typescript({
check: true,
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
}),
postcss(),
ssr || umd ? false : babel({
exclude: 'node_modules/**'
}),
ssr || umd ? false : getBabelOutputPlugin({
"presets": [
["@babel/preset-env", { "modules": false, "useBuiltIns": false, "targets": "ie >= 9", "exclude": ["transform-async-to-generator", "proposal-async-generator-functions", "transform-regenerator"] }]
],
"sourceType": "unambiguous",
"plugins": [
["@babel/plugin-transform-runtime", { "helpers": false, "corejs": false, "regenerator": false, "useESModules": false, "absoluteRuntime": false }]
],
}),
min ? uglify({
output: {
comments: /^!/,
}
}): false,
commonjs({
extensions: [
'.js',
'.jsx',
'.json',
// '.vue'
'.ts',
'.vue'
],

@@ -37,64 +72,39 @@ }),

}
return res
}
let config = baseConfig()
config.input = 'src/index.js'
let config = baseConfig(false, false)
config.output.file = 'dist/vue-upload-component.js'
config.output.name = 'VueUploadComponent'
config.plugins.push(
vue({
template: {
isProduction: true,
},
css: true,
}),
babel()
)
let configMin = baseConfig()
configMin.input = 'src/index.js'
let configPart = baseConfig(true, false)
configPart.output.file = 'dist/vue-upload-component.part.js'
let configSSR = baseConfig(false, true, true)
configSSR.output.file = 'dist/vue-upload-component.ssr.js'
let configUmd = baseConfig(false, false, true)
configUmd.input = config.output.file
configUmd.output.file = config.output.file
let configPartUmd = baseConfig(false, false, true)
configPartUmd.input = configPart.output.file
configPartUmd.output.file = configPart.output.file
let configMin = baseConfig(false, false, true, true)
configMin.input = config.output.file
configMin.output.file = 'dist/vue-upload-component.min.js'
configMin.output.name = 'VueUploadComponent'
configMin.plugins.push(
vue({
style: {
trim: true,
},
template: {
isProduction: true,
},
css: true,
}),
babel(),
uglify({
output: {
comments: /^!/,
}
})
)
let configPart = baseConfig()
configPart.input = 'src/index.js'
configPart.output.file = 'dist/vue-upload-component.part.js'
configPart.output.name = 'VueUploadComponent'
configPart.plugins.push(
pluginCSS(),
vue({
style: {
trim: true,
},
template: {
isProduction: true,
},
css: false,
}),
babel()
)
module.exports = [
config,
configPart,
configSSR,
configUmd,
configPartUmd,
configMin,
configPart,
]

@@ -17,3 +17,6 @@ import {

this.options = options
}
this.chunks = []
this.sessionId = null
this.chunkSize = null
}

@@ -24,3 +27,3 @@ /**

get maxRetries () {
return parseInt(this.options.maxRetries)
return parseInt(this.options.maxRetries, 10)
}

@@ -32,3 +35,3 @@

get maxActiveChunks () {
return parseInt(this.options.maxActive)
return parseInt(this.options.maxActive, 10)
}

@@ -117,2 +120,3 @@

get chunksToUpload () {
console.log(this.chunks)
return this.chunks.filter(chunk => {

@@ -229,7 +233,9 @@ return !chunk.active && !chunk.uploaded

method: 'POST',
headers: Object.assign({}, this.headers, {
headers: {
...this.headers,
'Content-Type': 'application/json'
}),
},
url: this.action,
body: Object.assign(this.startBody, {
body: {
...this.startBody,
phase: 'start',

@@ -239,3 +245,3 @@ mime_type: this.fileType,

name: this.fileName
})
}
}).then(res => {

@@ -309,3 +315,4 @@ if (res.status !== 'success') {

sendFormRequest(chunk.xhr, Object.assign(this.uploadBody, {
sendFormRequest(chunk.xhr, {
...this.uploadBody,
phase: 'upload',

@@ -315,3 +322,3 @@ session_id: this.sessionId,

chunk: chunk.blob
})).then(res => {
}).then(res => {
chunk.active = false

@@ -348,10 +355,12 @@ if (res.status === 'success') {

method: 'POST',
headers: Object.assign({}, this.headers, {
headers: {
...this.headers,
'Content-Type': 'application/json'
}),
},
url: this.action,
body: Object.assign(this.finishBody, {
body: {
...this.finishBody,
phase: 'finish',
session_id: this.sessionId
})
session_id: this.sessionId,
}
}).then(res => {

@@ -358,0 +367,0 @@ this.file.response = res

@@ -29,3 +29,3 @@ /**

if (xhr.status >= 200 && xhr.status < 300) {
var response
let response
try {

@@ -54,3 +54,3 @@ response = JSON.parse(xhr.response)

const body = new FormData()
for (var name in data) {
for (let name in data) {
body.append(name, data[name])

@@ -62,3 +62,3 @@ }

if (xhr.status >= 200 && xhr.status < 300) {
var response
let response
try {

@@ -65,0 +65,0 @@ response = JSON.parse(xhr.response)

@@ -1,197 +0,32 @@

const path = require('path')
const merge = require('webpack-merge')
const webpack = require('webpack')
/* eslint @typescript-eslint/no-require-imports: 0 */
const packageInfo = require('./package')
const bodyParser = require('webpack-body-parser')
const chunkUpload = require('./src/utils/chunkUpload')
const { VueLoaderPlugin } = require('vue-loader')
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const chunkUpload = require('./src/utils/chunkUpload')
const bodyParser = require('webpack-body-parser')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const packageInfo = require('./package.json')
const { VueLoaderPlugin } = require('vue-loader')
const isDev = process.env.NODE_ENV === 'development'
function baseConfig() {
let config = {
mode: process.env.NODE_ENV === 'development' ? 'development' : 'production',
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/dist',
filename: '[name].js',
chunkFilename: '[chunkhash:8].[name].chunk.js',
},
const IsCssExtract = !isDev
resolve: {
modules: [
path.join(__dirname, 'node_modules'),
],
alias: {
'vue-upload-component': path.join(__dirname, 'src'),
},
extensions: [
'.js',
'.jsx',
'.json',
'.vue',
'.md',
],
},
externals: {
vue: 'Vue',
vuex: 'Vuex',
'vue-router': 'VueRouter',
'vue-i18n': 'VueI18n',
'marked': 'marked',
'highlight.js': 'hljs',
'cropperjs': 'Cropper',
'@xkeshi/image-compressor': 'ImageCompressor',
},
module: {
rules: [
{
test: /\.jsx?$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'env',
{
modules: false
}
],
'stage-0',
],
plugins: [
[
'transform-runtime',
{
helpers: false,
polyfill: false,
regenerator: true,
moduleName: 'babel-runtime'
}
]
],
cacheDirectory: isDev
},
},
{
loader: 'eslint-loader',
},
],
},
{
test: /\.(md|txt)$/,
use: [
{
loader: 'raw-loader',
},
]
},
{
test: /\.css$/,
use: [
{
loader: 'vue-style-loader',
},
{
loader: 'css-loader',
options: {
minimize: !isDev,
},
},
]
},
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
preserveWhitespace: false,
cssModules: {
localIdentName: '[hash:base64:8]',
camelCase: true,
},
},
},
],
},
/*
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
preserveWhitespace: false,
loaders: {
js: [
{
loader: 'babel-loader',
options: {
presets: [
[
'env',
{
modules: false
}
],
'stage-0'
],
plugins: [
[
'transform-runtime',
{
helpers: false,
polyfill: false,
regenerator: true,
moduleName: 'babel-runtime'
}
]
],
cacheDirectory: isDev
}
},
],
}
},
},
{
loader: 'eslint-loader',
},
]
}
*/
]
},
plugins: [
new webpack.BannerPlugin(`Name: ${packageInfo.name}\nVersion: ${packageInfo.version}\nAuthor: ${packageInfo.author}`),
new VueLoaderPlugin(),
],
devtool: isDev ? 'eval-source-map' : 'source-map'
}
if (isDev) {
config.plugins.push(new webpack.HotModuleReplacementPlugin())
}
return config
if (!isDev) {
let version = packageInfo.version.split('.');
version[version.length - 1] = parseInt(version[version.length - 1], 10) + 1;
packageInfo.version = version.join('.');
fs.writeFileSync('./package.json', JSON.stringify(packageInfo, null, 2), { flags: 'utf8' })
}
module.exports = {
mode: process.env.NODE_ENV,
devtool: isDev ? 'eval-source-map' : 'source-map',
module.exports = merge(baseConfig(), {
entry: {
index: [
path.join(__dirname, 'docs/index.js'),
docs: [
path.join(__dirname, 'docs/entry.js'),
],

@@ -201,6 +36,48 @@ },

output: {
path: path.join(__dirname, 'docs/dist'),
path: __dirname,
publicPath: '/',
filename: 'docs/dist/[name].js',
chunkFilename: 'docs/dist/[chunkhash:8].[name].chunk.js',
},
resolve: {
modules: [
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'docs'),
],
alias: {
// "vue": "@vue/runtime-dom",
"@": path.join(__dirname, 'src'),
"@/": path.join(__dirname, 'src/'),
'vue-upload-component': path.join(__dirname, isDev && false ? 'src' : 'dist/vue-upload-component.js'),
},
extensions: [
'.js',
'.ts',
'.tsx',
'.json',
'.vue',
'.md',
],
},
externals: {
// vue: 'Vue',
// vuex: 'Vuex',
// 'vue-router': 'VueRouter',
// 'vue-i18n': 'VueI18n',
'marked': 'marked',
'highlight.js': 'hljs',
'cropperjs': 'Cropper',
'@xkeshi/image-compressor': 'ImageCompressor',
},
// cache: false,
devServer: {
inline: true,
hot: true,
liveReload: true,
overlay: true,
disableHostCheck: true,
watchOptions: {
poll: true
},
before(app) {

@@ -235,15 +112,126 @@ let id = 1000000

// host: '0.0.0.0',
hot: true,
contentBase: path.join(__dirname, 'docs'),
contentBase: __dirname,
clientLogLevel: 'error',
noInfo: true,
publicPath: '/dist',
inline: true,
publicPath: '/',
historyApiFallback: true,
overlay: {
warnings: true,
errors: true
},
// host: '172.16.23.1'
},
})
target: 'web',
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
compilerOptions: {
whitespace: 'condense',
},
transpileOptions: {
transforms: {
dangerousTaggedTemplateString: true
}
},
},
}
],
},
{
test: /\.html?$/,
use: [
{
loader: 'html-loader',
}
]
},
{
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
},
{
loader: 'eslint-loader',
},
],
},
{
test: /\.(md|txt)$/,
use: [
{
loader: 'raw-loader',
},
]
},
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.(vue|tsx?)$/],
}
},
{
loader: 'eslint-loader',
}
],
},
{
test: /(\.css)$/,
use: [
{
loader: 'style-loader',
},
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
],
},
]
},
plugins: [
// new webpack.HotModuleReplacementPlugin(),
new webpack.BannerPlugin(`Name: ${packageInfo.name}\nComponent URI: ${packageInfo.homepage}\nVersion: ${packageInfo.version}\nAuthor: ${packageInfo.author}\nLicense: ${packageInfo.license}\nDescription: ${packageInfo.description}`),
new webpack.DefinePlugin({
'process.version': JSON.stringify(packageInfo.version),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: true,
}),
// new MiniCssExtractPlugin({
// filename: 'assets/[name].css',
// chunkFilename: 'assets/[name].[id].css',
// }),
new VueLoaderPlugin(),
new OptimizeCssAssetsPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, 'docs/index.template.html'),
minify: {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
html5: true,
},
xhtml: true,
inlineSource: '.(js|css)$',
}),
],
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc