ugcinc-render 1.8.156 → 1.8.158
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +55 -10
- package/dist/index.mjs +55 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -980,6 +980,8 @@ interface ImMessage {
|
|
|
980
980
|
id: string;
|
|
981
981
|
sender: ImMessageSender;
|
|
982
982
|
text: string;
|
|
983
|
+
/** Optional image URL to display above the text */
|
|
984
|
+
imageUrl?: string;
|
|
983
985
|
/** Group with previous message (no gap, continuous bubble feel) */
|
|
984
986
|
groupWithPrevious?: boolean;
|
|
985
987
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -980,6 +980,8 @@ interface ImMessage {
|
|
|
980
980
|
id: string;
|
|
981
981
|
sender: ImMessageSender;
|
|
982
982
|
text: string;
|
|
983
|
+
/** Optional image URL to display above the text */
|
|
984
|
+
imageUrl?: string;
|
|
983
985
|
/** Group with previous message (no gap, continuous bubble feel) */
|
|
984
986
|
groupWithPrevious?: boolean;
|
|
985
987
|
}
|
package/dist/index.js
CHANGED
|
@@ -5252,7 +5252,13 @@ var MESSAGE_DEFAULTS2 = {
|
|
|
5252
5252
|
receivedMessagePaddingRight: 200,
|
|
5253
5253
|
multiLineSentMessagePaddingLeft: 31,
|
|
5254
5254
|
multiLineReceivedMessagePaddingRight: 31,
|
|
5255
|
-
messagesAnchorY: 2340
|
|
5255
|
+
messagesAnchorY: 2340,
|
|
5256
|
+
// Image message defaults
|
|
5257
|
+
imageMaxWidth: 600,
|
|
5258
|
+
imageAspectRatio: 1,
|
|
5259
|
+
// width / height
|
|
5260
|
+
imageBorderRadius: 30,
|
|
5261
|
+
imageGapToText: 8
|
|
5256
5262
|
};
|
|
5257
5263
|
function calculateMessagePositions2(props) {
|
|
5258
5264
|
const messages = props.messages ?? [];
|
|
@@ -5268,6 +5274,9 @@ function calculateMessagePositions2(props) {
|
|
|
5268
5274
|
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
5269
5275
|
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
5270
5276
|
const bubbleTextFontSize = props.bubbleTextFontSize ?? MESSAGE_DEFAULTS2.bubbleTextFontSize;
|
|
5277
|
+
const imageMaxWidth = MESSAGE_DEFAULTS2.imageMaxWidth;
|
|
5278
|
+
const imageAspectRatio = MESSAGE_DEFAULTS2.imageAspectRatio;
|
|
5279
|
+
const imageGapToText = MESSAGE_DEFAULTS2.imageGapToText;
|
|
5271
5280
|
const calculatedMessages = [];
|
|
5272
5281
|
let currentY = messagesAnchorY;
|
|
5273
5282
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -5285,8 +5294,20 @@ function calculateMessagePositions2(props) {
|
|
|
5285
5294
|
const textHeight = numLines * lineHeight;
|
|
5286
5295
|
const bubbleWidth = textWidth + bubblePaddingX * 2;
|
|
5287
5296
|
const bubbleHeight = textHeight + bubblePaddingY * 2;
|
|
5297
|
+
let imageWidth;
|
|
5298
|
+
let imageHeight;
|
|
5299
|
+
let imageY;
|
|
5300
|
+
let totalHeight = bubbleHeight;
|
|
5301
|
+
if (msg.imageUrl) {
|
|
5302
|
+
imageWidth = Math.min(imageMaxWidth, maxBubbleWidth);
|
|
5303
|
+
imageHeight = imageWidth / imageAspectRatio;
|
|
5304
|
+
totalHeight = imageHeight + imageGapToText + bubbleHeight;
|
|
5305
|
+
}
|
|
5288
5306
|
const x = isSender ? canvasWidth - paddingRight - bubbleWidth : paddingLeft;
|
|
5289
5307
|
const y = currentY - bubbleHeight;
|
|
5308
|
+
if (msg.imageUrl && imageHeight) {
|
|
5309
|
+
imageY = y - imageGapToText - imageHeight;
|
|
5310
|
+
}
|
|
5290
5311
|
calculatedMessages.unshift({
|
|
5291
5312
|
message: msg,
|
|
5292
5313
|
x,
|
|
@@ -5294,16 +5315,21 @@ function calculateMessagePositions2(props) {
|
|
|
5294
5315
|
width: bubbleWidth,
|
|
5295
5316
|
height: bubbleHeight,
|
|
5296
5317
|
textWidth,
|
|
5297
|
-
textHeight
|
|
5318
|
+
textHeight,
|
|
5319
|
+
imageWidth,
|
|
5320
|
+
imageHeight,
|
|
5321
|
+
imageY
|
|
5298
5322
|
});
|
|
5299
5323
|
const prevMsg = i > 0 ? messages[i - 1] : null;
|
|
5300
5324
|
const gap = prevMsg && prevMsg.sender === msg.sender && !msg.groupWithPrevious ? messageGapSameUser : messageGapDifferentUser;
|
|
5301
|
-
|
|
5325
|
+
const topOfMessage = msg.imageUrl && imageY !== void 0 ? imageY : y;
|
|
5326
|
+
currentY = topOfMessage - gap;
|
|
5302
5327
|
}
|
|
5303
5328
|
return calculatedMessages;
|
|
5304
5329
|
}
|
|
5305
5330
|
function generateMessageElements2(props, calculatedMessages) {
|
|
5306
5331
|
const elements = [];
|
|
5332
|
+
const canvasWidth = props.width ?? 1206;
|
|
5307
5333
|
const senderBubbleColor = props.senderBubbleColor ?? MESSAGE_DEFAULTS2.senderBubbleColor;
|
|
5308
5334
|
const recipientBubbleColor = props.recipientBubbleColor ?? MESSAGE_DEFAULTS2.recipientBubbleColor;
|
|
5309
5335
|
const bubbleTextColor = props.bubbleTextColor ?? MESSAGE_DEFAULTS2.bubbleTextColor;
|
|
@@ -5312,10 +5338,28 @@ function generateMessageElements2(props, calculatedMessages) {
|
|
|
5312
5338
|
const bubbleBorderRadius = props.bubbleBorderRadius ?? MESSAGE_DEFAULTS2.bubbleBorderRadius;
|
|
5313
5339
|
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
5314
5340
|
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
5341
|
+
const imageBorderRadius = MESSAGE_DEFAULTS2.imageBorderRadius;
|
|
5342
|
+
const sentMessagePaddingRight = props.sentMessagePaddingRight ?? MESSAGE_DEFAULTS2.sentMessagePaddingRight;
|
|
5343
|
+
const receivedMessagePaddingLeft = props.receivedMessagePaddingLeft ?? MESSAGE_DEFAULTS2.receivedMessagePaddingLeft;
|
|
5315
5344
|
for (const calc of calculatedMessages) {
|
|
5316
|
-
const { message, x, y, width, height } = calc;
|
|
5345
|
+
const { message, x, y, width, height, imageWidth, imageHeight, imageY } = calc;
|
|
5317
5346
|
const isSender = message.sender === "user";
|
|
5318
5347
|
const bubbleColor = isSender ? senderBubbleColor : recipientBubbleColor;
|
|
5348
|
+
if (message.imageUrl && imageWidth && imageHeight && imageY !== void 0) {
|
|
5349
|
+
const imageX = isSender ? canvasWidth - sentMessagePaddingRight - imageWidth : receivedMessagePaddingLeft;
|
|
5350
|
+
elements.push({
|
|
5351
|
+
id: `image-${message.id}`,
|
|
5352
|
+
type: "image",
|
|
5353
|
+
x: imageX,
|
|
5354
|
+
y: imageY,
|
|
5355
|
+
width: imageWidth,
|
|
5356
|
+
height: imageHeight,
|
|
5357
|
+
zIndex: 10,
|
|
5358
|
+
url: message.imageUrl,
|
|
5359
|
+
borderRadius: imageBorderRadius,
|
|
5360
|
+
objectFit: "cover"
|
|
5361
|
+
});
|
|
5362
|
+
}
|
|
5319
5363
|
elements.push({
|
|
5320
5364
|
id: `bubble-${message.id}`,
|
|
5321
5365
|
type: "text",
|
|
@@ -5338,7 +5382,7 @@ function generateMessageElements2(props, calculatedMessages) {
|
|
|
5338
5382
|
height: height - bubblePaddingY * 2,
|
|
5339
5383
|
zIndex: 11,
|
|
5340
5384
|
text: message.text,
|
|
5341
|
-
fontFamily: "SF Pro Display",
|
|
5385
|
+
fontFamily: '"SF Pro Display", "Apple Color Emoji", sans-serif',
|
|
5342
5386
|
fontWeight: 400,
|
|
5343
5387
|
fontSize: bubbleTextFontSize,
|
|
5344
5388
|
letterSpacing: bubbleTextLetterSpacing,
|
|
@@ -5484,10 +5528,10 @@ var defaultIMessageDmProps = {
|
|
|
5484
5528
|
messagesAnchorY: 2340,
|
|
5485
5529
|
// Example messages
|
|
5486
5530
|
messages: [
|
|
5487
|
-
{ id: "msg-1", sender: "
|
|
5488
|
-
{ id: "msg-2", sender: "
|
|
5489
|
-
{ id: "msg-3", sender: "
|
|
5490
|
-
{ id: "msg-4", sender: "recipient", text: "
|
|
5531
|
+
{ 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" },
|
|
5532
|
+
{ id: "msg-2", sender: "recipient", text: "don't worry king, i gotchu" },
|
|
5533
|
+
{ id: "msg-3", sender: "recipient", text: "that is indeed a cute kitty", groupWithPrevious: true },
|
|
5534
|
+
{ id: "msg-4", sender: "recipient", text: "try this line out for speed: are you a kitty? because you deserve pets", groupWithPrevious: true }
|
|
5491
5535
|
]
|
|
5492
5536
|
};
|
|
5493
5537
|
var IMessageDmComposition = (props) => {
|
|
@@ -5704,7 +5748,7 @@ var IMessageDmComposition = (props) => {
|
|
|
5704
5748
|
"span",
|
|
5705
5749
|
{
|
|
5706
5750
|
style: {
|
|
5707
|
-
fontFamily: "SF Pro Display",
|
|
5751
|
+
fontFamily: '"SF Pro Display", "Apple Color Emoji", sans-serif',
|
|
5708
5752
|
fontWeight: 400,
|
|
5709
5753
|
fontSize: usernameFontSize,
|
|
5710
5754
|
letterSpacing: usernameLetterSpacing,
|
|
@@ -6667,6 +6711,7 @@ var iMessageDmPropsSchema = import_zod.z.object({
|
|
|
6667
6711
|
id: import_zod.z.string(),
|
|
6668
6712
|
sender: import_zod.z.enum(["user", "recipient"]),
|
|
6669
6713
|
text: import_zod.z.string(),
|
|
6714
|
+
imageUrl: import_zod.z.string().optional(),
|
|
6670
6715
|
groupWithPrevious: import_zod.z.boolean().optional()
|
|
6671
6716
|
})).optional()
|
|
6672
6717
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -4315,7 +4315,13 @@ var MESSAGE_DEFAULTS2 = {
|
|
|
4315
4315
|
receivedMessagePaddingRight: 200,
|
|
4316
4316
|
multiLineSentMessagePaddingLeft: 31,
|
|
4317
4317
|
multiLineReceivedMessagePaddingRight: 31,
|
|
4318
|
-
messagesAnchorY: 2340
|
|
4318
|
+
messagesAnchorY: 2340,
|
|
4319
|
+
// Image message defaults
|
|
4320
|
+
imageMaxWidth: 600,
|
|
4321
|
+
imageAspectRatio: 1,
|
|
4322
|
+
// width / height
|
|
4323
|
+
imageBorderRadius: 30,
|
|
4324
|
+
imageGapToText: 8
|
|
4319
4325
|
};
|
|
4320
4326
|
function calculateMessagePositions2(props) {
|
|
4321
4327
|
const messages = props.messages ?? [];
|
|
@@ -4331,6 +4337,9 @@ function calculateMessagePositions2(props) {
|
|
|
4331
4337
|
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
4332
4338
|
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
4333
4339
|
const bubbleTextFontSize = props.bubbleTextFontSize ?? MESSAGE_DEFAULTS2.bubbleTextFontSize;
|
|
4340
|
+
const imageMaxWidth = MESSAGE_DEFAULTS2.imageMaxWidth;
|
|
4341
|
+
const imageAspectRatio = MESSAGE_DEFAULTS2.imageAspectRatio;
|
|
4342
|
+
const imageGapToText = MESSAGE_DEFAULTS2.imageGapToText;
|
|
4334
4343
|
const calculatedMessages = [];
|
|
4335
4344
|
let currentY = messagesAnchorY;
|
|
4336
4345
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -4348,8 +4357,20 @@ function calculateMessagePositions2(props) {
|
|
|
4348
4357
|
const textHeight = numLines * lineHeight;
|
|
4349
4358
|
const bubbleWidth = textWidth + bubblePaddingX * 2;
|
|
4350
4359
|
const bubbleHeight = textHeight + bubblePaddingY * 2;
|
|
4360
|
+
let imageWidth;
|
|
4361
|
+
let imageHeight;
|
|
4362
|
+
let imageY;
|
|
4363
|
+
let totalHeight = bubbleHeight;
|
|
4364
|
+
if (msg.imageUrl) {
|
|
4365
|
+
imageWidth = Math.min(imageMaxWidth, maxBubbleWidth);
|
|
4366
|
+
imageHeight = imageWidth / imageAspectRatio;
|
|
4367
|
+
totalHeight = imageHeight + imageGapToText + bubbleHeight;
|
|
4368
|
+
}
|
|
4351
4369
|
const x = isSender ? canvasWidth - paddingRight - bubbleWidth : paddingLeft;
|
|
4352
4370
|
const y = currentY - bubbleHeight;
|
|
4371
|
+
if (msg.imageUrl && imageHeight) {
|
|
4372
|
+
imageY = y - imageGapToText - imageHeight;
|
|
4373
|
+
}
|
|
4353
4374
|
calculatedMessages.unshift({
|
|
4354
4375
|
message: msg,
|
|
4355
4376
|
x,
|
|
@@ -4357,16 +4378,21 @@ function calculateMessagePositions2(props) {
|
|
|
4357
4378
|
width: bubbleWidth,
|
|
4358
4379
|
height: bubbleHeight,
|
|
4359
4380
|
textWidth,
|
|
4360
|
-
textHeight
|
|
4381
|
+
textHeight,
|
|
4382
|
+
imageWidth,
|
|
4383
|
+
imageHeight,
|
|
4384
|
+
imageY
|
|
4361
4385
|
});
|
|
4362
4386
|
const prevMsg = i > 0 ? messages[i - 1] : null;
|
|
4363
4387
|
const gap = prevMsg && prevMsg.sender === msg.sender && !msg.groupWithPrevious ? messageGapSameUser : messageGapDifferentUser;
|
|
4364
|
-
|
|
4388
|
+
const topOfMessage = msg.imageUrl && imageY !== void 0 ? imageY : y;
|
|
4389
|
+
currentY = topOfMessage - gap;
|
|
4365
4390
|
}
|
|
4366
4391
|
return calculatedMessages;
|
|
4367
4392
|
}
|
|
4368
4393
|
function generateMessageElements2(props, calculatedMessages) {
|
|
4369
4394
|
const elements = [];
|
|
4395
|
+
const canvasWidth = props.width ?? 1206;
|
|
4370
4396
|
const senderBubbleColor = props.senderBubbleColor ?? MESSAGE_DEFAULTS2.senderBubbleColor;
|
|
4371
4397
|
const recipientBubbleColor = props.recipientBubbleColor ?? MESSAGE_DEFAULTS2.recipientBubbleColor;
|
|
4372
4398
|
const bubbleTextColor = props.bubbleTextColor ?? MESSAGE_DEFAULTS2.bubbleTextColor;
|
|
@@ -4375,10 +4401,28 @@ function generateMessageElements2(props, calculatedMessages) {
|
|
|
4375
4401
|
const bubbleBorderRadius = props.bubbleBorderRadius ?? MESSAGE_DEFAULTS2.bubbleBorderRadius;
|
|
4376
4402
|
const bubblePaddingX = props.bubblePaddingX ?? MESSAGE_DEFAULTS2.bubblePaddingX;
|
|
4377
4403
|
const bubblePaddingY = props.bubblePaddingY ?? MESSAGE_DEFAULTS2.bubblePaddingY;
|
|
4404
|
+
const imageBorderRadius = MESSAGE_DEFAULTS2.imageBorderRadius;
|
|
4405
|
+
const sentMessagePaddingRight = props.sentMessagePaddingRight ?? MESSAGE_DEFAULTS2.sentMessagePaddingRight;
|
|
4406
|
+
const receivedMessagePaddingLeft = props.receivedMessagePaddingLeft ?? MESSAGE_DEFAULTS2.receivedMessagePaddingLeft;
|
|
4378
4407
|
for (const calc of calculatedMessages) {
|
|
4379
|
-
const { message, x, y, width, height } = calc;
|
|
4408
|
+
const { message, x, y, width, height, imageWidth, imageHeight, imageY } = calc;
|
|
4380
4409
|
const isSender = message.sender === "user";
|
|
4381
4410
|
const bubbleColor = isSender ? senderBubbleColor : recipientBubbleColor;
|
|
4411
|
+
if (message.imageUrl && imageWidth && imageHeight && imageY !== void 0) {
|
|
4412
|
+
const imageX = isSender ? canvasWidth - sentMessagePaddingRight - imageWidth : receivedMessagePaddingLeft;
|
|
4413
|
+
elements.push({
|
|
4414
|
+
id: `image-${message.id}`,
|
|
4415
|
+
type: "image",
|
|
4416
|
+
x: imageX,
|
|
4417
|
+
y: imageY,
|
|
4418
|
+
width: imageWidth,
|
|
4419
|
+
height: imageHeight,
|
|
4420
|
+
zIndex: 10,
|
|
4421
|
+
url: message.imageUrl,
|
|
4422
|
+
borderRadius: imageBorderRadius,
|
|
4423
|
+
objectFit: "cover"
|
|
4424
|
+
});
|
|
4425
|
+
}
|
|
4382
4426
|
elements.push({
|
|
4383
4427
|
id: `bubble-${message.id}`,
|
|
4384
4428
|
type: "text",
|
|
@@ -4401,7 +4445,7 @@ function generateMessageElements2(props, calculatedMessages) {
|
|
|
4401
4445
|
height: height - bubblePaddingY * 2,
|
|
4402
4446
|
zIndex: 11,
|
|
4403
4447
|
text: message.text,
|
|
4404
|
-
fontFamily: "SF Pro Display",
|
|
4448
|
+
fontFamily: '"SF Pro Display", "Apple Color Emoji", sans-serif',
|
|
4405
4449
|
fontWeight: 400,
|
|
4406
4450
|
fontSize: bubbleTextFontSize,
|
|
4407
4451
|
letterSpacing: bubbleTextLetterSpacing,
|
|
@@ -4547,10 +4591,10 @@ var defaultIMessageDmProps = {
|
|
|
4547
4591
|
messagesAnchorY: 2340,
|
|
4548
4592
|
// Example messages
|
|
4549
4593
|
messages: [
|
|
4550
|
-
{ id: "msg-1", sender: "
|
|
4551
|
-
{ id: "msg-2", sender: "
|
|
4552
|
-
{ id: "msg-3", sender: "
|
|
4553
|
-
{ id: "msg-4", sender: "recipient", text: "
|
|
4594
|
+
{ 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" },
|
|
4595
|
+
{ id: "msg-2", sender: "recipient", text: "don't worry king, i gotchu" },
|
|
4596
|
+
{ id: "msg-3", sender: "recipient", text: "that is indeed a cute kitty", groupWithPrevious: true },
|
|
4597
|
+
{ id: "msg-4", sender: "recipient", text: "try this line out for speed: are you a kitty? because you deserve pets", groupWithPrevious: true }
|
|
4554
4598
|
]
|
|
4555
4599
|
};
|
|
4556
4600
|
var IMessageDmComposition = (props) => {
|
|
@@ -4767,7 +4811,7 @@ var IMessageDmComposition = (props) => {
|
|
|
4767
4811
|
"span",
|
|
4768
4812
|
{
|
|
4769
4813
|
style: {
|
|
4770
|
-
fontFamily: "SF Pro Display",
|
|
4814
|
+
fontFamily: '"SF Pro Display", "Apple Color Emoji", sans-serif',
|
|
4771
4815
|
fontWeight: 400,
|
|
4772
4816
|
fontSize: usernameFontSize,
|
|
4773
4817
|
letterSpacing: usernameLetterSpacing,
|
|
@@ -5447,6 +5491,7 @@ var iMessageDmPropsSchema = z.object({
|
|
|
5447
5491
|
id: z.string(),
|
|
5448
5492
|
sender: z.enum(["user", "recipient"]),
|
|
5449
5493
|
text: z.string(),
|
|
5494
|
+
imageUrl: z.string().optional(),
|
|
5450
5495
|
groupWithPrevious: z.boolean().optional()
|
|
5451
5496
|
})).optional()
|
|
5452
5497
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.158",
|
|
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",
|