@pixldocs/canvas-renderer 0.5.150 → 0.5.151
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-CczB1vpO.cjs → index-Clvky1Ne.cjs} +62 -9
- package/dist/index-Clvky1Ne.cjs.map +1 -0
- package/dist/{index-khnxviCH.js → index-Dp8yJxTW.js} +62 -9
- package/dist/index-Dp8yJxTW.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{svgTextToPath-ws6Fh3rx.js → svgTextToPath-BE8TxgiO.js} +2 -2
- package/dist/svgTextToPath-BE8TxgiO.js.map +1 -0
- package/dist/{svgTextToPath-DolCNU9g.cjs → svgTextToPath-qhinMiiS.cjs} +2 -2
- package/dist/svgTextToPath-qhinMiiS.cjs.map +1 -0
- package/dist/{vectorPdfExport-qAWd8i87.cjs → vectorPdfExport-BEohav7Y.cjs} +7 -7
- package/dist/vectorPdfExport-BEohav7Y.cjs.map +1 -0
- package/dist/{vectorPdfExport-CDnEStQk.js → vectorPdfExport-TF3IGImZ.js} +7 -7
- package/dist/vectorPdfExport-TF3IGImZ.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-CczB1vpO.cjs.map +0 -1
- package/dist/index-khnxviCH.js.map +0 -1
- package/dist/svgTextToPath-DolCNU9g.cjs.map +0 -1
- package/dist/svgTextToPath-ws6Fh3rx.js.map +0 -1
- package/dist/vectorPdfExport-CDnEStQk.js.map +0 -1
- package/dist/vectorPdfExport-qAWd8i87.cjs.map +0 -1
|
@@ -5711,6 +5711,7 @@ function applyTextBackground(obj, cfg) {
|
|
|
5711
5711
|
const bgPath = hasBg ? `<path d="${bgD}" fill="${escapeXmlAttr(bgFill)}"${bgOpacityAttr} />` : "";
|
|
5712
5712
|
svg = svg.replace(/style="[^"]*filter:\s*url\([^)]+\)[^"]*"/i, "");
|
|
5713
5713
|
svg = svg.replace(/<filter[\s\S]*?<\/filter>/gi, "");
|
|
5714
|
+
svg = bakeTextSvgToFabricLineStarts(svg, this, w);
|
|
5714
5715
|
let bgShadowMarker = "";
|
|
5715
5716
|
let textShadowMarker = "";
|
|
5716
5717
|
if (hasShadow) {
|
|
@@ -5743,17 +5744,69 @@ function applyTextBackground(obj, cfg) {
|
|
|
5743
5744
|
const openTagMatch = svg.match(/^\s*<g\b[^>]*>/);
|
|
5744
5745
|
const inserted = bgShadowMarker + bgPath + textShadowMarker;
|
|
5745
5746
|
const shadowBlur = hasShadow ? Math.max(0, Number(shadow.blur ?? 0)) : 0;
|
|
5746
|
-
const
|
|
5747
|
+
const decorationTags = [
|
|
5748
|
+
shadowBlur > 0 ? 'data-pd-shadow-blur="1"' : "",
|
|
5749
|
+
hasBg ? 'data-pd-text-bg="1"' : ""
|
|
5750
|
+
].filter(Boolean).join(" ");
|
|
5751
|
+
const decorationAttr = decorationTags ? ` ${decorationTags}` : "";
|
|
5747
5752
|
if (openTagMatch) {
|
|
5748
5753
|
const openTag = openTagMatch[0];
|
|
5749
|
-
const taggedOpenTag =
|
|
5754
|
+
const taggedOpenTag = decorationAttr ? openTag.replace(/^<g\b/, `<g${decorationAttr}`).replace(/\s(data-pd-shadow-blur="1")(?=[^>]*\s\1)/i, "").replace(/\s(data-pd-text-bg="1")(?=[^>]*\s\1)/i, "") : openTag;
|
|
5750
5755
|
return svg.replace(openTag, taggedOpenTag + inserted);
|
|
5751
5756
|
}
|
|
5752
|
-
return `<g${
|
|
5757
|
+
return `<g${decorationAttr}>${inserted}${svg}</g>`;
|
|
5753
5758
|
};
|
|
5754
5759
|
}
|
|
5755
5760
|
}
|
|
5756
5761
|
function recolorSvgFills(svg, color) {
|
|
5762
|
+
return _recolorSvgFills(svg, color);
|
|
5763
|
+
}
|
|
5764
|
+
function bakeTextSvgToFabricLineStarts(svg, obj, w) {
|
|
5765
|
+
var _a;
|
|
5766
|
+
try {
|
|
5767
|
+
const lines = (obj == null ? void 0 : obj._textLines) ?? [];
|
|
5768
|
+
if (!Array.isArray(lines) || lines.length === 0) return svg;
|
|
5769
|
+
const halfW = w / 2;
|
|
5770
|
+
const lineXs = [];
|
|
5771
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5772
|
+
let lineLeft = 0;
|
|
5773
|
+
try {
|
|
5774
|
+
lineLeft = ((_a = obj._getLineLeftOffset) == null ? void 0 : _a.call(obj, i)) ?? 0;
|
|
5775
|
+
} catch {
|
|
5776
|
+
lineLeft = 0;
|
|
5777
|
+
}
|
|
5778
|
+
lineXs.push(-halfW + (Number.isFinite(lineLeft) ? lineLeft : 0));
|
|
5779
|
+
}
|
|
5780
|
+
const textOpenRe = /<text\b([^>]*)>/i;
|
|
5781
|
+
const textOpenMatch = svg.match(textOpenRe);
|
|
5782
|
+
if (!textOpenMatch) return svg;
|
|
5783
|
+
let textAttrs = textOpenMatch[1];
|
|
5784
|
+
if (/\stext-anchor\s*=\s*"[^"]*"/i.test(textAttrs)) {
|
|
5785
|
+
textAttrs = textAttrs.replace(/\stext-anchor\s*=\s*"[^"]*"/i, ' text-anchor="start"');
|
|
5786
|
+
} else {
|
|
5787
|
+
textAttrs = ` text-anchor="start"${textAttrs}`;
|
|
5788
|
+
}
|
|
5789
|
+
textAttrs = textAttrs.replace(
|
|
5790
|
+
/(\sstyle=")([^"]*)(")/i,
|
|
5791
|
+
(_m, pre, val, post) => pre + val.replace(/text-align\s*:\s*[^;"']+;?/gi, "").trim() + post
|
|
5792
|
+
);
|
|
5793
|
+
const newTextOpen = `<text${textAttrs}>`;
|
|
5794
|
+
let lineIdx = 0;
|
|
5795
|
+
const newSvg = svg.replace(textOpenMatch[0], newTextOpen).replace(
|
|
5796
|
+
/<tspan\b([^>]*?)\sx="([^"]*)"([^>]*)>/gi,
|
|
5797
|
+
(_m, pre, _oldX, post) => {
|
|
5798
|
+
const x = lineXs[lineIdx];
|
|
5799
|
+
lineIdx += 1;
|
|
5800
|
+
if (typeof x !== "number" || !Number.isFinite(x)) return _m;
|
|
5801
|
+
return `<tspan${pre} x="${x.toFixed(3)}"${post}>`;
|
|
5802
|
+
}
|
|
5803
|
+
);
|
|
5804
|
+
return newSvg;
|
|
5805
|
+
} catch {
|
|
5806
|
+
return svg;
|
|
5807
|
+
}
|
|
5808
|
+
}
|
|
5809
|
+
function _recolorSvgFills(svg, color) {
|
|
5757
5810
|
const safe = escapeXmlAttr(color);
|
|
5758
5811
|
let out = svg.replace(
|
|
5759
5812
|
/(<(?:text|tspan|path|rect)\b[^>]*?\sfill=")([^"]*)("[^>]*>)/gi,
|
|
@@ -15974,9 +16027,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15974
16027
|
}
|
|
15975
16028
|
return svgString;
|
|
15976
16029
|
}
|
|
15977
|
-
const resolvedPackageVersion = "0.5.
|
|
16030
|
+
const resolvedPackageVersion = "0.5.151";
|
|
15978
16031
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
15979
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16032
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.151";
|
|
15980
16033
|
const roundParityValue = (value) => {
|
|
15981
16034
|
if (typeof value !== "number") return value;
|
|
15982
16035
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16411,7 +16464,7 @@ class PixldocsRenderer {
|
|
|
16411
16464
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16412
16465
|
}
|
|
16413
16466
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16414
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
16467
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BEohav7Y.cjs"));
|
|
16415
16468
|
const prepared = preparePagesForExport(
|
|
16416
16469
|
cloned.pages,
|
|
16417
16470
|
canvasWidth,
|
|
@@ -18513,7 +18566,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18513
18566
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18514
18567
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18515
18568
|
try {
|
|
18516
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
18569
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BEohav7Y.cjs"));
|
|
18517
18570
|
try {
|
|
18518
18571
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18519
18572
|
} catch {
|
|
@@ -18648,7 +18701,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
18648
18701
|
}
|
|
18649
18702
|
if (shouldOutlineText) {
|
|
18650
18703
|
try {
|
|
18651
|
-
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-
|
|
18704
|
+
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-qhinMiiS.cjs"));
|
|
18652
18705
|
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
18653
18706
|
try {
|
|
18654
18707
|
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|
|
@@ -18860,4 +18913,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
18860
18913
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
18861
18914
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
18862
18915
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
18863
|
-
//# sourceMappingURL=index-
|
|
18916
|
+
//# sourceMappingURL=index-Clvky1Ne.cjs.map
|