@pixldocs/canvas-renderer 0.5.213 → 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.
- package/dist/{index-XZf4TDQ-.js → index-CDdfs3IB.js} +30 -83
- package/dist/index-CDdfs3IB.js.map +1 -0
- package/dist/{index-zkVpb-YL.cjs → index-Cy2_ElDZ.cjs} +30 -83
- package/dist/index-Cy2_ElDZ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-krI8SwbX.cjs → vectorPdfExport-BBG0QRse.cjs} +9 -21
- package/dist/vectorPdfExport-BBG0QRse.cjs.map +1 -0
- package/dist/{vectorPdfExport-ox1nl4G9.js → vectorPdfExport-CjIUU8on.js} +9 -21
- package/dist/vectorPdfExport-CjIUU8on.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-XZf4TDQ-.js.map +0 -1
- package/dist/index-zkVpb-YL.cjs.map +0 -1
- package/dist/vectorPdfExport-krI8SwbX.cjs.map +0 -1
- package/dist/vectorPdfExport-ox1nl4G9.js.map +0 -1
|
@@ -6884,9 +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
|
|
6888
|
-
|
|
6889
|
-
const finalColor = applyAlphaMultiplier(String(color),
|
|
6887
|
+
const alpha = resolveShadowAlpha(element);
|
|
6888
|
+
if (alpha <= 0) return null;
|
|
6889
|
+
const finalColor = applyAlphaMultiplier(String(color), alpha);
|
|
6890
6890
|
return new fabric.Shadow({
|
|
6891
6891
|
color: finalColor,
|
|
6892
6892
|
blur: blur || 0,
|
|
@@ -6896,67 +6896,27 @@ function buildTextShadow(element) {
|
|
|
6896
6896
|
nonScaling: false
|
|
6897
6897
|
});
|
|
6898
6898
|
}
|
|
6899
|
-
function
|
|
6899
|
+
function resolveShadowAlpha(element) {
|
|
6900
6900
|
const raw = element.textShadowStrength;
|
|
6901
|
-
const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) :
|
|
6902
|
-
|
|
6903
|
-
const intensity = Math.min(3, s / 33.34);
|
|
6904
|
-
if (intensity <= 1) return { passAlphas: [intensity] };
|
|
6905
|
-
const full = Math.floor(intensity);
|
|
6906
|
-
const frac = intensity - full;
|
|
6907
|
-
const arr = new Array(full).fill(1);
|
|
6908
|
-
if (frac > 0.01) arr.push(frac);
|
|
6909
|
-
return { passAlphas: arr };
|
|
6901
|
+
const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) : 100;
|
|
6902
|
+
return s / 100;
|
|
6910
6903
|
}
|
|
6911
6904
|
function applyTextShadow(textbox, element) {
|
|
6912
6905
|
const canonicalShadow = buildTextShadow(element);
|
|
6913
|
-
const { passAlphas } = resolveShadowStrength(element);
|
|
6914
|
-
const baseColor = element.textShadowColor;
|
|
6915
|
-
const blur = Number(element.textShadowBlur ?? 0) || 0;
|
|
6916
|
-
const ox = Number(element.textShadowOffsetX ?? 0) || 0;
|
|
6917
|
-
const oy = Number(element.textShadowOffsetY ?? 0) || 0;
|
|
6918
|
-
const hasShadow = !!canonicalShadow && passAlphas.length > 0;
|
|
6919
6906
|
const obj = textbox;
|
|
6920
|
-
if (
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
return;
|
|
6927
|
-
}
|
|
6928
|
-
const orig = obj.shadow;
|
|
6929
|
-
const baseC = obj.__pdShadowBaseColor || "#000";
|
|
6930
|
-
const b = obj.__pdShadowBlur || 0;
|
|
6931
|
-
const x = obj.__pdShadowOX || 0;
|
|
6932
|
-
const y = obj.__pdShadowOY || 0;
|
|
6933
|
-
for (let i = 0; i < alphas.length; i++) {
|
|
6934
|
-
obj.shadow = new fabric.Shadow({
|
|
6935
|
-
color: applyAlphaMultiplier(String(baseC), alphas[i]),
|
|
6936
|
-
blur: b,
|
|
6937
|
-
offsetX: x,
|
|
6938
|
-
offsetY: y,
|
|
6939
|
-
affectStroke: false,
|
|
6940
|
-
nonScaling: false
|
|
6941
|
-
});
|
|
6942
|
-
obj.__pdShadowOrigRender(ctx);
|
|
6943
|
-
}
|
|
6944
|
-
obj.shadow = orig;
|
|
6945
|
-
};
|
|
6946
|
-
}
|
|
6947
|
-
if (hasShadow) {
|
|
6948
|
-
obj.__pdShadowPassAlphas = passAlphas;
|
|
6949
|
-
obj.__pdShadowBaseColor = baseColor;
|
|
6950
|
-
obj.__pdShadowBlur = blur;
|
|
6951
|
-
obj.__pdShadowOX = ox;
|
|
6952
|
-
obj.__pdShadowOY = oy;
|
|
6953
|
-
obj.__pdShadowPasses = passAlphas.length;
|
|
6954
|
-
obj.__pdShadowLastAlpha = passAlphas[passAlphas.length - 1];
|
|
6955
|
-
} else {
|
|
6907
|
+
if (obj.__pdShadowOrigRender) {
|
|
6908
|
+
try {
|
|
6909
|
+
obj.render = obj.__pdShadowOrigRender;
|
|
6910
|
+
} catch {
|
|
6911
|
+
}
|
|
6912
|
+
obj.__pdShadowOrigRender = void 0;
|
|
6956
6913
|
obj.__pdShadowPassAlphas = void 0;
|
|
6957
|
-
obj.
|
|
6958
|
-
obj.
|
|
6914
|
+
obj.__pdShadowBaseColor = void 0;
|
|
6915
|
+
obj.__pdShadowBlur = void 0;
|
|
6916
|
+
obj.__pdShadowOX = void 0;
|
|
6917
|
+
obj.__pdShadowOY = void 0;
|
|
6959
6918
|
}
|
|
6919
|
+
obj.__pdShadowAlpha = canonicalShadow ? resolveShadowAlpha(element) : 1;
|
|
6960
6920
|
textbox.set("shadow", canonicalShadow ?? null);
|
|
6961
6921
|
}
|
|
6962
6922
|
function applyAlphaMultiplier(c, mult) {
|
|
@@ -7338,10 +7298,9 @@ function applyTextBackground(obj, cfg) {
|
|
|
7338
7298
|
const by = shadowBounds.y - pad;
|
|
7339
7299
|
const bw = shadowBounds.w + pad * 2;
|
|
7340
7300
|
const bh = shadowBounds.h + pad * 2;
|
|
7341
|
-
const
|
|
7342
|
-
const
|
|
7343
|
-
const
|
|
7344
|
-
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-passes="${passes}" data-last-alpha="${lastAlpha.toFixed(3)}"`;
|
|
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)}"`;
|
|
7345
7304
|
const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
|
|
7346
7305
|
if (hasBg && (bg == null ? void 0 : bg.shadowAffectsBg) !== false) {
|
|
7347
7306
|
const shadowOpacityAttr = bgOpacity < 1 ? ` fill-opacity="${bgOpacity}"` : "";
|
|
@@ -19057,9 +19016,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
19057
19016
|
}
|
|
19058
19017
|
return svgString;
|
|
19059
19018
|
}
|
|
19060
|
-
const resolvedPackageVersion = "0.5.
|
|
19019
|
+
const resolvedPackageVersion = "0.5.214";
|
|
19061
19020
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
19062
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
19021
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.214";
|
|
19063
19022
|
const roundParityValue = (value) => {
|
|
19064
19023
|
if (typeof value !== "number") return value;
|
|
19065
19024
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -19751,7 +19710,7 @@ class PixldocsRenderer {
|
|
|
19751
19710
|
await this.waitForCanvasScene(container, cloned, i);
|
|
19752
19711
|
}
|
|
19753
19712
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
19754
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
19713
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CjIUU8on.js");
|
|
19755
19714
|
const prepared = preparePagesForExport(
|
|
19756
19715
|
cloned.pages,
|
|
19757
19716
|
canvasWidth,
|
|
@@ -21673,7 +21632,7 @@ async function convertSvgTextDecorationsToLinesString(svgStr) {
|
|
|
21673
21632
|
}
|
|
21674
21633
|
}
|
|
21675
21634
|
async function rasterizeShadowMarkers(svg) {
|
|
21676
|
-
var _a, _b, _c, _d, _e, _f
|
|
21635
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21677
21636
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
21678
21637
|
const markers = Array.from(svg.querySelectorAll("g.__pdShadowRaster"));
|
|
21679
21638
|
if (markers.length === 0) return;
|
|
@@ -21728,29 +21687,17 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
21728
21687
|
img.setAttribute("y", String(by));
|
|
21729
21688
|
img.setAttribute("width", String(bw));
|
|
21730
21689
|
img.setAttribute("height", String(bh));
|
|
21731
|
-
img.setAttribute("opacity", String(SHADOW_RASTER_ALPHA_COMPENSATION));
|
|
21732
21690
|
img.setAttribute("preserveAspectRatio", "none");
|
|
21733
21691
|
img.setAttributeNS(XLINK_NS, "xlink:href", dataUrl);
|
|
21734
21692
|
img.setAttribute("href", dataUrl);
|
|
21735
|
-
const
|
|
21736
|
-
const
|
|
21737
|
-
|
|
21738
|
-
const baseOpacity = Number(img.getAttribute("opacity") || "1") || 1;
|
|
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));
|
|
21739
21696
|
(_e = marker.parentNode) == null ? void 0 : _e.replaceChild(img, marker);
|
|
21740
|
-
for (let i = 1; i < passes; i++) {
|
|
21741
|
-
const extra = img.cloneNode(true);
|
|
21742
|
-
if (i === passes - 1 && lastAlpha < 1) {
|
|
21743
|
-
extra.setAttribute("opacity", String(baseOpacity * lastAlpha));
|
|
21744
|
-
}
|
|
21745
|
-
(_f = img.parentNode) == null ? void 0 : _f.insertBefore(extra, img.nextSibling);
|
|
21746
|
-
}
|
|
21747
|
-
if (passes === 1 && lastAlpha < 1) {
|
|
21748
|
-
img.setAttribute("opacity", String(baseOpacity * lastAlpha));
|
|
21749
|
-
}
|
|
21750
21697
|
} catch (e) {
|
|
21751
21698
|
console.warn("[pdf-export] rasterizeShadowMarkers failed for one marker:", e);
|
|
21752
21699
|
try {
|
|
21753
|
-
(
|
|
21700
|
+
(_f = marker.parentNode) == null ? void 0 : _f.removeChild(marker);
|
|
21754
21701
|
} catch {
|
|
21755
21702
|
}
|
|
21756
21703
|
}
|
|
@@ -21951,7 +21898,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
21951
21898
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
21952
21899
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
21953
21900
|
try {
|
|
21954
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
21901
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CjIUU8on.js");
|
|
21955
21902
|
try {
|
|
21956
21903
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
21957
21904
|
} catch {
|
|
@@ -22351,4 +22298,4 @@ export {
|
|
|
22351
22298
|
buildTeaserBlurFlatKeys as y,
|
|
22352
22299
|
collectFontDescriptorsFromConfig as z
|
|
22353
22300
|
};
|
|
22354
|
-
//# sourceMappingURL=index-
|
|
22301
|
+
//# sourceMappingURL=index-CDdfs3IB.js.map
|