astro-icon
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -0,1 +1,2 @@ | ||
import { SPRITESHEET_NAMESPACE } from "./constants"; | ||
import { Props, Optimize } from "./Props"; | ||
@@ -23,3 +24,7 @@ import getFromService from "./resolver"; | ||
function optimizeSvg(contents: string, options: Optimize): string { | ||
function optimizeSvg( | ||
contents: string, | ||
name: string, | ||
options: Optimize | ||
): string { | ||
return optimizeSVGNative(contents, { | ||
@@ -36,3 +41,6 @@ plugins: [ | ||
"convertStyleToAttrs", | ||
"cleanupIDs", | ||
{ | ||
name: "cleanupIDs", | ||
params: { prefix: `${SPRITESHEET_NAMESPACE}:${name}` }, | ||
}, | ||
"removeRasterImages", | ||
@@ -71,3 +79,3 @@ "removeUselessDefs", | ||
const preprocessCache = new Map(); | ||
export function preprocess(contents: string, { optimize }) { | ||
export function preprocess(contents: string, name: string, { optimize }) { | ||
if (preprocessCache.has(contents)) { | ||
@@ -77,3 +85,3 @@ return preprocessCache.get(contents); | ||
if (optimize) { | ||
contents = optimizeSvg(contents, optimize); | ||
contents = optimizeSvg(contents, name, optimize); | ||
} | ||
@@ -128,2 +136,3 @@ domParserTokenizer.lastIndex = 0; | ||
) { | ||
const key = name; | ||
if (!name) { | ||
@@ -191,3 +200,3 @@ throw new Error("<Icon> requires a name!"); | ||
const { innerHTML, defaultProps } = preprocess(svg, { optimize }); | ||
const { innerHTML, defaultProps } = preprocess(svg, key, { optimize }); | ||
@@ -194,0 +203,0 @@ if (!innerHTML.trim()) { |
{ | ||
"name": "astro-icon", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28546
646