Compare commits

...

306 Commits

Author SHA1 Message Date
Surma
b6f69c57cf moar stuff 2019-02-07 17:35:48 +00:00
Surma
9e19c36b42 Add Xargo and config and stuff 2019-02-07 00:29:11 +00:00
Surma
cf45520be3 Cleanup and add pkg 2019-02-06 10:25:56 +00:00
Surma
8faf8a5b48 First attempt at Oxipng 2019-02-05 19:40:22 +00:00
Ewout ter Hoeven
cb16fb5437 Update libwebp to 1.0.2 (#439)
* Update package.json

* Update package.json

* Update README.md

* Update README.md

* Use cmake for libwebp

* Minimize libwebp
2019-02-05 15:45:03 +00:00
Surma
36f5fa2c47 Merge pull request #449 from GoogleChromeLabs/renovate/webpack-cli-3.x
Update dependency webpack-cli to v3.2.3
2019-02-05 10:20:37 +00:00
renovate[bot]
51ad22e72c Update dependency webpack-cli to v3.2.3 2019-02-05 03:22:41 +00:00
Surma
1a355c0c16 Merge pull request #448 from GoogleChromeLabs/renovate/terser-webpack-plugin-1.x
Update dependency terser-webpack-plugin to v1.2.2
2019-02-04 15:39:59 +00:00
renovate[bot]
fe5ba08963 Update dependency terser-webpack-plugin to v1.2.2 2019-02-04 14:46:39 +00:00
Jake Archibald
7fc994d4af This fixes #446 and sometimes it's best not to ask too many questions. (#447) 2019-02-04 13:34:56 +00:00
Surma
a0a8285e02 Merge pull request #445 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.21
2019-02-01 10:08:47 +00:00
renovate[bot]
da2e35f613 Update dependency @types/node to v10.12.21 2019-02-01 05:41:46 +00:00
Surma
09bdc25352 Merge pull request #443 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.20
2019-01-31 10:44:30 +00:00
renovate[bot]
ad263a9c36 Update dependency @types/node to v10.12.20 2019-01-30 23:41:51 +00:00
Surma
c8d8d4e43d Merge pull request #442 from GoogleChromeLabs/renovate/progress-bar-webpack-plugin-1.x
Update dependency progress-bar-webpack-plugin to v1.12.1
2019-01-29 18:11:12 +00:00
renovate[bot]
94249b8a93 Update dependency progress-bar-webpack-plugin to v1.12.1 2019-01-29 15:49:49 +00:00
Surma
edd2c51eb6 Merge pull request #441 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.19
2019-01-29 10:08:35 +00:00
renovate[bot]
1d24e9399f Update dependency @types/node to v10.12.19 2019-01-29 00:45:56 +00:00
Surma
3a0062276d Merge pull request #436 from GoogleChromeLabs/optimize-rotate
Optimize rotate
2019-01-23 22:45:10 -05:00
Surma
1993cf3f6c Remove unused bpp 2019-01-23 14:15:39 -05:00
Surma
c97aac31c6 Revert "Add rotate user timing"
This reverts commit 887db675c8.
2019-01-23 14:06:24 -05:00
Surma
507921cbe8 Use Uint32Array to copy an entire pixel per op 2019-01-23 10:17:52 -05:00
Surma
887db675c8 Add rotate user timing 2019-01-23 10:11:35 -05:00
Surma
3917618e4e Merge pull request #435 from GoogleChromeLabs/renovate/progress-bar-webpack-plugin-1.x
Update dependency progress-bar-webpack-plugin to v1.12.0
2019-01-22 13:36:30 -05:00
renovate[bot]
3c42d2e6a4 Update dependency progress-bar-webpack-plugin to v1.12.0 2019-01-22 18:01:07 +00:00
Surma
db8777b7f7 Merge pull request #434 from GoogleChromeLabs/renovate/clean-webpack-plugin-1.x
Update dependency clean-webpack-plugin to v1.0.1
2019-01-22 09:04:33 -05:00
renovate[bot]
18c2cddee2 Update dependency clean-webpack-plugin to v1.0.1 2019-01-22 05:14:58 +00:00
Surma
3ff9d3a1fa Merge pull request #432 from GoogleChromeLabs/renovate/critters-webpack-plugin-2.x
Update dependency critters-webpack-plugin to v2.2.0
2019-01-18 14:21:42 -05:00
renovate[bot]
6503667c78 Update dependency critters-webpack-plugin to v2.2.0 2019-01-18 16:46:25 +00:00
Surma
0fa95f84d4 Merge pull request #431 from GoogleChromeLabs/renovate/typescript-3.x
Update dependency typescript to v3.2.4
2019-01-17 19:45:53 -05:00
renovate[bot]
cf91a90270 Update dependency typescript to v3.2.4 2019-01-17 22:56:11 +00:00
Surma
690052f989 Merge pull request #427 from GoogleChromeLabs/renovate/tslint-5.x
Update dependency tslint to v5.12.1
2019-01-10 23:06:29 +00:00
renovate[bot]
b3e935f7e4 Update dependency tslint to v5.12.1 2019-01-10 22:41:01 +00:00
Surma
17314ebd29 Merge pull request #424 from GoogleChromeLabs/renovate/webpack-cli-3.x
Update dependency webpack-cli to v3.2.1
2019-01-10 17:10:54 +00:00
renovate[bot]
adc437cd51 Update dependency webpack-cli to v3.2.1 2019-01-07 10:23:37 +00:00
Surma
0e97b74510 Merge pull request #422 from GoogleChromeLabs/renovate/critters-webpack-plugin-2.x
Update dependency critters-webpack-plugin to v2.1.3
2019-01-07 11:21:36 +01:00
renovate[bot]
9ffb475cac Update dependency critters-webpack-plugin to v2.1.3 2019-01-05 20:00:02 +00:00
Surma
faa2b030c5 Merge pull request #423 from GoogleChromeLabs/renovate/ts-loader-5.x
Update dependency ts-loader to v5.3.3
2019-01-05 19:59:13 +00:00
renovate[bot]
e3b3b10e2a Update dependency ts-loader to v5.3.3 2019-01-05 19:19:18 +00:00
Surma
b569cf268c Merge pull request #415 from GoogleChromeLabs/renovate/critters-webpack-plugin-2.x
Update dependency critters-webpack-plugin to v2.1.2
2019-01-03 19:34:04 +00:00
renovate[bot]
b154b77556 Update dependency critters-webpack-plugin to v2.1.2 2019-01-03 19:24:19 +00:00
Surma
84c0f30a7c Merge pull request #420 from GoogleChromeLabs/renovate/webpack-cli-serve-0.x
Update dependency @webpack-cli/serve to v0.1.3
2019-01-03 19:23:19 +00:00
renovate[bot]
16463ff76d Update dependency @webpack-cli/serve to v0.1.3 2019-01-03 19:10:09 +00:00
Surma
8314e9e24b Merge pull request #421 from GoogleChromeLabs/renovate/webpack-cli-3.x
Update dependency webpack-cli to v3.2.0
2019-01-03 19:08:32 +00:00
renovate[bot]
a33c557818 Update dependency webpack-cli to v3.2.0 2019-01-03 05:49:28 +00:00
Surma
6fbdc65ad0 Merge pull request #418 from GoogleChromeLabs/renovate/husky-1.x
Update dependency husky to v1.3.1
2018-12-28 10:05:10 -05:00
renovate[bot]
9c9b6c4711 Update dependency husky to v1.3.1 2018-12-28 06:24:00 +00:00
Surma
46278d04c3 Merge pull request #414 from GoogleChromeLabs/renovate/terser-webpack-plugin-1.x
Update dependency terser-webpack-plugin to v1.2.1
2018-12-27 07:41:51 -05:00
renovate[bot]
c1c16508b5 Update dependency terser-webpack-plugin to v1.2.1 2018-12-27 12:35:42 +00:00
Surma
ed1b983711 Merge pull request #412 from GoogleChromeLabs/renovate/loader-utils-1.x
Update dependency loader-utils to v1.2.0
2018-12-24 22:04:29 +00:00
renovate[bot]
ec23e28eda Update dependency loader-utils to v1.2.0 2018-12-24 18:49:01 +00:00
Surma
d48b49e8e4 Merge pull request #411 from GoogleChromeLabs/renovate/webpack-dev-server-3.x
Update dependency webpack-dev-server to v3.1.14
2018-12-24 18:48:10 +00:00
renovate[bot]
14308970c6 Update dependency webpack-dev-server to v3.1.14 2018-12-24 10:09:10 +00:00
Surma
38e86e1012 Merge pull request #410 from GoogleChromeLabs/renovate/webpack-dev-server-3.x
Update dependency webpack-dev-server to v3.1.13
2018-12-22 19:52:50 +00:00
renovate[bot]
e9a33af831 Update dependency webpack-dev-server to v3.1.13 2018-12-22 19:29:27 +00:00
Surma
6a63e5dbb2 Merge pull request #409 from GoogleChromeLabs/renovate/terser-webpack-plugin-1.x
Update dependency terser-webpack-plugin to v1.2.0
2018-12-22 16:48:48 +00:00
renovate[bot]
1e1892a3d5 Update dependency terser-webpack-plugin to v1.2.0 2018-12-22 16:16:11 +00:00
Surma
8bff9a2973 Merge pull request #408 from GoogleChromeLabs/renovate/webpack-dev-server-3.x
Update dependency webpack-dev-server to v3.1.12
2018-12-22 16:15:31 +00:00
renovate[bot]
cbe753dd29 Update dependency webpack-dev-server to v3.1.12 2018-12-22 15:09:41 +00:00
Surma
b047845b43 Merge pull request #407 from GoogleChromeLabs/renovate/webpack-dev-server-3.x
Update dependency webpack-dev-server to v3.1.11
2018-12-21 19:17:48 +00:00
renovate[bot]
1bebc75381 Update dependency webpack-dev-server to v3.1.11 2018-12-21 18:11:16 +00:00
Surma
93c46bfc8d Merge pull request #406 from GoogleChromeLabs/renovate/ts-loader-5.x
Update dependency ts-loader to v5.3.2
2018-12-21 10:46:22 +00:00
renovate[bot]
a3d0f5963e Update dependency ts-loader to v5.3.2 2018-12-21 06:30:17 +00:00
Surma
006b82bf05 Merge pull request #404 from GoogleChromeLabs/renovate/file-loader-3.x
Update dependency file-loader to v3
2018-12-20 20:06:12 +00:00
renovate[bot]
c36e37ac6b Update dependency file-loader to v3 2018-12-20 17:42:21 +00:00
Surma
3cf6d7385a Merge pull request #403 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.18
2018-12-19 18:44:47 +00:00
renovate[bot]
9045b2fa97 Update dependency @types/node to v10.12.18 2018-12-19 18:26:21 +00:00
Surma
be6f3b9c6d Merge pull request #402 from GoogleChromeLabs/renovate/webpack-4.x
Update dependency webpack to v4.28.0
2018-12-19 13:00:37 +00:00
renovate[bot]
5a699b7ce9 Update dependency webpack to v4.28.0 2018-12-19 12:34:47 +00:00
Surma
f366a78e87 Merge pull request #400 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.17
2018-12-18 22:32:16 +00:00
renovate[bot]
c63c7ead51 Update dependency @types/node to v10.12.17 2018-12-18 22:02:40 +00:00
Surma
ecfa5902cd Merge pull request #399 from GoogleChromeLabs/renovate/husky-1.x
Update dependency husky to v1.3.0
2018-12-18 20:06:49 +00:00
renovate[bot]
444027b496 Update dependency husky to v1.3.0 2018-12-18 19:56:39 +00:00
Surma
9c5dcb93c7 Merge pull request #398 from GoogleChromeLabs/renovate/tslint-5.x
Update dependency tslint to v5.12.0
2018-12-18 13:12:06 +00:00
renovate[bot]
9594221271 Update dependency tslint to v5.12.0 2018-12-18 11:48:40 +00:00
Jake Archibald
01823d3b75 1.3.1 2018-12-18 09:39:59 +00:00
Surma
db07a90139 Merge pull request #396 from GoogleChromeLabs/kosamari-patch-2
Update README.md for OptiPNG
2018-12-17 19:15:55 +00:00
Mariko Kosaka
962d0928d3 Update README.md
closes #367
updating incorrect URL
2018-12-17 13:43:18 -05:00
Jake Archibald
e67d50c8e6 Preventing zoom in iOS Safari. (#395) 2018-12-17 17:05:41 +00:00
Surma
f9b2f17852 Merge pull request #385 from GoogleChromeLabs/renovate/typescript-3.x
Update dependency typescript to v3.2.2
2018-12-17 12:42:47 +00:00
Surma
9746a9f5ed Fix typings for TypeScript v3.2 2018-12-17 12:36:57 +00:00
renovate[bot]
be0877ecb0 Update dependency typescript to v3.2.2 2018-12-17 12:36:52 +00:00
Jake Archibald
d2fcdfae43 Debouncing input. Fixes #277 (#394)
* Debouncing input

* Clarifying comment

* More comments and clarifications
2018-12-17 11:54:30 +00:00
Surma
2c9eb46941 Merge pull request #393 from GoogleChromeLabs/webp-sharp-fix
Fixing sharp & preprocess settings. Fixes #392.
2018-12-17 10:59:29 +00:00
Jake Archibald
d30a85fd48 Using use_argb conditionally 2018-12-17 10:21:30 +00:00
Jake Archibald
9260bed1b1 Fixing sharp & preprocess settings 2018-12-17 10:01:47 +00:00
Surma
f6d12985a9 Merge pull request #390 from GoogleChromeLabs/renovate/worker-plugin-3.x
Update dependency worker-plugin to v3
2018-12-14 18:55:31 +00:00
renovate[bot]
10c9b1db7c Update dependency worker-plugin to v3 2018-12-14 18:10:49 +00:00
Surma
4fb17be8de Merge pull request #388 from GoogleChromeLabs/renovate/raw-loader-1.x
Update dependency raw-loader to v1
2018-12-14 18:08:27 +00:00
renovate[bot]
b592b1a088 Update dependency raw-loader to v1 2018-12-14 15:47:28 +00:00
Surma
0544a6507e Merge pull request #386 from GoogleChromeLabs/renovate/webpack-4.x
Update dependency webpack to v4.27.1
2018-12-14 15:45:24 +00:00
renovate[bot]
1e20ff15ed Update dependency webpack to v4.27.1 2018-12-14 15:28:46 +00:00
Surma
04a0ec0645 Merge pull request #383 from GoogleChromeLabs/renovate/tslint-config-airbnb-5.x
Update dependency tslint-config-airbnb to v5.11.1
2018-12-14 15:01:37 +00:00
renovate[bot]
f355292fe3 Update dependency tslint-config-airbnb to v5.11.1 2018-12-14 13:48:22 +00:00
Surma
32e4d813de Merge pull request #382 from GoogleChromeLabs/renovate/ts-loader-5.x
Update dependency ts-loader to v5.3.1
2018-12-14 13:47:40 +00:00
renovate[bot]
f960f5ea87 Update dependency ts-loader to v5.3.1 2018-12-14 10:18:46 +00:00
Surma
aa6f83e2fa Merge pull request #381 from GoogleChromeLabs/renovate/preact-8.x
Update dependency preact to v8.4.2
2018-12-14 10:18:06 +00:00
renovate[bot]
c09e1f1895 Update dependency preact to v8.4.2 2018-12-14 10:08:17 +00:00
Surma
7c311928dd Merge pull request #379 from GoogleChromeLabs/renovate/husky-1.x
Update dependency husky to v1.2.1
2018-12-14 10:07:31 +00:00
renovate[bot]
5f1c8bcb6b Update dependency husky to v1.2.1 2018-12-14 09:35:57 +00:00
Surma
93bc20f014 Merge pull request #378 from GoogleChromeLabs/renovate/critters-webpack-plugin-2.x
Update dependency critters-webpack-plugin to v2.1.1
2018-12-14 09:35:06 +00:00
renovate[bot]
d29d9571c6 Update dependency critters-webpack-plugin to v2.1.1 2018-12-14 09:28:18 +00:00
Surma
3d47dfc820 Merge pull request #375 from GoogleChromeLabs/renovate/webassembly-js-api-0.x
Update dependency @types/webassembly-js-api to v0.0.2
2018-12-14 09:27:04 +00:00
renovate[bot]
d7846c9add Update dependency @types/webassembly-js-api to v0.0.2 2018-12-14 08:29:39 +00:00
Surma
4d6fe9d641 Merge pull request #377 from GoogleChromeLabs/renovate/comlink-3.x
Update dependency comlink to v3.1.1
2018-12-14 08:28:41 +00:00
renovate[bot]
205feba75d Update dependency comlink to v3.1.1 2018-12-14 00:59:15 +00:00
Surma
ca7663b94a Merge pull request #384 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.15
2018-12-14 00:54:30 +00:00
renovate[bot]
83e45f054b Update dependency @types/node to v10.12.15 2018-12-13 22:44:08 +00:00
Surma
783e893a67 Merge pull request #376 from GoogleChromeLabs/renovate/node-10.x
Update dependency @types/node to v10.12.14
2018-12-13 19:09:00 +00:00
renovate[bot]
0a941866a9 Update dependency @types/node to v10.12.14 2018-12-13 19:03:04 +00:00
Surma
04edfe0085 Merge pull request #380 from GoogleChromeLabs/renovate/mini-css-extract-plugin-0.x
Update dependency mini-css-extract-plugin to v0.5.0
2018-12-13 19:02:16 +00:00
renovate[bot]
6cae634eca Update dependency mini-css-extract-plugin to v0.5.0 2018-12-13 18:53:39 +00:00
Surma
8c7bf278dc Merge pull request #374 from GoogleChromeLabs/renovate/pin-dependencies
Pin dependencies
2018-12-13 13:30:08 +00:00
renovate[bot]
f6106650b5 Pin dependencies 2018-12-13 13:20:33 +00:00
Surma
166e606034 Merge pull request #373 from GoogleChromeLabs/renovate/configure
Configure Renovate
2018-12-13 13:19:16 +00:00
renovate[bot]
c997e6a3e4 Add renovate.json 2018-12-13 13:13:44 +00:00
Jake Archibald
2a1b6dc9da 1.3.0 2018-12-12 12:59:05 +00:00
Maciej Matuszewski
129c33fa12 Add basic history handling (#288) (#309)
* Add basic history handling (#288)

* Move history management to Compress component

* Remove unused pathname property from history

* Rename history listener functions

* Use history.back instead of history.replace

* Support going forward in history. Persist last selected file in runtime

* Add netlify redirects file

* Use 301 status code for redirect

* Cleanup _redirects file

* Use 200 status code for redirects

* Simplify onPopState function

* Always redirect to 301 with url rewrite

* Remove redundant history function

* Remove file check on render. Call openEditor synchronously

* Use pushState only if user is on the initial screen. Mount history listener in constructor

* Simplify openEditor condition

* Update early return condition

* Rolling abstractions back into the main component
2018-12-12 12:58:03 +00:00
Jake Archibald
3245987113 Prevent both sides sharing a download URL. (#369) 2018-12-12 12:51:06 +00:00
Jake Archibald
593ad62cbb 1.2.3 2018-12-10 12:25:27 +00:00
Andrea Somaini
a625a76e9e Fixed blank text-fields with dark browser theme (#365)
When using dark browser themes the text-fields' text-color becomes white, so the text in those white background text-fields is unreadable.

Patched text-color so that it now is readable.
2018-12-10 12:24:12 +00:00
Jake Archibald
c2a305304b Rotation optimise. Fixes #362 (#363)
* Move early exit for no-rotation.

* lol this was meant to be 10 seconds.
2018-12-09 07:11:11 +00:00
Jake Archibald
7389c507fb 1.2.2 2018-12-04 10:57:07 +00:00
Jake Archibald
68f0f23016 Prevent image becoming misshapen on resize. Fixes #359. (#360) 2018-12-04 10:55:32 +00:00
Jake Archibald
dc809dde30 1.2.1 2018-11-30 11:44:33 +00:00
Jake Archibald
80dfa03b94 Avoid wrapping a single button (#357)
* Avoid wrapping a single button

* Making the zoom controls appear on the bottom, when the controls are positioned on the bottom
2018-11-30 11:44:15 +00:00
Jake Archibald
fca7a5350d 1.2.0 2018-11-30 11:02:10 +00:00
Jake Archibald
1b693fb57a Rotate (#322)
* Basic rotate & flip

* Flipping resize when orientation changes

* Hack around critters issue.

* Removing generator. Huge perf boost.

* Stable positioning

* Creating input processors

* Allowing rotation to be changed

* Reverting old change

* Adding tooltips

* No more flip

* Removing need for wrapper element boxing

* Adding comment

* Addressing nits

* Bleh
2018-11-30 11:00:25 +00:00
Jake Archibald
7723bd3b5f Making processor-worker a real worker (to TypeScript) (#351) 2018-11-29 08:39:48 +00:00
Jake Archibald
723fc142ec 1.1.0 2018-11-29 08:01:46 +00:00
Vadym
06d4d946d9 Display uploaded file name in the document title (#244) (#326)
* Add filename to the document.title

* minor fixes

* no-space-before-colon
2018-11-29 07:59:34 +00:00
Jake Archibald
428b7d976d Create CSS typings before build. Fixes #251. (#350)
* Create CSS typings before build

* Let's try this.

* Adding comment

* Remove hack from travis
2018-11-28 16:09:08 +00:00
Tiger Oakes
32f2b4e573 Remove TypeScript-specific static Compress import (#338)
Previously, Compress had a static import only used by TypeScript, 
as the module was loaded dynamically. The type can be replaced with
`import().default`.

TypeScript 2.9 introduced the ability to use `import()` within type 
statements.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
2018-11-28 14:57:05 +00:00
Jake Archibald
b3ab983f02 Removing if-env (it used the dreaded event-stream). Fixes 339. (#340)
Also updating node-sass.
2018-11-27 11:53:23 +00:00
Surma
e011724af4 Merge pull request #331 from GoogleChromeLabs/fix-windows-build
Fix build on Windows
2018-11-22 11:21:24 +00:00
Jason Miller
f11a6cb38a Fix build on Windows
Fixes #282.
2018-11-21 11:18:01 -05:00
Jake Archibald
adf6d3c60d Preventing form defaults. Fixes #294. (#329) 2018-11-21 07:14:40 +00:00
Surma
bb8f35ce09 Merge pull request #323 from GoogleChromeLabs/sass-downgrade
Downgrade node-sass (fixes #319)
2018-11-19 12:22:00 +00:00
Surma
ae9ae31ddc Downgrade node-sass (fixes #319) 2018-11-19 12:06:47 +00:00
Mariko Kosaka
67893817b5 Update issue templates to include feature request (#318) 2018-11-19 01:26:50 -08:00
Mariko Kosaka
f8da5b153d Merge pull request #304 : Create issue templates
Create issue templates
2018-11-19 11:55:40 +09:00
Mariko Kosaka
e2a956a088 ask to attach images 2018-11-19 11:51:08 +09:00
Surma
5c5b001fc7 Merge pull request #269 from DanielRuf/ci/test-nodejs-6-8-10-11
ci: test Node.js 8, 10 and 11
2018-11-18 13:24:37 +00:00
Daniel Ruf
e4beafed97 ci: do not test on Node.js 6 2018-11-18 14:00:28 +01:00
Mariko Kosaka
553a504140 Merge pull request #306 from Jarrku/codec-readme-typo
Fix typo
2018-11-16 11:21:28 -08:00
Simon VDB
44dd2ee808 Fix typo 2018-11-15 22:02:11 +01:00
Surma
b36c851b2a Create issue templates 2018-11-15 10:34:00 -08:00
Jamie Farrelly
0502d70cdf Preventing images from being dragged in Edge (#290) 2018-11-14 14:47:00 -08:00
Cătălin Mariș
86546574bb Further losslessly optimize logo.svg (#283) 2018-11-14 14:45:47 -08:00
Jake Archibald
f351712130 Building on #275 (#289)
* Upgrade devDependcies. Replace UglifyJS ⚰ with TerserJS 👶 Fix TypeScript compiler errors

* Remove babel and associated plugins

* Re-enable strictNullChecks and noImplicitAny

* Use surma's better ga type definition.
`ts-ignore` document.activeElement potential null warnings

* Avoiding ignores
2018-11-14 14:04:01 -08:00
Surma
c7f2ae2234 Merge pull request #279 from KraigWalker/bug/manifest-orientation
Fix #268 - change orientation to "any" from "portrait" in manifest.json
2018-11-14 08:25:09 -08:00
Kraig Walker
436f689115 fixes #268 - change orientation to "any" from "portrait" in manifest.json 2018-11-13 17:34:03 +00:00
Jake Archibald
951c7af724 Allow text fields next to range inputs be empty (yeah that's horrendous grammar but I'm very tired) (#273) 2018-11-13 07:48:25 -08:00
Jake Archibald
53b46f879f Avoid "update found" on initial load. 2018-11-13 07:37:07 -08:00
Daniel Ruf
cbe82112ab ci: test Node.js 6, 8, 10 and 11 2018-11-13 11:21:51 +01:00
Surma
7f5562ccfe Update README.md 2018-11-12 10:35:58 -08:00
Surma
76ec946616 Merge pull request #264 from GoogleChromeLabs/readme-typos
Fix typos 🙈
2018-11-11 19:15:45 -08:00
Mathias Bynens
68bb2edb39 Fix typos 🙈 2018-11-11 17:43:20 -08:00
Mariko Kosaka
9c85618aff Merge pull request #263 from GoogleChromeLabs/analytics-privacy
Adding readme, privacy section, reducing resolution of analytics data.
2018-11-11 06:07:52 -08:00
Jake Archibald
aebeff8b4c Adding readme, privacy section, reducing resolution of analytics data. 2018-11-11 05:11:28 -08:00
Jake Archibald
8d63125b13 Resetting pinch zoom (#261)
* Resetting pinch zoom

* Bumping version
2018-11-11 04:28:39 -08:00
Jake Archibald
2ca97ef586 Not entirely sure why this causes dev to fail, but this fixes it. 2018-11-10 16:10:25 -08:00
Jake Archibald
a1a00f0bfb Preload test (#262)
* Preload test

* Don't prerender analytics

* Version bump
2018-11-10 08:20:13 -08:00
Jake Archibald
6870b135b7 I'm calling this 1.0 2018-11-09 16:01:24 -08:00
Jake Archibald
a0f1379feb Adding manifest to headers 2018-11-09 12:08:55 -08:00
Jake Archibald
9b17322478 Removing old file from serviceworker 2018-11-09 11:11:34 -08:00
Surma
f562bad286 Add analytics script (fixes #174) (#245) 2018-11-09 10:53:10 -08:00
Jason Miller
6994cc3d15 _headers & _redirects generation (#240)
* Generate `_headers` and `_redirects` by passing assets through ejs templates.

* PR feedback

* Excluding service worker stuff from prerender

* Build SW in dev

* Let's give this a try

* lol

* Is this how it works?
2018-11-09 10:49:01 -08:00
Jake Archibald
9b572f9541 Ta-da. Back button. (#254) 2018-11-09 09:13:32 -08:00
Jake Archibald
71f893cb44 Enhanced offline (#249)
* Notification of updates & reloading

* Using version in service worker & allowing version to appear elsewhere

* Stupid file

* Ditching changelog for now. Using package json.

* Ugh.
2018-11-09 09:13:14 -08:00
Jake Archibald
6b76ea0a6f Update file drop (#253) 2018-11-09 08:53:36 -08:00
Jason Miller
7616d33883 Startup optimizations (#226)
* Startup optimisations

* I hate this file

* Inline main script

* Reverting change to do a fairer perf comparison

* Inlining again. Weeeeee!

* Lockfile
2018-11-09 16:01:02 +00:00
Jake Archibald
3c757bb2b2 Prevent browser pinch-zoom (#247) 2018-11-09 15:58:15 +00:00
Jake Archibald
a502df80ba Prevent logo taking over on smaller screens. (#250)
* Prevent logo taking over on smaller screens.

* I hate this file
2018-11-09 00:02:23 +00:00
Jake Archibald
921268ec58 Addressing nits from service worker PR. 2018-11-08 12:11:29 +00:00
Jason Miller
7d42d4f973 Add a serviceworker (#234)
* Add a serviceworker

* rename + fix random extra character

* Fixing worker typings

* Fixing types properly this time.

* Once of those rare cases where this matters.

* Naming the things.

* Move registration to the app (so we can use snackbar later)

* Moving SW plugin later so it picks up things like HTML

* MVP service worker

* Two stage-service worker

* Fix prerendering by conditionally awaiting Custom Elements polyfill.

* Fix icon 404's

* add doc comment to autoswplugin

* Fix type
2018-11-08 12:02:05 +00:00
Jake Archibald
e4e130c5d6 Mark private function as private 2018-11-08 11:21:57 +00:00
Jake Archibald
bcf7a63118 Android tablet bugs (#246)
* Prevent two-up being lost under options. Fixes #241.

* Working around some glitching when page was scrolled.

* Prevent software keyboard popping up again in Android Chrome.
2018-11-07 08:59:11 +00:00
Jake Archibald
66aac12db7 Caught a bit of repetition in our utils (#242)
Caught a bit of repetition in our utils
2018-11-06 14:19:48 +00:00
Jake Archibald
59cd1f8930 Splitting PointerTracker into its own project (#238) 2018-11-06 14:19:24 +00:00
Jake Archibald
150e704d20 It's a dev package 2018-11-06 13:50:50 +00:00
Paul Kinlan
b2d47f0fb8 fixing a deps issue. 2018-11-06 13:50:49 +00:00
Paul Kinlan
bd3d33296d Updating based on changes to filedrop element. 2018-11-06 13:50:49 +00:00
Paul Kinlan
f4c82ced97 #199 - Removes the file-drop custom element
+ Removes the custom element from the project
+ Replaces it with the externally maintined custom element
2018-11-06 13:50:48 +00:00
Jake Archibald
76188df0d3 Destructuring args. 2018-11-06 13:47:18 +00:00
Jake Archibald
9a58e4d339 Fixing lossless slider for webP. Previously you couldn't select "9" :D 2018-11-06 13:47:18 +00:00
Jake Archibald
f396a5b784 MozJPEG chroma subsampling and quality (#235)
* Adding chroma subsampling for mozjpeg

* Adding separate chroma quality.

* Preact sometimes removes the inline styles, this fixes it.

* Simplifying chroma subsample

* Adding comments
2018-11-06 13:46:52 +00:00
Jake Archibald
e572b853e2 Snackbar defaults & copy undo (#233)
* Fix snackbar defaults. Fixes #205.

* Undo copy settings across.

* Oops

* Fixing stupid minification bug

* Something weird happened with the last commit
2018-11-06 13:44:15 +00:00
Jake Archibald
726c2f195a Fixing graphics glitch. Fixes #166 (#232) 2018-11-06 13:41:08 +00:00
Jake Archibald
4599e51b1e Copy to side ui (#229)
* Copy settings to other side button

* Download button on the outside.

* Whoops
2018-11-06 13:39:03 +00:00
Jake Archibald
d93169cc5a Mobile ui (#227)
* Basic grid setup

* Fixing thumb on two-up

* Adding margin so you can still access the two-up

* Allow multi-panel to keep one open only

* Edge cases for one-open

* Abstracting results so it can be used as a heading.

* Ordering of items in mobile view. Changing scrolling element.

* Adding labels to collapsed view

* Adding height animation to multi-panel

* Fixing animation bugs

* Expand/collapse icon

* Allow two-up and pinch-zoom to work beneath controls

* Range bubble now behaves properly on mobile

* No longer need this.

* Prevent options overflow at larger widths
2018-11-06 13:37:52 +00:00
Jake Archibald
bdd3c11f1a Options ui (#222)
* wip

* Commenting stuff to keep the build happy

* Revealing sections

* Custom select elements & more form work

* Range input styles

* Text fields with inputs do the right thing

* Safari & Firefox fixes

* Large compress select

* oops

* MozJPEG options updated

* OptPNG options

* These asserts weren't true

* Generic options

* WebP options

* Hiding "edit" when "original image"

* Download icon

* Copy setting button - still not happy with this

* Progress indicator

* Loading icon enter/exit anim

* Preventing controls going under options

* Ahh so that's what was causing scrolling

* Ahh so that's what was causing outlines

* Simplifying range styles and fixing cross-browser

* Processing custom element styles

* Get precision from step by default

* I don't know how or when this happened.

* Don't need that many steps

* Avoid having an element that covers the pinch zoom

* Preventing overlap with zoom controls

* Prevent ts warning

* Fixing spinner position

* Simplifying FileSize
2018-11-06 13:36:23 +00:00
Jake Archibald
0cec90c7ca Main ui (#214)
* Class for file drop

* OCD

* We don't need the invalid state, as we'll accept all types.

* Flattening CSS

* Fixing zoom input in Firefox

* Fixing 'container' scaleTo

* two-up closer design match & smaller line

* Fixing edge bug
2018-11-06 13:31:58 +00:00
Jake Archibald
43def798e1 Two workers & worker termination (#198)
* Refactoring codecs

* Plugging in new processor

* Fixing decorator

* MozJPEG free issue

* Better worker aborting, and terminate workers that aren't used for 10 seconds

* Better comment

* Ooops, half-typed comment

* Uncommenting problematic line

* Surma fixed it!

* Abstracting WASM initialisation

* Better comment

* Don't need this.

* Adding ticket

* noInitalRun

* Reverting MozJPEG issue demo

* Making a const for worker timeout

* Inline docs

* Bail early rather than nesting

* Addressing nits
2018-10-28 09:17:43 +00:00
Jake Archibald
02b0c022ca Edge encode fix (#211)
* No canvas.toBlob in Edge.

* pffft
2018-10-20 14:50:37 +01:00
Jake Archibald
c82d0d1b88 Fix for loading SVG in Safari. (#212)
* Fix for loading SVG in Safari.

* Tidier code
2018-10-20 14:50:16 +01:00
Jake Archibald
e24d7865ce Lazy-loading the main part of the app (#197)
* Splitting main part of app out of the main bundle.

Also improving the transition from intro to compressor.

* Showing error if app fails to load.

* lol these aren't async

* Please don't tell anyone I did this

* Spinner if user selects a file before the app has loaded. (#208)
2018-10-20 12:53:36 +01:00
Jason Miller
a79f95b305 Fix <range-input disabled> (#195)
* Fix .disabled property reflection for range-input (only attribute worked previously)

* Revert "Fix .disabled property reflection for range-input (only attribute worked previously)"

This reverts commit f5964635b2.

* Fix reflection

* Use hasAttribute()
2018-10-20 12:51:30 +01:00
Surma
49b40b1c3e Remove virtual files before running (fixes #217) (#220) 2018-10-19 12:07:01 +01:00
Jake Archibald
11ee74e224 Edge gets confused about custom properties in @supports. (#206) 2018-10-14 14:11:20 +01:00
Surma
f335246673 Use mozjpeg function to free result (#207) 2018-10-14 14:10:21 +01:00
Jason Miller
ccb734aec6 Remove firebase travis deploy (for now) (#196)
* remove firebase (for now)

* Also rm .firebaserc
2018-10-14 09:35:07 +01:00
Jake Archibald
568b9e9459 Styling intro screen and adding demo images. 2018-10-12 14:12:32 +01:00
Jake Archibald
a43ea761f5 Missing bind 2018-10-12 14:04:18 +01:00
Surma
577c77cc30 Codecs cleanup (#189)
* Update imagequant processor

* Update mozjpeg encoder

* Update optipng encoder

* Update webp decoder

* Update webp encoder

* Remove old codec build tasks

* Add warning about docker image updates
2018-10-12 10:53:33 +01:00
Jake Archibald
d2f60baef9 Handle vectors (#187)
* Allow loading SVG. Fixes #138.

I also made the resizer vector-aware, so you can resize the image larger & stay sharp.

* Handling SVG without width/height set.

* Simplifying maths

* Doh, case sensitive
2018-10-11 14:15:01 +01:00
Jake Archibald
64acc08cd7 Improving image open time (#185)
* Moving intro into its own component

* Tidying JSX, and allowing image to render before first compression. Fixes #164.
2018-10-11 14:05:18 +01:00
Jake Archibald
a1f0b81dff Fixing resize again. Fixes #183. (#184) 2018-10-09 13:34:38 +01:00
Jake Archibald
48bb58dc89 Moving range input component 2018-10-09 12:19:24 +01:00
Jake Archibald
765cc213d2 Updating linting rules and fixing bug 2018-10-02 14:56:20 +01:00
Jason Miller
37f5c0dd76 Design review fixes (#172)
* Design review fixes

* Adding styles for mozjpeg & fixing some merge errors
2018-10-02 14:53:21 +01:00
Jake Archibald
b25d1eaf86 <range-input> (#171) 2018-10-02 11:41:07 +01:00
Jake Archibald
248676aa31 Fixing webp sniffing. Fixes #178. (#179) 2018-10-02 11:30:38 +01:00
Ewa
059c80c05d Center the image canvas in PinchZoom (#170)
* Center the image canvas in PinchZoom

* Fixing pinch zoom
2018-10-01 13:57:26 +01:00
Jake Archibald
cfd42818b7 Edge file constructor fix (#180)
* Hacking around lack of `new File` in Edge.

* Less hacky solution - preserves types
2018-09-28 14:44:59 +01:00
Jake Archibald
5e66e0acc4 Adding custom element polyfill (#177) 2018-09-27 14:49:45 +01:00
Jake Archibald
c9fe5ffbcf Creating fallbacks for all ImageBitmap usage & refactoring. (#175)
Fixes #173
2018-09-27 14:44:54 +01:00
Surma
1b630a092f Dockerize mozjpeg (#169)
* Dockerize mozjpeg build process

* Update README
2018-09-26 12:31:26 +01:00
Ewa
09e60284cb Merge pull request #168 from GoogleChromeLabs/devnook-fix-105
Reposition the TwoUp handle on resize
2018-09-18 07:29:21 +02:00
Ewa Gasperowicz
76b34c62db Review code format fixes 2018-09-18 07:26:51 +02:00
Ewa Gasperowicz
9d7212bc1d Review code format fixes 2018-09-17 13:25:33 +02:00
Ewa Gasperowicz
1b69c9231d Keep relative screen division while resizing 2018-09-17 13:21:31 +02:00
Ewa Gasperowicz
bcd88f6356 Add fallback to window.onresize 2018-09-17 11:30:06 +02:00
Ewa Gasperowicz
2a47f67214 Reposition the TwoUp handle on resize 2018-09-17 11:08:54 +02:00
Mariko Kosaka
5e8dc1b26c Add multi-panel component (#95)
* add multi-panel component

* make _functions private

* fix spelling errors

* spacing fix

* spelling fix

* store result of _getClosestHeading and avoid calling twice.

* remove returns that are not needed

* move getClosestHeading as separate function

* re-thinking casting and logic

* reflect code review

* do not remove focus when hit spacebar

* add comments and fix type

* handle heading keyevents

* set expanded hight to auto
2018-09-12 14:57:01 +01:00
Jake Archibald
c591f1f37d Result cache LRU (#165)
* Give the result cache some LRU love

* Fixing LRU cache move-to-start, and simplifying
2018-09-11 17:31:08 +01:00
Jake Archibald
4db43ccd4e Button to copy settings to the other side 2018-09-06 13:05:17 +01:00
Jake Archibald
ea5d3c2d78 Adding resize preprocessor (#152)
* Adding resize preprocessor

* Using ! on form

* Haha oops

* Using createImageBitmapPolyfill

* Updating package.json

* Oops again

* Ooops again
2018-09-05 15:46:26 +01:00
Jake Archibald
700b1f15cd Pinch-zoom: scale around given origin. (#139)
Also setting a min scale.
2018-09-05 09:39:26 +01:00
Jake Archibald
485ba174e3 Adding result cache. Fixes #87. (#148) 2018-09-05 08:29:17 +01:00
Jason Miller
32f6f8b941 Options UI (#135)
* Move gzipped size calculations into a worker and wrap it up in a `<GzipSize />` component that will also handle showing % of original size once that info is plumbed

* A couple tweaks for the app welcome (drop files) screen. We don't have mocks for this one, but this is at least a minor improvement.

* Prettier "pop" effect and styling for the drop zone/indicator.

* Styling for the quantization toggle to make it look like a disclosure triangle/button.

* Add controls bar (zoom in/out/to, background toggle). @todo: extract into its own component.

* When clicking/tapping the image area, give it focus.

* Utilities used by this PR

* Add a `two-up-handle` attribute to the handle for easier styling (classname gets mangled so it doesn't make for a good public API)

* Add a dummy comment to test netlify deploy

* Remove commented-out code.

* Fix styling of vertical split (which as it turns out is slightly different in the mocks anyway)

* Use a composited overlay for the dark background instead of animating background-color

* Move grayscale styling into `<two-up>` by default, then set colors via custom properties

* Remove commented-out svg fill

* Remove dummy comment

* Change `<GzipSize>` to be `<FileSize>`, add `compress` option that lets us show gzipped sizes later if we need. Defaults to `false`, and the gzip worker is only lazily instantiated the first time a compressed size calculation is requested.

* Dependency updates

* Remove color animations from dnd overlay

* Don't use a cyclical import for EncodedImage, instead just specify the types of the properties we Options actually uses.

* Pass source image through to FileSize component so it can compute delta

* Stylize size display with colors based on delta amount/direction

* Remove box-shadow animation.

* Simplify font stack

* Remove commented out code

* Remove gzip compression from size component

* Remove memoization bits

* Use specific flattend props instead of passing large context objects around.

* Remove unused packages.

* Remove unreachable String case in FileSize, and omit redundant File type

* Simplify calculateSize()

* Fix types for FileSize!

* Remove FileSize title

* Make delta variable consistent.

* Skip passing compareTo value for original image

* Remove manual focus

* Fix whitespace

* remove unused keyframes

* remove pointless flex-wrap property

* Remove unused resetZoom() method

* Remove pointless flex properties

* Use `on` prefix for event handling

* Remove pointless justify-self property

* Use an inline SVG for TwoUp's handle icon so it can be colored from outside the component..

* Move orientation state up from `<Output>` into `<App>` and share it with `<Options>`.

* Make the options panels responsive :)

* Show a plus sign for size increases `(+8%)`

* Use inline SVG for the zoom +/- icons, collect SVG icons into one file now that I've verified they get tree-shaken properly.

* Fix top/bottom options panels being reversed

* remove commented out code

* lockfile

* Revert quanitzation toggle styles so it's just a checkbox.

* Remove minimum delta for compare size

* Rename data prop to file.

* scale int -> float

* remove tabIndex

* Remove old icon files

* Add width to options panels

* Add vertical scrolling when options are taller than 80% of the screen height.
2018-09-05 08:21:54 +01:00
Surma
54ad30a7ed Optipng (#156)
* omg it’s compiling

* example actually works

* Expose compression level options

* Disable crypto and path module emulation in webpack

* Update README

* Remove small image

* Use -O3 on optipng

* Free memory after copy

* Handle unexpected file reader return types

* Rename level label to effort
2018-09-04 16:49:45 +01:00
Surma
170d75482e Merge pull request #155 from sendilkumarn/fix-name-replace
fix broken file renaming for file names with dot
2018-08-29 12:18:33 +01:00
Sendil Kumar
a8db2b30f2 fix broken file renaming for file names with dot
remove grouping in regex
2018-08-29 13:12:33 +02:00
Surma
e3b1b08424 Make WebP decoder use memory views (#145)
* Make WebP decoder use memory views

* Update webp_dec README

* Port quantizer to memory views as well
2018-08-21 13:29:53 +01:00
Jake Archibald
8006a1a5e7 Memory view rather than pointers (#144). Part of #141.
* Returning an object seems to work well

* This doesn't work

* This does!

* Better cast?

* Updating usage in Squoosh
2018-08-21 09:27:04 +01:00
Jake Archibald
1ae65dd4a1 Mozjpeg opts (#140)
* Switching to embind

* Adding options to mozjpeg wasm

* Updating packages

* Ditching enum - causing more problems than it's worth

* Adding mozjpeg options UI

* Forgot about this enum

* Bools just work
2018-08-17 16:25:28 +01:00
Jake Archibald
bff515b63f Adding changed points and coalescing to pointer tracker. Fixes #133. (#134)
* Adding changed points and coalescing to pointer tracker. Fixes #133.

* Nits and exposing native pointer
2018-08-15 15:14:33 +01:00
Jake Archibald
65c3ea826f Avoid preprocessing images that have already been preprocessed. (#125)
* Avoid preprocessing images that have already been preprocessed.

* Using cleanMerge an cleanSet, and fixing bugs in our compression.
2018-08-10 12:59:29 +01:00
Jake Archibald
602d5140f9 Konami code fix. lol. Thanks @remy. 2018-08-08 14:47:58 +01:00
Jake Archibald
44f0700332 Adding clean-set (#124)
* Adding clean-set

* Moving to our own cleanSet and cleanMerge.

* Oops, this can be simpler

* Allow the path to be a number

* Better typing
2018-08-07 12:19:06 +01:00
Jason Miller
c90db020b0 Snackbar (#99)
* Initial swing

* Finish up <snack-bar> implementation and integrate it

* Add missing types

* Use shift() since we dont care about referential equality

* Use `_` for private fields

* Remove rogue handler

* Remove impossible fallback value

* Make `<snack-bar>` actually contain its children

* will-change for the button ripple

* Guard against mutliple button action clicks

* `onhide()` -> `onremove()`

* remove transitionend

* Replace inline ref callback with linkRef

* showError only accepts strings

* Remove undefined initialization

* Throw on error

* Add missing error type.

* `SnackBar` ▶️ `Snack`

* Avoid child retaining a reference to parent, make show() return a Promise.

* async/await and avoid processing the stack if it is already being processed

* Add a meaningful return value to showSnackbar()
2018-08-06 14:32:48 +01:00
Jake Archibald
ef4094885e Easter egg (#123)
* lol zx quant

* Adding ZX option

* Improving colour selection so we don't end up with the same colour twice. Also fixing a bug with the colour conflict resolution.

* Putting it behind a konami code

* Better comments

* Adding comment

* Removing unnecessary malloc.
2018-08-06 12:42:23 +01:00
Surma
b52d9d9194 Merge pull request #122 from GoogleChromeLabs/quant-ui-fix
Quant fixes
2018-08-06 10:16:58 +01:00
Jake Archibald
d3f2836f48 Hide quantize options if original image. Fixes #120. 2018-08-02 16:59:13 +01:00
Jake Archibald
27722f77f9 Simplifying new object creation 2018-08-02 16:56:15 +01:00
Jake Archibald
3a0db14c40 Minor tweaks 2018-08-02 16:52:57 +01:00
Jake Archibald
e0dc1b48ec Creating new objects rather than mutating existing objects. Fixes #121. 2018-08-02 16:52:11 +01:00
Surma
009327c2c4 Merge pull request #115 from GoogleChromeLabs/imagequant
Implement image quantization via libimagequant
2018-08-01 12:50:08 +01:00
Surma
b16d60b52b No name on preprocessors 2018-08-01 12:36:31 +01:00
Surma
c550fe9283 Refactor preprocessors module 2018-08-01 12:32:45 +01:00
Surma
dce4fc70ac Clean up imagquant codec 2018-08-01 12:19:44 +01:00
Surma
b3f3ecbf28 Actually respect numColors lol 2018-07-31 12:46:32 +01:00
Surma
e8c0ddfc7f Remove lambda from JSX 2018-07-31 12:41:02 +01:00
Surma
a002b376af Hook up options UI to quantizer 2018-07-31 12:32:37 +01:00
Surma
2165383da4 Start integrating quantizer in the main data flow 2018-07-30 16:54:30 +01:00
Surma
5fbf6b297f Hardcode quantization pass 2018-07-30 16:28:37 +01:00
Surma
9d5ad83ff8 Transpile libimagequant 2018-07-30 15:51:57 +01:00
Paul Kinlan
07f17dece2 Adding Travis Support (#113)
* Adds travis script that will build the project whenever the master branch is updated.

The key to upload is in travis env variable.

Note: This does not yet run the test suite, it will deploy if the build is successful.
Note: it has to build twice, because the first build will fail due to a loader issue.
2018-07-30 15:47:00 +01:00
Jake Archibald
f2f467ecb8 WebP encode options (#110)
* Flailing

* Holy shit struct binding

* Options in the encoder!

* Integrating webp options

* Addressing feedback

* This isn't needed anymore
2018-07-27 14:06:45 +01:00
Surma
2ea9e22b52 Merge pull request #91 from GoogleChromeLabs/webp-decoder
WASM WebpDecoder
2018-07-20 11:13:09 +01:00
Surma
4ee5572d2f Jake’s thoroughness is doing my head in :P 2018-07-20 11:12:42 +01:00
Surma
df7e112d22 Nits by Jake 2018-07-20 10:58:07 +01:00
Surma
13ac3ed5b2 Use createImageBitmap as hailmary 2018-07-20 10:56:40 +01:00
Surma
b7c223bc0d Remove baseline image decoders, refactor decodeFile 2018-07-20 10:56:40 +01:00
Surma
0f08121596 Implement mime type sniffing 2018-07-20 10:56:39 +01:00
Surma
b15545402a Adressing smaller review comments 2018-07-20 10:56:39 +01:00
Surma
b310c97044 Smaller inline webp image 2018-07-20 10:56:38 +01:00
Surma
307c6b05ae Write out logging command 2018-07-20 10:56:38 +01:00
Jason Miller
77a6d21924 show decode errors reliably. 2018-07-20 10:56:37 +01:00
Surma
d22a343378 Actually move decoding to worker 2018-07-20 10:56:37 +01:00
Surma
790a5b580d Set up decoder infrastructure 2018-07-20 10:56:36 +01:00
Jake Archibald
6e8f8bbe41 Vertical two-up (#100)
* Fixing bad property name.

* Allowing two-up to work vertically at smaller widths.

* Switching to orientation attr

* Fixing type and getter/setter behaviour
2018-07-20 09:32:18 +01:00
Jake Archibald
cc9d01a9ab Basic webp integration (#103) 2018-07-17 10:37:42 +01:00
Paul Kinlan
526520c399 Adds support for onpaste #97 (#98)
* Adds support for onpaste #97

+ file-drop listens for onpaste, if there is data and it matches the
   type it will use that and raise a custom event
+ Adds a new event on file drop 'onfiledrop'
+ App listens for this event and will map to onFileDrop

* Hoisting getFileData

* The linter seems to think Array.from is of type File, when it's not.

* Remove an entire type of event handler.
+ Removes onfilepaste, joins into 'onfiledrop'
+ Adds 'action' to let you distinguish between the paste or drop
+ Updates app so it just uses the one event.

* Fixing PR issues

+ null return types >>> undefiend.
+ FileDropAction type.
+ remove coercsion on the array types.
2018-07-16 14:00:47 +01:00
Jason Miller
acbc31bc35 Merge pull request #96 from GoogleChromeLabs/fix-mjs-errors
Fix errors arising from strict .mjs handling
2018-07-10 10:59:06 -04:00
Jason Miller
e8e151a926 Fix errors arising from strict .mjs handling. 2018-07-10 10:57:11 -04:00
Jason Miller
835a537c55 Fix lint issues resulting from switching to airbnb (#94)
* Fix lint issues resulting from switching to airbnb.

* Case sensitivity change

* Fix lint script to actually lint tsx files
2018-07-10 14:01:09 +01:00
Jason Miller
23ea9fad49 Merge pull request #89 from GoogleChromeLabs/mjs
Switch to .mjs for ES Modules.
2018-07-09 15:45:35 -04:00
Surma
491280935a Merge pull request #92 from GoogleChromeLabs/fix-workers
Rename encoding worker so it actually runs in a worker
2018-07-04 15:48:22 +01:00
Jason Miller
900eda9a8e Rename encoding worker so it actually runs in a worker 2018-07-04 10:35:16 -04:00
Jason Miller
38d0057833 Switch to .mjs for ES Modules. Fixes #88. 2018-07-04 10:02:20 -04:00
Jake Archibald
3867448aad All the encoders that Chrome/Safari/Firefox support out of the box. (#74)
* All the encoders that Chrome/Safari/Firefox support out of the box.

* Typo
2018-07-02 19:10:10 +01:00
Jake Archibald
807a76d443 Adding download support. Fixes #47. 2018-07-02 19:04:09 +01:00
Jake Archibald
3e26a0a3cc Fixing file drop for Safari & Edge (#73) 2018-07-02 18:55:46 +01:00
Jake Archibald
68729979e3 Adding browser's webp encoder (#72)
* Adding WebP (without feature detect in place)

* Adding WebP check

* Remove unused import
2018-07-02 15:49:52 +01:00
Jake Archibald
a09ec269b8 Adding native encoders (#71)
* Adding browser png

* Adding native JPEG & file size output

* Removing log

* Fixing blob typing

* Fix timing issue
2018-07-02 15:14:09 +01:00
Jake Archibald
3f18c927f1 Allow mouse wheel on two-up handle. Fixes #49 (#54) 2018-07-02 09:17:57 +01:00
Jake Archibald
9add650b75 Refactorings (#65)
* Refactorings

* Responding to feedback
2018-07-01 16:01:42 +01:00
Surma
cc3ed168d8 Merge pull request #70 from GoogleChromeLabs/lint-fix
Fixing issues raised by the linter. Fixes #68
2018-06-30 00:25:02 +01:00
Paul Kinlan
3b9b1e9f2e 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.
2018-06-29 21:12:17 +00:00
Paul Kinlan
7c220b1a92 Adding in Drag and Drop support to fix #45 (#56)
* Merging file drop

* Fixing double drop
2018-06-29 16:37:48 +01:00
Jason Miller
3035a68b90 Options UI (#39)
* Initial work to add Options config

* Use a single encoder instance and retry up to 10 times on failure.

* Switch both sides to allow encoding from the source image, add options configuration for each.

* Styling for options (and a few tweaks for the app)

* Dep updates.

* Remove commented out code.

* Fix Encoder typing

* Fix lint issues

* Apparently I didnt have tslint autofix enabled on the chromebook

* Attempt to fix layout/panning issues

* Fix missing custom element import!

* Fix variable naming, remove dynamic encoder names, remove retry, allow encoders to return ImageData.

* Refactor state management to use an Array of objects and immutable updates instead of relying on explicit update notifications.

* Add Identity encoder, which is a passthrough encoder that handles the "original" view.

* Drop comlink-loader into the project and add ".worker" to the jpeg encoder filename so it runs in a worker (🦄)

* lint fixes.

* cleanup

* smaller PR feedback fixes

* rename "jpeg" codec to "MozJpeg"

* Formatting fixes for Options

* Colocate codecs and their options UIs in src/codecs, and standardize the namings

* Handle canvas errors

* Throw if quality is undefined, add default quality

* add note about temp styles

* add note about temp styles [2]

* Renaming updateOption

* Clarify option input bindings

* Move updateCanvas() to util and rename to drawBitmapToCanvas

* use generics to pass through encoder options

* Remove unused dependencies

* fix options type

* const

* Use `Array.prototype.some()` for image loading check

* Display encoding errors in the UI.

* I fought typescript and I think I won

* This doesn't need to be optional

* Quality isn't optional

* Simplifying comlink casting

* Splitting counters into loading and displaying

* Still loading if the loading counter isn't equal.
2018-06-29 16:29:18 +01:00
Surma
65847c0ed7 Merge pull request #62 from GoogleChromeLabs/linting
Switch to tslint and run it as commit hook
2018-06-26 15:16:42 +01:00
Surma
5303afe9ad Fix code lint complaints 2018-06-26 15:11:07 +01:00
Surma
579b8a494a Use better exclude option 2018-06-26 15:10:54 +01:00
Surma
56faf619d0 Allow leading underscores on variable names 2018-06-26 14:44:31 +01:00
Surma
85e3a12c84 Add lint fix script 2018-06-26 14:43:33 +01:00
Surma
cab8d3f13c Allow leading underscores in private methods 2018-06-26 14:40:28 +01:00
Surma
5c651a1716 Switch to tslint and run it as commit hook 2018-06-26 11:19:44 +01:00
Surma
ba0ad81646 Merge pull request #52 from GoogleChromeLabs/codec-fixes
Codec fixes
2018-06-14 13:39:22 +01:00
Surma
695bbed12b Update webp to v1.0.0 2018-06-14 13:32:05 +01:00
Surma
6a6d478f77 Commit webp decoder binaries 2018-06-14 13:29:11 +01:00
Surma
d75a3aca9b Merge pull request #50 from GoogleChromeLabs/webp-dec
Decoder for webp
2018-06-14 13:25:49 +01:00
Surma
91945da5ae Add documentation 2018-06-13 23:44:46 +01:00
Surma
00e73daabd Decoder for webp 2018-06-13 23:40:24 +01:00
233 changed files with 25319 additions and 11501 deletions

View File

@@ -1,13 +0,0 @@
{
"plugins": [
"transform-class-properties",
"transform-react-constant-elements",
"transform-react-remove-prop-types",
[
"transform-react-jsx",
{
"pragma": "h"
}
]
]
}

View File

@@ -1,5 +0,0 @@
{
"projects": {
"default": "squoosh-beta"
}
}

36
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,36 @@
---
name: Bug report
about: Something is not working as expected
labels:
---
**Before you start**
Please take a look at the [FAQ](https://github.com/GoogleChromeLabs/squoosh/wiki/FAQ) as well as the already opened issues! If nothing fits your problem, go ahead and fill out the following template:
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Version:**
- OS w/ version: [e.g. iOS 12]
- Browser w/ version [e.g. Chrome 70]
- Node version: [e.g. 10.11.0]
- npm version: [e.g. 6.4.1]
**Is your issue related to the quality of image compression?**
Please attach original and output images (you can drag & drop to attach).
- Original image
- Output image from Squoosh
**Additional context, screenshots, screencasts**
Add any other context about the problem here.

View File

@@ -0,0 +1,18 @@
---
name: Feature request
about: Suggest an idea for this project
labels:
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Does other service/app have this feature?**
Add any service you know/use that has this feature (We want to know for research)
**Additional context**
Add any other context or screenshots about the feature request here.

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ node_modules
/*.log /*.log
*.scss.d.ts *.scss.d.ts
*.css.d.ts *.css.d.ts
*.o

7
.travis.yml Normal file
View File

@@ -0,0 +1,7 @@
language: node_js
node_js:
- node
- 10
- 8
cache: npm
script: npm run build

View File

@@ -1,5 +1,31 @@
# Squoosh! # [Squoosh]!
Squoosh will be an image compression web app that allows you to dive into the [Squoosh] is an image compression web app that allows you to dive into the advanced options provided
advanced options provided by various image compressors. by various image compressors.
# Privacy
Google Analytics is used to record the following:
* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
* Before and after image size once an image is downloaded. These values are rounded to the nearest
kilobyte.
Image compression is handled locally; no additional data is sent to the server.
# Building locally
Clone the repo, and:
```sh
npm install
npm run build
```
You can run the development server with:
```sh
npm start
```
[Squoosh]: https://squoosh.app

18
_headers.ejs Normal file
View File

@@ -0,0 +1,18 @@
# Long-term cache by default.
/*
Cache-Control: max-age=31536000
# And here are the exceptions:
/
Cache-Control: no-cache
/serviceworker.js
Cache-Control: no-cache
/manifest.json
Cache-Control: must-revalidate, max-age=3600
# URLs in /assets do not include a hash and are mutable.
# But it isn't a big deal if the user gets an old version.
/assets/*
Cache-Control: must-revalidate, max-age=3600

2
_redirects.ejs Normal file
View File

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

View File

@@ -11,6 +11,6 @@ $ npm install
$ npm run build $ npm run build
``` ```
This will build two files: `<codec name>_<enc or dec>.js` and `<codec name>_<enc or dec>.wasm`. It will most likely be necessary to set [`Module["locateFile"]`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution) to sucessfully load the `.wasm` file. When the `.js` file is loaded, a global `<codec name>_<enc or dec>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html). This will build two files: `<codec name>_<enc or dec>.js` and `<codec name>_<enc or dec>.wasm`. It will most likely be necessary to set [`Module["locateFile"]`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution) to successfully load the `.wasm` file. When the `.js` file is loaded, a global `<codec name>_<enc or dec>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
Each codec will document its API in its README. Each codec will document its API in its README.

BIN
codecs/example.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
codecs/example_palette.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@@ -0,0 +1,30 @@
# ImageQuant
- Source: <https://github.com/ImageOptim/libimagequant>
- Version: v2.12.1
## Dependencies
- Docker
## Example
See `example.html`
## API
### `int version()`
Returns the version of libimagequant as a number. va.b.c is encoded as 0x0a0b0c
### `RawImage quantize(std::string buffer, int image_width, int image_height, int numColors, float dithering)`
Quantizes the given images, using at most `numColors`, a value between 2 and 256. `dithering` is a value between 0 and 1 controlling the amount of dithering. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.
### `RawImage zx_quantize(std::string buffer, int image_width, int image_height, float dithering)`
???
### `void free_result()`
Frees the result created by `quantize()`.

48
codecs/imagequant/build.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
echo "============================================="
echo "Compiling libimagequant"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="imagequant"' \
-I node_modules/libimagequant \
--std=c99 \
-c \
node_modules/libimagequant/{libimagequant,pam,mediancut,blur,mempool,kmeans,nearest}.c
)
echo "============================================="
echo "Compiling wasm module"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="imagequant"' \
-I node_modules/libimagequant \
-o ./imagequant.js \
--std=c++11 *.o \
-x c++ \
imagequant.cpp
)
echo "============================================="
echo "Compiling wasm module done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -0,0 +1,41 @@
<!doctype html>
<style>
canvas {
image-rendering: pixelated;
}
</style>
<script src='imagequant.js'></script>
<script>
const Module = imagequant();
async function loadImage(src) {
// Load image
const img = document.createElement('img');
img.src = src;
await new Promise(resolve => img.onload = resolve);
// Make canvas same size as image
const canvas = document.createElement('canvas');
[canvas.width, canvas.height] = [img.width, img.height];
// Draw image onto canvas
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
return ctx.getImageData(0, 0, img.width, img.height);
}
Module.onRuntimeInitialized = async _ => {
console.log('Version:', Module.version().toString(16));
const image = await loadImage('../example.png');
// const rawImage = Module.quantize(image.data, image.width, image.height, 256, 1.0);
const rawImage = Module.zx_quantize(image.data, image.width, image.height, 1.0);
console.log('done');
Module.free_result();
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), rawImage.width, rawImage.height);
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
const ctx = canvas.getContext('2d');
ctx.putImageData(imageData, 0, 0);
document.body.appendChild(canvas);
};
</script>

View File

@@ -0,0 +1,245 @@
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include "libimagequant.h"
using namespace emscripten;
int version() {
return (((LIQ_VERSION/10000) % 100) << 16) |
(((LIQ_VERSION/100 ) % 100) << 8) |
(((LIQ_VERSION/1 ) % 100) << 0);
}
class RawImage {
public:
val buffer;
int width;
int height;
RawImage(val b, int w, int h)
: buffer(b), width(w), height(h) {}
};
liq_attr *attr;
liq_image *image;
liq_result *res;
uint8_t* result;
RawImage quantize(std::string rawimage, int image_width, int image_height, int num_colors, float dithering) {
const uint8_t* image_buffer = (uint8_t*)rawimage.c_str();
int size = image_width * image_height;
attr = liq_attr_create();
image = liq_image_create_rgba(attr, image_buffer, image_width, image_height, 0);
liq_set_max_colors(attr, num_colors);
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
uint8_t* image8bit = (uint8_t*) malloc(size);
result = (uint8_t*) malloc(size * 4);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
// Turn palletted image back into an RGBA image
for(int i = 0; i < size; i++) {
result[i * 4 + 0] = pal->entries[image8bit[i]].r;
result[i * 4 + 1] = pal->entries[image8bit[i]].g;
result[i * 4 + 2] = pal->entries[image8bit[i]].b;
result[i * 4 + 3] = pal->entries[image8bit[i]].a;
}
free(image8bit);
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
}
const liq_color zx_colors[] = {
{.a = 255, .r = 0, .g = 0, .b = 0}, // regular black
{.a = 255, .r = 0, .g = 0, .b = 215}, // regular blue
{.a = 255, .r = 215, .g = 0, .b = 0}, // regular red
{.a = 255, .r = 215, .g = 0, .b = 215}, // regular magenta
{.a = 255, .r = 0, .g = 215, .b = 0}, // regular green
{.a = 255, .r = 0, .g = 215, .b = 215}, // regular cyan
{.a = 255, .r = 215, .g = 215, .b = 0}, // regular yellow
{.a = 255, .r = 215, .g = 215, .b = 215}, // regular white
{.a = 255, .r = 0, .g = 0, .b = 255}, // bright blue
{.a = 255, .r = 255, .g = 0, .b = 0}, // bright red
{.a = 255, .r = 255, .g = 0, .b = 255}, // bright magenta
{.a = 255, .r = 0, .g = 255, .b = 0}, // bright green
{.a = 255, .r = 0, .g = 255, .b = 255}, // bright cyan
{.a = 255, .r = 255, .g = 255, .b = 0}, // bright yellow
{.a = 255, .r = 255, .g = 255, .b = 255} // bright white
};
uint8_t block[8 * 8 * 4];
/**
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The two colours must
* both be 'regular' or 'bright'. Black exists as both regular and bright.
*/
RawImage zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
const uint8_t* image_buffer = (uint8_t*) rawimage.c_str();
int size = image_width * image_height;
int bytes_per_pixel = 4;
result = (uint8_t*) malloc(size * bytes_per_pixel);
uint8_t* image8bit = (uint8_t*) malloc(8 * 8);
// For each 8x8 grid
for (int block_start_y = 0; block_start_y < image_height; block_start_y += 8) {
for (int block_start_x = 0; block_start_x < image_width; block_start_x += 8) {
int color_popularity[15] = {0};
int block_index = 0;
int block_width = 8;
int block_height = 8;
// If the block hangs off the right/bottom of the image dimensions, make it smaller to fit.
if (block_start_y + block_height > image_height) {
block_height = image_height - block_start_y;
}
if (block_start_x + block_width > image_width) {
block_width = image_width - block_start_x;
}
// For each pixel in that block:
for (int y = block_start_y; y < block_start_y + block_height; y++) {
for (int x = block_start_x; x < block_start_x + block_width; x++) {
int pixel_start = (y * image_width * bytes_per_pixel) + (x * bytes_per_pixel);
int smallest_distance = INT_MAX;
int winning_index = -1;
// Copy pixel data for quantizing later
block[block_index++] = image_buffer[pixel_start];
block[block_index++] = image_buffer[pixel_start + 1];
block[block_index++] = image_buffer[pixel_start + 2];
block[block_index++] = image_buffer[pixel_start + 3];
// Which zx color is this pixel closest to?
for (int color_index = 0; color_index < 15; color_index++) {
liq_color color = zx_colors[color_index];
// Using Euclidean distance. LibQuant has better methods, but it requires conversion to
// LAB, so I don't think it's worth it.
int distance =
pow(color.r - image_buffer[pixel_start + 0], 2) +
pow(color.g - image_buffer[pixel_start + 1], 2) +
pow(color.b - image_buffer[pixel_start + 2], 2);
if (distance < smallest_distance) {
winning_index = color_index;
smallest_distance = distance;
}
}
color_popularity[winning_index]++;
}
}
// Get the three most popular colours for the block.
int first_color_index = 0;
int second_color_index = 0;
int third_color_index = 0;
int highest_popularity = -1;
int second_highest_popularity = -1;
int third_highest_popularity = -1;
for (int color_index = 0; color_index < 15; color_index++) {
if (color_popularity[color_index] > highest_popularity) {
// Store this as the most popular pixel, and demote the current values:
third_color_index = second_color_index;
third_highest_popularity = second_highest_popularity;
second_color_index = first_color_index;
second_highest_popularity = highest_popularity;
first_color_index = color_index;
highest_popularity = color_popularity[color_index];
} else if (color_popularity[color_index] > second_highest_popularity) {
third_color_index = second_color_index;
third_highest_popularity = second_highest_popularity;
second_color_index = color_index;
second_highest_popularity = color_popularity[color_index];
} else if (color_popularity[color_index] > third_highest_popularity) {
third_color_index = color_index;
third_highest_popularity = color_popularity[color_index];
}
}
// ZX images can't mix bright and regular colours, except black which appears in both.
// Resolve any conflict:
while (1) {
// If either colour is black, there's no conflict to resolve.
if (first_color_index != 0 && second_color_index != 0) {
if (first_color_index >= 8 && second_color_index < 8) {
// Make the second color bright
second_color_index = second_color_index + 7;
} else if (first_color_index < 8 && second_color_index >= 8) {
// Make the second color regular
second_color_index = second_color_index - 7;
}
}
// If, during conflict resolving, we now have two of the same colour (because we initially
// selected the bright & regular version of the same colour), retry again with the third
// most popular colour.
if (first_color_index == second_color_index) {
second_color_index = third_color_index;
} else break;
}
// Quantize
attr = liq_attr_create();
image = liq_image_create_rgba(attr, block, block_width, block_height, 0);
liq_set_max_colors(attr, 2);
liq_image_add_fixed_color(image, zx_colors[first_color_index]);
liq_image_add_fixed_color(image, zx_colors[second_color_index]);
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
// Turn palletted image back into an RGBA image, and write it into the full size result image.
for(int y = 0; y < block_height; y++) {
for(int x = 0; x < block_width; x++) {
int image8BitPos = y * block_width + x;
int resultStartPos = ((block_start_y + y) * bytes_per_pixel * image_width) + ((block_start_x + x) * bytes_per_pixel);
result[resultStartPos + 0] = pal->entries[image8bit[image8BitPos]].r;
result[resultStartPos + 1] = pal->entries[image8bit[image8BitPos]].g;
result[resultStartPos + 2] = pal->entries[image8bit[image8BitPos]].b;
result[resultStartPos + 3] = pal->entries[image8bit[image8BitPos]].a;
}
}
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
}
}
free(image8bit);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
}
void free_result() {
free(result);
}
EMSCRIPTEN_BINDINGS(my_module) {
class_<RawImage>("RawImage")
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
function("quantize", &quantize);
function("zx_quantize", &zx_quantize);
function("version", &version);
function("free_result", &free_result);
}

15
codecs/imagequant/imagequant.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
interface RawImage {
buffer: Uint8Array;
width: number;
height: number;
}
interface QuantizerModule extends EmscriptenWasm.Module {
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): RawImage;
zx_quantize(data: BufferSource, width: number, height: number, dither: number): RawImage;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

1147
codecs/imagequant/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"name": "imagequant",
"scripts": {
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
},
"napa": {
"libimagequant": "ImageOptim/libimagequant#2.12.1"
},
"devDependencies": {
"napa": "3.0.0"
}
}

View File

@@ -6,8 +6,6 @@
## Dependencies ## Dependencies
- Docker - Docker
- Automake
- pkg-config
## Example ## Example
@@ -19,26 +17,31 @@ See `example.html`
Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c
### `uint8_t* create_buffer(int width, int height)`
Allocates an RGBA buffer for an image with the given dimension.
### `void destroy_buffer(uint8_t* p)`
Frees a buffer created with `create_buffer`.
### `void encode(uint8_t* image_buffer, int image_width, int image_height, int quality)`
Encodes the given image with given dimension to JPEG. `quality` is a number between 0 and 100. The higher the number, the better the quality of the encoded image. The result is implicitly stored and can be accessed using the `get_result_*()` functions.
### `void free_result()` ### `void free_result()`
Frees the result created by `encode()`. Frees the result created by `encode()`.
### `int get_result_pointer()` ### `Uint8Array encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts)`
Returns the pointer to the start of the buffer holding the encoded data. Encodes the given image with given dimension to JPEG. Options looks like this:
### `int get_result_size()` ```c++
struct MozJpegOptions {
Returns the length of the buffer holding the encoded data. int quality;
bool baseline;
bool arithmetic;
bool progressive;
bool optimize_coding;
int smoothing;
int color_space;
int quant_table;
bool trellis_multipass;
bool trellis_opt_zero;
bool trellis_opt_table;
int trellis_loops;
bool auto_subsample;
int chroma_subsample;
bool separate_chroma_quality;
int chroma_quality;
};
```

53
codecs/mozjpeg_enc/build.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling mozjpeg"
echo "============================================="
(
cd node_modules/mozjpeg
autoreconf -fiv
emconfigure ./configure --without-simd
emmake make libjpeg.la
)
echo "============================================="
echo "Compiling mozjpeg done"
echo "============================================="
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="mozjpeg_enc"' \
-I node_modules/mozjpeg \
-o ./mozjpeg_enc.js \
-Wno-deprecated-register \
-Wno-writable-strings \
node_modules/mozjpeg/rdswitch.c \
-x c++ -std=c++11 \
mozjpeg_enc.cpp \
node_modules/mozjpeg/.libs/libjpeg.a
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -1,7 +1,7 @@
<!doctype html> <!doctype html>
<script src='mozjpeg_enc.js'></script> <script src='mozjpeg_enc.js'></script>
<script> <script>
const Module = mozjpeg_enc(); const module = mozjpeg_enc();
async function loadImage(src) { async function loadImage(src) {
// Load image // Load image
@@ -17,26 +17,27 @@
return ctx.getImageData(0, 0, img.width, img.height); return ctx.getImageData(0, 0, img.width, img.height);
} }
Module.onRuntimeInitialized = async _ => { module.onRuntimeInitialized = async _ => {
const api = { console.log('Version:', module.version().toString(16));
version: Module.cwrap('version', 'number', []),
create_buffer: Module.cwrap('create_buffer', 'number', ['number', 'number']),
destroy_buffer: Module.cwrap('destroy_buffer', '', ['number']),
encode: Module.cwrap('encode', '', ['number', 'number', 'number', 'number']),
free_result: Module.cwrap('free_result', '', ['number']),
get_result_pointer: Module.cwrap('get_result_pointer', 'number', []),
get_result_size: Module.cwrap('get_result_size', 'number', []),
};
const image = await loadImage('../example.png'); const image = await loadImage('../example.png');
const p = api.create_buffer(image.width, image.height); const result = module.encode(image.data, image.width, image.height, {
Module.HEAP8.set(image.data, p); quality: 75,
api.encode(p, image.width, image.height, 2); baseline: false,
const resultPointer = api.get_result_pointer(); arithmetic: false,
const resultSize = api.get_result_size(); progressive: true,
const resultView = new Uint8Array(Module.HEAP8.buffer, resultPointer, resultSize); optimize_coding: true,
const result = new Uint8Array(resultView); smoothing: 0,
api.free_result(resultPointer); color_space: 3,
api.destroy_buffer(p); quant_table: 3,
trellis_multipass: false,
trellis_opt_zero: false,
trellis_opt_table: false,
trellis_loops: 1,
auto_subsample: true,
chroma_subsample: 2,
separate_chroma_quality: false,
chroma_quality: 75,
});
const blob = new Blob([result], {type: 'image/jpeg'}); const blob = new Blob([result], {type: 'image/jpeg'});
const blobURL = URL.createObjectURL(blob); const blobURL = URL.createObjectURL(blob);

View File

@@ -1,17 +1,40 @@
#include "emscripten.h" #include <emscripten/bind.h>
#include <emscripten/val.h>
#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#include "jpeglib.h"
#include "config.h" #include "config.h"
#include "jpeglib.h"
#include "cdjpeg.h"
// MozJPEG doesnt expose a numeric version, so I have to do some fun C macro hackery to turn it into a string. More details here: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html using namespace emscripten;
// MozJPEG doesnt expose a numeric version, so I have to do some fun C macro hackery to turn it
// into a string. More details here: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
#define xstr(s) str(s) #define xstr(s) str(s)
#define str(s) #s #define str(s) #s
EMSCRIPTEN_KEEPALIVE struct MozJpegOptions {
int quality;
bool baseline;
bool arithmetic;
bool progressive;
bool optimize_coding;
int smoothing;
int color_space;
int quant_table;
bool trellis_multipass;
bool trellis_opt_zero;
bool trellis_opt_table;
int trellis_loops;
bool auto_subsample;
int chroma_subsample;
bool separate_chroma_quality;
int chroma_quality;
};
int version() { int version() {
char buffer[] = xstr(MOZJPEG_VERSION); char buffer[] = xstr(MOZJPEG_VERSION);
int version = 0; int version = 0;
@@ -28,27 +51,11 @@ int version() {
return version; return version;
} }
EMSCRIPTEN_KEEPALIVE uint8_t* last_result;
uint8_t* create_buffer(int width, int height) { struct jpeg_compress_struct cinfo;
return malloc(width * height * 4 * sizeof(uint8_t));
}
EMSCRIPTEN_KEEPALIVE val encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts) {
void destroy_buffer(uint8_t* p) { uint8_t* image_buffer = (uint8_t*) image_in.c_str();
free(p);
}
int result[2];
EMSCRIPTEN_KEEPALIVE
void encode(uint8_t* image_buffer, int image_width, int image_height, int quality) {
// Manually convert RGBA data into RGB
for(int y = 0; y < image_height; y++) {
for(int x = 0; x < image_width; x++) {
image_buffer[(y*image_width + x)*3 + 0] = image_buffer[(y*image_width + x)*4 + 0];
image_buffer[(y*image_width + x)*3 + 1] = image_buffer[(y*image_width + x)*4 + 1];
image_buffer[(y*image_width + x)*3 + 2] = image_buffer[(y*image_width + x)*4 + 2];
}
}
// The code below is basically the `write_JPEG_file` function from // The code below is basically the `write_JPEG_file` function from
// https://github.com/mozilla/mozjpeg/blob/master/example.c // https://github.com/mozilla/mozjpeg/blob/master/example.c
@@ -61,7 +68,6 @@ void encode(uint8_t* image_buffer, int image_width, int image_height, int qualit
* compression/decompression processes, in existence at once. We refer * compression/decompression processes, in existence at once. We refer
* to any one struct (and its associated working data) as a "JPEG object". * to any one struct (and its associated working data) as a "JPEG object".
*/ */
struct jpeg_compress_struct cinfo;
/* This struct represents a JPEG error handler. It is declared separately /* This struct represents a JPEG error handler. It is declared separately
* because applications often want to supply a specialized error handler * because applications often want to supply a specialized error handler
* (see the second half of this file for an example). But here we just * (see the second half of this file for an example). But here we just
@@ -109,18 +115,57 @@ void encode(uint8_t* image_buffer, int image_width, int image_height, int qualit
*/ */
cinfo.image_width = image_width; /* image width and height, in pixels */ cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_height = image_height; cinfo.image_height = image_height;
cinfo.input_components = 3; /* # of color components per pixel */ cinfo.input_components = 4; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
/* Now use the library's routine to set default compression parameters. /* Now use the library's routine to set default compression parameters.
* (You must set at least cinfo.in_color_space before calling this, * (You must set at least cinfo.in_color_space before calling this,
* since the defaults depend on the source color space.) * since the defaults depend on the source color space.)
*/ */
jpeg_set_defaults(&cinfo); jpeg_set_defaults(&cinfo);
/* Now you can set any non-default parameters you wish to.
* Here we just illustrate the use of quality (quantization table) scaling:
*/
jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE) opts.color_space);
if (opts.quant_table != -1) {
jpeg_c_set_int_param(&cinfo, JINT_BASE_QUANT_TBL_IDX, opts.quant_table);
}
cinfo.optimize_coding = opts.optimize_coding;
if (opts.arithmetic) {
cinfo.arith_code = TRUE;
cinfo.optimize_coding = FALSE;
}
cinfo.smoothing_factor = opts.smoothing;
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_USE_SCANS_IN_TRELLIS, opts.trellis_multipass);
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_TRELLIS_EOB_OPT, opts.trellis_opt_zero);
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_TRELLIS_Q_OPT, opts.trellis_opt_table);
jpeg_c_set_int_param(&cinfo, JINT_TRELLIS_NUM_LOOPS, opts.trellis_loops);
// A little hacky to build a string for this, but it means we can use set_quality_ratings which
// does some useful heuristic stuff.
std::string quality_str = std::to_string(opts.quality);
if (opts.separate_chroma_quality && opts.color_space == JCS_YCbCr) {
quality_str += "," + std::to_string(opts.chroma_quality);
}
char const *pqual = quality_str.c_str();
set_quality_ratings(&cinfo, (char*) pqual, opts.baseline);
if (!opts.auto_subsample && opts.color_space == JCS_YCbCr) {
cinfo.comp_info[0].h_samp_factor = opts.chroma_subsample;
cinfo.comp_info[0].v_samp_factor = opts.chroma_subsample;
}
if (!opts.baseline && opts.progressive) {
jpeg_simple_progression(&cinfo);
} else {
cinfo.num_scans = 0;
cinfo.scan_info = NULL;
}
/* Step 4: Start compressor */ /* Step 4: Start compressor */
/* TRUE ensures that we will write a complete interchange-JPEG file. /* TRUE ensures that we will write a complete interchange-JPEG file.
@@ -136,7 +181,7 @@ void encode(uint8_t* image_buffer, int image_width, int image_height, int qualit
* To keep things simple, we pass one scanline per call; you can pass * To keep things simple, we pass one scanline per call; you can pass
* more if you wish, though. * more if you wish, though.
*/ */
row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
while (cinfo.next_scanline < cinfo.image_height) { while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg_write_scanlines expects an array of pointers to scanlines. /* jpeg_write_scanlines expects an array of pointers to scanlines.
@@ -152,27 +197,38 @@ void encode(uint8_t* image_buffer, int image_width, int image_height, int qualit
jpeg_finish_compress(&cinfo); jpeg_finish_compress(&cinfo);
/* Step 7: release JPEG compression object */ /* Step 7: release JPEG compression object */
result[0] = (int)output; last_result = output;
result[1] = size;
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
/* And we're done! */ /* And we're done! */
return val(typed_memory_view(size, output));
} }
EMSCRIPTEN_KEEPALIVE
void free_result() { void free_result() {
free(result[0]); // not sure if this is right with mozjpeg /* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
} }
EMSCRIPTEN_KEEPALIVE EMSCRIPTEN_BINDINGS(my_module) {
int get_result_pointer() { value_object<MozJpegOptions>("MozJpegOptions")
return result[0]; .field("quality", &MozJpegOptions::quality)
} .field("baseline", &MozJpegOptions::baseline)
.field("arithmetic", &MozJpegOptions::arithmetic)
.field("progressive", &MozJpegOptions::progressive)
.field("optimize_coding", &MozJpegOptions::optimize_coding)
.field("smoothing", &MozJpegOptions::smoothing)
.field("color_space", &MozJpegOptions::color_space)
.field("quant_table", &MozJpegOptions::quant_table)
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
.field("trellis_loops", &MozJpegOptions::trellis_loops)
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
.field("auto_subsample", &MozJpegOptions::auto_subsample)
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
.field("chroma_quality", &MozJpegOptions::chroma_quality)
;
EMSCRIPTEN_KEEPALIVE function("version", &version);
int get_result_size() { function("encode", &encode);
return result[1]; function("free_result", &free_result);
} }

View File

@@ -1 +1,8 @@
export default function(opts: EmscriptenWasm.ModuleOpts): EmscriptenWasm.Module; import { EncodeOptions } from '../../src/codecs/mozjpeg/encoder-meta';
interface MozJPEGModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): MozJPEGModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -21,8 +21,8 @@
"integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
"dev": true, "dev": true,
"requires": { "requires": {
"delegates": "1.0.0", "delegates": "^1.0.0",
"readable-stream": "2.3.5" "readable-stream": "^2.0.6"
} }
}, },
"balanced-match": { "balanced-match": {
@@ -43,7 +43,7 @@
"integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=",
"dev": true, "dev": true,
"requires": { "requires": {
"readable-stream": "2.3.5" "readable-stream": "^2.0.5"
} }
}, },
"block-stream": { "block-stream": {
@@ -52,7 +52,7 @@
"integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
"dev": true, "dev": true,
"requires": { "requires": {
"inherits": "2.0.3" "inherits": "~2.0.0"
} }
}, },
"brace-expansion": { "brace-expansion": {
@@ -61,7 +61,7 @@
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true, "dev": true,
"requires": { "requires": {
"balanced-match": "1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
@@ -72,8 +72,8 @@
"dev": true, "dev": true,
"requires": { "requires": {
"base64-js": "0.0.8", "base64-js": "0.0.8",
"ieee754": "1.1.8", "ieee754": "^1.1.4",
"isarray": "1.0.0" "isarray": "^1.0.0"
} }
}, },
"buffer-crc32": { "buffer-crc32": {
@@ -88,10 +88,10 @@
"integrity": "sha512-Cg8/ZSBEa8ZVY9HspcGUYaK63d/bN7rqS3CYCzEGUxuYv6UlmcjzDUz2fCFFHyTvUW5Pk0I+3hkA3iXlIj6guA==", "integrity": "sha512-Cg8/ZSBEa8ZVY9HspcGUYaK63d/bN7rqS3CYCzEGUxuYv6UlmcjzDUz2fCFFHyTvUW5Pk0I+3hkA3iXlIj6guA==",
"dev": true, "dev": true,
"requires": { "requires": {
"get-proxy": "2.1.0", "get-proxy": "^2.0.0",
"isurl": "1.0.0", "isurl": "^1.0.0-alpha5",
"tunnel-agent": "0.6.0", "tunnel-agent": "^0.6.0",
"url-to-options": "1.0.1" "url-to-options": "^1.0.1"
} }
}, },
"code-point-at": { "code-point-at": {
@@ -106,7 +106,7 @@
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-readlink": "1.0.1" "graceful-readlink": ">= 1.0.0"
} }
}, },
"concat-map": { "concat-map": {
@@ -121,8 +121,8 @@
"integrity": "sha1-q6CXR9++TD5w52am5BWG4YWfxvI=", "integrity": "sha1-q6CXR9++TD5w52am5BWG4YWfxvI=",
"dev": true, "dev": true,
"requires": { "requires": {
"ini": "1.3.5", "ini": "^1.3.4",
"proto-list": "1.2.4" "proto-list": "~1.2.1"
} }
}, },
"console-control-strings": { "console-control-strings": {
@@ -158,14 +158,14 @@
"integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=", "integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=",
"dev": true, "dev": true,
"requires": { "requires": {
"decompress-tar": "4.1.1", "decompress-tar": "^4.0.0",
"decompress-tarbz2": "4.1.1", "decompress-tarbz2": "^4.0.0",
"decompress-targz": "4.1.1", "decompress-targz": "^4.0.0",
"decompress-unzip": "4.0.1", "decompress-unzip": "^4.0.1",
"graceful-fs": "4.1.11", "graceful-fs": "^4.1.10",
"make-dir": "1.2.0", "make-dir": "^1.0.0",
"pify": "2.3.0", "pify": "^2.3.0",
"strip-dirs": "2.1.0" "strip-dirs": "^2.0.0"
}, },
"dependencies": { "dependencies": {
"pify": { "pify": {
@@ -182,7 +182,7 @@
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
"dev": true, "dev": true,
"requires": { "requires": {
"mimic-response": "1.0.0" "mimic-response": "^1.0.0"
} }
}, },
"decompress-tar": { "decompress-tar": {
@@ -191,9 +191,9 @@
"integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"file-type": "5.2.0", "file-type": "^5.2.0",
"is-stream": "1.1.0", "is-stream": "^1.1.0",
"tar-stream": "1.5.5" "tar-stream": "^1.5.2"
} }
}, },
"decompress-tarbz2": { "decompress-tarbz2": {
@@ -202,11 +202,11 @@
"integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==",
"dev": true, "dev": true,
"requires": { "requires": {
"decompress-tar": "4.1.1", "decompress-tar": "^4.1.0",
"file-type": "6.2.0", "file-type": "^6.1.0",
"is-stream": "1.1.0", "is-stream": "^1.1.0",
"seek-bzip": "1.0.5", "seek-bzip": "^1.0.5",
"unbzip2-stream": "1.2.5" "unbzip2-stream": "^1.0.9"
}, },
"dependencies": { "dependencies": {
"file-type": { "file-type": {
@@ -223,9 +223,9 @@
"integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==",
"dev": true, "dev": true,
"requires": { "requires": {
"decompress-tar": "4.1.1", "decompress-tar": "^4.1.1",
"file-type": "5.2.0", "file-type": "^5.2.0",
"is-stream": "1.1.0" "is-stream": "^1.1.0"
} }
}, },
"decompress-unzip": { "decompress-unzip": {
@@ -234,10 +234,10 @@
"integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=", "integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=",
"dev": true, "dev": true,
"requires": { "requires": {
"file-type": "3.9.0", "file-type": "^3.8.0",
"get-stream": "2.3.1", "get-stream": "^2.2.0",
"pify": "2.3.0", "pify": "^2.3.0",
"yauzl": "2.9.1" "yauzl": "^2.4.2"
}, },
"dependencies": { "dependencies": {
"file-type": { "file-type": {
@@ -252,8 +252,8 @@
"integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=",
"dev": true, "dev": true,
"requires": { "requires": {
"object-assign": "4.1.1", "object-assign": "^4.0.1",
"pinkie-promise": "2.0.1" "pinkie-promise": "^2.0.0"
} }
}, },
"pify": { "pify": {
@@ -282,17 +282,17 @@
"integrity": "sha512-DpO9K1sXAST8Cpzb7kmEhogJxymyVUd5qz/vCOSyvwtp2Klj2XcDt5YUuasgxka44SxF0q5RriKIwJmQHG2AuA==", "integrity": "sha512-DpO9K1sXAST8Cpzb7kmEhogJxymyVUd5qz/vCOSyvwtp2Klj2XcDt5YUuasgxka44SxF0q5RriKIwJmQHG2AuA==",
"dev": true, "dev": true,
"requires": { "requires": {
"caw": "2.0.1", "caw": "^2.0.0",
"content-disposition": "0.5.2", "content-disposition": "^0.5.2",
"decompress": "4.2.0", "decompress": "^4.0.0",
"ext-name": "5.0.0", "ext-name": "^5.0.0",
"file-type": "5.2.0", "file-type": "5.2.0",
"filenamify": "2.0.0", "filenamify": "^2.0.0",
"get-stream": "3.0.0", "get-stream": "^3.0.0",
"got": "7.1.0", "got": "^7.0.0",
"make-dir": "1.2.0", "make-dir": "^1.0.0",
"p-event": "1.3.0", "p-event": "^1.0.0",
"pify": "3.0.0" "pify": "^3.0.0"
} }
}, },
"duplexer3": { "duplexer3": {
@@ -307,7 +307,7 @@
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"once": "1.4.0" "once": "^1.4.0"
} }
}, },
"error-ex": { "error-ex": {
@@ -316,7 +316,7 @@
"integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
"dev": true, "dev": true,
"requires": { "requires": {
"is-arrayish": "0.2.1" "is-arrayish": "^0.2.1"
} }
}, },
"escape-string-regexp": { "escape-string-regexp": {
@@ -331,7 +331,7 @@
"integrity": "sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==", "integrity": "sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==",
"dev": true, "dev": true,
"requires": { "requires": {
"mime-db": "1.33.0" "mime-db": "^1.28.0"
} }
}, },
"ext-name": { "ext-name": {
@@ -340,8 +340,8 @@
"integrity": "sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==", "integrity": "sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"ext-list": "2.2.2", "ext-list": "^2.0.0",
"sort-keys-length": "1.0.1" "sort-keys-length": "^1.0.0"
} }
}, },
"extend": { "extend": {
@@ -356,7 +356,7 @@
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
"dev": true, "dev": true,
"requires": { "requires": {
"pend": "1.2.0" "pend": "~1.2.0"
} }
}, },
"file-type": { "file-type": {
@@ -377,9 +377,9 @@
"integrity": "sha1-vRYiYsC26Uv7zc8Zo7uzdk94VpU=", "integrity": "sha1-vRYiYsC26Uv7zc8Zo7uzdk94VpU=",
"dev": true, "dev": true,
"requires": { "requires": {
"filename-reserved-regex": "2.0.0", "filename-reserved-regex": "^2.0.0",
"strip-outer": "1.0.0", "strip-outer": "^1.0.0",
"trim-repeated": "1.0.0" "trim-repeated": "^1.0.0"
} }
}, },
"fs.realpath": { "fs.realpath": {
@@ -394,10 +394,10 @@
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "4.1.11", "graceful-fs": "^4.1.2",
"inherits": "2.0.3", "inherits": "~2.0.0",
"mkdirp": "0.5.1", "mkdirp": ">=0.5 0",
"rimraf": "2.6.2" "rimraf": "2"
} }
}, },
"fstream-ignore": { "fstream-ignore": {
@@ -406,9 +406,9 @@
"integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=",
"dev": true, "dev": true,
"requires": { "requires": {
"fstream": "1.0.11", "fstream": "^1.0.0",
"inherits": "2.0.3", "inherits": "2",
"minimatch": "3.0.4" "minimatch": "^3.0.0"
} }
}, },
"gauge": { "gauge": {
@@ -417,14 +417,14 @@
"integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
"dev": true, "dev": true,
"requires": { "requires": {
"aproba": "1.2.0", "aproba": "^1.0.3",
"console-control-strings": "1.1.0", "console-control-strings": "^1.0.0",
"has-unicode": "2.0.1", "has-unicode": "^2.0.0",
"object-assign": "4.1.1", "object-assign": "^4.1.0",
"signal-exit": "3.0.2", "signal-exit": "^3.0.0",
"string-width": "1.0.2", "string-width": "^1.0.1",
"strip-ansi": "3.0.1", "strip-ansi": "^3.0.1",
"wide-align": "1.1.2" "wide-align": "^1.1.0"
} }
}, },
"get-proxy": { "get-proxy": {
@@ -433,7 +433,7 @@
"integrity": "sha512-zmZIaQTWnNQb4R4fJUEp/FC51eZsc6EkErspy3xtIYStaq8EB/hDIWipxsal+E8rz0qD7f2sL/NA9Xee4RInJw==", "integrity": "sha512-zmZIaQTWnNQb4R4fJUEp/FC51eZsc6EkErspy3xtIYStaq8EB/hDIWipxsal+E8rz0qD7f2sL/NA9Xee4RInJw==",
"dev": true, "dev": true,
"requires": { "requires": {
"npm-conf": "1.1.3" "npm-conf": "^1.1.0"
} }
}, },
"get-stream": { "get-stream": {
@@ -448,12 +448,12 @@
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"fs.realpath": "1.0.0", "fs.realpath": "^1.0.0",
"inflight": "1.0.6", "inflight": "^1.0.4",
"inherits": "2.0.3", "inherits": "2",
"minimatch": "3.0.4", "minimatch": "^3.0.4",
"once": "1.4.0", "once": "^1.3.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "^1.0.0"
} }
}, },
"got": { "got": {
@@ -462,20 +462,20 @@
"integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==", "integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==",
"dev": true, "dev": true,
"requires": { "requires": {
"decompress-response": "3.3.0", "decompress-response": "^3.2.0",
"duplexer3": "0.1.4", "duplexer3": "^0.1.4",
"get-stream": "3.0.0", "get-stream": "^3.0.0",
"is-plain-obj": "1.1.0", "is-plain-obj": "^1.1.0",
"is-retry-allowed": "1.1.0", "is-retry-allowed": "^1.0.0",
"is-stream": "1.1.0", "is-stream": "^1.0.0",
"isurl": "1.0.0", "isurl": "^1.0.0-alpha5",
"lowercase-keys": "1.0.0", "lowercase-keys": "^1.0.0",
"p-cancelable": "0.3.0", "p-cancelable": "^0.3.0",
"p-timeout": "1.2.1", "p-timeout": "^1.1.1",
"safe-buffer": "5.1.1", "safe-buffer": "^5.0.1",
"timed-out": "4.0.1", "timed-out": "^4.0.0",
"url-parse-lax": "1.0.0", "url-parse-lax": "^1.0.0",
"url-to-options": "1.0.1" "url-to-options": "^1.0.1"
} }
}, },
"graceful-fs": { "graceful-fs": {
@@ -502,7 +502,7 @@
"integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==",
"dev": true, "dev": true,
"requires": { "requires": {
"has-symbol-support-x": "1.4.2" "has-symbol-support-x": "^1.4.1"
} }
}, },
"has-unicode": { "has-unicode": {
@@ -529,8 +529,8 @@
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true, "dev": true,
"requires": { "requires": {
"once": "1.4.0", "once": "^1.3.0",
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"inherits": { "inherits": {
@@ -557,7 +557,7 @@
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true, "dev": true,
"requires": { "requires": {
"number-is-nan": "1.0.1" "number-is-nan": "^1.0.0"
} }
}, },
"is-natural-number": { "is-natural-number": {
@@ -602,8 +602,8 @@
"integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==",
"dev": true, "dev": true,
"requires": { "requires": {
"has-to-string-tag-x": "1.4.1", "has-to-string-tag-x": "^1.2.0",
"is-object": "1.0.1" "is-object": "^1.0.1"
} }
}, },
"load-json-file": { "load-json-file": {
@@ -612,10 +612,10 @@
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "4.1.11", "graceful-fs": "^4.1.2",
"parse-json": "2.2.0", "parse-json": "^2.2.0",
"pify": "2.3.0", "pify": "^2.0.0",
"strip-bom": "3.0.0" "strip-bom": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"pify": { "pify": {
@@ -638,7 +638,7 @@
"integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==", "integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==",
"dev": true, "dev": true,
"requires": { "requires": {
"pify": "3.0.0" "pify": "^3.0.0"
} }
}, },
"mime-db": { "mime-db": {
@@ -659,7 +659,7 @@
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true, "dev": true,
"requires": { "requires": {
"brace-expansion": "1.1.11" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
@@ -697,16 +697,16 @@
"integrity": "sha1-7DqP3gcZC2ny/kNMOVo+aUaEG1Y=", "integrity": "sha1-7DqP3gcZC2ny/kNMOVo+aUaEG1Y=",
"dev": true, "dev": true,
"requires": { "requires": {
"download": "6.2.5", "download": "^6.2.2",
"extend": "3.0.1", "extend": "^3.0.1",
"load-json-file": "2.0.0", "load-json-file": "^2.0.0",
"minimist": "1.2.0", "minimist": "^1.2.0",
"mkdirp": "0.5.1", "mkdirp": "^0.5.1",
"npm-cache-filename": "1.0.2", "npm-cache-filename": "^1.0.2",
"npmlog": "4.1.2", "npmlog": "^4.1.0",
"rimraf": "2.6.2", "rimraf": "^2.6.1",
"tar-pack": "3.4.1", "tar-pack": "^3.4.0",
"write-json-file": "2.3.0" "write-json-file": "^2.2.0"
} }
}, },
"npm-cache-filename": { "npm-cache-filename": {
@@ -721,8 +721,8 @@
"integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==", "integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==",
"dev": true, "dev": true,
"requires": { "requires": {
"config-chain": "1.1.11", "config-chain": "^1.1.11",
"pify": "3.0.0" "pify": "^3.0.0"
} }
}, },
"npmlog": { "npmlog": {
@@ -731,10 +731,10 @@
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"dev": true, "dev": true,
"requires": { "requires": {
"are-we-there-yet": "1.1.4", "are-we-there-yet": "~1.1.2",
"console-control-strings": "1.1.0", "console-control-strings": "~1.1.0",
"gauge": "2.7.4", "gauge": "~2.7.3",
"set-blocking": "2.0.0" "set-blocking": "~2.0.0"
} }
}, },
"number-is-nan": { "number-is-nan": {
@@ -755,7 +755,7 @@
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true, "dev": true,
"requires": { "requires": {
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"p-cancelable": { "p-cancelable": {
@@ -770,7 +770,7 @@
"integrity": "sha1-jmtPT2XHK8W2/ii3XtqHT5akoIU=", "integrity": "sha1-jmtPT2XHK8W2/ii3XtqHT5akoIU=",
"dev": true, "dev": true,
"requires": { "requires": {
"p-timeout": "1.2.1" "p-timeout": "^1.1.1"
} }
}, },
"p-finally": { "p-finally": {
@@ -785,7 +785,7 @@
"integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=", "integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=",
"dev": true, "dev": true,
"requires": { "requires": {
"p-finally": "1.0.0" "p-finally": "^1.0.0"
} }
}, },
"parse-json": { "parse-json": {
@@ -794,7 +794,7 @@
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"dev": true, "dev": true,
"requires": { "requires": {
"error-ex": "1.3.1" "error-ex": "^1.2.0"
} }
}, },
"path-is-absolute": { "path-is-absolute": {
@@ -827,7 +827,7 @@
"integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
"dev": true, "dev": true,
"requires": { "requires": {
"pinkie": "2.0.4" "pinkie": "^2.0.0"
} }
}, },
"prepend-http": { "prepend-http": {
@@ -854,13 +854,13 @@
"integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
"dev": true, "dev": true,
"requires": { "requires": {
"core-util-is": "1.0.2", "core-util-is": "~1.0.0",
"inherits": "2.0.3", "inherits": "~2.0.3",
"isarray": "1.0.0", "isarray": "~1.0.0",
"process-nextick-args": "2.0.0", "process-nextick-args": "~2.0.0",
"safe-buffer": "5.1.1", "safe-buffer": "~5.1.1",
"string_decoder": "1.0.3", "string_decoder": "~1.0.3",
"util-deprecate": "1.0.2" "util-deprecate": "~1.0.1"
} }
}, },
"rimraf": { "rimraf": {
@@ -869,7 +869,7 @@
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true, "dev": true,
"requires": { "requires": {
"glob": "7.1.2" "glob": "^7.0.5"
} }
}, },
"safe-buffer": { "safe-buffer": {
@@ -884,7 +884,7 @@
"integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=",
"dev": true, "dev": true,
"requires": { "requires": {
"commander": "2.8.1" "commander": "~2.8.1"
} }
}, },
"set-blocking": { "set-blocking": {
@@ -905,7 +905,7 @@
"integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=",
"dev": true, "dev": true,
"requires": { "requires": {
"is-plain-obj": "1.1.0" "is-plain-obj": "^1.0.0"
} }
}, },
"sort-keys-length": { "sort-keys-length": {
@@ -914,7 +914,7 @@
"integrity": "sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=", "integrity": "sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=",
"dev": true, "dev": true,
"requires": { "requires": {
"sort-keys": "1.1.2" "sort-keys": "^1.0.0"
} }
}, },
"string-width": { "string-width": {
@@ -923,9 +923,9 @@
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true, "dev": true,
"requires": { "requires": {
"code-point-at": "1.1.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "1.0.0", "is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "3.0.1" "strip-ansi": "^3.0.0"
} }
}, },
"string_decoder": { "string_decoder": {
@@ -934,7 +934,7 @@
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"safe-buffer": "5.1.1" "safe-buffer": "~5.1.0"
} }
}, },
"strip-ansi": { "strip-ansi": {
@@ -943,7 +943,7 @@
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true, "dev": true,
"requires": { "requires": {
"ansi-regex": "2.1.1" "ansi-regex": "^2.0.0"
} }
}, },
"strip-bom": { "strip-bom": {
@@ -958,7 +958,7 @@
"integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==",
"dev": true, "dev": true,
"requires": { "requires": {
"is-natural-number": "4.0.1" "is-natural-number": "^4.0.1"
} }
}, },
"strip-outer": { "strip-outer": {
@@ -967,7 +967,7 @@
"integrity": "sha1-qsC6YNLpDF1PJ1/Yhp/ZotMQ/7g=", "integrity": "sha1-qsC6YNLpDF1PJ1/Yhp/ZotMQ/7g=",
"dev": true, "dev": true,
"requires": { "requires": {
"escape-string-regexp": "1.0.5" "escape-string-regexp": "^1.0.2"
} }
}, },
"tar": { "tar": {
@@ -976,9 +976,9 @@
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
"dev": true, "dev": true,
"requires": { "requires": {
"block-stream": "0.0.9", "block-stream": "*",
"fstream": "1.0.11", "fstream": "^1.0.2",
"inherits": "2.0.3" "inherits": "2"
} }
}, },
"tar-pack": { "tar-pack": {
@@ -987,14 +987,14 @@
"integrity": "sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg==", "integrity": "sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "2.6.9", "debug": "^2.2.0",
"fstream": "1.0.11", "fstream": "^1.0.10",
"fstream-ignore": "1.0.5", "fstream-ignore": "^1.0.5",
"once": "1.4.0", "once": "^1.3.3",
"readable-stream": "2.3.5", "readable-stream": "^2.1.4",
"rimraf": "2.6.2", "rimraf": "^2.5.1",
"tar": "2.2.1", "tar": "^2.2.1",
"uid-number": "0.0.6" "uid-number": "^0.0.6"
} }
}, },
"tar-stream": { "tar-stream": {
@@ -1003,10 +1003,10 @@
"integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==", "integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==",
"dev": true, "dev": true,
"requires": { "requires": {
"bl": "1.2.1", "bl": "^1.0.0",
"end-of-stream": "1.4.1", "end-of-stream": "^1.0.0",
"readable-stream": "2.3.5", "readable-stream": "^2.0.0",
"xtend": "4.0.1" "xtend": "^4.0.0"
} }
}, },
"through": { "through": {
@@ -1027,7 +1027,7 @@
"integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=",
"dev": true, "dev": true,
"requires": { "requires": {
"escape-string-regexp": "1.0.5" "escape-string-regexp": "^1.0.2"
} }
}, },
"tunnel-agent": { "tunnel-agent": {
@@ -1036,7 +1036,7 @@
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"dev": true, "dev": true,
"requires": { "requires": {
"safe-buffer": "5.1.1" "safe-buffer": "^5.0.1"
} }
}, },
"uid-number": { "uid-number": {
@@ -1051,8 +1051,8 @@
"integrity": "sha512-izD3jxT8xkzwtXRUZjtmRwKnZoeECrfZ8ra/ketwOcusbZEp4mjULMnJOCfTDZBgGQAAY1AJ/IgxcwkavcX9Og==", "integrity": "sha512-izD3jxT8xkzwtXRUZjtmRwKnZoeECrfZ8ra/ketwOcusbZEp4mjULMnJOCfTDZBgGQAAY1AJ/IgxcwkavcX9Og==",
"dev": true, "dev": true,
"requires": { "requires": {
"buffer": "3.6.0", "buffer": "^3.0.1",
"through": "2.3.8" "through": "^2.3.6"
} }
}, },
"url-parse-lax": { "url-parse-lax": {
@@ -1061,7 +1061,7 @@
"integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=",
"dev": true, "dev": true,
"requires": { "requires": {
"prepend-http": "1.0.4" "prepend-http": "^1.0.1"
} }
}, },
"url-to-options": { "url-to-options": {
@@ -1082,7 +1082,7 @@
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
"dev": true, "dev": true,
"requires": { "requires": {
"string-width": "1.0.2" "string-width": "^1.0.2"
} }
}, },
"wrappy": { "wrappy": {
@@ -1097,9 +1097,9 @@
"integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "4.1.11", "graceful-fs": "^4.1.11",
"imurmurhash": "0.1.4", "imurmurhash": "^0.1.4",
"signal-exit": "3.0.2" "signal-exit": "^3.0.2"
} }
}, },
"write-json-file": { "write-json-file": {
@@ -1108,12 +1108,12 @@
"integrity": "sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=", "integrity": "sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=",
"dev": true, "dev": true,
"requires": { "requires": {
"detect-indent": "5.0.0", "detect-indent": "^5.0.0",
"graceful-fs": "4.1.11", "graceful-fs": "^4.1.2",
"make-dir": "1.2.0", "make-dir": "^1.0.0",
"pify": "3.0.0", "pify": "^3.0.0",
"sort-keys": "2.0.0", "sort-keys": "^2.0.0",
"write-file-atomic": "2.3.0" "write-file-atomic": "^2.0.0"
}, },
"dependencies": { "dependencies": {
"sort-keys": { "sort-keys": {
@@ -1122,7 +1122,7 @@
"integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=",
"dev": true, "dev": true,
"requires": { "requires": {
"is-plain-obj": "1.1.0" "is-plain-obj": "^1.0.0"
} }
} }
} }
@@ -1139,8 +1139,8 @@
"integrity": "sha1-qBmB6nCleUYTOIPwKcWCGok1mn8=", "integrity": "sha1-qBmB6nCleUYTOIPwKcWCGok1mn8=",
"dev": true, "dev": true,
"requires": { "requires": {
"buffer-crc32": "0.2.13", "buffer-crc32": "~0.2.3",
"fd-slicer": "1.0.1" "fd-slicer": "~1.0.1"
} }
} }
} }

View File

@@ -2,14 +2,12 @@
"name": "mozjpeg_enc", "name": "mozjpeg_enc",
"scripts": { "scripts": {
"install": "napa", "install": "napa",
"build": "npm run build:library && npm run build:wasm", "build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
"build:library": "cd node_modules/mozjpeg && autoreconf -fiv && docker run --rm -v $(pwd):/src trzeci/emscripten emconfigure ./configure --without-simd && docker run --rm -v $(pwd):/src trzeci/emscripten emmake make libjpeg.la",
"build:wasm": "docker run --rm -v $(pwd):/src trzeci/emscripten emcc -O3 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME=\"mozjpeg_enc\"' -I node_modules/mozjpeg -o ./mozjpeg_enc.js mozjpeg_enc.c node_modules/mozjpeg/.libs/libjpeg.a"
}, },
"napa": { "napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1" "mozjpeg": "mozilla/mozjpeg#v3.3.1"
}, },
"devDependencies": { "devDependencies": {
"napa": "^3.0.0" "napa": "3.0.0"
} }
} }

2
codecs/optipng/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
build/
*.o

26
codecs/optipng/README.md Normal file
View File

@@ -0,0 +1,26 @@
# OptiPNG
- Source: <http://optipng.sourceforge.net/>
- Version: v0.7.7
## Dependencies
- Docker
## Example
See `example.html`
## API
### `int version()`
Returns the version of optipng as a number. va.b.c is encoded as 0x0a0b0c
### `ArrayBuffer compress(std::string buffer, {level})`;
`compress` will re-compress the given PNG image via `buffer`. `level` is a number between 0 and 7.
### `void free_result()`
Frees the result created by `compress()`.

87
codecs/optipng/build.sh Executable file
View File

@@ -0,0 +1,87 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export PREFIX="/src/build"
export CFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
export CPPFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
export LDFLAGS="${OPTIMIZE} -L${PREFIX}/lib/"
apt-get update
apt-get install -qqy autoconf libtool
echo "============================================="
echo "Compiling zlib"
echo "============================================="
test -n "$SKIP_ZLIB" || (
cd node_modules/zlib
emconfigure ./configure --prefix=${PREFIX}/
emmake make
emmake make install
)
echo "============================================="
echo "Compiling zlib done"
echo "============================================="
echo "============================================="
echo "Compiling libpng"
echo "============================================="
test -n "$SKIP_LIBPNG" || (
cd node_modules/libpng
autoreconf -i
emconfigure ./configure --with-zlib-prefix=${PREFIX}/ --prefix=${PREFIX}/
emmake make
emmake make install
)
echo "============================================="
echo "Compiling libpng done"
echo "============================================="
echo "============================================="
echo "Compiling optipng"
echo "============================================="
(
emcc \
${OPTIMIZE} \
-Wno-implicit-function-declaration \
-I ${PREFIX}/include \
-I node_modules/optipng/src/opngreduc \
-I node_modules/optipng/src/pngxtern \
-I node_modules/optipng/src/cexcept \
-I node_modules/optipng/src/gifread \
-I node_modules/optipng/src/pnmio \
-I node_modules/optipng/src/minitiff \
--std=c99 -c \
node_modules/optipng/src/opngreduc/*.c \
node_modules/optipng/src/pngxtern/*.c \
node_modules/optipng/src/gifread/*.c \
node_modules/optipng/src/minitiff/*.c \
node_modules/optipng/src/pnmio/*.c \
node_modules/optipng/src/optipng/*.c
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="optipng"' \
-I ${PREFIX}/include \
-I node_modules/optipng/src/opngreduc \
-I node_modules/optipng/src/pngxtern \
-I node_modules/optipng/src/cexcept \
-I node_modules/optipng/src/gifread \
-I node_modules/optipng/src/pnmio \
-I node_modules/optipng/src/minitiff \
-o "optipng.js" \
--std=c++11 \
optipng.cpp \
*.o \
${PREFIX}/lib/libz.so ${PREFIX}/lib/libpng.a
)
echo "============================================="
echo "Compiling optipng done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -0,0 +1,19 @@
<!doctype html>
<script src='optipng.js'></script>
<script>
const Module = optipng();
Module.onRuntimeInitialized = async _ => {
console.log('Version:', Module.version().toString(16));
const image = await fetch('../example_palette.png').then(r => r.arrayBuffer());
const newImage = Module.compress(image, {level: 3});
console.log('done');
Module.free_result();
console.log(`Old size: ${image.byteLength}, new size: ${newImage.byteLength} (${newImage.byteLength/image.byteLength*100}%)`);
const blobURL = URL.createObjectURL(new Blob([newImage], {type: 'image/png'}));
const img = document.createElement('img');
img.src = blobURL;
document.body.appendChild(img);
};
</script>

View File

@@ -0,0 +1,53 @@
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include <stdio.h>
using namespace emscripten;
extern "C" int main(int argc, char *argv[]);
int version() {
// FIXME (@surma): Havent found a version in optipng :(
return 0;
}
struct OptiPngOpts {
int level;
};
uint8_t* result;
val compress(std::string png, OptiPngOpts opts) {
remove("input.png");
remove("output.png");
FILE* infile = fopen("input.png", "wb");
fwrite(png.c_str(), png.length(), 1, infile);
fflush(infile);
fclose(infile);
char optlevel[8];
sprintf(&optlevel[0], "-o%d", opts.level);
char* args[] = {"optipng", optlevel, "-out", "output.png", "input.png"};
main(5, args);
FILE *outfile = fopen("output.png", "rb");
fseek(outfile, 0, SEEK_END);
int fsize = ftell(outfile);
result = (uint8_t*) malloc(fsize);
fseek(outfile, 0, SEEK_SET);
fread(result, fsize, 1, outfile);
return val(typed_memory_view(fsize, result));
}
void free_result() {
free(result);
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<OptiPngOpts>("OptiPngOpts")
.field("level", &OptiPngOpts::level);
function("version", &version);
function("compress", &compress);
function("free_result", &free_result);
}

10
codecs/optipng/optipng.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import {EncodeOptions} from "src/codecs/optipng/encoder";
export interface OptiPngModule extends EmscriptenWasm.Module {
compress(data: BufferSource, opts: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): OptiPngModule;

24
codecs/optipng/optipng.js Normal file

File diff suppressed because one or more lines are too long

BIN
codecs/optipng/optipng.wasm Normal file

Binary file not shown.

1457
codecs/optipng/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
{
"name": "optipng",
"scripts": {
"install": "tar-dependency install && napa",
"build": "npm run build:wasm",
"build:wasm": "docker run --rm -v $(pwd):/src -e SKIP_ZLIB=\"${SKIP_ZLIB}\" -e SKIP_LIBPNG=\"${SKIP_LIBPNG}\" trzeci/emscripten ./build.sh"
},
"tarDependencies": {
"node_modules/optipng": {
"url": "https://netcologne.dl.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz",
"strip": 1
}
},
"napa": {
"libpng": "emscripten-ports/libpng",
"zlib": "emscripten-ports/zlib"
},
"dependencies": {
"napa": "3.0.0",
"tar-dependency": "0.0.3"
}
}

0
codecs/oxipng/.cargo-ok Normal file
View File

5
codecs/oxipng/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
/target
**/*.rs.bk
Cargo.lock
bin/
wasm-pack.log

36
codecs/oxipng/Cargo.toml Normal file
View File

@@ -0,0 +1,36 @@
[package]
name = "test"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
[lib]
path = "lib.rs"
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
cfg-if = "0.1.2"
wasm-bindgen = "0.2"
oxipng = "2.2.0"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.2"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

52
codecs/oxipng/README.md Normal file
View File

@@ -0,0 +1,52 @@
# 🦀🕸️ `wasm-pack-template`
A template for kick starting a Rust and WebAssembly project using
[`wasm-pack`](https://github.com/rustwasm/wasm-pack).
This template is designed for compiling Rust libraries into WebAssembly and
publishing the resulting package to NPM.
* Want to use the published NPM package in a Website? [Check out
`create-wasm-app`.](https://github.com/rustwasm/create-wasm-app)
* Want to make a monorepo-style Website without publishing to NPM? Check out
[`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template)
and/or
[`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template).
## 🔋 Batteries Included
* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
between WebAssembly and JavaScript.
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
for logging panic messages to the developer console.
* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
for small code size.
## 🚴 Usage
### 🐑 Use `cargo generate` to Clone this Template
[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
```
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project
```
### 🛠️ Build with `wasm-pack build`
```
wasm-pack build
```
### 🔬 Test in Headless Browsers with `wasm-pack test`
```
wasm-pack test --headless --firefox
```
### 🎁 Publish to NPM with `wasm-pack publish`
```
wasm-pack publish
```

5
codecs/oxipng/Xargo.toml Normal file
View File

@@ -0,0 +1,5 @@
[target.wasm32-unknown-unknown.dependencies]
time = {}
[target.wasm32-unknown-unknown.dependencies.std]
features = ["wasm_syscall"]

View File

@@ -0,0 +1,52 @@
# 🦀🕸️ `wasm-pack-template`
A template for kick starting a Rust and WebAssembly project using
[`wasm-pack`](https://github.com/rustwasm/wasm-pack).
This template is designed for compiling Rust libraries into WebAssembly and
publishing the resulting package to NPM.
* Want to use the published NPM package in a Website? [Check out
`create-wasm-app`.](https://github.com/rustwasm/create-wasm-app)
* Want to make a monorepo-style Website without publishing to NPM? Check out
[`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template)
and/or
[`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template).
## 🔋 Batteries Included
* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
between WebAssembly and JavaScript.
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
for logging panic messages to the developer console.
* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
for small code size.
## 🚴 Usage
### 🐑 Use `cargo generate` to Clone this Template
[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
```
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project
```
### 🛠️ Build with `wasm-pack build`
```
wasm-pack build
```
### 🔬 Test in Headless Browsers with `wasm-pack test`
```
wasm-pack test --headless --firefox
```
### 🎁 Publish to NPM with `wasm-pack publish`
```
wasm-pack publish
```

BIN
codecs/oxipng/pkg/img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

14
codecs/oxipng/pkg/lol.js Normal file
View File

@@ -0,0 +1,14 @@
const oxipng = require("./oxipng_wasm");
const repl = require("repl");
const fs = require("fs");
async function init() {
// const img = fs.readFileSync("img.png")
// const output = oxipng.compress(img, 0);
// fs.writeFileSync("output.png", output);
console.log(">>>", oxipng.doit());
const r = repl.start("node> ");
r.context.i = oxipng;
}
init();

3
codecs/oxipng/pkg/oxipng.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
/* tslint:disable */
export function compress(arg0: Uint8Array, arg1: number): Uint8Array;

View File

@@ -0,0 +1,73 @@
/* tslint:disable */
var wasm;
const TextDecoder = require('util').TextDecoder;
let cachedTextDecoder = new TextDecoder('utf-8');
let cachegetUint8Memory = null;
function getUint8Memory() {
if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory;
}
function getStringFromWasm(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
}
module.exports.__wbg_log_64e6f53d8e6d5db5 = function(arg0, arg1) {
let varg0 = getStringFromWasm(arg0, arg1);
console.log(varg0);
};
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
getUint8Memory().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
}
let cachedGlobalArgumentPtr = null;
function globalArgumentPtr() {
if (cachedGlobalArgumentPtr === null) {
cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr();
}
return cachedGlobalArgumentPtr;
}
let cachegetUint32Memory = null;
function getUint32Memory() {
if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
}
return cachegetUint32Memory;
}
/**
* @param {Uint8Array} arg0
* @param {number} arg1
* @returns {Uint8Array}
*/
module.exports.compress = function(arg0, arg1) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
wasm.compress(retptr, ptr0, len0, arg1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
};
wasm = require('./oxipng_bg');

6
codecs/oxipng/pkg/oxipng_bg.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/* tslint:disable */
export const memory: WebAssembly.Memory;
export function __wbindgen_global_argument_ptr(): number;
export function compress(a: number, b: number, c: number, d: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_free(a: number, b: number): void;

View File

@@ -0,0 +1,9 @@
const path = require('path').join(__dirname, 'oxipng_bg.wasm');
const bytes = require('fs').readFileSync(path);
let imports = {};
imports['./oxipng'] = require('./oxipng');
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
module.exports = wasmInstance.exports;

Binary file not shown.

3
codecs/oxipng/pkg/oxipng_manual.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
/* tslint:disable */
export function compress(arg0: Uint8Array, arg1: number): Promise<Uint8Array>;

View File

@@ -0,0 +1,77 @@
/* tslint:disable */
import wasmUrl from './oxipng_bg.wasm';
let wasm;
const instancePromise = WebAssembly.instantiateStreaming(fetch(wasmUrl), {
"./oxipng": {__wbg_log_64e6f53d8e6d5db5}
});
let cachedTextDecoder = new TextDecoder('utf-8');
let cachegetUint8Memory = null;
function getUint8Memory() {
if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory;
}
function getStringFromWasm(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
}
export function __wbg_log_64e6f53d8e6d5db5(arg0, arg1) {
let varg0 = getStringFromWasm(arg0, arg1);
console.log(varg0);
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
getUint8Memory().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
}
let cachedGlobalArgumentPtr = null;
function globalArgumentPtr() {
if (cachedGlobalArgumentPtr === null) {
cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr();
}
return cachedGlobalArgumentPtr;
}
let cachegetUint32Memory = null;
function getUint32Memory() {
if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
}
return cachegetUint32Memory;
}
/**
* @param {Uint8Array} arg0
* @param {number} arg1
* @returns {Uint8Array}
*/
export async function compress(arg0, arg1) {
wasm = (await instancePromise).instance.exports;
debugger;
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
wasm.compress(retptr, ptr0, len0, arg1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
}

3
codecs/oxipng/pkg/oxipng_wasm.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
/* tslint:disable */
export function doit(): number;

View File

@@ -0,0 +1,11 @@
/* tslint:disable */
var wasm;
/**
* @returns {number}
*/
module.exports.doit = function() {
return wasm.doit();
};
wasm = require('./oxipng_wasm_bg');

3
codecs/oxipng/pkg/oxipng_wasm_bg.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
/* tslint:disable */
export const memory: WebAssembly.Memory;
export function doit(): number;

View File

@@ -0,0 +1,8 @@
const path = require('path').join(__dirname, 'oxipng_wasm_bg.wasm');
const bytes = require('fs').readFileSync(path);
let imports = {};
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
module.exports = wasmInstance.exports;

Binary file not shown.

View File

@@ -0,0 +1,15 @@
{
"name": "oxipng-wasm",
"collaborators": [
"Surma <surma@surma.link>"
],
"version": "0.1.0",
"files": [
"oxipng_wasm_bg.wasm",
"oxipng_wasm.js",
"oxipng_wasm_bg.js",
"oxipng_wasm.d.ts"
],
"main": "oxipng_wasm.js",
"types": "oxipng_wasm.d.ts"
}

View File

42
codecs/oxipng/src/lib.rs Normal file
View File

@@ -0,0 +1,42 @@
extern crate cfg_if;
extern crate wasm_bindgen;
// extern crate oxipng;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
use std::time::{Instant};
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
}
}
// #[wasm_bindgen]
// extern {
// #[wasm_bindgen(js_namespace = console)]
// fn log(s: &str);
// }
// #[wasm_bindgen]
// pub fn compress(img: Vec<u8>, level: u8) -> Vec<u8> {
// log(&format!("len: {}, level: {}", img.len(), level));
// let mut options = oxipng::Options::from_preset(level);
// options.threads = 0;
// let result = oxipng::optimize_from_memory(img.as_slice(), &options);
// match result {
// Ok(v) => v,
// Err(e) => e.to_string().as_bytes().to_vec()
// }
// }
#[wasm_bindgen]
pub fn doit() -> u32 {
let start = Instant::now();
start.elapsed().as_secs() as u32
}

View File

@@ -0,0 +1,17 @@
use cfg_if::cfg_if;
cfg_if! {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
if #[cfg(feature = "console_error_panic_hook")] {
extern crate console_error_panic_hook;
pub use self::console_error_panic_hook::set_once as set_panic_hook;
} else {
#[inline]
pub fn set_panic_hook() {}
}
}

1
codecs/oxipng/tmp/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target

View File

@@ -0,0 +1,27 @@
[package]
name = "loltest"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
[lib]
path = "lib.rs"
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.2"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

View File

@@ -0,0 +1,2 @@
[dependencies.std]
features = ["wasm_syscall"]

View File

@@ -0,0 +1,20 @@
Im trying to activate [the `wasm_syscall` feature][1] in Rusts stdlib for WebAssembly.
Here is my `Cargo.toml` and my `Xargo.toml`. But even with this setup the generated wasm file is still hard-coded to panic.
**HELP?**
My current command to compile is:
```
xargo build --target wasm32-unknown-unknown --release
```
If you have [`wasm2wat`][2] installed, you can verify the generate code via
```
wasm2wat target/wasm32-unknown-unknown/release/loltest.wasm | grep -A5 perform::
```
[1]: https://github.com/rust-lang/rust/blob/b139669f374eb5024a50eb13f116ff763b1c5935/src/libstd/sys/wasm/mod.rs#L309
[2]: https://github.com/WebAssembly/wabt

14
codecs/oxipng/tmp/lib.rs Normal file
View File

@@ -0,0 +1,14 @@
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use std::thread::spawn;
#[wasm_bindgen]
pub fn doit() {
// let child = spawn(move || -> u32 {
// 5
// });
// let result = child.join().unwrap();
let result = spawn();
println!("Result: {}", result);
}

47
codecs/oxipng/tmp/lol.js Normal file
View File

@@ -0,0 +1,47 @@
// const oxipng = require("./oxipng_wasm");
const repl = require("repl");
const fs = require("fs");
const dec = new TextDecoder();
let buffer = '';
async function init() {
const { instance } = await WebAssembly.instantiate(
fs.readFileSync("./target/wasm32-unknown-unknown/release/loltest.wasm"),
{
__wbindgen_placeholder__: {
__wbindgen_describe(v) {
console.log(`__wbindgen_desribe(${v})`);
}
},
env: {
// See https://github.com/rust-lang/rust/blob/master/src/libstd/sys/wasm/mod.rs
rust_wasm_syscall(syscall, ptr) {
switch(syscall) {
case 1: // Write
const [fd, dataPtr, len] = new Uint32Array(instance.exports.memory.buffer, ptr, 3 * 4);
const fragment = new Uint8Array(instance.exports.memory.buffer, dataPtr, len);
buffer += dec.decode(fragment);
const idx = buffer.indexOf('\n');
if(idx !== -1) {
console.log(buffer.slice(0, idx));
buffer = buffer.slice(idx);
}
return 1;
case 6: // Time
return 1;
default:
return 0; // False, unimplemented
}
}
}
}
);
try {
instance.exports.doit();
} catch{}
const r = repl.start("node> ");
r.context.i = instance;
}
init();

File diff suppressed because it is too large Load Diff

22
codecs/webp_dec/README.md Normal file
View File

@@ -0,0 +1,22 @@
# WebP decoder
- Source: <https://github.com/webmproject/libwebp>
- Version: v1.0.2
## Example
See `example.html`
## API
### `int version()`
Returns the version of libwebp as a number. va.b.c is encoded as 0x0a0b0c
### `RawImage decode(std::string buffer)`
Decodes the given webp buffer into raw RGBA. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.
### `void free_result()`
Frees the result created by `decode()`.

60
codecs/webp_dec/build.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling libwebp"
echo "============================================="
test -n "$SKIP_LIBWEBP" || (
cd node_modules/libwebp
autoreconf -fiv
rm -rf build || true
mkdir -p build && cd build
emconfigure ../configure \
--disable-libwebpdemux \
--disable-wic \
--disable-gif \
--disable-tiff \
--disable-jpeg \
--disable-png \
--disable-sdl \
--disable-gl \
--disable-threading \
--disable-neon-rtcd \
--disable-neon \
--disable-sse2 \
--disable-sse4.1
emmake make
)
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
emcc \
${OPTIMIZE} \
--bind \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="webp_dec"' \
--std=c++11 \
-I node_modules/libwebp \
-o ./webp_dec.js \
-x c++ \
webp_dec.cpp \
node_modules/libwebp/build/src/.libs/libwebp.a
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -0,0 +1,24 @@
<!doctype html>
<script src='webp_dec.js'></script>
<script>
const Module = webp_dec();
async function loadFile(src) {
const resp = await fetch(src);
return await resp.arrayBuffer();
}
Module.onRuntimeInitialized = async _ => {
console.log('Version:', Module.version().toString(16));
const image = await loadFile('../example.webp');
const result = Module.decode(image);
const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
Module.free_result();
const canvas = document.createElement('canvas');
canvas.width = result.width;
canvas.height = result.height;
document.body.appendChild(canvas);
const ctx = canvas.getContext('2d');
ctx.putImageData(imageData, 0, 0);
};
</script>

1147
codecs/webp_dec/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"name": "webp_dec",
"scripts": {
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
},
"napa": {
"libwebp": "webmproject/libwebp#v1.0.2"
},
"devDependencies": {
"napa": "3.0.0"
}
}

View File

@@ -0,0 +1,47 @@
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include "src/webp/decode.h"
#include "src/webp/demux.h"
#include <string>
using namespace emscripten;
int version() {
return WebPGetDecoderVersion();
}
class RawImage {
public:
val buffer;
int width;
int height;
RawImage(val b, int w, int h)
: buffer(b), width(w), height(h) {}
};
uint8_t* last_result;
RawImage decode(std::string buffer) {
int width, height;
last_result = WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height);
return RawImage(
val(typed_memory_view(width*height*4, last_result)),
width,
height
);
}
void free_result() {
free(last_result);
}
EMSCRIPTEN_BINDINGS(my_module) {
class_<RawImage>("RawImage")
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
function("decode", &decode);
function("version", &version);
function("free_result", &free_result);
}

13
codecs/webp_dec/webp_dec.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
interface RawImage {
buffer: Uint8Array;
width: number;
height: number;
}
interface WebPModule extends EmscriptenWasm.Module {
decode(data: BufferSource): RawImage;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): WebPModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1,7 +1,7 @@
# WebP encoder # WebP encoder
- Source: <https://github.com/webmproject/libwebp> - Source: <https://github.com/webmproject/libwebp>
- Version: v0.6.1 - Version: v1.0.2
## Dependencies ## Dependencies
@@ -17,26 +17,10 @@ See `example.html`
Returns the version of libwebp as a number. va.b.c is encoded as 0x0a0b0c Returns the version of libwebp as a number. va.b.c is encoded as 0x0a0b0c
### `uint8_t* create_buffer(int width, int height)` ### `UInt8Array encode(uint8_t* image_buffer, int image_width, int image_height, WebPConfig config)`
Allocates an RGBA buffer for an image with the given dimension. Encodes the given image with given dimension to WebP.
### `void destroy_buffer(uint8_t* p)`
Frees a buffer created with `create_buffer`.
### `void encode(uint8_t* image_buffer, int image_width, int image_height, float quality)`
Encodes the given image with given dimension to WebP. `quality` is a number between 0 and 100. The higher the number, the better the quality of the encoded image. The result is implicitly stored and can be accessed using the `get_result_*()` functions.
### `void free_result()` ### `void free_result()`
Frees the result created by `encode()`. Frees the last result created by `encode()`.
### `int get_result_pointer()`
Returns the pointer to the start of the buffer holding the encoded data.
### `int get_result_size()`
Returns the length of the buffer holding the encoded data.

61
codecs/webp_enc/build.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling libwebp"
echo "============================================="
test -n "$SKIP_LIBWEBP" || (
cd node_modules/libwebp
autoreconf -fiv
rm -rf build || true
mkdir -p build && cd build
emconfigure ../configure \
--disable-libwebpdemux \
--disable-wic \
--disable-gif \
--disable-tiff \
--disable-jpeg \
--disable-png \
--disable-sdl \
--disable-gl \
--disable-threading \
--disable-neon-rtcd \
--disable-neon \
--disable-sse2 \
--disable-sse4.1
emmake make
)
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
emcc \
${OPTIMIZE} \
--bind \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="webp_enc"' \
--std=c++11 \
-I node_modules/libwebp \
-o ./webp_enc.js \
-x c++ \
webp_enc.cpp \
node_modules/libwebp/build/src/.libs/libwebp.a
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -1,7 +1,7 @@
<!doctype html> <!doctype html>
<script src='webp_enc.js'></script> <script src='webp_enc.js'></script>
<script> <script>
const Module = webp_enc(); const module = webp_enc();
async function loadImage(src) { async function loadImage(src) {
// Load image // Load image
@@ -17,28 +17,43 @@
return ctx.getImageData(0, 0, img.width, img.height); return ctx.getImageData(0, 0, img.width, img.height);
} }
Module.onRuntimeInitialized = async _ => { module.onRuntimeInitialized = async _ => {
const api = { console.log('Version:', module.version().toString(16));
version: Module.cwrap('version', 'number', []),
create_buffer: Module.cwrap('create_buffer', 'number', ['number', 'number']),
destroy_buffer: Module.cwrap('destroy_buffer', '', ['number']),
encode: Module.cwrap('encode', '', ['number', 'number', 'number', 'number']),
free_result: Module.cwrap('free_result', '', ['number']),
get_result_pointer: Module.cwrap('get_result_pointer', 'number', []),
get_result_size: Module.cwrap('get_result_size', 'number', []),
};
const image = await loadImage('../example.png'); const image = await loadImage('../example.png');
const p = api.create_buffer(image.width, image.height); const result = module.encode(image.data, image.width, image.height, {
Module.HEAP8.set(image.data, p); quality: 75,
api.encode(p, image.width, image.height, 2); target_size: 0,
const resultPointer = api.get_result_pointer(); target_PSNR: 0,
const resultSize = api.get_result_size(); method: 4,
const resultView = new Uint8Array(Module.HEAP8.buffer, resultPointer, resultSize); sns_strength: 50,
const result = new Uint8Array(resultView); filter_strength: 60,
api.free_result(resultPointer); filter_sharpness: 0,
api.destroy_buffer(p); filter_type: 1,
partitions: 0,
segments: 4,
pass: 1,
show_compressed: 0,
preprocessing: 0,
autofilter: 0,
partition_limit: 0,
alpha_compression: 1,
alpha_filtering: 1,
alpha_quality: 100,
lossless: 0,
exact: 0,
image_hint: 0,
emulate_jpeg_size: 0,
thread_level: 0,
low_memory: 0,
near_lossless: 100,
use_delta_palette: 0,
use_sharp_yuv: 0,
});
console.log('size', result.length);
const blob = new Blob([result], {type: 'image/webp'});
module.free_result();
const blob = new Blob([result], {type: 'image/jpeg'});
const blobURL = URL.createObjectURL(blob); const blobURL = URL.createObjectURL(blob);
const img = document.createElement('img'); const img = document.createElement('img');
img.src = blobURL; img.src = blobURL;

View File

@@ -2,12 +2,12 @@
"name": "webp_enc", "name": "webp_enc",
"scripts": { "scripts": {
"install": "napa", "install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten emcc -O3 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME=\"webp_enc\"' -I node_modules/libwebp -o ./webp_enc.js webp_enc.c node_modules/libwebp/src/{dec,dsp,demux,enc,mux,utils}/*.c" "build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
}, },
"napa": { "napa": {
"libwebp": "webmproject/libwebp#v0.6.1" "libwebp": "webmproject/libwebp#v1.0.2"
}, },
"devDependencies": { "devDependencies": {
"napa": "^3.0.0" "napa": "3.0.0"
} }
} }

View File

@@ -1,44 +0,0 @@
#include "emscripten.h"
#include "src/webp/encode.h"
#include <stdlib.h>
EMSCRIPTEN_KEEPALIVE
int version() {
return WebPGetEncoderVersion();
}
EMSCRIPTEN_KEEPALIVE
uint8_t* create_buffer(int width, int height) {
return malloc(width * height * 4 * sizeof(uint8_t));
}
EMSCRIPTEN_KEEPALIVE
void destroy_buffer(uint8_t* p) {
free(p);
}
int result[2];
EMSCRIPTEN_KEEPALIVE
void encode(uint8_t* img_in, int width, int height, float quality) {
uint8_t* img_out;
size_t size;
size = WebPEncodeRGBA(img_in, width, height, width * 4, quality, &img_out);
result[0] = (int)img_out;
result[1] = size;
}
EMSCRIPTEN_KEEPALIVE
void free_result() {
WebPFree(result[0]);
}
EMSCRIPTEN_KEEPALIVE
int get_result_pointer() {
return result[0];
}
EMSCRIPTEN_KEEPALIVE
int get_result_size() {
return result[1];
}

View File

@@ -0,0 +1,96 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "src/webp/encode.h"
#include <stdlib.h>
#include <string.h>
#include <stdexcept>
using namespace emscripten;
int version() {
return WebPGetEncoderVersion();
}
uint8_t* last_result;
val encode(std::string img, int width, int height, WebPConfig config) {
uint8_t* img_in = (uint8_t*) img.c_str();
// A lot of this is duplicated from Encode in picture_enc.c
WebPPicture pic;
WebPMemoryWriter wrt;
int ok;
if (!WebPPictureInit(&pic)) {
// shouldn't happen, except if system installation is broken
throw std::runtime_error("Unexpected error");
}
// Only use use_argb if we really need it, as it's slower.
pic.use_argb = config.lossless || config.use_sharp_yuv || config.preprocessing > 0;
pic.width = width;
pic.height = height;
pic.writer = WebPMemoryWrite;
pic.custom_ptr = &wrt;
WebPMemoryWriterInit(&wrt);
ok = WebPPictureImportRGBA(&pic, (uint8_t*) img_in, width * 4) && WebPEncode(&config, &pic);
WebPPictureFree(&pic);
if (!ok) {
WebPMemoryWriterClear(&wrt);
throw std::runtime_error("Encode failed");
}
last_result = wrt.mem;
return val(typed_memory_view(wrt.size, wrt.mem));
}
void free_result() {
WebPFree(last_result);
}
EMSCRIPTEN_BINDINGS(my_module) {
enum_<WebPImageHint>("WebPImageHint")
.value("WEBP_HINT_DEFAULT", WebPImageHint::WEBP_HINT_DEFAULT)
.value("WEBP_HINT_PICTURE", WebPImageHint::WEBP_HINT_PICTURE)
.value("WEBP_HINT_PHOTO", WebPImageHint::WEBP_HINT_PHOTO)
.value("WEBP_HINT_GRAPH", WebPImageHint::WEBP_HINT_GRAPH)
;
value_object<WebPConfig>("WebPConfig")
.field("lossless", &WebPConfig::lossless)
.field("quality", &WebPConfig::quality)
.field("method", &WebPConfig::method)
.field("image_hint", &WebPConfig::image_hint)
.field("target_size", &WebPConfig::target_size)
.field("target_PSNR", &WebPConfig::target_PSNR)
.field("segments", &WebPConfig::segments)
.field("sns_strength", &WebPConfig::sns_strength)
.field("filter_strength", &WebPConfig::filter_strength)
.field("filter_sharpness", &WebPConfig::filter_sharpness)
.field("filter_type", &WebPConfig::filter_type)
.field("autofilter", &WebPConfig::autofilter)
.field("alpha_compression", &WebPConfig::alpha_compression)
.field("alpha_filtering", &WebPConfig::alpha_filtering)
.field("alpha_quality", &WebPConfig::alpha_quality)
.field("pass", &WebPConfig::pass)
.field("show_compressed", &WebPConfig::show_compressed)
.field("preprocessing", &WebPConfig::preprocessing)
.field("partitions", &WebPConfig::partitions)
.field("partition_limit", &WebPConfig::partition_limit)
.field("emulate_jpeg_size", &WebPConfig::emulate_jpeg_size)
.field("thread_level", &WebPConfig::thread_level)
.field("low_memory", &WebPConfig::low_memory)
.field("near_lossless", &WebPConfig::near_lossless)
.field("exact", &WebPConfig::exact)
.field("use_delta_palette", &WebPConfig::use_delta_palette)
.field("use_sharp_yuv", &WebPConfig::use_sharp_yuv)
;
function("version", &version);
function("encode", &encode);
function("free_result", &free_result);
}

9
codecs/webp_enc/webp_enc.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
import { EncodeOptions } from '../../src/codecs/webp/encoder-meta';
interface WebPModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): WebPModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

74
config/add-css-types.js Normal file
View File

@@ -0,0 +1,74 @@
const DtsCreator = require('typed-css-modules');
const chokidar = require('chokidar');
const util = require('util');
const sass = require('node-sass');
const sassRender = util.promisify(sass.render);
async function sassToCss(path) {
const result = await sassRender({ file: path });
return result.css;
}
/**
* @typedef {Object} Opts
* @property {boolean} watch Watch for changes
*/
/**
* Create typing files for CSS & SCSS.
*
* @param {string[]} rootPaths Paths to search within
* @param {Opts} [opts={}] Options.
*/
function addCssTypes(rootPaths, opts = {}) {
return new Promise((resolve) => {
const { watch = false } = opts;
const paths = [];
const preReadyPromises = [];
let ready = false;
for (const rootPath of rootPaths) {
// Look for scss & css in each path.
paths.push(rootPath + '/**/*.scss');
paths.push(rootPath + '/**/*.css');
}
// For simplicity, the watcher is used even if we're not watching.
// If we're not watching, we stop the watcher after the initial files are found.
const watcher = chokidar.watch(paths, {
// Avoid processing already-processed files.
ignored: '*.d.*',
// Without this, travis and netlify builds never complete. I'm not sure why, but it might be
// related to https://github.com/paulmillr/chokidar/pull/758
persistent: watch,
});
function change(path) {
const promise = (async function() {
const creator = new DtsCreator({ camelCase: true });
const result = path.endsWith('.scss') ?
await creator.create(path, await sassToCss(path)) :
await creator.create(path);
await result.writeFile();
})();
if (!ready) preReadyPromises.push(promise);
}
watcher.on('change', change);
watcher.on('add', change);
// 'ready' is when events have been fired for file discovery.
watcher.on('ready', () => {
ready = true;
// Wait for the current set of processing to finish.
Promise.all(preReadyPromises).then(resolve);
// And if we're not watching, close the watcher.
if (!watch) watcher.close();
});
})
}
module.exports = addCssTypes;

View File

@@ -0,0 +1,47 @@
const path = require('path');
const fs = require('fs');
const ejs = require('ejs');
const AssetsPlugin = require('assets-webpack-plugin');
module.exports = class AssetTemplatePlugin extends AssetsPlugin {
constructor(options) {
options = options || {};
if (!options.template) throw Error('AssetTemplatePlugin: template option is required.');
super({
useCompilerPath: true,
filename: options.filename,
processOutput: files => this._processOutput(files)
});
this._template = path.resolve(process.cwd(), options.template);
const ignore = options.ignore || /(manifest\.json|\.DS_Store)$/;
this._ignore = typeof ignore === 'function' ? ({ test: ignore }) : ignore;
}
_processOutput(files) {
const mapping = {
all: [],
byType: {},
entries: {}
};
for (const entryName in files) {
// non-entry-point-derived assets are collected under an empty string key
// since that's a bit awkward, we'll call them "assets"
const name = entryName === '' ? 'assets' : entryName;
const listing = files[entryName];
const entry = mapping.entries[name] = {
all: [],
byType: {}
};
for (let type in listing) {
const list = [].concat(listing[type]).filter(file => !this._ignore.test(file));
if (!list.length) continue;
mapping.all = mapping.all.concat(list);
mapping.byType[type] = (mapping.byType[type] || []).concat(list);
entry.all = entry.all.concat(list);
entry.byType[type] = (entry.byType[type] || []).concat(list);
}
}
mapping.files = mapping.all;
return ejs.render(fs.readFileSync(this._template, 'utf8'), mapping);
}
};

158
config/auto-sw-plugin.js Normal file
View File

@@ -0,0 +1,158 @@
const util = require('util');
const minimatch = require('minimatch');
const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
const WebWorkerTemplatePlugin = require('webpack/lib/webworker/WebWorkerTemplatePlugin');
const ParserHelpers = require('webpack/lib/ParserHelpers');
const NAME = 'auto-sw-plugin';
const JS_TYPES = ['auto', 'esm', 'dynamic'];
/**
* Automatically finds and bundles Service Workers by looking for navigator.serviceWorker.register(..).
* An Array of webpack assets is injected into the Service Worker bundle as a `BUILD_ASSETS` global.
* Hidden and `.map` files are excluded by default, and this can be customized using the include & exclude options.
* @example
* // webpack config
* plugins: [
* new AutoSWPlugin({
* exclude: [
* '**\/.*', // don't expose hidden files (default)
* '**\/*.map', // don't precache sourcemaps (default)
* 'index.html' // don't cache the page itself
* ]
* })
* ]
* @param {Object} [options={}]
* @param {string[]} [options.exclude] Minimatch pattern(s) of which assets to omit from BUILD_ASSETS.
* @param {string[]} [options.include] Minimatch pattern(s) of assets to allow in BUILD_ASSETS.
*/
module.exports = class AutoSWPlugin {
constructor(options) {
this.options = Object.assign({
exclude: [
'**/*.map',
'**/.*'
]
}, options || {});
}
apply(compiler) {
const serviceWorkers = [];
compiler.hooks.emit.tapPromise(NAME, compilation => this.emit(compiler, compilation, serviceWorkers));
compiler.hooks.normalModuleFactory.tap(NAME, (factory) => {
for (const type of JS_TYPES) {
factory.hooks.parser.for(`javascript/${type}`).tap(NAME, parser => {
let counter = 0;
const processRegisterCall = expr => {
const dep = parser.evaluateExpression(expr.arguments[0]);
if (!dep.isString()) {
parser.state.module.warnings.push({
message: 'navigator.serviceWorker.register() will only be bundled if passed a String literal.'
});
return false;
}
const filename = dep.string;
const outputFilename = this.options.filename || 'serviceworker.js'
const context = parser.state.current.context;
serviceWorkers.push({
outputFilename,
filename,
context
});
const id = `__webpack__serviceworker__${++counter}`;
ParserHelpers.toConstantDependency(parser, id)(expr.arguments[0]);
return ParserHelpers.addParsedVariableToModule(parser, id, '__webpack_public_path__ + ' + JSON.stringify(outputFilename));
};
parser.hooks.call.for('navigator.serviceWorker.register').tap(NAME, processRegisterCall);
parser.hooks.call.for('self.navigator.serviceWorker.register').tap(NAME, processRegisterCall);
parser.hooks.call.for('window.navigator.serviceWorker.register').tap(NAME, processRegisterCall);
});
}
});
}
createFilter(list) {
const filters = [].concat(list);
for (let i=0; i<filters.length; i++) {
if (typeof filters[i] === 'string') {
filters[i] = minimatch.filter(filters[i]);
}
}
return filters;
}
async emit(compiler, compilation, serviceWorkers) {
let assetMapping = Object.keys(compilation.assets);
if (this.options.include) {
const filters = this.createFilter(this.options.include);
assetMapping = assetMapping.filter(filename => {
for (const filter of filters) {
if (filter(filename)) return true;
}
return false;
});
}
if (this.options.exclude) {
const filters = this.createFilter(this.options.exclude);
assetMapping = assetMapping.filter(filename => {
for (const filter of filters) {
if (filter(filename)) return false;
}
return true;
});
}
await Promise.all(serviceWorkers.map(
(serviceWorker, index) => this.compileServiceWorker(compiler, compilation, serviceWorker, index, assetMapping)
));
}
async compileServiceWorker(compiler, compilation, options, index, assetMapping) {
const entryFilename = options.filename;
const chunkFilename = compiler.options.output.chunkFilename.replace(/\.([a-z]+)$/i, '.serviceworker.$1');
const workerOptions = {
filename: options.outputFilename, // chunkFilename.replace(/\.?\[(?:chunkhash|contenthash|hash)(:\d+(?::\d+)?)?\]/g, ''),
chunkFilename: this.options.chunkFilename || chunkFilename,
globalObject: 'self'
};
const childCompiler = compilation.createChildCompiler(NAME, { filename: workerOptions.filename });
(new WebWorkerTemplatePlugin(workerOptions)).apply(childCompiler);
/* The duplication DefinePlugin ends up causing is problematic (it doesn't hoist injections), so we'll do it manually. */
// (new DefinePlugin({
// BUILD_ASSETS: JSON.stringify(assetMapping)
// })).apply(childCompiler);
(new SingleEntryPlugin(options.context, entryFilename, workerOptions.filename)).apply(childCompiler);
const subCache = `subcache ${__dirname} ${entryFilename} ${index}`;
let childCompilation;
childCompiler.hooks.compilation.tap(NAME, c => {
childCompilation = c;
if (childCompilation.cache) {
if (!childCompilation.cache[subCache]) childCompilation.cache[subCache] = {};
childCompilation.cache = childCompilation.cache[subCache];
}
});
await (util.promisify(childCompiler.runAsChild.bind(childCompiler)))();
const versionVar = this.options.version ?
`var VERSION = ${JSON.stringify(this.options.version)};` : '';
const original = childCompilation.assets[workerOptions.filename].source();
const source = `${versionVar}var BUILD_ASSETS=${JSON.stringify(assetMapping)};${original}`;
childCompilation.assets[workerOptions.filename] = {
source: () => source,
size: () => Buffer.byteLength(source, 'utf8')
};
Object.assign(compilation.assets, childCompilation.assets);
}
};

View File

@@ -1,54 +0,0 @@
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
},
{
"source": "**/*.@(jpg|jpeg|gif|png|ico)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=7200"
}
]
},
{
"source": "**/*.@(js|css|json|manifest|map)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=31536000"
}
]
},
{
"source": "sw.js",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=0"
}
]
}
]
}
}

11
global.d.ts vendored
View File

@@ -1,22 +1,23 @@
declare const __webpack_public_path__: string; declare const __webpack_public_path__: string;
declare const PRERENDER: boolean;
declare interface NodeModule { declare interface NodeModule {
hot: any; hot: any;
} }
declare interface Window { declare interface Window {
STATE: any STATE: any;
ga: typeof ga;
} }
declare namespace JSX { declare namespace JSX {
interface Element { } interface Element { }
interface IntrinsicElements { } interface IntrinsicElements { }
interface HTMLAttributes {
decoding?: string;
}
} }
declare module 'preact-i18n';
declare module 'preact-material-components-drawer';
declare module 'material-radial-progress';
declare module 'classnames' { declare module 'classnames' {
export default function classnames(...args: any[]): string; export default function classnames(...args: any[]): string;
} }

20217
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,94 +1,69 @@
{ {
"private": true, "private": true,
"name": "squoosh", "name": "squoosh",
"version": "0.0.0", "version": "1.3.1",
"license": "apache-2.0", "license": "apache-2.0",
"scripts": { "scripts": {
"build:mozjpeg_enc": "cd codecs/mozjpeg_enc && npm run build", "start": "webpack-dev-server --host 0.0.0.0 --hot",
"build:codecs": "npm run build:mozjpeg_enc",
"start": "webpack serve --host 0.0.0.0 --hot",
"build": "webpack -p", "build": "webpack -p",
"lint": "eslint src" "lint": "tslint -c tslint.json -p tsconfig.json -t verbose 'src/**/*.{ts,tsx,js,jsx}'",
"lintfix": "tslint -c tslint.json -p tsconfig.json -t verbose --fix 'src/**/*.{ts,tsx,js,jsx}'"
}, },
"eslintConfig": { "husky": {
"extends": [ "hooks": {
"standard", "pre-commit": "npm run lint"
"standard-jsx"
],
"rules": {
"indent": [
2,
2
],
"semi": [
2,
"always"
],
"prefer-const": 1
} }
}, },
"eslintIgnore": [
"build/*"
],
"devDependencies": { "devDependencies": {
"@types/node": "^9.4.7", "@types/node": "10.12.21",
"@types/webassembly-js-api": "0.0.1", "@types/pretty-bytes": "5.1.0",
"babel-loader": "^7.1.4", "@types/webassembly-js-api": "0.0.2",
"babel-plugin-jsx-pragmatic": "^1.0.2", "@webcomponents/custom-elements": "1.2.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "@webpack-cli/serve": "0.1.3",
"babel-plugin-transform-class-properties": "^6.24.1", "assets-webpack-plugin": "3.9.7",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "chokidar": "2.0.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "classnames": "2.2.6",
"babel-plugin-transform-react-constant-elements": "^6.23.0", "clean-webpack-plugin": "1.0.1",
"babel-plugin-transform-react-jsx": "^6.24.1", "comlink": "3.1.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13", "copy-webpack-plugin": "4.6.0",
"babel-preset-env": "^1.6.1", "critters-webpack-plugin": "2.2.0",
"babel-register": "^6.26.0", "css-loader": "1.0.1",
"clean-webpack-plugin": "^0.1.19", "ejs": "2.6.1",
"copy-webpack-plugin": "^4.5.1", "exports-loader": "0.7.0",
"css-loader": "^0.28.11", "file-drop-element": "0.0.9",
"eslint": "^4.18.2", "file-loader": "3.0.1",
"eslint-config-standard": "^11.0.0", "html-webpack-plugin": "3.2.0",
"eslint-config-standard-jsx": "^5.0.0", "husky": "1.3.1",
"eslint-plugin-import": "^2.10.0", "idb-keyval": "3.1.0",
"eslint-plugin-node": "^6.0.1", "linkstate": "1.1.1",
"eslint-plugin-promise": "^3.7.0", "loader-utils": "1.2.0",
"eslint-plugin-react": "^7.7.0", "mini-css-extract-plugin": "0.5.0",
"eslint-plugin-standard": "^3.0.1", "minimatch": "3.0.4",
"exports-loader": "^0.7.0", "node-sass": "4.11.0",
"file-loader": "^1.1.11", "optimize-css-assets-webpack-plugin": "5.0.1",
"html-webpack-plugin": "^3.0.6", "pointer-tracker": "2.0.3",
"if-env": "^1.0.4", "preact": "8.4.2",
"loader-utils": "^1.1.0", "prerender-loader": "1.2.0",
"mini-css-extract-plugin": "^0.3.0", "pretty-bytes": "5.1.0",
"node-sass": "^4.7.2", "progress-bar-webpack-plugin": "1.12.1",
"optimize-css-assets-webpack-plugin": "^4.0.0", "raw-loader": "1.0.0",
"progress-bar-webpack-plugin": "^1.11.0", "sass-loader": "7.1.0",
"raw-loader": "^0.5.1", "script-ext-html-webpack-plugin": "2.1.3",
"sass-loader": "^6.0.7", "source-map-loader": "0.2.4",
"script-ext-html-webpack-plugin": "^2.0.1", "style-loader": "0.23.1",
"source-map-loader": "^0.2.3", "terser-webpack-plugin": "1.2.2",
"style-loader": "^0.20.3", "ts-loader": "5.3.3",
"ts-loader": "^4.0.1", "tslint": "5.12.1",
"tslint": "^5.9.1", "tslint-config-airbnb": "5.11.1",
"tslint-config-semistandard": "^7.0.0", "tslint-config-semistandard": "7.0.0",
"tslint-react": "^3.5.1", "tslint-react": "3.6.0",
"typescript": "^2.7.2", "typed-css-modules": "0.3.7",
"typings-for-css-modules-loader": "^1.7.0", "typescript": "3.2.4",
"webpack": "^4.3.0", "url-loader": "1.1.2",
"webpack-bundle-analyzer": "^2.11.1", "webpack": "4.28.0",
"webpack-cli": "^2.0.13", "webpack-bundle-analyzer": "3.0.3",
"webpack-dev-server": "^3.1.1", "webpack-cli": "3.2.3",
"webpack-plugin-replace": "^1.1.1" "webpack-dev-server": "3.1.14",
}, "worker-plugin": "3.0.0"
"dependencies": {
"classnames": "^2.2.5",
"material-components-web": "^0.32.0",
"material-radial-progress": "git+https://gist.github.com/02134901c77c5309924bfcf8b4435ebe.git",
"preact": "^8.2.7",
"preact-i18n": "^1.2.0",
"preact-material-components": "^1.3.7",
"preact-material-components-drawer": "git+https://gist.github.com/a78fceed440b98e62582e4440b86bfab.git",
"preact-router": "^2.6.0"
} }
} }

5
renovate.json Normal file
View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/assets/icon-large.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
src/assets/icon-small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Some files were not shown because too many files have changed in this diff Show More