@pixldocs/canvas-renderer 0.5.480 → 0.5.481

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.
@@ -819,6 +819,12 @@ function getNodeLeft(node) {
819
819
  function getNodeTop(node) {
820
820
  return typeof node.top === "number" ? node.top : 0;
821
821
  }
822
+ function getStackMainAnchorOffset(node, mainSize) {
823
+ const anchor = node.stackAnchor;
824
+ if (anchor === "center") return mainSize / 2;
825
+ if (anchor === "end") return mainSize;
826
+ return 0;
827
+ }
822
828
  function resolveStackGroupEffectivePositions(group, pageChildren, options) {
823
829
  const mode = group.layoutMode ?? "absolute";
824
830
  if (!isStackLayoutMode(mode)) return /* @__PURE__ */ new Map();
@@ -848,8 +854,10 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
848
854
  const mLeft = child.marginLeft ?? 0;
849
855
  const hugAdjust = getVerticalHugTextAdjust(group, child);
850
856
  const hugTopOffset = hugAdjust ? hugAdjust.topOffset : 0;
857
+ const h = hugAdjust ? hugAdjust.glyphHeight : sizes.get(child.id).height;
858
+ const anchorOffset = getStackMainAnchorOffset(child, h);
851
859
  const visualTop = !firstSeen ? padTop + storedTop + mTop : prevBottom + gap + storedTop + mTop;
852
- const effectiveTop = firstSeen ? visualTop : visualTop - hugTopOffset;
860
+ const effectiveTop = visualTop - anchorOffset - hugTopOffset;
853
861
  if (firstSeen && hugTopOffset > 0 && placedIds.length > 0) {
854
862
  for (const placedId of placedIds) {
855
863
  const placed = out.get(placedId);
@@ -858,7 +866,6 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
858
866
  }
859
867
  firstSeen = true;
860
868
  out.set(child.id, { top: effectiveTop, left: padLeft + storedLeft + mLeft });
861
- const h = hugAdjust ? hugAdjust.glyphHeight : sizes.get(child.id).height;
862
869
  prevBottom = effectiveTop + hugTopOffset + h + (child.marginBottom ?? 0);
863
870
  placedIds.push(child.id);
864
871
  }
@@ -871,10 +878,11 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
871
878
  const storedTop = getNodeTop(child);
872
879
  const mTop = child.marginTop ?? 0;
873
880
  const mLeft = child.marginLeft ?? 0;
874
- const effectiveLeft = !firstSeen ? padLeft + storedLeft + mLeft : prevRight + gap + storedLeft + mLeft;
881
+ const w = sizes.get(child.id).width;
882
+ const anchorOffset = getStackMainAnchorOffset(child, w);
883
+ const effectiveLeft = (!firstSeen ? padLeft + storedLeft + mLeft : prevRight + gap + storedLeft + mLeft) - anchorOffset;
875
884
  firstSeen = true;
876
885
  out.set(child.id, { top: padTop + storedTop + mTop, left: effectiveLeft });
877
- const w = sizes.get(child.id).width;
878
886
  prevRight = effectiveLeft + w + (child.marginRight ?? 0);
879
887
  }
880
888
  }
@@ -980,13 +988,14 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
980
988
  const pos = out.get(child.id);
981
989
  if (!pos) continue;
982
990
  const startMain = cursor + marginStart;
991
+ const anchorOffset = getStackMainAnchorOffset(child, main);
983
992
  if (isVertical) {
984
993
  const hugAdjust = getVerticalHugTextAdjust(group, child);
985
- out.set(child.id, { top: startMain - ((hugAdjust == null ? void 0 : hugAdjust.topOffset) ?? 0), left: pos.left });
994
+ out.set(child.id, { top: startMain - anchorOffset - ((hugAdjust == null ? void 0 : hugAdjust.topOffset) ?? 0), left: pos.left });
986
995
  } else {
987
- out.set(child.id, { top: pos.top, left: startMain });
996
+ out.set(child.id, { top: pos.top, left: startMain - anchorOffset });
988
997
  }
989
- cursor = startMain + main + marginEnd + gap + extraGap;
998
+ cursor = startMain - anchorOffset + main + marginEnd + gap + extraGap;
990
999
  }
991
1000
  }
992
1001
  }
@@ -26384,9 +26393,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26384
26393
  }
26385
26394
  return svgString;
26386
26395
  }
26387
- const resolvedPackageVersion = "0.5.480";
26396
+ const resolvedPackageVersion = "0.5.481";
26388
26397
  const PACKAGE_VERSION = resolvedPackageVersion;
26389
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.480";
26398
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.481";
26390
26399
  const roundParityValue = (value) => {
26391
26400
  if (typeof value !== "number") return value;
26392
26401
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27200,7 +27209,7 @@ class PixldocsRenderer {
27200
27209
  await this.waitForCanvasScene(container, cloned, i);
27201
27210
  }
27202
27211
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27203
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-8y-rUG9Q.cjs"));
27212
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-VuNMn-Mu.cjs"));
27204
27213
  const prepared = preparePagesForExport(
27205
27214
  cloned.pages,
27206
27215
  canvasWidth,
@@ -29520,7 +29529,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29520
29529
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29521
29530
  sanitizeSvgTreeForPdf(svgToDraw);
29522
29531
  try {
29523
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-8y-rUG9Q.cjs"));
29532
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-VuNMn-Mu.cjs"));
29524
29533
  try {
29525
29534
  await logTextMeasurementDiagnostic(svgToDraw);
29526
29535
  } catch {
@@ -29834,4 +29843,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29834
29843
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29835
29844
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29836
29845
  exports.warmTemplateFromForm = warmTemplateFromForm;
29837
- //# sourceMappingURL=index-BvNexoyT.cjs.map
29846
+ //# sourceMappingURL=index-C-V0iK3K.cjs.map