+26
-3
@@ -143,3 +143,3 @@ import fs from 'fs'; | ||
| !opts.folder && | ||
| process.stdin.isTTY === true | ||
| process.stdin.isTTY | ||
| ) { | ||
@@ -528,8 +528,31 @@ return command.help(); | ||
| /** Show list of available plugins with short description. */ | ||
| /** | ||
| * Show list of available plugins with short description with the presets it belongs to. | ||
| */ | ||
| function showAvailablePlugins() { | ||
| const pluginToPresetsMap = new Map(); | ||
| for (const plugin of builtinPlugins) { | ||
| if (plugin.isPreset) { | ||
| for (const presetPlugins of plugin.plugins) { | ||
| if (!pluginToPresetsMap.has(presetPlugins.name)) { | ||
| pluginToPresetsMap.set(presetPlugins.name, [plugin.name]); | ||
| } else { | ||
| pluginToPresetsMap.get(presetPlugins.name).push(plugin.name); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| const list = builtinPlugins | ||
| .map((plugin) => ` [ ${colors.green(plugin.name)} ] ${plugin.description}`) | ||
| .map((plugin) => { | ||
| const name = plugin.name; | ||
| let description = plugin.description || ''; | ||
| const presetsForThisPlugin = pluginToPresetsMap.get(name) || []; | ||
| if (presetsForThisPlugin && presetsForThisPlugin.length > 0) { | ||
| description += ` (${presetsForThisPlugin.join(', ')})`; | ||
| } | ||
| return ` [ ${colors.green(name)} ] ${description}`; | ||
| }) | ||
| .join('\n'); | ||
| console.log('Currently available plugins:\n' + list); | ||
| } |
@@ -36,3 +36,3 @@ import { visit } from '../util/visit.js'; | ||
| /** | ||
| * @template {string} T | ||
| * @template {`preset-${string}`} T | ||
| * @param {{ name: T, plugins: ReadonlyArray<import('../types.js').BuiltinPlugin<string, any>> }} arg0 | ||
@@ -39,0 +39,0 @@ * @returns {import('../types.js').BuiltinPluginOrPreset<T, any>} |
@@ -148,2 +148,10 @@ import { attrsGroups, referencesProps } from '../../plugins/_collections.js'; | ||
| const hasScriptsEventAttrs = [ | ||
| ...attrsGroups.animationEvent, | ||
| ...attrsGroups.documentEvent, | ||
| ...attrsGroups.documentElementEvent, | ||
| ...attrsGroups.globalEvent, | ||
| ...attrsGroups.graphicalEvent, | ||
| ]; | ||
| /** | ||
@@ -174,11 +182,3 @@ * If the current node contains any scripts. This does not check parents or | ||
| const eventAttrs = [ | ||
| ...attrsGroups.animationEvent, | ||
| ...attrsGroups.documentEvent, | ||
| ...attrsGroups.documentElementEvent, | ||
| ...attrsGroups.globalEvent, | ||
| ...attrsGroups.graphicalEvent, | ||
| ]; | ||
| return eventAttrs.some((attr) => node.attributes[attr] != null); | ||
| return hasScriptsEventAttrs.some((attr) => node.attributes[attr] != null); | ||
| }; | ||
@@ -185,0 +185,0 @@ |
+16
-8
@@ -139,15 +139,23 @@ import { AddAttributesToSVGElementParams } from '../plugins/addAttributesToSVGElement.js'; | ||
| export type BuiltinPluginOrPreset<Name extends string, Params> = BuiltinPlugin< | ||
| Name, | ||
| Params | ||
| > & { | ||
| type PresetProperties<IsPreset extends boolean> = { | ||
| name: IsPreset extends true ? `preset-${string}` : string; | ||
| /** If the plugin is itself a preset that invokes other plugins. */ | ||
| isPreset?: true; | ||
| isPreset: IsPreset extends true ? true : undefined; | ||
| /** | ||
| * If the plugin is a preset that invokes other plugins, this returns an | ||
| * array of the plugins in the preset in the order that they are invoked. | ||
| * If {@link #isPreset} is true, an array of the plugins in the preset | ||
| * in the order that they are invoked. | ||
| */ | ||
| plugins?: ReadonlyArray<BuiltinPlugin<string, Object>>; | ||
| plugins: IsPreset extends true | ||
| ? ReadonlyArray<BuiltinPlugin<string, Object>> | ||
| : undefined; | ||
| }; | ||
| export type BuiltinPluginOrPreset<Name extends string, Params> = BuiltinPlugin< | ||
| Name, | ||
| Params | ||
| > & | ||
| (PresetProperties<true> | Partial<PresetProperties<false>>); | ||
| export type XastDoctype = { | ||
@@ -154,0 +162,0 @@ type: 'doctype'; |
+1
-1
@@ -7,2 +7,2 @@ /** | ||
| */ | ||
| export const VERSION = '4.0.0'; | ||
| export const VERSION = '4.0.1'; |
+8
-5
| { | ||
| "packageManager": "yarn@3.8.7", | ||
| "name": "svgo", | ||
| "version": "4.0.0", | ||
| "version": "4.0.1", | ||
| "description": "SVGO is a Node.js library and command-line application for optimizing vector images.", | ||
@@ -86,3 +86,3 @@ "license": "MIT", | ||
| "test:types": "yarn build:types && tsc && tsd", | ||
| "test:regression": "node ./test/regression-extract.js && cross-env NO_DIFF=1 node ./test/regression.js", | ||
| "test:regression": "node ./test/regression/extract.js && node ./test/regression/optimize.js && cross-env NO_DIFF=1 node ./test/regression/compare.js", | ||
| "qa": "yarn lint && yarn test:types && yarn test && yarn test:bundles && yarn test:regression", | ||
@@ -92,2 +92,3 @@ "clean": "yarn clean:build && yarn clean:types", | ||
| "clean:types": "rimraf types", | ||
| "spellcheck": "cspell -u .", | ||
| "prepublishOnly": "yarn clean && yarn build" | ||
@@ -112,3 +113,3 @@ }, | ||
| "picocolors": "^1.1.1", | ||
| "sax": "^1.4.1" | ||
| "sax": "^1.5.0" | ||
| }, | ||
@@ -125,5 +126,7 @@ "devDependencies": { | ||
| "@types/node": "^22.15.3", | ||
| "@types/pngjs": "^6.0.5", | ||
| "@types/sax": "^1.2.7", | ||
| "@types/tar-stream": "^3.1.3", | ||
| "cross-env": "^7.0.3", | ||
| "cspell": "^9.2.2", | ||
| "eslint": "^9.25.1", | ||
@@ -133,3 +136,3 @@ "globals": "^14.0.0", | ||
| "pixelmatch": "^7.1.0", | ||
| "playwright": "^1.52.0", | ||
| "playwright": "1.53.2", | ||
| "pngjs": "^7.0.0", | ||
@@ -144,4 +147,4 @@ "prettier": "^3.5.3", | ||
| "resolutions": { | ||
| "sax@^1.4.1": "patch:sax@npm%3A1.4.1#./.yarn/patches/sax-npm-1.4.1-503b1923cb.patch" | ||
| "sax@^1.5.0": "patch:sax@npm%3A1.5.0#./.yarn/patches/sax-npm-1.5.0-d40bca2226.patch" | ||
| } | ||
| } |
@@ -109,3 +109,3 @@ /** | ||
| * | ||
| * @see https://developer.mozilla.org/docs/Web/HTML/Element/pre | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre | ||
| * @type {Readonly<Set<string>>} | ||
@@ -2399,3 +2399,3 @@ */ | ||
| * @type {Readonly<Record<string, Set<string>>>} | ||
| * @see https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes | ||
| */ | ||
@@ -2402,0 +2402,0 @@ export const pseudoClasses = { |
@@ -47,4 +47,6 @@ import { removeLeadingZero } from '../lib/svgo/tools.js'; | ||
| if (node.attributes.viewBox != null) { | ||
| const nums = node.attributes.viewBox.trim().split(/(?:\s,?|,)\s*/g); | ||
| node.attributes.viewBox = nums | ||
| const numbers = node.attributes.viewBox | ||
| .trim() | ||
| .split(/(?:\s,?|,)\s*/g); | ||
| node.attributes.viewBox = numbers | ||
| .map((value) => { | ||
@@ -51,0 +53,0 @@ const num = Number(value); |
@@ -126,3 +126,3 @@ import { colorsNames, colorsProps, colorsShortNames } from './_collections.js'; | ||
| if (match != null) { | ||
| const nums = match.slice(1, 4).map((m) => { | ||
| const numbers = match.slice(1, 4).map((m) => { | ||
| let n; | ||
@@ -136,3 +136,3 @@ if (m.indexOf('%') > -1) { | ||
| }); | ||
| val = convertRgbToHex(nums); | ||
| val = convertRgbToHex(numbers); | ||
| } | ||
@@ -139,0 +139,0 @@ } |
@@ -18,4 +18,4 @@ import { attrsGroupsDefaults, colorsProps } from './_collections.js'; | ||
| * @type {import('../lib/types.js').Plugin} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/linearGradient | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/radialGradient | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient | ||
| */ | ||
@@ -22,0 +22,0 @@ export const fn = (root) => { |
@@ -233,4 +233,3 @@ import { js2path, path2js } from './_path.js'; | ||
| start[1] = cursor[1]; | ||
| } | ||
| if (command === 'M') { | ||
| } else if (command === 'M') { | ||
| // M → m | ||
@@ -251,7 +250,6 @@ // skip first moveto | ||
| // lineto (x y) | ||
| if (command === 'l') { | ||
| else if (command === 'l') { | ||
| cursor[0] += args[0]; | ||
| cursor[1] += args[1]; | ||
| } | ||
| if (command === 'L') { | ||
| } else if (command === 'L') { | ||
| // L → l | ||
@@ -266,6 +264,5 @@ command = 'l'; | ||
| // horizontal lineto (x) | ||
| if (command === 'h') { | ||
| else if (command === 'h') { | ||
| cursor[0] += args[0]; | ||
| } | ||
| if (command === 'H') { | ||
| } else if (command === 'H') { | ||
| // H → h | ||
@@ -278,6 +275,5 @@ command = 'h'; | ||
| // vertical lineto (y) | ||
| if (command === 'v') { | ||
| else if (command === 'v') { | ||
| cursor[1] += args[0]; | ||
| } | ||
| if (command === 'V') { | ||
| } else if (command === 'V') { | ||
| // V → v | ||
@@ -290,7 +286,6 @@ command = 'v'; | ||
| // curveto (x1 y1 x2 y2 x y) | ||
| if (command === 'c') { | ||
| else if (command === 'c') { | ||
| cursor[0] += args[4]; | ||
| cursor[1] += args[5]; | ||
| } | ||
| if (command === 'C') { | ||
| } else if (command === 'C') { | ||
| // C → c | ||
@@ -309,7 +304,6 @@ command = 'c'; | ||
| // smooth curveto (x2 y2 x y) | ||
| if (command === 's') { | ||
| else if (command === 's') { | ||
| cursor[0] += args[2]; | ||
| cursor[1] += args[3]; | ||
| } | ||
| if (command === 'S') { | ||
| } else if (command === 'S') { | ||
| // S → s | ||
@@ -326,7 +320,6 @@ command = 's'; | ||
| // quadratic Bézier curveto (x1 y1 x y) | ||
| if (command === 'q') { | ||
| else if (command === 'q') { | ||
| cursor[0] += args[2]; | ||
| cursor[1] += args[3]; | ||
| } | ||
| if (command === 'Q') { | ||
| } else if (command === 'Q') { | ||
| // Q → q | ||
@@ -343,7 +336,6 @@ command = 'q'; | ||
| // smooth quadratic Bézier curveto (x y) | ||
| if (command === 't') { | ||
| else if (command === 't') { | ||
| cursor[0] += args[0]; | ||
| cursor[1] += args[1]; | ||
| } | ||
| if (command === 'T') { | ||
| } else if (command === 'T') { | ||
| // T → t | ||
@@ -358,7 +350,6 @@ command = 't'; | ||
| // elliptical arc (rx ry x-axis-rotation large-arc-flag sweep-flag x y) | ||
| if (command === 'a') { | ||
| else if (command === 'a') { | ||
| cursor[0] += args[5]; | ||
| cursor[1] += args[6]; | ||
| } | ||
| if (command === 'A') { | ||
| } else if (command === 'A') { | ||
| // A → a | ||
@@ -373,3 +364,3 @@ command = 'a'; | ||
| // closepath | ||
| if (command === 'Z' || command === 'z') { | ||
| else if (command === 'Z' || command === 'z') { | ||
| // reset cursor | ||
@@ -376,0 +367,0 @@ cursor[0] = start[0]; |
@@ -32,3 +32,3 @@ import * as csstree from 'css-tree'; | ||
| * | ||
| * @see https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes | ||
| */ | ||
@@ -35,0 +35,0 @@ const preservedPseudos = [ |
@@ -70,3 +70,3 @@ import { querySelectorAll } from '../lib/xast.js'; | ||
| * | ||
| * @link https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors|MDN CSS Selectors | ||
| * @link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|MDN CSS Selectors | ||
| * | ||
@@ -73,0 +73,0 @@ * @author Bradley Mease |
@@ -20,3 +20,3 @@ import { detachNodeFromParent } from '../lib/xast.js'; | ||
| * @author Daniel Wabyick | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/desc | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc | ||
| * | ||
@@ -23,0 +23,0 @@ * @type {import('../lib/types.js').Plugin<RemoveDescParams>} |
@@ -10,4 +10,3 @@ import { detachNodeFromParent } from '../lib/xast.js'; | ||
| export const name = 'removeElementsByAttr'; | ||
| export const description = | ||
| 'removes arbitrary elements by ID or className (disabled by default)'; | ||
| export const description = 'removes arbitrary elements by ID or className'; | ||
@@ -14,0 +13,0 @@ /** |
| import { elemsGroups } from './_collections.js'; | ||
| import { detachNodeFromParent } from '../lib/xast.js'; | ||
| import { collectStylesheet, computeStyle } from '../lib/style.js'; | ||
| import { findReferences } from '../lib/svgo/tools.js'; | ||
@@ -25,5 +26,29 @@ export const name = 'removeEmptyContainers'; | ||
| const stylesheet = collectStylesheet(root); | ||
| const removedIds = new Set(); | ||
| /** | ||
| * @type {Map<string, { | ||
| * node: import('../lib/types.js').XastElement, | ||
| * parent: import('../lib/types.js').XastParent, | ||
| * }[]>} | ||
| */ | ||
| const usesById = new Map(); | ||
| return { | ||
| element: { | ||
| enter: (node, parentNode) => { | ||
| if (node.name === 'use') { | ||
| // Record uses so those referencing empty containers can be removed. | ||
| for (const [name, value] of Object.entries(node.attributes)) { | ||
| const ids = findReferences(name, value); | ||
| for (const id of ids) { | ||
| let references = usesById.get(id); | ||
| if (references === undefined) { | ||
| references = []; | ||
| usesById.set(id, references); | ||
| } | ||
| references.push({ node: node, parent: parentNode }); | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| exit: (node, parentNode) => { | ||
@@ -65,5 +90,21 @@ // remove only empty non-svg containers | ||
| detachNodeFromParent(node, parentNode); | ||
| if (node.attributes.id) { | ||
| removedIds.add(node.attributes.id); | ||
| } | ||
| }, | ||
| }, | ||
| root: { | ||
| exit: () => { | ||
| // Remove any <use> elements that referenced an empty container. | ||
| for (const id of removedIds) { | ||
| const uses = usesById.get(id); | ||
| if (uses) { | ||
| for (const use of uses) { | ||
| detachNodeFromParent(use.node, use.parent); | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
@@ -193,34 +193,2 @@ import { elemsGroups } from './_collections.js'; | ||
| // Removes hidden elements | ||
| // https://www.w3schools.com/cssref/pr_class_visibility.asp | ||
| const computedStyle = computeStyle(stylesheet, node); | ||
| if ( | ||
| isHidden && | ||
| computedStyle.visibility && | ||
| computedStyle.visibility.type === 'static' && | ||
| computedStyle.visibility.value === 'hidden' && | ||
| // keep if any descendant enables visibility | ||
| querySelector(node, '[visibility=visible]') == null | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // display="none" | ||
| // | ||
| // https://www.w3.org/TR/SVG11/painting.html#DisplayProperty | ||
| // "A value of display: none indicates that the given element | ||
| // and its children shall not be rendered directly" | ||
| if ( | ||
| displayNone && | ||
| computedStyle.display && | ||
| computedStyle.display.type === 'static' && | ||
| computedStyle.display.value === 'none' && | ||
| // markers with display: none still rendered | ||
| node.name !== 'marker' | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // Circles with zero radius | ||
@@ -367,28 +335,2 @@ // | ||
| // Path with empty data | ||
| // | ||
| // https://www.w3.org/TR/SVG11/paths.html#DAttribute | ||
| // | ||
| // <path d=""/> | ||
| if (pathEmptyD && node.name === 'path') { | ||
| if (node.attributes.d == null) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| const pathData = parsePathData(node.attributes.d); | ||
| if (pathData.length === 0) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // keep single point paths for markers | ||
| if ( | ||
| pathData.length === 1 && | ||
| computedStyle['marker-start'] == null && | ||
| computedStyle['marker-end'] == null | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| } | ||
| // Polyline with empty points | ||
@@ -422,2 +364,60 @@ // | ||
| // Removes hidden elements | ||
| // https://www.w3schools.com/cssref/pr_class_visibility.asp | ||
| const computedStyle = computeStyle(stylesheet, node); | ||
| if ( | ||
| isHidden && | ||
| computedStyle.visibility && | ||
| computedStyle.visibility.type === 'static' && | ||
| computedStyle.visibility.value === 'hidden' && | ||
| // keep if any descendant enables visibility | ||
| querySelector(node, '[visibility=visible]') == null | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // display="none" | ||
| // | ||
| // https://www.w3.org/TR/SVG11/painting.html#DisplayProperty | ||
| // "A value of display: none indicates that the given element | ||
| // and its children shall not be rendered directly" | ||
| if ( | ||
| displayNone && | ||
| computedStyle.display && | ||
| computedStyle.display.type === 'static' && | ||
| computedStyle.display.value === 'none' && | ||
| // markers with display: none still rendered | ||
| node.name !== 'marker' | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // Path with empty data | ||
| // | ||
| // https://www.w3.org/TR/SVG11/paths.html#DAttribute | ||
| // | ||
| // <path d=""/> | ||
| if (pathEmptyD && node.name === 'path') { | ||
| if (node.attributes.d == null) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| const pathData = parsePathData(node.attributes.d); | ||
| if (pathData.length === 0) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| // keep single point paths for markers | ||
| if ( | ||
| pathData.length === 1 && | ||
| computedStyle['marker-start'] == null && | ||
| computedStyle['marker-end'] == null | ||
| ) { | ||
| removeElement(node, parentNode); | ||
| return; | ||
| } | ||
| } | ||
| for (const [name, value] of Object.entries(node.attributes)) { | ||
@@ -424,0 +424,0 @@ const ids = findReferences(name, value); |
@@ -8,3 +8,3 @@ import { detachNodeFromParent } from '../lib/xast.js'; | ||
| export const description = | ||
| 'removes elements that are drawn outside of the viewBox (disabled by default)'; | ||
| 'removes elements that are drawn outside of the viewBox'; | ||
@@ -11,0 +11,0 @@ /** |
| import { detachNodeFromParent } from '../lib/xast.js'; | ||
| export const name = 'removeRasterImages'; | ||
| export const description = 'removes raster images (disabled by default)'; | ||
| export const description = 'removes raster images'; | ||
@@ -6,0 +6,0 @@ /** |
@@ -5,3 +5,3 @@ import { attrsGroups } from './_collections.js'; | ||
| export const name = 'removeScripts'; | ||
| export const description = 'removes scripts (disabled by default)'; | ||
| export const description = 'removes scripts'; | ||
@@ -8,0 +8,0 @@ /** Union of all event attributes. */ |
| import { detachNodeFromParent } from '../lib/xast.js'; | ||
| export const name = 'removeStyleElement'; | ||
| export const description = 'removes <style> element (disabled by default)'; | ||
| export const description = 'removes <style> element'; | ||
@@ -6,0 +6,0 @@ /** |
@@ -9,3 +9,3 @@ import { detachNodeFromParent } from '../lib/xast.js'; | ||
| * | ||
| * https://developer.mozilla.org/docs/Web/SVG/Element/title | ||
| * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title | ||
| * | ||
@@ -12,0 +12,0 @@ * @author Igor Kalashnikov |
@@ -10,3 +10,7 @@ import { | ||
| import { visitSkip } from '../lib/util/visit.js'; | ||
| import { collectStylesheet, computeStyle } from '../lib/style.js'; | ||
| import { | ||
| collectStylesheet, | ||
| computeStyle, | ||
| includesAttrSelector, | ||
| } from '../lib/style.js'; | ||
@@ -196,3 +200,8 @@ /** | ||
| // keep defaults if parent has own or inherited style | ||
| if (computedParentStyle?.[name] == null) { | ||
| if ( | ||
| computedParentStyle?.[name] == null && | ||
| !stylesheet.rules.some((rule) => | ||
| includesAttrSelector(rule.selector, name), | ||
| ) | ||
| ) { | ||
| delete node.attributes[name]; | ||
@@ -199,0 +208,0 @@ } |
@@ -34,8 +34,8 @@ export const name = 'removeViewBox'; | ||
| } | ||
| const nums = node.attributes.viewBox.split(/[ ,]+/g); | ||
| const numbers = node.attributes.viewBox.split(/[ ,]+/g); | ||
| if ( | ||
| nums[0] === '0' && | ||
| nums[1] === '0' && | ||
| node.attributes.width.replace(/px$/, '') === nums[2] && // could use parseFloat too | ||
| node.attributes.height.replace(/px$/, '') === nums[3] | ||
| numbers[0] === '0' && | ||
| numbers[1] === '0' && | ||
| node.attributes.width.replace(/px$/, '') === numbers[2] && // could use parseFloat too | ||
| node.attributes.height.replace(/px$/, '') === numbers[3] | ||
| ) { | ||
@@ -42,0 +42,0 @@ delete node.attributes.viewBox; |
@@ -21,3 +21,3 @@ import { elems } from './_collections.js'; | ||
| * @type {Record<string, string>} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Attribute/xlink:show#usage_notes | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:show#usage_notes | ||
| */ | ||
@@ -34,4 +34,4 @@ const SHOW_TO_TARGET = { | ||
| * @type {Set<string>} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Attribute/xlink:href | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Attribute/href | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/href | ||
| */ | ||
@@ -65,3 +65,3 @@ const LEGACY_ELEMENTS = new Set([ | ||
| * @type {import('../lib/types.js').Plugin<RemoveXlinkParams>} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Attribute/xlink:href | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href | ||
| */ | ||
@@ -68,0 +68,0 @@ export const fn = (_, params) => { |
| export const name = 'removeXMLNS'; | ||
| export const description = | ||
| 'removes xmlns attribute (for inline svg, disabled by default)'; | ||
| export const description = 'removes xmlns attribute (for inline svg)'; | ||
@@ -5,0 +4,0 @@ /** |
@@ -29,3 +29,3 @@ import { collectStylesheet } from '../lib/style.js'; | ||
| * @type {import('../lib/types.js').XastElement} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/defs | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs | ||
| */ | ||
@@ -32,0 +32,0 @@ let svgDefs; |
| export function invokePlugins(ast: import("../types.js").XastNode, info: any, plugins: ReadonlyArray<any>, overrides: any, globalOverrides: any): void; | ||
| export function createPreset<T extends string>({ name, plugins }: { | ||
| export function createPreset<T extends `preset-${string}`>({ name, plugins }: { | ||
| name: T; | ||
| plugins: ReadonlyArray<import("../types.js").BuiltinPlugin<string, any>>; | ||
| }): import("../types.js").BuiltinPluginOrPreset<T, any>; |
@@ -125,11 +125,13 @@ import { AddAttributesToSVGElementParams } from '../plugins/addAttributesToSVGElement.js'; | ||
| }; | ||
| export type BuiltinPluginOrPreset<Name extends string, Params> = BuiltinPlugin<Name, Params> & { | ||
| type PresetProperties<IsPreset extends boolean> = { | ||
| name: IsPreset extends true ? `preset-${string}` : string; | ||
| /** If the plugin is itself a preset that invokes other plugins. */ | ||
| isPreset?: true; | ||
| isPreset: IsPreset extends true ? true : undefined; | ||
| /** | ||
| * If the plugin is a preset that invokes other plugins, this returns an | ||
| * array of the plugins in the preset in the order that they are invoked. | ||
| * If {@link #isPreset} is true, an array of the plugins in the preset | ||
| * in the order that they are invoked. | ||
| */ | ||
| plugins?: ReadonlyArray<BuiltinPlugin<string, Object>>; | ||
| plugins: IsPreset extends true ? ReadonlyArray<BuiltinPlugin<string, Object>> : undefined; | ||
| }; | ||
| export type BuiltinPluginOrPreset<Name extends string, Params> = BuiltinPlugin<Name, Params> & (PresetProperties<true> | Partial<PresetProperties<false>>); | ||
| export type XastDoctype = { | ||
@@ -277,1 +279,2 @@ type: 'doctype'; | ||
| }; | ||
| export {}; |
@@ -12,3 +12,3 @@ /** | ||
| * | ||
| * @see https://developer.mozilla.org/docs/Web/HTML/Element/pre | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre | ||
| * @type {Readonly<Set<string>>} | ||
@@ -98,4 +98,4 @@ */ | ||
| * @type {Readonly<Record<string, Set<string>>>} | ||
| * @see https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes | ||
| */ | ||
| export const pseudoClasses: Readonly<Record<string, Set<string>>>; |
@@ -8,5 +8,5 @@ export const name: "convertOneStopGradients"; | ||
| * @type {import('../lib/types.js').Plugin} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/linearGradient | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/radialGradient | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient | ||
| */ | ||
| export const fn: import("../lib/types.js").Plugin; |
@@ -66,3 +66,3 @@ export const name: "removeAttributesBySelector"; | ||
| * | ||
| * @link https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors|MDN CSS Selectors | ||
| * @link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|MDN CSS Selectors | ||
| * | ||
@@ -69,0 +69,0 @@ * @author Bradley Mease |
@@ -14,3 +14,3 @@ /** | ||
| * @author Daniel Wabyick | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Element/desc | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc | ||
| * | ||
@@ -17,0 +17,0 @@ * @type {import('../lib/types.js').Plugin<RemoveDescParams>} |
@@ -7,3 +7,3 @@ /** | ||
| export const name: "removeElementsByAttr"; | ||
| export const description: "removes arbitrary elements by ID or className (disabled by default)"; | ||
| export const description: "removes arbitrary elements by ID or className"; | ||
| /** | ||
@@ -10,0 +10,0 @@ * Remove arbitrary SVG elements by ID or className. |
| export const name: "removeOffCanvasPaths"; | ||
| export const description: "removes elements that are drawn outside of the viewBox (disabled by default)"; | ||
| export const description: "removes elements that are drawn outside of the viewBox"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Remove elements that are drawn outside of the viewBox. |
| export const name: "removeRasterImages"; | ||
| export const description: "removes raster images (disabled by default)"; | ||
| export const description: "removes raster images"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Remove raster images references in <image>. |
| export const name: "removeScripts"; | ||
| export const description: "removes scripts (disabled by default)"; | ||
| export const description: "removes scripts"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Remove scripts. |
| export const name: "removeStyleElement"; | ||
| export const description: "removes <style> element (disabled by default)"; | ||
| export const description: "removes <style> element"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Remove <style>. |
@@ -6,3 +6,3 @@ export const name: "removeTitle"; | ||
| * | ||
| * https://developer.mozilla.org/docs/Web/SVG/Element/title | ||
| * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title | ||
| * | ||
@@ -9,0 +9,0 @@ * @author Igor Kalashnikov |
@@ -16,3 +16,3 @@ /** | ||
| * @type {import('../lib/types.js').Plugin<RemoveXlinkParams>} | ||
| * @see https://developer.mozilla.org/docs/Web/SVG/Attribute/xlink:href | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href | ||
| */ | ||
@@ -19,0 +19,0 @@ export const fn: import("../lib/types.js").Plugin<RemoveXlinkParams>; |
| export const name: "removeXMLNS"; | ||
| export const description: "removes xmlns attribute (for inline svg, disabled by default)"; | ||
| export const description: "removes xmlns attribute (for inline svg)"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Remove the xmlns attribute when present. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1451473
0.33%27559
0.35%26
8.33%Updated