svgfusion-core
Version:
Core engine and utilities for SVGFusion - the foundation library that powers SVG to component conversion.
52 lines (43 loc) • 20.3 kB
JavaScript
import {svgToComponentName}from'svgfusion-utils';export{extractColors,extractColorsWithElementMapping,generateColorProps,generateDefaultColors,replaceColorsWithProps,replaceCurrentColorWithVariables}from'svgfusion-utils';var k=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var f=class{parse(t){let r=this.cleanSvgContent(t),e=this.parseElement(r);return {root:e,viewBox:e.attributes.viewBox,width:e.attributes.width,height:e.attributes.height,namespace:e.attributes.xmlns}}extractColors(t){let r=[];return this.traverseElements(t.root,e=>{e.attributes.fill&&this.isValidColor(e.attributes.fill)&&r.push({value:e.attributes.fill,type:"fill",element:e,attribute:"fill"}),e.attributes.stroke&&this.isValidColor(e.attributes.stroke)&&r.push({value:e.attributes.stroke,type:"stroke",element:e,attribute:"stroke"}),e.attributes["stop-color"]&&this.isValidColor(e.attributes["stop-color"])&&r.push({value:e.attributes["stop-color"],type:"stop-color",element:e,attribute:"stop-color"});}),r}cleanSvgContent(t){return t.replace(/<\?xml[^>]*\?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()}parseElement(t){if(typeof DOMParser<"u"){let e=new DOMParser().parseFromString(t,"image/svg+xml");if(e.querySelector("parsererror"))throw new Error("Invalid SVG: XML parsing failed");let o=e.documentElement;if(o.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(o)}try{let e=(typeof k<"u"?k:function(){throw new Error("require not available")}())("jsdom"),{JSDOM:s}=e,i=new s(t,{contentType:"image/svg+xml"}).window.document.documentElement;if(i.tagName.toLowerCase()!=="svg")throw new Error("Invalid SVG: No svg element found");return this.convertDOMToSVGElement(i)}catch{return this.parseElementWithRegex(t)}}convertDOMToSVGElement(t){let r={tag:this.preserveSvgTagCase(t.tagName),attributes:{},children:[]};for(let e=0;e<t.attributes.length;e++){let s=t.attributes[e];r.attributes[s.name]=s.value;}for(let e=0;e<t.children.length;e++){let s=t.children[e];r.children.push(this.convertDOMToSVGElement(s));}return t.children.length===0&&t.textContent?.trim()&&(r.content=t.textContent.trim()),r}parseElementWithRegex(t){let r=t.match(/<svg([^>]*)>/i);if(!r)throw new Error("Invalid SVG: No svg element found");let e=this.parseAttributes(r[1]),s=this.parseChildren(t);return {tag:"svg",attributes:e,children:s}}parseAttributes(t){let r={},e=/(\w+(?:-\w+)*)=["']([^"']*)["']/g,s;for(;(s=e.exec(t))!==null;)r[s[1]]=s[2];return r}parseChildren(t){let r=[],e=t.match(/<svg[^>]*>(.*)<\/svg>/is);if(!e||!e[1])return r;let s=e[1],o=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,i;for(;(i=o.exec(s))!==null;){let[,a,c,l]=i,p=this.parseAttributes(c),u={tag:a,attributes:p,children:[]};l!==void 0&&(l.includes("<")?u.children=this.parseNestedElements(l):l.trim()&&(u.content=l.trim())),r.push(u);}return r}parseNestedElements(t){let r=[],e=/<(\w+(?::\w+)?)([^>]*?)(?:\s*\/\s*>|>(.*?)<\/\1\s*>)/gs,s;for(;(s=e.exec(t))!==null;){let[,o,i,a]=s,c=this.parseAttributes(i),l={tag:o,attributes:c,children:[]};a!==void 0&&(a.includes("<")?l.children=this.parseNestedElements(a):a.trim()&&(l.content=a.trim())),r.push(l);}return r}traverseElements(t,r){r(t),t.children.forEach(e=>this.traverseElements(e,r));}preserveSvgTagCase(t){let r=t.toLowerCase();return {clippath:"clipPath",defs:"defs",foreignobject:"foreignObject",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath",use:"use"}[r]||r}isValidColor(t){return !t||t==="none"||t==="transparent"||t==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(t)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)?true:["red","green","blue","black","white","yellow","cyan","magenta"].includes(t.toLowerCase())}};var g=class{options;constructor(t={}){this.options={preserveOriginalNames:t.preserveOriginalNames??false,generateClasses:t.generateClasses??true,colorPrefix:t.colorPrefix??"color"};}extractColors(t){let r=[];this.traverseElement(t,r);let e=new Map;return r.forEach(s=>{this.isValidColor(s.value)&&e.set(s.value,s);}),Array.from(e.values()).sort((s,o)=>s.value.localeCompare(o.value))}apply(t){let r=this.extractColors(t),e=this.generateColorMappings(r),s=this.replaceColorsWithVariables(t,e);return {mappings:e,processedElement:s,originalColors:r.map(o=>o.value)}}generateColorMappings(t){return t.map((r,e)=>({originalColor:r.value,variableName:e===0?this.options.colorPrefix:`${this.options.colorPrefix}${e+1}`,type:r.type}))}replaceColorsWithVariables(t,r){let e=new Map(r.map(s=>[s.originalColor,s.variableName]));return this.transformElement(t,s=>{let o={...s.attributes};if(o.fill&&e.has(o.fill)&&(o.fill=`{${e.get(o.fill)}}`),o.stroke&&e.has(o.stroke)&&(o.stroke=`{${e.get(o.stroke)}}`),o["stop-color"]&&e.has(o["stop-color"])&&(o["stop-color"]=`{${e.get(o["stop-color"])}}`),o.style){let i=o.style,a=i.match(/fill:\s*([^;]+)/);if(a){let p=a[1].trim();e.has(p)&&(i=i.replace(/fill:\s*[^;]+/,`fill: {${e.get(p)}}`));}let c=i.match(/stroke:\s*([^;]+)/);if(c){let p=c[1].trim();e.has(p)&&(i=i.replace(/stroke:\s*[^;]+/,`stroke: {${e.get(p)}}`));}let l=i.match(/stop-color:\s*([^;]+)/);if(l){let p=l[1].trim();e.has(p)&&(i=i.replace(/stop-color:\s*[^;]+/,`stop-color: {${e.get(p)}}`));}o.style=i;}if(this.isDrawableElement(s.tag)){let i=s.attributes.fill!==void 0&&s.attributes.fill!=="",a=s.attributes.stroke!==void 0&&s.attributes.stroke!=="";i&&!a&&!o.stroke&&(o.stroke="none"),a&&!i&&!o.fill&&(o.fill="none");}return {...s,attributes:o}})}traverseElement(t,r){t.attributes.fill&&r.push({value:t.attributes.fill,type:"fill",element:t,attribute:"fill"}),t.attributes.stroke&&r.push({value:t.attributes.stroke,type:"stroke",element:t,attribute:"stroke"}),t.attributes["stop-color"]&&r.push({value:t.attributes["stop-color"],type:"stop-color",element:t,attribute:"stop-color"}),t.attributes.style&&this.extractColorsFromStyle(t.attributes.style).forEach(s=>{r.push({value:s.value,type:s.type,element:t,attribute:"style"});}),t.children.forEach(e=>this.traverseElement(e,r));}transformElement(t,r){let e=r(t);return {...e,children:e.children.map(s=>this.transformElement(s,r))}}isDrawableElement(t){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(t)}isValidColor(t){return !t||t==="none"||t==="transparent"||t==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(t)||/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)||/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)?true:["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy"].includes(t.toLowerCase())}extractColorsFromStyle(t){let r=[],e=t.match(/fill:\s*([^;]+)/);if(e){let i=e[1].trim();this.isValidColor(i)&&r.push({value:i,type:"fill"});}let s=t.match(/stroke:\s*([^;]+)/);if(s){let i=s[1].trim();this.isValidColor(i)&&r.push({value:i,type:"stroke"});}let o=t.match(/stop-color:\s*([^;]+)/);if(o){let i=o[1].trim();this.isValidColor(i)&&r.push({value:i,type:"stop-color"});}return r}};var S=class{options;constructor(t={}){this.options={preserveExisting:t.preserveExisting??true,onlyIfStrokePresent:t.onlyIfStrokePresent??true};}apply(t){let r=0;return {processedElement:this.transformElement(t,s=>this.shouldAddVectorEffect(s)?(r++,{...s,attributes:{...s.attributes,"vector-effect":"non-scaling-stroke"}}):s),elementsModified:r}}shouldAddVectorEffect(t){return this.options.preserveExisting&&t.attributes["vector-effect"]?false:["path","line","polyline","polygon","rect","circle","ellipse"].includes(t.tag)}transformElement(t,r){let e=r(t);return {...e,children:e.children.map(s=>this.transformElement(s,r))}}};var v=class{options;constructor(t={}){this.options={preserveOriginalNames:t.preserveOriginalNames??false,strokeWidthPrefix:t.strokeWidthPrefix??"strokeWidth",generateClasses:t.generateClasses??true};}extractStrokeWidths(t){let r=[];this.traverseElement(t,r);let e=new Map;return r.forEach(s=>{this.isValidStrokeWidth(s.value)&&e.set(s.value,s);}),Array.from(e.values()).sort((s,o)=>{let i=parseFloat(s.value),a=parseFloat(o.value);return isNaN(i)&&isNaN(a)?s.value.localeCompare(o.value):isNaN(i)?1:isNaN(a)?-1:i-a})}apply(t){let r=this.extractStrokeWidths(t),e=this.generateStrokeWidthMappings(r),s=this.replaceStrokeWidthsWithVariables(t,e);return {mappings:e,processedElement:s,originalStrokeWidths:r.map(o=>o.value)}}traverseElement(t,r){if(t.attributes["stroke-width"]&&r.push({value:t.attributes["stroke-width"],element:t,attribute:"stroke-width"}),t.attributes.style){let e=this.extractStrokeWidthFromStyle(t.attributes.style);e&&r.push({value:e,element:t,attribute:"style",styleProperty:"stroke-width"});}t.children.forEach(e=>this.traverseElement(e,r));}extractStrokeWidthFromStyle(t){let r=t.match(/stroke-width\s*:\s*([^;]+)/);return r?r[1].trim():null}isValidStrokeWidth(t){return t==="inherit"||t==="none"||t==="initial"||t==="unset"||t.includes("var(")||t.includes("calc(")?false:/^[\d.]+(?:px|pt|pc|in|cm|mm|em|rem|ex|ch|vw|vh|vmin|vmax|%)?$/.test(t.trim())}generateStrokeWidthMappings(t){return t.map((r,e)=>({originalStrokeWidth:r.value,variableName:e===0?this.options.strokeWidthPrefix:`${this.options.strokeWidthPrefix}${e+1}`}))}replaceStrokeWidthsWithVariables(t,r){let e=new Map(r.map(s=>[s.originalStrokeWidth,s.variableName]));return this.transformElement(t,s=>{let o={...s.attributes};if(o["stroke-width"]&&e.has(o["stroke-width"])&&(o["stroke-width"]=`{${e.get(o["stroke-width"])}}`),o.style){let i=o.style;e.forEach((a,c)=>{let l=new RegExp(`stroke-width\\s*:\\s*${this.escapeRegExp(c)}`,"g");i=i.replace(l,`stroke-width: {${a}}`);}),o.style=i;}return {...s,attributes:o}})}transformElement(t,r){let e=r(t);return {...e,children:e.children.map(s=>this.transformElement(s,r))}}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var b=class{options;constructor(t={}){this.options={addRole:t.addRole??true,addAriaHidden:t.addAriaHidden??false,addTitle:t.addTitle??true,addDesc:t.addDesc??true,defaultRole:t.defaultRole??"img",preserveExisting:t.preserveExisting??true};}apply(t){let r=[];if(t.tag!=="svg")return {processedElement:t,attributesAdded:r};let e={...t.attributes};return this.options.addRole&&(!this.options.preserveExisting||!e.role)&&(e.role=this.options.defaultRole,r.push("role")),this.options.addAriaHidden&&(!this.options.preserveExisting||!e["aria-hidden"])&&(e["aria-hidden"]="true",r.push("aria-hidden")),this.options.addTitle&&r.push("title-support"),this.options.addDesc&&r.push("desc-support"),this.options.addTitle&&this.options.addDesc&&(!this.options.preserveExisting||!e["aria-labelledby"])?(e["aria-labelledby"]="{titleId} {descId}",r.push("aria-labelledby")):this.options.addTitle&&(!this.options.preserveExisting||!e["aria-labelledby"])&&(e["aria-labelledby"]="{titleId}",r.push("aria-labelledby")),{processedElement:{...t,attributes:e},attributesAdded:r}}generateProps(){let t=[];return this.options.addTitle&&t.push("title?: string","titleId?: string"),this.options.addDesc&&t.push("desc?: string","descId?: string"),t}generateJSXElements(t){let r=[];return t==="react"?(this.options.addDesc&&r.push("{desc ? <desc id={descId}>{desc}</desc> : null}"),this.options.addTitle&&r.push("{title ? <title id={titleId}>{title}</title> : null}")):(this.options.addDesc&&r.push('<desc v-if="desc" :id="descId">{{ desc }}</desc>'),this.options.addTitle&&r.push('<title v-if="title" :id="titleId">{{ title }}</title>')),r.join(`
`)}};var E=class{constructor(t){this.options=t;}apply(t){return this.options.enabled?this.normalizeElements(t):t}normalizeElements(t){return t.map(r=>this.transformElement(r,e=>{let s={...e.attributes};if(this.isDrawableElement(e.tag)){let o=e.attributes.fill!==void 0&&e.attributes.fill!=="",i=e.attributes.stroke!==void 0&&e.attributes.stroke!=="";o&&!i&&(s.stroke="none"),i&&!o&&(s.fill="none");}return {...e,attributes:s}}))}transformElement(t,r){let e=r(t);return e.children&&(e.children=e.children.map(s=>this.transformElement(s,r))),e}isDrawableElement(t){return ["path","circle","ellipse","line","rect","polygon","polyline","text","tspan","use"].includes(t)}};var h=class{transform(t,r={}){let{optimize:e=true,splitColors:s=false,splitStrokeWidths:o=false,fixedStrokeWidth:i=false,normalizeFillStroke:a=false,accessibility:c=true,removeComments:l=true,removeDuplicates:p=true,minifyPaths:u=false}=r,d=this.deepCloneAst(t),m=[],x=[],y=[];return e&&(this.applyOptimizations(d,{removeComments:l,removeDuplicates:p,minifyPaths:u&&!s}),m.push("optimization")),s&&(x=this.applySplitColors(d),m.push("split-colors")),o&&(y=this.applySplitStrokeWidths(d),m.push("split-stroke-widths")),i&&(this.applyFixedStrokeWidth(d),m.push("fixed-stroke-width")),a&&(this.applyFillStrokeNormalization(d),m.push("normalize-fill-stroke")),c&&(this.applyAccessibility(d),m.push("accessibility")),{ast:d,colorMappings:x,strokeWidthMappings:y,metadata:{originalColors:x.map(C=>C.originalColor),originalStrokeWidths:y.map(C=>C.originalStrokeWidth),optimizationApplied:e,features:m,hasClassAttributes:this.hasClassAttributes(d)}}}applySplitColors(t){let e=new g({generateClasses:true,colorPrefix:"color"}).apply(t.root);return t.root=e.processedElement,e.mappings}applyFixedStrokeWidth(t){let e=new S({onlyIfStrokePresent:false,preserveExisting:true}).apply(t.root);t.root=e.processedElement;}applyAccessibility(t){let e=new b({addRole:true,addTitle:true,addDesc:true,defaultRole:"img",preserveExisting:true}).apply(t.root);t.root=e.processedElement;}applyFillStrokeNormalization(t){let r=new E({enabled:true});t.root.children=r.apply(t.root.children);}applyOptimizations(t,r){r.removeDuplicates&&this.removeDuplicateElements(t),r.minifyPaths&&this.minifyPaths(t),this.removeEmptyGroups(t);}removeDuplicateElements(t){}minifyPaths(t){this.traverseElements(t.root,r=>{r.tag==="path"&&r.attributes.d&&(r.attributes.d=r.attributes.d.replace(/\s+/g," ").replace(/([MLHVCSQTAZ])\s+/gi,"$1").trim());});}removeEmptyGroups(t){let r=e=>(e.children=e.children.filter(r),!(e.tag==="g"&&e.children.length===0&&!e.content));t.root.children=t.root.children.filter(r);}traverseElements(t,r){r(t),t.children.forEach(e=>this.traverseElements(e,r));}isValidColor(t){return !t||t==="none"||t==="transparent"||t==="currentColor"?false:/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(t)||/^rgba?\(.+\)$/.test(t)||/^hsla?\(.+\)$/.test(t)}deepCloneAst(t){return {...t,root:this.deepCloneElement(t.root)}}deepCloneElement(t){return {...t,attributes:{...t.attributes},children:t.children.map(r=>this.deepCloneElement(r))}}hasClassAttributes(t){let r=e=>e.attributes.class||e.attributes.className?true:e.children.some(s=>r(s));return r(t.root)}applySplitStrokeWidths(t){let e=new v({generateClasses:true,strokeWidthPrefix:"strokeWidth"}).apply(t.root);return t.root=e.processedElement,e.mappings}};var V=class{options;constructor(t={}){this.options={typescript:true,memo:true,forwardRef:true,exportDefault:true,componentName:"Icon",prefix:"",suffix:"",includeTypes:true,...t};}astToJsx(t){return this.elementToJsx(t.root,0)}elementToJsx(t,r=0){let e=" ".repeat(r+1),{tag:s,attributes:o,children:i,content:a}=t,c=this.attributesToJsx(o),l=c.length>0?" "+c.join(" "):"";if(i.length===0&&!a)return `${e}<${s}${l} />`;let p=`${e}<${s}${l}>`;return a&&(p+=a),i.length>0&&(p+=`
`,p+=i.map(u=>this.elementToJsx(u,r+1)).join(`
`),p+=`
`+e),p+=`</${s}>`,p}attributesToJsx(t){return Object.entries(t).map(([r,e])=>{let s=this.convertAttributeName(r);return e.startsWith("{")&&e.endsWith("}")?`${s}=${e}`:`${s}="${e}"`})}convertAttributeName(t){let r={class:"className",for:"htmlFor",tabindex:"tabIndex",readonly:"readOnly",maxlength:"maxLength",cellpadding:"cellPadding",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"};return t.startsWith("aria-")||t.startsWith("data-")?t:t.includes("-")?t.replace(/-([a-z])/g,(e,s)=>s.toUpperCase()):r[t]||t}generateColorProps(t,r=true){return t.length===0?"":t.map(e=>{let s=e.variableName,o=`${s}Class`;if(this.options.typescript){let i=` ${s}?: string;`;return r&&(i+=`
${o}?: string;`),i}else {let i=` ${s}: PropTypes.string,`;return r&&(i+=`
${o}: PropTypes.string,`),i}}).join(`
`)}generateColorDefaults(t){return t.length===0?"":t.map(r=>{let e=r.variableName,s=r.originalColor;return `${e} = "${s}"`}).join(", ")}generateStrokeWidthProps(t,r=true){return t.length===0?"":t.map(e=>{let s=e.variableName,o=`${s}Class`;if(this.options.typescript){let i=` ${s}?: string | number;`;return r&&(i+=`
${o}?: string;`),i}else {let i=` ${s}: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),`;return r&&(i+=`
${o}: PropTypes.string,`),i}}).join(`
`)}generateStrokeWidthDefaults(t){return t.length===0?"":t.map(r=>{let e=r.variableName,s=r.originalStrokeWidth;return `${e} = "${s}"`}).join(", ")}getComponentName(){return svgToComponentName(this.options.componentName,this.options.prefix,this.options.suffix)}generateFilename(t,r){return `${t}.${r}`}sanitizeComponentName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"").replace(/^[0-9]/,"_$&")}};var G=class{parser;transformer;constructor(){this.parser=new f,this.transformer=new h;}extractColors(t){let r=this.parser.parse(t),e=this.parser.extractColors(r);return Array.from(new Set(e.map(s=>s.value))).sort()}validate(t){let r=[];try{let e=this.parser.parse(t);e.root||r.push("No root SVG element found"),!e.viewBox&&!e.width&&!e.height&&r.push("SVG should have viewBox or width/height attributes");}catch(e){r.push(e instanceof Error?e.message:String(e));}return {valid:r.length===0,errors:r}}async convert(t,r,e){try{let s=this.parser.parse(t),o=this.transformer.transform(s,r.transformation);return {...await new e(r.generator).generate(o),metadata:o.metadata}}catch(s){throw new Error(`SVG conversion failed: ${s instanceof Error?s.message:String(s)}`)}}};function A(n,t){let{format:r,exportType:e,typescript:s}=t,o=[...n].sort((i,a)=>i.componentName.localeCompare(a.componentName));return e==="default"?$(o):N(o,r,s,t.framework)}function N(n,t,r,e){let s="";s+=`// Auto-generated index file for tree-shaking
`,s+=`// This file exports all components for optimal bundling
`;for(let o of n){let i=w(o.filename,e);s+=`export { default as ${o.componentName} } from './${i}';
`;}if(r&&t==="ts"){s+=`
// TypeScript component types
`,e==="vue"?s+=`export type IconComponent = any;
`:s+=`export type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;
`,s+=`export type IconComponents = {
`;for(let o of n)s+=` ${o.componentName}: IconComponent;
`;s+=`};
`;}return s}function $(n,t,r){let e="";e+=`w// Auto-generated index file
`,e+=`// Warning: Default exports are less tree-shakeable
`;for(let s of n){let o=w(s.filename);e+=`import ${s.componentName} from './${o}';
`;}e+=`
export default {
`;for(let s of n)e+=` ${s.componentName},
`;e+=`};
`,e+=`
// Individual exports for flexibility
`;for(let s of n)e+=`export { default as ${s.componentName} } from './${w(s.filename)}';
`;return e}function w(n,t){return t==="vue"&&n.endsWith(".vue")?n:n.replace(/\.(tsx?|jsx?|vue)$/,"")}function R(n){let t=n.map(e=>e.componentName).sort(),r=`# Generated Components
`;r+=`This directory contains ${n.length} auto-generated components from SVG files.
`,r+=`## Usage
`,r+=`### Named imports (recommended for tree-shaking)
`,r+="```typescript\n",r+=`import { ${t.slice(0,3).join(", ")} } from './index';
`,r+="```\n\n",r+=`### Default import
`,r+="```typescript\n",r+=`import * as Icons from './index';
`,r+="```\n\n",r+=`## Available Components
`;for(let e of t)r+=`- \`${e}\`
`;return r+=`
## Tree-shaking
`,r+="This index file is optimized for tree-shaking. When using named imports, ",r+=`bundlers like webpack, Rollup, or Vite will only include the components you actually use.
`,r}export{V as ComponentGenerator,G as SVGFusion,f as SVGParser,h as SVGTransformer,A as generateIndexFile,R as generateReadmeContent};