@pixldocs/canvas-renderer 0.4.1 → 0.4.3

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();
@@ -12920,6 +12929,7 @@ function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, opti
12920
12929
  svg.setAttribute("viewBox", `0 0 ${pageWidth} ${pageHeight}`);
12921
12930
  sanitizeSvgTreeForPdf(svg);
12922
12931
  normalizeSvgViewBoxOrigin(svg);
12932
+ disambiguateNestedSvgIds(svg);
12923
12933
  expandSvgUseElements(svg);
12924
12934
  const svgToDraw = normalizeSvgExplicitColors(svg);
12925
12935
  inlineComputedStyles(svgToDraw);