@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.
@@ -801,6 +801,12 @@ function getNodeLeft(node) {
801
801
  function getNodeTop(node) {
802
802
  return typeof node.top === "number" ? node.top : 0;
803
803
  }
804
+ function getStackMainAnchorOffset(node, mainSize) {
805
+ const anchor = node.stackAnchor;
806
+ if (anchor === "center") return mainSize / 2;
807
+ if (anchor === "end") return mainSize;
808
+ return 0;
809
+ }
804
810
  function resolveStackGroupEffectivePositions(group, pageChildren, options) {
805
811
  const mode = group.layoutMode ?? "absolute";
806
812
  if (!isStackLayoutMode(mode)) return /* @__PURE__ */ new Map();
@@ -830,8 +836,10 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
830
836
  const mLeft = child.marginLeft ?? 0;
831
837
  const hugAdjust = getVerticalHugTextAdjust(group, child);
832
838
  const hugTopOffset = hugAdjust ? hugAdjust.topOffset : 0;
839
+ const h = hugAdjust ? hugAdjust.glyphHeight : sizes.get(child.id).height;
840
+ const anchorOffset = getStackMainAnchorOffset(child, h);
833
841
  const visualTop = !firstSeen ? padTop + storedTop + mTop : prevBottom + gap + storedTop + mTop;
834
- const effectiveTop = firstSeen ? visualTop : visualTop - hugTopOffset;
842
+ const effectiveTop = visualTop - anchorOffset - hugTopOffset;
835
843
  if (firstSeen && hugTopOffset > 0 && placedIds.length > 0) {
836
844
  for (const placedId of placedIds) {
837
845
  const placed = out.get(placedId);
@@ -840,7 +848,6 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
840
848
  }
841
849
  firstSeen = true;
842
850
  out.set(child.id, { top: effectiveTop, left: padLeft + storedLeft + mLeft });
843
- const h = hugAdjust ? hugAdjust.glyphHeight : sizes.get(child.id).height;
844
851
  prevBottom = effectiveTop + hugTopOffset + h + (child.marginBottom ?? 0);
845
852
  placedIds.push(child.id);
846
853
  }
@@ -853,10 +860,11 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
853
860
  const storedTop = getNodeTop(child);
854
861
  const mTop = child.marginTop ?? 0;
855
862
  const mLeft = child.marginLeft ?? 0;
856
- const effectiveLeft = !firstSeen ? padLeft + storedLeft + mLeft : prevRight + gap + storedLeft + mLeft;
863
+ const w = sizes.get(child.id).width;
864
+ const anchorOffset = getStackMainAnchorOffset(child, w);
865
+ const effectiveLeft = (!firstSeen ? padLeft + storedLeft + mLeft : prevRight + gap + storedLeft + mLeft) - anchorOffset;
857
866
  firstSeen = true;
858
867
  out.set(child.id, { top: padTop + storedTop + mTop, left: effectiveLeft });
859
- const w = sizes.get(child.id).width;
860
868
  prevRight = effectiveLeft + w + (child.marginRight ?? 0);
861
869
  }
862
870
  }
@@ -962,13 +970,14 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
962
970
  const pos = out.get(child.id);
963
971
  if (!pos) continue;
964
972
  const startMain = cursor + marginStart;
973
+ const anchorOffset = getStackMainAnchorOffset(child, main);
965
974
  if (isVertical) {
966
975
  const hugAdjust = getVerticalHugTextAdjust(group, child);
967
- out.set(child.id, { top: startMain - ((hugAdjust == null ? void 0 : hugAdjust.topOffset) ?? 0), left: pos.left });
976
+ out.set(child.id, { top: startMain - anchorOffset - ((hugAdjust == null ? void 0 : hugAdjust.topOffset) ?? 0), left: pos.left });
968
977
  } else {
969
- out.set(child.id, { top: pos.top, left: startMain });
978
+ out.set(child.id, { top: pos.top, left: startMain - anchorOffset });
970
979
  }
971
- cursor = startMain + main + marginEnd + gap + extraGap;
980
+ cursor = startMain - anchorOffset + main + marginEnd + gap + extraGap;
972
981
  }
973
982
  }
974
983
  }
@@ -26366,9 +26375,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26366
26375
  }
26367
26376
  return svgString;
26368
26377
  }
26369
- const resolvedPackageVersion = "0.5.480";
26378
+ const resolvedPackageVersion = "0.5.481";
26370
26379
  const PACKAGE_VERSION = resolvedPackageVersion;
26371
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.480";
26380
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.481";
26372
26381
  const roundParityValue = (value) => {
26373
26382
  if (typeof value !== "number") return value;
26374
26383
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27182,7 +27191,7 @@ class PixldocsRenderer {
27182
27191
  await this.waitForCanvasScene(container, cloned, i);
27183
27192
  }
27184
27193
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27185
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CwvZ-BD6.js");
27194
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CksPPH4M.js");
27186
27195
  const prepared = preparePagesForExport(
27187
27196
  cloned.pages,
27188
27197
  canvasWidth,
@@ -29502,7 +29511,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29502
29511
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29503
29512
  sanitizeSvgTreeForPdf(svgToDraw);
29504
29513
  try {
29505
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CwvZ-BD6.js");
29514
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CksPPH4M.js");
29506
29515
  try {
29507
29516
  await logTextMeasurementDiagnostic(svgToDraw);
29508
29517
  } catch {
@@ -29819,4 +29828,4 @@ export {
29819
29828
  buildTeaserBlurFlatKeys as y,
29820
29829
  collectFontDescriptorsFromConfig as z
29821
29830
  };
29822
- //# sourceMappingURL=index-Bdt_4Ak_.js.map
29831
+ //# sourceMappingURL=index-CS-rW-8B.js.map