/var/www/flurhymez/node_modules/svgo/plugins
NameSizeModeActions
addAttributesToSVGElement.js20660644editdlrm
addClassesToSVGElement.js18330644editdlrm
cleanupAttrs.js14570644editdlrm
cleanupEnableBackground.js20140644editdlrm
cleanupIDs.js71450644editdlrm
cleanupListOfValues.js39960644editdlrm
cleanupNumericValues.js29560644editdlrm
collapseGroups.js39260644editdlrm
convertColors.js42220644editdlrm
convertEllipseToCircle.js9380644editdlrm
convertPathData.js283890644editdlrm
convertShapeToPath.js59830644editdlrm
convertStyleToAttrs.js38280644editdlrm
convertTransform.js116960644editdlrm
inlineStyles.js121820644editdlrm
mergePaths.js29940644editdlrm
mergeStyles.js23800644editdlrm
minifyStyles.js43890644editdlrm
moveElemsAttrsToGroup.js37410644editdlrm
moveGroupAttrsToElems.js17120644editdlrm
plugins.js32240644editdlrm
prefixIds.js65850644editdlrm
preset-default.js29900644editdlrm
removeAttributesBySelector.js24430644editdlrm
removeAttrs.js41910644editdlrm
removeComments.js6340644editdlrm
removeDesc.js10750644editdlrm
removeDimensions.js12270644editdlrm
removeDoctype.js11330644editdlrm
removeEditorsNSData.js20220644editdlrm
removeElementsByAttr.js21390644editdlrm
removeEmptyAttrs.js7770644editdlrm
removeEmptyContainers.js14910644editdlrm
removeEmptyText.js13890644editdlrm
removeHiddenElems.js92890644editdlrm
removeMetadata.js5660644editdlrm
removeNonInheritableGroupAttrs.js9250644editdlrm
removeOffCanvasPaths.js39670644editdlrm
removeRasterImages.js7750644editdlrm
removeScriptElement.js6010644editdlrm
removeStyleElement.js6040644editdlrm
removeTitle.js5790644editdlrm
removeUnknownsAndDefaults.js63460644editdlrm
removeUnusedNS.js18480644editdlrm
removeUselessDefs.js17240644editdlrm
removeUselessStrokeAndFill.js43590644editdlrm
removeViewBox.js14020644editdlrm
removeXMLNS.js6660644editdlrm
removeXMLProcInst.js6100644editdlrm
reusePaths.js33790644editdlrm
sortAttrs.js27220644editdlrm
sortDefsChildren.js18330644editdlrm
_applyTransforms.js98240644editdlrm
_collections.js444760644editdlrm
_path.js213580644editdlrm
_transforms.js107690644editdlrm
Edit: /var/www/flurhymez/node_modules/svgo/plugins/reusePaths.js (3379B)
'use strict'; /** * @typedef {import('../lib/types').XastElement} XastElement * @typedef {import('../lib/types').XastParent} XastParent * @typedef {import('../lib/types').XastNode} XastNode */ const JSAPI = require('../lib/svgo/jsAPI.js'); exports.type = 'visitor'; exports.name = 'reusePaths'; exports.active = false; exports.description = 'Finds elements with the same d, fill, and ' + 'stroke, and converts them to elements ' + 'referencing a single def.'; /** * Finds elements with the same d, fill, and stroke, and converts them to * elements referencing a single def. * * @author Jacob Howcroft * * @type {import('../lib/types').Plugin} */ exports.fn = () => { /** * @type {Map>} */ const paths = new Map(); return { element: { enter: (node) => { if (node.name === 'path' && node.attributes.d != null) { const d = node.attributes.d; const fill = node.attributes.fill || ''; const stroke = node.attributes.stroke || ''; const key = d + ';s:' + stroke + ';f:' + fill; let list = paths.get(key); if (list == null) { list = []; paths.set(key, list); } list.push(node); } }, exit: (node, parentNode) => { if (node.name === 'svg' && parentNode.type === 'root') { /** * @type {XastElement} */ const rawDefs = { type: 'element', name: 'defs', attributes: {}, children: [], }; /** * @type {XastElement} */ const defsTag = new JSAPI(rawDefs, node); let index = 0; for (const list of paths.values()) { if (list.length > 1) { // add reusable path to defs /** * @type {XastElement} */ const rawPath = { type: 'element', name: 'path', attributes: { ...list[0].attributes }, children: [], }; delete rawPath.attributes.transform; let id; if (rawPath.attributes.id == null) { id = 'reuse-' + index; index += 1; rawPath.attributes.id = id; } else { id = rawPath.attributes.id; delete list[0].attributes.id; } /** * @type {XastElement} */ const reusablePath = new JSAPI(rawPath, defsTag); defsTag.children.push(reusablePath); // convert paths to for (const pathNode of list) { pathNode.name = 'use'; pathNode.attributes['xlink:href'] = '#' + id; delete pathNode.attributes.d; delete pathNode.attributes.stroke; delete pathNode.attributes.fill; } } } if (defsTag.children.length !== 0) { if (node.attributes['xmlns:xlink'] == null) { node.attributes['xmlns:xlink'] = 'http://www.w3.org/1999/xlink'; } node.children.unshift(defsTag); } } }, }, }; };