ugcinc-render 1.5.22 → 1.5.24

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.
package/dist/index.d.mts CHANGED
@@ -1172,12 +1172,16 @@ declare function hexToRgba(hex: string, opacity?: number): string;
1172
1172
  */
1173
1173
 
1174
1174
  /**
1175
- * Calculate the actual width of a text element when autoWidth is enabled
1176
- * Returns { actualWidth, actualX } where actualX is adjusted based on boxAlign
1175
+ * Calculate the actual dimensions of a text element when autoWidth is enabled
1176
+ * Returns { actualWidth, actualX, actualHeight } where:
1177
+ * - actualX is adjusted based on boxAlign
1178
+ * - actualHeight is calculated based on the number of wrapped lines
1177
1179
  */
1178
1180
  declare function calculateAutoWidthDimensions(elem: ImageEditorElement, textContent: string, ctx?: CanvasRenderingContext2D | null): {
1179
1181
  actualWidth: number;
1180
1182
  actualX: number;
1183
+ actualHeight: number;
1184
+ lineCount: number;
1181
1185
  } | null;
1182
1186
  interface PositionResolutionError {
1183
1187
  elementId: string;
package/dist/index.d.ts CHANGED
@@ -1172,12 +1172,16 @@ declare function hexToRgba(hex: string, opacity?: number): string;
1172
1172
  */
1173
1173
 
1174
1174
  /**
1175
- * Calculate the actual width of a text element when autoWidth is enabled
1176
- * Returns { actualWidth, actualX } where actualX is adjusted based on boxAlign
1175
+ * Calculate the actual dimensions of a text element when autoWidth is enabled
1176
+ * Returns { actualWidth, actualX, actualHeight } where:
1177
+ * - actualX is adjusted based on boxAlign
1178
+ * - actualHeight is calculated based on the number of wrapped lines
1177
1179
  */
1178
1180
  declare function calculateAutoWidthDimensions(elem: ImageEditorElement, textContent: string, ctx?: CanvasRenderingContext2D | null): {
1179
1181
  actualWidth: number;
1180
1182
  actualX: number;
1183
+ actualHeight: number;
1184
+ lineCount: number;
1181
1185
  } | null;
1182
1186
  interface PositionResolutionError {
1183
1187
  elementId: string;
package/dist/index.js CHANGED
@@ -779,7 +779,7 @@ var FONT_FAMILIES2 = {
779
779
  arial: "Arial, sans-serif"
780
780
  };
781
781
  function calculateAutoWidthDimensions(elem, textContent, ctx) {
782
- if (elem.type !== "text" || !elem.autoWidth) {
782
+ if (elem.type !== "text") {
783
783
  return null;
784
784
  }
785
785
  let measureCtx = ctx;
@@ -796,9 +796,13 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
796
796
  const fontType = elem.font ?? "tiktok";
797
797
  const paddingLeft = elem.paddingLeft ?? 0;
798
798
  const paddingRight = elem.paddingRight ?? 0;
799
+ const paddingTop = elem.paddingTop ?? 0;
800
+ const paddingBottom = elem.paddingBottom ?? 0;
799
801
  const letterSpacing = elem.letterSpacing ?? 0;
802
+ const lineHeight = elem.lineHeight ?? 1.2;
800
803
  const maxWidth = elem.width;
801
804
  const boxAlign = elem.boxAlign ?? "left";
805
+ const autoWidth = elem.autoWidth ?? false;
802
806
  const fontFamily = FONT_FAMILIES2[fontType] ?? FONT_FAMILIES2.tiktok;
803
807
  measureCtx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
804
808
  const availableWidth = maxWidth - paddingLeft - paddingRight;
@@ -819,6 +823,7 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
819
823
  }
820
824
  }
821
825
  if (currentLine) lines.push(currentLine);
826
+ if (lines.length === 0) lines.push("");
822
827
  let widestLineWidth = 0;
823
828
  for (const line of lines) {
824
829
  const chars = [...line];
@@ -829,21 +834,27 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
829
834
  if (chars.length > 0) lineWidth -= letterSpacing;
830
835
  widestLineWidth = Math.max(widestLineWidth, lineWidth);
831
836
  }
832
- const actualWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
837
+ const actualWidth = autoWidth ? Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth) : maxWidth;
838
+ const textHeight = lines.length * fontSize * lineHeight;
839
+ const actualHeight = textHeight + paddingTop + paddingBottom;
833
840
  let actualX;
834
- switch (boxAlign) {
835
- case "right":
836
- actualX = elem.x + maxWidth - actualWidth;
837
- break;
838
- case "center":
839
- actualX = elem.x + (maxWidth - actualWidth) / 2;
840
- break;
841
- case "left":
842
- default:
843
- actualX = elem.x;
844
- break;
841
+ if (autoWidth) {
842
+ switch (boxAlign) {
843
+ case "right":
844
+ actualX = elem.x + maxWidth - actualWidth;
845
+ break;
846
+ case "center":
847
+ actualX = elem.x + (maxWidth - actualWidth) / 2;
848
+ break;
849
+ case "left":
850
+ default:
851
+ actualX = elem.x;
852
+ break;
853
+ }
854
+ } else {
855
+ actualX = elem.x;
845
856
  }
846
- return { actualWidth, actualX };
857
+ return { actualWidth, actualX, actualHeight, lineCount: lines.length };
847
858
  }
848
859
  function detectCircularDependency(elements, startId, axis, visited = /* @__PURE__ */ new Set(), path = []) {
849
860
  if (visited.has(startId)) {
@@ -933,38 +944,40 @@ function topologicalSortForAxis(elements, axis) {
933
944
  }
934
945
  return { sorted, errors };
935
946
  }
936
- function getSelfAnchorOffsetX(element, selfAnchor) {
947
+ function getSelfAnchorOffsetX(element, selfAnchor, actualWidth) {
948
+ const width = actualWidth ?? element.width;
937
949
  switch (selfAnchor) {
938
950
  case "left":
939
951
  return 0;
940
952
  case "center":
941
- return element.width / 2;
953
+ return width / 2;
942
954
  case "right":
943
- return element.width;
955
+ return width;
944
956
  default:
945
957
  return 0;
946
958
  }
947
959
  }
948
- function getSelfAnchorOffsetY(element, selfAnchor) {
960
+ function getSelfAnchorOffsetY(element, selfAnchor, actualHeight) {
961
+ const height = actualHeight ?? element.height;
949
962
  switch (selfAnchor) {
950
963
  case "top":
951
964
  return 0;
952
965
  case "middle":
953
- return element.height / 2;
966
+ return height / 2;
954
967
  case "bottom":
955
- return element.height;
968
+ return height;
956
969
  default:
957
970
  return 0;
958
971
  }
959
972
  }
960
- function calculateAbsoluteX(element, referenceElement, anchor, selfAnchor, offset) {
973
+ function calculateAbsoluteX(element, referenceElement, anchor, selfAnchor, offset, actualWidth) {
961
974
  const refX = anchor === "left" ? referenceElement.x : referenceElement.x + referenceElement.width;
962
- const selfOffset = getSelfAnchorOffsetX(element, selfAnchor);
975
+ const selfOffset = getSelfAnchorOffsetX(element, selfAnchor, actualWidth);
963
976
  return refX + offset - selfOffset;
964
977
  }
965
- function calculateAbsoluteY(element, referenceElement, anchor, selfAnchor, offset) {
978
+ function calculateAbsoluteY(element, referenceElement, anchor, selfAnchor, offset, actualHeight) {
966
979
  const refY = anchor === "top" ? referenceElement.y : referenceElement.y + referenceElement.height;
967
- const selfOffset = getSelfAnchorOffsetY(element, selfAnchor);
980
+ const selfOffset = getSelfAnchorOffsetY(element, selfAnchor, actualHeight);
968
981
  return refY + offset - selfOffset;
969
982
  }
970
983
  function resolveElementPositions(elements, textValues) {
@@ -996,18 +1009,24 @@ function resolveElementPositions(elements, textValues) {
996
1009
  for (const elem of elements) {
997
1010
  resolvedX.set(elem.id, { x: elem.x, width: elem.width });
998
1011
  resolvedY.set(elem.id, { y: elem.y, height: elem.height });
999
- if (elem.type === "text" && elem.autoWidth) {
1012
+ if (elem.type === "text") {
1000
1013
  const textContent = getTextContent(elem);
1001
- const autoWidthResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
1002
- if (autoWidthResult) {
1003
- referenceX.set(elem.id, { x: autoWidthResult.actualX, width: autoWidthResult.actualWidth });
1014
+ const autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
1015
+ if (autoResult) {
1016
+ if (elem.autoWidth) {
1017
+ referenceX.set(elem.id, { x: autoResult.actualX, width: autoResult.actualWidth });
1018
+ } else {
1019
+ referenceX.set(elem.id, { x: elem.x, width: elem.width });
1020
+ }
1021
+ referenceY.set(elem.id, { y: elem.y, height: autoResult.actualHeight });
1004
1022
  } else {
1005
1023
  referenceX.set(elem.id, { x: elem.x, width: elem.width });
1024
+ referenceY.set(elem.id, { y: elem.y, height: elem.height });
1006
1025
  }
1007
1026
  } else {
1008
1027
  referenceX.set(elem.id, { x: elem.x, width: elem.width });
1028
+ referenceY.set(elem.id, { y: elem.y, height: elem.height });
1009
1029
  }
1010
- referenceY.set(elem.id, { y: elem.y, height: elem.height });
1011
1030
  }
1012
1031
  for (const elem of sortedX) {
1013
1032
  if (elem.relativePositionX) {
@@ -1016,21 +1035,37 @@ function resolveElementPositions(elements, textValues) {
1016
1035
  if (refPosition) {
1017
1036
  const defaultSelfAnchor = elem.relativePositionX.anchor === "right" ? "left" : "right";
1018
1037
  const selfAnchor = elem.relativePositionX.selfAnchor ?? defaultSelfAnchor;
1038
+ let actualWidth;
1039
+ let autoResult = null;
1040
+ if (elem.type === "text") {
1041
+ const textContent = getTextContent(elem);
1042
+ autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
1043
+ if (autoResult && elem.autoWidth) {
1044
+ actualWidth = autoResult.actualWidth;
1045
+ }
1046
+ }
1019
1047
  const newX = calculateAbsoluteX(
1020
1048
  elem,
1021
1049
  refPosition,
1022
1050
  elem.relativePositionX.anchor,
1023
1051
  selfAnchor,
1024
- elem.relativePositionX.offset
1052
+ elem.relativePositionX.offset,
1053
+ actualWidth
1054
+ // Use actual width for self anchor calculation
1025
1055
  );
1026
1056
  resolvedX.set(elem.id, { x: newX, width: elem.width });
1027
- if (elem.type === "text" && elem.autoWidth) {
1028
- const textContent = getTextContent(elem);
1029
- const autoWidthResult = calculateAutoWidthDimensions({ ...elem, x: newX }, textContent, measureCtx);
1030
- if (autoWidthResult) {
1031
- referenceX.set(elem.id, { x: autoWidthResult.actualX, width: autoWidthResult.actualWidth });
1057
+ if (autoResult) {
1058
+ if (elem.autoWidth) {
1059
+ const updatedResult = calculateAutoWidthDimensions({ ...elem, x: newX }, getTextContent(elem), measureCtx);
1060
+ if (updatedResult) {
1061
+ referenceX.set(elem.id, { x: updatedResult.actualX, width: updatedResult.actualWidth });
1062
+ referenceY.set(elem.id, { y: referenceY.get(elem.id)?.y ?? elem.y, height: updatedResult.actualHeight });
1063
+ } else {
1064
+ referenceX.set(elem.id, { x: newX, width: elem.width });
1065
+ }
1032
1066
  } else {
1033
1067
  referenceX.set(elem.id, { x: newX, width: elem.width });
1068
+ referenceY.set(elem.id, { y: referenceY.get(elem.id)?.y ?? elem.y, height: autoResult.actualHeight });
1034
1069
  }
1035
1070
  } else {
1036
1071
  referenceX.set(elem.id, { x: newX, width: elem.width });
@@ -1045,15 +1080,29 @@ function resolveElementPositions(elements, textValues) {
1045
1080
  if (refPosition) {
1046
1081
  const defaultSelfAnchor = elem.relativePositionY.anchor === "bottom" ? "top" : "bottom";
1047
1082
  const selfAnchor = elem.relativePositionY.selfAnchor ?? defaultSelfAnchor;
1083
+ let actualHeight;
1084
+ if (elem.type === "text") {
1085
+ const textContent = getTextContent(elem);
1086
+ const autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
1087
+ if (autoResult) {
1088
+ actualHeight = autoResult.actualHeight;
1089
+ }
1090
+ }
1048
1091
  const newY = calculateAbsoluteY(
1049
1092
  elem,
1050
1093
  refPosition,
1051
1094
  elem.relativePositionY.anchor,
1052
1095
  selfAnchor,
1053
- elem.relativePositionY.offset
1096
+ elem.relativePositionY.offset,
1097
+ actualHeight
1098
+ // Use actual height for self anchor calculation
1054
1099
  );
1055
1100
  resolvedY.set(elem.id, { y: newY, height: elem.height });
1056
- referenceY.set(elem.id, { y: newY, height: elem.height });
1101
+ if (actualHeight !== void 0) {
1102
+ referenceY.set(elem.id, { y: newY, height: actualHeight });
1103
+ } else {
1104
+ referenceY.set(elem.id, { y: newY, height: elem.height });
1105
+ }
1057
1106
  }
1058
1107
  }
1059
1108
  }
package/dist/index.mjs CHANGED
@@ -693,7 +693,7 @@ var FONT_FAMILIES2 = {
693
693
  arial: "Arial, sans-serif"
694
694
  };
695
695
  function calculateAutoWidthDimensions(elem, textContent, ctx) {
696
- if (elem.type !== "text" || !elem.autoWidth) {
696
+ if (elem.type !== "text") {
697
697
  return null;
698
698
  }
699
699
  let measureCtx = ctx;
@@ -710,9 +710,13 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
710
710
  const fontType = elem.font ?? "tiktok";
711
711
  const paddingLeft = elem.paddingLeft ?? 0;
712
712
  const paddingRight = elem.paddingRight ?? 0;
713
+ const paddingTop = elem.paddingTop ?? 0;
714
+ const paddingBottom = elem.paddingBottom ?? 0;
713
715
  const letterSpacing = elem.letterSpacing ?? 0;
716
+ const lineHeight = elem.lineHeight ?? 1.2;
714
717
  const maxWidth = elem.width;
715
718
  const boxAlign = elem.boxAlign ?? "left";
719
+ const autoWidth = elem.autoWidth ?? false;
716
720
  const fontFamily = FONT_FAMILIES2[fontType] ?? FONT_FAMILIES2.tiktok;
717
721
  measureCtx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
718
722
  const availableWidth = maxWidth - paddingLeft - paddingRight;
@@ -733,6 +737,7 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
733
737
  }
734
738
  }
735
739
  if (currentLine) lines.push(currentLine);
740
+ if (lines.length === 0) lines.push("");
736
741
  let widestLineWidth = 0;
737
742
  for (const line of lines) {
738
743
  const chars = [...line];
@@ -743,21 +748,27 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
743
748
  if (chars.length > 0) lineWidth -= letterSpacing;
744
749
  widestLineWidth = Math.max(widestLineWidth, lineWidth);
745
750
  }
746
- const actualWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
751
+ const actualWidth = autoWidth ? Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth) : maxWidth;
752
+ const textHeight = lines.length * fontSize * lineHeight;
753
+ const actualHeight = textHeight + paddingTop + paddingBottom;
747
754
  let actualX;
748
- switch (boxAlign) {
749
- case "right":
750
- actualX = elem.x + maxWidth - actualWidth;
751
- break;
752
- case "center":
753
- actualX = elem.x + (maxWidth - actualWidth) / 2;
754
- break;
755
- case "left":
756
- default:
757
- actualX = elem.x;
758
- break;
755
+ if (autoWidth) {
756
+ switch (boxAlign) {
757
+ case "right":
758
+ actualX = elem.x + maxWidth - actualWidth;
759
+ break;
760
+ case "center":
761
+ actualX = elem.x + (maxWidth - actualWidth) / 2;
762
+ break;
763
+ case "left":
764
+ default:
765
+ actualX = elem.x;
766
+ break;
767
+ }
768
+ } else {
769
+ actualX = elem.x;
759
770
  }
760
- return { actualWidth, actualX };
771
+ return { actualWidth, actualX, actualHeight, lineCount: lines.length };
761
772
  }
762
773
  function detectCircularDependency(elements, startId, axis, visited = /* @__PURE__ */ new Set(), path = []) {
763
774
  if (visited.has(startId)) {
@@ -847,38 +858,40 @@ function topologicalSortForAxis(elements, axis) {
847
858
  }
848
859
  return { sorted, errors };
849
860
  }
850
- function getSelfAnchorOffsetX(element, selfAnchor) {
861
+ function getSelfAnchorOffsetX(element, selfAnchor, actualWidth) {
862
+ const width = actualWidth ?? element.width;
851
863
  switch (selfAnchor) {
852
864
  case "left":
853
865
  return 0;
854
866
  case "center":
855
- return element.width / 2;
867
+ return width / 2;
856
868
  case "right":
857
- return element.width;
869
+ return width;
858
870
  default:
859
871
  return 0;
860
872
  }
861
873
  }
862
- function getSelfAnchorOffsetY(element, selfAnchor) {
874
+ function getSelfAnchorOffsetY(element, selfAnchor, actualHeight) {
875
+ const height = actualHeight ?? element.height;
863
876
  switch (selfAnchor) {
864
877
  case "top":
865
878
  return 0;
866
879
  case "middle":
867
- return element.height / 2;
880
+ return height / 2;
868
881
  case "bottom":
869
- return element.height;
882
+ return height;
870
883
  default:
871
884
  return 0;
872
885
  }
873
886
  }
874
- function calculateAbsoluteX(element, referenceElement, anchor, selfAnchor, offset) {
887
+ function calculateAbsoluteX(element, referenceElement, anchor, selfAnchor, offset, actualWidth) {
875
888
  const refX = anchor === "left" ? referenceElement.x : referenceElement.x + referenceElement.width;
876
- const selfOffset = getSelfAnchorOffsetX(element, selfAnchor);
889
+ const selfOffset = getSelfAnchorOffsetX(element, selfAnchor, actualWidth);
877
890
  return refX + offset - selfOffset;
878
891
  }
879
- function calculateAbsoluteY(element, referenceElement, anchor, selfAnchor, offset) {
892
+ function calculateAbsoluteY(element, referenceElement, anchor, selfAnchor, offset, actualHeight) {
880
893
  const refY = anchor === "top" ? referenceElement.y : referenceElement.y + referenceElement.height;
881
- const selfOffset = getSelfAnchorOffsetY(element, selfAnchor);
894
+ const selfOffset = getSelfAnchorOffsetY(element, selfAnchor, actualHeight);
882
895
  return refY + offset - selfOffset;
883
896
  }
884
897
  function resolveElementPositions(elements, textValues) {
@@ -910,18 +923,24 @@ function resolveElementPositions(elements, textValues) {
910
923
  for (const elem of elements) {
911
924
  resolvedX.set(elem.id, { x: elem.x, width: elem.width });
912
925
  resolvedY.set(elem.id, { y: elem.y, height: elem.height });
913
- if (elem.type === "text" && elem.autoWidth) {
926
+ if (elem.type === "text") {
914
927
  const textContent = getTextContent(elem);
915
- const autoWidthResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
916
- if (autoWidthResult) {
917
- referenceX.set(elem.id, { x: autoWidthResult.actualX, width: autoWidthResult.actualWidth });
928
+ const autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
929
+ if (autoResult) {
930
+ if (elem.autoWidth) {
931
+ referenceX.set(elem.id, { x: autoResult.actualX, width: autoResult.actualWidth });
932
+ } else {
933
+ referenceX.set(elem.id, { x: elem.x, width: elem.width });
934
+ }
935
+ referenceY.set(elem.id, { y: elem.y, height: autoResult.actualHeight });
918
936
  } else {
919
937
  referenceX.set(elem.id, { x: elem.x, width: elem.width });
938
+ referenceY.set(elem.id, { y: elem.y, height: elem.height });
920
939
  }
921
940
  } else {
922
941
  referenceX.set(elem.id, { x: elem.x, width: elem.width });
942
+ referenceY.set(elem.id, { y: elem.y, height: elem.height });
923
943
  }
924
- referenceY.set(elem.id, { y: elem.y, height: elem.height });
925
944
  }
926
945
  for (const elem of sortedX) {
927
946
  if (elem.relativePositionX) {
@@ -930,21 +949,37 @@ function resolveElementPositions(elements, textValues) {
930
949
  if (refPosition) {
931
950
  const defaultSelfAnchor = elem.relativePositionX.anchor === "right" ? "left" : "right";
932
951
  const selfAnchor = elem.relativePositionX.selfAnchor ?? defaultSelfAnchor;
952
+ let actualWidth;
953
+ let autoResult = null;
954
+ if (elem.type === "text") {
955
+ const textContent = getTextContent(elem);
956
+ autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
957
+ if (autoResult && elem.autoWidth) {
958
+ actualWidth = autoResult.actualWidth;
959
+ }
960
+ }
933
961
  const newX = calculateAbsoluteX(
934
962
  elem,
935
963
  refPosition,
936
964
  elem.relativePositionX.anchor,
937
965
  selfAnchor,
938
- elem.relativePositionX.offset
966
+ elem.relativePositionX.offset,
967
+ actualWidth
968
+ // Use actual width for self anchor calculation
939
969
  );
940
970
  resolvedX.set(elem.id, { x: newX, width: elem.width });
941
- if (elem.type === "text" && elem.autoWidth) {
942
- const textContent = getTextContent(elem);
943
- const autoWidthResult = calculateAutoWidthDimensions({ ...elem, x: newX }, textContent, measureCtx);
944
- if (autoWidthResult) {
945
- referenceX.set(elem.id, { x: autoWidthResult.actualX, width: autoWidthResult.actualWidth });
971
+ if (autoResult) {
972
+ if (elem.autoWidth) {
973
+ const updatedResult = calculateAutoWidthDimensions({ ...elem, x: newX }, getTextContent(elem), measureCtx);
974
+ if (updatedResult) {
975
+ referenceX.set(elem.id, { x: updatedResult.actualX, width: updatedResult.actualWidth });
976
+ referenceY.set(elem.id, { y: referenceY.get(elem.id)?.y ?? elem.y, height: updatedResult.actualHeight });
977
+ } else {
978
+ referenceX.set(elem.id, { x: newX, width: elem.width });
979
+ }
946
980
  } else {
947
981
  referenceX.set(elem.id, { x: newX, width: elem.width });
982
+ referenceY.set(elem.id, { y: referenceY.get(elem.id)?.y ?? elem.y, height: autoResult.actualHeight });
948
983
  }
949
984
  } else {
950
985
  referenceX.set(elem.id, { x: newX, width: elem.width });
@@ -959,15 +994,29 @@ function resolveElementPositions(elements, textValues) {
959
994
  if (refPosition) {
960
995
  const defaultSelfAnchor = elem.relativePositionY.anchor === "bottom" ? "top" : "bottom";
961
996
  const selfAnchor = elem.relativePositionY.selfAnchor ?? defaultSelfAnchor;
997
+ let actualHeight;
998
+ if (elem.type === "text") {
999
+ const textContent = getTextContent(elem);
1000
+ const autoResult = calculateAutoWidthDimensions(elem, textContent, measureCtx);
1001
+ if (autoResult) {
1002
+ actualHeight = autoResult.actualHeight;
1003
+ }
1004
+ }
962
1005
  const newY = calculateAbsoluteY(
963
1006
  elem,
964
1007
  refPosition,
965
1008
  elem.relativePositionY.anchor,
966
1009
  selfAnchor,
967
- elem.relativePositionY.offset
1010
+ elem.relativePositionY.offset,
1011
+ actualHeight
1012
+ // Use actual height for self anchor calculation
968
1013
  );
969
1014
  resolvedY.set(elem.id, { y: newY, height: elem.height });
970
- referenceY.set(elem.id, { y: newY, height: elem.height });
1015
+ if (actualHeight !== void 0) {
1016
+ referenceY.set(elem.id, { y: newY, height: actualHeight });
1017
+ } else {
1018
+ referenceY.set(elem.id, { y: newY, height: elem.height });
1019
+ }
971
1020
  }
972
1021
  }
973
1022
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc-render",
3
- "version": "1.5.22",
3
+ "version": "1.5.24",
4
4
  "description": "Unified rendering package for UGC Inc - shared types, components, and compositions for pixel-perfect client/server rendering",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",