@pixldocs/canvas-renderer 0.5.479 → 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
  }
@@ -877,7 +885,11 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
877
885
  const crossPadEnd = isVertical ? padRight : padBottom;
878
886
  crossContainer = maxCross + crossPad0 + crossPadEnd;
879
887
  }
880
- if (align !== "start" && crossContainer != null && kids.length > 0) {
888
+ const anyChildOverride = kids.some((c) => {
889
+ const v = c.alignSelf;
890
+ return typeof v === "string" && v !== "auto";
891
+ });
892
+ if ((align !== "start" || anyChildOverride) && crossContainer != null && kids.length > 0) {
881
893
  const crossPad0 = isVertical ? padLeft : padTop;
882
894
  const crossPadEnd = isVertical ? padRight : padBottom;
883
895
  const innerCross = Math.max(0, crossContainer - crossPad0 - crossPadEnd);
@@ -886,10 +898,13 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
886
898
  if (!pos) continue;
887
899
  const sz = sizes.get(child.id);
888
900
  const childCross = isVertical ? sz.width : sz.height;
901
+ const selfRaw = child.alignSelf;
902
+ const effective = selfRaw && selfRaw !== "auto" ? selfRaw : align;
903
+ if (effective === "start") continue;
889
904
  let crossPos;
890
- if (align === "stretch") {
905
+ if (effective === "stretch") {
891
906
  crossPos = crossPad0;
892
- } else if (align === "center") {
907
+ } else if (effective === "center") {
893
908
  crossPos = crossPad0 + (innerCross - childCross) / 2;
894
909
  } else {
895
910
  crossPos = crossPad0 + (innerCross - childCross);
@@ -955,13 +970,14 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
955
970
  const pos = out.get(child.id);
956
971
  if (!pos) continue;
957
972
  const startMain = cursor + marginStart;
973
+ const anchorOffset = getStackMainAnchorOffset(child, main);
958
974
  if (isVertical) {
959
975
  const hugAdjust = getVerticalHugTextAdjust(group, child);
960
- 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 });
961
977
  } else {
962
- out.set(child.id, { top: pos.top, left: startMain });
978
+ out.set(child.id, { top: pos.top, left: startMain - anchorOffset });
963
979
  }
964
- cursor = startMain + main + marginEnd + gap + extraGap;
980
+ cursor = startMain - anchorOffset + main + marginEnd + gap + extraGap;
965
981
  }
966
982
  }
967
983
  }
@@ -26359,9 +26375,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26359
26375
  }
26360
26376
  return svgString;
26361
26377
  }
26362
- const resolvedPackageVersion = "0.5.479";
26378
+ const resolvedPackageVersion = "0.5.481";
26363
26379
  const PACKAGE_VERSION = resolvedPackageVersion;
26364
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.479";
26380
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.481";
26365
26381
  const roundParityValue = (value) => {
26366
26382
  if (typeof value !== "number") return value;
26367
26383
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27175,7 +27191,7 @@ class PixldocsRenderer {
27175
27191
  await this.waitForCanvasScene(container, cloned, i);
27176
27192
  }
27177
27193
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27178
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DRfak0Ck.js");
27194
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CksPPH4M.js");
27179
27195
  const prepared = preparePagesForExport(
27180
27196
  cloned.pages,
27181
27197
  canvasWidth,
@@ -29495,7 +29511,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29495
29511
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29496
29512
  sanitizeSvgTreeForPdf(svgToDraw);
29497
29513
  try {
29498
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DRfak0Ck.js");
29514
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CksPPH4M.js");
29499
29515
  try {
29500
29516
  await logTextMeasurementDiagnostic(svgToDraw);
29501
29517
  } catch {
@@ -29812,4 +29828,4 @@ export {
29812
29828
  buildTeaserBlurFlatKeys as y,
29813
29829
  collectFontDescriptorsFromConfig as z
29814
29830
  };
29815
- //# sourceMappingURL=index-Dqwkt9nO.js.map
29831
+ //# sourceMappingURL=index-CS-rW-8B.js.map