@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.
@@ -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
  }
@@ -895,7 +903,11 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
895
903
  const crossPadEnd = isVertical ? padRight : padBottom;
896
904
  crossContainer = maxCross + crossPad0 + crossPadEnd;
897
905
  }
898
- if (align !== "start" && crossContainer != null && kids.length > 0) {
906
+ const anyChildOverride = kids.some((c) => {
907
+ const v = c.alignSelf;
908
+ return typeof v === "string" && v !== "auto";
909
+ });
910
+ if ((align !== "start" || anyChildOverride) && crossContainer != null && kids.length > 0) {
899
911
  const crossPad0 = isVertical ? padLeft : padTop;
900
912
  const crossPadEnd = isVertical ? padRight : padBottom;
901
913
  const innerCross = Math.max(0, crossContainer - crossPad0 - crossPadEnd);
@@ -904,10 +916,13 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
904
916
  if (!pos) continue;
905
917
  const sz = sizes.get(child.id);
906
918
  const childCross = isVertical ? sz.width : sz.height;
919
+ const selfRaw = child.alignSelf;
920
+ const effective = selfRaw && selfRaw !== "auto" ? selfRaw : align;
921
+ if (effective === "start") continue;
907
922
  let crossPos;
908
- if (align === "stretch") {
923
+ if (effective === "stretch") {
909
924
  crossPos = crossPad0;
910
- } else if (align === "center") {
925
+ } else if (effective === "center") {
911
926
  crossPos = crossPad0 + (innerCross - childCross) / 2;
912
927
  } else {
913
928
  crossPos = crossPad0 + (innerCross - childCross);
@@ -973,13 +988,14 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
973
988
  const pos = out.get(child.id);
974
989
  if (!pos) continue;
975
990
  const startMain = cursor + marginStart;
991
+ const anchorOffset = getStackMainAnchorOffset(child, main);
976
992
  if (isVertical) {
977
993
  const hugAdjust = getVerticalHugTextAdjust(group, child);
978
- 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 });
979
995
  } else {
980
- out.set(child.id, { top: pos.top, left: startMain });
996
+ out.set(child.id, { top: pos.top, left: startMain - anchorOffset });
981
997
  }
982
- cursor = startMain + main + marginEnd + gap + extraGap;
998
+ cursor = startMain - anchorOffset + main + marginEnd + gap + extraGap;
983
999
  }
984
1000
  }
985
1001
  }
@@ -26377,9 +26393,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26377
26393
  }
26378
26394
  return svgString;
26379
26395
  }
26380
- const resolvedPackageVersion = "0.5.479";
26396
+ const resolvedPackageVersion = "0.5.481";
26381
26397
  const PACKAGE_VERSION = resolvedPackageVersion;
26382
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.479";
26398
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.481";
26383
26399
  const roundParityValue = (value) => {
26384
26400
  if (typeof value !== "number") return value;
26385
26401
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27193,7 +27209,7 @@ class PixldocsRenderer {
27193
27209
  await this.waitForCanvasScene(container, cloned, i);
27194
27210
  }
27195
27211
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27196
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DtQDA2s0.cjs"));
27212
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-VuNMn-Mu.cjs"));
27197
27213
  const prepared = preparePagesForExport(
27198
27214
  cloned.pages,
27199
27215
  canvasWidth,
@@ -29513,7 +29529,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29513
29529
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29514
29530
  sanitizeSvgTreeForPdf(svgToDraw);
29515
29531
  try {
29516
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DtQDA2s0.cjs"));
29532
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-VuNMn-Mu.cjs"));
29517
29533
  try {
29518
29534
  await logTextMeasurementDiagnostic(svgToDraw);
29519
29535
  } catch {
@@ -29827,4 +29843,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29827
29843
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29828
29844
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29829
29845
  exports.warmTemplateFromForm = warmTemplateFromForm;
29830
- //# sourceMappingURL=index-HdyrEZYv.cjs.map
29846
+ //# sourceMappingURL=index-C-V0iK3K.cjs.map