@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.cjs CHANGED
@@ -12247,8 +12247,9 @@ function inlineSvgStyleBlockDeclarations(svg) {
12247
12247
  });
12248
12248
  });
12249
12249
  const normalizePresentationValue = (key, value) => {
12250
- if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(value);
12251
- return value;
12250
+ const cleaned = value.replace(/\s*!important\s*$/i, "").trim();
12251
+ if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(cleaned);
12252
+ return cleaned;
12252
12253
  };
12253
12254
  const applyDeclarations = (elements, declarations) => {
12254
12255
  for (const el of elements) {
@@ -12714,6 +12715,14 @@ function inlineComputedStyles(svg) {
12714
12715
  if (wrap.parentNode) document.body.removeChild(wrap);
12715
12716
  }
12716
12717
  }
12718
+ function disambiguateNestedSvgIds(rootSvg) {
12719
+ const nestedSvgs = Array.from(rootSvg.querySelectorAll("svg"));
12720
+ const toProcess = nestedSvgs.filter((s) => s !== rootSvg);
12721
+ if (toProcess.length < 2) return;
12722
+ toProcess.forEach((nested, idx) => {
12723
+ prefixSvgIds(nested, `n${idx}`);
12724
+ });
12725
+ }
12717
12726
  function prefixSvgIds(svg, prefix) {
12718
12727
  const safePrefix = String(prefix).replace(/[^a-zA-Z0-9-]/g, "_");
12719
12728
  const idMap = /* @__PURE__ */ new Map();
@@ -12945,6 +12954,7 @@ function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, opti
12945
12954
  sanitizeSvgTreeForPdf(svgToDraw);
12946
12955
  normalizeSvgGradientStopOffsets(svgToDraw);
12947
12956
  expandSvgGradientHrefs(svgToDraw);
12957
+ disambiguateNestedSvgIds(svgToDraw);
12948
12958
  prefixSvgIds(svgToDraw, pageKey);
12949
12959
  bakeGroupOpacityIntoChildren(svgToDraw);
12950
12960
  stripSuspiciousFullPageOverlayNodes(svgToDraw);