mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 02:29:50 +00:00
Remove CLI / libsquoosh (#1321)
Unfortunately, due to a few people leaving the team, and staffing issues resulting from the current economic climate (ugh), I'm deprecating the CLI and libsquoosh parts of Squoosh. The web app will continue to be supported and improved. I know that sucks, but there simply isn't the time & people to work on this. If anyone from the community wants to fork it, you have my blessing.
This commit is contained in:
@@ -17,7 +17,7 @@ import Toggle from './Toggle';
|
||||
import Select from './Select';
|
||||
import { Options as QuantOptionsComponent } from 'features/processors/quantize/client';
|
||||
import { Options as ResizeOptionsComponent } from 'features/processors/resize/client';
|
||||
import { CLIIcon, SwapIcon } from 'client/lazy-app/icons';
|
||||
import { SwapIcon } from 'client/lazy-app/icons';
|
||||
|
||||
interface Props {
|
||||
index: 0 | 1;
|
||||
@@ -29,7 +29,6 @@ interface Props {
|
||||
onEncoderOptionsChange(index: 0 | 1, newOptions: EncoderOptions): void;
|
||||
onProcessorOptionsChange(index: 0 | 1, newOptions: ProcessorState): void;
|
||||
onCopyToOtherSideClick(index: 0 | 1): void;
|
||||
onCopyCliClick(index: 0 | 1): void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -107,10 +106,6 @@ export default class Options extends Component<Props, State> {
|
||||
this.props.onEncoderOptionsChange(this.props.index, newOptions);
|
||||
};
|
||||
|
||||
private onCopyCliClick = () => {
|
||||
this.props.onCopyCliClick(this.props.index);
|
||||
};
|
||||
|
||||
private onCopyToOtherSideClick = () => {
|
||||
this.props.onCopyToOtherSideClick(this.props.index);
|
||||
};
|
||||
@@ -137,13 +132,6 @@ export default class Options extends Component<Props, State> {
|
||||
<h3 class={style.optionsTitle}>
|
||||
<div class={style.titleAndButtons}>
|
||||
Edit
|
||||
<button
|
||||
class={style.cliButton}
|
||||
title="Copy npx command"
|
||||
onClick={this.onCopyCliClick}
|
||||
>
|
||||
<CLIIcon />
|
||||
</button>
|
||||
<button
|
||||
class={style.copyOverButton}
|
||||
title="Copy settings to other side"
|
||||
|
||||
@@ -31,7 +31,6 @@ import Results from './Results';
|
||||
import WorkerBridge from '../worker-bridge';
|
||||
import { resize } from 'features/processors/resize/client';
|
||||
import type SnackBarElement from 'shared/custom-els/snack-bar';
|
||||
import { generateCliInvocation } from '../util/cli';
|
||||
import { drawableToImageData } from '../util/canvas';
|
||||
|
||||
export type OutputType = EncoderType | 'identity';
|
||||
@@ -462,29 +461,6 @@ export default class Compress extends Component<Props, State> {
|
||||
}));
|
||||
};
|
||||
|
||||
private onCopyCliClick = async (index: 0 | 1) => {
|
||||
try {
|
||||
const cliInvocation = generateCliInvocation(
|
||||
this.state.sides[index].latestSettings.encoderState!,
|
||||
this.state.sides[index].latestSettings.processorState,
|
||||
);
|
||||
await navigator.clipboard.writeText(cliInvocation);
|
||||
const result = await this.props.showSnack(
|
||||
'CLI command copied to clipboard',
|
||||
{
|
||||
timeout: 8000,
|
||||
actions: ['usage', 'dismiss'],
|
||||
},
|
||||
);
|
||||
|
||||
if (result === 'usage') {
|
||||
open('https://github.com/GoogleChromeLabs/squoosh/tree/dev/cli');
|
||||
}
|
||||
} catch (e) {
|
||||
this.props.showSnack(String(e));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Debounce the heavy lifting of updateImage.
|
||||
* Otherwise, the thrashing causes jank, and sometimes crashes iOS Safari.
|
||||
@@ -852,7 +828,6 @@ export default class Compress extends Component<Props, State> {
|
||||
onEncoderTypeChange={this.onEncoderTypeChange}
|
||||
onEncoderOptionsChange={this.onEncoderOptionsChange}
|
||||
onProcessorOptionsChange={this.onProcessorOptionsChange}
|
||||
onCopyCliClick={this.onCopyCliClick}
|
||||
onCopyToOtherSideClick={this.onCopyToOtherClick}
|
||||
/>
|
||||
));
|
||||
|
||||
@@ -92,17 +92,6 @@ export const DownloadIcon = () => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const CLIIcon = () => (
|
||||
<svg viewBox="0 0 81.3 68.8">
|
||||
<path
|
||||
fill="none"
|
||||
stroke-miterlimit="15.6"
|
||||
stroke-width="6.3"
|
||||
d="M3.1 3.1h75v62.5h-75zm18.8 43.8l12.5-12.5-12.5-12.5m18.7 25h18.8"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const SwapIcon = () => (
|
||||
<svg viewBox="0 0 18 14">
|
||||
<path d="M5.5 3.6v6.8L2.1 7l3.4-3.4M7 0L0 7l7 7V0zm4 0v14l7-7-7-7z" />
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EncoderState, ProcessorState } from '../feature-meta';
|
||||
|
||||
// Maps our encoder.type values to CLI parameter names
|
||||
const typeMap = new Map<string, string>([
|
||||
['avif', '--avif'],
|
||||
['jxl', '--jxl'],
|
||||
['mozJPEG', '--mozjpeg'],
|
||||
['oxiPNG', '--oxipng'],
|
||||
['webP', '--webp'],
|
||||
['wp2', '--wp2'],
|
||||
]);
|
||||
|
||||
// Same as JSON.stringify, but with single quotes around the entire value
|
||||
// so that shells don’t do weird stuff.
|
||||
function cliJson<T>(v: T): string {
|
||||
return "'" + JSON.stringify(v) + "'";
|
||||
}
|
||||
|
||||
export function generateCliInvocation(
|
||||
encoder: EncoderState,
|
||||
processor: ProcessorState,
|
||||
): string {
|
||||
if (!typeMap.has(encoder.type)) {
|
||||
throw Error(`Encoder ${encoder.type} is unsupported in the CLI`);
|
||||
}
|
||||
return [
|
||||
'npx',
|
||||
'@squoosh/cli',
|
||||
...(processor.resize.enabled
|
||||
? ['--resize', cliJson(processor.resize)]
|
||||
: []),
|
||||
...(processor.quantize.enabled
|
||||
? ['--quant', cliJson(processor.quantize)]
|
||||
: []),
|
||||
typeMap.get(encoder.type)!,
|
||||
cliJson(encoder.options),
|
||||
].join(' ');
|
||||
}
|
||||
Reference in New Issue
Block a user