Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svgo

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgo - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

plugins/plugins-types.ts

113

lib/svgo.d.ts
import type { StringifyOptions, DataUri, Plugin as PluginFn } from './types';
import type {
BuiltinsWithOptionalParams,
BuiltinsWithRequiredParams,
} from '../plugins/plugins-types';
type PluginDef = {
name: string;
fn: PluginFn<unknown>;
};
type Usage<T extends PluginDef> = {
name: T['name'];
params?: Parameters<T['fn']>[1];
};
type UsageReqParams<T extends PluginDef> = {
name: T['name'];
params: Parameters<T['fn']>[1];
};
type CustomPlugin = {

@@ -23,84 +12,16 @@ name: string;

type DefaultPlugin =
| Usage<typeof import('../plugins/cleanupAttrs.js')>
| Usage<typeof import('../plugins/cleanupEnableBackground.js')>
| Usage<typeof import('../plugins/cleanupIds.js')>
| Usage<typeof import('../plugins/cleanupNumericValues.js')>
| Usage<typeof import('../plugins/collapseGroups.js')>
| Usage<typeof import('../plugins/convertColors.js')>
| Usage<typeof import('../plugins/convertEllipseToCircle.js')>
| Usage<typeof import('../plugins/convertPathData.js')>
| Usage<typeof import('../plugins/convertShapeToPath.js')>
| Usage<typeof import('../plugins/convertTransform.js')>
| Usage<typeof import('../plugins/mergeStyles.js')>
| Usage<typeof import('../plugins/inlineStyles.js')>
| Usage<typeof import('../plugins/mergePaths.js')>
| Usage<typeof import('../plugins/minifyStyles.js')>
| Usage<typeof import('../plugins/moveElemsAttrsToGroup.js')>
| Usage<typeof import('../plugins/moveGroupAttrsToElems.js')>
| Usage<typeof import('../plugins/removeComments.js')>
| Usage<typeof import('../plugins/removeDesc.js')>
| Usage<typeof import('../plugins/removeDoctype.js')>
| Usage<typeof import('../plugins/removeEditorsNSData.js')>
| Usage<typeof import('../plugins/removeEmptyAttrs.js')>
| Usage<typeof import('../plugins/removeEmptyContainers.js')>
| Usage<typeof import('../plugins/removeEmptyText.js')>
| Usage<typeof import('../plugins/removeHiddenElems.js')>
| Usage<typeof import('../plugins/removeMetadata.js')>
| Usage<typeof import('../plugins/removeNonInheritableGroupAttrs.js')>
| Usage<typeof import('../plugins/removeTitle.js')>
| Usage<typeof import('../plugins/removeUnknownsAndDefaults.js')>
| Usage<typeof import('../plugins/removeUnusedNS.js')>
| Usage<typeof import('../plugins/removeUselessDefs.js')>
| Usage<typeof import('../plugins/removeUselessStrokeAndFill.js')>
| Usage<typeof import('../plugins/removeViewBox.js')>
| Usage<typeof import('../plugins/removeXMLProcInst.js')>
| Usage<typeof import('../plugins/sortAttrs.js')>
| Usage<typeof import('../plugins/sortDefsChildren.js')>;
type Overrides<T = DefaultPlugin> = T extends DefaultPlugin
? { [key in T['name']]?: T['params'] | false }
: never;
type PresetDefault = {
name: 'preset-default';
params?: {
floatPrecision?: number;
/**
* All default plugins can be customized or disabled here
* for example
* {
* sortAttrs: { xmlnsOrder: "alphabetical" },
* cleanupAttrs: false,
* }
*/
overrides?: Overrides;
};
};
type BuiltinPluginWithOptionalParams =
| DefaultPlugin
| PresetDefault
| Usage<typeof import('../plugins/cleanupListOfValues.js')>
| Usage<typeof import('../plugins/convertStyleToAttrs.js')>
| Usage<typeof import('../plugins/prefixIds.js')>
| Usage<typeof import('../plugins/removeDimensions.js')>
| Usage<typeof import('../plugins/removeOffCanvasPaths.js')>
| Usage<typeof import('../plugins/removeRasterImages.js')>
| Usage<typeof import('../plugins/removeScriptElement.js')>
| Usage<typeof import('../plugins/removeStyleElement.js')>
| Usage<typeof import('../plugins/removeXMLNS.js')>
| Usage<typeof import('../plugins/reusePaths.js')>;
type BuiltinPluginWithRequiredParams =
| UsageReqParams<typeof import('../plugins/addAttributesToSVGElement.js')>
| UsageReqParams<typeof import('../plugins/addClassesToSVGElement.js')>
| UsageReqParams<typeof import('../plugins/removeAttributesBySelector.js')>
| UsageReqParams<typeof import('../plugins/removeAttrs.js')>
| UsageReqParams<typeof import('../plugins/removeElementsByAttr.js')>;
type PluginConfig =
| BuiltinPluginWithOptionalParams['name']
| BuiltinPluginWithOptionalParams
| BuiltinPluginWithRequiredParams
| keyof BuiltinsWithOptionalParams
| {
[Name in keyof BuiltinsWithOptionalParams]: {
name: Name;
params?: BuiltinsWithOptionalParams[Name];
};
}[keyof BuiltinsWithOptionalParams]
| {
[Name in keyof BuiltinsWithRequiredParams]: {
name: Name;
params: BuiltinsWithRequiredParams[Name];
};
}[keyof BuiltinsWithRequiredParams]
| CustomPlugin;

@@ -107,0 +28,0 @@

{
"packageManager": "yarn@2.4.3",
"name": "svgo",
"version": "3.0.0",
"version": "3.0.1",
"description": "Nodejs-based tool for optimizing SVG vector graphics files",

@@ -117,3 +117,2 @@ "license": "MIT",

"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^14.1.0",

@@ -120,0 +119,0 @@ "@types/css-tree": "^1.0.7",

@@ -50,6 +50,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* attribute?: string | Record<string, null | string>,
* attributes?: Array<string | Record<string, null | string>>
* }>}
* @type {import('./plugins-types').Plugin<'addAttributesToSVGElement'>}
*/

