@pixldocs/canvas-renderer 0.5.225 → 0.5.227

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jspdf = require("jspdf");
4
4
  const svg2pdf_js = require("svg2pdf.js");
5
5
  const fabric = require("fabric");
6
- const index = require("./index-6nrov1rx.cjs");
6
+ const index = require("./index-C6xglmFZ.cjs");
7
7
  const pdfFonts = require("./pdfFonts-BTj2f465.cjs");
8
8
  function _interopNamespaceDefault(e) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -3271,7 +3271,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
3271
3271
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
3272
3272
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
3273
3273
  try {
3274
- const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-6nrov1rx.cjs")).then((n) => n.canvasImageLoader);
3274
+ const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-C6xglmFZ.cjs")).then((n) => n.canvasImageLoader);
3275
3275
  return await getNormalizedSvgUrl(imageUrl, colorMap);
3276
3276
  } catch {
3277
3277
  return null;
@@ -4080,7 +4080,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
4080
4080
  }
4081
4081
  let fetchUrl = imageUrl;
4082
4082
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
4083
- const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-6nrov1rx.cjs")).then((n) => n.canvasImageLoader);
4083
+ const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-C6xglmFZ.cjs")).then((n) => n.canvasImageLoader);
4084
4084
  if (isPrivateUrl(imageUrl)) return null;
4085
4085
  const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
4086
4086
  proxyUrl.searchParams.set("url", imageUrl);
@@ -4259,6 +4259,18 @@ function fabricMatrixToJsPdfAdvancedMatrix(fabricM, _pageHeight) {
4259
4259
  async function rasterizeCropGroupToPng(liveGroup, frameW, frameH, multiplier = 2, maintainResolution = false, imageUrl, forceBlobReplace = false, stored, backgroundColor) {
4260
4260
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4261
4261
  const bgFill = backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "none" ? normalizeBgColor(backgroundColor) : void 0;
4262
+ const hasSvgMask = !!liveGroup.clipPath && (liveGroup.clipPath.__svgMask === true || liveGroup.__svgMaskUrl || liveGroup.clipPath.__svgMaskUrl || liveGroup.clipPath.__svgMaskType || liveGroup.__svgMaskType);
4263
+ if (hasSvgMask) {
4264
+ try {
4265
+ const baked = liveGroup.toCanvasElement({
4266
+ multiplier: Math.max(4, multiplier),
4267
+ enableRetinaScaling: false
4268
+ });
4269
+ return baked.toDataURL("image/png");
4270
+ } catch (e) {
4271
+ console.warn("[client-pdf-export] svg-mask crop bake failed, falling back to rect clip", e);
4272
+ }
4273
+ }
4262
4274
  const cropData = liveGroup.__cropData;
4263
4275
  const rxRatio = (cropData == null ? void 0 : cropData.rx) || 0;
4264
4276
  const minFrameDim = Math.min(frameW, frameH);
@@ -4751,7 +4763,11 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
4751
4763
  if (isSvgSource) {
4752
4764
  exportMultiplier = Math.max(exportMultiplier, 4);
4753
4765
  }
4754
- const canVectorizeSvg = isSvgSource && !!imageUrlForRaster && !elementHasFade(element);
4766
+ const hasSvgMaskOnLive = !!liveGroup.clipPath && (liveGroup.clipPath.__svgMask === true || liveGroup.clipPath.__svgMaskUrl || liveGroup.clipPath.__svgMaskType || liveGroup.__svgMaskUrl || liveGroup.__svgMaskType);
4767
+ if (hasSvgMaskOnLive) {
4768
+ exportMultiplier = Math.max(exportMultiplier, 4);
4769
+ }
4770
+ const canVectorizeSvg = isSvgSource && !!imageUrlForRaster && !elementHasFade(element) && !hasSvgMaskOnLive;
4755
4771
  if (canVectorizeSvg) {
4756
4772
  const svgEl = await fetchSvgAsElement(imageUrlForRaster, element.svgColorMap);
4757
4773
  if (svgEl) {
@@ -5643,9 +5659,8 @@ function isGroupBackgroundDrawable(item) {
5643
5659
  }
5644
5660
  function buildPageDrawList(children, pageTree, visibilityFilter) {
5645
5661
  const out = [];
5646
- function visit(nodes, reverseGroupChildren) {
5647
- const list = reverseGroupChildren ? [...nodes].reverse() : nodes;
5648
- for (const n of list) {
5662
+ function visit(nodes) {
5663
+ for (const n of nodes) {
5649
5664
  if (index.isElement(n)) {
5650
5665
  if (visibilityFilter === "strict" ? n.visible !== false : n.visible) out.push(n);
5651
5666
  } else if (index.isGroup(n)) {
@@ -5662,11 +5677,11 @@ function buildPageDrawList(children, pageTree, visibilityFilter) {
5662
5677
  fill: g.backgroundColor
5663
5678
  });
5664
5679
  }
5665
- visit(g.children ?? [], true);
5680
+ visit(g.children ?? []);
5666
5681
  }
5667
5682
  }
5668
5683
  }
5669
- visit(children, false);
5684
+ visit(children);
5670
5685
  return out;
5671
5686
  }
5672
5687
  function preparePagesForExport(pages, canvasWidth, canvasHeight, options) {
@@ -5726,7 +5741,7 @@ function getOriginalRasterImageUrlMapForPdfPage(page) {
5726
5741
  return byId;
5727
5742
  }
5728
5743
  async function exportMultiPagePdf(pages, options) {
5729
- const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "selectable", skipLiveCanvasSvgFastPath = false, useLiveCanvasObjectPdfPath = false, compressImages = true, compressionQuality } = options;
5744
+ const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "auto", skipLiveCanvasSvgFastPath = false, useLiveCanvasObjectPdfPath = false, compressImages = true, compressionQuality } = options;
5730
5745
  pdfFonts.resetPdfFontRegistry();
5731
5746
  const __prevCompress = __pdfCompressImages;
5732
5747
  const __prevQuality = __pdfJpegQuality;
@@ -6177,4 +6192,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
6177
6192
  exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
6178
6193
  exports.preparePagesForExport = preparePagesForExport;
6179
6194
  exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
6180
- //# sourceMappingURL=vectorPdfExport-CVeK--lR.cjs.map
6195
+ //# sourceMappingURL=vectorPdfExport-nf7ZJYZj.cjs.map