Update Prettier

Also manually run prettier on `src/` and `lib/` to ensure
consistent formatting.
This commit is contained in:
Tim van der Lippe
2021-10-20 12:21:56 +01:00
parent e3f840c6da
commit e23bc4d2e5
8 changed files with 49 additions and 50 deletions

View File

@@ -77,7 +77,9 @@ export default function entryDataPlugin() {
} }
return JSON.stringify( return JSON.stringify(
getDependencies(chunks, chunk).map((filename) => fileNameToURL(filename)), getDependencies(chunks, chunk).map((filename) =>
fileNameToURL(filename),
),
); );
}, },
); );

14
package-lock.json generated
View File

@@ -40,7 +40,7 @@
"postcss-url": "^8.0.0", "postcss-url": "^8.0.0",
"preact": "^10.5.5", "preact": "^10.5.5",
"preact-render-to-string": "^5.1.11", "preact-render-to-string": "^5.1.11",
"prettier": "^2.1.2", "prettier": "^2.4.1",
"rollup": "^2.38.0", "rollup": "^2.38.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"serve": "^11.3.2", "serve": "^11.3.2",
@@ -7529,9 +7529,9 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.1.2", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
@@ -15029,9 +15029,9 @@
} }
}, },
"prettier": { "prettier": {
"version": "2.1.2", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
"dev": true "dev": true
}, },
"pretty-format": { "pretty-format": {

View File

@@ -40,7 +40,7 @@
"postcss-url": "^8.0.0", "postcss-url": "^8.0.0",
"preact": "^10.5.5", "preact": "^10.5.5",
"preact-render-to-string": "^5.1.11", "preact-render-to-string": "^5.1.11",
"prettier": "^2.1.2", "prettier": "^2.4.1",
"rollup": "^2.38.0", "rollup": "^2.38.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"serve": "^11.3.2", "serve": "^11.3.2",

View File

@@ -40,24 +40,23 @@ type PartialButNotUndefined<T> = {
[P in keyof T]: T[P]; [P in keyof T]: T[P];
}; };
const supportedEncoderMapP: Promise<PartialButNotUndefined< const supportedEncoderMapP: Promise<PartialButNotUndefined<typeof encoderMap>> =
typeof encoderMap (async () => {
>> = (async () => { const supportedEncoderMap: PartialButNotUndefined<typeof encoderMap> = {
const supportedEncoderMap: PartialButNotUndefined<typeof encoderMap> = { ...encoderMap,
...encoderMap, };
};
// Filter out entries where the feature test fails // Filter out entries where the feature test fails
await Promise.all( await Promise.all(
Object.entries(encoderMap).map(async ([encoderName, details]) => { Object.entries(encoderMap).map(async ([encoderName, details]) => {
if ('featureTest' in details && !(await details.featureTest())) { if ('featureTest' in details && !(await details.featureTest())) {
delete supportedEncoderMap[encoderName as keyof typeof encoderMap]; delete supportedEncoderMap[encoderName as keyof typeof encoderMap];
} }
}), }),
); );
return supportedEncoderMap; return supportedEncoderMap;
})(); })();
export default class Options extends Component<Props, State> { export default class Options extends Component<Props, State> {
state: State = { state: State = {

View File

@@ -14,9 +14,11 @@ import { EncodeOptions } from '../shared/meta';
import { threads } from 'wasm-feature-detect'; import { threads } from 'wasm-feature-detect';
async function initMT() { async function initMT() {
const { default: init, initThreadPool, optimise } = await import( const {
'codecs/oxipng/pkg-parallel/squoosh_oxipng' default: init,
); initThreadPool,
optimise,
} = await import('codecs/oxipng/pkg-parallel/squoosh_oxipng');
await init(); await init();
await initThreadPool(navigator.hardwareConcurrency); await initThreadPool(navigator.hardwareConcurrency);
return optimise; return optimise;

View File

@@ -2,9 +2,9 @@ import * as styles from './styles.css';
import 'add-css:./styles.css'; import 'add-css:./styles.css';
// So it doesn't cause an error when running in node // So it doesn't cause an error when running in node
const HTMLEl = ((__PRERENDER__ const HTMLEl = (__PRERENDER__
? Object ? Object
: HTMLElement) as unknown) as typeof HTMLElement; : HTMLElement) as unknown as typeof HTMLElement;
/** /**
* A simple spinner. This custom element has no JS API. Just put it in the document, and it'll * A simple spinner. This custom element has no JS API. Just put it in the document, and it'll

View File

@@ -2,9 +2,9 @@ import * as style from './styles.css';
import 'add-css:./styles.css'; import 'add-css:./styles.css';
// So it doesn't cause an error when running in node // So it doesn't cause an error when running in node
const HTMLEl = ((__PRERENDER__ const HTMLEl = (__PRERENDER__
? Object ? Object
: HTMLElement) as unknown) as typeof HTMLElement; : HTMLElement) as unknown as typeof HTMLElement;
export interface SnackOptions { export interface SnackOptions {
timeout?: number; timeout?: number;

View File

@@ -82,24 +82,20 @@ initialJs = subtractSets(
export const initial = ['/', ...initialJs]; export const initial = ['/', ...initialJs];
export const theRest = (async () => { export const theRest = (async () => {
const [ const [supportsThreads, supportsSimd, supportsWebP, supportsAvif] =
supportsThreads, await Promise.all([
supportsSimd, threads(),
supportsWebP, simd(),
supportsAvif, ...[webpDataUrl, avifDataUrl].map(async (dataUrl) => {
] = await Promise.all([ if (!self.createImageBitmap) return false;
threads(), const response = await fetch(dataUrl);
simd(), const blob = await response.blob();
...[webpDataUrl, avifDataUrl].map(async (dataUrl) => { return createImageBitmap(blob).then(
if (!self.createImageBitmap) return false; () => true,
const response = await fetch(dataUrl); () => false,
const blob = await response.blob(); );
return createImageBitmap(blob).then( }),
() => true, ]);
() => false,
);
}),
]);
const items: string[] = []; const items: string[] = [];