@pixldocs/canvas-renderer 0.5.197 → 0.5.199

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.
@@ -3427,7 +3427,9 @@ function preloadImage(url) {
3427
3427
  if (cached) return Promise.resolve(cached);
3428
3428
  return new Promise((resolve, reject) => {
3429
3429
  const img = new Image();
3430
- img.crossOrigin = "anonymous";
3430
+ if (!url.startsWith("data:") && !url.startsWith("blob:")) {
3431
+ img.crossOrigin = "anonymous";
3432
+ }
3431
3433
  img.onload = () => {
3432
3434
  htmlImageCache.set(url, img);
3433
3435
  trimCache(htmlImageCache);
@@ -3653,7 +3655,6 @@ function loadPlaceholderTile() {
3653
3655
  if (placeholderTilePromise) return placeholderTilePromise;
3654
3656
  placeholderTilePromise = new Promise((resolve, reject) => {
3655
3657
  const img = new Image();
3656
- img.crossOrigin = "anonymous";
3657
3658
  img.onload = () => {
3658
3659
  placeholderTileImage = img;
3659
3660
  resolve(img);
@@ -3891,7 +3892,8 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
3891
3892
  resolvedUrl: url.slice(0, 240),
3892
3893
  usedProxy: !url.startsWith("data:") && !url.startsWith("blob:") && url !== imageUrl
3893
3894
  });
3894
- const img = await fabric.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
3895
+ const imgLoadOptions = url.startsWith("data:") || url.startsWith("blob:") ? {} : { crossOrigin: "anonymous" };
3896
+ const img = await fabric.FabricImage.fromURL(url, imgLoadOptions);
3895
3897
  if (!fabricRef.current) return;
3896
3898
  await normalizeSvgImageDimensions(img, imageUrl, element.sourceFormat);
3897
3899
  const isHidden = !element.visible;
@@ -16919,9 +16921,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16919
16921
  }
16920
16922
  return svgString;
16921
16923
  }
16922
- const resolvedPackageVersion = "0.5.197";
16924
+ const resolvedPackageVersion = "0.5.199";
16923
16925
  const PACKAGE_VERSION = resolvedPackageVersion;
16924
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.197";
16926
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.199";
16925
16927
  const roundParityValue = (value) => {
16926
16928
  if (typeof value !== "number") return value;
16927
16929
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17008,6 +17010,9 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
17008
17010
  try {
17009
17011
  const decode = async (src) => new Promise((resolve, reject) => {
17010
17012
  const el = new Image();
17013
+ if (!src.startsWith("data:") && !src.startsWith("blob:")) {
17014
+ el.crossOrigin = "anonymous";
17015
+ }
17011
17016
  el.onload = () => resolve(el);
17012
17017
  el.onerror = (e) => reject(e);
17013
17018
  el.decoding = "sync";
@@ -17597,7 +17602,7 @@ class PixldocsRenderer {
17597
17602
  await this.waitForCanvasScene(container, cloned, i);
17598
17603
  }
17599
17604
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17600
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D4pUlnXw.js");
17605
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D57BlzeZ.js");
17601
17606
  const prepared = preparePagesForExport(
17602
17607
  cloned.pages,
17603
17608
  canvasWidth,
@@ -17608,26 +17613,13 @@ class PixldocsRenderer {
17608
17613
  watermark: !!options.watermark,
17609
17614
  returnBlob: true,
17610
17615
  pdfTextMode: options.textMode ?? (cloned == null ? void 0 : cloned.pdfTextMode) ?? ((_a = cloned.canvas) == null ? void 0 : _a.n) ?? "auto",
17611
- // IMPORTANT: We intentionally do NOT skip the live-canvas SVG fast path
17612
- // here, even when `shouldForcePerElement` is true via auto-detection.
17613
- //
17614
- // Reason: skipping the fast path forces the config-space export, which
17615
- // computes positions from stored values rather than the live Fabric
17616
- // layout (post auto-shrink, post text-init, post crop-group bake).
17617
- // That drift causes severe text overlap / mis-positioning in the PDF
17618
- // while the on-screen preview (which uses the live canvas) still looks
17619
- // correct. v0.5.191 shipped with this skip enabled and produced exactly
17620
- // that regression.
17621
- //
17622
- // The large-photo missing/corrupt image issue is solved by the
17623
- // `downscaleConfigRasterImages()` pre-pass above, which shrinks and
17624
- // recompresses oversized `data:image/*` sources before the canvas
17625
- // mounts. That keeps SVG capture reliable without altering layout.
17626
- //
17627
- // We still honor an explicit `forcePerElementPdf: true` from the host
17628
- // app (advanced opt-in for niche cases), but the auto path no longer
17629
- // toggles this flag.
17630
- skipLiveCanvasSvgFastPath: forceMode === true
17616
+ // Safari/WebKit can still let svg2pdf silently drop valid JPEG data-URL
17617
+ // <image> nodes even after the data is compressed and Fabric has loaded
17618
+ // it. For auto Safari mode, bypass only the full-page SVG->svg2pdf fast
17619
+ // path and use the live Fabric object PDF path instead, preserving live
17620
+ // matrices/order so we do not regress into stale config-space layout.
17621
+ skipLiveCanvasSvgFastPath: forceMode === true,
17622
+ useLiveCanvasObjectPdfPath: shouldForcePerElement && forceMode !== true
17631
17623
  });
17632
17624
  if (!result || typeof result === "undefined") {
17633
17625
  throw new Error("exportMultiPagePdf returned no blob (returnBlob path failed)");
@@ -19794,7 +19786,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19794
19786
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19795
19787
  sanitizeSvgTreeForPdf(svgToDraw);
19796
19788
  try {
19797
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D4pUlnXw.js");
19789
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D57BlzeZ.js");
19798
19790
  try {
19799
19791
  await logTextMeasurementDiagnostic(svgToDraw);
19800
19792
  } catch {
@@ -20194,4 +20186,4 @@ export {
20194
20186
  buildTeaserBlurFlatKeys as y,
20195
20187
  collectFontDescriptorsFromConfig as z
20196
20188
  };
20197
- //# sourceMappingURL=index-6bqq7X_L.js.map
20189
+ //# sourceMappingURL=index-CyCjpD2N.js.map