@uppy/compressor
Advanced tools
Comparing version 2.0.0 to 2.0.1
# @uppy/compressor | ||
## 2.0.1 | ||
Released: 2024-07-30 | ||
Included in: Uppy v4.1.0 | ||
- @uppy/compressor: mark `quality` as optional (Antoine du Hamel / #5374) | ||
## 2.0.0-beta.5 | ||
@@ -4,0 +11,0 @@ |
import { BasePlugin, Uppy } from '@uppy/core'; | ||
import CompressorJS from 'compressorjs'; | ||
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'; | ||
import type { PluginOpts } from '@uppy/core/lib/BasePlugin.js'; | ||
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js'; | ||
declare module '@uppy/core' { | ||
@@ -11,8 +11,11 @@ interface UppyEventMap<M extends Meta, B extends Body> { | ||
export interface CompressorOpts extends PluginOpts, CompressorJS.Options { | ||
quality: number; | ||
limit?: number; | ||
} | ||
export default class Compressor<M extends Meta, B extends Body> extends BasePlugin<CompressorOpts, M, B> { | ||
declare const defaultOptions: { | ||
quality: number; | ||
limit: number; | ||
}; | ||
export default class Compressor<M extends Meta, B extends Body> extends BasePlugin<DefinePluginOpts<CompressorOpts, keyof typeof defaultOptions>, M, B> { | ||
#private; | ||
constructor(uppy: Uppy<M, B>, opts: CompressorOpts); | ||
constructor(uppy: Uppy<M, B>, opts?: CompressorOpts); | ||
compress(blob: Blob): Promise<Blob | File>; | ||
@@ -23,2 +26,3 @@ prepareUpload(fileIDs: string[]): Promise<void>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,6 +12,13 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
import locale from "./locale.js"; | ||
const defaultOptions = { | ||
quality: 0.6, | ||
limit: 10 | ||
}; | ||
var _RateLimitedQueue = /*#__PURE__*/_classPrivateFieldLooseKey("RateLimitedQueue"); | ||
export default class Compressor extends BasePlugin { | ||
constructor(uppy, opts) { | ||
super(uppy, opts); | ||
super(uppy, { | ||
...defaultOptions, | ||
...opts | ||
}); | ||
Object.defineProperty(this, _RateLimitedQueue, { | ||
@@ -24,10 +31,2 @@ writable: true, | ||
this.defaultLocale = locale; | ||
const defaultOptions = { | ||
quality: 0.6, | ||
limit: 10 | ||
}; | ||
this.opts = { | ||
...defaultOptions, | ||
...opts | ||
}; | ||
_classPrivateFieldLooseBase(this, _RateLimitedQueue)[_RateLimitedQueue] = new RateLimitedQueue(this.opts.limit); | ||
@@ -34,0 +33,0 @@ this.i18nInit(); |
{ | ||
"name": "@uppy/compressor", | ||
"description": "Uppy plugin that compresses images before upload, saving up to 60% in size", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "main": "lib/index.js", | ||
"@transloadit/prettier-bytes": "^0.3.4", | ||
"@uppy/utils": "^6.0.0", | ||
"@uppy/utils": "^6.0.1", | ||
"compressorjs": "^1.2.1", | ||
@@ -33,3 +33,3 @@ "preact": "^10.5.13", | ||
"peerDependencies": { | ||
"@uppy/core": "^4.0.0" | ||
"@uppy/core": "^4.1.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "publishConfig": { |
@@ -10,3 +10,3 @@ import { BasePlugin, Uppy } from '@uppy/core' | ||
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile' | ||
import type { PluginOpts } from '@uppy/core/lib/BasePlugin.js' | ||
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js' | ||
@@ -22,14 +22,22 @@ import locale from './locale.ts' | ||
export interface CompressorOpts extends PluginOpts, CompressorJS.Options { | ||
quality: number | ||
limit?: number | ||
} | ||
const defaultOptions = { | ||
quality: 0.6, | ||
limit: 10, | ||
} satisfies Partial<CompressorOpts> | ||
export default class Compressor< | ||
M extends Meta, | ||
B extends Body, | ||
> extends BasePlugin<CompressorOpts, M, B> { | ||
> extends BasePlugin< | ||
DefinePluginOpts<CompressorOpts, keyof typeof defaultOptions>, | ||
M, | ||
B | ||
> { | ||
#RateLimitedQueue | ||
constructor(uppy: Uppy<M, B>, opts: CompressorOpts) { | ||
super(uppy, opts) | ||
constructor(uppy: Uppy<M, B>, opts?: CompressorOpts) { | ||
super(uppy, { ...defaultOptions, ...opts }) | ||
this.id = this.opts.id || 'Compressor' | ||
@@ -40,9 +48,2 @@ this.type = 'modifier' | ||
const defaultOptions = { | ||
quality: 0.6, | ||
limit: 10, | ||
} | ||
this.opts = { ...defaultOptions, ...opts } | ||
this.#RateLimitedQueue = new RateLimitedQueue(this.opts.limit) | ||
@@ -49,0 +50,0 @@ |
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
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
32387
380
Updated@uppy/utils@^6.0.1