@pixldocs/canvas-renderer 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12228,8 +12228,9 @@ function inlineSvgStyleBlockDeclarations(svg) {
12228
12228
  });
12229
12229
  });
12230
12230
  const normalizePresentationValue = (key, value) => {
12231
- if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(value);
12232
- return value;
12231
+ const cleaned = value.replace(/\s*!important\s*$/i, "").trim();
12232
+ if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(cleaned);
12233
+ return cleaned;
12233
12234
  };
12234
12235
  const applyDeclarations = (elements, declarations) => {
12235
12236
  for (const el of elements) {
@@ -12695,6 +12696,14 @@ function inlineComputedStyles(svg) {
12695
12696
  if (wrap.parentNode) document.body.removeChild(wrap);
12696
12697
  }
12697
12698
  }
12699
+ function disambiguateNestedSvgIds(rootSvg) {
12700
+ const nestedSvgs = Array.from(rootSvg.querySelectorAll("svg"));
12701
+ const toProcess = nestedSvgs.filter((s) => s !== rootSvg);
12702
+ if (toProcess.length < 2) return;
12703
+ toProcess.forEach((nested, idx) => {
12704
+ prefixSvgIds(nested, `n${idx}`);
12705
+ });
12706
+ }
12698
12707
  function prefixSvgIds(svg, prefix) {
12699
12708
  const safePrefix = String(prefix).replace(/[^a-zA-Z0-9-]/g, "_");
12700
12709
  const idMap = /* @__PURE__ */ new Map();
@@ -12926,6 +12935,7 @@ function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, opti
12926
12935
  sanitizeSvgTreeForPdf(svgToDraw);
12927
12936
  normalizeSvgGradientStopOffsets(svgToDraw);
12928
12937
  expandSvgGradientHrefs(svgToDraw);
12938
+ disambiguateNestedSvgIds(svgToDraw);
12929
12939
  prefixSvgIds(svgToDraw, pageKey);
12930
12940
  bakeGroupOpacityIntoChildren(svgToDraw);
12931
12941
  stripSuspiciousFullPageOverlayNodes(svgToDraw);