@pixldocs/canvas-renderer 0.5.212 → 0.5.213
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-B1QDVK5k.js → index-XZf4TDQ-.js} +80 -21
- package/dist/index-XZf4TDQ-.js.map +1 -0
- package/dist/{index-DB8j0PV0.cjs → index-zkVpb-YL.cjs} +80 -21
- package/dist/index-zkVpb-YL.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-zGrrm-iT.cjs → vectorPdfExport-krI8SwbX.cjs} +20 -6
- package/dist/vectorPdfExport-krI8SwbX.cjs.map +1 -0
- package/dist/{vectorPdfExport-CN-N0DE8.js → vectorPdfExport-ox1nl4G9.js} +20 -6
- package/dist/vectorPdfExport-ox1nl4G9.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-B1QDVK5k.js.map +0 -1
- package/dist/index-DB8j0PV0.cjs.map +0 -1
- package/dist/vectorPdfExport-CN-N0DE8.js.map +0 -1
- package/dist/vectorPdfExport-zGrrm-iT.cjs.map +0 -1
|
@@ -6902,8 +6902,9 @@ function buildTextShadow(element) {
|
|
|
6902
6902
|
if (!color || color === "transparent") return null;
|
|
6903
6903
|
const type = element.textShadowType;
|
|
6904
6904
|
if (type && type !== "drop") return null;
|
|
6905
|
-
const {
|
|
6906
|
-
const
|
|
6905
|
+
const { passAlphas } = resolveShadowStrength(element);
|
|
6906
|
+
const firstAlpha = passAlphas.length > 0 ? passAlphas[0] : 0;
|
|
6907
|
+
const finalColor = applyAlphaMultiplier(String(color), firstAlpha);
|
|
6907
6908
|
return new fabric__namespace.Shadow({
|
|
6908
6909
|
color: finalColor,
|
|
6909
6910
|
blur: blur || 0,
|
|
@@ -6915,25 +6916,66 @@ function buildTextShadow(element) {
|
|
|
6915
6916
|
}
|
|
6916
6917
|
function resolveShadowStrength(element) {
|
|
6917
6918
|
const raw = element.textShadowStrength;
|
|
6918
|
-
const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) :
|
|
6919
|
-
if (s <= 0) return {
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6919
|
+
const s = typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) : 33.34;
|
|
6920
|
+
if (s <= 0) return { passAlphas: [] };
|
|
6921
|
+
const intensity = Math.min(3, s / 33.34);
|
|
6922
|
+
if (intensity <= 1) return { passAlphas: [intensity] };
|
|
6923
|
+
const full = Math.floor(intensity);
|
|
6924
|
+
const frac = intensity - full;
|
|
6925
|
+
const arr = new Array(full).fill(1);
|
|
6926
|
+
if (frac > 0.01) arr.push(frac);
|
|
6927
|
+
return { passAlphas: arr };
|
|
6923
6928
|
}
|
|
6924
6929
|
function applyTextShadow(textbox, element) {
|
|
6925
|
-
const
|
|
6926
|
-
const {
|
|
6930
|
+
const canonicalShadow = buildTextShadow(element);
|
|
6931
|
+
const { passAlphas } = resolveShadowStrength(element);
|
|
6932
|
+
const baseColor = element.textShadowColor;
|
|
6933
|
+
const blur = Number(element.textShadowBlur ?? 0) || 0;
|
|
6934
|
+
const ox = Number(element.textShadowOffsetX ?? 0) || 0;
|
|
6935
|
+
const oy = Number(element.textShadowOffsetY ?? 0) || 0;
|
|
6936
|
+
const hasShadow = !!canonicalShadow && passAlphas.length > 0;
|
|
6927
6937
|
const obj = textbox;
|
|
6928
6938
|
if (!obj.__pdShadowOrigRender) {
|
|
6929
6939
|
obj.__pdShadowOrigRender = obj.render.bind(obj);
|
|
6930
6940
|
obj.render = function(ctx) {
|
|
6931
|
-
const
|
|
6932
|
-
|
|
6941
|
+
const alphas = obj.__pdShadowPassAlphas;
|
|
6942
|
+
if (!alphas || alphas.length <= 1) {
|
|
6943
|
+
obj.__pdShadowOrigRender(ctx);
|
|
6944
|
+
return;
|
|
6945
|
+
}
|
|
6946
|
+
const orig = obj.shadow;
|
|
6947
|
+
const baseC = obj.__pdShadowBaseColor || "#000";
|
|
6948
|
+
const b = obj.__pdShadowBlur || 0;
|
|
6949
|
+
const x = obj.__pdShadowOX || 0;
|
|
6950
|
+
const y = obj.__pdShadowOY || 0;
|
|
6951
|
+
for (let i = 0; i < alphas.length; i++) {
|
|
6952
|
+
obj.shadow = new fabric__namespace.Shadow({
|
|
6953
|
+
color: applyAlphaMultiplier(String(baseC), alphas[i]),
|
|
6954
|
+
blur: b,
|
|
6955
|
+
offsetX: x,
|
|
6956
|
+
offsetY: y,
|
|
6957
|
+
affectStroke: false,
|
|
6958
|
+
nonScaling: false
|
|
6959
|
+
});
|
|
6960
|
+
obj.__pdShadowOrigRender(ctx);
|
|
6961
|
+
}
|
|
6962
|
+
obj.shadow = orig;
|
|
6933
6963
|
};
|
|
6934
6964
|
}
|
|
6935
|
-
|
|
6936
|
-
|
|
6965
|
+
if (hasShadow) {
|
|
6966
|
+
obj.__pdShadowPassAlphas = passAlphas;
|
|
6967
|
+
obj.__pdShadowBaseColor = baseColor;
|
|
6968
|
+
obj.__pdShadowBlur = blur;
|
|
6969
|
+
obj.__pdShadowOX = ox;
|
|
6970
|
+
obj.__pdShadowOY = oy;
|
|
6971
|
+
obj.__pdShadowPasses = passAlphas.length;
|
|
6972
|
+
obj.__pdShadowLastAlpha = passAlphas[passAlphas.length - 1];
|
|
6973
|
+
} else {
|
|
6974
|
+
obj.__pdShadowPassAlphas = void 0;
|
|
6975
|
+
obj.__pdShadowPasses = 0;
|
|
6976
|
+
obj.__pdShadowLastAlpha = 1;
|
|
6977
|
+
}
|
|
6978
|
+
textbox.set("shadow", canonicalShadow ?? null);
|
|
6937
6979
|
}
|
|
6938
6980
|
function applyAlphaMultiplier(c, mult) {
|
|
6939
6981
|
const m = Math.max(0, Math.min(1, mult));
|
|
@@ -7314,7 +7356,10 @@ function applyTextBackground(obj, cfg) {
|
|
|
7314
7356
|
const by = shadowBounds.y - pad;
|
|
7315
7357
|
const bw = shadowBounds.w + pad * 2;
|
|
7316
7358
|
const bh = shadowBounds.h + pad * 2;
|
|
7317
|
-
const
|
|
7359
|
+
const passes = Math.max(1, Math.min(8, Number(this.__pdShadowPasses) || 1));
|
|
7360
|
+
const lastAlphaRaw = Number(this.__pdShadowLastAlpha);
|
|
7361
|
+
const lastAlpha = Number.isFinite(lastAlphaRaw) ? Math.max(0, Math.min(1, lastAlphaRaw)) : 1;
|
|
7362
|
+
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)}"`;
|
|
7318
7363
|
const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
|
|
7319
7364
|
if (hasBg && (bg == null ? void 0 : bg.shadowAffectsBg) !== false) {
|
|
7320
7365
|
const shadowOpacityAttr = bgOpacity < 1 ? ` fill-opacity="${bgOpacity}"` : "";
|
|
@@ -19030,9 +19075,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
19030
19075
|
}
|
|
19031
19076
|
return svgString;
|
|
19032
19077
|
}
|
|
19033
|
-
const resolvedPackageVersion = "0.5.
|
|
19078
|
+
const resolvedPackageVersion = "0.5.213";
|
|
19034
19079
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
19035
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
19080
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.213";
|
|
19036
19081
|
const roundParityValue = (value) => {
|
|
19037
19082
|
if (typeof value !== "number") return value;
|
|
19038
19083
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -19724,7 +19769,7 @@ class PixldocsRenderer {
|
|
|
19724
19769
|
await this.waitForCanvasScene(container, cloned, i);
|
|
19725
19770
|
}
|
|
19726
19771
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
19727
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
19772
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-krI8SwbX.cjs"));
|
|
19728
19773
|
const prepared = preparePagesForExport(
|
|
19729
19774
|
cloned.pages,
|
|
19730
19775
|
canvasWidth,
|
|
@@ -21646,7 +21691,7 @@ async function convertSvgTextDecorationsToLinesString(svgStr) {
|
|
|
21646
21691
|
}
|
|
21647
21692
|
}
|
|
21648
21693
|
async function rasterizeShadowMarkers(svg) {
|
|
21649
|
-
var _a, _b, _c, _d, _e, _f;
|
|
21694
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
21650
21695
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
21651
21696
|
const markers = Array.from(svg.querySelectorAll("g.__pdShadowRaster"));
|
|
21652
21697
|
if (markers.length === 0) return;
|
|
@@ -21705,11 +21750,25 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
21705
21750
|
img.setAttribute("preserveAspectRatio", "none");
|
|
21706
21751
|
img.setAttributeNS(XLINK_NS, "xlink:href", dataUrl);
|
|
21707
21752
|
img.setAttribute("href", dataUrl);
|
|
21753
|
+
const passes = Math.max(1, Math.min(8, parseInt(marker.getAttribute("data-passes") || "1", 10) || 1));
|
|
21754
|
+
const lastAlphaRaw = parseFloat(marker.getAttribute("data-last-alpha") || "1");
|
|
21755
|
+
const lastAlpha = Number.isFinite(lastAlphaRaw) ? Math.max(0, Math.min(1, lastAlphaRaw)) : 1;
|
|
21756
|
+
const baseOpacity = Number(img.getAttribute("opacity") || "1") || 1;
|
|
21708
21757
|
(_e = marker.parentNode) == null ? void 0 : _e.replaceChild(img, marker);
|
|
21758
|
+
for (let i = 1; i < passes; i++) {
|
|
21759
|
+
const extra = img.cloneNode(true);
|
|
21760
|
+
if (i === passes - 1 && lastAlpha < 1) {
|
|
21761
|
+
extra.setAttribute("opacity", String(baseOpacity * lastAlpha));
|
|
21762
|
+
}
|
|
21763
|
+
(_f = img.parentNode) == null ? void 0 : _f.insertBefore(extra, img.nextSibling);
|
|
21764
|
+
}
|
|
21765
|
+
if (passes === 1 && lastAlpha < 1) {
|
|
21766
|
+
img.setAttribute("opacity", String(baseOpacity * lastAlpha));
|
|
21767
|
+
}
|
|
21709
21768
|
} catch (e) {
|
|
21710
21769
|
console.warn("[pdf-export] rasterizeShadowMarkers failed for one marker:", e);
|
|
21711
21770
|
try {
|
|
21712
|
-
(
|
|
21771
|
+
(_g = marker.parentNode) == null ? void 0 : _g.removeChild(marker);
|
|
21713
21772
|
} catch {
|
|
21714
21773
|
}
|
|
21715
21774
|
}
|
|
@@ -21910,7 +21969,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
21910
21969
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
21911
21970
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
21912
21971
|
try {
|
|
21913
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
21972
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-krI8SwbX.cjs"));
|
|
21914
21973
|
try {
|
|
21915
21974
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
21916
21975
|
} catch {
|
|
@@ -22307,4 +22366,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
22307
22366
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
22308
22367
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
22309
22368
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
22310
|
-
//# sourceMappingURL=index-
|
|
22369
|
+
//# sourceMappingURL=index-zkVpb-YL.cjs.map
|