mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 01:37:26 +00:00
Fixing issues raised by the linter. Fixes #68
+ just cleans up issues, and disables one test that can't be fixed. + biggest change is encoders not using multiple imports now.
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import * as mozJPEG from './mozjpeg/encoder';
|
||||
import { EncoderState as MozJPEGEncodeData, EncodeOptions as MozJPEGEncodeOptions } from './mozjpeg/encoder';
|
||||
import * as identity from './identity/encoder';
|
||||
import { EncoderState as IdentityEncodeData, EncodeOptions as IdentityEncodeOptions } from './identity/encoder';
|
||||
|
||||
export type EncoderState = IdentityEncodeData | MozJPEGEncodeData;
|
||||
export type EncoderOptions = IdentityEncodeOptions | MozJPEGEncodeOptions;
|
||||
export type EncoderState = identity.EncoderState | mozJPEG.EncoderState;
|
||||
export type EncoderOptions = identity.EncodeOptions | mozJPEG.EncodeOptions;
|
||||
export type EncoderType = keyof typeof encoderMap;
|
||||
|
||||
export const encoderMap = {
|
||||
[identity.type]: identity,
|
||||
[mozJPEG.type]: mozJPEG
|
||||
[mozJPEG.type]: mozJPEG,
|
||||
};
|
||||
|
||||
export const encoders = Array.from(Object.values(encoderMap));
|
||||
|
||||
@@ -54,7 +54,7 @@ export default class MozJpegEncoder {
|
||||
encode: m.cwrap('encode', '', ['number', 'number', 'number', 'number']),
|
||||
free_result: m.cwrap('free_result', '', []),
|
||||
get_result_pointer: m.cwrap('get_result_pointer', 'number', []),
|
||||
get_result_size: m.cwrap('get_result_size', 'number', [])
|
||||
get_result_size: m.cwrap('get_result_size', 'number', []),
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { bind } from '../../../../lib/util';
|
||||
import './styles.css';
|
||||
|
||||
// tslint:disable-next-line:max-line-length
|
||||
function firstMatchingItem(list: DataTransferItemList, acceptVal: string): DataTransferItem | undefined {
|
||||
// Split accepts values by ',' then by '/'. Trim everything & lowercase.
|
||||
const accepts = acceptVal.toLowerCase().split(',').map(accept => {
|
||||
const accepts = acceptVal.toLowerCase().split(',').map((accept) => {
|
||||
return accept.trim().split('/').map(part => part.trim());
|
||||
}).filter(acceptParts => acceptParts.length === 2); // Filter invalid values
|
||||
|
||||
return Array.from(list).find(item => {
|
||||
return Array.from(list).find((item) => {
|
||||
if (item.kind !== 'file') return false;
|
||||
|
||||
// 'Parse' the type.
|
||||
@@ -56,7 +57,7 @@ export class FileDrop extends HTMLElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.addEventListener('dragover', (event) => event.preventDefault());
|
||||
this.addEventListener('dragover', event => event.preventDefault());
|
||||
this.addEventListener('drop', this._onDrop);
|
||||
this.addEventListener('dragenter', this._onDragEnter);
|
||||
this.addEventListener('dragend', () => this._reset());
|
||||
@@ -73,7 +74,7 @@ export class FileDrop extends HTMLElement {
|
||||
|
||||
@bind
|
||||
private _onDragEnter(event: DragEvent) {
|
||||
this._dragEnterCount++;
|
||||
this._dragEnterCount += 1;
|
||||
if (this._dragEnterCount > 1) return;
|
||||
|
||||
// We don't have data, attempt to get it and if it matches, set the correct state.
|
||||
@@ -87,7 +88,7 @@ export class FileDrop extends HTMLElement {
|
||||
|
||||
@bind
|
||||
private _onDragLeave() {
|
||||
this._dragEnterCount--;
|
||||
this._dragEnterCount -= 1;
|
||||
if (this._dragEnterCount === 0) {
|
||||
this._reset();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { FileDropEvent, FileDrop } from ".";
|
||||
|
||||
import { FileDropEvent, FileDrop } from '.';
|
||||
|
||||
declare global {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user