@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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-6nrov1rx.cjs");
3
+ const index = require("./index-C6xglmFZ.cjs");
4
4
  exports.DEPLOYMENT_VERSION_MARKER = index.DEPLOYMENT_VERSION_MARKER;
5
5
  exports.FONT_FALLBACK_DEVANAGARI = index.FONT_FALLBACK_DEVANAGARI;
6
6
  exports.FONT_FALLBACK_MATH = index.FONT_FALLBACK_MATH;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-BpViFQMO.js";
1
+ import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-BEJVbec7.js";
2
2
  export {
3
3
  D as DEPLOYMENT_VERSION_MARKER,
4
4
  F as FONT_FALLBACK_DEVANAGARI,
@@ -1,7 +1,7 @@
1
1
  import { jsPDF, ShadingPattern } from "jspdf";
2
2
  import { svg2pdf } from "svg2pdf.js";
3
3
  import * as fabric from "fabric";
4
- import { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-BpViFQMO.js";
4
+ import { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-BEJVbec7.js";
5
5
  import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-DhEaMTZl.js";
6
6
  async function embedFontsForSvg(pdf, svgStr) {
7
7
  var _a;
@@ -3252,7 +3252,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
3252
3252
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
3253
3253
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
3254
3254
  try {
3255
- const { getNormalizedSvgUrl } = await import("./index-BpViFQMO.js").then((n) => n.a6);
3255
+ const { getNormalizedSvgUrl } = await import("./index-BEJVbec7.js").then((n) => n.a6);
3256
3256
  return await getNormalizedSvgUrl(imageUrl, colorMap);
3257
3257
  } catch {
3258
3258
  return null;
@@ -4061,7 +4061,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
4061
4061
  }
4062
4062
  let fetchUrl = imageUrl;
4063
4063
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
4064
- const { isPrivateUrl } = await import("./index-BpViFQMO.js").then((n) => n.a6);
4064
+ const { isPrivateUrl } = await import("./index-BEJVbec7.js").then((n) => n.a6);
4065
4065
  if (isPrivateUrl(imageUrl)) return null;
4066
4066
  const proxyUrl = new URL(`${API_URL}/image-proxy`);
4067
4067
  proxyUrl.searchParams.set("url", imageUrl);
@@ -4240,6 +4240,18 @@ function fabricMatrixToJsPdfAdvancedMatrix(fabricM, _pageHeight) {
4240
4240
  async function rasterizeCropGroupToPng(liveGroup, frameW, frameH, multiplier = 2, maintainResolution = false, imageUrl, forceBlobReplace = false, stored, backgroundColor) {
4241
4241
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4242
4242
  const bgFill = backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "none" ? normalizeBgColor(backgroundColor) : void 0;
4243
+ const hasSvgMask = !!liveGroup.clipPath && (liveGroup.clipPath.__svgMask === true || liveGroup.__svgMaskUrl || liveGroup.clipPath.__svgMaskUrl || liveGroup.clipPath.__svgMaskType || liveGroup.__svgMaskType);
4244
+ if (hasSvgMask) {
4245
+ try {
4246
+ const baked = liveGroup.toCanvasElement({
4247
+ multiplier: Math.max(4, multiplier),
4248
+ enableRetinaScaling: false
4249
+ });
4250
+ return baked.toDataURL("image/png");
4251
+ } catch (e) {
4252
+ console.warn("[client-pdf-export] svg-mask crop bake failed, falling back to rect clip", e);
4253
+ }
4254
+ }
4243
4255
  const cropData = liveGroup.__cropData;
4244
4256
  const rxRatio = (cropData == null ? void 0 : cropData.rx) || 0;
4245
4257
  const minFrameDim = Math.min(frameW, frameH);
@@ -4732,7 +4744,11 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
4732
4744
  if (isSvgSource) {
4733
4745
  exportMultiplier = Math.max(exportMultiplier, 4);
4734
4746
  }
4735
- const canVectorizeSvg = isSvgSource && !!imageUrlForRaster && !elementHasFade(element);
4747
+ const hasSvgMaskOnLive = !!liveGroup.clipPath && (liveGroup.clipPath.__svgMask === true || liveGroup.clipPath.__svgMaskUrl || liveGroup.clipPath.__svgMaskType || liveGroup.__svgMaskUrl || liveGroup.__svgMaskType);
4748
+ if (hasSvgMaskOnLive) {
4749
+ exportMultiplier = Math.max(exportMultiplier, 4);
4750
+ }
4751
+ const canVectorizeSvg = isSvgSource && !!imageUrlForRaster && !elementHasFade(element) && !hasSvgMaskOnLive;
4736
4752
  if (canVectorizeSvg) {
4737
4753
  const svgEl = await fetchSvgAsElement(imageUrlForRaster, element.svgColorMap);
4738
4754
  if (svgEl) {
@@ -5624,9 +5640,8 @@ function isGroupBackgroundDrawable(item) {
5624
5640
  }
5625
5641
  function buildPageDrawList(children, pageTree, visibilityFilter) {
5626
5642
  const out = [];
5627
- function visit(nodes, reverseGroupChildren) {
5628
- const list = reverseGroupChildren ? [...nodes].reverse() : nodes;
5629
- for (const n of list) {
5643
+ function visit(nodes) {
5644
+ for (const n of nodes) {
5630
5645
  if (isElement(n)) {
5631
5646
  if (visibilityFilter === "strict" ? n.visible !== false : n.visible) out.push(n);
5632
5647
  } else if (isGroup(n)) {
@@ -5643,11 +5658,11 @@ function buildPageDrawList(children, pageTree, visibilityFilter) {
5643
5658
  fill: g.backgroundColor
5644
5659
  });
5645
5660
  }
5646
- visit(g.children ?? [], true);
5661
+ visit(g.children ?? []);
5647
5662
  }
5648
5663
  }
5649
5664
  }
5650
- visit(children, false);
5665
+ visit(children);
5651
5666
  return out;
5652
5667
  }
5653
5668
  function preparePagesForExport(pages, canvasWidth, canvasHeight, options) {
@@ -5707,7 +5722,7 @@ function getOriginalRasterImageUrlMapForPdfPage(page) {
5707
5722
  return byId;
5708
5723
  }
5709
5724
  async function exportMultiPagePdf(pages, options) {
5710
- const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "selectable", skipLiveCanvasSvgFastPath = false, useLiveCanvasObjectPdfPath = false, compressImages = true, compressionQuality } = options;
5725
+ const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "auto", skipLiveCanvasSvgFastPath = false, useLiveCanvasObjectPdfPath = false, compressImages = true, compressionQuality } = options;
5711
5726
  resetPdfFontRegistry();
5712
5727
  const __prevCompress = __pdfCompressImages;
5713
5728
  const __prevQuality = __pdfJpegQuality;
@@ -6160,4 +6175,4 @@ export {
6160
6175
  preparePagesForExport,
6161
6176
  rewriteSvgFontsForJsPDFWithSourceMeta
6162
6177
  };
6163
- //# sourceMappingURL=vectorPdfExport-D46sZGKA.js.map
6178
+ //# sourceMappingURL=vectorPdfExport-DAM2BQr4.js.map