mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
Move plugin types into d.ts
This commit is contained in:
@ -47,10 +47,7 @@ plugins: [
|
||||
*
|
||||
* @author April Arcus
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* attribute?: string | Record<string, null | string>,
|
||||
* attributes?: Array<string | Record<string, null | string>>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'addAttributesToSVGElement'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
if (!Array.isArray(params.attributes) && !params.attribute) {
|
||||
|
@ -49,10 +49,7 @@ plugins: [
|
||||
*
|
||||
* @author April Arcus
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* className?: string,
|
||||
* classNames?: Array<string>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'addClassesToSVGElement'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
if (
|
||||
|
@ -13,11 +13,7 @@ const regSpaces = /\s{2,}/g;
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* newlines?: boolean,
|
||||
* trim?: boolean,
|
||||
* spaces?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'cleanupAttrs'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const { newlines = true, trim = true, spaces = true } = params;
|
||||
|
@ -18,7 +18,7 @@ exports.description =
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'cleanupEnableBackground'>}
|
||||
*/
|
||||
exports.fn = (root) => {
|
||||
const regEnableBackground =
|
||||
|
@ -123,13 +123,7 @@ const getIdString = (arr) => {
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* remove?: boolean,
|
||||
* minify?: boolean,
|
||||
* preserve?: Array<string>,
|
||||
* preservePrefixes?: Array<string>,
|
||||
* force?: boolean,
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'cleanupIds'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -32,12 +32,7 @@ const absoluteLengths = {
|
||||
*
|
||||
* @author kiyopikko
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* floatPrecision?: number,
|
||||
* leadingZero?: boolean,
|
||||
* defaultPx?: boolean,
|
||||
* convertToPx?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'cleanupListOfValues'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -25,12 +25,7 @@ const absoluteLengths = {
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* floatPrecision?: number,
|
||||
* leadingZero?: boolean,
|
||||
* defaultPx?: boolean,
|
||||
* convertToPx?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'cleanupNumericValues'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -49,7 +49,7 @@ const hasAnimatedAttr = (node, name) => {
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'collapseGroups'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -61,13 +61,7 @@ const convertRgbToHex = ([r, g, b]) => {
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* currentColor?: boolean | string | RegExp,
|
||||
* names2hex?: boolean,
|
||||
* rgb2hex?: boolean,
|
||||
* shorthex?: boolean,
|
||||
* shortname?: boolean,
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'convertColors'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -10,7 +10,7 @@ exports.description = 'converts non-eccentric <ellipse>s to <circle>s';
|
||||
*
|
||||
* @author Taylor Hunt
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'convertEllipseToCircle'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -82,26 +82,7 @@ let arcTolerance;
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -21,10 +21,7 @@ const regNumber = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;
|
||||
*
|
||||
* @author Lev Solntsev
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* convertArcs?: boolean,
|
||||
* floatPrecision?: number
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'convertShapeToPath'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const { convertArcs = false, floatPrecision: precision } = params;
|
||||
|
@ -65,9 +65,7 @@ const regStripComments = new RegExp(
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* keepImportant?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'convertStyleToAttrs'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const { keepImportant = false } = params;
|
||||
|
@ -24,20 +24,7 @@ exports.description = 'collapses multiple transformations and optimizes it';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -63,12 +63,7 @@ const toAny = (value) => value;
|
||||
*
|
||||
* @author strarsis <strarsis@gmail.com>
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* onlyMatchedOnce?: boolean,
|
||||
* removeMatchedSelectors?: boolean,
|
||||
* useMqs?: Array<string>,
|
||||
* usePseudos?: Array<string>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'inlineStyles'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -12,11 +12,7 @@ exports.description = 'merges multiple paths in one if possible';
|
||||
*
|
||||
* @author Kir Belevich, Lev Solntsev
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* force?: boolean,
|
||||
* floatPrecision?: number,
|
||||
* noSpaceAfterFlags?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'mergePaths'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -15,7 +15,7 @@ exports.description = 'merge multiple style elements into one';
|
||||
*
|
||||
* @author strarsis <strarsis@gmail.com>
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'mergeStyles'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
/**
|
||||
|
@ -15,14 +15,7 @@ exports.description =
|
||||
*
|
||||
* @author strarsis <strarsis@gmail.com>
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (_root, { usage, ...params }) => {
|
||||
let enableTagsUsage = true;
|
||||
|
@ -26,7 +26,7 @@ exports.description = 'Move common attributes of group children to the group';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'moveElemsAttrsToGroup'>}
|
||||
*/
|
||||
exports.fn = (root) => {
|
||||
// find if any style element is present
|
||||
|
@ -23,7 +23,7 @@ const pathElemsWithGroupsAndText = [...pathElems, 'g', 'text'];
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'moveGroupAttrsToElems'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
213
plugins/plugins-types.ts
Normal file
213
plugins/plugins-types.ts
Normal file
@ -0,0 +1,213 @@
|
||||
import type * as csso from 'csso';
|
||||
import type {
|
||||
Plugin as PluginDef,
|
||||
PluginInfo,
|
||||
XastElement,
|
||||
} from '../lib/types';
|
||||
|
||||
type DefaultPlugins = {
|
||||
cleanupAttrs: {
|
||||
newlines?: boolean;
|
||||
trim?: boolean;
|
||||
spaces?: boolean;
|
||||
};
|
||||
cleanupEnableBackground: void;
|
||||
cleanupIds: {
|
||||
remove?: boolean;
|
||||
minify?: boolean;
|
||||
preserve?: Array<string>;
|
||||
preservePrefixes?: Array<string>;
|
||||
force?: boolean;
|
||||
};
|
||||
cleanupNumericValues: {
|
||||
floatPrecision?: number;
|
||||
leadingZero?: boolean;
|
||||
defaultPx?: boolean;
|
||||
convertToPx?: boolean;
|
||||
};
|
||||
collapseGroups: void;
|
||||
convertColors: {
|
||||
currentColor?: boolean | string | RegExp;
|
||||
names2hex?: boolean;
|
||||
rgb2hex?: boolean;
|
||||
shorthex?: boolean;
|
||||
shortname?: boolean;
|
||||
};
|
||||
convertEllipseToCircle: void;
|
||||
convertPathData: {
|
||||
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;
|
||||
};
|
||||
convertShapeToPath: {
|
||||
convertArcs?: boolean;
|
||||
floatPrecision?: number;
|
||||
};
|
||||
convertTransform: {
|
||||
convertToShorts?: boolean;
|
||||
degPrecision?: number;
|
||||
floatPrecision?: number;
|
||||
transformPrecision?: number;
|
||||
matrixToTransform?: boolean;
|
||||
shortTranslate?: boolean;
|
||||
shortScale?: boolean;
|
||||
shortRotate?: boolean;
|
||||
removeUseless?: boolean;
|
||||
collapseIntoOne?: boolean;
|
||||
leadingZero?: boolean;
|
||||
negativeExtraSpace?: boolean;
|
||||
};
|
||||
mergeStyles: void;
|
||||
inlineStyles: {
|
||||
onlyMatchedOnce?: boolean;
|
||||
removeMatchedSelectors?: boolean;
|
||||
useMqs?: Array<string>;
|
||||
usePseudos?: Array<string>;
|
||||
};
|
||||
mergePaths: {
|
||||
force?: boolean;
|
||||
floatPrecision?: number;
|
||||
noSpaceAfterFlags?: boolean;
|
||||
};
|
||||
minifyStyles: csso.MinifyOptions &
|
||||
Omit<csso.CompressOptions, 'usage'> & {
|
||||
usage?:
|
||||
| boolean
|
||||
| {
|
||||
force?: boolean;
|
||||
ids?: boolean;
|
||||
classes?: boolean;
|
||||
tags?: boolean;
|
||||
};
|
||||
};
|
||||
moveElemsAttrsToGroup: void;
|
||||
moveGroupAttrsToElems: void;
|
||||
removeComments: void;
|
||||
removeDesc: {
|
||||
removeAny?: boolean;
|
||||
};
|
||||
removeDoctype: void;
|
||||
removeEditorsNSData: {
|
||||
additionalNamespaces?: Array<string>;
|
||||
};
|
||||
removeEmptyAttrs: void;
|
||||
removeEmptyContainers: void;
|
||||
removeEmptyText: {
|
||||
text?: boolean;
|
||||
tspan?: boolean;
|
||||
tref?: boolean;
|
||||
};
|
||||
removeHiddenElems: {
|
||||
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;
|
||||
};
|
||||
removeMetadata: void;
|
||||
removeNonInheritableGroupAttrs: void;
|
||||
removeTitle: void;
|
||||
removeUnknownsAndDefaults: {
|
||||
unknownContent?: boolean;
|
||||
unknownAttrs?: boolean;
|
||||
defaultAttrs?: boolean;
|
||||
uselessOverrides?: boolean;
|
||||
keepDataAttrs?: boolean;
|
||||
keepAriaAttrs?: boolean;
|
||||
keepRoleAttr?: boolean;
|
||||
};
|
||||
removeUnusedNS: void;
|
||||
removeUselessDefs: void;
|
||||
removeUselessStrokeAndFill: {
|
||||
stroke?: boolean;
|
||||
fill?: boolean;
|
||||
removeNone?: boolean;
|
||||
};
|
||||
removeViewBox: void;
|
||||
removeXMLProcInst: void;
|
||||
sortAttrs: {
|
||||
order?: Array<string>;
|
||||
xmlnsOrder?: 'front' | 'alphabetical';
|
||||
};
|
||||
sortDefsChildren: void;
|
||||
};
|
||||
|
||||
type BuiltinsWithOptionalParams = DefaultPlugins & {
|
||||
cleanupListOfValues: {
|
||||
floatPrecision?: number;
|
||||
leadingZero?: boolean;
|
||||
defaultPx?: boolean;
|
||||
convertToPx?: boolean;
|
||||
};
|
||||
convertStyleToAttrs: {
|
||||
keepImportant?: boolean;
|
||||
};
|
||||
prefixIds: {
|
||||
prefix?:
|
||||
| boolean
|
||||
| string
|
||||
| ((node: XastElement, info: PluginInfo) => string);
|
||||
delim?: string;
|
||||
prefixIds?: boolean;
|
||||
prefixClassNames?: boolean;
|
||||
};
|
||||
removeDimensions: void;
|
||||
removeOffCanvasPaths: void;
|
||||
removeRasterImages: void;
|
||||
removeScriptElement: void;
|
||||
removeStyleElement: void;
|
||||
removeXMLNS: void;
|
||||
reusePaths: void;
|
||||
};
|
||||
|
||||
type BuiltinsWithRequiredParams = {
|
||||
addAttributesToSVGElement: {
|
||||
attribute?: string | Record<string, null | string>;
|
||||
attributes?: Array<string | Record<string, null | string>>;
|
||||
};
|
||||
addClassesToSVGElement: {
|
||||
className?: string;
|
||||
classNames?: Array<string>;
|
||||
};
|
||||
removeAttributesBySelector: any;
|
||||
removeAttrs: {
|
||||
elemSeparator?: string;
|
||||
preserveCurrentColor?: boolean;
|
||||
attrs: string | Array<string>;
|
||||
};
|
||||
removeElementsByAttr: {
|
||||
id?: string | Array<string>;
|
||||
class?: string | Array<string>;
|
||||
};
|
||||
};
|
||||
|
||||
type PluginsParams = BuiltinsWithOptionalParams & BuiltinsWithRequiredParams;
|
||||
|
||||
export type Plugin<Name extends keyof PluginsParams> = PluginDef<
|
||||
PluginsParams[Name]
|
||||
>;
|
@ -3,11 +3,6 @@
|
||||
const csstree = require('css-tree');
|
||||
const { referencesProps } = require('./_collections.js');
|
||||
|
||||
/**
|
||||
* @typedef {import('../lib/types').XastElement} XastElement
|
||||
* @typedef {import('../lib/types').PluginInfo} PluginInfo
|
||||
*/
|
||||
|
||||
exports.name = 'prefixIds';
|
||||
exports.description = 'prefix IDs';
|
||||
|
||||
@ -75,12 +70,7 @@ const toAny = (value) => value;
|
||||
*
|
||||
* @author strarsis <strarsis@gmail.com>
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (_root, params, info) => {
|
||||
const { delim = '__', prefixIds = true, prefixClassNames = true } = params;
|
||||
|
@ -73,7 +73,7 @@ exports.description =
|
||||
*
|
||||
* @author Bradley Mease
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<any>}
|
||||
* @type {import('./plugins-types').Plugin<'removeAttributesBySelector'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const selectors = Array.isArray(params.selectors)
|
||||
|
@ -81,11 +81,7 @@ plugins: [
|
||||
*
|
||||
* @author Benny Schudel
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* elemSeparator?: string,
|
||||
* preserveCurrentColor?: boolean,
|
||||
* attrs: string | Array<string>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeAttrs'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
if (typeof params.attrs == 'undefined') {
|
||||
|
@ -14,7 +14,7 @@ exports.description = 'removes comments';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeComments'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -16,7 +16,7 @@ const standardDescs = /^(Created with|Created using)/;
|
||||
*
|
||||
* @author Daniel Wabyick
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{ removeAny?: boolean }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeDesc'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const { removeAny = true } = params;
|
||||
|
@ -14,7 +14,7 @@ exports.description =
|
||||
*
|
||||
* @author Benny Schudel
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeDimensions'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -27,7 +27,7 @@ exports.description = 'removes doctype declaration';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeDoctype'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -16,9 +16,7 @@ exports.description = 'removes editors namespaces, elements and attributes';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* additionalNamespaces?: Array<string>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeEditorsNSData'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
let namespaces = editorNamespaces;
|
||||
|
@ -37,10 +37,7 @@ exports.description =
|
||||
*
|
||||
* @author Eli Dupuis (@elidupuis)
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* id?: string | Array<string>,
|
||||
* class?: string | Array<string>
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeElementsByAttr'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const ids =
|
||||
|
@ -10,7 +10,7 @@ exports.description = 'removes empty attributes';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeEmptyAttrs'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -19,7 +19,7 @@ exports.description = 'removes empty container elements';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeEmptyContainers'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -22,11 +22,7 @@ exports.description = 'removes empty <text> elements';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* text?: boolean,
|
||||
* tspan?: boolean,
|
||||
* tref?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeEmptyText'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const { text = true, tspan = true, tref = true } = params;
|
||||
|
@ -28,23 +28,7 @@ exports.description =
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -12,7 +12,7 @@ exports.description = 'removes <metadata>';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeMetadata'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -15,7 +15,7 @@ exports.description =
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeNonInheritableGroupAttrs'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -17,7 +17,7 @@ exports.description =
|
||||
*
|
||||
* @author JoshyPHP
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeOffCanvasPaths'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ exports.description = 'removes raster images (disabled by default)';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeRasterImages'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -12,7 +12,7 @@ exports.description = 'removes <script> elements (disabled by default)';
|
||||
*
|
||||
* @author Patrick Klingemann
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeScriptElement'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -12,7 +12,7 @@ exports.description = 'removes <style> element (disabled by default)';
|
||||
*
|
||||
* @author Betsy Dupuis
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeStyleElement'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -12,7 +12,7 @@ exports.description = 'removes <title>';
|
||||
*
|
||||
* @author Igor Kalashnikov
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeTitle'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -92,15 +92,7 @@ for (const [name, config] of Object.entries(elems)) {
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @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'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -9,7 +9,7 @@ exports.description = 'removes unused namespaces declaration';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeUnusedNS'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
/**
|
||||
|
@ -15,7 +15,7 @@ exports.description = 'removes elements in <defs> without id';
|
||||
*
|
||||
* @author Lev Solntsev
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeUselessDefs'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -12,11 +12,7 @@ exports.description = 'removes useless stroke and fill attributes';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* stroke?: boolean,
|
||||
* fill?: boolean,
|
||||
* removeNone?: boolean
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'removeUselessStrokeAndFill'>}
|
||||
*/
|
||||
exports.fn = (root, params) => {
|
||||
const {
|
||||
|
@ -17,7 +17,7 @@ const viewBoxElems = ['svg', 'pattern', 'symbol'];
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeViewBox'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -14,7 +14,7 @@ exports.description =
|
||||
*
|
||||
* @author Ricardo Tomasi
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeXMLNS'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -13,7 +13,7 @@ exports.description = 'removes XML processing instructions';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'removeXMLProcInst'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
@ -18,7 +18,7 @@ exports.description =
|
||||
*
|
||||
* @author Jacob Howcroft
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'reusePaths'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
/**
|
||||
|
@ -8,10 +8,7 @@ exports.description = 'Sort element attributes for better compression';
|
||||
*
|
||||
* @author Nikolay Frantsev
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<{
|
||||
* order?: Array<string>
|
||||
* xmlnsOrder?: 'front' | 'alphabetical'
|
||||
* }>}
|
||||
* @type {import('./plugins-types').Plugin<'sortAttrs'>}
|
||||
*/
|
||||
exports.fn = (_root, params) => {
|
||||
const {
|
||||
|
@ -9,7 +9,7 @@ exports.description = 'Sorts children of <defs> to improve compression';
|
||||
*
|
||||
* @author David Leston
|
||||
*
|
||||
* @type {import('../lib/types').Plugin<void>}
|
||||
* @type {import('./plugins-types').Plugin<'sortDefsChildren'>}
|
||||
*/
|
||||
exports.fn = () => {
|
||||
return {
|
||||
|
Reference in New Issue
Block a user