@uppy/utils
Advanced tools
Comparing version 3.6.2 to 4.0.0-alpha.0
@@ -0,25 +1,9 @@ | ||
"use strict"; | ||
/** | ||
* Little AbortController proxy module so we can swap out the implementation easily later. | ||
*/ | ||
var _require = require('abortcontroller-polyfill/dist/abortcontroller'), | ||
AbortController = _require.AbortController, | ||
AbortSignal = _require.AbortSignal; | ||
function createAbortError(message) { | ||
if (message === void 0) { | ||
message = 'Aborted'; | ||
} | ||
try { | ||
return new DOMException(message, 'AbortError'); | ||
} catch (_unused) { | ||
// For Internet Explorer | ||
var error = new Error(message); | ||
error.name = 'AbortError'; | ||
return error; | ||
} | ||
} | ||
exports.AbortController = AbortController; | ||
exports.AbortSignal = AbortSignal; | ||
exports.createAbortError = createAbortError; | ||
exports.createAbortError = (message = 'Aborted') => new DOMException(message, 'AbortError'); |
@@ -1,2 +0,4 @@ | ||
var dataURItoBlob = require('./dataURItoBlob'); | ||
"use strict"; | ||
const dataURItoBlob = require('./dataURItoBlob'); | ||
/** | ||
@@ -12,3 +14,3 @@ * Save a <canvas> element's content to a Blob object. | ||
if (canvas.toBlob) { | ||
return new Promise(function (resolve) { | ||
return new Promise(resolve => { | ||
canvas.toBlob(resolve, type, quality); | ||
@@ -18,5 +20,5 @@ }); | ||
return Promise.resolve().then(function () { | ||
return Promise.resolve().then(() => { | ||
return dataURItoBlob(canvas.toDataURL(type, quality), {}); | ||
}); | ||
}; |
@@ -0,6 +1,8 @@ | ||
"use strict"; | ||
module.exports = function dataURItoBlob(dataURI, opts, toFile) { | ||
// get the base64 data | ||
var data = dataURI.split(',')[1]; // user may provide mime type, if not get it from data URI | ||
const data = dataURI.split(',')[1]; // user may provide mime type, if not get it from data URI | ||
var mimeType = opts.mimeType || dataURI.split(',')[0].split(':')[1].split(';')[0]; // default to plain/text if data URI has no mimeType | ||
let mimeType = opts.mimeType || dataURI.split(',')[0].split(':')[1].split(';')[0]; // default to plain/text if data URI has no mimeType | ||
@@ -11,13 +13,13 @@ if (mimeType == null) { | ||
var binary = atob(data); | ||
var array = []; | ||
const binary = atob(data); | ||
const array = []; | ||
for (var i = 0; i < binary.length; i++) { | ||
for (let i = 0; i < binary.length; i++) { | ||
array.push(binary.charCodeAt(i)); | ||
} | ||
var bytes; | ||
let bytes; | ||
try { | ||
bytes = new Uint8Array(array); // eslint-disable-line compat/compat | ||
bytes = new Uint8Array(array); | ||
} catch (err) { | ||
@@ -24,0 +26,0 @@ return null; |
@@ -1,5 +0,7 @@ | ||
var dataURItoBlob = require('./dataURItoBlob'); | ||
"use strict"; | ||
const dataURItoBlob = require('./dataURItoBlob'); | ||
module.exports = function dataURItoFile(dataURI, opts) { | ||
return dataURItoBlob(dataURI, opts, true); | ||
}; |
@@ -1,3 +0,6 @@ | ||
var _require = require('./AbortController'), | ||
createAbortError = _require.createAbortError; | ||
"use strict"; | ||
const { | ||
createAbortError | ||
} = require('./AbortController'); | ||
/** | ||
@@ -13,3 +16,3 @@ * Return a Promise that resolves after `ms` milliseconds. | ||
module.exports = function delay(ms, opts) { | ||
return new Promise(function (resolve, reject) { | ||
return new Promise((resolve, reject) => { | ||
if (opts && opts.signal && opts.signal.aborted) { | ||
@@ -25,3 +28,3 @@ return reject(createAbortError()); | ||
var timeout = setTimeout(function () { | ||
const timeout = setTimeout(() => { | ||
cleanup(); | ||
@@ -28,0 +31,0 @@ resolve(); |
@@ -1,14 +0,18 @@ | ||
var throttle = require('lodash.throttle'); | ||
"use strict"; | ||
const throttle = require('lodash.throttle'); | ||
function _emitSocketProgress(uploader, progressData, file) { | ||
var progress = progressData.progress, | ||
bytesUploaded = progressData.bytesUploaded, | ||
bytesTotal = progressData.bytesTotal; | ||
const { | ||
progress, | ||
bytesUploaded, | ||
bytesTotal | ||
} = progressData; | ||
if (progress) { | ||
uploader.uppy.log("Upload progress: " + progress); | ||
uploader.uppy.log(`Upload progress: ${progress}`); | ||
uploader.uppy.emit('upload-progress', file, { | ||
uploader: uploader, | ||
bytesUploaded: bytesUploaded, | ||
bytesTotal: bytesTotal | ||
uploader, | ||
bytesUploaded, | ||
bytesTotal | ||
}); | ||
@@ -15,0 +19,0 @@ } |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -5,4 +7,4 @@ * Create a wrapper around an event emitter with a `remove` method to remove | ||
*/ | ||
module.exports = /*#__PURE__*/function () { | ||
function EventTracker(emitter) { | ||
module.exports = class EventTracker { | ||
constructor(emitter) { | ||
this._events = []; | ||
@@ -12,22 +14,14 @@ this._emitter = emitter; | ||
var _proto = EventTracker.prototype; | ||
_proto.on = function on(event, fn) { | ||
on(event, fn) { | ||
this._events.push([event, fn]); | ||
return this._emitter.on(event, fn); | ||
}; | ||
} | ||
_proto.remove = function remove() { | ||
var _this = this; | ||
this._events.forEach(function (_ref) { | ||
var event = _ref[0], | ||
fn = _ref[1]; | ||
_this._emitter.off(event, fn); | ||
remove() { | ||
this._events.forEach(([event, fn]) => { | ||
this._emitter.off(event, fn); | ||
}); | ||
}; | ||
} | ||
return EventTracker; | ||
}(); | ||
}; |
@@ -1,2 +0,4 @@ | ||
var NetworkError = require('./NetworkError'); | ||
"use strict"; | ||
const NetworkError = require('./NetworkError'); | ||
/** | ||
@@ -7,4 +9,4 @@ * Wrapper around window.fetch that throws a NetworkError when appropriate | ||
module.exports = function fetchWithNetworkError() { | ||
return fetch.apply(void 0, arguments).catch(function (err) { | ||
module.exports = function fetchWithNetworkError(...options) { | ||
return fetch(...options).catch(err => { | ||
if (err.name === 'AbortError') { | ||
@@ -11,0 +13,0 @@ throw err; |
@@ -1,2 +0,4 @@ | ||
var isDOMElement = require('./isDOMElement'); | ||
"use strict"; | ||
const isDOMElement = require('./isDOMElement'); | ||
/** | ||
@@ -12,3 +14,3 @@ * Find one or more DOM elements. | ||
if (typeof element === 'string') { | ||
var elements = [].slice.call(document.querySelectorAll(element)); | ||
const elements = [].slice.call(document.querySelectorAll(element)); | ||
return elements.length > 0 ? elements : null; | ||
@@ -15,0 +17,0 @@ } |
@@ -1,2 +0,4 @@ | ||
var isDOMElement = require('./isDOMElement'); | ||
"use strict"; | ||
const isDOMElement = require('./isDOMElement'); | ||
/** | ||
@@ -10,7 +12,3 @@ * Find a DOM element. | ||
module.exports = function findDOMElement(element, context) { | ||
if (context === void 0) { | ||
context = document; | ||
} | ||
module.exports = function findDOMElement(element, context = document) { | ||
if (typeof element === 'string') { | ||
@@ -17,0 +15,0 @@ return context.querySelector(element); |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -9,3 +11,3 @@ * Array.prototype.findIndex ponyfill for old browsers. | ||
module.exports = function findIndex(array, predicate) { | ||
for (var i = 0; i < array.length; i++) { | ||
for (let i = 0; i < array.length; i++) { | ||
if (predicate(array[i])) return i; | ||
@@ -12,0 +14,0 @@ } |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
module.exports = ['a[href]:not([tabindex^="-"]):not([inert]):not([aria-hidden])', 'area[href]:not([tabindex^="-"]):not([inert]):not([aria-hidden])', 'input:not([disabled]):not([inert]):not([aria-hidden])', 'select:not([disabled]):not([inert]):not([aria-hidden])', 'textarea:not([disabled]):not([inert]):not([aria-hidden])', 'button:not([disabled]):not([inert]):not([aria-hidden])', 'iframe:not([tabindex^="-"]):not([inert]):not([aria-hidden])', 'object:not([tabindex^="-"]):not([inert]):not([aria-hidden])', 'embed:not([tabindex^="-"]):not([inert]):not([aria-hidden])', '[contenteditable]:not([tabindex^="-"]):not([inert]):not([aria-hidden])', '[tabindex]:not([tabindex^="-"]):not([inert]):not([aria-hidden])']; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -11,22 +13,22 @@ * Takes a file object and turns it into fileID, by converting file.name to lowercase, | ||
// is slower! simple string concatenation is fast | ||
var id = 'uppy'; | ||
let id = 'uppy'; | ||
if (typeof file.name === 'string') { | ||
id += "-" + encodeFilename(file.name.toLowerCase()); | ||
id += `-${encodeFilename(file.name.toLowerCase())}`; | ||
} | ||
if (file.type !== undefined) { | ||
id += "-" + file.type; | ||
id += `-${file.type}`; | ||
} | ||
if (file.meta && typeof file.meta.relativePath === 'string') { | ||
id += "-" + encodeFilename(file.meta.relativePath.toLowerCase()); | ||
id += `-${encodeFilename(file.meta.relativePath.toLowerCase())}`; | ||
} | ||
if (file.data.size !== undefined) { | ||
id += "-" + file.data.size; | ||
id += `-${file.data.size}`; | ||
} | ||
if (file.data.lastModified !== undefined) { | ||
id += "-" + file.data.lastModified; | ||
id += `-${file.data.lastModified}`; | ||
} | ||
@@ -38,5 +40,5 @@ | ||
function encodeFilename(name) { | ||
var suffix = ''; | ||
return name.replace(/[^A-Z0-9]/ig, function (character) { | ||
suffix += "-" + encodeCharacter(character); | ||
let suffix = ''; | ||
return name.replace(/[^A-Z0-9]/ig, character => { | ||
suffix += `-${encodeCharacter(character)}`; | ||
return '/'; | ||
@@ -43,0 +45,0 @@ }) + suffix; |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
module.exports = function getBytesRemaining(fileProgress) { | ||
return fileProgress.bytesTotal - fileProgress.bytesUploaded; | ||
}; |
@@ -1,4 +0,6 @@ | ||
var webkitGetAsEntryApi = require('./utils/webkitGetAsEntryApi/index'); | ||
"use strict"; | ||
var fallbackApi = require('./utils/fallbackApi'); | ||
const webkitGetAsEntryApi = require('./utils/webkitGetAsEntryApi/index'); | ||
const fallbackApi = require('./utils/fallbackApi'); | ||
/** | ||
@@ -15,7 +17,5 @@ * Returns a promise that resolves to the array of dropped files (if a folder is dropped, and browser supports folder parsing - promise resolves to the flat array of all files in all directories). | ||
module.exports = function getDroppedFiles(dataTransfer, _temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$logDropError = _ref.logDropError, | ||
logDropError = _ref$logDropError === void 0 ? function () {} : _ref$logDropError; | ||
module.exports = function getDroppedFiles(dataTransfer, { | ||
logDropError = () => {} | ||
} = {}) { | ||
// Get all files from all subdirs. Works (at least) in Chrome, Mozilla, and Safari | ||
@@ -22,0 +22,0 @@ if (dataTransfer.items && dataTransfer.items[0] && 'webkitGetAsEntry' in dataTransfer.items[0]) { |
@@ -1,7 +0,9 @@ | ||
var toArray = require('../../toArray'); // .files fallback, should be implemented in any browser | ||
"use strict"; | ||
const toArray = require('../../toArray'); // .files fallback, should be implemented in any browser | ||
module.exports = function fallbackApi(dataTransfer) { | ||
var files = toArray(dataTransfer.files); | ||
const files = toArray(dataTransfer.files); | ||
return Promise.resolve(files); | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -9,11 +11,12 @@ * Recursive function, calls the original callback() when the directory is entirely parsed. | ||
*/ | ||
module.exports = function getFilesAndDirectoriesFromDirectory(directoryReader, oldEntries, logDropError, _ref) { | ||
var onSuccess = _ref.onSuccess; | ||
directoryReader.readEntries(function (entries) { | ||
var newEntries = [].concat(oldEntries, entries); // According to the FileSystem API spec, getFilesAndDirectoriesFromDirectory() must be called until it calls the onSuccess with an empty array. | ||
module.exports = function getFilesAndDirectoriesFromDirectory(directoryReader, oldEntries, logDropError, { | ||
onSuccess | ||
}) { | ||
directoryReader.readEntries(entries => { | ||
const newEntries = [...oldEntries, ...entries]; // According to the FileSystem API spec, getFilesAndDirectoriesFromDirectory() must be called until it calls the onSuccess with an empty array. | ||
if (entries.length) { | ||
setTimeout(function () { | ||
setTimeout(() => { | ||
getFilesAndDirectoriesFromDirectory(directoryReader, newEntries, logDropError, { | ||
onSuccess: onSuccess | ||
onSuccess | ||
}); | ||
@@ -25,3 +28,3 @@ }, 0); // Done iterating this particular directory | ||
}, // Make sure we resolve on error anyway, it's fine if only one directory couldn't be parsed! | ||
function (error) { | ||
error => { | ||
logDropError(error); | ||
@@ -28,0 +31,0 @@ onSuccess(oldEntries); |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -11,3 +13,3 @@ * Get the relative path from the FileEntry#fullPath, because File#webkitRelativePath is always '', at least onDrop. | ||
// fileEntry.name - "hi.jpeg" | ||
if (!fileEntry.fullPath || fileEntry.fullPath === "/" + fileEntry.name) { | ||
if (!fileEntry.fullPath || fileEntry.fullPath === `/${fileEntry.name}`) { | ||
return null; | ||
@@ -14,0 +16,0 @@ } |
@@ -1,10 +0,12 @@ | ||
var toArray = require('../../../toArray'); | ||
"use strict"; | ||
var getRelativePath = require('./getRelativePath'); | ||
const toArray = require('../../../toArray'); | ||
var getFilesAndDirectoriesFromDirectory = require('./getFilesAndDirectoriesFromDirectory'); | ||
const getRelativePath = require('./getRelativePath'); | ||
const getFilesAndDirectoriesFromDirectory = require('./getFilesAndDirectoriesFromDirectory'); | ||
module.exports = function webkitGetAsEntryApi(dataTransfer, logDropError) { | ||
var files = []; | ||
var rootPromises = []; | ||
const files = []; | ||
const rootPromises = []; | ||
/** | ||
@@ -17,35 +19,29 @@ * Returns a resolved promise, when :files array is enhanced | ||
var createPromiseToAddFileOrParseDirectory = function createPromiseToAddFileOrParseDirectory(entry) { | ||
return new Promise(function (resolve) { | ||
// This is a base call | ||
if (entry.isFile) { | ||
// Creates a new File object which can be used to read the file. | ||
entry.file(function (file) { | ||
file.relativePath = getRelativePath(entry); | ||
files.push(file); | ||
resolve(); | ||
}, // Make sure we resolve on error anyway, it's fine if only one file couldn't be read! | ||
function (error) { | ||
logDropError(error); | ||
resolve(); | ||
}); // This is a recursive call | ||
} else if (entry.isDirectory) { | ||
var directoryReader = entry.createReader(); | ||
getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, { | ||
onSuccess: function onSuccess(entries) { | ||
var promises = entries.map(function (entry) { | ||
return createPromiseToAddFileOrParseDirectory(entry); | ||
}); | ||
Promise.all(promises).then(function () { | ||
return resolve(); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}; // For each dropped item, - make sure it's a file/directory, and start deepening in! | ||
const createPromiseToAddFileOrParseDirectory = entry => new Promise(resolve => { | ||
// This is a base call | ||
if (entry.isFile) { | ||
// Creates a new File object which can be used to read the file. | ||
entry.file(file => { | ||
file.relativePath = getRelativePath(entry); | ||
files.push(file); | ||
resolve(); | ||
}, // Make sure we resolve on error anyway, it's fine if only one file couldn't be read! | ||
error => { | ||
logDropError(error); | ||
resolve(); | ||
}); // This is a recursive call | ||
} else if (entry.isDirectory) { | ||
const directoryReader = entry.createReader(); | ||
getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, { | ||
onSuccess: entries => { | ||
const promises = entries.map(entry => createPromiseToAddFileOrParseDirectory(entry)); | ||
Promise.all(promises).then(() => resolve()); | ||
} | ||
}); | ||
} | ||
}); // For each dropped item, - make sure it's a file/directory, and start deepening in! | ||
toArray(dataTransfer.items).forEach(function (item) { | ||
var entry = item.webkitGetAsEntry(); // :entry can be null when we drop the url e.g. | ||
toArray(dataTransfer.items).forEach(item => { | ||
const entry = item.webkitGetAsEntry(); // :entry can be null when we drop the url e.g. | ||
@@ -56,5 +52,3 @@ if (entry) { | ||
}); | ||
return Promise.all(rootPromises).then(function () { | ||
return files; | ||
}); | ||
return Promise.all(rootPromises).then(() => files); | ||
}; |
@@ -1,11 +0,13 @@ | ||
var getSpeed = require('./getSpeed'); | ||
"use strict"; | ||
var getBytesRemaining = require('./getBytesRemaining'); | ||
const getSpeed = require('./getSpeed'); | ||
const getBytesRemaining = require('./getBytesRemaining'); | ||
module.exports = function getETA(fileProgress) { | ||
if (!fileProgress.bytesUploaded) return 0; | ||
var uploadSpeed = getSpeed(fileProgress); | ||
var bytesRemaining = getBytesRemaining(fileProgress); | ||
var secondsRemaining = Math.round(bytesRemaining / uploadSpeed * 10) / 10; | ||
const uploadSpeed = getSpeed(fileProgress); | ||
const bytesRemaining = getBytesRemaining(fileProgress); | ||
const secondsRemaining = Math.round(bytesRemaining / uploadSpeed * 10) / 10; | ||
return secondsRemaining; | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -8,3 +10,3 @@ * Takes a full filename string and returns an object {name, extension} | ||
module.exports = function getFileNameAndExtension(fullFileName) { | ||
var lastDot = fullFileName.lastIndexOf('.'); // these count as no extension: "no-dot", "trailing-dot." | ||
const lastDot = fullFileName.lastIndexOf('.'); // these count as no extension: "no-dot", "trailing-dot." | ||
@@ -11,0 +13,0 @@ if (lastDot === -1 || lastDot === fullFileName.length - 1) { |
@@ -1,7 +0,9 @@ | ||
var getFileNameAndExtension = require('./getFileNameAndExtension'); | ||
"use strict"; | ||
var mimeTypes = require('./mimeTypes'); | ||
const getFileNameAndExtension = require('./getFileNameAndExtension'); | ||
const mimeTypes = require('./mimeTypes'); | ||
module.exports = function getFileType(file) { | ||
var fileExtension = file.name ? getFileNameAndExtension(file.name).extension : null; | ||
let fileExtension = file.name ? getFileNameAndExtension(file.name).extension : null; | ||
fileExtension = fileExtension ? fileExtension.toLowerCase() : null; | ||
@@ -8,0 +10,0 @@ |
@@ -1,6 +0,4 @@ | ||
// TODO Check which types are actually supported in browsers. Chrome likes webm | ||
// from my testing, but we may need more. | ||
// We could use a library but they tend to contain dozens of KBs of mappings, | ||
// most of which will go unused, so not sure if that's worth it. | ||
var mimeToExtensions = { | ||
"use strict"; | ||
const mimeToExtensions = { | ||
'audio/mp3': 'mp3', | ||
@@ -7,0 +5,0 @@ 'audio/mp4': 'mp4', |
@@ -0,7 +1,9 @@ | ||
"use strict"; | ||
module.exports = function getSocketHost(url) { | ||
// get the host domain | ||
var regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i; | ||
var host = regex.exec(url)[1]; | ||
var socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'; | ||
return socketProtocol + "://" + host; | ||
const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i; | ||
const host = regex.exec(url)[1]; | ||
const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'; | ||
return `${socketProtocol}://${host}`; | ||
}; |
@@ -0,6 +1,8 @@ | ||
"use strict"; | ||
module.exports = function getSpeed(fileProgress) { | ||
if (!fileProgress.bytesUploaded) return 0; | ||
var timeElapsed = new Date() - fileProgress.uploadStarted; | ||
var uploadSpeed = fileProgress.bytesUploaded / (timeElapsed / 1000); | ||
const timeElapsed = new Date() - fileProgress.uploadStarted; | ||
const uploadSpeed = fileProgress.bytesUploaded / (timeElapsed / 1000); | ||
return uploadSpeed; | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * Get the declared text direction for an element. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -5,7 +7,7 @@ * Returns a timestamp in the format of `hours:minutes:seconds` | ||
module.exports = function getTimeStamp() { | ||
var date = new Date(); | ||
var hours = pad(date.getHours().toString()); | ||
var minutes = pad(date.getMinutes().toString()); | ||
var seconds = pad(date.getSeconds().toString()); | ||
return hours + ":" + minutes + ":" + seconds; | ||
const date = new Date(); | ||
const hours = pad(date.getHours().toString()); | ||
const minutes = pad(date.getMinutes().toString()); | ||
const seconds = pad(date.getSeconds().toString()); | ||
return `${hours}:${minutes}:${seconds}`; | ||
}; | ||
@@ -12,0 +14,0 @@ /** |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
module.exports = function has(object, key) { | ||
return Object.prototype.hasOwnProperty.call(object, key); | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * Check if an object is a DOM element. Duck-typing based on `nodeType`. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -7,3 +9,3 @@ * Checks if the browser supports Drag & Drop (not supported on mobile devices, for example). | ||
module.exports = function isDragDropSupported() { | ||
var div = document.createElement('div'); | ||
const div = document.createElement('div'); | ||
@@ -10,0 +12,0 @@ if (!('draggable' in div) || !('ondragstart' in div && 'ondrop' in div)) { |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * Checks if current device reports itself as “mobile”. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
function isNetworkError(xhr) { | ||
@@ -2,0 +4,0 @@ if (!xhr) { |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * Check if a URL string is an object URL from `URL.createObjectURL`. |
@@ -0,4 +1,6 @@ | ||
"use strict"; | ||
module.exports = function isPreviewSupported(fileType) { | ||
if (!fileType) return false; | ||
var fileTypeSpecific = fileType.split('/')[1]; // list of images that browsers can preview | ||
const fileTypeSpecific = fileType.split('/')[1]; // list of images that browsers can preview | ||
@@ -5,0 +7,0 @@ if (/^(jpe?g|gif|png|svg|svg\+xml|bmp|webp|avif)$/.test(fileTypeSpecific)) { |
@@ -0,10 +1,5 @@ | ||
"use strict"; | ||
module.exports = function isTouchDevice() { | ||
// works on most browsers | ||
if ('ontouchstart' in window) { | ||
return true; | ||
} // works on IE10/11 and Surface | ||
// eslint-disable-next-line compat/compat | ||
return !!navigator.maxTouchPoints; | ||
return 'ontouchstart' in window || 'maxTouchPoints' in navigator; | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
// ___Why not add the mime-types package? | ||
@@ -2,0 +4,0 @@ // It's 19.7kB gzipped, and we only need mime types for well-known extensions (for file previews). |
@@ -1,34 +0,12 @@ | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
"use strict"; | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var NetworkError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(NetworkError, _Error); | ||
function NetworkError(error, xhr) { | ||
var _this; | ||
if (xhr === void 0) { | ||
xhr = null; | ||
} | ||
_this = _Error.call(this, "This looks like a network error, the endpoint might be blocked by an internet provider or a firewall.\n\nSource error: [" + error + "]") || this; | ||
_this.isNetworkError = true; | ||
_this.request = xhr; | ||
return _this; | ||
class NetworkError extends Error { | ||
constructor(error, xhr = null) { | ||
super(`This looks like a network error, the endpoint might be blocked by an internet provider or a firewall.\n\nSource error: [${error}]`); | ||
this.isNetworkError = true; | ||
this.request = xhr; | ||
} | ||
return NetworkError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
} | ||
module.exports = NetworkError; |
@@ -1,14 +0,16 @@ | ||
var secondsToTime = require('./secondsToTime'); | ||
"use strict"; | ||
const secondsToTime = require('./secondsToTime'); | ||
module.exports = function prettyETA(seconds) { | ||
var time = secondsToTime(seconds); // Only display hours and minutes if they are greater than 0 but always | ||
const time = secondsToTime(seconds); // Only display hours and minutes if they are greater than 0 but always | ||
// display minutes if hours is being displayed | ||
// Display a leading zero if the there is a preceding unit: 1m 05s, but 5s | ||
var hoursStr = time.hours ? time.hours + "h " : ''; | ||
var minutesVal = time.hours ? ("0" + time.minutes).substr(-2) : time.minutes; | ||
var minutesStr = minutesVal ? minutesVal + "m" : ''; | ||
var secondsVal = minutesVal ? ("0" + time.seconds).substr(-2) : time.seconds; | ||
var secondsStr = time.hours ? '' : minutesVal ? " " + secondsVal + "s" : secondsVal + "s"; | ||
return "" + hoursStr + minutesStr + secondsStr; | ||
const hoursStr = time.hours ? `${time.hours}h ` : ''; | ||
const minutesVal = time.hours ? `0${time.minutes}`.substr(-2) : time.minutes; | ||
const minutesStr = minutesVal ? `${minutesVal}m` : ''; | ||
const secondsVal = minutesVal ? `0${time.seconds}`.substr(-2) : time.seconds; | ||
const secondsStr = time.hours ? '' : minutesVal ? ` ${secondsVal}s` : `${secondsVal}s`; | ||
return `${hoursStr}${minutesStr}${secondsStr}`; | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -7,4 +9,4 @@ * Helper to abort upload requests if there has not been any progress for `timeout` ms. | ||
*/ | ||
var ProgressTimeout = /*#__PURE__*/function () { | ||
function ProgressTimeout(timeout, timeoutHandler) { | ||
class ProgressTimeout { | ||
constructor(timeout, timeoutHandler) { | ||
this._timeout = timeout; | ||
@@ -17,5 +19,3 @@ this._onTimedOut = timeoutHandler; | ||
var _proto = ProgressTimeout.prototype; | ||
_proto.progress = function progress() { | ||
progress() { | ||
// Some browsers fire another progress event when the upload is | ||
@@ -30,5 +30,5 @@ // cancelled, so we have to ignore progress after the timer was | ||
} | ||
}; | ||
} | ||
_proto.done = function done() { | ||
done() { | ||
if (this._aliveTimer) { | ||
@@ -40,7 +40,6 @@ clearTimeout(this._aliveTimer); | ||
this._isDone = true; | ||
}; | ||
} | ||
return ProgressTimeout; | ||
}(); | ||
} | ||
module.exports = ProgressTimeout; |
@@ -1,3 +0,5 @@ | ||
var findIndex = require('./findIndex'); | ||
"use strict"; | ||
const findIndex = require('./findIndex'); | ||
function createCancelError() { | ||
@@ -7,4 +9,4 @@ return new Error('Cancelled'); | ||
module.exports = /*#__PURE__*/function () { | ||
function RateLimitedQueue(limit) { | ||
class RateLimitedQueue { | ||
constructor(limit) { | ||
if (typeof limit !== 'number' || limit === 0) { | ||
@@ -20,10 +22,6 @@ this.limit = Infinity; | ||
var _proto = RateLimitedQueue.prototype; | ||
_proto._call = function _call(fn) { | ||
var _this = this; | ||
_call(fn) { | ||
this.activeRequests += 1; | ||
var _done = false; | ||
var cancelActive; | ||
let done = false; | ||
let cancelActive; | ||
@@ -38,32 +36,30 @@ try { | ||
return { | ||
abort: function abort() { | ||
if (_done) return; | ||
_done = true; | ||
_this.activeRequests -= 1; | ||
abort: () => { | ||
if (done) return; | ||
done = true; | ||
this.activeRequests -= 1; | ||
cancelActive(); | ||
_this._queueNext(); | ||
this._queueNext(); | ||
}, | ||
done: function done() { | ||
if (_done) return; | ||
_done = true; | ||
_this.activeRequests -= 1; | ||
done: () => { | ||
if (done) return; | ||
done = true; | ||
this.activeRequests -= 1; | ||
_this._queueNext(); | ||
this._queueNext(); | ||
} | ||
}; | ||
}; | ||
} | ||
_proto._queueNext = function _queueNext() { | ||
var _this2 = this; | ||
_queueNext() { | ||
// Do it soon but not immediately, this allows clearing out the entire queue synchronously | ||
// one by one without continuously _advancing_ it (and starting new tasks before immediately | ||
// aborting them) | ||
Promise.resolve().then(function () { | ||
_this2._next(); | ||
Promise.resolve().then(() => { | ||
this._next(); | ||
}); | ||
}; | ||
} | ||
_proto._next = function _next() { | ||
_next() { | ||
if (this.activeRequests >= this.limit) { | ||
@@ -80,28 +76,22 @@ return; | ||
var next = this.queuedHandlers.shift(); | ||
const next = this.queuedHandlers.shift(); | ||
var handler = this._call(next.fn); | ||
const handler = this._call(next.fn); | ||
next.abort = handler.abort; | ||
next.done = handler.done; | ||
}; | ||
} | ||
_proto._queue = function _queue(fn, options) { | ||
var _this3 = this; | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var handler = { | ||
fn: fn, | ||
_queue(fn, options = {}) { | ||
const handler = { | ||
fn, | ||
priority: options.priority || 0, | ||
abort: function abort() { | ||
_this3._dequeue(handler); | ||
abort: () => { | ||
this._dequeue(handler); | ||
}, | ||
done: function done() { | ||
done: () => { | ||
throw new Error('Cannot mark a queued request as done: this indicates a bug'); | ||
} | ||
}; | ||
var index = findIndex(this.queuedHandlers, function (other) { | ||
const index = findIndex(this.queuedHandlers, other => { | ||
return handler.priority > other.priority; | ||
@@ -117,6 +107,6 @@ }); | ||
return handler; | ||
}; | ||
} | ||
_proto._dequeue = function _dequeue(handler) { | ||
var index = this.queuedHandlers.indexOf(handler); | ||
_dequeue(handler) { | ||
const index = this.queuedHandlers.indexOf(handler); | ||
@@ -126,5 +116,5 @@ if (index !== -1) { | ||
} | ||
}; | ||
} | ||
_proto.run = function run(fn, queueOptions) { | ||
run(fn, queueOptions) { | ||
if (this.activeRequests < this.limit) { | ||
@@ -135,20 +125,14 @@ return this._call(fn); | ||
return this._queue(fn, queueOptions); | ||
}; | ||
} | ||
_proto.wrapPromiseFunction = function wrapPromiseFunction(fn, queueOptions) { | ||
var _this4 = this; | ||
wrapPromiseFunction(fn, queueOptions) { | ||
return (...args) => { | ||
let queuedRequest; | ||
const outerPromise = new Promise((resolve, reject) => { | ||
queuedRequest = this.run(() => { | ||
let cancelError; | ||
let innerPromise; | ||
return function () { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var queuedRequest; | ||
var outerPromise = new Promise(function (resolve, reject) { | ||
queuedRequest = _this4.run(function () { | ||
var cancelError; | ||
var innerPromise; | ||
try { | ||
innerPromise = Promise.resolve(fn.apply(void 0, args)); | ||
innerPromise = Promise.resolve(fn(...args)); | ||
} catch (err) { | ||
@@ -158,3 +142,3 @@ innerPromise = Promise.reject(err); | ||
innerPromise.then(function (result) { | ||
innerPromise.then(result => { | ||
if (cancelError) { | ||
@@ -166,3 +150,3 @@ reject(cancelError); | ||
} | ||
}, function (err) { | ||
}, err => { | ||
if (cancelError) { | ||
@@ -175,3 +159,3 @@ reject(cancelError); | ||
}); | ||
return function () { | ||
return () => { | ||
cancelError = createCancelError(); | ||
@@ -182,3 +166,3 @@ }; | ||
outerPromise.abort = function () { | ||
outerPromise.abort = () => { | ||
queuedRequest.abort(); | ||
@@ -189,5 +173,9 @@ }; | ||
}; | ||
}; | ||
} | ||
return RateLimitedQueue; | ||
}(); | ||
} | ||
module.exports = { | ||
RateLimitedQueue, | ||
internalRateLimitedQueue: Symbol('__queue') | ||
}; |
@@ -1,10 +0,10 @@ | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
"use strict"; | ||
var getFileNameAndExtension = require('./getFileNameAndExtension'); | ||
const getFileNameAndExtension = require('./getFileNameAndExtension'); | ||
module.exports = function remoteFileObjToLocal(file) { | ||
return _extends({}, file, { | ||
return { ...file, | ||
type: file.mimeType, | ||
extension: file.name ? getFileNameAndExtension(file.name).extension : null | ||
}); | ||
}; | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
module.exports = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExMWFhUXGBgbFxgYFxcXGBgbFxcXFxcYGBgYHSggGRolHRcVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGhAQGi0dHR0tLS0tLSstLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tKy0tLS0tKy0tOCstLS0tLTc3Lf/AABEIAMMBAwMBIgACEQEDEQH/xAAcAAACAwEBAQEAAAAAAAAAAAAEBQIDBgABBwj/xA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lLrOItIFMkAxtK5cj+BrzDVnFokzNyDdpOUu+HTW+inVcWvIbYBpMbSGNeDHXMSZXq5ChEPixFJpAIewOdYXIc+86jyR9PEOZialBpilBOSBEnMDMi47Gy5cj8DA+KwbGtYWtgvpuDoJANxtMblW8Jpj3BffMGiDJkcxGvguXJTL8TRDHOa0QHU3PcBN3NIh3Y3OiIbTGSk+BmdJJ6nLP1XLkQL8I3Rty002EtcS5sup3s6Qh6w+7vN0T5dtFy5aMznFarmNoFpIklx3knUmdfNB4sfz6jRZozEBvKBabAd7rly1N8GDWtfzPYxzjqXMYSdrkiSuXLkpH//Z'; |
@@ -0,10 +1,12 @@ | ||
"use strict"; | ||
module.exports = function secondsToTime(rawSeconds) { | ||
var hours = Math.floor(rawSeconds / 3600) % 24; | ||
var minutes = Math.floor(rawSeconds / 60) % 60; | ||
var seconds = Math.floor(rawSeconds % 60); | ||
const hours = Math.floor(rawSeconds / 3600) % 24; | ||
const minutes = Math.floor(rawSeconds / 60) % 60; | ||
const seconds = Math.floor(rawSeconds % 60); | ||
return { | ||
hours: hours, | ||
minutes: minutes, | ||
seconds: seconds | ||
hours, | ||
minutes, | ||
seconds | ||
}; | ||
}; |
@@ -0,4 +1,6 @@ | ||
"use strict"; | ||
module.exports = function settle(promises) { | ||
var resolutions = []; | ||
var rejections = []; | ||
const resolutions = []; | ||
const rejections = []; | ||
@@ -13,6 +15,4 @@ function resolved(value) { | ||
var wait = Promise.all(promises.map(function (promise) { | ||
return promise.then(resolved, rejected); | ||
})); | ||
return wait.then(function () { | ||
const wait = Promise.all(promises.map(promise => promise.then(resolved, rejected))); | ||
return wait.then(() => { | ||
return { | ||
@@ -19,0 +19,0 @@ successful: resolutions, |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * Converts list into array |
@@ -1,4 +0,4 @@ | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
"use strict"; | ||
var has = require('./hasProperty'); | ||
const has = require('./hasProperty'); | ||
/** | ||
@@ -17,12 +17,11 @@ * Translates strings with interpolation & pluralization support. | ||
module.exports = /*#__PURE__*/function () { | ||
module.exports = class Translator { | ||
/** | ||
* @param {object|Array<object>} locales - locale or list of locales. | ||
*/ | ||
function Translator(locales) { | ||
var _this = this; | ||
constructor(locales) { | ||
this.locale = { | ||
strings: {}, | ||
pluralize: function pluralize(n) { | ||
pluralize(n) { | ||
if (n === 1) { | ||
@@ -34,8 +33,7 @@ return 0; | ||
} | ||
}; | ||
if (Array.isArray(locales)) { | ||
locales.forEach(function (locale) { | ||
return _this._apply(locale); | ||
}); | ||
locales.forEach(locale => this._apply(locale)); | ||
} else { | ||
@@ -46,5 +44,3 @@ this._apply(locales); | ||
var _proto = Translator.prototype; | ||
_proto._apply = function _apply(locale) { | ||
_apply(locale) { | ||
if (!locale || !locale.strings) { | ||
@@ -54,6 +50,8 @@ return; | ||
var prevLocale = this.locale; | ||
this.locale = _extends({}, prevLocale, { | ||
strings: _extends({}, prevLocale.strings, locale.strings) | ||
}); | ||
const prevLocale = this.locale; | ||
this.locale = { ...prevLocale, | ||
strings: { ...prevLocale.strings, | ||
...locale.strings | ||
} | ||
}; | ||
this.locale.pluralize = locale.pluralize || prevLocale.pluralize; | ||
@@ -72,13 +70,10 @@ } | ||
*/ | ||
; | ||
_proto.interpolate = function interpolate(phrase, options) { | ||
var _String$prototype = String.prototype, | ||
split = _String$prototype.split, | ||
replace = _String$prototype.replace; | ||
var dollarRegex = /\$/g; | ||
var dollarBillsYall = '$$$$'; | ||
var interpolated = [phrase]; | ||
for (var arg in options) { | ||
interpolate(phrase, options) { | ||
const dollarRegex = /\$/g; | ||
const dollarBillsYall = '$$$$'; | ||
let interpolated = [phrase]; | ||
for (const arg in options) { | ||
if (arg !== '_' && has(options, arg)) { | ||
@@ -88,6 +83,6 @@ // Ensure replacement value is escaped to prevent special $-prefixed | ||
// be escaped with "$" itself, and we need two in the resulting output. | ||
var replacement = options[arg]; | ||
let replacement = options[arg]; | ||
if (typeof replacement === 'string') { | ||
replacement = replace.call(options[arg], dollarRegex, dollarBillsYall); | ||
replacement = dollarRegex[Symbol.replace](replacement, dollarBillsYall); | ||
} // We create a new `RegExp` each time instead of using a more-efficient | ||
@@ -98,3 +93,3 @@ // string replace so that the same argument can be replaced multiple times | ||
interpolated = insertReplacement(interpolated, new RegExp("%\\{" + arg + "\\}", 'g'), replacement); | ||
interpolated = insertReplacement(interpolated, new RegExp(`%\\{${arg}\\}`, 'g'), replacement); | ||
} | ||
@@ -106,4 +101,4 @@ } | ||
function insertReplacement(source, rx, replacement) { | ||
var newParts = []; | ||
source.forEach(function (chunk) { | ||
const newParts = []; | ||
source.forEach(chunk => { | ||
// When the source contains multiple placeholders for interpolation, | ||
@@ -117,3 +112,3 @@ // we should ignore chunks that are not strings, because those | ||
split.call(chunk, rx).forEach(function (raw, i, list) { | ||
rx[Symbol.split](chunk).forEach((raw, i, list) => { | ||
if (raw !== '') { | ||
@@ -139,5 +134,5 @@ newParts.push(raw); | ||
*/ | ||
; | ||
_proto.translate = function translate(key, options) { | ||
translate(key, options) { | ||
return this.translateArray(key, options).join(''); | ||
@@ -152,15 +147,15 @@ } | ||
*/ | ||
; | ||
_proto.translateArray = function translateArray(key, options) { | ||
translateArray(key, options) { | ||
if (!has(this.locale.strings, key)) { | ||
throw new Error("missing string: " + key); | ||
throw new Error(`missing string: ${key}`); | ||
} | ||
var string = this.locale.strings[key]; | ||
var hasPluralForms = typeof string === 'object'; | ||
const string = this.locale.strings[key]; | ||
const hasPluralForms = typeof string === 'object'; | ||
if (hasPluralForms) { | ||
if (options && typeof options.smart_count !== 'undefined') { | ||
var plural = this.locale.pluralize(options.smart_count); | ||
const plural = this.locale.pluralize(options.smart_count); | ||
return this.interpolate(string[plural], options); | ||
@@ -173,5 +168,4 @@ } | ||
return this.interpolate(string, options); | ||
}; | ||
} | ||
return Translator; | ||
}(); | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -10,3 +12,3 @@ * Truncates a string to the given number of chars (maxLength) by inserting '...' in the middle of that string. | ||
module.exports = function truncateString(string, maxLength) { | ||
var separator = '...'; // Return original string if it's already shorter than maxLength | ||
const separator = '...'; // Return original string if it's already shorter than maxLength | ||
@@ -21,6 +23,6 @@ if (string.length <= maxLength) { | ||
var charsToShow = maxLength - separator.length; | ||
var frontChars = Math.ceil(charsToShow / 2); | ||
var backChars = Math.floor(charsToShow / 2); | ||
const charsToShow = maxLength - separator.length; | ||
const frontChars = Math.ceil(charsToShow / 2); | ||
const backChars = Math.floor(charsToShow / 2); | ||
return string.substr(0, frontChars) + separator + string.substr(string.length - backChars); | ||
}; |
{ | ||
"name": "@uppy/utils", | ||
"description": "Shared utility functions for Uppy Core and plugins maintained by the Uppy team.", | ||
"version": "3.6.2", | ||
"version": "4.0.0-alpha.0", | ||
"license": "MIT", | ||
@@ -21,6 +21,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"abortcontroller-polyfill": "^1.4.0", | ||
"lodash.throttle": "^4.1.1" | ||
}, | ||
"gitHead": "4b782ffbbb443672843d7b4096956bed3b11d612" | ||
"gitHead": "113b627dd0ef5aa5d198dc309dda05da2117dfe5" | ||
} |
/** | ||
* Little AbortController proxy module so we can swap out the implementation easily later. | ||
*/ | ||
const { AbortController, AbortSignal } = require('abortcontroller-polyfill/dist/abortcontroller') | ||
function createAbortError (message = 'Aborted') { | ||
try { | ||
return new DOMException(message, 'AbortError') | ||
} catch { | ||
// For Internet Explorer | ||
const error = new Error(message) | ||
error.name = 'AbortError' | ||
return error | ||
} | ||
} | ||
exports.AbortController = AbortController | ||
exports.AbortSignal = AbortSignal | ||
exports.createAbortError = createAbortError | ||
exports.createAbortError = (message = 'Aborted') => new DOMException(message, 'AbortError') |
@@ -21,3 +21,3 @@ module.exports = function dataURItoBlob (dataURI, opts, toFile) { | ||
try { | ||
bytes = new Uint8Array(array) // eslint-disable-line compat/compat | ||
bytes = new Uint8Array(array) | ||
} catch (err) { | ||
@@ -24,0 +24,0 @@ return null |
@@ -16,30 +16,29 @@ const toArray = require('../../../toArray') | ||
*/ | ||
const createPromiseToAddFileOrParseDirectory = (entry) => | ||
new Promise((resolve) => { | ||
// This is a base call | ||
if (entry.isFile) { | ||
// Creates a new File object which can be used to read the file. | ||
entry.file( | ||
(file) => { | ||
file.relativePath = getRelativePath(entry) | ||
files.push(file) | ||
resolve() | ||
}, | ||
// Make sure we resolve on error anyway, it's fine if only one file couldn't be read! | ||
(error) => { | ||
logDropError(error) | ||
resolve() | ||
} | ||
) | ||
const createPromiseToAddFileOrParseDirectory = (entry) => new Promise((resolve) => { | ||
// This is a base call | ||
if (entry.isFile) { | ||
// Creates a new File object which can be used to read the file. | ||
entry.file( | ||
(file) => { | ||
file.relativePath = getRelativePath(entry) | ||
files.push(file) | ||
resolve() | ||
}, | ||
// Make sure we resolve on error anyway, it's fine if only one file couldn't be read! | ||
(error) => { | ||
logDropError(error) | ||
resolve() | ||
} | ||
) | ||
// This is a recursive call | ||
} else if (entry.isDirectory) { | ||
const directoryReader = entry.createReader() | ||
getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, { | ||
onSuccess: (entries) => { | ||
const promises = entries.map((entry) => createPromiseToAddFileOrParseDirectory(entry)) | ||
Promise.all(promises).then(() => resolve()) | ||
}, | ||
}) | ||
} | ||
}) | ||
} else if (entry.isDirectory) { | ||
const directoryReader = entry.createReader() | ||
getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, { | ||
onSuccess: (entries) => { | ||
const promises = entries.map((entry) => createPromiseToAddFileOrParseDirectory(entry)) | ||
Promise.all(promises).then(() => resolve()) | ||
}, | ||
}) | ||
} | ||
}) | ||
@@ -46,0 +45,0 @@ // For each dropped item, - make sure it's a file/directory, and start deepening in! |
@@ -1,5 +0,1 @@ | ||
// TODO Check which types are actually supported in browsers. Chrome likes webm | ||
// from my testing, but we may need more. | ||
// We could use a library but they tend to contain dozens of KBs of mappings, | ||
// most of which will go unused, so not sure if that's worth it. | ||
const mimeToExtensions = { | ||
@@ -6,0 +2,0 @@ 'audio/mp3': 'mp3', |
module.exports = function getSocketHost (url) { | ||
// get the host domain | ||
var regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i | ||
var host = regex.exec(url)[1] | ||
var socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss' | ||
const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i | ||
const host = regex.exec(url)[1] | ||
const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss' | ||
return `${socketProtocol}://${host}` | ||
} |
@@ -5,6 +5,6 @@ /** | ||
module.exports = function getTimeStamp () { | ||
var date = new Date() | ||
var hours = pad(date.getHours().toString()) | ||
var minutes = pad(date.getMinutes().toString()) | ||
var seconds = pad(date.getSeconds().toString()) | ||
const date = new Date() | ||
const hours = pad(date.getHours().toString()) | ||
const minutes = pad(date.getMinutes().toString()) | ||
const seconds = pad(date.getSeconds().toString()) | ||
return `${hours}:${minutes}:${seconds}` | ||
@@ -11,0 +11,0 @@ } |
module.exports = function isTouchDevice () { | ||
// works on most browsers | ||
if ('ontouchstart' in window) { | ||
return true | ||
} | ||
// works on IE10/11 and Surface | ||
// eslint-disable-next-line compat/compat | ||
return !!navigator.maxTouchPoints | ||
return 'ontouchstart' in window || 'maxTouchPoints' in navigator | ||
} |
@@ -7,3 +7,3 @@ const findIndex = require('./findIndex') | ||
module.exports = class RateLimitedQueue { | ||
class RateLimitedQueue { | ||
constructor (limit) { | ||
@@ -157,1 +157,6 @@ if (typeof limit !== 'number' || limit === 0) { | ||
} | ||
module.exports = { | ||
RateLimitedQueue, | ||
internalRateLimitedQueue: Symbol('__queue'), | ||
} |
@@ -1,2 +0,2 @@ | ||
const RateLimitedQueue = require('./RateLimitedQueue') | ||
const { RateLimitedQueue } = require('./RateLimitedQueue') | ||
@@ -3,0 +3,0 @@ const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) |
@@ -58,3 +58,2 @@ const has = require('./hasProperty') | ||
interpolate (phrase, options) { | ||
const { split, replace } = String.prototype | ||
const dollarRegex = /\$/g | ||
@@ -69,5 +68,5 @@ const dollarBillsYall = '$$$$' | ||
// be escaped with "$" itself, and we need two in the resulting output. | ||
var replacement = options[arg] | ||
let replacement = options[arg] | ||
if (typeof replacement === 'string') { | ||
replacement = replace.call(options[arg], dollarRegex, dollarBillsYall) | ||
replacement = dollarRegex[Symbol.replace](replacement, dollarBillsYall) | ||
} | ||
@@ -94,3 +93,3 @@ // We create a new `RegExp` each time instead of using a more-efficient | ||
split.call(chunk, rx).forEach((raw, i, list) => { | ||
rx[Symbol.split](chunk).forEach((raw, i, list) => { | ||
if (raw !== '') { | ||
@@ -97,0 +96,0 @@ newParts.push(raw) |
@@ -13,4 +13,6 @@ declare module '@uppy/utils/lib/Translator' { | ||
constructor (opts: Translator.Locale | Translator.Locale[]) | ||
translate (key: string, options: object): string | ||
translateArray (key: string, options: object): any[] | ||
translate (key: string, options: Record<string, unknown>): string | ||
translateArray (key: string, options: Record<string, unknown>): any[] | ||
} | ||
@@ -32,3 +34,5 @@ | ||
constructor (emitter: EventTracker.Emitter) | ||
on (event: string, handler: EventTracker.EventHandler): void | ||
remove (): void | ||
@@ -43,3 +47,5 @@ } | ||
constructor (timeout: number, timeoutHandler: () => void) | ||
progress (): void | ||
done (): void | ||
@@ -63,4 +69,5 @@ } | ||
class RateLimitedQueue { | ||
export class RateLimitedQueue { | ||
constructor(limit: number) | ||
run( | ||
@@ -70,2 +77,3 @@ fn: () => RateLimitedQueue.AbortFunction, | ||
): RateLimitedQueue.QueueEntry | ||
wrapPromiseFunction( | ||
@@ -77,3 +85,3 @@ fn: () => RateLimitedQueue.PromiseFunction, | ||
export = RateLimitedQueue | ||
export const internalRateLimitedQueue: symbol | ||
} | ||
@@ -116,3 +124,3 @@ | ||
function emitSocketProgress ( | ||
uploader: object, | ||
uploader: unknown, | ||
progressData: ProgressData, | ||
@@ -150,3 +158,3 @@ file: UppyUtils.UppyFile | ||
declare module '@uppy/utils/lib/getETA' { | ||
function getETA (progress: object): number | ||
function getETA (progress: unknown): number | ||
export = getETA | ||
@@ -242,3 +250,3 @@ } | ||
dataTransfer: DataTransfer, | ||
options?: object | ||
options?: Record<string, unknown> | ||
): Promise<File[]> | ||
@@ -276,3 +284,3 @@ export = getDroppedFiles | ||
url: string | ||
body?: object | ||
body?: Record<string, unknown> | ||
} | ||
@@ -289,6 +297,6 @@ size: number | ||
export interface Store { | ||
getState (): object | ||
setState (patch: object): void | ||
getState (): Record<string, unknown> | ||
setState (patch: Record<string, unknown>): void | ||
subscribe (listener: any): () => void | ||
} | ||
} |
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
219744
2906
1
- Removedabortcontroller-polyfill@^1.4.0
- Removedabortcontroller-polyfill@1.7.6(transitive)