@pixldocs/canvas-renderer 0.5.161 → 0.5.162
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-Co0kEgTl.js → index-C6rEqM4R.js} +57 -5
- package/dist/{index-Co0kEgTl.js.map → index-C6rEqM4R.js.map} +1 -1
- package/dist/{index-OWSb_i03.cjs → index-D96xE7-z.cjs} +57 -5
- package/dist/{index-OWSb_i03.cjs.map → index-D96xE7-z.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-B_T8jiQ3.js → vectorPdfExport-C5vnOg8Q.js} +15 -5
- package/dist/vectorPdfExport-C5vnOg8Q.js.map +1 -0
- package/dist/{vectorPdfExport-CqdQi3YK.cjs → vectorPdfExport-KTzhlsHG.cjs} +15 -5
- package/dist/vectorPdfExport-KTzhlsHG.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/vectorPdfExport-B_T8jiQ3.js.map +0 -1
- package/dist/vectorPdfExport-CqdQi3YK.cjs.map +0 -1
|
@@ -15878,6 +15878,36 @@ function normalizeSvgDimensions(svg, targetWidth, targetHeight) {
|
|
|
15878
15878
|
}
|
|
15879
15879
|
return normalized;
|
|
15880
15880
|
}
|
|
15881
|
+
function isTextboxLike(obj) {
|
|
15882
|
+
return !!obj && (obj instanceof fabric.Textbox || obj.type === "textbox" || Array.isArray(obj == null ? void 0 : obj._textLines) && typeof obj.getLineWidth === "function");
|
|
15883
|
+
}
|
|
15884
|
+
function stampFabricLineMetricsOnTextSvg(svg, obj) {
|
|
15885
|
+
const lines = Array.isArray(obj == null ? void 0 : obj._textLines) ? obj._textLines : [];
|
|
15886
|
+
if (!lines.length || typeof (obj == null ? void 0 : obj.getLineWidth) !== "function") return svg;
|
|
15887
|
+
const boxWidth = Number(obj.width ?? 0) || 0;
|
|
15888
|
+
let lineIndex = 0;
|
|
15889
|
+
return svg.replace(/<tspan\b([^>]*)>/gi, (match, attrs) => {
|
|
15890
|
+
var _a;
|
|
15891
|
+
if (lineIndex >= lines.length || !/\sy\s*=/.test(attrs)) return match;
|
|
15892
|
+
let lineWidth = 0;
|
|
15893
|
+
let lineLeft = 0;
|
|
15894
|
+
try {
|
|
15895
|
+
lineWidth = Number(obj.getLineWidth(lineIndex) || 0);
|
|
15896
|
+
} catch {
|
|
15897
|
+
lineWidth = 0;
|
|
15898
|
+
}
|
|
15899
|
+
try {
|
|
15900
|
+
lineLeft = Number(((_a = obj._getLineLeftOffset) == null ? void 0 : _a.call(obj, lineIndex)) ?? 0);
|
|
15901
|
+
} catch {
|
|
15902
|
+
lineLeft = 0;
|
|
15903
|
+
}
|
|
15904
|
+
const lineStart = -boxWidth / 2 + lineLeft;
|
|
15905
|
+
lineIndex++;
|
|
15906
|
+
if (!Number.isFinite(lineWidth) || lineWidth <= 0 || !Number.isFinite(lineStart)) return match;
|
|
15907
|
+
const cleaned = attrs.replace(/\sdata-pd-line-width="[^"]*"/gi, "").replace(/\sdata-pd-line-start="[^"]*"/gi, "");
|
|
15908
|
+
return `<tspan${cleaned} data-pd-line-width="${Number(lineWidth.toFixed(3))}" data-pd-line-start="${Number(lineStart.toFixed(3))}">`;
|
|
15909
|
+
});
|
|
15910
|
+
}
|
|
15881
15911
|
function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight) {
|
|
15882
15912
|
const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
|
|
15883
15913
|
const prevSvgVPT = fabricInstance.svgViewportTransformation;
|
|
@@ -15894,6 +15924,22 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15894
15924
|
);
|
|
15895
15925
|
} catch {
|
|
15896
15926
|
}
|
|
15927
|
+
const textSvgPatchRecords = [];
|
|
15928
|
+
try {
|
|
15929
|
+
const visit = (obj) => {
|
|
15930
|
+
if (!obj) return;
|
|
15931
|
+
if (isTextboxLike(obj) && typeof obj.toSVG === "function") {
|
|
15932
|
+
const originalToSVG = obj.toSVG.bind(obj);
|
|
15933
|
+
obj.toSVG = (reviver) => stampFabricLineMetricsOnTextSvg(originalToSVG(reviver), obj);
|
|
15934
|
+
textSvgPatchRecords.push({ obj, originalToSVG });
|
|
15935
|
+
}
|
|
15936
|
+
const children = Array.isArray(obj == null ? void 0 : obj._objects) ? obj._objects : [];
|
|
15937
|
+
for (const child of children) visit(child);
|
|
15938
|
+
};
|
|
15939
|
+
for (const obj of fabricInstance.getObjects().slice()) visit(obj);
|
|
15940
|
+
} catch (e) {
|
|
15941
|
+
console.warn("[canvas-svg-capture][textMetrics] patch pass error:", e);
|
|
15942
|
+
}
|
|
15897
15943
|
const fadeBakeRecords = [];
|
|
15898
15944
|
try {
|
|
15899
15945
|
const objs = fabricInstance.getObjects().slice();
|
|
@@ -15950,6 +15996,12 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15950
15996
|
} catch {
|
|
15951
15997
|
}
|
|
15952
15998
|
}
|
|
15999
|
+
for (const rec of textSvgPatchRecords) {
|
|
16000
|
+
try {
|
|
16001
|
+
rec.obj.toSVG = rec.originalToSVG;
|
|
16002
|
+
} catch {
|
|
16003
|
+
}
|
|
16004
|
+
}
|
|
15953
16005
|
try {
|
|
15954
16006
|
fabricInstance.enableRetinaScaling = prevRetina;
|
|
15955
16007
|
fabricInstance.setDimensions(
|
|
@@ -15963,9 +16015,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15963
16015
|
}
|
|
15964
16016
|
return svgString;
|
|
15965
16017
|
}
|
|
15966
|
-
const resolvedPackageVersion = "0.5.
|
|
16018
|
+
const resolvedPackageVersion = "0.5.162";
|
|
15967
16019
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
15968
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16020
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.162";
|
|
15969
16021
|
const roundParityValue = (value) => {
|
|
15970
16022
|
if (typeof value !== "number") return value;
|
|
15971
16023
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16400,7 +16452,7 @@ class PixldocsRenderer {
|
|
|
16400
16452
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16401
16453
|
}
|
|
16402
16454
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16403
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
16455
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C5vnOg8Q.js");
|
|
16404
16456
|
const prepared = preparePagesForExport(
|
|
16405
16457
|
cloned.pages,
|
|
16406
16458
|
canvasWidth,
|
|
@@ -18502,7 +18554,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18502
18554
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18503
18555
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18504
18556
|
try {
|
|
18505
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
18557
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C5vnOg8Q.js");
|
|
18506
18558
|
try {
|
|
18507
18559
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18508
18560
|
} catch {
|
|
@@ -18852,4 +18904,4 @@ export {
|
|
|
18852
18904
|
collectFontDescriptorsFromConfig as y,
|
|
18853
18905
|
collectFontsFromConfig as z
|
|
18854
18906
|
};
|
|
18855
|
-
//# sourceMappingURL=index-
|
|
18907
|
+
//# sourceMappingURL=index-C6rEqM4R.js.map
|