Merge branch 'dev' into gitignore

This commit is contained in:
Surma
2020-12-10 13:11:45 +00:00
committed by GitHub
5 changed files with 155 additions and 3 deletions

View File

@ -47,7 +47,7 @@ The default values for each `config` option can be found in the [`codecs.js`][co
Squoosh CLI has an _experimental_ auto optimizer that compresses an image as much as possible, trying to hit a specific [Butteraugli] target value. The higher the Butteraugli target value, the more artifacts can be introduced.
You can make use of the auto optimizer buy using “auto” as the config object.
You can make use of the auto optimizer by using “auto” as the config object.
```
$ npx @squoosh/cli --wp2 auto test.png

View File

@ -112,7 +112,9 @@ export default async function ({ watch }) {
plugins: [
{ resolveFileUrl, resolveImportMeta },
OMT({ loader: await omtLoaderPromise }),
serviceWorkerPlugin({ output: 'static/sw.js' }),
serviceWorkerPlugin({
output: 'static/serviceworker.js',
}),
...commonPlugins(),
commonjs(),
resolve(),

137
src/copy/sw-bridge.894ac.js Normal file
View File

@ -0,0 +1,137 @@
(self.webpackJsonp = self.webpackJsonp || []).push([
[0],
{
54: function (e, t, n) {
'use strict';
n.d(t, 'a', function () {
return o;
}),
n.d(t, 'b', function () {
return s;
});
class r {
constructor(e = 'keyval-store', t = 'keyval') {
(this.storeName = t),
(this._dbp = new Promise((n, r) => {
const a = indexedDB.open(e, 1);
(a.onerror = () => r(a.error)),
(a.onsuccess = () => n(a.result)),
(a.onupgradeneeded = () => {
a.result.createObjectStore(t);
});
}));
}
_withIDBStore(e, t) {
return this._dbp.then(
(n) =>
new Promise((r, a) => {
const i = n.transaction(this.storeName, e);
(i.oncomplete = () => r()),
(i.onabort = i.onerror = () => a(i.error)),
t(i.objectStore(this.storeName));
}),
);
}
}
let a;
function i() {
return a || (a = new r()), a;
}
function o(e, t = i()) {
let n;
return t
._withIDBStore('readonly', (t) => {
n = t.get(e);
})
.then(() => n.result);
}
function s(e, t, n = i()) {
return n._withIDBStore('readwrite', (n) => {
n.put(t, e);
});
}
},
56: function (e, t, n) {
'use strict';
n.r(t),
function (e) {
n.d(t, 'getSharedImage', function () {
return i;
}),
n.d(t, 'offliner', function () {
return o;
}),
n.d(t, 'mainAppLoaded', function () {
return s;
});
var r = n(54);
async function a(e) {
if (e.waiting) return;
const t = await (async function (e) {
return e.installing
? e.installing
: new Promise((t) => {
e.addEventListener('updatefound', () => t(e.installing), {
once: !0,
});
});
})(e);
return new Promise((e) => {
t.addEventListener('statechange', () => {
'installed' === t.state && e();
});
});
}
function i() {
return new Promise((e) => {
const t = (n) => {
'load-image' === n.data.action &&
(e(n.data.file),
navigator.serviceWorker.removeEventListener('message', t));
};
navigator.serviceWorker.addEventListener('message', t),
navigator.serviceWorker.controller.postMessage('share-ready');
});
}
async function o(t) {
if ('boolean' == typeof PRERENDER) return;
navigator.serviceWorker.register(e);
const n = !!navigator.serviceWorker.controller;
if (
(navigator.serviceWorker.addEventListener(
'controllerchange',
async () => {
n
? location.reload()
: t('Ready to work offline', { timeout: 5e3 });
},
),
!n)
)
return;
const r = await navigator.serviceWorker.getRegistration();
r &&
(await a(r),
'reload' ===
(await t('Update available', {
actions: ['reload', 'dismiss'],
})) &&
(async function () {
const e = await navigator.serviceWorker.getRegistration();
e && e.waiting && e.waiting.postMessage('skip-waiting');
})());
}
async function s() {
if (await Object(r.a)('user-interacted')) return;
Object(r.b)('user-interacted', !0);
const e = await (async function () {
const e = await navigator.serviceWorker.getRegistration();
return e ? e.active || e.waiting || e.installing : null;
})();
e && e.postMessage('cache-all');
}
}.call(this, n.p + 'serviceworker.js');
},
},
]);
//# sourceMappingURL=sw-bridge.894ac.js.map

4
src/copy/sw.js Normal file
View File

@ -0,0 +1,4 @@
// I accidentally shipped with the wrong service worker name.
// This picks up users that still might be using that version.
// We'll be able to delete this file eventually.
skipWaiting();

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB