@pixldocs/canvas-renderer 0.5.212 → 0.5.214

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.
@@ -6884,8 +6884,9 @@ function buildTextShadow(element) {
6884
6884
  if (!color || color === "transparent") return null;
6885
6885
  const type = element.textShadowType;
6886
6886
  if (type && type !== "drop") return null;
6887
- const { perPassAlpha } = resolveShadowStrength(element);
6888
- const finalColor = applyAlphaMultiplier(String(color), perPassAlpha);
6887
+ const alpha = resolveShadowAlpha(element);
6888
+ if (alpha <= 0) return null;
6889
+ const finalColor = applyAlphaMultiplier(String(color), alpha);
6889
6890
  return new fabric.Shadow({
6890
6891
  color: finalColor,
6891
6892
  blur: blur || 0,
@@ -6895,27 +6896,28 @@ function buildTextShadow(element) {
6895
6896
  nonScaling: false
6896
6897
  });
6897
6898
  }
6898
- function resolveShadowStrength(element) {
6899
+ function resolveShadowAlpha(element) {
6899
6900
  const raw = element.textShadowStrength;
6900
- const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) : 25;
6901
- if (s <= 0) return { perPassAlpha: 0, passes: 0 };
6902
- if (s <= 25) return { perPassAlpha: s / 25, passes: 1 };
6903
- const passes = Math.min(4, Math.ceil(s / 25));
6904
- return { perPassAlpha: 1, passes };
6901
+ const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) : 100;
6902
+ return s / 100;
6905
6903
  }
6906
6904
  function applyTextShadow(textbox, element) {
6907
- const shadow = buildTextShadow(element);
6908
- const { passes } = resolveShadowStrength(element);
6905
+ const canonicalShadow = buildTextShadow(element);
6909
6906
  const obj = textbox;
6910
- if (!obj.__pdShadowOrigRender) {
6911
- obj.__pdShadowOrigRender = obj.render.bind(obj);
6912
- obj.render = function(ctx) {
6913
- const n = Math.max(1, Number(obj.__pdShadowPasses || 1));
6914
- for (let i = 0; i < n; i++) obj.__pdShadowOrigRender(ctx);
6915
- };
6907
+ if (obj.__pdShadowOrigRender) {
6908
+ try {
6909
+ obj.render = obj.__pdShadowOrigRender;
6910
+ } catch {
6911
+ }
6912
+ obj.__pdShadowOrigRender = void 0;
6913
+ obj.__pdShadowPassAlphas = void 0;
6914
+ obj.__pdShadowBaseColor = void 0;
6915
+ obj.__pdShadowBlur = void 0;
6916
+ obj.__pdShadowOX = void 0;
6917
+ obj.__pdShadowOY = void 0;
6916
6918
  }
6917
- obj.__pdShadowPasses = shadow ? Math.max(1, passes) : 1;
6918
- textbox.set("shadow", shadow ?? null);
6919
+ obj.__pdShadowAlpha = canonicalShadow ? resolveShadowAlpha(element) : 1;
6920
+ textbox.set("shadow", canonicalShadow ?? null);
6919
6921
  }
6920
6922
  function applyAlphaMultiplier(c, mult) {
6921
6923
  const m = Math.max(0, Math.min(1, mult));
@@ -7296,7 +7298,9 @@ function applyTextBackground(obj, cfg) {
7296
7298
  const by = shadowBounds.y - pad;
7297
7299
  const bw = shadowBounds.w + pad * 2;
7298
7300
  const bh = shadowBounds.h + pad * 2;
7299
- const dataAttrs = `data-blur="${blur.toFixed(3)}" data-ox="${ox.toFixed(3)}" data-oy="${oy.toFixed(3)}" data-bx="${bx.toFixed(3)}" data-by="${by.toFixed(3)}" data-bw="${bw.toFixed(3)}" data-bh="${bh.toFixed(3)}" data-color="${escapeXmlAttr(shadowColor)}"`;
7301
+ const alphaRaw = Number(this.__pdShadowAlpha);
7302
+ const shadowAlpha = Number.isFinite(alphaRaw) ? Math.max(0, Math.min(1, alphaRaw)) : 1;
7303
+ const dataAttrs = `data-blur="${blur.toFixed(3)}" data-ox="${ox.toFixed(3)}" data-oy="${oy.toFixed(3)}" data-bx="${bx.toFixed(3)}" data-by="${by.toFixed(3)}" data-bw="${bw.toFixed(3)}" data-bh="${bh.toFixed(3)}" data-color="${escapeXmlAttr(shadowColor)}" data-alpha="${shadowAlpha.toFixed(3)}"`;
7300
7304
  const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
7301
7305
  if (hasBg && (bg == null ? void 0 : bg.shadowAffectsBg) !== false) {
7302
7306
  const shadowOpacityAttr = bgOpacity < 1 ? ` fill-opacity="${bgOpacity}"` : "";
@@ -19012,9 +19016,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
19012
19016
  }
19013
19017
  return svgString;
19014
19018
  }
19015
- const resolvedPackageVersion = "0.5.212";
19019
+ const resolvedPackageVersion = "0.5.214";
19016
19020
  const PACKAGE_VERSION = resolvedPackageVersion;
19017
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.212";
19021
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.214";
19018
19022
  const roundParityValue = (value) => {
19019
19023
  if (typeof value !== "number") return value;
19020
19024
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19706,7 +19710,7 @@ class PixldocsRenderer {
19706
19710
  await this.waitForCanvasScene(container, cloned, i);
19707
19711
  }
19708
19712
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19709
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CN-N0DE8.js");
19713
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CjIUU8on.js");
19710
19714
  const prepared = preparePagesForExport(
19711
19715
  cloned.pages,
19712
19716
  canvasWidth,
@@ -21683,10 +21687,12 @@ async function rasterizeShadowMarkers(svg) {
21683
21687
  img.setAttribute("y", String(by));
21684
21688
  img.setAttribute("width", String(bw));
21685
21689
  img.setAttribute("height", String(bh));
21686
- img.setAttribute("opacity", String(SHADOW_RASTER_ALPHA_COMPENSATION));
21687
21690
  img.setAttribute("preserveAspectRatio", "none");
21688
21691
  img.setAttributeNS(XLINK_NS, "xlink:href", dataUrl);
21689
21692
  img.setAttribute("href", dataUrl);
21693
+ const alphaRaw = parseFloat(marker.getAttribute("data-alpha") || "1");
21694
+ const shadowAlpha = Number.isFinite(alphaRaw) ? Math.max(0, Math.min(1, alphaRaw)) : 1;
21695
+ img.setAttribute("opacity", String(SHADOW_RASTER_ALPHA_COMPENSATION * shadowAlpha));
21690
21696
  (_e = marker.parentNode) == null ? void 0 : _e.replaceChild(img, marker);
21691
21697
  } catch (e) {
21692
21698
  console.warn("[pdf-export] rasterizeShadowMarkers failed for one marker:", e);
@@ -21892,7 +21898,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
21892
21898
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
21893
21899
  sanitizeSvgTreeForPdf(svgToDraw);
21894
21900
  try {
21895
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CN-N0DE8.js");
21901
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CjIUU8on.js");
21896
21902
  try {
21897
21903
  await logTextMeasurementDiagnostic(svgToDraw);
21898
21904
  } catch {
@@ -22292,4 +22298,4 @@ export {
22292
22298
  buildTeaserBlurFlatKeys as y,
22293
22299
  collectFontDescriptorsFromConfig as z
22294
22300
  };
22295
- //# sourceMappingURL=index-B1QDVK5k.js.map
22301
+ //# sourceMappingURL=index-CDdfs3IB.js.map