ugcinc-render 1.8.160 → 1.8.162
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 +15 -12
- package/dist/index.d.ts +15 -12
- package/dist/index.js +305 -123
- package/dist/index.mjs +305 -123
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1080,23 +1080,26 @@ interface IMessageDmCompositionProps {
|
|
|
1080
1080
|
messageTextLetterSpacing?: number;
|
|
1081
1081
|
messageTextColor?: string;
|
|
1082
1082
|
messageText?: string;
|
|
1083
|
+
messageAreaTop?: number;
|
|
1084
|
+
messageAreaBottom?: number;
|
|
1083
1085
|
senderBubbleColor?: string;
|
|
1084
1086
|
recipientBubbleColor?: string;
|
|
1085
1087
|
bubbleTextColor?: string;
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1088
|
+
messageFontSize?: number;
|
|
1089
|
+
messageLineHeight?: number;
|
|
1090
|
+
messageLetterSpacing?: number;
|
|
1091
|
+
messagePaddingTop?: number;
|
|
1092
|
+
messagePaddingBottom?: number;
|
|
1093
|
+
messagePaddingLeft?: number;
|
|
1094
|
+
messagePaddingRight?: number;
|
|
1095
|
+
bubbleRadiusNormal?: number;
|
|
1096
|
+
bubbleRadiusGrouped?: number;
|
|
1097
|
+
messageGapInGroup?: number;
|
|
1091
1098
|
messageGapSameUser?: number;
|
|
1092
1099
|
messageGapDifferentUser?: number;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
receivedMessagePaddingRight?: number;
|
|
1097
|
-
multiLineSentMessagePaddingLeft?: number;
|
|
1098
|
-
multiLineReceivedMessagePaddingRight?: number;
|
|
1099
|
-
messagesAnchorY?: number;
|
|
1100
|
+
recipientBubbleLeft?: number;
|
|
1101
|
+
senderBubbleRight?: number;
|
|
1102
|
+
bubbleMaxWidth?: number;
|
|
1100
1103
|
messages?: ImMessage[];
|
|
1101
1104
|
}
|
|
1102
1105
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1080,23 +1080,26 @@ interface IMessageDmCompositionProps {
|
|
|
1080
1080
|
messageTextLetterSpacing?: number;
|
|
1081
1081
|
messageTextColor?: string;
|
|
1082
1082
|
messageText?: string;
|
|
1083
|
+
messageAreaTop?: number;
|
|
1084
|
+
messageAreaBottom?: number;
|
|
1083
1085
|
senderBubbleColor?: string;
|
|
1084
1086
|
recipientBubbleColor?: string;
|
|
1085
1087
|
bubbleTextColor?: string;
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1088
|
+
messageFontSize?: number;
|
|
1089
|
+
messageLineHeight?: number;
|
|
1090
|
+
messageLetterSpacing?: number;
|
|
1091
|
+
messagePaddingTop?: number;
|
|
1092
|
+
messagePaddingBottom?: number;
|
|
1093
|
+
messagePaddingLeft?: number;
|
|
1094
|
+
messagePaddingRight?: number;
|
|
1095
|
+
bubbleRadiusNormal?: number;
|
|
1096
|
+
bubbleRadiusGrouped?: number;
|
|
1097
|
+
messageGapInGroup?: number;
|
|
1091
1098
|
messageGapSameUser?: number;
|
|
1092
1099
|
messageGapDifferentUser?: number;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
receivedMessagePaddingRight?: number;
|
|
1097
|
-
multiLineSentMessagePaddingLeft?: number;
|
|
1098
|
-
multiLineReceivedMessagePaddingRight?: number;
|
|
1099
|
-
messagesAnchorY?: number;
|
|
1100
|
+
recipientBubbleLeft?: number;
|
|
1101
|
+
senderBubbleRight?: number;
|
|
1102
|
+
bubbleMaxWidth?: number;
|
|
1100
1103
|
messages?: ImMessage[];
|
|
1101
1104
|
}
|
|
1102
1105
|
|
package/dist/index.js
CHANGED
|
@@ -5255,159 +5255,323 @@ var import_remotion10 = require("remotion");
|
|
|
5255
5255
|
|
|
5256
5256
|
// src/compositions/IMessageDmComposition/convertPropsToElements.ts
|
|
5257
5257
|
var MESSAGE_DEFAULTS2 = {
|
|
5258
|
+
// Message area bounds
|
|
5259
|
+
messageAreaTop: 450,
|
|
5260
|
+
messageAreaBottom: 2310,
|
|
5261
|
+
// Message colors
|
|
5258
5262
|
senderBubbleColor: "#1a42d5",
|
|
5259
5263
|
recipientBubbleColor: "#303032",
|
|
5260
5264
|
bubbleTextColor: "#ffffff",
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5265
|
+
// Message typography
|
|
5266
|
+
messageFontSize: 48,
|
|
5267
|
+
messageLineHeight: 60,
|
|
5268
|
+
messageLetterSpacing: 0.5,
|
|
5269
|
+
// Message padding (inside bubble)
|
|
5270
|
+
messagePaddingTop: 20,
|
|
5271
|
+
messagePaddingBottom: 20,
|
|
5272
|
+
messagePaddingLeft: 39,
|
|
5273
|
+
messagePaddingRight: 39,
|
|
5274
|
+
// Bubble corner radii
|
|
5275
|
+
bubbleRadiusNormal: 40,
|
|
5276
|
+
bubbleRadiusGrouped: 10,
|
|
5277
|
+
// Message spacing
|
|
5278
|
+
messageGapInGroup: 6,
|
|
5266
5279
|
messageGapSameUser: 8,
|
|
5267
5280
|
messageGapDifferentUser: 36,
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
multiLineSentMessagePaddingLeft: 31,
|
|
5273
|
-
multiLineReceivedMessagePaddingRight: 31,
|
|
5274
|
-
messagesAnchorY: 2340,
|
|
5281
|
+
// Bubble positioning
|
|
5282
|
+
recipientBubbleLeft: 48,
|
|
5283
|
+
senderBubbleRight: 1178,
|
|
5284
|
+
bubbleMaxWidth: 900,
|
|
5275
5285
|
// Image message defaults
|
|
5276
5286
|
imageMaxWidth: 600,
|
|
5277
5287
|
imageAspectRatio: 1,
|
|
5278
|
-
// width / height
|
|
5279
5288
|
imageBorderRadius: 30,
|
|
5280
5289
|
imageGapToText: 8
|
|
5281
5290
|
};
|
|
5291
|
+
var FONT_FAMILY2 = getFontFamily("apple");
|
|
5292
|
+
function calculateAutoWidthAndLines3({
|
|
5293
|
+
text,
|
|
5294
|
+
maxWidth,
|
|
5295
|
+
paddingLeft,
|
|
5296
|
+
paddingRight,
|
|
5297
|
+
fontSize,
|
|
5298
|
+
letterSpacing
|
|
5299
|
+
}) {
|
|
5300
|
+
if (typeof document === "undefined") {
|
|
5301
|
+
return { width: maxWidth, lines: [text] };
|
|
5302
|
+
}
|
|
5303
|
+
const availableWidth = maxWidth - paddingLeft - paddingRight;
|
|
5304
|
+
if (availableWidth <= 0) {
|
|
5305
|
+
return { width: maxWidth, lines: [text] };
|
|
5306
|
+
}
|
|
5307
|
+
const measureSpan = document.createElement("span");
|
|
5308
|
+
measureSpan.style.cssText = `
|
|
5309
|
+
position: absolute;
|
|
5310
|
+
visibility: hidden;
|
|
5311
|
+
pointer-events: none;
|
|
5312
|
+
font-family: ${FONT_FAMILY2};
|
|
5313
|
+
font-size: ${fontSize}px;
|
|
5314
|
+
font-weight: normal;
|
|
5315
|
+
letter-spacing: ${letterSpacing}px;
|
|
5316
|
+
white-space: nowrap;
|
|
5317
|
+
`;
|
|
5318
|
+
document.body.appendChild(measureSpan);
|
|
5319
|
+
const measureText = (textToMeasure) => {
|
|
5320
|
+
measureSpan.textContent = textToMeasure;
|
|
5321
|
+
return measureSpan.getBoundingClientRect().width;
|
|
5322
|
+
};
|
|
5323
|
+
const words = text.split(/(\s+)/);
|
|
5324
|
+
const lines = [];
|
|
5325
|
+
let currentLine = "";
|
|
5326
|
+
for (let i = 0; i < words.length; i++) {
|
|
5327
|
+
const word = words[i];
|
|
5328
|
+
if (word === "\n" || word === "\r\n") {
|
|
5329
|
+
if (currentLine) lines.push(currentLine);
|
|
5330
|
+
currentLine = "";
|
|
5331
|
+
continue;
|
|
5332
|
+
}
|
|
5333
|
+
if (!word) continue;
|
|
5334
|
+
if (/^\s+$/.test(word)) {
|
|
5335
|
+
if (currentLine) currentLine += word;
|
|
5336
|
+
continue;
|
|
5337
|
+
}
|
|
5338
|
+
const testLine = currentLine + word;
|
|
5339
|
+
const testWidth = measureText(testLine);
|
|
5340
|
+
const WRAP_TOLERANCE = 0.5;
|
|
5341
|
+
if (testWidth > availableWidth + WRAP_TOLERANCE) {
|
|
5342
|
+
if (currentLine.trim()) {
|
|
5343
|
+
lines.push(currentLine.trimEnd());
|
|
5344
|
+
currentLine = "";
|
|
5345
|
+
}
|
|
5346
|
+
const wordWidth = measureText(word);
|
|
5347
|
+
if (wordWidth > availableWidth) {
|
|
5348
|
+
let remainingWord = word;
|
|
5349
|
+
while (remainingWord) {
|
|
5350
|
+
let breakPoint = 1;
|
|
5351
|
+
for (let j = 1; j <= remainingWord.length; j++) {
|
|
5352
|
+
measureSpan.textContent = remainingWord.substring(0, j);
|
|
5353
|
+
if (measureSpan.getBoundingClientRect().width > availableWidth) {
|
|
5354
|
+
breakPoint = Math.max(1, j - 1);
|
|
5355
|
+
break;
|
|
5356
|
+
}
|
|
5357
|
+
breakPoint = j;
|
|
5358
|
+
}
|
|
5359
|
+
if (breakPoint >= remainingWord.length) {
|
|
5360
|
+
currentLine = remainingWord;
|
|
5361
|
+
break;
|
|
5362
|
+
} else {
|
|
5363
|
+
lines.push(remainingWord.substring(0, breakPoint));
|
|
5364
|
+
remainingWord = remainingWord.substring(breakPoint);
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5367
|
+
} else {
|
|
5368
|
+
currentLine = word;
|
|
5369
|
+
}
|
|
5370
|
+
} else {
|
|
5371
|
+
currentLine = testLine;
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
if (currentLine.trim()) lines.push(currentLine.trimEnd());
|
|
5375
|
+
if (lines.length === 0) lines.push("");
|
|
5376
|
+
let widestLineWidth = 0;
|
|
5377
|
+
for (const line of lines) {
|
|
5378
|
+
const lineWidth = measureText(line);
|
|
5379
|
+
widestLineWidth = Math.max(widestLineWidth, lineWidth);
|
|
5380
|
+
}
|
|
5381
|
+
document.body.removeChild(measureSpan);
|
|
5382
|
+
const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
|
|
5383
|
+
return { width: calculatedWidth, lines };
|
|
5384
|
+
}
|
|
5282
5385
|
function calculateMessagePositions2(props) {
|
|
5283
5386
|
const messages = props.messages ?? [];
|
|
5284
5387
|
if (messages.length === 0) return [];
|
|
5285
|
-
const
|
|
5286
|
-
const
|
|
5388
|
+
const messageAreaBottom = props.messageAreaBottom ?? MESSAGE_DEFAULTS2.messageAreaBottom;
|
|
5389
|
+
const messageFontSize = props.messageFontSize ?? MESSAGE_DEFAULTS2.messageFontSize;
|
|
5390
|
+
const messageLineHeight = props.messageLineHeight ?? MESSAGE_DEFAULTS2.messageLineHeight;
|
|
5391
|
+
const messageLetterSpacing = props.messageLetterSpacing ?? MESSAGE_DEFAULTS2.messageLetterSpacing;
|
|
5392
|
+
const messagePaddingTop = props.messagePaddingTop ?? MESSAGE_DEFAULTS2.messagePaddingTop;
|
|
5393
|
+
const messagePaddingBottom = props.messagePaddingBottom ?? MESSAGE_DEFAULTS2.messagePaddingBottom;
|
|
5394
|
+
const messagePaddingLeft = props.messagePaddingLeft ?? MESSAGE_DEFAULTS2.messagePaddingLeft;
|
|
5395
|
+
const messagePaddingRight = props.messagePaddingRight ?? MESSAGE_DEFAULTS2.messagePaddingRight;
|
|
5396
|
+
const messageGapInGroup = props.messageGapInGroup ?? MESSAGE_DEFAULTS2.messageGapInGroup;
|
|
5287
5397
|
const messageGapSameUser = props.messageGapSameUser ?? MESSAGE_DEFAULTS2.messageGapSameUser;
|
|
5288
5398
|
const messageGapDifferentUser = props.messageGapDifferentUser ?? MESSAGE_DEFAULTS2.messageGapDifferentUser;
|
|
5289
|
-
const
|
|
5290
|
-
const
|
|
5291
|
-
const
|
|
5292
|
-
const receivedMessagePaddingRight = props.receivedMessagePaddingRight ?? MESSAGE_DEFAULTS2.receivedMessagePaddingRight;
|
|
5293
|
-
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
5294
|
-
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
5295
|
-
const bubbleTextFontSize = props.bubbleTextFontSize ?? MESSAGE_DEFAULTS2.bubbleTextFontSize;
|
|
5399
|
+
const recipientBubbleLeft = props.recipientBubbleLeft ?? MESSAGE_DEFAULTS2.recipientBubbleLeft;
|
|
5400
|
+
const senderBubbleRight = props.senderBubbleRight ?? MESSAGE_DEFAULTS2.senderBubbleRight;
|
|
5401
|
+
const bubbleMaxWidth = props.bubbleMaxWidth ?? MESSAGE_DEFAULTS2.bubbleMaxWidth;
|
|
5296
5402
|
const imageMaxWidth = MESSAGE_DEFAULTS2.imageMaxWidth;
|
|
5297
5403
|
const imageAspectRatio = MESSAGE_DEFAULTS2.imageAspectRatio;
|
|
5298
5404
|
const imageGapToText = MESSAGE_DEFAULTS2.imageGapToText;
|
|
5299
5405
|
const calculatedMessages = [];
|
|
5300
|
-
let
|
|
5406
|
+
let currentBottom = messageAreaBottom;
|
|
5301
5407
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
5302
|
-
const
|
|
5303
|
-
if (!
|
|
5304
|
-
const
|
|
5305
|
-
const
|
|
5306
|
-
const
|
|
5307
|
-
const
|
|
5308
|
-
const
|
|
5309
|
-
const
|
|
5310
|
-
const
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5408
|
+
const message = messages[i];
|
|
5409
|
+
if (!message) continue;
|
|
5410
|
+
const prevMessage = i > 0 ? messages[i - 1] : null;
|
|
5411
|
+
const nextMessage = i < messages.length - 1 ? messages[i + 1] : null;
|
|
5412
|
+
const isGroupedWithPrev = message.groupWithPrevious && prevMessage?.sender === message.sender;
|
|
5413
|
+
const isGroupedWithNext = nextMessage?.groupWithPrevious && nextMessage?.sender === message.sender;
|
|
5414
|
+
const isFirstInGroup = !isGroupedWithPrev;
|
|
5415
|
+
const isLastInGroup = !isGroupedWithNext;
|
|
5416
|
+
const isSingleMessage = isFirstInGroup && isLastInGroup;
|
|
5417
|
+
let gap = 0;
|
|
5418
|
+
if (i < messages.length - 1) {
|
|
5419
|
+
const belowMessage = messages[i + 1];
|
|
5420
|
+
if (belowMessage?.groupWithPrevious && belowMessage.sender === message.sender) {
|
|
5421
|
+
gap = messageGapInGroup;
|
|
5422
|
+
} else if (belowMessage?.sender === message.sender) {
|
|
5423
|
+
gap = messageGapSameUser;
|
|
5424
|
+
} else {
|
|
5425
|
+
gap = messageGapDifferentUser;
|
|
5426
|
+
}
|
|
5427
|
+
}
|
|
5428
|
+
const { width: bubbleWidth, lines } = calculateAutoWidthAndLines3({
|
|
5429
|
+
text: message.text,
|
|
5430
|
+
maxWidth: bubbleMaxWidth,
|
|
5431
|
+
paddingLeft: messagePaddingLeft,
|
|
5432
|
+
paddingRight: messagePaddingRight,
|
|
5433
|
+
fontSize: messageFontSize,
|
|
5434
|
+
letterSpacing: messageLetterSpacing
|
|
5435
|
+
});
|
|
5436
|
+
const lineCount = lines.length;
|
|
5437
|
+
const textHeight = lineCount * messageLineHeight;
|
|
5438
|
+
const bubbleHeight = textHeight + messagePaddingTop + messagePaddingBottom;
|
|
5439
|
+
const bubbleBottom = currentBottom - gap;
|
|
5440
|
+
const bubbleTop = bubbleBottom - bubbleHeight;
|
|
5441
|
+
let bubbleLeft;
|
|
5442
|
+
if (message.sender === "recipient") {
|
|
5443
|
+
bubbleLeft = recipientBubbleLeft;
|
|
5444
|
+
} else {
|
|
5445
|
+
bubbleLeft = senderBubbleRight - bubbleWidth;
|
|
5446
|
+
}
|
|
5316
5447
|
let imageWidth;
|
|
5317
5448
|
let imageHeight;
|
|
5318
5449
|
let imageY;
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
imageWidth = Math.min(imageMaxWidth, maxBubbleWidth);
|
|
5450
|
+
if (message.imageUrl) {
|
|
5451
|
+
imageWidth = Math.min(imageMaxWidth, bubbleMaxWidth);
|
|
5322
5452
|
imageHeight = imageWidth / imageAspectRatio;
|
|
5323
|
-
|
|
5324
|
-
}
|
|
5325
|
-
const x = isSender ? canvasWidth - paddingRight - bubbleWidth : paddingLeft;
|
|
5326
|
-
const y = currentY - bubbleHeight;
|
|
5327
|
-
if (msg.imageUrl && imageHeight) {
|
|
5328
|
-
imageY = y - imageGapToText - imageHeight;
|
|
5453
|
+
imageY = bubbleTop - imageGapToText - imageHeight;
|
|
5329
5454
|
}
|
|
5330
5455
|
calculatedMessages.unshift({
|
|
5331
|
-
message
|
|
5332
|
-
|
|
5333
|
-
|
|
5456
|
+
message,
|
|
5457
|
+
top: bubbleTop,
|
|
5458
|
+
bottom: bubbleBottom,
|
|
5459
|
+
left: bubbleLeft,
|
|
5334
5460
|
width: bubbleWidth,
|
|
5335
5461
|
height: bubbleHeight,
|
|
5336
|
-
|
|
5337
|
-
|
|
5462
|
+
lines,
|
|
5463
|
+
isFirstInGroup,
|
|
5464
|
+
isLastInGroup,
|
|
5465
|
+
isSingleMessage,
|
|
5338
5466
|
imageWidth,
|
|
5339
5467
|
imageHeight,
|
|
5340
5468
|
imageY
|
|
5341
5469
|
});
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5470
|
+
if (message.imageUrl && imageY !== void 0) {
|
|
5471
|
+
currentBottom = imageY;
|
|
5472
|
+
} else {
|
|
5473
|
+
currentBottom = bubbleTop;
|
|
5474
|
+
}
|
|
5346
5475
|
}
|
|
5347
5476
|
return calculatedMessages;
|
|
5348
5477
|
}
|
|
5478
|
+
function getCornerRadii2(cm, bubbleRadiusNormal, bubbleRadiusGrouped) {
|
|
5479
|
+
const isUser = cm.message.sender === "user";
|
|
5480
|
+
if (cm.isSingleMessage) {
|
|
5481
|
+
return {
|
|
5482
|
+
topLeft: bubbleRadiusNormal,
|
|
5483
|
+
topRight: bubbleRadiusNormal,
|
|
5484
|
+
bottomLeft: bubbleRadiusNormal,
|
|
5485
|
+
bottomRight: bubbleRadiusNormal
|
|
5486
|
+
};
|
|
5487
|
+
}
|
|
5488
|
+
if (isUser) {
|
|
5489
|
+
return {
|
|
5490
|
+
topLeft: bubbleRadiusNormal,
|
|
5491
|
+
topRight: cm.isFirstInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
5492
|
+
bottomLeft: bubbleRadiusNormal,
|
|
5493
|
+
bottomRight: cm.isLastInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped
|
|
5494
|
+
};
|
|
5495
|
+
} else {
|
|
5496
|
+
return {
|
|
5497
|
+
topLeft: cm.isFirstInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
5498
|
+
topRight: bubbleRadiusNormal,
|
|
5499
|
+
bottomLeft: cm.isLastInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
5500
|
+
bottomRight: bubbleRadiusNormal
|
|
5501
|
+
};
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5349
5504
|
function generateMessageElements2(props, calculatedMessages) {
|
|
5505
|
+
if (calculatedMessages.length === 0) {
|
|
5506
|
+
return [];
|
|
5507
|
+
}
|
|
5350
5508
|
const elements = [];
|
|
5351
5509
|
const canvasWidth = props.width ?? 1206;
|
|
5352
5510
|
const senderBubbleColor = props.senderBubbleColor ?? MESSAGE_DEFAULTS2.senderBubbleColor;
|
|
5353
5511
|
const recipientBubbleColor = props.recipientBubbleColor ?? MESSAGE_DEFAULTS2.recipientBubbleColor;
|
|
5354
5512
|
const bubbleTextColor = props.bubbleTextColor ?? MESSAGE_DEFAULTS2.bubbleTextColor;
|
|
5355
|
-
const
|
|
5356
|
-
const
|
|
5357
|
-
const
|
|
5358
|
-
const
|
|
5359
|
-
const
|
|
5513
|
+
const messageFontSize = props.messageFontSize ?? MESSAGE_DEFAULTS2.messageFontSize;
|
|
5514
|
+
const messageLineHeight = props.messageLineHeight ?? MESSAGE_DEFAULTS2.messageLineHeight;
|
|
5515
|
+
const messageLetterSpacing = props.messageLetterSpacing ?? MESSAGE_DEFAULTS2.messageLetterSpacing;
|
|
5516
|
+
const messagePaddingTop = props.messagePaddingTop ?? MESSAGE_DEFAULTS2.messagePaddingTop;
|
|
5517
|
+
const messagePaddingBottom = props.messagePaddingBottom ?? MESSAGE_DEFAULTS2.messagePaddingBottom;
|
|
5518
|
+
const messagePaddingLeft = props.messagePaddingLeft ?? MESSAGE_DEFAULTS2.messagePaddingLeft;
|
|
5519
|
+
const messagePaddingRight = props.messagePaddingRight ?? MESSAGE_DEFAULTS2.messagePaddingRight;
|
|
5520
|
+
const bubbleRadiusNormal = props.bubbleRadiusNormal ?? MESSAGE_DEFAULTS2.bubbleRadiusNormal;
|
|
5521
|
+
const bubbleRadiusGrouped = props.bubbleRadiusGrouped ?? MESSAGE_DEFAULTS2.bubbleRadiusGrouped;
|
|
5522
|
+
const bubbleMaxWidth = props.bubbleMaxWidth ?? MESSAGE_DEFAULTS2.bubbleMaxWidth;
|
|
5523
|
+
const recipientBubbleLeft = props.recipientBubbleLeft ?? MESSAGE_DEFAULTS2.recipientBubbleLeft;
|
|
5524
|
+
const senderBubbleRight = props.senderBubbleRight ?? MESSAGE_DEFAULTS2.senderBubbleRight;
|
|
5360
5525
|
const imageBorderRadius = MESSAGE_DEFAULTS2.imageBorderRadius;
|
|
5361
|
-
const
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
const
|
|
5365
|
-
const
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
const imageX = isSender ? canvasWidth - sentMessagePaddingRight - imageWidth : receivedMessagePaddingLeft;
|
|
5526
|
+
const lineHeightMultiplier = messageLineHeight / messageFontSize;
|
|
5527
|
+
for (let i = 0; i < calculatedMessages.length; i++) {
|
|
5528
|
+
const cm = calculatedMessages[i];
|
|
5529
|
+
const isUser = cm.message.sender === "user";
|
|
5530
|
+
const bubbleColor = isUser ? senderBubbleColor : recipientBubbleColor;
|
|
5531
|
+
if (cm.message.imageUrl && cm.imageWidth && cm.imageHeight && cm.imageY !== void 0) {
|
|
5532
|
+
const imageX = isUser ? senderBubbleRight - cm.imageWidth : recipientBubbleLeft;
|
|
5369
5533
|
elements.push({
|
|
5370
|
-
id: `image-${message.id}`,
|
|
5534
|
+
id: `image-${cm.message.id}`,
|
|
5371
5535
|
type: "image",
|
|
5372
5536
|
x: imageX,
|
|
5373
|
-
y: imageY,
|
|
5374
|
-
width: imageWidth,
|
|
5375
|
-
height: imageHeight,
|
|
5376
|
-
zIndex:
|
|
5377
|
-
url: message.imageUrl,
|
|
5537
|
+
y: cm.imageY,
|
|
5538
|
+
width: cm.imageWidth,
|
|
5539
|
+
height: cm.imageHeight,
|
|
5540
|
+
zIndex: 5 + i,
|
|
5541
|
+
url: cm.message.imageUrl,
|
|
5378
5542
|
borderRadius: imageBorderRadius,
|
|
5379
5543
|
objectFit: "cover"
|
|
5380
5544
|
});
|
|
5381
5545
|
}
|
|
5546
|
+
const radii = getCornerRadii2(cm, bubbleRadiusNormal, bubbleRadiusGrouped);
|
|
5547
|
+
const elementX = isUser ? senderBubbleRight - bubbleMaxWidth : recipientBubbleLeft;
|
|
5548
|
+
const textContent = cm.lines.join("\n");
|
|
5382
5549
|
elements.push({
|
|
5383
|
-
id: `
|
|
5384
|
-
type: "text",
|
|
5385
|
-
x,
|
|
5386
|
-
y,
|
|
5387
|
-
width,
|
|
5388
|
-
height,
|
|
5389
|
-
zIndex: 10,
|
|
5390
|
-
text: "",
|
|
5391
|
-
backgroundColor: bubbleColor,
|
|
5392
|
-
backgroundOpacity: 100,
|
|
5393
|
-
borderRadius: bubbleBorderRadius
|
|
5394
|
-
});
|
|
5395
|
-
elements.push({
|
|
5396
|
-
id: `text-${message.id}`,
|
|
5550
|
+
id: `message-${cm.message.id}`,
|
|
5397
5551
|
type: "text",
|
|
5398
|
-
x:
|
|
5399
|
-
y:
|
|
5400
|
-
width:
|
|
5401
|
-
height: height
|
|
5402
|
-
zIndex:
|
|
5403
|
-
text:
|
|
5552
|
+
x: elementX,
|
|
5553
|
+
y: cm.top,
|
|
5554
|
+
width: bubbleMaxWidth,
|
|
5555
|
+
height: cm.height,
|
|
5556
|
+
zIndex: 5 + i,
|
|
5557
|
+
text: textContent,
|
|
5404
5558
|
font: "apple",
|
|
5405
5559
|
fontWeight: 400,
|
|
5406
|
-
fontSize:
|
|
5407
|
-
letterSpacing:
|
|
5560
|
+
fontSize: messageFontSize,
|
|
5561
|
+
letterSpacing: messageLetterSpacing,
|
|
5562
|
+
lineHeight: lineHeightMultiplier,
|
|
5408
5563
|
color: bubbleTextColor,
|
|
5409
5564
|
textAlign: "left",
|
|
5410
|
-
verticalAlign: "
|
|
5565
|
+
verticalAlign: "middle",
|
|
5566
|
+
backgroundColor: bubbleColor,
|
|
5567
|
+
backgroundOpacity: 100,
|
|
5568
|
+
backgroundBorderRadius: radii,
|
|
5569
|
+
paddingTop: messagePaddingTop,
|
|
5570
|
+
paddingRight: messagePaddingRight,
|
|
5571
|
+
paddingBottom: messagePaddingBottom,
|
|
5572
|
+
paddingLeft: messagePaddingLeft,
|
|
5573
|
+
autoWidth: true,
|
|
5574
|
+
boxAlign: isUser ? "right" : "left"
|
|
5411
5575
|
});
|
|
5412
5576
|
}
|
|
5413
5577
|
return elements;
|
|
@@ -5527,24 +5691,33 @@ var defaultIMessageDmProps = {
|
|
|
5527
5691
|
homeIndicatorLeft: 387,
|
|
5528
5692
|
homeIndicatorRight: 818,
|
|
5529
5693
|
homeIndicatorColor: "#ffffff",
|
|
5530
|
-
// Message
|
|
5694
|
+
// Message area bounds
|
|
5695
|
+
messageAreaTop: 450,
|
|
5696
|
+
messageAreaBottom: 2310,
|
|
5697
|
+
// Message colors
|
|
5531
5698
|
senderBubbleColor: "#1a42d5",
|
|
5532
5699
|
recipientBubbleColor: "#303032",
|
|
5533
5700
|
bubbleTextColor: "#ffffff",
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5701
|
+
// Message typography
|
|
5702
|
+
messageFontSize: 48,
|
|
5703
|
+
messageLineHeight: 60,
|
|
5704
|
+
messageLetterSpacing: 0.5,
|
|
5705
|
+
// Message padding (inside bubble)
|
|
5706
|
+
messagePaddingTop: 20,
|
|
5707
|
+
messagePaddingBottom: 20,
|
|
5708
|
+
messagePaddingLeft: 39,
|
|
5709
|
+
messagePaddingRight: 39,
|
|
5710
|
+
// Bubble corner radii
|
|
5711
|
+
bubbleRadiusNormal: 40,
|
|
5712
|
+
bubbleRadiusGrouped: 10,
|
|
5713
|
+
// Message spacing
|
|
5714
|
+
messageGapInGroup: 6,
|
|
5539
5715
|
messageGapSameUser: 8,
|
|
5540
5716
|
messageGapDifferentUser: 36,
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
multiLineSentMessagePaddingLeft: 31,
|
|
5546
|
-
multiLineReceivedMessagePaddingRight: 31,
|
|
5547
|
-
messagesAnchorY: 2340,
|
|
5717
|
+
// Bubble positioning
|
|
5718
|
+
recipientBubbleLeft: 48,
|
|
5719
|
+
senderBubbleRight: 1178,
|
|
5720
|
+
bubbleMaxWidth: 900,
|
|
5548
5721
|
// Example messages
|
|
5549
5722
|
messages: [
|
|
5550
5723
|
{ id: "msg-1", sender: "user", text: "heyyy fae, help me slide on this baddie pls \u{1F64F}", imageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/06c3ed1c-eefb-4a60-b0c4-5fb872811ba0/pinterest-1766175214139-0-JpXmGIxVWdjEJ3qxGyoC4DAi2KAZrg.jpg" },
|
|
@@ -6707,24 +6880,33 @@ var iMessageDmPropsSchema = import_zod.z.object({
|
|
|
6707
6880
|
messageTextLetterSpacing: import_zod.z.number().optional(),
|
|
6708
6881
|
messageTextColor: import_zod.z.string().optional(),
|
|
6709
6882
|
messageText: import_zod.z.string().optional(),
|
|
6710
|
-
// Message
|
|
6883
|
+
// Message area bounds
|
|
6884
|
+
messageAreaTop: import_zod.z.number().optional(),
|
|
6885
|
+
messageAreaBottom: import_zod.z.number().optional(),
|
|
6886
|
+
// Message colors
|
|
6711
6887
|
senderBubbleColor: import_zod.z.string().optional(),
|
|
6712
6888
|
recipientBubbleColor: import_zod.z.string().optional(),
|
|
6713
6889
|
bubbleTextColor: import_zod.z.string().optional(),
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6890
|
+
// Message typography
|
|
6891
|
+
messageFontSize: import_zod.z.number().optional(),
|
|
6892
|
+
messageLineHeight: import_zod.z.number().optional(),
|
|
6893
|
+
messageLetterSpacing: import_zod.z.number().optional(),
|
|
6894
|
+
// Message padding (inside bubble)
|
|
6895
|
+
messagePaddingTop: import_zod.z.number().optional(),
|
|
6896
|
+
messagePaddingBottom: import_zod.z.number().optional(),
|
|
6897
|
+
messagePaddingLeft: import_zod.z.number().optional(),
|
|
6898
|
+
messagePaddingRight: import_zod.z.number().optional(),
|
|
6899
|
+
// Bubble corner radii
|
|
6900
|
+
bubbleRadiusNormal: import_zod.z.number().optional(),
|
|
6901
|
+
bubbleRadiusGrouped: import_zod.z.number().optional(),
|
|
6902
|
+
// Message spacing
|
|
6903
|
+
messageGapInGroup: import_zod.z.number().optional(),
|
|
6719
6904
|
messageGapSameUser: import_zod.z.number().optional(),
|
|
6720
6905
|
messageGapDifferentUser: import_zod.z.number().optional(),
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
multiLineSentMessagePaddingLeft: import_zod.z.number().optional(),
|
|
6726
|
-
multiLineReceivedMessagePaddingRight: import_zod.z.number().optional(),
|
|
6727
|
-
messagesAnchorY: import_zod.z.number().optional(),
|
|
6906
|
+
// Bubble positioning
|
|
6907
|
+
recipientBubbleLeft: import_zod.z.number().optional(),
|
|
6908
|
+
senderBubbleRight: import_zod.z.number().optional(),
|
|
6909
|
+
bubbleMaxWidth: import_zod.z.number().optional(),
|
|
6728
6910
|
// Messages
|
|
6729
6911
|
messages: import_zod.z.array(import_zod.z.object({
|
|
6730
6912
|
id: import_zod.z.string(),
|
package/dist/index.mjs
CHANGED
|
@@ -4301,159 +4301,323 @@ import { Img as Img5, staticFile as staticFile3 } from "remotion";
|
|
|
4301
4301
|
|
|
4302
4302
|
// src/compositions/IMessageDmComposition/convertPropsToElements.ts
|
|
4303
4303
|
var MESSAGE_DEFAULTS2 = {
|
|
4304
|
+
// Message area bounds
|
|
4305
|
+
messageAreaTop: 450,
|
|
4306
|
+
messageAreaBottom: 2310,
|
|
4307
|
+
// Message colors
|
|
4304
4308
|
senderBubbleColor: "#1a42d5",
|
|
4305
4309
|
recipientBubbleColor: "#303032",
|
|
4306
4310
|
bubbleTextColor: "#ffffff",
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4311
|
+
// Message typography
|
|
4312
|
+
messageFontSize: 48,
|
|
4313
|
+
messageLineHeight: 60,
|
|
4314
|
+
messageLetterSpacing: 0.5,
|
|
4315
|
+
// Message padding (inside bubble)
|
|
4316
|
+
messagePaddingTop: 20,
|
|
4317
|
+
messagePaddingBottom: 20,
|
|
4318
|
+
messagePaddingLeft: 39,
|
|
4319
|
+
messagePaddingRight: 39,
|
|
4320
|
+
// Bubble corner radii
|
|
4321
|
+
bubbleRadiusNormal: 40,
|
|
4322
|
+
bubbleRadiusGrouped: 10,
|
|
4323
|
+
// Message spacing
|
|
4324
|
+
messageGapInGroup: 6,
|
|
4312
4325
|
messageGapSameUser: 8,
|
|
4313
4326
|
messageGapDifferentUser: 36,
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
multiLineSentMessagePaddingLeft: 31,
|
|
4319
|
-
multiLineReceivedMessagePaddingRight: 31,
|
|
4320
|
-
messagesAnchorY: 2340,
|
|
4327
|
+
// Bubble positioning
|
|
4328
|
+
recipientBubbleLeft: 48,
|
|
4329
|
+
senderBubbleRight: 1178,
|
|
4330
|
+
bubbleMaxWidth: 900,
|
|
4321
4331
|
// Image message defaults
|
|
4322
4332
|
imageMaxWidth: 600,
|
|
4323
4333
|
imageAspectRatio: 1,
|
|
4324
|
-
// width / height
|
|
4325
4334
|
imageBorderRadius: 30,
|
|
4326
4335
|
imageGapToText: 8
|
|
4327
4336
|
};
|
|
4337
|
+
var FONT_FAMILY2 = getFontFamily("apple");
|
|
4338
|
+
function calculateAutoWidthAndLines3({
|
|
4339
|
+
text,
|
|
4340
|
+
maxWidth,
|
|
4341
|
+
paddingLeft,
|
|
4342
|
+
paddingRight,
|
|
4343
|
+
fontSize,
|
|
4344
|
+
letterSpacing
|
|
4345
|
+
}) {
|
|
4346
|
+
if (typeof document === "undefined") {
|
|
4347
|
+
return { width: maxWidth, lines: [text] };
|
|
4348
|
+
}
|
|
4349
|
+
const availableWidth = maxWidth - paddingLeft - paddingRight;
|
|
4350
|
+
if (availableWidth <= 0) {
|
|
4351
|
+
return { width: maxWidth, lines: [text] };
|
|
4352
|
+
}
|
|
4353
|
+
const measureSpan = document.createElement("span");
|
|
4354
|
+
measureSpan.style.cssText = `
|
|
4355
|
+
position: absolute;
|
|
4356
|
+
visibility: hidden;
|
|
4357
|
+
pointer-events: none;
|
|
4358
|
+
font-family: ${FONT_FAMILY2};
|
|
4359
|
+
font-size: ${fontSize}px;
|
|
4360
|
+
font-weight: normal;
|
|
4361
|
+
letter-spacing: ${letterSpacing}px;
|
|
4362
|
+
white-space: nowrap;
|
|
4363
|
+
`;
|
|
4364
|
+
document.body.appendChild(measureSpan);
|
|
4365
|
+
const measureText = (textToMeasure) => {
|
|
4366
|
+
measureSpan.textContent = textToMeasure;
|
|
4367
|
+
return measureSpan.getBoundingClientRect().width;
|
|
4368
|
+
};
|
|
4369
|
+
const words = text.split(/(\s+)/);
|
|
4370
|
+
const lines = [];
|
|
4371
|
+
let currentLine = "";
|
|
4372
|
+
for (let i = 0; i < words.length; i++) {
|
|
4373
|
+
const word = words[i];
|
|
4374
|
+
if (word === "\n" || word === "\r\n") {
|
|
4375
|
+
if (currentLine) lines.push(currentLine);
|
|
4376
|
+
currentLine = "";
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
4379
|
+
if (!word) continue;
|
|
4380
|
+
if (/^\s+$/.test(word)) {
|
|
4381
|
+
if (currentLine) currentLine += word;
|
|
4382
|
+
continue;
|
|
4383
|
+
}
|
|
4384
|
+
const testLine = currentLine + word;
|
|
4385
|
+
const testWidth = measureText(testLine);
|
|
4386
|
+
const WRAP_TOLERANCE = 0.5;
|
|
4387
|
+
if (testWidth > availableWidth + WRAP_TOLERANCE) {
|
|
4388
|
+
if (currentLine.trim()) {
|
|
4389
|
+
lines.push(currentLine.trimEnd());
|
|
4390
|
+
currentLine = "";
|
|
4391
|
+
}
|
|
4392
|
+
const wordWidth = measureText(word);
|
|
4393
|
+
if (wordWidth > availableWidth) {
|
|
4394
|
+
let remainingWord = word;
|
|
4395
|
+
while (remainingWord) {
|
|
4396
|
+
let breakPoint = 1;
|
|
4397
|
+
for (let j = 1; j <= remainingWord.length; j++) {
|
|
4398
|
+
measureSpan.textContent = remainingWord.substring(0, j);
|
|
4399
|
+
if (measureSpan.getBoundingClientRect().width > availableWidth) {
|
|
4400
|
+
breakPoint = Math.max(1, j - 1);
|
|
4401
|
+
break;
|
|
4402
|
+
}
|
|
4403
|
+
breakPoint = j;
|
|
4404
|
+
}
|
|
4405
|
+
if (breakPoint >= remainingWord.length) {
|
|
4406
|
+
currentLine = remainingWord;
|
|
4407
|
+
break;
|
|
4408
|
+
} else {
|
|
4409
|
+
lines.push(remainingWord.substring(0, breakPoint));
|
|
4410
|
+
remainingWord = remainingWord.substring(breakPoint);
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
} else {
|
|
4414
|
+
currentLine = word;
|
|
4415
|
+
}
|
|
4416
|
+
} else {
|
|
4417
|
+
currentLine = testLine;
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
if (currentLine.trim()) lines.push(currentLine.trimEnd());
|
|
4421
|
+
if (lines.length === 0) lines.push("");
|
|
4422
|
+
let widestLineWidth = 0;
|
|
4423
|
+
for (const line of lines) {
|
|
4424
|
+
const lineWidth = measureText(line);
|
|
4425
|
+
widestLineWidth = Math.max(widestLineWidth, lineWidth);
|
|
4426
|
+
}
|
|
4427
|
+
document.body.removeChild(measureSpan);
|
|
4428
|
+
const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
|
|
4429
|
+
return { width: calculatedWidth, lines };
|
|
4430
|
+
}
|
|
4328
4431
|
function calculateMessagePositions2(props) {
|
|
4329
4432
|
const messages = props.messages ?? [];
|
|
4330
4433
|
if (messages.length === 0) return [];
|
|
4331
|
-
const
|
|
4332
|
-
const
|
|
4434
|
+
const messageAreaBottom = props.messageAreaBottom ?? MESSAGE_DEFAULTS2.messageAreaBottom;
|
|
4435
|
+
const messageFontSize = props.messageFontSize ?? MESSAGE_DEFAULTS2.messageFontSize;
|
|
4436
|
+
const messageLineHeight = props.messageLineHeight ?? MESSAGE_DEFAULTS2.messageLineHeight;
|
|
4437
|
+
const messageLetterSpacing = props.messageLetterSpacing ?? MESSAGE_DEFAULTS2.messageLetterSpacing;
|
|
4438
|
+
const messagePaddingTop = props.messagePaddingTop ?? MESSAGE_DEFAULTS2.messagePaddingTop;
|
|
4439
|
+
const messagePaddingBottom = props.messagePaddingBottom ?? MESSAGE_DEFAULTS2.messagePaddingBottom;
|
|
4440
|
+
const messagePaddingLeft = props.messagePaddingLeft ?? MESSAGE_DEFAULTS2.messagePaddingLeft;
|
|
4441
|
+
const messagePaddingRight = props.messagePaddingRight ?? MESSAGE_DEFAULTS2.messagePaddingRight;
|
|
4442
|
+
const messageGapInGroup = props.messageGapInGroup ?? MESSAGE_DEFAULTS2.messageGapInGroup;
|
|
4333
4443
|
const messageGapSameUser = props.messageGapSameUser ?? MESSAGE_DEFAULTS2.messageGapSameUser;
|
|
4334
4444
|
const messageGapDifferentUser = props.messageGapDifferentUser ?? MESSAGE_DEFAULTS2.messageGapDifferentUser;
|
|
4335
|
-
const
|
|
4336
|
-
const
|
|
4337
|
-
const
|
|
4338
|
-
const receivedMessagePaddingRight = props.receivedMessagePaddingRight ?? MESSAGE_DEFAULTS2.receivedMessagePaddingRight;
|
|
4339
|
-
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
4340
|
-
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
4341
|
-
const bubbleTextFontSize = props.bubbleTextFontSize ?? MESSAGE_DEFAULTS2.bubbleTextFontSize;
|
|
4445
|
+
const recipientBubbleLeft = props.recipientBubbleLeft ?? MESSAGE_DEFAULTS2.recipientBubbleLeft;
|
|
4446
|
+
const senderBubbleRight = props.senderBubbleRight ?? MESSAGE_DEFAULTS2.senderBubbleRight;
|
|
4447
|
+
const bubbleMaxWidth = props.bubbleMaxWidth ?? MESSAGE_DEFAULTS2.bubbleMaxWidth;
|
|
4342
4448
|
const imageMaxWidth = MESSAGE_DEFAULTS2.imageMaxWidth;
|
|
4343
4449
|
const imageAspectRatio = MESSAGE_DEFAULTS2.imageAspectRatio;
|
|
4344
4450
|
const imageGapToText = MESSAGE_DEFAULTS2.imageGapToText;
|
|
4345
4451
|
const calculatedMessages = [];
|
|
4346
|
-
let
|
|
4452
|
+
let currentBottom = messageAreaBottom;
|
|
4347
4453
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
4348
|
-
const
|
|
4349
|
-
if (!
|
|
4350
|
-
const
|
|
4351
|
-
const
|
|
4352
|
-
const
|
|
4353
|
-
const
|
|
4354
|
-
const
|
|
4355
|
-
const
|
|
4356
|
-
const
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4454
|
+
const message = messages[i];
|
|
4455
|
+
if (!message) continue;
|
|
4456
|
+
const prevMessage = i > 0 ? messages[i - 1] : null;
|
|
4457
|
+
const nextMessage = i < messages.length - 1 ? messages[i + 1] : null;
|
|
4458
|
+
const isGroupedWithPrev = message.groupWithPrevious && prevMessage?.sender === message.sender;
|
|
4459
|
+
const isGroupedWithNext = nextMessage?.groupWithPrevious && nextMessage?.sender === message.sender;
|
|
4460
|
+
const isFirstInGroup = !isGroupedWithPrev;
|
|
4461
|
+
const isLastInGroup = !isGroupedWithNext;
|
|
4462
|
+
const isSingleMessage = isFirstInGroup && isLastInGroup;
|
|
4463
|
+
let gap = 0;
|
|
4464
|
+
if (i < messages.length - 1) {
|
|
4465
|
+
const belowMessage = messages[i + 1];
|
|
4466
|
+
if (belowMessage?.groupWithPrevious && belowMessage.sender === message.sender) {
|
|
4467
|
+
gap = messageGapInGroup;
|
|
4468
|
+
} else if (belowMessage?.sender === message.sender) {
|
|
4469
|
+
gap = messageGapSameUser;
|
|
4470
|
+
} else {
|
|
4471
|
+
gap = messageGapDifferentUser;
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
const { width: bubbleWidth, lines } = calculateAutoWidthAndLines3({
|
|
4475
|
+
text: message.text,
|
|
4476
|
+
maxWidth: bubbleMaxWidth,
|
|
4477
|
+
paddingLeft: messagePaddingLeft,
|
|
4478
|
+
paddingRight: messagePaddingRight,
|
|
4479
|
+
fontSize: messageFontSize,
|
|
4480
|
+
letterSpacing: messageLetterSpacing
|
|
4481
|
+
});
|
|
4482
|
+
const lineCount = lines.length;
|
|
4483
|
+
const textHeight = lineCount * messageLineHeight;
|
|
4484
|
+
const bubbleHeight = textHeight + messagePaddingTop + messagePaddingBottom;
|
|
4485
|
+
const bubbleBottom = currentBottom - gap;
|
|
4486
|
+
const bubbleTop = bubbleBottom - bubbleHeight;
|
|
4487
|
+
let bubbleLeft;
|
|
4488
|
+
if (message.sender === "recipient") {
|
|
4489
|
+
bubbleLeft = recipientBubbleLeft;
|
|
4490
|
+
} else {
|
|
4491
|
+
bubbleLeft = senderBubbleRight - bubbleWidth;
|
|
4492
|
+
}
|
|
4362
4493
|
let imageWidth;
|
|
4363
4494
|
let imageHeight;
|
|
4364
4495
|
let imageY;
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
imageWidth = Math.min(imageMaxWidth, maxBubbleWidth);
|
|
4496
|
+
if (message.imageUrl) {
|
|
4497
|
+
imageWidth = Math.min(imageMaxWidth, bubbleMaxWidth);
|
|
4368
4498
|
imageHeight = imageWidth / imageAspectRatio;
|
|
4369
|
-
|
|
4370
|
-
}
|
|
4371
|
-
const x = isSender ? canvasWidth - paddingRight - bubbleWidth : paddingLeft;
|
|
4372
|
-
const y = currentY - bubbleHeight;
|
|
4373
|
-
if (msg.imageUrl && imageHeight) {
|
|
4374
|
-
imageY = y - imageGapToText - imageHeight;
|
|
4499
|
+
imageY = bubbleTop - imageGapToText - imageHeight;
|
|
4375
4500
|
}
|
|
4376
4501
|
calculatedMessages.unshift({
|
|
4377
|
-
message
|
|
4378
|
-
|
|
4379
|
-
|
|
4502
|
+
message,
|
|
4503
|
+
top: bubbleTop,
|
|
4504
|
+
bottom: bubbleBottom,
|
|
4505
|
+
left: bubbleLeft,
|
|
4380
4506
|
width: bubbleWidth,
|
|
4381
4507
|
height: bubbleHeight,
|
|
4382
|
-
|
|
4383
|
-
|
|
4508
|
+
lines,
|
|
4509
|
+
isFirstInGroup,
|
|
4510
|
+
isLastInGroup,
|
|
4511
|
+
isSingleMessage,
|
|
4384
4512
|
imageWidth,
|
|
4385
4513
|
imageHeight,
|
|
4386
4514
|
imageY
|
|
4387
4515
|
});
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4516
|
+
if (message.imageUrl && imageY !== void 0) {
|
|
4517
|
+
currentBottom = imageY;
|
|
4518
|
+
} else {
|
|
4519
|
+
currentBottom = bubbleTop;
|
|
4520
|
+
}
|
|
4392
4521
|
}
|
|
4393
4522
|
return calculatedMessages;
|
|
4394
4523
|
}
|
|
4524
|
+
function getCornerRadii2(cm, bubbleRadiusNormal, bubbleRadiusGrouped) {
|
|
4525
|
+
const isUser = cm.message.sender === "user";
|
|
4526
|
+
if (cm.isSingleMessage) {
|
|
4527
|
+
return {
|
|
4528
|
+
topLeft: bubbleRadiusNormal,
|
|
4529
|
+
topRight: bubbleRadiusNormal,
|
|
4530
|
+
bottomLeft: bubbleRadiusNormal,
|
|
4531
|
+
bottomRight: bubbleRadiusNormal
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
if (isUser) {
|
|
4535
|
+
return {
|
|
4536
|
+
topLeft: bubbleRadiusNormal,
|
|
4537
|
+
topRight: cm.isFirstInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
4538
|
+
bottomLeft: bubbleRadiusNormal,
|
|
4539
|
+
bottomRight: cm.isLastInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped
|
|
4540
|
+
};
|
|
4541
|
+
} else {
|
|
4542
|
+
return {
|
|
4543
|
+
topLeft: cm.isFirstInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
4544
|
+
topRight: bubbleRadiusNormal,
|
|
4545
|
+
bottomLeft: cm.isLastInGroup ? bubbleRadiusNormal : bubbleRadiusGrouped,
|
|
4546
|
+
bottomRight: bubbleRadiusNormal
|
|
4547
|
+
};
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4395
4550
|
function generateMessageElements2(props, calculatedMessages) {
|
|
4551
|
+
if (calculatedMessages.length === 0) {
|
|
4552
|
+
return [];
|
|
4553
|
+
}
|
|
4396
4554
|
const elements = [];
|
|
4397
4555
|
const canvasWidth = props.width ?? 1206;
|
|
4398
4556
|
const senderBubbleColor = props.senderBubbleColor ?? MESSAGE_DEFAULTS2.senderBubbleColor;
|
|
4399
4557
|
const recipientBubbleColor = props.recipientBubbleColor ?? MESSAGE_DEFAULTS2.recipientBubbleColor;
|
|
4400
4558
|
const bubbleTextColor = props.bubbleTextColor ?? MESSAGE_DEFAULTS2.bubbleTextColor;
|
|
4401
|
-
const
|
|
4402
|
-
const
|
|
4403
|
-
const
|
|
4404
|
-
const
|
|
4405
|
-
const
|
|
4559
|
+
const messageFontSize = props.messageFontSize ?? MESSAGE_DEFAULTS2.messageFontSize;
|
|
4560
|
+
const messageLineHeight = props.messageLineHeight ?? MESSAGE_DEFAULTS2.messageLineHeight;
|
|
4561
|
+
const messageLetterSpacing = props.messageLetterSpacing ?? MESSAGE_DEFAULTS2.messageLetterSpacing;
|
|
4562
|
+
const messagePaddingTop = props.messagePaddingTop ?? MESSAGE_DEFAULTS2.messagePaddingTop;
|
|
4563
|
+
const messagePaddingBottom = props.messagePaddingBottom ?? MESSAGE_DEFAULTS2.messagePaddingBottom;
|
|
4564
|
+
const messagePaddingLeft = props.messagePaddingLeft ?? MESSAGE_DEFAULTS2.messagePaddingLeft;
|
|
4565
|
+
const messagePaddingRight = props.messagePaddingRight ?? MESSAGE_DEFAULTS2.messagePaddingRight;
|
|
4566
|
+
const bubbleRadiusNormal = props.bubbleRadiusNormal ?? MESSAGE_DEFAULTS2.bubbleRadiusNormal;
|
|
4567
|
+
const bubbleRadiusGrouped = props.bubbleRadiusGrouped ?? MESSAGE_DEFAULTS2.bubbleRadiusGrouped;
|
|
4568
|
+
const bubbleMaxWidth = props.bubbleMaxWidth ?? MESSAGE_DEFAULTS2.bubbleMaxWidth;
|
|
4569
|
+
const recipientBubbleLeft = props.recipientBubbleLeft ?? MESSAGE_DEFAULTS2.recipientBubbleLeft;
|
|
4570
|
+
const senderBubbleRight = props.senderBubbleRight ?? MESSAGE_DEFAULTS2.senderBubbleRight;
|
|
4406
4571
|
const imageBorderRadius = MESSAGE_DEFAULTS2.imageBorderRadius;
|
|
4407
|
-
const
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
const
|
|
4411
|
-
const
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
const imageX = isSender ? canvasWidth - sentMessagePaddingRight - imageWidth : receivedMessagePaddingLeft;
|
|
4572
|
+
const lineHeightMultiplier = messageLineHeight / messageFontSize;
|
|
4573
|
+
for (let i = 0; i < calculatedMessages.length; i++) {
|
|
4574
|
+
const cm = calculatedMessages[i];
|
|
4575
|
+
const isUser = cm.message.sender === "user";
|
|
4576
|
+
const bubbleColor = isUser ? senderBubbleColor : recipientBubbleColor;
|
|
4577
|
+
if (cm.message.imageUrl && cm.imageWidth && cm.imageHeight && cm.imageY !== void 0) {
|
|
4578
|
+
const imageX = isUser ? senderBubbleRight - cm.imageWidth : recipientBubbleLeft;
|
|
4415
4579
|
elements.push({
|
|
4416
|
-
id: `image-${message.id}`,
|
|
4580
|
+
id: `image-${cm.message.id}`,
|
|
4417
4581
|
type: "image",
|
|
4418
4582
|
x: imageX,
|
|
4419
|
-
y: imageY,
|
|
4420
|
-
width: imageWidth,
|
|
4421
|
-
height: imageHeight,
|
|
4422
|
-
zIndex:
|
|
4423
|
-
url: message.imageUrl,
|
|
4583
|
+
y: cm.imageY,
|
|
4584
|
+
width: cm.imageWidth,
|
|
4585
|
+
height: cm.imageHeight,
|
|
4586
|
+
zIndex: 5 + i,
|
|
4587
|
+
url: cm.message.imageUrl,
|
|
4424
4588
|
borderRadius: imageBorderRadius,
|
|
4425
4589
|
objectFit: "cover"
|
|
4426
4590
|
});
|
|
4427
4591
|
}
|
|
4592
|
+
const radii = getCornerRadii2(cm, bubbleRadiusNormal, bubbleRadiusGrouped);
|
|
4593
|
+
const elementX = isUser ? senderBubbleRight - bubbleMaxWidth : recipientBubbleLeft;
|
|
4594
|
+
const textContent = cm.lines.join("\n");
|
|
4428
4595
|
elements.push({
|
|
4429
|
-
id: `
|
|
4430
|
-
type: "text",
|
|
4431
|
-
x,
|
|
4432
|
-
y,
|
|
4433
|
-
width,
|
|
4434
|
-
height,
|
|
4435
|
-
zIndex: 10,
|
|
4436
|
-
text: "",
|
|
4437
|
-
backgroundColor: bubbleColor,
|
|
4438
|
-
backgroundOpacity: 100,
|
|
4439
|
-
borderRadius: bubbleBorderRadius
|
|
4440
|
-
});
|
|
4441
|
-
elements.push({
|
|
4442
|
-
id: `text-${message.id}`,
|
|
4596
|
+
id: `message-${cm.message.id}`,
|
|
4443
4597
|
type: "text",
|
|
4444
|
-
x:
|
|
4445
|
-
y:
|
|
4446
|
-
width:
|
|
4447
|
-
height: height
|
|
4448
|
-
zIndex:
|
|
4449
|
-
text:
|
|
4598
|
+
x: elementX,
|
|
4599
|
+
y: cm.top,
|
|
4600
|
+
width: bubbleMaxWidth,
|
|
4601
|
+
height: cm.height,
|
|
4602
|
+
zIndex: 5 + i,
|
|
4603
|
+
text: textContent,
|
|
4450
4604
|
font: "apple",
|
|
4451
4605
|
fontWeight: 400,
|
|
4452
|
-
fontSize:
|
|
4453
|
-
letterSpacing:
|
|
4606
|
+
fontSize: messageFontSize,
|
|
4607
|
+
letterSpacing: messageLetterSpacing,
|
|
4608
|
+
lineHeight: lineHeightMultiplier,
|
|
4454
4609
|
color: bubbleTextColor,
|
|
4455
4610
|
textAlign: "left",
|
|
4456
|
-
verticalAlign: "
|
|
4611
|
+
verticalAlign: "middle",
|
|
4612
|
+
backgroundColor: bubbleColor,
|
|
4613
|
+
backgroundOpacity: 100,
|
|
4614
|
+
backgroundBorderRadius: radii,
|
|
4615
|
+
paddingTop: messagePaddingTop,
|
|
4616
|
+
paddingRight: messagePaddingRight,
|
|
4617
|
+
paddingBottom: messagePaddingBottom,
|
|
4618
|
+
paddingLeft: messagePaddingLeft,
|
|
4619
|
+
autoWidth: true,
|
|
4620
|
+
boxAlign: isUser ? "right" : "left"
|
|
4457
4621
|
});
|
|
4458
4622
|
}
|
|
4459
4623
|
return elements;
|
|
@@ -4573,24 +4737,33 @@ var defaultIMessageDmProps = {
|
|
|
4573
4737
|
homeIndicatorLeft: 387,
|
|
4574
4738
|
homeIndicatorRight: 818,
|
|
4575
4739
|
homeIndicatorColor: "#ffffff",
|
|
4576
|
-
// Message
|
|
4740
|
+
// Message area bounds
|
|
4741
|
+
messageAreaTop: 450,
|
|
4742
|
+
messageAreaBottom: 2310,
|
|
4743
|
+
// Message colors
|
|
4577
4744
|
senderBubbleColor: "#1a42d5",
|
|
4578
4745
|
recipientBubbleColor: "#303032",
|
|
4579
4746
|
bubbleTextColor: "#ffffff",
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4747
|
+
// Message typography
|
|
4748
|
+
messageFontSize: 48,
|
|
4749
|
+
messageLineHeight: 60,
|
|
4750
|
+
messageLetterSpacing: 0.5,
|
|
4751
|
+
// Message padding (inside bubble)
|
|
4752
|
+
messagePaddingTop: 20,
|
|
4753
|
+
messagePaddingBottom: 20,
|
|
4754
|
+
messagePaddingLeft: 39,
|
|
4755
|
+
messagePaddingRight: 39,
|
|
4756
|
+
// Bubble corner radii
|
|
4757
|
+
bubbleRadiusNormal: 40,
|
|
4758
|
+
bubbleRadiusGrouped: 10,
|
|
4759
|
+
// Message spacing
|
|
4760
|
+
messageGapInGroup: 6,
|
|
4585
4761
|
messageGapSameUser: 8,
|
|
4586
4762
|
messageGapDifferentUser: 36,
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
multiLineSentMessagePaddingLeft: 31,
|
|
4592
|
-
multiLineReceivedMessagePaddingRight: 31,
|
|
4593
|
-
messagesAnchorY: 2340,
|
|
4763
|
+
// Bubble positioning
|
|
4764
|
+
recipientBubbleLeft: 48,
|
|
4765
|
+
senderBubbleRight: 1178,
|
|
4766
|
+
bubbleMaxWidth: 900,
|
|
4594
4767
|
// Example messages
|
|
4595
4768
|
messages: [
|
|
4596
4769
|
{ id: "msg-1", sender: "user", text: "heyyy fae, help me slide on this baddie pls \u{1F64F}", imageUrl: "https://n14dcpakf8w1fekl.public.blob.vercel-storage.com/media/06c3ed1c-eefb-4a60-b0c4-5fb872811ba0/pinterest-1766175214139-0-JpXmGIxVWdjEJ3qxGyoC4DAi2KAZrg.jpg" },
|
|
@@ -5470,24 +5643,33 @@ var iMessageDmPropsSchema = z.object({
|
|
|
5470
5643
|
messageTextLetterSpacing: z.number().optional(),
|
|
5471
5644
|
messageTextColor: z.string().optional(),
|
|
5472
5645
|
messageText: z.string().optional(),
|
|
5473
|
-
// Message
|
|
5646
|
+
// Message area bounds
|
|
5647
|
+
messageAreaTop: z.number().optional(),
|
|
5648
|
+
messageAreaBottom: z.number().optional(),
|
|
5649
|
+
// Message colors
|
|
5474
5650
|
senderBubbleColor: z.string().optional(),
|
|
5475
5651
|
recipientBubbleColor: z.string().optional(),
|
|
5476
5652
|
bubbleTextColor: z.string().optional(),
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5653
|
+
// Message typography
|
|
5654
|
+
messageFontSize: z.number().optional(),
|
|
5655
|
+
messageLineHeight: z.number().optional(),
|
|
5656
|
+
messageLetterSpacing: z.number().optional(),
|
|
5657
|
+
// Message padding (inside bubble)
|
|
5658
|
+
messagePaddingTop: z.number().optional(),
|
|
5659
|
+
messagePaddingBottom: z.number().optional(),
|
|
5660
|
+
messagePaddingLeft: z.number().optional(),
|
|
5661
|
+
messagePaddingRight: z.number().optional(),
|
|
5662
|
+
// Bubble corner radii
|
|
5663
|
+
bubbleRadiusNormal: z.number().optional(),
|
|
5664
|
+
bubbleRadiusGrouped: z.number().optional(),
|
|
5665
|
+
// Message spacing
|
|
5666
|
+
messageGapInGroup: z.number().optional(),
|
|
5482
5667
|
messageGapSameUser: z.number().optional(),
|
|
5483
5668
|
messageGapDifferentUser: z.number().optional(),
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
multiLineSentMessagePaddingLeft: z.number().optional(),
|
|
5489
|
-
multiLineReceivedMessagePaddingRight: z.number().optional(),
|
|
5490
|
-
messagesAnchorY: z.number().optional(),
|
|
5669
|
+
// Bubble positioning
|
|
5670
|
+
recipientBubbleLeft: z.number().optional(),
|
|
5671
|
+
senderBubbleRight: z.number().optional(),
|
|
5672
|
+
bubbleMaxWidth: z.number().optional(),
|
|
5491
5673
|
// Messages
|
|
5492
5674
|
messages: z.array(z.object({
|
|
5493
5675
|
id: z.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.162",
|
|
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",
|