diff --git a/index.d.ts b/index.d.ts index 570ae17..5d02775 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,58 +1,58 @@ -export interface Options { // eslint-disable-line @typescript-eslint/consistent-type-definitions +type Options = { /** - Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level. - - Values: `1` (brute-force) to `11` (fastest) - - @default 3 - */ + * Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level. + * Values: `1` (brute-force) to `11` (fastest) + * @default 3 + */ speed?: number; /** - Remove optional metadata. - - @default false - */ + * Remove optional metadata. + * @default false + */ strip?: boolean; /** - Instructs pngquant to use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved. - - Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG. - - Values: `[0...1, 0...1]` - - @example [0.3, 0.5] - */ + * Instructs pngquant to use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved. + * Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG. + * Values: `[0...1, 0...1]` + * @example [0.3, 0.5] + */ quality?: [number, number]; /** - Set the dithering level using a fractional number between 0 (none) and 1 (full). - - Pass in `false` to disable dithering. - - Values: 0...1 - - @default 1 - */ + * Set the dithering level using a fractional number between 0 (none) and 1 (full). + * Pass in `false` to disable dithering. + * Values: 0...1 + * @default 1 + */ dithering?: number | boolean; /** - Truncate number of least significant bits of color (per channel). - - Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors. - */ + * Truncate number of least significant bits of color (per channel). + * Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors. + */ posterize?: number; -} + + /** + * Print verbose status messages. + * @default false + */ + verbose?: boolean; +}; /** -Image data to optimize. -*/ -export type Plugin = (input: Uint8Array) => Promise; + * Buffer or stream to optimize. + * @info Banned type Buffer has been replaced in Imagemin >=8.0.1 with Uint8Array, must stick to it. + * @see https://sindresorhus.com/blog/goodbye-nodejs-buffer [@typescript-eslint/ban-types] + * @see https://github.com/imagemin/imagemin/compare/v8.0.1...main + */ +type Plugin = (input: Uint8Array | NodeJS.ReadableStream) => Promise; /** -Imagemin plugin for pngquant. + * Imagemin plugin for pngquant. + * @returns An Imagemin plugin. + */ +declare function imageminPngquant(options?: Options): Plugin; -@returns An Imagemin plugin. -*/ -export default function imageminPngquant(options?: Options): Plugin; +export {type Options, type Plugin, imageminPngquant}; diff --git a/package.json b/package.json index a57c3b3..a6e9356 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "imagemin-pngquant", - "version": "10.0.0", + "version": "11.0.0", "description": "Imagemin plugin for `pngquant`", "license": "MIT", "repository": "imagemin/imagemin-pngquant", @@ -37,6 +37,9 @@ "pngquant-bin": "^9.0.0", "uint8array-extras": "^1.1.0" }, + "peerDependencies": { + "imagemin": "^8.0.1" + }, "devDependencies": { "@types/node": "^20.12.10", "ava": "^6.1.3", diff --git a/readme.md b/readme.md index 879f2df..e1a434f 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ npm install imagemin-pngquant ### Prerequisites -> **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev` +> **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev` ```sh sudo apt-get -y install libpng-dev libimagequant-dev @@ -20,7 +20,7 @@ sudo apt-get -y install libpng-dev libimagequant-dev ```js import imagemin from 'imagemin'; -import imageminPngquant from 'imagemin-pngquant'; +import { imageminPngquant } from 'imagemin-pngquant'; await imagemin(['images/*.png'], { destination: 'build/images',