ugcinc-render 1.8.155 → 1.8.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -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
- currentY = y - gap;
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",
@@ -5385,16 +5429,16 @@ var defaultIMessageDmProps = {
5385
5429
  profilePicRight: 680,
5386
5430
  username: "aidan gollan",
5387
5431
  usernameTop: 355,
5388
- usernameBottom: 393,
5389
- usernameLeft: 450,
5390
- usernameRight: 756,
5391
- usernameFontSize: 42,
5392
- usernameLetterSpacing: 0,
5432
+ usernameBottom: 404,
5433
+ usernameLeft: 429,
5434
+ usernameRight: 752,
5435
+ usernameFontSize: 36,
5436
+ usernameLetterSpacing: 0.8,
5393
5437
  usernameColor: "#ffffff",
5394
- usernameArrowOffsetX: 12,
5395
- usernameArrowOffsetY: -3,
5396
- usernameArrowWidth: 13,
5397
- usernameArrowHeight: 23,
5438
+ usernameArrowOffsetX: -57,
5439
+ usernameArrowOffsetY: 2,
5440
+ usernameArrowWidth: 14,
5441
+ usernameArrowHeight: 24,
5398
5442
  // Divider line defaults
5399
5443
  dividerLineY: 425,
5400
5444
  dividerLineColor: "#262626",
@@ -5484,10 +5528,10 @@ var defaultIMessageDmProps = {
5484
5528
  messagesAnchorY: 2340,
5485
5529
  // Example messages
5486
5530
  messages: [
5487
- { id: "msg-1", sender: "recipient", text: "Hey! How are you?" },
5488
- { id: "msg-2", sender: "user", text: "I'm good, thanks!" },
5489
- { id: "msg-3", sender: "user", text: "How about you?", groupWithPrevious: true },
5490
- { id: "msg-4", sender: "recipient", text: "Great! Just working on some stuff." }
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) => {
@@ -5512,16 +5556,16 @@ var IMessageDmComposition = (props) => {
5512
5556
  profilePicRight = 680,
5513
5557
  username = "aidan gollan",
5514
5558
  usernameTop = 355,
5515
- usernameBottom = 393,
5516
- usernameLeft = 450,
5517
- usernameRight = 756,
5518
- usernameFontSize = 42,
5519
- usernameLetterSpacing = 0,
5559
+ usernameBottom = 404,
5560
+ usernameLeft = 429,
5561
+ usernameRight = 752,
5562
+ usernameFontSize = 36,
5563
+ usernameLetterSpacing = 0.8,
5520
5564
  usernameColor = "#ffffff",
5521
- usernameArrowOffsetX = 12,
5522
- usernameArrowOffsetY = -3,
5523
- usernameArrowWidth = 13,
5524
- usernameArrowHeight = 23,
5565
+ usernameArrowOffsetX = -57,
5566
+ usernameArrowOffsetY = 2,
5567
+ usernameArrowWidth = 14,
5568
+ usernameArrowHeight = 24,
5525
5569
  dividerLineY = 425,
5526
5570
  dividerLineColor = "#262626",
5527
5571
  showDebugOverlay = false,
@@ -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
- currentY = y - gap;
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",
@@ -4448,16 +4492,16 @@ var defaultIMessageDmProps = {
4448
4492
  profilePicRight: 680,
4449
4493
  username: "aidan gollan",
4450
4494
  usernameTop: 355,
4451
- usernameBottom: 393,
4452
- usernameLeft: 450,
4453
- usernameRight: 756,
4454
- usernameFontSize: 42,
4455
- usernameLetterSpacing: 0,
4495
+ usernameBottom: 404,
4496
+ usernameLeft: 429,
4497
+ usernameRight: 752,
4498
+ usernameFontSize: 36,
4499
+ usernameLetterSpacing: 0.8,
4456
4500
  usernameColor: "#ffffff",
4457
- usernameArrowOffsetX: 12,
4458
- usernameArrowOffsetY: -3,
4459
- usernameArrowWidth: 13,
4460
- usernameArrowHeight: 23,
4501
+ usernameArrowOffsetX: -57,
4502
+ usernameArrowOffsetY: 2,
4503
+ usernameArrowWidth: 14,
4504
+ usernameArrowHeight: 24,
4461
4505
  // Divider line defaults
4462
4506
  dividerLineY: 425,
4463
4507
  dividerLineColor: "#262626",
@@ -4547,10 +4591,10 @@ var defaultIMessageDmProps = {
4547
4591
  messagesAnchorY: 2340,
4548
4592
  // Example messages
4549
4593
  messages: [
4550
- { id: "msg-1", sender: "recipient", text: "Hey! How are you?" },
4551
- { id: "msg-2", sender: "user", text: "I'm good, thanks!" },
4552
- { id: "msg-3", sender: "user", text: "How about you?", groupWithPrevious: true },
4553
- { id: "msg-4", sender: "recipient", text: "Great! Just working on some stuff." }
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) => {
@@ -4575,16 +4619,16 @@ var IMessageDmComposition = (props) => {
4575
4619
  profilePicRight = 680,
4576
4620
  username = "aidan gollan",
4577
4621
  usernameTop = 355,
4578
- usernameBottom = 393,
4579
- usernameLeft = 450,
4580
- usernameRight = 756,
4581
- usernameFontSize = 42,
4582
- usernameLetterSpacing = 0,
4622
+ usernameBottom = 404,
4623
+ usernameLeft = 429,
4624
+ usernameRight = 752,
4625
+ usernameFontSize = 36,
4626
+ usernameLetterSpacing = 0.8,
4583
4627
  usernameColor = "#ffffff",
4584
- usernameArrowOffsetX = 12,
4585
- usernameArrowOffsetY = -3,
4586
- usernameArrowWidth = 13,
4587
- usernameArrowHeight = 23,
4628
+ usernameArrowOffsetX = -57,
4629
+ usernameArrowOffsetY = 2,
4630
+ usernameArrowWidth = 14,
4631
+ usernameArrowHeight = 24,
4588
4632
  dividerLineY = 425,
4589
4633
  dividerLineColor = "#262626",
4590
4634
  showDebugOverlay = false,
@@ -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.155",
3
+ "version": "1.8.157",
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",