@uppy/core
Advanced tools
Comparing version 3.11.3 to 3.12.0
# @uppy/core | ||
## 3.12.0 | ||
Released: 2024-06-04 | ||
Included in: Uppy v3.26.0 | ||
- @uppy/core: check capabilities in clearUploadedFiles (Merlijn Vos / #5201) | ||
- @uppy/core: PartialTree - change the `maxTotalFileSize` error (Evgenia Karunus / #5203) | ||
## 3.11.3 | ||
@@ -4,0 +12,0 @@ |
@@ -15,2 +15,3 @@ export default { | ||
}, | ||
aggregateExceedsSize: 'You selected %{size} of files, but maximum allowed size is %{sizeAllowed}', | ||
exceedsSize: '%{file} exceeds maximum allowed size of %{size}', | ||
@@ -17,0 +18,0 @@ missingRequiredMetaField: 'Missing required meta fields', |
@@ -59,17 +59,11 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
if (maxTotalFileSize) { | ||
let totalFilesSize = existingFiles.reduce((total, f) => { | ||
const totalFilesSize = [...existingFiles, ...addingFiles].reduce((total, f) => { | ||
var _f$size; | ||
return total + ((_f$size = f.size) != null ? _f$size : 0); | ||
}, 0); | ||
for (const addingFile of addingFiles) { | ||
if (addingFile.size != null) { | ||
// We can't check maxTotalFileSize if the size is unknown. | ||
totalFilesSize += addingFile.size; | ||
if (totalFilesSize > maxTotalFileSize) { | ||
throw new RestrictionError(this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxTotalFileSize), | ||
file: addingFile.name | ||
})); | ||
} | ||
} | ||
if (totalFilesSize > maxTotalFileSize) { | ||
throw new RestrictionError(this.getI18n()('aggregateExceedsSize', { | ||
sizeAllowed: prettierBytes(maxTotalFileSize), | ||
size: prettierBytes(totalFilesSize) | ||
})); | ||
} | ||
@@ -76,0 +70,0 @@ } |
@@ -27,3 +27,3 @@ let _Symbol$for, _Symbol$for2; | ||
const packageJson = { | ||
"version": "3.11.3" | ||
"version": "3.12.0" | ||
}; | ||
@@ -446,2 +446,9 @@ import locale from "./locale.js"; | ||
clearUploadedFiles() { | ||
const { | ||
capabilities, | ||
currentUploads | ||
} = this.getState(); | ||
if (Object.keys(currentUploads).length > 0 && !capabilities.individualCancellation) { | ||
throw new Error('The installed uploader plugin does not allow removing files during an upload.'); | ||
} | ||
this.setState({ | ||
@@ -739,3 +746,3 @@ ...defaultUploadState, | ||
if (newFileIDs.length !== currentUploads[uploadID].fileIDs.length && !capabilities.individualCancellation) { | ||
throw new Error('individualCancellation is disabled'); | ||
throw new Error('The installed uploader plugin does not allow removing files during an upload.'); | ||
} | ||
@@ -742,0 +749,0 @@ updatedUploads[uploadID] = { |
{ | ||
"name": "@uppy/core", | ||
"description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:", | ||
"version": "3.11.3", | ||
"version": "3.12.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -15,2 +15,4 @@ export default { | ||
}, | ||
aggregateExceedsSize: | ||
'You selected %{size} of files, but maximum allowed size is %{sizeAllowed}', | ||
exceedsSize: '%{file} exceeds maximum allowed size of %{size}', | ||
@@ -17,0 +19,0 @@ missingRequiredMetaField: 'Missing required meta fields', |
@@ -101,21 +101,13 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
if (maxTotalFileSize) { | ||
let totalFilesSize = existingFiles.reduce( | ||
(total, f) => (total + (f.size ?? 0)) as number, | ||
const totalFilesSize = [...existingFiles, ...addingFiles].reduce( | ||
(total, f) => total + (f.size ?? 0), | ||
0, | ||
) | ||
for (const addingFile of addingFiles) { | ||
if (addingFile.size != null) { | ||
// We can't check maxTotalFileSize if the size is unknown. | ||
totalFilesSize += addingFile.size | ||
if (totalFilesSize > maxTotalFileSize) { | ||
throw new RestrictionError( | ||
this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxTotalFileSize), | ||
file: addingFile.name, | ||
}), | ||
) | ||
} | ||
} | ||
if (totalFilesSize > maxTotalFileSize) { | ||
throw new RestrictionError( | ||
this.getI18n()('aggregateExceedsSize', { | ||
sizeAllowed: prettierBytes(maxTotalFileSize), | ||
size: prettierBytes(totalFilesSize), | ||
}), | ||
) | ||
} | ||
@@ -122,0 +114,0 @@ } |
@@ -8,2 +8,3 @@ /* eslint-disable */ | ||
| 'youHaveToAtLeastSelectX' | ||
| 'aggregateExceedsSize' | ||
| 'exceedsSize' | ||
@@ -10,0 +11,0 @@ | 'missingRequiredMetaField' |
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 too big to display
Sorry, the diff of this file is too big to display
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
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
477685
8222