forked from external-repos/squoosh
Adding native encoders (#71)
* Adding browser png * Adding native JPEG & file size output * Removing log * Fixing blob typing * Fix timing issue
This commit is contained in:
@@ -2,14 +2,19 @@ import { h, Component } from 'preact';
|
||||
import * as style from './style.scss';
|
||||
import { bind } from '../../lib/util';
|
||||
import MozJpegEncoderOptions from '../../codecs/mozjpeg/options';
|
||||
import BrowserJPEGEncoderOptions from '../../codecs/browser-jpeg/options';
|
||||
|
||||
import { type as mozJPEGType } from '../../codecs/mozjpeg/encoder';
|
||||
import { type as identityType } from '../../codecs/identity/encoder';
|
||||
import { type as browserPNGType } from '../../codecs/browser-png/encoder';
|
||||
import { type as browserJPEGType } from '../../codecs/browser-jpeg/encoder';
|
||||
import { EncoderState, EncoderType, EncoderOptions, encoders } from '../../codecs/encoders';
|
||||
|
||||
const encoderOptionsComponentMap = {
|
||||
[mozJPEGType]: MozJpegEncoderOptions,
|
||||
[identityType]: undefined
|
||||
[identityType]: undefined,
|
||||
[browserPNGType]: undefined,
|
||||
[browserJPEGType]: BrowserJPEGEncoderOptions,
|
||||
};
|
||||
|
||||
interface Props {
|
||||
@@ -50,8 +55,8 @@ export default class Options extends Component<Props, State> {
|
||||
{EncoderOptionComponent &&
|
||||
<EncoderOptionComponent
|
||||
options={
|
||||
// Casting options, as encoderOptionsComponentMap[encodeData.type] ensures the correct type,
|
||||
// but typescript isn't smart enough.
|
||||
// Casting options, as encoderOptionsComponentMap[encodeData.type] ensures the correct
|
||||
// type, but typescript isn't smart enough.
|
||||
encoderState.options as typeof EncoderOptionComponent['prototype']['props']['options']
|
||||
}
|
||||
onChange={onOptionsChange}
|
||||
|
||||
Reference in New Issue
Block a user