🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@uppy/compressor

Package Overview
Dependencies
Maintainers
8
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/compressor - npm Package Compare versions

Comparing version

to
0.2.3

7

CHANGELOG.md
# @uppy/compressor
## 0.2.3
Released: 2022-03-16
Included in: Uppy v2.8.0
- @uppy/compressor: ignore remote files, calculate savings correctly (Artur Paikin / #3578)
## 0.2.2

@@ -4,0 +11,0 @@

25

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _core = require("@uppy/core");

@@ -12,4 +7,2 @@

var _locale = require("./locale.js");
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }

@@ -25,2 +18,4 @@

const locale = require("./locale.js");
var _RateLimitedQueue = /*#__PURE__*/_classPrivateFieldLooseKey("RateLimitedQueue");

@@ -37,3 +32,3 @@

this.type = 'modifier';
this.defaultLocale = _locale.default;
this.defaultLocale = locale;
const defaultOptions = {

@@ -68,4 +63,5 @@ quality: 0.6,

const compressedBlob = await this.compress(file.data);
this.uppy.log(`[Image Compressor] Image ${file.id} size before/after compression: ${file.data.size} / ${compressedBlob.size}`);
totalCompressedSize += compressedBlob.size;
const compressedSavingsSize = file.data.size - compressedBlob.size;
this.uppy.log(`[Image Compressor] Image ${file.id} compressed by ${prettierBytes(compressedSavingsSize)}`);
totalCompressedSize += compressedSavingsSize;
this.uppy.setFileState(file.id, {

@@ -86,6 +82,11 @@ data: compressedBlob,

message: this.i18n('compressingImages')
}); // Some browsers (Firefox) add blobs with empty file type, when files are
});
if (file.isRemote) {
return Promise.resolve();
} // Some browsers (Firefox) add blobs with empty file type, when files are
// added from a folder. Uppy auto-detects type from extension, but leaves the original blob intact.
// However, Compressor.js failes when file has no type, so we set it here
if (!file.data.type) {

@@ -130,2 +131,2 @@ file.data = file.data.slice(0, file.data.size, file.type);

exports.default = Compressor;
module.exports = Compressor;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
module.exports = {
strings: {

@@ -13,3 +9,2 @@ // Shown in the Status Bar

}
};
exports.default = _default;
};
{
"name": "@uppy/compressor",
"description": "Uppy plugin that compresses images before upload, saving up to 60% in size",
"version": "0.2.2",
"version": "0.2.3",
"license": "MIT",

@@ -33,3 +33,3 @@ "main": "lib/index.js",

"peerDependencies": {
"@uppy/core": "^2.1.5"
"@uppy/core": "^2.1.6"
},

@@ -36,0 +36,0 @@ "publishConfig": {

@@ -49,4 +49,5 @@ import { BasePlugin } from '@uppy/core'

const compressedBlob = await this.compress(file.data)
this.uppy.log(`[Image Compressor] Image ${file.id} size before/after compression: ${file.data.size} / ${compressedBlob.size}`)
totalCompressedSize += compressedBlob.size
const compressedSavingsSize = file.data.size - compressedBlob.size
this.uppy.log(`[Image Compressor] Image ${file.id} compressed by ${prettierBytes(compressedSavingsSize)}`)
totalCompressedSize += compressedSavingsSize
this.uppy.setFileState(file.id, {

@@ -70,2 +71,6 @@ data: compressedBlob,

if (file.isRemote) {
return Promise.resolve()
}
// Some browsers (Firefox) add blobs with empty file type, when files are

@@ -72,0 +77,0 @@ // added from a folder. Uppy auto-detects type from extension, but leaves the original blob intact.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet