fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
2 lines • 1.34 kB
JavaScript
import{SignalAbortedError as e,log as t}from"../util/internals/console.min.mjs";import{svgValidTagNamesRegEx as n}from"./constants.min.mjs";import{applyViewboxTransform as r}from"./applyViewboxTransform.min.mjs";import{getTagName as i}from"./getTagName.min.mjs";import{hasInvalidAncestor as a}from"./hasInvalidAncestor.min.mjs";import{parseUseDirectives as o}from"./parseUseDirectives.min.mjs";import{ElementsParser as s}from"./elements_parser.min.mjs";const c=e=>n.test(i(e)),l=()=>({objects:[],elements:[],options:{},allElements:[]});async function u(n,l,{crossOrigin:u,signal:d}={}){if(d&&d.aborted)return t(`log`,new e(`parseSVGDocument`)),{objects:[],elements:[],options:{},allElements:[]};let f=n.documentElement;o(n);let p=Array.from(f.getElementsByTagName(`*`)),m={...r(f),crossOrigin:u,signal:d},h=p.filter(e=>(r(e),c(e)&&!a(e)));if(!h||h&&!h.length)return{objects:[],elements:[],options:{},allElements:[],options:m,allElements:p};let g={};return p.filter(e=>i(e)===`clipPath`).forEach(e=>{e.setAttribute(`originalTransform`,e.getAttribute(`transform`)||``);let t=e.getAttribute(`id`);g[t]=Array.from(e.getElementsByTagName(`*`)).filter(e=>c(e))}),{objects:await new s(h,m,l,n,g).parse(),elements:h,options:m,allElements:p}}export{l as createEmptyResponse,u as parseSVGDocument};
//# sourceMappingURL=parseSVGDocument.min.mjs.map