ugcinc-render 1.8.102 → 1.8.104
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.js +126 -47
- package/dist/index.mjs +107 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2878,7 +2878,7 @@ function ScreenshotAnimation({
|
|
|
2878
2878
|
}
|
|
2879
2879
|
|
|
2880
2880
|
// src/compositions/InstagramDmComposition/index.tsx
|
|
2881
|
-
var
|
|
2881
|
+
var import_react9 = require("react");
|
|
2882
2882
|
var import_remotion10 = require("remotion");
|
|
2883
2883
|
|
|
2884
2884
|
// src/compositions/InstagramDmComposition/theme.ts
|
|
@@ -3524,6 +3524,7 @@ function IgMessageFooter({
|
|
|
3524
3524
|
}
|
|
3525
3525
|
|
|
3526
3526
|
// src/compositions/InstagramDmComposition/components/IgMessages.tsx
|
|
3527
|
+
var import_react8 = __toESM(require("react"));
|
|
3527
3528
|
var import_remotion9 = require("remotion");
|
|
3528
3529
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3529
3530
|
var DEFAULTS2 = {
|
|
@@ -3544,7 +3545,7 @@ var DEFAULTS2 = {
|
|
|
3544
3545
|
bubbleRadiusGrouped: 12,
|
|
3545
3546
|
messageGapInGroup: 6,
|
|
3546
3547
|
messageGapSameUser: 35,
|
|
3547
|
-
messageGapDifferentUser:
|
|
3548
|
+
messageGapDifferentUser: 37,
|
|
3548
3549
|
recipientBubbleLeft: 168,
|
|
3549
3550
|
senderBubbleRight: 1182,
|
|
3550
3551
|
bubbleMaxWidth: 866,
|
|
@@ -3577,11 +3578,93 @@ function getInterpolatedSenderColor(bubbleCenter, messageAreaTop, messageAreaBot
|
|
|
3577
3578
|
}
|
|
3578
3579
|
}
|
|
3579
3580
|
var FONT_FAMILY = '"SF Pro", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif';
|
|
3580
|
-
function
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3581
|
+
function calculateAutoWidthAndLines2({
|
|
3582
|
+
text,
|
|
3583
|
+
maxWidth,
|
|
3584
|
+
paddingLeft,
|
|
3585
|
+
paddingRight,
|
|
3586
|
+
fontSize
|
|
3587
|
+
}) {
|
|
3588
|
+
if (typeof document === "undefined") {
|
|
3589
|
+
return { width: maxWidth, lines: [text] };
|
|
3590
|
+
}
|
|
3591
|
+
const availableWidth = maxWidth - paddingLeft - paddingRight;
|
|
3592
|
+
if (availableWidth <= 0) {
|
|
3593
|
+
return { width: maxWidth, lines: [text] };
|
|
3594
|
+
}
|
|
3595
|
+
const measureSpan = document.createElement("span");
|
|
3596
|
+
measureSpan.style.cssText = `
|
|
3597
|
+
position: absolute;
|
|
3598
|
+
visibility: hidden;
|
|
3599
|
+
pointer-events: none;
|
|
3600
|
+
font-family: ${FONT_FAMILY};
|
|
3601
|
+
font-size: ${fontSize}px;
|
|
3602
|
+
font-weight: 400;
|
|
3603
|
+
letter-spacing: 0px;
|
|
3604
|
+
white-space: nowrap;
|
|
3605
|
+
`;
|
|
3606
|
+
document.body.appendChild(measureSpan);
|
|
3607
|
+
const measureText = (textToMeasure) => {
|
|
3608
|
+
measureSpan.textContent = textToMeasure;
|
|
3609
|
+
return measureSpan.getBoundingClientRect().width;
|
|
3610
|
+
};
|
|
3611
|
+
const words = text.split(/(\s+)/);
|
|
3612
|
+
const lines = [];
|
|
3613
|
+
let currentLine = "";
|
|
3614
|
+
for (let i = 0; i < words.length; i++) {
|
|
3615
|
+
const word = words[i];
|
|
3616
|
+
if (word === "\n" || word === "\r\n") {
|
|
3617
|
+
if (currentLine) lines.push(currentLine);
|
|
3618
|
+
currentLine = "";
|
|
3619
|
+
continue;
|
|
3620
|
+
}
|
|
3621
|
+
if (!word) continue;
|
|
3622
|
+
if (/^\s+$/.test(word)) {
|
|
3623
|
+
if (currentLine) currentLine += word;
|
|
3624
|
+
continue;
|
|
3625
|
+
}
|
|
3626
|
+
const testLine = currentLine + word;
|
|
3627
|
+
const testWidth = measureText(testLine);
|
|
3628
|
+
const WRAP_TOLERANCE = 0.5;
|
|
3629
|
+
if (testWidth > availableWidth + WRAP_TOLERANCE && currentLine.trim()) {
|
|
3630
|
+
lines.push(currentLine.trimEnd());
|
|
3631
|
+
currentLine = word;
|
|
3632
|
+
const wordWidth = measureText(word);
|
|
3633
|
+
if (wordWidth > availableWidth) {
|
|
3634
|
+
let remainingWord = word;
|
|
3635
|
+
while (remainingWord) {
|
|
3636
|
+
let breakPoint = 1;
|
|
3637
|
+
for (let j = 1; j <= remainingWord.length; j++) {
|
|
3638
|
+
measureSpan.textContent = remainingWord.substring(0, j);
|
|
3639
|
+
if (measureSpan.getBoundingClientRect().width > availableWidth) {
|
|
3640
|
+
breakPoint = Math.max(1, j - 1);
|
|
3641
|
+
break;
|
|
3642
|
+
}
|
|
3643
|
+
breakPoint = j;
|
|
3644
|
+
}
|
|
3645
|
+
if (breakPoint >= remainingWord.length) {
|
|
3646
|
+
currentLine = remainingWord;
|
|
3647
|
+
break;
|
|
3648
|
+
} else {
|
|
3649
|
+
lines.push(remainingWord.substring(0, breakPoint));
|
|
3650
|
+
remainingWord = remainingWord.substring(breakPoint);
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
} else {
|
|
3655
|
+
currentLine = testLine;
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
if (currentLine.trim()) lines.push(currentLine.trimEnd());
|
|
3659
|
+
if (lines.length === 0) lines.push("");
|
|
3660
|
+
let widestLineWidth = 0;
|
|
3661
|
+
for (const line of lines) {
|
|
3662
|
+
const lineWidth = measureText(line);
|
|
3663
|
+
widestLineWidth = Math.max(widestLineWidth, lineWidth);
|
|
3664
|
+
}
|
|
3665
|
+
document.body.removeChild(measureSpan);
|
|
3666
|
+
const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
|
|
3667
|
+
return { width: calculatedWidth, lines };
|
|
3585
3668
|
}
|
|
3586
3669
|
function IgMessages({
|
|
3587
3670
|
messages = [],
|
|
@@ -3613,7 +3696,6 @@ function IgMessages({
|
|
|
3613
3696
|
if (messages.length === 0) {
|
|
3614
3697
|
return null;
|
|
3615
3698
|
}
|
|
3616
|
-
const maxTextWidth = bubbleMaxWidth - messagePaddingLeft - messagePaddingRight;
|
|
3617
3699
|
const renderedMessages = [];
|
|
3618
3700
|
let currentBottom = messageAreaBottom;
|
|
3619
3701
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -3636,22 +3718,16 @@ function IgMessages({
|
|
|
3636
3718
|
gap = messageGapDifferentUser;
|
|
3637
3719
|
}
|
|
3638
3720
|
}
|
|
3639
|
-
const
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3721
|
+
const { width: bubbleWidth, lines } = calculateAutoWidthAndLines2({
|
|
3722
|
+
text: message.text,
|
|
3723
|
+
maxWidth: bubbleMaxWidth,
|
|
3724
|
+
paddingLeft: messagePaddingLeft,
|
|
3725
|
+
paddingRight: messagePaddingRight,
|
|
3726
|
+
fontSize: messageFontSize
|
|
3727
|
+
});
|
|
3728
|
+
const lineCount = lines.length;
|
|
3647
3729
|
const textHeight = lineCount * messageLineHeight;
|
|
3648
3730
|
const bubbleHeight = textHeight + messagePaddingTop + messagePaddingBottom;
|
|
3649
|
-
let bubbleWidth;
|
|
3650
|
-
if (fitsOnSingleLine) {
|
|
3651
|
-
bubbleWidth = actualTextWidth + messagePaddingLeft + messagePaddingRight;
|
|
3652
|
-
} else {
|
|
3653
|
-
bubbleWidth = bubbleMaxWidth;
|
|
3654
|
-
}
|
|
3655
3731
|
const bubbleBottom = currentBottom - gap;
|
|
3656
3732
|
const bubbleTop = bubbleBottom - bubbleHeight;
|
|
3657
3733
|
let bubbleLeft;
|
|
@@ -3667,6 +3743,7 @@ function IgMessages({
|
|
|
3667
3743
|
left: bubbleLeft,
|
|
3668
3744
|
width: bubbleWidth,
|
|
3669
3745
|
height: bubbleHeight,
|
|
3746
|
+
lines,
|
|
3670
3747
|
isFirstInGroup,
|
|
3671
3748
|
isLastInGroup,
|
|
3672
3749
|
isSingleMessage
|
|
@@ -3791,10 +3868,12 @@ function IgMessages({
|
|
|
3791
3868
|
fontFamily: '"SF Pro", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif',
|
|
3792
3869
|
fontWeight: 400,
|
|
3793
3870
|
lineHeight: `${messageLineHeight}px`,
|
|
3794
|
-
textAlign: "left"
|
|
3795
|
-
wordBreak: "break-word"
|
|
3871
|
+
textAlign: "left"
|
|
3796
3872
|
},
|
|
3797
|
-
children: rm.
|
|
3873
|
+
children: rm.lines.map((line, idx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react8.default.Fragment, { children: [
|
|
3874
|
+
line,
|
|
3875
|
+
idx < rm.lines.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("br", {})
|
|
3876
|
+
] }, idx))
|
|
3798
3877
|
}
|
|
3799
3878
|
)
|
|
3800
3879
|
},
|
|
@@ -3808,7 +3887,7 @@ function IgMessages({
|
|
|
3808
3887
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3809
3888
|
var defaultInstagramDmProps = {
|
|
3810
3889
|
showDebugOverlay: true,
|
|
3811
|
-
referenceImageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/
|
|
3890
|
+
referenceImageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/IMG_3177-twSYuZPHRoxH9PA2xhpDUeKIg2ny7p.png",
|
|
3812
3891
|
showReferenceImage: true,
|
|
3813
3892
|
referenceOpacity: 50,
|
|
3814
3893
|
width: 1206,
|
|
@@ -3903,7 +3982,7 @@ var defaultInstagramDmProps = {
|
|
|
3903
3982
|
bubbleRadiusGrouped: 12,
|
|
3904
3983
|
messageGapInGroup: DEFAULTS2.messageGapInGroup,
|
|
3905
3984
|
messageGapSameUser: DEFAULTS2.messageGapSameUser,
|
|
3906
|
-
messageGapDifferentUser:
|
|
3985
|
+
messageGapDifferentUser: 37,
|
|
3907
3986
|
recipientBubbleLeft: DEFAULTS2.recipientBubbleLeft,
|
|
3908
3987
|
senderBubbleRight: DEFAULTS2.senderBubbleRight,
|
|
3909
3988
|
bubbleMaxWidth: DEFAULTS2.bubbleMaxWidth,
|
|
@@ -3991,20 +4070,20 @@ function InstagramDmComposition({
|
|
|
3991
4070
|
profilePicGap
|
|
3992
4071
|
}) {
|
|
3993
4072
|
const clampedReferenceOpacity = Math.max(0, Math.min(100, referenceOpacity));
|
|
3994
|
-
const [fontsLoaded, setFontsLoaded] = (0,
|
|
3995
|
-
const [zoom, setZoom] = (0,
|
|
3996
|
-
const [scrollX, setScrollX] = (0,
|
|
3997
|
-
const [scrollY, setScrollY] = (0,
|
|
3998
|
-
const [referenceVisible, setReferenceVisible] = (0,
|
|
3999
|
-
const handleZoomChange = (0,
|
|
4073
|
+
const [fontsLoaded, setFontsLoaded] = (0, import_react9.useState)(false);
|
|
4074
|
+
const [zoom, setZoom] = (0, import_react9.useState)(100);
|
|
4075
|
+
const [scrollX, setScrollX] = (0, import_react9.useState)(0);
|
|
4076
|
+
const [scrollY, setScrollY] = (0, import_react9.useState)(0);
|
|
4077
|
+
const [referenceVisible, setReferenceVisible] = (0, import_react9.useState)(true);
|
|
4078
|
+
const handleZoomChange = (0, import_react9.useCallback)((newZoom, newScrollX, newScrollY) => {
|
|
4000
4079
|
setZoom(newZoom);
|
|
4001
4080
|
setScrollX(newScrollX);
|
|
4002
4081
|
setScrollY(newScrollY);
|
|
4003
4082
|
}, []);
|
|
4004
|
-
const handleToggleReference = (0,
|
|
4083
|
+
const handleToggleReference = (0, import_react9.useCallback)(() => {
|
|
4005
4084
|
setReferenceVisible((prev) => !prev);
|
|
4006
4085
|
}, []);
|
|
4007
|
-
(0,
|
|
4086
|
+
(0, import_react9.useEffect)(() => {
|
|
4008
4087
|
const interceptBeforeUnload = (e) => {
|
|
4009
4088
|
e.stopImmediatePropagation();
|
|
4010
4089
|
};
|
|
@@ -4023,7 +4102,7 @@ function InstagramDmComposition({
|
|
|
4023
4102
|
window.removeEventListener("beforeunload", interceptBeforeUnload, { capture: true });
|
|
4024
4103
|
};
|
|
4025
4104
|
}, []);
|
|
4026
|
-
(0,
|
|
4105
|
+
(0, import_react9.useEffect)(() => {
|
|
4027
4106
|
const handle = (0, import_remotion10.delayRender)("Loading fonts...");
|
|
4028
4107
|
preloadFonts().then(() => {
|
|
4029
4108
|
setFontsLoaded(true);
|
|
@@ -4923,10 +5002,10 @@ function isValidCaptionPreset(name) {
|
|
|
4923
5002
|
}
|
|
4924
5003
|
|
|
4925
5004
|
// src/hooks/index.ts
|
|
4926
|
-
var
|
|
5005
|
+
var import_react10 = require("react");
|
|
4927
5006
|
function useFontsLoaded() {
|
|
4928
|
-
const [loaded, setLoaded] = (0,
|
|
4929
|
-
(0,
|
|
5007
|
+
const [loaded, setLoaded] = (0, import_react10.useState)(areFontsLoaded());
|
|
5008
|
+
(0, import_react10.useEffect)(() => {
|
|
4930
5009
|
if (!loaded) {
|
|
4931
5010
|
preloadFonts().then(() => setLoaded(true)).catch(console.error);
|
|
4932
5011
|
}
|
|
@@ -4934,8 +5013,8 @@ function useFontsLoaded() {
|
|
|
4934
5013
|
return loaded;
|
|
4935
5014
|
}
|
|
4936
5015
|
function useImageLoader(src) {
|
|
4937
|
-
const [image, setImage] = (0,
|
|
4938
|
-
(0,
|
|
5016
|
+
const [image, setImage] = (0, import_react10.useState)(null);
|
|
5017
|
+
(0, import_react10.useEffect)(() => {
|
|
4939
5018
|
if (!src) {
|
|
4940
5019
|
setImage(null);
|
|
4941
5020
|
return;
|
|
@@ -4955,9 +5034,9 @@ function useImageLoader(src) {
|
|
|
4955
5034
|
return image;
|
|
4956
5035
|
}
|
|
4957
5036
|
function useImagePreloader(sources) {
|
|
4958
|
-
const [images, setImages] = (0,
|
|
4959
|
-
const [loaded, setLoaded] = (0,
|
|
4960
|
-
(0,
|
|
5037
|
+
const [images, setImages] = (0, import_react10.useState)({});
|
|
5038
|
+
const [loaded, setLoaded] = (0, import_react10.useState)(false);
|
|
5039
|
+
(0, import_react10.useEffect)(() => {
|
|
4961
5040
|
const entries = Object.entries(sources);
|
|
4962
5041
|
if (entries.length === 0) {
|
|
4963
5042
|
setLoaded(true);
|
|
@@ -4995,7 +5074,7 @@ function useImagePreloader(sources) {
|
|
|
4995
5074
|
return { loaded, images };
|
|
4996
5075
|
}
|
|
4997
5076
|
function useResolvedPositions(elements, textValues) {
|
|
4998
|
-
return (0,
|
|
5077
|
+
return (0, import_react10.useMemo)(() => {
|
|
4999
5078
|
if (elements.length === 0) {
|
|
5000
5079
|
return { elements: [], errors: [] };
|
|
5001
5080
|
}
|
|
@@ -5189,7 +5268,7 @@ var instagramDmSchema = import_zod.z.object({
|
|
|
5189
5268
|
// Debug overlay
|
|
5190
5269
|
showDebugOverlay: import_zod.z.boolean().optional().default(true).describe("Show debug overlay with mouse coordinates"),
|
|
5191
5270
|
// Reference overlay
|
|
5192
|
-
referenceImageUrl: import_zod.z.string().optional().default("https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/
|
|
5271
|
+
referenceImageUrl: import_zod.z.string().optional().default("https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/IMG_3177-twSYuZPHRoxH9PA2xhpDUeKIg2ny7p.png").describe("Reference screenshot URL"),
|
|
5193
5272
|
showReferenceImage: import_zod.z.boolean().optional().default(true).describe("Show/hide reference image"),
|
|
5194
5273
|
referenceOpacity: import_zod.z.number().min(0).max(100).optional().default(50).describe("Reference overlay opacity (0-100)"),
|
|
5195
5274
|
// Canvas
|
|
@@ -5281,7 +5360,7 @@ var instagramDmSchema = import_zod.z.object({
|
|
|
5281
5360
|
// Message spacing
|
|
5282
5361
|
messageGapInGroup: import_zod.z.number().optional().default(6).describe("Gap between messages in group"),
|
|
5283
5362
|
messageGapSameUser: import_zod.z.number().optional().default(35).describe("Gap between messages from same user"),
|
|
5284
|
-
messageGapDifferentUser: import_zod.z.number().optional().default(
|
|
5363
|
+
messageGapDifferentUser: import_zod.z.number().optional().default(37).describe("Gap between messages from different users"),
|
|
5285
5364
|
// Bubble positioning
|
|
5286
5365
|
recipientBubbleLeft: import_zod.z.number().optional().default(168).describe("Recipient bubble left X"),
|
|
5287
5366
|
senderBubbleRight: import_zod.z.number().optional().default(1182).describe("Sender bubble right X"),
|
package/dist/index.mjs
CHANGED
|
@@ -2593,6 +2593,7 @@ function IgMessageFooter({
|
|
|
2593
2593
|
}
|
|
2594
2594
|
|
|
2595
2595
|
// src/compositions/InstagramDmComposition/components/IgMessages.tsx
|
|
2596
|
+
import React8 from "react";
|
|
2596
2597
|
import { Img as Img5 } from "remotion";
|
|
2597
2598
|
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2598
2599
|
var DEFAULTS2 = {
|
|
@@ -2613,7 +2614,7 @@ var DEFAULTS2 = {
|
|
|
2613
2614
|
bubbleRadiusGrouped: 12,
|
|
2614
2615
|
messageGapInGroup: 6,
|
|
2615
2616
|
messageGapSameUser: 35,
|
|
2616
|
-
messageGapDifferentUser:
|
|
2617
|
+
messageGapDifferentUser: 37,
|
|
2617
2618
|
recipientBubbleLeft: 168,
|
|
2618
2619
|
senderBubbleRight: 1182,
|
|
2619
2620
|
bubbleMaxWidth: 866,
|
|
@@ -2646,11 +2647,93 @@ function getInterpolatedSenderColor(bubbleCenter, messageAreaTop, messageAreaBot
|
|
|
2646
2647
|
}
|
|
2647
2648
|
}
|
|
2648
2649
|
var FONT_FAMILY = '"SF Pro", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif';
|
|
2649
|
-
function
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2650
|
+
function calculateAutoWidthAndLines2({
|
|
2651
|
+
text,
|
|
2652
|
+
maxWidth,
|
|
2653
|
+
paddingLeft,
|
|
2654
|
+
paddingRight,
|
|
2655
|
+
fontSize
|
|
2656
|
+
}) {
|
|
2657
|
+
if (typeof document === "undefined") {
|
|
2658
|
+
return { width: maxWidth, lines: [text] };
|
|
2659
|
+
}
|
|
2660
|
+
const availableWidth = maxWidth - paddingLeft - paddingRight;
|
|
2661
|
+
if (availableWidth <= 0) {
|
|
2662
|
+
return { width: maxWidth, lines: [text] };
|
|
2663
|
+
}
|
|
2664
|
+
const measureSpan = document.createElement("span");
|
|
2665
|
+
measureSpan.style.cssText = `
|
|
2666
|
+
position: absolute;
|
|
2667
|
+
visibility: hidden;
|
|
2668
|
+
pointer-events: none;
|
|
2669
|
+
font-family: ${FONT_FAMILY};
|
|
2670
|
+
font-size: ${fontSize}px;
|
|
2671
|
+
font-weight: 400;
|
|
2672
|
+
letter-spacing: 0px;
|
|
2673
|
+
white-space: nowrap;
|
|
2674
|
+
`;
|
|
2675
|
+
document.body.appendChild(measureSpan);
|
|
2676
|
+
const measureText = (textToMeasure) => {
|
|
2677
|
+
measureSpan.textContent = textToMeasure;
|
|
2678
|
+
return measureSpan.getBoundingClientRect().width;
|
|
2679
|
+
};
|
|
2680
|
+
const words = text.split(/(\s+)/);
|
|
2681
|
+
const lines = [];
|
|
2682
|
+
let currentLine = "";
|
|
2683
|
+
for (let i = 0; i < words.length; i++) {
|
|
2684
|
+
const word = words[i];
|
|
2685
|
+
if (word === "\n" || word === "\r\n") {
|
|
2686
|
+
if (currentLine) lines.push(currentLine);
|
|
2687
|
+
currentLine = "";
|
|
2688
|
+
continue;
|
|
2689
|
+
}
|
|
2690
|
+
if (!word) continue;
|
|
2691
|
+
if (/^\s+$/.test(word)) {
|
|
2692
|
+
if (currentLine) currentLine += word;
|
|
2693
|
+
continue;
|
|
2694
|
+
}
|
|
2695
|
+
const testLine = currentLine + word;
|
|
2696
|
+
const testWidth = measureText(testLine);
|
|
2697
|
+
const WRAP_TOLERANCE = 0.5;
|
|
2698
|
+
if (testWidth > availableWidth + WRAP_TOLERANCE && currentLine.trim()) {
|
|
2699
|
+
lines.push(currentLine.trimEnd());
|
|
2700
|
+
currentLine = word;
|
|
2701
|
+
const wordWidth = measureText(word);
|
|
2702
|
+
if (wordWidth > availableWidth) {
|
|
2703
|
+
let remainingWord = word;
|
|
2704
|
+
while (remainingWord) {
|
|
2705
|
+
let breakPoint = 1;
|
|
2706
|
+
for (let j = 1; j <= remainingWord.length; j++) {
|
|
2707
|
+
measureSpan.textContent = remainingWord.substring(0, j);
|
|
2708
|
+
if (measureSpan.getBoundingClientRect().width > availableWidth) {
|
|
2709
|
+
breakPoint = Math.max(1, j - 1);
|
|
2710
|
+
break;
|
|
2711
|
+
}
|
|
2712
|
+
breakPoint = j;
|
|
2713
|
+
}
|
|
2714
|
+
if (breakPoint >= remainingWord.length) {
|
|
2715
|
+
currentLine = remainingWord;
|
|
2716
|
+
break;
|
|
2717
|
+
} else {
|
|
2718
|
+
lines.push(remainingWord.substring(0, breakPoint));
|
|
2719
|
+
remainingWord = remainingWord.substring(breakPoint);
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
} else {
|
|
2724
|
+
currentLine = testLine;
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
if (currentLine.trim()) lines.push(currentLine.trimEnd());
|
|
2728
|
+
if (lines.length === 0) lines.push("");
|
|
2729
|
+
let widestLineWidth = 0;
|
|
2730
|
+
for (const line of lines) {
|
|
2731
|
+
const lineWidth = measureText(line);
|
|
2732
|
+
widestLineWidth = Math.max(widestLineWidth, lineWidth);
|
|
2733
|
+
}
|
|
2734
|
+
document.body.removeChild(measureSpan);
|
|
2735
|
+
const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
|
|
2736
|
+
return { width: calculatedWidth, lines };
|
|
2654
2737
|
}
|
|
2655
2738
|
function IgMessages({
|
|
2656
2739
|
messages = [],
|
|
@@ -2682,7 +2765,6 @@ function IgMessages({
|
|
|
2682
2765
|
if (messages.length === 0) {
|
|
2683
2766
|
return null;
|
|
2684
2767
|
}
|
|
2685
|
-
const maxTextWidth = bubbleMaxWidth - messagePaddingLeft - messagePaddingRight;
|
|
2686
2768
|
const renderedMessages = [];
|
|
2687
2769
|
let currentBottom = messageAreaBottom;
|
|
2688
2770
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -2705,22 +2787,16 @@ function IgMessages({
|
|
|
2705
2787
|
gap = messageGapDifferentUser;
|
|
2706
2788
|
}
|
|
2707
2789
|
}
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2790
|
+
const { width: bubbleWidth, lines } = calculateAutoWidthAndLines2({
|
|
2791
|
+
text: message.text,
|
|
2792
|
+
maxWidth: bubbleMaxWidth,
|
|
2793
|
+
paddingLeft: messagePaddingLeft,
|
|
2794
|
+
paddingRight: messagePaddingRight,
|
|
2795
|
+
fontSize: messageFontSize
|
|
2796
|
+
});
|
|
2797
|
+
const lineCount = lines.length;
|
|
2716
2798
|
const textHeight = lineCount * messageLineHeight;
|
|
2717
2799
|
const bubbleHeight = textHeight + messagePaddingTop + messagePaddingBottom;
|
|
2718
|
-
let bubbleWidth;
|
|
2719
|
-
if (fitsOnSingleLine) {
|
|
2720
|
-
bubbleWidth = actualTextWidth + messagePaddingLeft + messagePaddingRight;
|
|
2721
|
-
} else {
|
|
2722
|
-
bubbleWidth = bubbleMaxWidth;
|
|
2723
|
-
}
|
|
2724
2800
|
const bubbleBottom = currentBottom - gap;
|
|
2725
2801
|
const bubbleTop = bubbleBottom - bubbleHeight;
|
|
2726
2802
|
let bubbleLeft;
|
|
@@ -2736,6 +2812,7 @@ function IgMessages({
|
|
|
2736
2812
|
left: bubbleLeft,
|
|
2737
2813
|
width: bubbleWidth,
|
|
2738
2814
|
height: bubbleHeight,
|
|
2815
|
+
lines,
|
|
2739
2816
|
isFirstInGroup,
|
|
2740
2817
|
isLastInGroup,
|
|
2741
2818
|
isSingleMessage
|
|
@@ -2860,10 +2937,12 @@ function IgMessages({
|
|
|
2860
2937
|
fontFamily: '"SF Pro", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif',
|
|
2861
2938
|
fontWeight: 400,
|
|
2862
2939
|
lineHeight: `${messageLineHeight}px`,
|
|
2863
|
-
textAlign: "left"
|
|
2864
|
-
wordBreak: "break-word"
|
|
2940
|
+
textAlign: "left"
|
|
2865
2941
|
},
|
|
2866
|
-
children: rm.
|
|
2942
|
+
children: rm.lines.map((line, idx) => /* @__PURE__ */ jsxs9(React8.Fragment, { children: [
|
|
2943
|
+
line,
|
|
2944
|
+
idx < rm.lines.length - 1 && /* @__PURE__ */ jsx11("br", {})
|
|
2945
|
+
] }, idx))
|
|
2867
2946
|
}
|
|
2868
2947
|
)
|
|
2869
2948
|
},
|
|
@@ -2877,7 +2956,7 @@ function IgMessages({
|
|
|
2877
2956
|
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2878
2957
|
var defaultInstagramDmProps = {
|
|
2879
2958
|
showDebugOverlay: true,
|
|
2880
|
-
referenceImageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/
|
|
2959
|
+
referenceImageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/IMG_3177-twSYuZPHRoxH9PA2xhpDUeKIg2ny7p.png",
|
|
2881
2960
|
showReferenceImage: true,
|
|
2882
2961
|
referenceOpacity: 50,
|
|
2883
2962
|
width: 1206,
|
|
@@ -2972,7 +3051,7 @@ var defaultInstagramDmProps = {
|
|
|
2972
3051
|
bubbleRadiusGrouped: 12,
|
|
2973
3052
|
messageGapInGroup: DEFAULTS2.messageGapInGroup,
|
|
2974
3053
|
messageGapSameUser: DEFAULTS2.messageGapSameUser,
|
|
2975
|
-
messageGapDifferentUser:
|
|
3054
|
+
messageGapDifferentUser: 37,
|
|
2976
3055
|
recipientBubbleLeft: DEFAULTS2.recipientBubbleLeft,
|
|
2977
3056
|
senderBubbleRight: DEFAULTS2.senderBubbleRight,
|
|
2978
3057
|
bubbleMaxWidth: DEFAULTS2.bubbleMaxWidth,
|
|
@@ -3975,7 +4054,7 @@ var instagramDmSchema = z.object({
|
|
|
3975
4054
|
// Debug overlay
|
|
3976
4055
|
showDebugOverlay: z.boolean().optional().default(true).describe("Show debug overlay with mouse coordinates"),
|
|
3977
4056
|
// Reference overlay
|
|
3978
|
-
referenceImageUrl: z.string().optional().default("https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/
|
|
4057
|
+
referenceImageUrl: z.string().optional().default("https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/8ff1462b-13d7-4abe-9325-0a6ad19004f0/IMG_3177-twSYuZPHRoxH9PA2xhpDUeKIg2ny7p.png").describe("Reference screenshot URL"),
|
|
3979
4058
|
showReferenceImage: z.boolean().optional().default(true).describe("Show/hide reference image"),
|
|
3980
4059
|
referenceOpacity: z.number().min(0).max(100).optional().default(50).describe("Reference overlay opacity (0-100)"),
|
|
3981
4060
|
// Canvas
|
|
@@ -4067,7 +4146,7 @@ var instagramDmSchema = z.object({
|
|
|
4067
4146
|
// Message spacing
|
|
4068
4147
|
messageGapInGroup: z.number().optional().default(6).describe("Gap between messages in group"),
|
|
4069
4148
|
messageGapSameUser: z.number().optional().default(35).describe("Gap between messages from same user"),
|
|
4070
|
-
messageGapDifferentUser: z.number().optional().default(
|
|
4149
|
+
messageGapDifferentUser: z.number().optional().default(37).describe("Gap between messages from different users"),
|
|
4071
4150
|
// Bubble positioning
|
|
4072
4151
|
recipientBubbleLeft: z.number().optional().default(168).describe("Recipient bubble left X"),
|
|
4073
4152
|
senderBubbleRight: z.number().optional().default(1182).describe("Sender bubble right X"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.104",
|
|
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",
|