@pixldocs/canvas-renderer 0.5.210 → 0.5.211

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.
@@ -4053,6 +4053,11 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
4053
4053
  setObjectData(cropGroup, element.id);
4054
4054
  cropGroup.__imageSrc = imageUrl;
4055
4055
  cropGroup.__svgColorMap = nextSvgColorMap;
4056
+ cropGroup.set({
4057
+ flipX: element.flipX ?? false,
4058
+ flipY: element.flipY ?? false
4059
+ });
4060
+ cropGroup.setCoords();
4056
4061
  finalObject = cropGroup;
4057
4062
  } else {
4058
4063
  setObjectData(img, element.id);
@@ -18947,9 +18952,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
18947
18952
  }
18948
18953
  return svgString;
18949
18954
  }
18950
- const resolvedPackageVersion = "0.5.210";
18955
+ const resolvedPackageVersion = "0.5.211";
18951
18956
  const PACKAGE_VERSION = resolvedPackageVersion;
18952
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.210";
18957
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.211";
18953
18958
  const roundParityValue = (value) => {
18954
18959
  if (typeof value !== "number") return value;
18955
18960
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19009,7 +19014,7 @@ function detectSafariOrIos() {
19009
19014
  return false;
19010
19015
  }
19011
19016
  }
19012
- async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes = 2e6) {
19017
+ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes = 2e6, jpegQuality = 0.85) {
19013
19018
  if (!maxEdgePx || maxEdgePx <= 0) return 0;
19014
19019
  if (typeof document === "undefined") return 0;
19015
19020
  const targets = [];
@@ -19073,7 +19078,7 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
19073
19078
  return null;
19074
19079
  }
19075
19080
  let scale = tooLargeByEdge ? maxEdgePx / longest : 1;
19076
- let quality = 0.85;
19081
+ let quality = Math.max(0.4, Math.min(1, jpegQuality));
19077
19082
  let best = null;
19078
19083
  for (let attempt = 0; attempt < 4; attempt++) {
19079
19084
  const tw = Math.max(1, Math.round(w * scale));
@@ -19097,7 +19102,7 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
19097
19102
  }
19098
19103
  const byteScale = Math.sqrt(maxDataUrlBytes / Math.max(1, outBytes)) * 0.92;
19099
19104
  scale = Math.max(0.1, scale * Math.min(0.95, byteScale));
19100
- quality = Math.max(0.68, quality - 0.06);
19105
+ quality = Math.max(0.4, quality - 0.06);
19101
19106
  }
19102
19107
  if (blobUrl) URL.revokeObjectURL(blobUrl);
19103
19108
  return best;
@@ -19472,7 +19477,9 @@ class PixldocsRenderer {
19472
19477
  title: options == null ? void 0 : options.title,
19473
19478
  textMode: options == null ? void 0 : options.textMode,
19474
19479
  forcePerElementPdf: options == null ? void 0 : options.forcePerElementPdf,
19475
- maxImageEdgePx: options == null ? void 0 : options.maxImageEdgePx
19480
+ maxImageEdgePx: options == null ? void 0 : options.maxImageEdgePx,
19481
+ compressImages: options == null ? void 0 : options.compressImages,
19482
+ compressionQuality: options == null ? void 0 : options.compressionQuality
19476
19483
  });
19477
19484
  }
19478
19485
  /**
@@ -19480,7 +19487,7 @@ class PixldocsRenderer {
19480
19487
  * This is the primary PDF export API — mirrors renderFromForm() but returns a PDF.
19481
19488
  */
