/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/removeOffCanvasPaths.js (3967B)
'use strict'; /** * @typedef {import('../lib/types').PathDataItem} PathDataItem */ const { visitSkip, detachNodeFromParent } = require('../lib/xast.js'); const { parsePathData } = require('../lib/path.js'); const { intersects } = require('./_path.js'); exports.type = 'visitor'; exports.name = 'removeOffCanvasPaths'; exports.active = false; exports.description = 'removes elements that are drawn outside of the viewbox (disabled by default)'; /** * Remove elements that are drawn outside of the viewbox. * * @author JoshyPHP * * @type {import('../lib/types').Plugin} */ exports.fn = () => { /** * @type {null | { * top: number, * right: number, * bottom: number, * left: number, * width: number, * height: number * }} */ let viewBoxData = null; return { element: { enter: (node, parentNode) => { if (node.name === 'svg' && parentNode.type === 'root') { let viewBox = ''; // find viewbox if (node.attributes.viewBox != null) { // remove commas and plus signs, normalize and trim whitespace viewBox = node.attributes.viewBox; } else if ( node.attributes.height != null && node.attributes.width != null ) { viewBox = `0 0 ${node.attributes.width} ${node.attributes.height}`; } // parse viewbox // remove commas and plus signs, normalize and trim whitespace viewBox = viewBox .replace(/[,+]|px/g, ' ') .replace(/\s+/g, ' ') .replace(/^\s*|\s*$/g, ''); // ensure that the dimensions are 4 values separated by space const m = /^(-?\d*\.?\d+) (-?\d*\.?\d+) (\d*\.?\d+) (\d*\.?\d+)$/.exec( viewBox ); if (m == null) { return; } const left = Number.parseFloat(m[1]); const top = Number.parseFloat(m[2]); const width = Number.parseFloat(m[3]); const height = Number.parseFloat(m[4]); // store the viewBox boundaries viewBoxData = { left, top, right: left + width, bottom: top + height, width, height, }; } // consider that any item with a transform attribute is visible if (node.attributes.transform != null) { return visitSkip; } if ( node.name === 'path' && node.attributes.d != null && viewBoxData != null ) { const pathData = parsePathData(node.attributes.d); // consider that a M command within the viewBox is visible let visible = false; for (const pathDataItem of pathData) { if (pathDataItem.command === 'M') { const [x, y] = pathDataItem.args; if ( x >= viewBoxData.left && x <= viewBoxData.right && y >= viewBoxData.top && y <= viewBoxData.bottom ) { visible = true; } } } if (visible) { return; } if (pathData.length === 2) { // close the path too short for intersects() pathData.push({ command: 'z', args: [] }); } const { left, top, width, height } = viewBoxData; /** * @type {Array} */ const viewBoxPathData = [ { command: 'M', args: [left, top] }, { command: 'h', args: [width] }, { command: 'v', args: [height] }, { command: 'H', args: [left] }, { command: 'z', args: [] }, ]; if (intersects(viewBoxPathData, pathData) === false) { detachNodeFromParent(node, parentNode); } } }, }, }; };