@pixldocs/canvas-renderer 0.5.483 → 0.5.485

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.
@@ -804,6 +804,9 @@ function simpleWidth(node) {
804
804
  function simpleHeight(node) {
805
805
  if (isElement(node)) {
806
806
  const el = node;
807
+ if (el.type === "line") {
808
+ return Math.max(1, Number(el.strokeWidth) || Number(el.height) || 1);
809
+ }
807
810
  const h = el.height;
808
811
  if (typeof h === "number") return h;
809
812
  if (el.type === "text" && el.text) {
@@ -10093,12 +10096,28 @@ function createText(element) {
10093
10096
  applyTextShadow(textbox, element);
10094
10097
  return textbox;
10095
10098
  }
10099
+ function getLineVisualGeometry(element) {
10100
+ const visualWidth = Math.max(1, Number(element.width) * (element.scaleX ?? 1) || 100);
10101
+ const strokeWidth = Math.max(0, Number(element.strokeWidth) || 2);
10102
+ const capInset = Math.min(visualWidth / 2, strokeWidth / 2);
10103
+ return {
10104
+ x1: capInset,
10105
+ y1: 0,
10106
+ x2: Math.max(capInset, visualWidth - capInset),
10107
+ y2: 0,
10108
+ visualWidth,
10109
+ strokeWidth
10110
+ };
10111
+ }
10096
10112
  function createLine(element) {
10097
- const lineLength = element.width * (element.scaleX ?? 1);
10098
- return new fabric__namespace.Line([0, 0, lineLength, 0], {
10113
+ const g = getLineVisualGeometry(element);
10114
+ return new fabric__namespace.Line([g.x1, g.y1, g.x2, g.y2], {
10099
10115
  stroke: element.stroke || "#1a1a1a",
10100
- strokeWidth: element.strokeWidth || 2,
10116
+ strokeWidth: g.strokeWidth,
10101
10117
  strokeDashArray: element.strokeDashArray,
10118
+ strokeLineCap: "round",
10119
+ strokeLineJoin: "round",
10120
+ strokeUniform: true,
10102
10121
  scaleX: 1,
10103
10122
  scaleY: 1
10104
10123
  });
@@ -16175,9 +16194,10 @@ const PageCanvas = react.forwardRef(
16175
16194
  } else if (obj instanceof fabric__namespace.Line) {
16176
16195
  const x1 = obj.x1 ?? 0, y1 = obj.y1 ?? 0, x2 = obj.x2 ?? 0, y2 = obj.y2 ?? 0;
16177
16196
  const rawLen = Math.hypot(x2 - x1, y2 - y1);
16197
+ const sw = Math.max(0, Number(obj.strokeWidth ?? (sourceElement == null ? void 0 : sourceElement.strokeWidth) ?? 0) || 0);
16178
16198
  const ownScaleX = obj.scaleX ?? 1;
16179
16199
  const selScaleX = isActiveSelection && activeObj ? Math.abs(activeObj.scaleX ?? 1) : 1;
16180
- intrinsicWidth = rawLen * Math.abs(ownScaleX) * selScaleX;
16200
+ intrinsicWidth = rawLen * Math.abs(ownScaleX) * selScaleX + sw;
16181
16201
  intrinsicHeight = 0;
16182
16202
  } else {
16183
16203
  intrinsicWidth = obj.width ?? 0;
@@ -18823,23 +18843,21 @@ const PageCanvas = react.forwardRef(
18823
18843
  const baseScaleY = isImage && element.imageFit === "fill" ? rH / ((obj.height ?? 1) || 1) : 1;
18824
18844
  const isLine = obj instanceof fabric__namespace.Line;
18825
18845
  if (isLine) {
18826
- const lineLen = Math.max(1, Number(element.width) || rW || 100);
18827
- const lineSet = {
18828
- x1: 0,
18829
- y1: 0,
18830
- x2: lineLen,
18831
- y2: 0,
18846
+ const lineGeometry = getLineVisualGeometry(element);
18847
+ obj.set({
18848
+ x1: lineGeometry.x1,
18849
+ y1: lineGeometry.y1,
18850
+ x2: lineGeometry.x2,
18851
+ y2: lineGeometry.y2,
18832
18852
  angle: element.angle ?? 0,
18833
18853
  scaleX: 1,
18834
18854
  scaleY: 1,
18835
18855
  skewX: 0,
18836
18856
  skewY: 0
18837
- };
18857
+ });
18838
18858
  if (!skipPositionUpdate) {
18839
- lineSet.left = fabricPos.left;
18840
- lineSet.top = fabricPos.top;
18859
+ obj.set({ left: fabricPos.left, top: fabricPos.top });
18841
18860
  }
18842
- obj.set(lineSet);
18843
18861
  obj.setCoords();
18844
18862
  }
18845
18863
  if (!isLine) {
@@ -19347,14 +19365,23 @@ const PageCanvas = react.forwardRef(
19347
19365
  if (fcShape) fcShape.renderAll();
19348
19366
  }
19349
19367
  if (isLine) {
19368
+ const lineGeometry = getLineVisualGeometry(element);
19369
+ const prevLeft = obj.left;
19370
+ const prevTop = obj.top;
19350
19371
  obj.set({
19372
+ x1: lineGeometry.x1,
19373
+ y1: lineGeometry.y1,
19374
+ x2: lineGeometry.x2,
19375
+ y2: lineGeometry.y2,
19351
19376
  stroke: element.stroke || "#1a1a1a",
19352
- strokeWidth: typeof element.strokeWidth === "number" ? element.strokeWidth : 2,
19377
+ strokeWidth: lineGeometry.strokeWidth,
19353
19378
  strokeUniform: true,
19354
19379
  strokeLineCap: "round",
19355
19380
  strokeLineJoin: "round",
19356
19381
  ...element.strokeDashArray && { strokeDashArray: element.strokeDashArray }
19357
19382
  });
19383
+ obj.set({ left: prevLeft, top: prevTop });
19384
+ obj.setCoords();
19358
19385
  }
19359
19386
  if (element.fillGradient && isGradientConfig(element.fillGradient)) {
19360
19387
  const objWidth = typeof obj.width === "number" ? obj.width : rW;
@@ -26393,9 +26420,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26393
26420
  }
26394
26421
  return svgString;
26395
26422
  }
26396
- const resolvedPackageVersion = "0.5.483";
26423
+ const resolvedPackageVersion = "0.5.485";
26397
26424
  const PACKAGE_VERSION = resolvedPackageVersion;
26398
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.483";
26425
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.485";
26399
26426
  const roundParityValue = (value) => {
26400
26427
  if (typeof value !== "number") return value;
26401
26428
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27209,7 +27236,7 @@ class PixldocsRenderer {
27209
27236
  await this.waitForCanvasScene(container, cloned, i);
27210
27237
  }
27211
27238
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27212
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D7rfsr1y.cjs"));
27239
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-pylbB5Ls.cjs"));
27213
27240
  const prepared = preparePagesForExport(
27214
27241
  cloned.pages,
27215
27242
  canvasWidth,
@@ -29529,7 +29556,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29529
29556
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29530
29557
  sanitizeSvgTreeForPdf(svgToDraw);
29531
29558
  try {
29532
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D7rfsr1y.cjs"));
29559
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-pylbB5Ls.cjs"));
29533
29560
  try {
29534
29561
  await logTextMeasurementDiagnostic(svgToDraw);
29535
29562
  } catch {
@@ -29843,4 +29870,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29843
29870
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29844
29871
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29845
29872
  exports.warmTemplateFromForm = warmTemplateFromForm;
29846
- //# sourceMappingURL=index-Cb2oeGs6.cjs.map
29873
+ //# sourceMappingURL=index-DG8BpcY2.cjs.map