@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.
@@ -3445,7 +3445,9 @@ function preloadImage(url) {
3445
3445
  if (cached) return Promise.resolve(cached);
3446
3446
  return new Promise((resolve, reject) => {
3447
3447
  const img = new Image();
3448
- img.crossOrigin = "anonymous";
3448
+ if (!url.startsWith("data:") && !url.startsWith("blob:")) {
3449
+ img.crossOrigin = "anonymous";
3450
+ }
3449
3451
  img.onload = () => {
3450
3452
  htmlImageCache.set(url, img);
3451
3453
  trimCache(htmlImageCache);
@@ -3671,7 +3673,6 @@ function loadPlaceholderTile() {
3671
3673
  if (placeholderTilePromise) return placeholderTilePromise;
3672
3674
  placeholderTilePromise = new Promise((resolve, reject) => {
3673
3675
  const img = new Image();
3674
- img.crossOrigin = "anonymous";
3675
3676
  img.onload = () => {
3676
3677
  placeholderTileImage = img;
3677
3678
  resolve(img);
@@ -3909,7 +3910,8 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
3909
3910
  resolvedUrl: url.slice(0, 240),
3910
3911
  usedProxy: !url.startsWith("data:") && !url.startsWith("blob:") && url !== imageUrl
3911
3912
  });
3912
- const img = await fabric__namespace.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
3913
+ const imgLoadOptions = url.startsWith("data:") || url.startsWith("blob:") ? {} : { crossOrigin: "anonymous" };
3914
+ const img = await fabric__namespace.FabricImage.fromURL(url, imgLoadOptions);
3913
3915
  if (!fabricRef.current) return;
3914
3916
  await normalizeSvgImageDimensions(img, imageUrl, element.sourceFormat);
3915
3917
  const isHidden = !element.visible;
@@ -16937,9 +16939,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16937
16939
  }
16938
16940
  return svgString;
16939
16941
  }
16940
- const resolvedPackageVersion = "0.5.197";
16942
+ const resolvedPackageVersion = "0.5.199";
16941
16943
  const PACKAGE_VERSION = resolvedPackageVersion;
16942
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.197";
16944
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.199";
16943
16945
  const roundParityValue = (value) => {
16944
16946
  if (typeof value !== "number") return value;
16945
16947
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17026,6 +17028,9 @@ async function downscaleConfigRasterImages(config, maxEdgePx, maxDataUrlBytes =
17026
17028
  try {
17027
17029
  const decode = async (src) => new Promise((resolve, reject) => {
17028
17030
  const el = new Image();
17031
+ if (!src.startsWith("data:") && !src.startsWith("blob:")) {
17032
+ el.crossOrigin = "anonymous";
17033
+ }
17029
17034
  el.onload = () => resolve(el);
17030
17035
  el.onerror = (e) => reject(e);
17031
17036
  el.decoding = "sync";
@@ -17615,7 +17620,7 @@ class PixldocsRenderer {
17615
17620
  await this.waitForCanvasScene(container, cloned, i);
17616
17621
  }
17617
17622
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17618
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CMSo382K.cjs"));
17623
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Dq4rWmf6.cjs"));
17619
17624
  const prepared = preparePagesForExport(
17620
17625
  cloned.pages,
17621
17626
  canvasWidth,
@@ -17626,26 +17631,13 @@ class PixldocsRenderer {
17626
17631
  watermark: !!options.watermark,
17627
17632
  returnBlob: true,
17628
17633
  pdfTextMode: options.textMode ?? (cloned == null ? void 0 : cloned.pdfTextMode) ?? ((_a = cloned.canvas) == null ? void 0 : _a.n) ?? "auto",
17629
- // IMPORTANT: We intentionally do NOT skip the live-canvas SVG fast path
17630
- // here, even when `shouldForcePerElement` is true via auto-detection.
17631
- //
17632
- // Reason: skipping the fast path forces the config-space export, which
17633
- // computes positions from stored values rather than the live Fabric
17634
- // layout (post auto-shrink, post text-init, post crop-group bake).
17635
- // That drift causes severe text overlap / mis-positioning in the PDF
17636
- // while the on-screen preview (which uses the live canvas) still looks
17637
- // correct. v0.5.191 shipped with this skip enabled and produced exactly
17638
- // that regression.
17639
- //
17640
- // The large-photo missing/corrupt image issue is solved by the
17641
- // `downscaleConfigRasterImages()` pre-pass above, which shrinks and
17642
- // recompresses oversized `data:image/*` sources before the canvas
17643
- // mounts. That keeps SVG capture reliable without altering layout.
17644
- //
17645
- // We still honor an explicit `forcePerElementPdf: true` from the host
17646
- // app (advanced opt-in for niche cases), but the auto path no longer
17647
- // toggles this flag.
17648
- skipLiveCanvasSvgFastPath: forceMode === true
17634
+ // Safari/WebKit can still let svg2pdf silently drop valid JPEG data-URL
17635
+ // <image> nodes even after the data is compressed and Fabric has loaded
17636
+ // it. For auto Safari mode, bypass only the full-page SVG->svg2pdf fast
17637
+ // path and use the live Fabric object PDF path instead, preserving live
17638
+ // matrices/order so we do not regress into stale config-space layout.
17639
+ skipLiveCanvasSvgFastPath: forceMode === true,
17640
+ useLiveCanvasObjectPdfPath: shouldForcePerElement && forceMode !== true
17649
17641
  });
17650
17642
  if (!result || typeof result === "undefined") {
17651
17643
  throw new Error("exportMultiPagePdf returned no blob (returnBlob path failed)");
@@ -19812,7 +19804,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19812
19804
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19813
19805
  sanitizeSvgTreeForPdf(svgToDraw);
19814
19806
  try {
19815
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CMSo382K.cjs"));
19807
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Dq4rWmf6.cjs"));
19816
19808
  try {
19817
19809
  await logTextMeasurementDiagnostic(svgToDraw);
19818
19810
  } catch {
@@ -20209,4 +20201,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
20209
20201
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
20210
20202
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
20211
20203
  exports.warmTemplateFromForm = warmTemplateFromForm;
20212
- //# sourceMappingURL=index-dXQP21w2.cjs.map
20204
+ //# sourceMappingURL=index-CEUoSPy-.cjs.map