@pixldocs/canvas-renderer 0.5.238 → 0.5.240
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-CTr4Fc8y.js → index-B2H1tQ0S.js} +34 -5
- package/dist/index-B2H1tQ0S.js.map +1 -0
- package/dist/{index-5DJXGPPs.cjs → index-DBOS1ouN.cjs} +34 -5
- package/dist/index-DBOS1ouN.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-BIPt7Ujn.js → vectorPdfExport-CHVrwSi7.js} +4 -4
- package/dist/{vectorPdfExport-BIPt7Ujn.js.map → vectorPdfExport-CHVrwSi7.js.map} +1 -1
- package/dist/{vectorPdfExport-CFbPBurt.cjs → vectorPdfExport-D1yCN3sm.cjs} +4 -4
- package/dist/{vectorPdfExport-CFbPBurt.cjs.map → vectorPdfExport-D1yCN3sm.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-5DJXGPPs.cjs.map +0 -1
- package/dist/index-CTr4Fc8y.js.map +0 -1
|
@@ -7442,6 +7442,31 @@ function buildRoundedRectPath2D(ctx, x, y, w, h, rTL, rTR, rBR, rBL) {
|
|
|
7442
7442
|
if (tl > 0) ctx.quadraticCurveTo(x, y, x + tl, y);
|
|
7443
7443
|
ctx.closePath();
|
|
7444
7444
|
}
|
|
7445
|
+
function measureLineGlyphWidth(obj, lineIndex) {
|
|
7446
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
7447
|
+
try {
|
|
7448
|
+
const rawLine = (_a2 = obj == null ? void 0 : obj._textLines) == null ? void 0 : _a2[lineIndex];
|
|
7449
|
+
const lineText = Array.isArray(rawLine) ? rawLine.join("") : String(rawLine ?? "");
|
|
7450
|
+
if (!lineText) return 0;
|
|
7451
|
+
const fontSize = Number(((_b = obj.getValueOfPropertyAt) == null ? void 0 : _b.call(obj, lineIndex, 0, "fontSize")) ?? obj.fontSize ?? 0);
|
|
7452
|
+
if (!fontSize) return 0;
|
|
7453
|
+
const fontStyle = String(((_c = obj.getValueOfPropertyAt) == null ? void 0 : _c.call(obj, lineIndex, 0, "fontStyle")) ?? obj.fontStyle ?? "normal");
|
|
7454
|
+
const fontWeight = String(((_d = obj.getValueOfPropertyAt) == null ? void 0 : _d.call(obj, lineIndex, 0, "fontWeight")) ?? obj.fontWeight ?? "400");
|
|
7455
|
+
const fontFamily = String(((_e = obj.getValueOfPropertyAt) == null ? void 0 : _e.call(obj, lineIndex, 0, "fontFamily")) ?? obj.fontFamily ?? "sans-serif");
|
|
7456
|
+
const charSpacing = Number(((_f = obj.getValueOfPropertyAt) == null ? void 0 : _f.call(obj, lineIndex, 0, "charSpacing")) ?? obj.charSpacing ?? 0);
|
|
7457
|
+
if (typeof document === "undefined") return 0;
|
|
7458
|
+
const off = document.createElement("canvas");
|
|
7459
|
+
const ctx = off.getContext("2d");
|
|
7460
|
+
if (!ctx) return 0;
|
|
7461
|
+
ctx.font = `${fontStyle} normal ${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
7462
|
+
const measured = ctx.measureText(lineText).width;
|
|
7463
|
+
const graphemeCount = Array.from(lineText).length;
|
|
7464
|
+
const spacingWidth = graphemeCount > 1 ? charSpacing / 1e3 * fontSize * (graphemeCount - 1) : 0;
|
|
7465
|
+
return Math.max(0, measured + spacingWidth);
|
|
7466
|
+
} catch {
|
|
7467
|
+
return 0;
|
|
7468
|
+
}
|
|
7469
|
+
}
|
|
7445
7470
|
function applyTextBackground(obj, cfg) {
|
|
7446
7471
|
var _a2;
|
|
7447
7472
|
obj[PD_BG_KEY] = { ...cfg };
|
|
@@ -8046,6 +8071,10 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit, lineFullWidth = false) {
|
|
|
8046
8071
|
} catch {
|
|
8047
8072
|
lineH = 0;
|
|
8048
8073
|
}
|
|
8074
|
+
if (fit && !lineFullWidth) {
|
|
8075
|
+
const measured = measureLineGlyphWidth(obj, i);
|
|
8076
|
+
if (measured > 0) lineW = measured;
|
|
8077
|
+
}
|
|
8049
8078
|
const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
|
|
8050
8079
|
const usedH = cursorY + halfH;
|
|
8051
8080
|
const remaining = h - usedH;
|
|
@@ -21121,9 +21150,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
21121
21150
|
}
|
|
21122
21151
|
return svgString;
|
|
21123
21152
|
}
|
|
21124
|
-
const resolvedPackageVersion = "0.5.
|
|
21153
|
+
const resolvedPackageVersion = "0.5.240";
|
|
21125
21154
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
21126
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
21155
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.240";
|
|
21127
21156
|
const roundParityValue = (value) => {
|
|
21128
21157
|
if (typeof value !== "number") return value;
|
|
21129
21158
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -21870,7 +21899,7 @@ class PixldocsRenderer {
|
|
|
21870
21899
|
await this.waitForCanvasScene(container, cloned, i);
|
|
21871
21900
|
}
|
|
21872
21901
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
21873
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
21902
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CHVrwSi7.js");
|
|
21874
21903
|
const prepared = preparePagesForExport(
|
|
21875
21904
|
cloned.pages,
|
|
21876
21905
|
canvasWidth,
|
|
@@ -24190,7 +24219,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
24190
24219
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
24191
24220
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
24192
24221
|
try {
|
|
24193
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
24222
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CHVrwSi7.js");
|
|
24194
24223
|
try {
|
|
24195
24224
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
24196
24225
|
} catch {
|
|
@@ -24590,4 +24619,4 @@ export {
|
|
|
24590
24619
|
buildTeaserBlurFlatKeys as y,
|
|
24591
24620
|
collectFontDescriptorsFromConfig as z
|
|
24592
24621
|
};
|
|
24593
|
-
//# sourceMappingURL=index-
|
|
24622
|
+
//# sourceMappingURL=index-B2H1tQ0S.js.map
|