@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
|
@@ -15896,6 +15896,36 @@ function normalizeSvgDimensions(svg, targetWidth, targetHeight) {
|
|
|
15896
15896
|
}
|
|
15897
15897
|
return normalized;
|
|
15898
15898
|
}
|
|
15899
|
+
function isTextboxLike(obj) {
|
|
15900
|
+
return !!obj && (obj instanceof fabric__namespace.Textbox || obj.type === "textbox" || Array.isArray(obj == null ? void 0 : obj._textLines) && typeof obj.getLineWidth === "function");
|
|
15901
|
+
}
|
|
15902
|
+
function stampFabricLineMetricsOnTextSvg(svg, obj) {
|
|
15903
|
+
const lines = Array.isArray(obj == null ? void 0 : obj._textLines) ? obj._textLines : [];
|
|
15904
|
+
if (!lines.length || typeof (obj == null ? void 0 : obj.getLineWidth) !== "function") return svg;
|
|
15905
|
+
const boxWidth = Number(obj.width ?? 0) || 0;
|
|
15906
|
+
let lineIndex = 0;
|
|
15907
|
+
return svg.replace(/<tspan\b([^>]*)>/gi, (match, attrs) => {
|
|
15908
|
+
var _a;
|
|
15909
|
+
if (lineIndex >= lines.length || !/\sy\s*=/.test(attrs)) return match;
|
|
15910
|
+
let lineWidth = 0;
|
|
15911
|
+
let lineLeft = 0;
|
|
15912
|
+
try {
|
|
15913
|
+
lineWidth = Number(obj.getLineWidth(lineIndex) || 0);
|
|
15914
|
+
} catch {
|
|
15915
|
+
lineWidth = 0;
|
|
15916
|
+
}
|
|
15917
|
+
try {
|
|
15918
|
+
lineLeft = Number(((_a = obj._getLineLeftOffset) == null ? void 0 : _a.call(obj, lineIndex)) ?? 0);
|
|
15919
|
+
} catch {
|
|
15920
|
+
lineLeft = 0;
|
|
15921
|
+
}
|
|
15922
|
+
const lineStart = -boxWidth / 2 + lineLeft;
|
|
15923
|
+
lineIndex++;
|
|
15924
|
+
if (!Number.isFinite(lineWidth) || lineWidth <= 0 || !Number.isFinite(lineStart)) return match;
|
|
15925
|
+
const cleaned = attrs.replace(/\sdata-pd-line-width="[^"]*"/gi, "").replace(/\sdata-pd-line-start="[^"]*"/gi, "");
|
|
15926
|
+
return `<tspan${cleaned} data-pd-line-width="${Number(lineWidth.toFixed(3))}" data-pd-line-start="${Number(lineStart.toFixed(3))}">`;
|
|
15927
|
+
});
|
|
15928
|
+
}
|
|
15899
15929
|
function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight) {
|
|
15900
15930
|
const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
|
|
15901
15931
|
const prevSvgVPT = fabricInstance.svgViewportTransformation;
|
|
@@ -15912,6 +15942,22 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15912
15942
|
);
|
|
15913
15943
|
} catch {
|
|
15914
15944
|
}
|
|
15945
|
+
const textSvgPatchRecords = [];
|
|
15946
|
+
try {
|
|
15947
|
+
const visit = (obj) => {
|
|
15948
|
+
if (!obj) return;
|
|
15949
|
+
if (isTextboxLike(obj) && typeof obj.toSVG === "function") {
|
|
15950
|
+
const originalToSVG = obj.toSVG.bind(obj);
|
|
15951
|
+
obj.toSVG = (reviver) => stampFabricLineMetricsOnTextSvg(originalToSVG(reviver), obj);
|
|
15952
|
+
textSvgPatchRecords.push({ obj, originalToSVG });
|
|
15953
|
+
}
|
|
15954
|
+
const children = Array.isArray(obj == null ? void 0 : obj._objects) ? obj._objects : [];
|
|
15955
|
+
for (const child of children) visit(child);
|
|
15956
|
+
};
|
|
15957
|
+
for (const obj of fabricInstance.getObjects().slice()) visit(obj);
|
|
15958
|
+
} catch (e) {
|
|
15959
|
+
console.warn("[canvas-svg-capture][textMetrics] patch pass error:", e);
|
|
15960
|
+
}
|
|
15915
15961
|
const fadeBakeRecords = [];
|
|
15916
15962
|
try {
|
|
15917
15963
|
const objs = fabricInstance.getObjects().slice();
|
|
@@ -15968,6 +16014,12 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15968
16014
|
} catch {
|
|
15969
16015
|
}
|
|
15970
16016
|
}
|
|
16017
|
+
for (const rec of textSvgPatchRecords) {
|
|
16018
|
+
try {
|
|
16019
|
+
rec.obj.toSVG = rec.originalToSVG;
|
|
16020
|
+
} catch {
|
|
16021
|
+
}
|
|
16022
|
+
}
|
|
15971
16023
|
try {
|
|
15972
16024
|
fabricInstance.enableRetinaScaling = prevRetina;
|
|
15973
16025
|
fabricInstance.setDimensions(
|
|
@@ -15981,9 +16033,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
15981
16033
|
}
|
|
15982
16034
|
return svgString;
|
|
15983
16035
|
}
|
|
15984
|
-
const resolvedPackageVersion = "0.5.
|
|
16036
|
+
const resolvedPackageVersion = "0.5.162";
|
|
15985
16037
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
15986
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16038
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.162";
|
|
15987
16039
|
const roundParityValue = (value) => {
|
|
15988
16040
|
if (typeof value !== "number") return value;
|
|
15989
16041
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16418,7 +16470,7 @@ class PixldocsRenderer {
|
|
|
16418
16470
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16419
16471
|
}
|
|
16420
16472
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16421
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
16473
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-KTzhlsHG.cjs"));
|
|
16422
16474
|
const prepared = preparePagesForExport(
|
|
16423
16475
|
cloned.pages,
|
|
16424
16476
|
canvasWidth,
|
|
@@ -18520,7 +18572,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18520
18572
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18521
18573
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18522
18574
|
try {
|
|
18523
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
18575
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-KTzhlsHG.cjs"));
|
|
18524
18576
|
try {
|
|
18525
18577
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18526
18578
|
} catch {
|
|
@@ -18867,4 +18919,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
18867
18919
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
18868
18920
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
18869
18921
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
18870
|
-
//# sourceMappingURL=index-
|
|
18922
|
+
//# sourceMappingURL=index-D96xE7-z.cjs.map
|