Skip to content

Commit

Permalink
@uppy/compressor: mark quality as optional (#5374)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jul 29, 2024
1 parent 05d0789 commit 72e84a8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/@uppy/compressor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import prettierBytes from '@transloadit/prettier-bytes'
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'

import locale from './locale.ts'

Expand All @@ -18,30 +18,31 @@ declare module '@uppy/core' {
}

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'
this.type = 'modifier'

this.defaultLocale = locale

const defaultOptions = {
quality: 0.6,
limit: 10,
}

this.opts = { ...defaultOptions, ...opts }

this.#RateLimitedQueue = new RateLimitedQueue(this.opts.limit)

this.i18nInit()
Expand Down

0 comments on commit 72e84a8

Please sign in to comment.