Initial commit

This commit is contained in:
Alejandro Martinez
2026-02-12 02:04:10 +01:00
commit f09af719cf
13433 changed files with 2193445 additions and 0 deletions

54
node_modules/astro/dist/assets/utils/svg.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
import { optimize } from "svgo";
import { parse, renderSync } from "ultrahtml";
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
import { dropAttributes } from "../runtime.js";
function parseSvg({
path,
contents,
svgoConfig
}) {
let processedContents = contents;
if (svgoConfig) {
try {
const config = typeof svgoConfig === "boolean" ? void 0 : svgoConfig;
const result = optimize(contents, config);
processedContents = result.data;
} catch (cause) {
throw new AstroError(
{
...AstroErrorData.CannotOptimizeSvg,
message: AstroErrorData.CannotOptimizeSvg.message(path)
},
{ cause }
);
}
}
const root = parse(processedContents);
const svgNode = root.children.find(
({ name, type }) => type === 1 && name === "svg"
);
if (!svgNode) {
throw new Error("SVG file does not contain an <svg> element");
}
const { attributes, children } = svgNode;
const body = renderSync({ ...root, children });
return { attributes, body };
}
function makeSvgComponent(meta, contents, svgoConfig) {
const file = typeof contents === "string" ? contents : contents.toString("utf-8");
const { attributes, body: children } = parseSvg({
path: meta.fsPath,
contents: file,
svgoConfig
});
const props = {
meta,
attributes: dropAttributes(attributes),
children
};
return `import { createSvgComponent } from 'astro/assets/runtime';
export default createSvgComponent(${JSON.stringify(props)})`;
}
export {
makeSvgComponent
};