ugcinc-render 1.8.224 → 1.8.225
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/{chunk-2BNW6ZNK.mjs → chunk-4WPUQ7LJ.mjs} +49 -13
- package/dist/index.js +49 -13
- package/dist/index.mjs +1 -1
- package/dist/utils/index.js +49 -13
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -835,6 +835,28 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
835
835
|
const canvas = document.createElement("canvas");
|
|
836
836
|
measureCtx = canvas.getContext("2d");
|
|
837
837
|
}
|
|
838
|
+
const attachmentPrefixes = ["image-", "story-reply-image-", "story-reply-bar-", "story-reply-text-"];
|
|
839
|
+
const getMessageGroupBounds = (messageElementId) => {
|
|
840
|
+
const elem = elementMap.get(messageElementId);
|
|
841
|
+
if (!elem) return void 0;
|
|
842
|
+
const actualHeight = getActualElementHeight(elem, textValues, measureCtx);
|
|
843
|
+
let top = elem.y;
|
|
844
|
+
let bottom = elem.y + actualHeight;
|
|
845
|
+
let left = elem.x;
|
|
846
|
+
let right = elem.x + elem.width;
|
|
847
|
+
const msgIdSuffix = messageElementId.replace(/^message-/, "");
|
|
848
|
+
for (const prefix of attachmentPrefixes) {
|
|
849
|
+
const assocElem = elementMap.get(`${prefix}${msgIdSuffix}`);
|
|
850
|
+
if (assocElem) {
|
|
851
|
+
const assocHeight = getActualElementHeight(assocElem, textValues, measureCtx);
|
|
852
|
+
top = Math.min(top, assocElem.y);
|
|
853
|
+
bottom = Math.max(bottom, assocElem.y + assocHeight);
|
|
854
|
+
left = Math.min(left, assocElem.x);
|
|
855
|
+
right = Math.max(right, assocElem.x + assocElem.width);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return { top, bottom, left, right };
|
|
859
|
+
};
|
|
838
860
|
let cropY = 0;
|
|
839
861
|
let cropHeight = canvasHeight;
|
|
840
862
|
if (dynamicCrop.vertical?.enabled) {
|
|
@@ -860,16 +882,24 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
860
882
|
let topY = 0;
|
|
861
883
|
let bottomY = canvasHeight;
|
|
862
884
|
if (startElementId) {
|
|
863
|
-
const
|
|
864
|
-
if (
|
|
865
|
-
topY =
|
|
885
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
886
|
+
if (bounds) {
|
|
887
|
+
topY = bounds.top;
|
|
888
|
+
} else {
|
|
889
|
+
const startElem = elementMap.get(startElementId);
|
|
890
|
+
if (startElem) topY = startElem.y;
|
|
866
891
|
}
|
|
867
892
|
}
|
|
868
893
|
if (endElementId) {
|
|
869
|
-
const
|
|
870
|
-
if (
|
|
871
|
-
|
|
872
|
-
|
|
894
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
895
|
+
if (bounds) {
|
|
896
|
+
bottomY = bounds.bottom;
|
|
897
|
+
} else {
|
|
898
|
+
const endElem = elementMap.get(endElementId);
|
|
899
|
+
if (endElem) {
|
|
900
|
+
const actualHeight = getActualElementHeight(endElem, textValues, measureCtx);
|
|
901
|
+
bottomY = endElem.y + actualHeight;
|
|
902
|
+
}
|
|
873
903
|
}
|
|
874
904
|
}
|
|
875
905
|
cropY = Math.max(0, topY - paddingStart);
|
|
@@ -904,15 +934,21 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
904
934
|
let leftX = 0;
|
|
905
935
|
let rightX = canvasWidth;
|
|
906
936
|
if (startElementId) {
|
|
907
|
-
const
|
|
908
|
-
if (
|
|
909
|
-
leftX =
|
|
937
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
938
|
+
if (bounds) {
|
|
939
|
+
leftX = bounds.left;
|
|
940
|
+
} else {
|
|
941
|
+
const startElem = elementMap.get(startElementId);
|
|
942
|
+
if (startElem) leftX = startElem.x;
|
|
910
943
|
}
|
|
911
944
|
}
|
|
912
945
|
if (endElementId) {
|
|
913
|
-
const
|
|
914
|
-
if (
|
|
915
|
-
rightX =
|
|
946
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
947
|
+
if (bounds) {
|
|
948
|
+
rightX = bounds.right;
|
|
949
|
+
} else {
|
|
950
|
+
const endElem = elementMap.get(endElementId);
|
|
951
|
+
if (endElem) rightX = endElem.x + endElem.width;
|
|
916
952
|
}
|
|
917
953
|
}
|
|
918
954
|
cropX = Math.max(0, leftX - paddingStart);
|
package/dist/index.js
CHANGED
|
@@ -1532,6 +1532,28 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
1532
1532
|
const canvas = document.createElement("canvas");
|
|
1533
1533
|
measureCtx = canvas.getContext("2d");
|
|
1534
1534
|
}
|
|
1535
|
+
const attachmentPrefixes = ["image-", "story-reply-image-", "story-reply-bar-", "story-reply-text-"];
|
|
1536
|
+
const getMessageGroupBounds = (messageElementId) => {
|
|
1537
|
+
const elem = elementMap.get(messageElementId);
|
|
1538
|
+
if (!elem) return void 0;
|
|
1539
|
+
const actualHeight = getActualElementHeight(elem, textValues, measureCtx);
|
|
1540
|
+
let top = elem.y;
|
|
1541
|
+
let bottom = elem.y + actualHeight;
|
|
1542
|
+
let left = elem.x;
|
|
1543
|
+
let right = elem.x + elem.width;
|
|
1544
|
+
const msgIdSuffix = messageElementId.replace(/^message-/, "");
|
|
1545
|
+
for (const prefix of attachmentPrefixes) {
|
|
1546
|
+
const assocElem = elementMap.get(`${prefix}${msgIdSuffix}`);
|
|
1547
|
+
if (assocElem) {
|
|
1548
|
+
const assocHeight = getActualElementHeight(assocElem, textValues, measureCtx);
|
|
1549
|
+
top = Math.min(top, assocElem.y);
|
|
1550
|
+
bottom = Math.max(bottom, assocElem.y + assocHeight);
|
|
1551
|
+
left = Math.min(left, assocElem.x);
|
|
1552
|
+
right = Math.max(right, assocElem.x + assocElem.width);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return { top, bottom, left, right };
|
|
1556
|
+
};
|
|
1535
1557
|
let cropY = 0;
|
|
1536
1558
|
let cropHeight = canvasHeight;
|
|
1537
1559
|
if (dynamicCrop.vertical?.enabled) {
|
|
@@ -1557,16 +1579,24 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
1557
1579
|
let topY = 0;
|
|
1558
1580
|
let bottomY = canvasHeight;
|
|
1559
1581
|
if (startElementId) {
|
|
1560
|
-
const
|
|
1561
|
-
if (
|
|
1562
|
-
topY =
|
|
1582
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
1583
|
+
if (bounds) {
|
|
1584
|
+
topY = bounds.top;
|
|
1585
|
+
} else {
|
|
1586
|
+
const startElem = elementMap.get(startElementId);
|
|
1587
|
+
if (startElem) topY = startElem.y;
|
|
1563
1588
|
}
|
|
1564
1589
|
}
|
|
1565
1590
|
if (endElementId) {
|
|
1566
|
-
const
|
|
1567
|
-
if (
|
|
1568
|
-
|
|
1569
|
-
|
|
1591
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
1592
|
+
if (bounds) {
|
|
1593
|
+
bottomY = bounds.bottom;
|
|
1594
|
+
} else {
|
|
1595
|
+
const endElem = elementMap.get(endElementId);
|
|
1596
|
+
if (endElem) {
|
|
1597
|
+
const actualHeight = getActualElementHeight(endElem, textValues, measureCtx);
|
|
1598
|
+
bottomY = endElem.y + actualHeight;
|
|
1599
|
+
}
|
|
1570
1600
|
}
|
|
1571
1601
|
}
|
|
1572
1602
|
cropY = Math.max(0, topY - paddingStart);
|
|
@@ -1601,15 +1631,21 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
1601
1631
|
let leftX = 0;
|
|
1602
1632
|
let rightX = canvasWidth;
|
|
1603
1633
|
if (startElementId) {
|
|
1604
|
-
const
|
|
1605
|
-
if (
|
|
1606
|
-
leftX =
|
|
1634
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
1635
|
+
if (bounds) {
|
|
1636
|
+
leftX = bounds.left;
|
|
1637
|
+
} else {
|
|
1638
|
+
const startElem = elementMap.get(startElementId);
|
|
1639
|
+
if (startElem) leftX = startElem.x;
|
|
1607
1640
|
}
|
|
1608
1641
|
}
|
|
1609
1642
|
if (endElementId) {
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1612
|
-
rightX =
|
|
1643
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
1644
|
+
if (bounds) {
|
|
1645
|
+
rightX = bounds.right;
|
|
1646
|
+
} else {
|
|
1647
|
+
const endElem = elementMap.get(endElementId);
|
|
1648
|
+
if (endElem) rightX = endElem.x + endElem.width;
|
|
1613
1649
|
}
|
|
1614
1650
|
}
|
|
1615
1651
|
cropX = Math.max(0, leftX - paddingStart);
|
package/dist/index.mjs
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -908,6 +908,28 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
908
908
|
const canvas = document.createElement("canvas");
|
|
909
909
|
measureCtx = canvas.getContext("2d");
|
|
910
910
|
}
|
|
911
|
+
const attachmentPrefixes = ["image-", "story-reply-image-", "story-reply-bar-", "story-reply-text-"];
|
|
912
|
+
const getMessageGroupBounds = (messageElementId) => {
|
|
913
|
+
const elem = elementMap.get(messageElementId);
|
|
914
|
+
if (!elem) return void 0;
|
|
915
|
+
const actualHeight = getActualElementHeight(elem, textValues, measureCtx);
|
|
916
|
+
let top = elem.y;
|
|
917
|
+
let bottom = elem.y + actualHeight;
|
|
918
|
+
let left = elem.x;
|
|
919
|
+
let right = elem.x + elem.width;
|
|
920
|
+
const msgIdSuffix = messageElementId.replace(/^message-/, "");
|
|
921
|
+
for (const prefix of attachmentPrefixes) {
|
|
922
|
+
const assocElem = elementMap.get(`${prefix}${msgIdSuffix}`);
|
|
923
|
+
if (assocElem) {
|
|
924
|
+
const assocHeight = getActualElementHeight(assocElem, textValues, measureCtx);
|
|
925
|
+
top = Math.min(top, assocElem.y);
|
|
926
|
+
bottom = Math.max(bottom, assocElem.y + assocHeight);
|
|
927
|
+
left = Math.min(left, assocElem.x);
|
|
928
|
+
right = Math.max(right, assocElem.x + assocElem.width);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return { top, bottom, left, right };
|
|
932
|
+
};
|
|
911
933
|
let cropY = 0;
|
|
912
934
|
let cropHeight = canvasHeight;
|
|
913
935
|
if (dynamicCrop.vertical?.enabled) {
|
|
@@ -933,16 +955,24 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
933
955
|
let topY = 0;
|
|
934
956
|
let bottomY = canvasHeight;
|
|
935
957
|
if (startElementId) {
|
|
936
|
-
const
|
|
937
|
-
if (
|
|
938
|
-
topY =
|
|
958
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
959
|
+
if (bounds) {
|
|
960
|
+
topY = bounds.top;
|
|
961
|
+
} else {
|
|
962
|
+
const startElem = elementMap.get(startElementId);
|
|
963
|
+
if (startElem) topY = startElem.y;
|
|
939
964
|
}
|
|
940
965
|
}
|
|
941
966
|
if (endElementId) {
|
|
942
|
-
const
|
|
943
|
-
if (
|
|
944
|
-
|
|
945
|
-
|
|
967
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
968
|
+
if (bounds) {
|
|
969
|
+
bottomY = bounds.bottom;
|
|
970
|
+
} else {
|
|
971
|
+
const endElem = elementMap.get(endElementId);
|
|
972
|
+
if (endElem) {
|
|
973
|
+
const actualHeight = getActualElementHeight(endElem, textValues, measureCtx);
|
|
974
|
+
bottomY = endElem.y + actualHeight;
|
|
975
|
+
}
|
|
946
976
|
}
|
|
947
977
|
}
|
|
948
978
|
cropY = Math.max(0, topY - paddingStart);
|
|
@@ -977,15 +1007,21 @@ function calculateCropBounds(elements, dynamicCrop, canvasWidth, canvasHeight, t
|
|
|
977
1007
|
let leftX = 0;
|
|
978
1008
|
let rightX = canvasWidth;
|
|
979
1009
|
if (startElementId) {
|
|
980
|
-
const
|
|
981
|
-
if (
|
|
982
|
-
leftX =
|
|
1010
|
+
const bounds = getMessageGroupBounds(startElementId);
|
|
1011
|
+
if (bounds) {
|
|
1012
|
+
leftX = bounds.left;
|
|
1013
|
+
} else {
|
|
1014
|
+
const startElem = elementMap.get(startElementId);
|
|
1015
|
+
if (startElem) leftX = startElem.x;
|
|
983
1016
|
}
|
|
984
1017
|
}
|
|
985
1018
|
if (endElementId) {
|
|
986
|
-
const
|
|
987
|
-
if (
|
|
988
|
-
rightX =
|
|
1019
|
+
const bounds = getMessageGroupBounds(endElementId);
|
|
1020
|
+
if (bounds) {
|
|
1021
|
+
rightX = bounds.right;
|
|
1022
|
+
} else {
|
|
1023
|
+
const endElem = elementMap.get(endElementId);
|
|
1024
|
+
if (endElem) rightX = endElem.x + endElem.width;
|
|
989
1025
|
}
|
|
990
1026
|
}
|
|
991
1027
|
cropX = Math.max(0, leftX - paddingStart);
|
package/dist/utils/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.225",
|
|
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",
|