19482
19489
  async renderPdfFromForm(options) {
19483
- const { templateId, formSchemaId, sectionState, themeId, watermark, watermarkOptions, prefetched, title, fontBaseUrl, textMode, forcePerElementPdf, maxImageEdgePx } = options;
19490
+ const { templateId, formSchemaId, sectionState, themeId, watermark, watermarkOptions, prefetched, title, fontBaseUrl, textMode, forcePerElementPdf, maxImageEdgePx, compressImages, compressionQuality } = options;
19484
19491
  const resolved = await resolveFromForm({
19485
19492
  templateId,
19486
19493
  formSchemaId,
@@ -19503,7 +19510,9 @@ class PixldocsRenderer {
19503
19510
  watermark: shouldWatermark,
19504
19511
  textMode,
19505
19512
  forcePerElementPdf,
19506
- maxImageEdgePx
19513
+ maxImageEdgePx,
19514
+ compressImages,
19515
+ compressionQuality
19507
19516
  });
19508
19517
  }
19509
19518
  async renderById(templateId, formData, options) {
@@ -19550,13 +19559,20 @@ class PixldocsRenderer {
19550
19559
  const hasUserDataImage = configHasUserDataImage(cloned);
19551
19560
  const isSafariLike = detectSafariOrIos();
19552
19561
  const shouldForcePerElement = forceMode === true ? true : forceMode === false ? false : false;
19562
+ const compressImagesOpt = options.compressImages ?? true;
19553
19563
  const maxEdgeOpt = options.maxImageEdgePx ?? this.config.maxImageEdgePx;
19554
- const effectiveMaxEdge = typeof maxEdgeOpt === "number" ? Math.max(0, maxEdgeOpt | 0) : hasUserDataImage ? 2048 : 0;
19564
+ const effectiveMaxEdge = typeof maxEdgeOpt === "number" ? Math.max(0, maxEdgeOpt | 0) : compressImagesOpt ? hasUserDataImage ? 2048 : 0 : 0;
19565
+ const downscaleQuality = compressImagesOpt ? typeof options.compressionQuality === "number" ? Math.max(0.4, Math.min(1, options.compressionQuality)) : 0.85 : 0.95;
19555
19566
  if (effectiveMaxEdge > 0) {
19556
19567
  try {
19557
- const downscaled = await downscaleConfigRasterImages(cloned, effectiveMaxEdge);
19568
+ const downscaled = await downscaleConfigRasterImages(
19569
+ cloned,
19570
+ effectiveMaxEdge,
19571
+ void 0,
19572
+ downscaleQuality
19573
+ );
19558
19574
  if (downscaled > 0) {
19559
- console.log(`[canvas-renderer][pdf-unified] downscaled ${downscaled} raster image(s) to <=${effectiveMaxEdge}px edge`);
19575
+ console.log(`[canvas-renderer][pdf-unified] downscaled ${downscaled} raster image(s) to <=${effectiveMaxEdge}px edge @ q=${downscaleQuality}`);
19560
19576
  }
19561
19577
  } catch (e) {
19562
19578
  console.warn("[canvas-renderer][pdf-unified] image downscale pass failed (continuing with originals):", e);
@@ -19567,7 +19583,9 @@ class PixldocsRenderer {
19567
19583
  hasUserDataImage,
19568
19584
  isSafariLike,
19569
19585
  shouldForcePerElement,
19570
- effectiveMaxEdge
19586
+ effectiveMaxEdge,
19587
+ compressImages: compressImagesOpt,
19588
+ downscaleQuality
19571
19589
  });
19572
19590
  const stampPrefix = `__pixldocs_pdf_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
19573
19591
  const pageIds = cloned.pages.map((p, i) => {
@@ -19628,7 +19646,7 @@ class PixldocsRenderer {
19628
19646
  await this.waitForCanvasScene(container, cloned, i);
19629
19647
  }
19630
19648
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19631
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Ch6GbQqO.js");
19649
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BEGl71uB.js");
19632
19650
  const prepared = preparePagesForExport(
19633
19651
  cloned.pages,
19634
19652
  canvasWidth,
@@ -19645,7 +19663,9 @@ class PixldocsRenderer {
19645
19663
  // path and use the live Fabric object PDF path instead, preserving live
19646
19664
  // matrices/order so we do not regress into stale config-space layout.
19647
19665
  skipLiveCanvasSvgFastPath: forceMode === true,
19648
- useLiveCanvasObjectPdfPath: shouldForcePerElement && forceMode !== true
19666
+ useLiveCanvasObjectPdfPath: shouldForcePerElement && forceMode !== true,
19667
+ compressImages: options.compressImages ?? true,
19668
+ compressionQuality: options.compressionQuality
19649
19669
  });
19650
19670
  if (!result || typeof result === "undefined") {
19651
19671
  throw new Error("exportMultiPagePdf returned no blob (returnBlob path failed)");
@@ -21812,7 +21832,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
21812
21832
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
21813
21833
  sanitizeSvgTreeForPdf(svgToDraw);
21814
21834
  try {
21815
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Ch6GbQqO.js");
21835
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BEGl71uB.js");
21816
21836
  try {
21817
21837
  await logTextMeasurementDiagnostic(svgToDraw);
21818
21838
  } catch {
@@ -22212,4 +22232,4 @@ export {
22212
22232
  buildTeaserBlurFlatKeys as y,
22213
22233
  collectFontDescriptorsFromConfig as z
22214
22234
  };
22215
- //# sourceMappingURL=index-DwYUddYW.js.map
22235
+ //# sourceMappingURL=index-C0tTvSFQ.js.map