@@ -56,0 +53,0 @@ exports.fn = (root, params) => {

@@ -52,6 +52,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* className?: string,
* classNames?: Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'addClassesToSVGElement'>}
*/

@@ -58,0 +55,0 @@ exports.fn = (root, params) => {

@@ -16,7 +16,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* newlines?: boolean,
* trim?: boolean,
* spaces?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'cleanupAttrs'>}
*/

@@ -23,0 +19,0 @@ exports.fn = (root, params) => {

@@ -21,3 +21,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'cleanupEnableBackground'>}
*/

@@ -24,0 +24,0 @@ exports.fn = (root) => {

@@ -13,5 +13,5 @@ 'use strict';

const regReferencesUrl = /\burl\(("|')?#(.+?)\1\)/;
const regReferencesUrl = /\burl\((["'])?#(.+?)\1\)/;
const regReferencesHref = /^#(.+?)$/;
const regReferencesBegin = /(\w+)\./;
const regReferencesBegin = /(\D+)\./;
const generateIdChars = [

@@ -127,9 +127,3 @@ 'a',

*
* @type {import('../lib/types').Plugin<{
* remove?: boolean,
* minify?: boolean,
* preserve?: Array<string>,
* preservePrefixes?: Array<string>,
* force?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'cleanupIds'>}
*/

@@ -136,0 +130,0 @@ exports.fn = (_root, params) => {

@@ -35,8 +35,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* floatPrecision?: number,
* leadingZero?: boolean,
* defaultPx?: boolean,
* convertToPx?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'cleanupListOfValues'>}
*/

@@ -43,0 +38,0 @@ exports.fn = (_root, params) => {

@@ -28,8 +28,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* floatPrecision?: number,
* leadingZero?: boolean,
* defaultPx?: boolean,
* convertToPx?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'cleanupNumericValues'>}
*/

@@ -36,0 +31,0 @@ exports.fn = (_root, params) => {

@@ -52,3 +52,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'collapseGroups'>}
*/

@@ -55,0 +55,0 @@ exports.fn = () => {

@@ -64,9 +64,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* currentColor?: boolean | string | RegExp,
* names2hex?: boolean,
* rgb2hex?: boolean,
* shorthex?: boolean,
* shortname?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'convertColors'>}
*/

@@ -73,0 +67,0 @@ exports.fn = (_root, params) => {

@@ -13,3 +13,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'convertEllipseToCircle'>}
*/

@@ -16,0 +16,0 @@ exports.fn = () => {

@@ -85,22 +85,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* applyTransforms?: boolean,
* applyTransformsStroked?: boolean,
* makeArcs?: {
* threshold: number,
* tolerance: number,
* },
* straightCurves?: boolean,
* lineShorthands?: boolean,
* curveSmoothShorthands?: boolean,
* floatPrecision?: number | false,
* transformPrecision?: number,
* removeUseless?: boolean,
* collapseRepeated?: boolean,
* utilizeAbsolute?: boolean,
* leadingZero?: boolean,
* negativeExtraSpace?: boolean,
* noSpaceAfterFlags?: boolean,
* forceAbsolutePath?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'convertPathData'>}
*/

@@ -107,0 +88,0 @@ exports.fn = (root, params) => {

@@ -24,6 +24,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* convertArcs?: boolean,
* floatPrecision?: number
* }>}
* @type {import('./plugins-types').Plugin<'convertShapeToPath'>}
*/

@@ -30,0 +27,0 @@ exports.fn = (root, params) => {

@@ -68,5 +68,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* keepImportant?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'convertStyleToAttrs'>}
*/

@@ -73,0 +71,0 @@ exports.fn = (_root, params) => {

@@ -27,16 +27,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* convertToShorts?: boolean,
* degPrecision?: number,
* floatPrecision?: number,
* transformPrecision?: number,
* matrixToTransform?: boolean,
* shortTranslate?: boolean,
* shortScale?: boolean,
* shortRotate?: boolean,
* removeUseless?: boolean,
* collapseIntoOne?: boolean,
* leadingZero?: boolean,
* negativeExtraSpace?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'convertTransform'>}
*/

@@ -43,0 +30,0 @@ exports.fn = (_root, params) => {

@@ -66,8 +66,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* onlyMatchedOnce?: boolean,
* removeMatchedSelectors?: boolean,
* useMqs?: Array<string>,
* usePseudos?: Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'inlineStyles'>}
*/

@@ -74,0 +69,0 @@ exports.fn = (root, params) => {

@@ -15,7 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* force?: boolean,
* floatPrecision?: number,
* noSpaceAfterFlags?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'mergePaths'>}
*/

@@ -22,0 +18,0 @@ exports.fn = (root, params) => {

@@ -18,3 +18,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'mergeStyles'>}
*/

@@ -21,0 +21,0 @@ exports.fn = () => {

@@ -18,10 +18,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<csso.MinifyOptions & Omit<csso.CompressOptions, 'usage'> & {
* usage?: boolean | {
* force?: boolean,
* ids?: boolean,
* classes?: boolean,
* tags?: boolean
* }
* }>}
* @type {import('./plugins-types').Plugin<'minifyStyles'>}
*/

@@ -28,0 +21,0 @@ exports.fn = (_root, { usage, ...params }) => {

@@ -29,3 +29,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'moveElemsAttrsToGroup'>}
*/

@@ -32,0 +32,0 @@ exports.fn = (root) => {

@@ -26,3 +26,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'moveGroupAttrsToElems'>}
*/

@@ -29,0 +29,0 @@ exports.fn = () => {

@@ -6,7 +6,2 @@ 'use strict';

/**
* @typedef {import('../lib/types').XastElement} XastElement
* @typedef {import('../lib/types').PluginInfo} PluginInfo
*/
exports.name = 'prefixIds';

@@ -79,8 +74,3 @@ exports.description = 'prefix IDs';

*
* @type {import('../lib/types').Plugin<{
* prefix?: boolean | string | ((node: XastElement, info: PluginInfo) => string),
* delim?: string,
* prefixIds?: boolean,
* prefixClassNames?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'prefixIds'>}
*/

@@ -87,0 +77,0 @@ exports.fn = (_root, params, info) => {

@@ -76,3 +76,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<any>}
* @type {import('./plugins-types').Plugin<'removeAttributesBySelector'>}
*/

@@ -79,0 +79,0 @@ exports.fn = (root, params) => {

@@ -84,7 +84,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* elemSeparator?: string,
* preserveCurrentColor?: boolean,
* attrs: string | Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'removeAttrs'>}
*/

@@ -91,0 +87,0 @@ exports.fn = (root, params) => {

@@ -17,3 +17,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeComments'>}
*/

@@ -20,0 +20,0 @@ exports.fn = () => {

@@ -19,3 +19,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{ removeAny?: boolean }>}
* @type {import('./plugins-types').Plugin<'removeDesc'>}
*/

@@ -22,0 +22,0 @@ exports.fn = (root, params) => {

@@ -17,3 +17,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeDimensions'>}
*/

@@ -20,0 +20,0 @@ exports.fn = () => {

@@ -30,3 +30,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeDoctype'>}
*/

@@ -33,0 +33,0 @@ exports.fn = () => {

@@ -19,5 +19,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* additionalNamespaces?: Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'removeEditorsNSData'>}
*/

@@ -24,0 +22,0 @@ exports.fn = (_root, params) => {

@@ -40,6 +40,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* id?: string | Array<string>,
* class?: string | Array<string>
* }>}
* @type {import('./plugins-types').Plugin<'removeElementsByAttr'>}
*/

@@ -46,0 +43,0 @@ exports.fn = (root, params) => {

@@ -13,3 +13,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeEmptyAttrs'>}
*/

@@ -16,0 +16,0 @@ exports.fn = () => {

@@ -22,3 +22,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeEmptyContainers'>}
*/

@@ -25,0 +25,0 @@ exports.fn = () => {

@@ -25,7 +25,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* text?: boolean,
* tspan?: boolean,
* tref?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'removeEmptyText'>}
*/

@@ -32,0 +28,0 @@ exports.fn = (root, params) => {

@@ -31,19 +31,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* isHidden: boolean,
* displayNone: boolean,
* opacity0: boolean,
* circleR0: boolean,
* ellipseRX0: boolean,
* ellipseRY0: boolean,
* rectWidth0: boolean,
* rectHeight0: boolean,
* patternWidth0: boolean,
* patternHeight0: boolean,
* imageWidth0: boolean,
* imageHeight0: boolean,
* pathEmptyD: boolean,
* polylineEmptyPoints: boolean,
* polygonEmptyPoints: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'removeHiddenElems'>}
*/

@@ -50,0 +34,0 @@ exports.fn = (root, params) => {

@@ -15,3 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeMetadata'>}
*/

@@ -18,0 +18,0 @@ exports.fn = () => {

@@ -18,3 +18,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeNonInheritableGroupAttrs'>}
*/

@@ -21,0 +21,0 @@ exports.fn = () => {

@@ -20,3 +20,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeOffCanvasPaths'>}
*/

@@ -23,0 +23,0 @@ exports.fn = () => {

@@ -15,3 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeRasterImages'>}
*/

@@ -18,0 +18,0 @@ exports.fn = () => {

@@ -15,3 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeScriptElement'>}
*/

@@ -18,0 +18,0 @@ exports.fn = () => {

@@ -15,3 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeStyleElement'>}
*/

@@ -18,0 +18,0 @@ exports.fn = () => {

@@ -15,3 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeTitle'>}
*/

@@ -18,0 +18,0 @@ exports.fn = () => {

@@ -95,11 +95,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* unknownContent?: boolean,
* unknownAttrs?: boolean,
* defaultAttrs?: boolean,
* uselessOverrides?: boolean,
* keepDataAttrs?: boolean,
* keepAriaAttrs?: boolean,
* keepRoleAttr?: boolean,
* }>}
* @type {import('./plugins-types').Plugin<'removeUnknownsAndDefaults'>}
*/

@@ -106,0 +98,0 @@ exports.fn = (root, params) => {

@@ -12,3 +12,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeUnusedNS'>}
*/

@@ -15,0 +15,0 @@ exports.fn = () => {

@@ -18,3 +18,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeUselessDefs'>}
*/

@@ -21,0 +21,0 @@ exports.fn = () => {

@@ -15,7 +15,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* stroke?: boolean,
* fill?: boolean,
* removeNone?: boolean
* }>}
* @type {import('./plugins-types').Plugin<'removeUselessStrokeAndFill'>}
*/

@@ -22,0 +18,0 @@ exports.fn = (root, params) => {

@@ -20,3 +20,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeViewBox'>}
*/

@@ -23,0 +23,0 @@ exports.fn = () => {

@@ -17,3 +17,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeXMLNS'>}
*/

@@ -20,0 +20,0 @@ exports.fn = () => {

@@ -16,3 +16,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'removeXMLProcInst'>}
*/

@@ -19,0 +19,0 @@ exports.fn = () => {

@@ -21,3 +21,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'reusePaths'>}
*/

@@ -24,0 +24,0 @@ exports.fn = () => {

@@ -11,6 +11,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<{
* order?: Array<string>
* xmlnsOrder?: 'front' | 'alphabetical'
* }>}
* @type {import('./plugins-types').Plugin<'sortAttrs'>}
*/

@@ -17,0 +14,0 @@ exports.fn = (_root, params) => {

@@ -12,3 +12,3 @@ 'use strict';

*
* @type {import('../lib/types').Plugin<void>}
* @type {import('./plugins-types').Plugin<'sortDefsChildren'>}
*/

@@ -15,0 +15,0 @@ exports.fn = () => {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc