Compare commits

..

2 Commits

Author SHA1 Message Date
Jake Archibald
fd98d67b3e lol this was meant to be 10 seconds. 2018-12-07 14:26:45 +00:00
Jake Archibald
db1db8506e Move early exit for no-rotation. 2018-12-07 14:26:22 +00:00
18 changed files with 274 additions and 337 deletions

View File

@@ -1,2 +0,0 @@
/index.html / 301
/* /index.html 301

View File

@@ -8,6 +8,6 @@
"libimagequant": "ImageOptim/libimagequant#2.12.1" "libimagequant": "ImageOptim/libimagequant#2.12.1"
}, },
"devDependencies": { "devDependencies": {
"napa": "3.0.0" "napa": "^3.0.0"
} }
} }

View File

@@ -8,6 +8,6 @@
"mozjpeg": "mozilla/mozjpeg#v3.3.1" "mozjpeg": "mozilla/mozjpeg#v3.3.1"
}, },
"devDependencies": { "devDependencies": {
"napa": "3.0.0" "napa": "^3.0.0"
} }
} }

View File

@@ -1,6 +1,6 @@
# OptiPNG # OptiPNG
- Source: <http://optipng.sourceforge.net/> - Source: <https://sourceforge.net/project/optipng>
- Version: v0.7.7 - Version: v0.7.7
## Dependencies ## Dependencies

View File

@@ -16,7 +16,7 @@
"zlib": "emscripten-ports/zlib" "zlib": "emscripten-ports/zlib"
}, },
"dependencies": { "dependencies": {
"napa": "3.0.0", "napa": "^3.0.0",
"tar-dependency": "0.0.3" "tar-dependency": "0.0.3"
} }
} }

View File

@@ -8,6 +8,6 @@
"libwebp": "webmproject/libwebp#v1.0.0" "libwebp": "webmproject/libwebp#v1.0.0"
}, },
"devDependencies": { "devDependencies": {
"napa": "3.0.0" "napa": "^3.0.0"
} }
} }

View File

@@ -8,6 +8,6 @@
"libwebp": "webmproject/libwebp#v1.0.0" "libwebp": "webmproject/libwebp#v1.0.0"
}, },
"devDependencies": { "devDependencies": {
"napa": "3.0.0" "napa": "^3.0.0"
} }
} }

View File

@@ -26,8 +26,7 @@ val encode(std::string img, int width, int height, WebPConfig config) {
throw std::runtime_error("Unexpected error"); throw std::runtime_error("Unexpected error");
} }
// Only use use_argb if we really need it, as it's slower. pic.use_argb = !!config.lossless;
pic.use_argb = config.lossless || config.use_sharp_yuv || config.preprocessing > 0;
pic.width = width; pic.width = width;
pic.height = height; pic.height = height;
pic.writer = WebPMemoryWrite; pic.writer = WebPMemoryWrite;

File diff suppressed because one or more lines are too long

Binary file not shown.

387
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "squoosh", "name": "squoosh",
"version": "1.3.1", "version": "1.2.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -62,41 +62,24 @@
} }
}, },
"@fimbul/bifrost": { "@fimbul/bifrost": {
"version": "0.15.0", "version": "0.11.0",
"resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.15.0.tgz", "resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.11.0.tgz",
"integrity": "sha512-sHTwnwA9YhxcVEJkBlfKH1KLmGQGnNYPxk+09w5NnkXelYiiP8a5f351weYfxG0CUPLt1Fgkha20Y/9+jhjn/Q==", "integrity": "sha512-GspMaQafpaUoXWWOUgNLQ4vsV52tIHUt0zpKPeJUYEyMvOSp7FIcZ1eQa7SK3GTusrEiksjMrDX/fwanigC3nQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@fimbul/ymir": "^0.15.0", "@fimbul/ymir": "^0.11.0",
"get-caller-file": "^2.0.0", "get-caller-file": "^1.0.2",
"tslib": "^1.8.1", "tslib": "^1.8.1",
"tsutils": "^3.1.0" "tsutils": "^2.24.0"
},
"dependencies": {
"get-caller-file": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.1.tgz",
"integrity": "sha512-SpOZHfz845AH0wJYVuZk2jWDqFmu7Xubsx+ldIpwzy5pDUpu7OJHK7QYNSA2NPlDSKQwM1GFaAkciOWjjW92Sg==",
"dev": true
},
"tsutils": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.5.2.tgz",
"integrity": "sha512-qIlklNuI/1Dzfm+G+kJV5gg3gimZIX5haYtIVQe7qGyKd7eu8T1t1DY6pz4Sc2CGXAj9s1izycctm9Zfl9sRuQ==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
} }
}, },
"@fimbul/ymir": { "@fimbul/ymir": {
"version": "0.15.0", "version": "0.11.0",
"resolved": "https://registry.npmjs.org/@fimbul/ymir/-/ymir-0.15.0.tgz", "resolved": "https://registry.npmjs.org/@fimbul/ymir/-/ymir-0.11.0.tgz",
"integrity": "sha512-Ow0TfxxQ65vIktHcZyXHeDsGKuzJ9Vt6y77R/aOrXQXLMdYHG+XdbiUWzQbtaGOmNzYVkQfINiFnIdvn5Bn24g==", "integrity": "sha512-aIYQMCWbBXe7DIofgu+4DLCPDCfqbKhPjBg4ajskJdq6CAJgySz6KyhGLNnKiDYZMF93ZsaEB/y3SafyMi98Mg==",
"dev": true, "dev": true,
"requires": { "requires": {
"inversify": "^5.0.0", "inversify": "^4.10.0",
"reflect-metadata": "^0.1.12", "reflect-metadata": "^0.1.12",
"tslib": "^1.8.1" "tslib": "^1.8.1"
} }
@@ -124,9 +107,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "10.12.15", "version": "10.12.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.15.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.6.tgz",
"integrity": "sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==", "integrity": "sha512-+ZWB5Ec1iki99xQFzBlivlKxSZQ+fuUKBott8StBOnLN4dWbRHlgdg1XknpW6g0tweniN5DcOqA64CJyOUPSAw==",
"dev": true "dev": true
}, },
"@types/pretty-bytes": { "@types/pretty-bytes": {
@@ -136,9 +119,9 @@
"dev": true "dev": true
}, },
"@types/webassembly-js-api": { "@types/webassembly-js-api": {
"version": "0.0.2", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/@types/webassembly-js-api/-/webassembly-js-api-0.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/webassembly-js-api/-/webassembly-js-api-0.0.1.tgz",
"integrity": "sha512-htlxJRag6RUiMYUkS8Fjup+TMHO0VarpiF9MrqYaGJ0wXtIraQFz40rfA8VIeCiWy8sgpv3RLmigpgicG8fqGA==", "integrity": "sha1-YtULIBB319TMEJuxytoi/f1FI/s=",
"dev": true "dev": true
}, },
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
@@ -2123,24 +2106,6 @@
"integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=",
"dev": true "dev": true
}, },
"caller-callsite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
"integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=",
"dev": true,
"requires": {
"callsites": "^2.0.0"
}
},
"caller-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz",
"integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=",
"dev": true,
"requires": {
"caller-callsite": "^2.0.0"
}
},
"callsites": { "callsites": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
@@ -2466,9 +2431,9 @@
} }
}, },
"comlink": { "comlink": {
"version": "3.1.1", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/comlink/-/comlink-3.1.1.tgz", "resolved": "https://registry.npmjs.org/comlink/-/comlink-3.0.3.tgz",
"integrity": "sha512-8H9/mrssKE9B4ZMLcN/2bZd1cukP61SrOjm8vhxpRSN8oCw7MSroNNm3Y7/vPUhK5a2AO55vb20rXm3840l3Pw==", "integrity": "sha512-toiZad0dmZIfqkSh4XyD40mRg6/X+8yNvtWCq+f79aIKsJGTf3hY8Ikr4wGx4494h1q9oNHznWMLdorNWsr6dQ==",
"dev": true "dev": true
}, },
"commander": { "commander": {
@@ -2706,9 +2671,9 @@
} }
}, },
"critters-webpack-plugin": { "critters-webpack-plugin": {
"version": "2.1.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/critters-webpack-plugin/-/critters-webpack-plugin-2.1.1.tgz", "resolved": "https://registry.npmjs.org/critters-webpack-plugin/-/critters-webpack-plugin-2.0.1.tgz",
"integrity": "sha512-X1/Y9hZdEDXHehpraW23vISqzwJGy8gqqHSDLRxphmxK8ppzS/cmQPdpbKs4OlcDK5+gioxAJjDjyT1vVpnu+Q==", "integrity": "sha512-b2CRY31n1OxtSMgqKt5kRIGNMYpQJGFlhojl8NWNQ3hyouAYmm42v4yQh1Phxrx9RXIii2MtQOJXXAY1HDXMyg==",
"dev": true, "dev": true,
"requires": { "requires": {
"css": "^2.2.1", "css": "^2.2.1",
@@ -2740,10 +2705,28 @@
"supports-color": "^5.3.0" "supports-color": "^5.3.0"
} }
}, },
"cssnano": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.1.7.tgz",
"integrity": "sha512-AiXL90l+MDuQmRNyypG2P7ux7K4XklxYzNNUd5HXZCNcH8/N9bHPcpN97v8tXgRVeFL/Ed8iP8mVmAAu0ZpT7A==",
"dev": true,
"requires": {
"cosmiconfig": "^5.0.0",
"cssnano-preset-default": "^4.0.5",
"is-resolvable": "^1.0.0",
"postcss": "^7.0.0"
}
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"postcss": { "postcss": {
"version": "7.0.6", "version": "7.0.5",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.6.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz",
"integrity": "sha512-Nq/rNjnHFcKgCDDZYO0lNsl6YWe6U7tTy+ESN+PnLxebL8uBtYX59HZqvrj7YLK5UCyll2hqDsJOo3ndzEW8Ug==", "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"chalk": "^2.4.1", "chalk": "^2.4.1",
@@ -2753,7 +2736,7 @@
}, },
"pretty-bytes": { "pretty-bytes": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=", "integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
"dev": true "dev": true
}, },
@@ -6198,9 +6181,9 @@
} }
}, },
"hash.js": { "hash.js": {
"version": "1.1.7", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz",
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==",
"dev": true, "dev": true,
"requires": { "requires": {
"inherits": "^2.0.3", "inherits": "^2.0.3",
@@ -6468,12 +6451,12 @@
"dev": true "dev": true
}, },
"husky": { "husky": {
"version": "1.2.1", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/husky/-/husky-1.2.1.tgz", "resolved": "https://registry.npmjs.org/husky/-/husky-1.1.4.tgz",
"integrity": "sha512-4Ylal3HWhnDvIszuiyLoVrSGI7QLg/ogkNCoHE34c+yZYzb9kBZNrlTOsdw92cGi3cJT8pPb6CdVfxFkLnc8Dg==", "integrity": "sha512-cZjGpS7qsaBSo3fOMUuR7erQloX3l5XzL1v/RkIqU6zrQImDdU70z5Re9fGDp7+kbYlM2EtS4aYMlahBeiCUGw==",
"dev": true, "dev": true,
"requires": { "requires": {
"cosmiconfig": "^5.0.7", "cosmiconfig": "^5.0.6",
"execa": "^1.0.0", "execa": "^1.0.0",
"find-up": "^3.0.0", "find-up": "^3.0.0",
"get-stdin": "^6.0.0", "get-stdin": "^6.0.0",
@@ -6485,24 +6468,6 @@
"slash": "^2.0.0" "slash": "^2.0.0"
}, },
"dependencies": { "dependencies": {
"cosmiconfig": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.7.tgz",
"integrity": "sha512-PcLqxTKiDmNT6pSpy4N6KtuPwb53W+2tzNvwOZw0WH9N6O0vLIBq0x8aj8Oj75ere4YcGi48bDFCL+3fRJdlNA==",
"dev": true,
"requires": {
"import-fresh": "^2.0.0",
"is-directory": "^0.3.1",
"js-yaml": "^3.9.0",
"parse-json": "^4.0.0"
}
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
},
"find-up": { "find-up": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
@@ -6512,16 +6477,6 @@
"locate-path": "^3.0.0" "locate-path": "^3.0.0"
} }
}, },
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"locate-path": { "locate-path": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
@@ -6621,16 +6576,6 @@
"integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==",
"dev": true "dev": true
}, },
"import-fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz",
"integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=",
"dev": true,
"requires": {
"caller-path": "^2.0.0",
"resolve-from": "^3.0.0"
}
},
"import-local": { "import-local": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz",
@@ -6869,9 +6814,9 @@
} }
}, },
"inversify": { "inversify": {
"version": "5.0.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/inversify/-/inversify-5.0.1.tgz", "resolved": "https://registry.npmjs.org/inversify/-/inversify-4.13.0.tgz",
"integrity": "sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ==", "integrity": "sha512-O5d8y7gKtyRwrvTLZzYET3kdFjqUy58sGpBYMARF13mzqDobpfBXVOPLH7HmnD2VR6Q+1HzZtslGvsdQfeb0SA==",
"dev": true "dev": true
}, },
"invert-kv": { "invert-kv": {
@@ -9215,33 +9160,45 @@
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "6.0.4", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.4.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.2.tgz",
"integrity": "sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg==", "integrity": "sha512-GXmKIvbrN3TV7aVqAzVFaMW8F8wzVX7voEBRO3bDA64+EX37YSayggRJP5Xig6HYHBkWKpFg9W5gg6orklubhg==",
"dev": true "dev": true
}, },
"ajv": { "ajv": {
"version": "6.6.1", "version": "5.5.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.1.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
"integrity": "sha512-ZoJjft5B+EJBjUyu9C9Hc0OZyPZSSlOF+plzouTrg6UlA8f+e/n8NIgBFG/9tppJtpPWfthHakK7juJdNDODww==", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"dev": true, "dev": true,
"requires": { "requires": {
"fast-deep-equal": "^2.0.1", "co": "^4.6.0",
"fast-deep-equal": "^1.0.0",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1", "json-schema-traverse": "^0.3.0"
"uri-js": "^4.2.2"
} }
}, },
"fast-deep-equal": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
"dev": true
},
"har-validator": { "har-validator": {
"version": "5.1.3", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
"dev": true, "dev": true,
"requires": { "requires": {
"ajv": "^6.5.5", "ajv": "^5.3.0",
"har-schema": "^2.0.0" "har-schema": "^2.0.0"
} }
}, },
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
"dev": true
},
"oauth-sign": { "oauth-sign": {
"version": "0.9.0", "version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@@ -9286,36 +9243,25 @@
"tough-cookie": "~2.4.3", "tough-cookie": "~2.4.3",
"tunnel-agent": "^0.6.0", "tunnel-agent": "^0.6.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
},
"dependencies": {
"tough-cookie": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"dev": true,
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
}
}
} }
}, },
"tough-cookie": { "tough-cookie": {
"version": "2.5.0", "version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"psl": "^1.1.28", "psl": "^1.1.24",
"punycode": "^2.1.1" "punycode": "^1.4.1"
}, }
"dependencies": { },
"punycode": { "ws": {
"version": "2.1.1", "version": "6.1.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.0.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "integrity": "sha512-H3dGVdGvW2H8bnYpIDc3u3LH8Wue3Qh+Zto6aXXFzvESkTVT6rAfKR6tR/+coaUvxs8yHtmNV0uioBF62ZGSTg==",
"dev": true "dev": true,
} "requires": {
"async-limiter": "~1.0.0"
} }
} }
} }
@@ -9944,14 +9890,27 @@
"dev": true "dev": true
}, },
"mini-css-extract-plugin": { "mini-css-extract-plugin": {
"version": "0.5.0", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.5.0.tgz", "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.4.4.tgz",
"integrity": "sha512-IuaLjruM0vMKhUUT51fQdQzBYTX49dLj8w68ALEAe2A4iYNpIC4eMac67mt3NzycvjOlf07/kYxJDc0RTl1Wqw==", "integrity": "sha512-o+Jm+ocb0asEngdM6FsZWtZsRzA8koFUudIDwYUfl94M3PejPHG7Vopw5hN9V8WsMkSFpm3tZP3Fesz89EyrfQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"loader-utils": "^1.1.0", "loader-utils": "^1.1.0",
"schema-utils": "^1.0.0", "schema-utils": "^1.0.0",
"webpack-sources": "^1.1.0" "webpack-sources": "^1.1.0"
},
"dependencies": {
"schema-utils": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz",
"integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==",
"dev": true,
"requires": {
"ajv": "^6.1.0",
"ajv-errors": "^1.0.0",
"ajv-keywords": "^3.1.0"
}
}
} }
}, },
"minimalistic-assert": { "minimalistic-assert": {
@@ -10843,9 +10802,9 @@
"dev": true "dev": true
}, },
"pako": { "pako": {
"version": "1.0.7", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.7.tgz", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==", "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
"dev": true "dev": true
}, },
"parallel-transform": { "parallel-transform": {
@@ -11669,9 +11628,9 @@
"dev": true "dev": true
}, },
"preact": { "preact": {
"version": "8.4.2", "version": "8.3.1",
"resolved": "https://registry.npmjs.org/preact/-/preact-8.4.2.tgz", "resolved": "https://registry.npmjs.org/preact/-/preact-8.3.1.tgz",
"integrity": "sha512-TsINETWiisfB6RTk0wh3/mvxbGRvx+ljeBccZ4Z6MPFKgu/KFGyf2Bmw3Z/jlXhL5JlNKY6QAbA9PVyzIy9//A==", "integrity": "sha512-s8H1Y8O9e+mOBo3UP1jvWqArPmjCba2lrrGLlq/0kN1XuIINUbYtf97iiXKxCuG3eYwmppPKnyW2DBrNj/TuTg==",
"dev": true "dev": true
}, },
"prelude-ls": { "prelude-ls": {
@@ -12025,14 +11984,10 @@
} }
}, },
"raw-loader": { "raw-loader": {
"version": "1.0.0", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-1.0.0.tgz", "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz",
"integrity": "sha512-Uqy5AqELpytJTRxYT4fhltcKPj0TyaEpzJDcGz7DFJi+pQOOi3GjR/DOdxTkTsF+NzhnldIoG6TORaBlInUuqA==", "integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=",
"dev": true, "dev": true
"requires": {
"loader-utils": "^1.1.0",
"schema-utils": "^1.0.0"
}
}, },
"read-chunk": { "read-chunk": {
"version": "2.1.0", "version": "2.1.0",
@@ -12608,9 +12563,9 @@
"dev": true "dev": true
}, },
"saxes": { "saxes": {
"version": "3.1.4", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.4.tgz", "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.3.tgz",
"integrity": "sha512-GVZmLJnkS4Vl8Pe9o4nc5ALZ615VOVxCmea8Cs0l+8GZw3RQ5XGOSUomIUfuZuk4Todo44v4y+HY1EATkDDiZg==", "integrity": "sha512-Nc5DXc5A+m3rUDtkS+vHlBWKT7mCKjJPyia7f8YMW773hsXVv2wEHQZGE0zs4+5PLwz9U5Sbl/94Cnd9vHV7Bg==",
"dev": true, "dev": true,
"requires": { "requires": {
"xmlchars": "^1.3.1" "xmlchars": "^1.3.1"
@@ -14061,9 +14016,9 @@
"dev": true "dev": true
}, },
"ts-loader": { "ts-loader": {
"version": "5.3.1", "version": "5.3.0",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-5.3.1.tgz", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-5.3.0.tgz",
"integrity": "sha512-fDDgpBH3SR8xlt2MasLdz3Yy611PQ/UY/KGyo7TgXhTRU/6sS8uGG0nJYnU1OdFBNKcoYbId1UTNaAOUn+i41g==", "integrity": "sha512-lGSNs7szRFj/rK9T1EQuayE3QNLg6izDUxt5jpmq0RG1rU2bapAt7E7uLckLCUPeO1jwxCiet2oRaWovc53UAg==",
"dev": true, "dev": true,
"requires": { "requires": {
"chalk": "^2.3.0", "chalk": "^2.3.0",
@@ -14168,14 +14123,14 @@
} }
}, },
"tslint-config-airbnb": { "tslint-config-airbnb": {
"version": "5.11.1", "version": "5.11.0",
"resolved": "https://registry.npmjs.org/tslint-config-airbnb/-/tslint-config-airbnb-5.11.1.tgz", "resolved": "https://registry.npmjs.org/tslint-config-airbnb/-/tslint-config-airbnb-5.11.0.tgz",
"integrity": "sha512-hkaittm2607vVMe8eotANGN1CimD5tor7uoY3ypg2VTtEcDB/KGWYbJOz58t8LI4cWSyWtgqYQ5F0HwKxxhlkQ==", "integrity": "sha512-o2FhaQtxXi6FQ1v0T2n/rACNos6PhuKRmvemMpWxI+9NJn2OOlJ3+OtEmnCdoF7GPXT3Eyk+Q0q4P96flrPl3w==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslint-consistent-codestyle": "^1.14.1", "tslint-consistent-codestyle": "^1.13.3",
"tslint-eslint-rules": "^5.4.0", "tslint-eslint-rules": "^5.4.0",
"tslint-microsoft-contrib": "~5.2.1" "tslint-microsoft-contrib": "~5.2.0"
} }
}, },
"tslint-config-semistandard": { "tslint-config-semistandard": {
@@ -14217,14 +14172,14 @@
} }
}, },
"tslint-consistent-codestyle": { "tslint-consistent-codestyle": {
"version": "1.14.1", "version": "1.13.3",
"resolved": "https://registry.npmjs.org/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.14.1.tgz", "resolved": "https://registry.npmjs.org/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.13.3.tgz",
"integrity": "sha512-UxGRX2fF5LpZtqYpuPFaIva+2D7ASX3pTVw41yis6Hmw7PPA3cBnFEX1jqRsnyxGrca6mHxz7xDnwCHtOjWJMQ==", "integrity": "sha512-+ocXSNGHqUCUyTJsPhS7xqcC3qf6FyP4vd1jEaXaWaJ5NNN36gKZhqNt3nAWH/YgSV0tYaapjSWMbJQJmn/5MQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@fimbul/bifrost": "^0.15.0", "@fimbul/bifrost": "^0.11.0",
"tslib": "^1.7.1", "tslib": "^1.7.1",
"tsutils": "^2.29.0" "tsutils": "^2.27.0"
} }
}, },
"tslint-eslint-rules": { "tslint-eslint-rules": {
@@ -14582,9 +14537,9 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "3.2.2", "version": "3.1.6",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz",
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==", "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
@@ -14605,6 +14560,56 @@
} }
} }
}, },
"uglifyjs-webpack-plugin": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.3.0.tgz",
"integrity": "sha512-ovHIch0AMlxjD/97j9AYovZxG5wnHOPkL7T1GKochBADp/Zwc44pEWNqpKl1Loupp1WhFg7SlYmHZRUfdAacgw==",
"dev": true,
"requires": {
"cacache": "^10.0.4",
"find-cache-dir": "^1.0.0",
"schema-utils": "^0.4.5",
"serialize-javascript": "^1.4.0",
"source-map": "^0.6.1",
"uglify-es": "^3.3.4",
"webpack-sources": "^1.1.0",
"worker-farm": "^1.5.2"
},
"dependencies": {
"commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true
},
"schema-utils": {
"version": "0.4.7",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz",
"integrity": "sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==",
"dev": true,
"requires": {
"ajv": "^6.1.0",
"ajv-keywords": "^3.1.0"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"requires": {
"commander": "~2.13.0",
"source-map": "~0.6.1"
}
}
}
},
"underscore": { "underscore": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz",
@@ -15027,9 +15032,9 @@
"dev": true "dev": true
}, },
"webpack": { "webpack": {
"version": "4.27.1", "version": "4.25.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.27.1.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.25.1.tgz",
"integrity": "sha512-WArHiLvHrlfyRM8i7f+2SFbr/XbQ0bXqTkPF8JpHOzub5482Y3wx7rEO8stuLGOKOgZJcqcisLhD7LrM/+fVMw==", "integrity": "sha512-T0GU/3NRtO4tMfNzsvpdhUr8HnzA4LTdP2zd+e5zd6CdOH5vNKHnAlO+DvzccfhPdzqRrALOFcjYxx7K5DWmvA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@webassemblyjs/ast": "1.7.11", "@webassemblyjs/ast": "1.7.11",
@@ -15053,7 +15058,7 @@
"node-libs-browser": "^2.0.0", "node-libs-browser": "^2.0.0",
"schema-utils": "^0.4.4", "schema-utils": "^0.4.4",
"tapable": "^1.1.0", "tapable": "^1.1.0",
"terser-webpack-plugin": "^1.1.0", "uglifyjs-webpack-plugin": "^1.2.4",
"watchpack": "^1.5.0", "watchpack": "^1.5.0",
"webpack-sources": "^1.3.0" "webpack-sources": "^1.3.0"
}, },
@@ -15772,9 +15777,9 @@
} }
}, },
"worker-plugin": { "worker-plugin": {
"version": "3.0.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/worker-plugin/-/worker-plugin-3.0.0.tgz", "resolved": "https://registry.npmjs.org/worker-plugin/-/worker-plugin-1.1.1.tgz",
"integrity": "sha512-iLcZBwR3TZO2A8s4S+VNzvuCvAHeZx84IR/zE8O89E+VBTTdn73cwDaUoCroftwtW1Qo0mMxYkJqwf0hyFwmeA==", "integrity": "sha512-s5XtToCv/eZdxZHB1t2Ggdl0F6jw+4qm5s/C3lxIp6z4V2aQRMte22x+v2Y1pbJzwTXE+jqGoa+wWn0oqovYyg==",
"dev": true, "dev": true,
"requires": { "requires": {
"loader-utils": "^1.1.0" "loader-utils": "^1.1.0"

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "squoosh", "name": "squoosh",
"version": "1.3.1", "version": "1.2.2",
"license": "apache-2.0", "license": "apache-2.0",
"scripts": { "scripts": {
"start": "webpack-dev-server --host 0.0.0.0 --hot", "start": "webpack-dev-server --host 0.0.0.0 --hot",
@@ -15,55 +15,55 @@
} }
}, },
"devDependencies": { "devDependencies": {
"@types/node": "10.12.15", "@types/node": "^10.12.6",
"@types/pretty-bytes": "5.1.0", "@types/pretty-bytes": "^5.1.0",
"@types/webassembly-js-api": "0.0.2", "@types/webassembly-js-api": "0.0.1",
"@webcomponents/custom-elements": "1.2.1", "@webcomponents/custom-elements": "^1.2.1",
"@webpack-cli/serve": "0.1.2", "@webpack-cli/serve": "^0.1.2",
"assets-webpack-plugin": "3.9.7", "assets-webpack-plugin": "^3.9.7",
"chokidar": "2.0.4", "chokidar": "^2.0.4",
"classnames": "2.2.6", "classnames": "^2.2.6",
"clean-webpack-plugin": "1.0.0", "clean-webpack-plugin": "^1.0.0",
"comlink": "3.1.1", "comlink": "^3.0.3",
"copy-webpack-plugin": "4.6.0", "copy-webpack-plugin": "^4.6.0",
"critters-webpack-plugin": "2.1.1", "critters-webpack-plugin": "^2.0.1",
"css-loader": "1.0.1", "css-loader": "^1.0.1",
"ejs": "2.6.1", "ejs": "^2.6.1",
"exports-loader": "0.7.0", "exports-loader": "^0.7.0",
"file-drop-element": "0.0.9", "file-drop-element": "^0.0.9",
"file-loader": "2.0.0", "file-loader": "^2.0.0",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "^3.2.0",
"husky": "1.2.1", "husky": "^1.1.4",
"idb-keyval": "3.1.0", "idb-keyval": "^3.1.0",
"linkstate": "1.1.1", "linkstate": "^1.1.1",
"loader-utils": "1.1.0", "loader-utils": "^1.1.0",
"mini-css-extract-plugin": "0.5.0", "mini-css-extract-plugin": "^0.4.4",
"minimatch": "3.0.4", "minimatch": "^3.0.4",
"node-sass": "4.11.0", "node-sass": "^4.11.0",
"optimize-css-assets-webpack-plugin": "5.0.1", "optimize-css-assets-webpack-plugin": "^5.0.1",
"pointer-tracker": "2.0.3", "pointer-tracker": "^2.0.3",
"preact": "8.4.2", "preact": "^8.3.1",
"prerender-loader": "1.2.0", "prerender-loader": "^1.2.0",
"pretty-bytes": "5.1.0", "pretty-bytes": "^5.1.0",
"progress-bar-webpack-plugin": "1.11.0", "progress-bar-webpack-plugin": "^1.11.0",
"raw-loader": "1.0.0", "raw-loader": "^0.5.1",
"sass-loader": "7.1.0", "sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.3", "script-ext-html-webpack-plugin": "^2.1.3",
"source-map-loader": "0.2.4", "source-map-loader": "^0.2.4",
"style-loader": "0.23.1", "style-loader": "^0.23.1",
"terser-webpack-plugin": "1.1.0", "terser-webpack-plugin": "^1.1.0",
"ts-loader": "5.3.1", "ts-loader": "^5.3.0",
"tslint": "5.11.0", "tslint": "^5.11.0",
"tslint-config-airbnb": "5.11.1", "tslint-config-airbnb": "^5.11.0",
"tslint-config-semistandard": "7.0.0", "tslint-config-semistandard": "^7.0.0",
"tslint-react": "3.6.0", "tslint-react": "^3.6.0",
"typed-css-modules": "0.3.7", "typed-css-modules": "^0.3.7",
"typescript": "3.2.2", "typescript": "^3.1.6",
"url-loader": "1.1.2", "url-loader": "^1.1.2",
"webpack": "4.27.1", "webpack": "^4.25.1",
"webpack-bundle-analyzer": "3.0.3", "webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "3.1.2", "webpack-cli": "^3.1.2",
"webpack-dev-server": "3.1.10", "webpack-dev-server": "^3.1.10",
"worker-plugin": "3.0.0" "worker-plugin": "^1.1.1"
} }
} }

View File

@@ -1,5 +0,0 @@
{
"extends": [
"config:base"
]
}

View File

@@ -9,8 +9,6 @@ import '../../lib/SnackBar';
import Intro from '../intro'; import Intro from '../intro';
import '../custom-els/LoadingSpinner'; import '../custom-els/LoadingSpinner';
const ROUTE_EDITOR = '/editor';
const compressPromise = import( const compressPromise = import(
/* webpackChunkName: "main-app" */ /* webpackChunkName: "main-app" */
'../compress', '../compress',
@@ -20,21 +18,15 @@ const offlinerPromise = import(
'../../lib/offliner', '../../lib/offliner',
); );
function back() {
window.history.back();
}
interface Props {} interface Props {}
interface State { interface State {
file?: File | Fileish; file?: File | Fileish;
isEditorOpen: Boolean;
Compress?: typeof import('../compress').default; Compress?: typeof import('../compress').default;
} }
export default class App extends Component<Props, State> { export default class App extends Component<Props, State> {
state: State = { state: State = {
isEditorOpen: false,
file: undefined, file: undefined,
Compress: undefined, Compress: undefined,
}; };
@@ -56,33 +48,22 @@ export default class App extends Component<Props, State> {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
this.setState(window.STATE); this.setState(window.STATE);
const oldCDU = this.componentDidUpdate; const oldCDU = this.componentDidUpdate;
this.componentDidUpdate = (props, state, prev) => { this.componentDidUpdate = (props, state) => {
if (oldCDU) oldCDU.call(this, props, state, prev); if (oldCDU) oldCDU.call(this, props, state);
window.STATE = this.state; window.STATE = this.state;
}; };
} }
// Since iOS 10, Apple tries to prevent disabling pinch-zoom. This is great in theory, but
// really breaks things on Squoosh, as you can easily end up zooming the UI when you mean to
// zoom the image. Once you've done this, it's really difficult to undo. Anyway, this seems to
// prevent it.
document.body.addEventListener('gesturestart', (event) => {
event.preventDefault();
});
window.addEventListener('popstate', this.onPopState);
} }
@bind @bind
private onFileDrop({ file }: FileDropEvent) { private onFileDrop(event: FileDropEvent) {
const { file } = event;
if (!file) return; if (!file) return;
this.openEditor();
this.setState({ file }); this.setState({ file });
} }
@bind @bind
private onIntroPickFile(file: File | Fileish) { private onIntroPickFile(file: File | Fileish) {
this.openEditor();
this.setState({ file }); this.setState({ file });
} }
@@ -93,25 +74,18 @@ export default class App extends Component<Props, State> {
} }
@bind @bind
private onPopState() { private onBack() {
this.setState({ isEditorOpen: location.pathname === ROUTE_EDITOR }); this.setState({ file: undefined });
} }
@bind render({}: Props, { file, Compress }: State) {
private openEditor() {
if (this.state.isEditorOpen) return;
history.pushState(null, '', ROUTE_EDITOR);
this.setState({ isEditorOpen: true });
}
render({}: Props, { file, isEditorOpen, Compress }: State) {
return ( return (
<div id="app" class={style.app}> <div id="app" class={style.app}>
<file-drop accept="image/*" onfiledrop={this.onFileDrop} class={style.drop}> <file-drop accept="image/*" onfiledrop={this.onFileDrop} class={style.drop}>
{!isEditorOpen {(!file)
? <Intro onFile={this.onIntroPickFile} showSnack={this.showSnack} /> ? <Intro onFile={this.onIntroPickFile} showSnack={this.showSnack} />
: (Compress) : (Compress)
? <Compress file={file!} showSnack={this.showSnack} onBack={back} /> ? <Compress file={file} showSnack={this.showSnack} onBack={this.onBack} />
: <loading-spinner class={style.appLoader}/> : <loading-spinner class={style.appLoader}/>
} }
<snack-bar ref={linkRef(this, 'snackbar')} /> <snack-bar ref={linkRef(this, 'snackbar')} />

View File

@@ -40,9 +40,7 @@ import Checkbox from '../checkbox';
import Expander from '../expander'; import Expander from '../expander';
import Select from '../select'; import Select from '../select';
const encoderOptionsComponentMap: { const encoderOptionsComponentMap = {
[x: string]: (new (...args: any[]) => Component<any, any>) | undefined;
} = {
[identity.type]: undefined, [identity.type]: undefined,
[optiPNG.type]: OptiPNGEncoderOptions, [optiPNG.type]: OptiPNGEncoderOptions,
[mozJPEG.type]: MozJpegEncoderOptions, [mozJPEG.type]: MozJpegEncoderOptions,

View File

@@ -43,7 +43,6 @@ $horizontalPadding: 15px;
.text-field { .text-field {
background: #fff; background: #fff;
color: #000;
font: inherit; font: inherit;
border: none; border: none;
padding: 2px 0 2px 10px; padding: 2px 0 2px 10px;

View File

@@ -160,7 +160,7 @@ function stateForNewSourceData(state: State, newSource: SourceImage): State {
for (const i of [0, 1]) { for (const i of [0, 1]) {
// Ditch previous encodings // Ditch previous encodings
const downloadUrl = state.sides[i].downloadUrl; const downloadUrl = state.sides[i].downloadUrl;
if (downloadUrl) URL.revokeObjectURL(downloadUrl); if (downloadUrl) URL.revokeObjectURL(downloadUrl!);
newState = cleanMerge(state, `sides.${i}`, { newState = cleanMerge(state, `sides.${i}`, {
preprocessed: undefined, preprocessed: undefined,
@@ -240,8 +240,6 @@ export default class Compress extends Component<Props, State> {
private readonly encodeCache = new ResultCache(); private readonly encodeCache = new ResultCache();
private readonly leftProcessor = new Processor(); private readonly leftProcessor = new Processor();
private readonly rightProcessor = new Processor(); private readonly rightProcessor = new Processor();
// For debouncing calls to updateImage for each side.
private readonly updateImageTimeoutIds: [number?, number?] = [undefined, undefined];
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
@@ -309,8 +307,10 @@ export default class Compress extends Component<Props, State> {
// The image only needs updated if the encoder/preprocessor settings have changed, or the // The image only needs updated if the encoder/preprocessor settings have changed, or the
// source has changed. // source has changed.
if (sourceDataChanged || encoderChanged || preprocessorChanged) { if (sourceDataChanged || encoderChanged || preprocessorChanged) {
this.queueUpdateImage(i, { this.updateImage(i, {
skipPreprocessing: !sourceDataChanged && !preprocessorChanged, skipPreprocessing: !sourceDataChanged && !preprocessorChanged,
}).catch((err) => {
console.error(err);
}); });
} }
} }
@@ -319,14 +319,9 @@ export default class Compress extends Component<Props, State> {
private async onCopyToOtherClick(index: 0 | 1) { private async onCopyToOtherClick(index: 0 | 1) {
const otherIndex = (index + 1) % 2; const otherIndex = (index + 1) % 2;
const oldSettings = this.state.sides[otherIndex]; const oldSettings = this.state.sides[otherIndex];
const newSettings = { ...this.state.sides[index] };
// Create a new object URL for the new settings. This avoids both sides sharing a URL, which
// means it can be safely revoked without impacting the other side.
if (newSettings.file) newSettings.downloadUrl = URL.createObjectURL(newSettings.file);
this.setState({ this.setState({
sides: cleanSet(this.state.sides, otherIndex, newSettings), sides: cleanSet(this.state.sides, otherIndex, this.state.sides[index]),
}); });
const result = await this.props.showSnack('Settings copied across', { const result = await this.props.showSnack('Settings copied across', {
@@ -457,27 +452,6 @@ export default class Compress extends Component<Props, State> {
} }
} }
/**
* Debounce the heavy lifting of updateImage.
* Otherwise, the thrashing causes jank, and sometimes crashes iOS Safari.
*/
private queueUpdateImage(index: number, options: UpdateImageOptions = {}): void {
// Call updateImage after this delay, unless queueUpdateImage is called again, in which case the
// timeout is reset.
const delay = 100;
clearTimeout(this.updateImageTimeoutIds[index]);
this.updateImageTimeoutIds[index] = self.setTimeout(
() => {
this.updateImage(index, options).catch((err) => {
console.error(err);
});
},
delay,
);
}
private async updateImage(index: number, options: UpdateImageOptions = {}): Promise<void> { private async updateImage(index: number, options: UpdateImageOptions = {}): Promise<void> {
const { const {
skipPreprocessing = false, skipPreprocessing = false,
@@ -576,9 +550,9 @@ export default class Compress extends Component<Props, State> {
mobileView={mobileView} mobileView={mobileView}
preprocessorState={side.latestSettings.preprocessorState} preprocessorState={side.latestSettings.preprocessorState}
encoderState={side.latestSettings.encoderState} encoderState={side.latestSettings.encoderState}
onEncoderTypeChange={this.onEncoderTypeChange.bind(this, index as 0|1)} onEncoderTypeChange={this.onEncoderTypeChange.bind(this, index)}
onEncoderOptionsChange={this.onEncoderOptionsChange.bind(this, index as 0|1)} onEncoderOptionsChange={this.onEncoderOptionsChange.bind(this, index)}
onPreprocessorOptionsChange={this.onPreprocessorOptionsChange.bind(this, index as 0|1)} onPreprocessorOptionsChange={this.onPreprocessorOptionsChange.bind(this, index)}
/> />
)); ));
@@ -592,7 +566,7 @@ export default class Compress extends Component<Props, State> {
source={source} source={source}
loading={loading || side.loading} loading={loading || side.loading}
copyDirection={copyDirections[index]} copyDirection={copyDirections[index]}
onCopyToOtherClick={this.onCopyToOtherClick.bind(this, index as 0|1)} onCopyToOtherClick={this.onCopyToOtherClick.bind(this, index)}
buttonPosition={mobileView ? 'stack-right' : buttonPositions[index]} buttonPosition={mobileView ? 'stack-right' : buttonPositions[index]}
> >
{!mobileView ? null : [ {!mobileView ? null : [

View File

@@ -251,11 +251,6 @@ module.exports = async function (_, env) {
filename: '_headers', filename: '_headers',
}), }),
isProd && new AssetTemplatePlugin({
template: path.join(__dirname, '_redirects.ejs'),
filename: '_redirects',
}),
new ScriptExtHtmlPlugin({ new ScriptExtHtmlPlugin({
inline: ['first'] inline: ['first']
}), }),