Merge branch 'dev' into analytics-update-3

This commit is contained in:
Pete LePage
2020-07-31 10:28:23 -04:00
committed by GitHub
15 changed files with 41 additions and 3470 deletions

View File

@ -1,3 +1,4 @@
CODEC_URL := https://github.com/ImageOptim/libimagequant/archive/2.12.1.tar.gz
CODEC_DIR := node_modules/libimagequant
CODEC_OUT_RELATIVE := libimagequant.a
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
@ -28,6 +29,12 @@ $(CODEC_DIR)/config.mk: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-sse
$(CODEC_DIR)/configure: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,6 @@
{
"name": "imagequant",
"scripts": {
"install": "napa",
"build": "../build-cpp.sh"
},
"napa": {
"libimagequant": "ImageOptim/libimagequant#2.12.1"
},
"devDependencies": {
"napa": "3.0.0"
}
}

View File

@ -1,3 +1,4 @@
CODEC_URL := https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz
CODEC_DIR := node_modules/mozjpeg
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
@ -37,9 +38,15 @@ $(CODEC_DIR)/Makefile: $(CODEC_DIR)/configure
--without-arith-enc \
--without-arith-dec
$(CODEC_DIR)/configure:
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
cd $(CODEC_DIR) && autoreconf -iv
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,6 @@
{
"name": "mozjpeg_enc",
"scripts": {
"install": "napa",
"build": "../build-cpp.sh"
},
"napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1"
},
"devDependencies": {
"napa": "3.0.0"
}
}

View File

@ -1,3 +1,4 @@
CODEC_URL := https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
CODEC_DIR = node_modules/libwebp
CODEC_OUT_RELATIVE = src/.libs/libwebp.a
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
@ -41,9 +42,15 @@ $(CODEC_DIR)/src/Makefile: $(CODEC_DIR)/configure
--disable-sse2 \
--disable-sse4.1
$(CODEC_DIR)/configure:
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
cd $(CODEC_DIR) && autoreconf -iv
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,6 @@
{
"name": "webp",
"scripts": {
"install": "napa",
"build": "../build-cpp.sh"
},
"napa": {
"libwebp": "webmproject/libwebp#v1.0.2"
},
"devDependencies": {
"napa": "3.0.0"
}
}

View File

@ -1,19 +1,19 @@
import { nativeDecode, sniffMimeType, canDecodeImage } from '../lib/util';
import { builtinDecode, sniffMimeType, canDecodeImage } from '../lib/util';
import Processor from './processor';
import webpDataUrl from 'url-loader!./tiny.webp';
const nativeWebPSupported = canDecodeImage(webpDataUrl);
const webPSupported = canDecodeImage(webpDataUrl);
export async function decodeImage(blob: Blob, processor: Processor): Promise<ImageData> {
const mimeType = await sniffMimeType(blob);
try {
if (mimeType === 'image/webp' && !(await nativeWebPSupported)) {
if (mimeType === 'image/webp' && !(await webPSupported)) {
return await processor.webpDecode(blob);
}
// Otherwise, just throw it at the browser's decoder.
return await nativeDecode(blob);
return await builtinDecode(blob);
} catch (err) {
throw Error("Couldn't decode image");
}

View File

@ -1,4 +1,4 @@
import { nativeResize, NativeResizeMethod, drawableToImageData } from '../../lib/util';
import { builtinResize, BuiltinResizeMethod, drawableToImageData } from '../../lib/util';
import { BrowserResizeOptions, VectorResizeOptions } from './processor-meta';
import { getContainOffsets } from './util';
@ -12,9 +12,9 @@ export function browserResize(data: ImageData, opts: BrowserResizeOptions): Imag
({ sx, sy, sw, sh } = getContainOffsets(sw, sh, opts.width, opts.height));
}
return nativeResize(
return builtinResize(
data, sx, sy, sw, sh, opts.width, opts.height,
opts.method.slice('browser-'.length) as NativeResizeMethod,
opts.method.slice('browser-'.length) as BuiltinResizeMethod,
);
}

View File

@ -12,8 +12,8 @@ export default class Select extends Component<Props, State> {
return (
<div class={style.select}>
<select class={`${style.nativeSelect} ${large ? style.large : ''}`} {...otherProps}/>
<svg class={style.arrow} viewBox="0 0 10 5"><path d="M0 0l5 5 5-5z"/></svg>
<select class={`${style.builtinSelect} ${large ? style.large : ''}`} {...otherProps} />
<svg class={style.arrow} viewBox="0 0 10 5"><path d="M0 0l5 5 5-5z" /></svg>
</div>
);
}

View File

@ -2,7 +2,7 @@
position: relative;
}
.native-select {
.builtin-select {
background: #2f2f2f;
border-radius: 4px;
font: inherit;

View File

@ -163,7 +163,7 @@ export function drawableToImageData(
return ctx.getImageData(0, 0, width, height);
}
export async function nativeDecode(blob: Blob): Promise<ImageData> {
export async function builtinDecode(blob: Blob): Promise<ImageData> {
// Prefer createImageBitmap as it's the off-thread option for Firefox.
const drawable = 'createImageBitmap' in self ?
await createImageBitmap(blob) : await blobToImg(blob);
@ -171,13 +171,13 @@ export async function nativeDecode(blob: Blob): Promise<ImageData> {
return drawableToImageData(drawable);
}
export type NativeResizeMethod = 'pixelated' | 'low' | 'medium' | 'high';
export type BuiltinResizeMethod = 'pixelated' | 'low' | 'medium' | 'high';
export function nativeResize(
export function builtinResize(
data: ImageData,
sx: number, sy: number, sw: number, sh: number,
dw: number, dh: number,
method: NativeResizeMethod,
method: BuiltinResizeMethod,
): ImageData {
const canvasSource = document.createElement('canvas');
canvasSource.width = data.width;

View File

@ -116,7 +116,7 @@ export async function cacheAdditionalProcessors(cacheName: string, buildAssets:
return createImageBitmap(blob).then(() => true, () => false);
})();
// No point caching the WebP decoder if it's supported natively:
// No point caching the WebP decoder if the browser supports it:
if (supportsWebP) {
toCache = toCache.filter(asset => !/webp[\-_]dec/.test(asset));
}