@liveblocks/emails 2.21.0-emails1 → 2.21.0-emails3

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.cts CHANGED
@@ -235,6 +235,16 @@ type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<Rea
235
235
  /** @deprecated Use `body` property instead. */
236
236
  reactBody: ReactNode;
237
237
  };
238
+ type PrepareThreadNotificationEmailOptions<U extends BaseUserMeta = DU> = {
239
+ /**
240
+ * A function that returns room info from room IDs.
241
+ */
242
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
243
+ /**
244
+ * A function that returns info from user IDs.
245
+ */
246
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
247
+ };
238
248
  /**
239
249
  * The styles used to customize the html elements in the resulting html safe string.
240
250
  * Each styles has priority over the base styles inherited.
@@ -261,7 +271,7 @@ type ConvertCommentBodyAsHtmlStyles = {
261
271
  */
262
272
  link: CSSProperties;
263
273
  };
264
- type PrepareThreadNotificationEmailAsHtmlOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
274
+ type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailOptions<U> & {
265
275
  /**
266
276
  * The styles used to customize the html elements in the resulting html safe string inside a comment body.
267
277
  * Each styles has priority over the base styles inherited.
@@ -295,7 +305,7 @@ type ThreadNotificationEmailDataAsHtml<U extends BaseUserMeta = DU> = ThreadNoti
295
305
  * )
296
306
  *
297
307
  */
298
- declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<string, BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
308
+ declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
299
309
  type CommentBodyContainerComponentProps = {
300
310
  /**
301
311
  * The blocks of the comment body
@@ -357,11 +367,7 @@ type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
357
367
  */
358
368
  Mention: ComponentType<CommentBodyMentionComponentProps<U>>;
359
369
  };
360
- type PrepareThreadNotificationEmailAsReactOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
361
- /**
362
- * A function that returns info from user IDs.
363
- */
364
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
370
+ type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailOptions<U> & {
365
371
  /**
366
372
  * The components used to customize the resulting React nodes inside a comment body.
367
373
  * Each components has priority over the base components inherited internally defined.
package/dist/index.d.ts CHANGED
@@ -235,6 +235,16 @@ type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<Rea
235
235
  /** @deprecated Use `body` property instead. */
236
236
  reactBody: ReactNode;
237
237
  };
238
+ type PrepareThreadNotificationEmailOptions<U extends BaseUserMeta = DU> = {
239
+ /**
240
+ * A function that returns room info from room IDs.
241
+ */
242
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
243
+ /**
244
+ * A function that returns info from user IDs.
245
+ */
246
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
247
+ };
238
248
  /**
239
249
  * The styles used to customize the html elements in the resulting html safe string.
240
250
  * Each styles has priority over the base styles inherited.
@@ -261,7 +271,7 @@ type ConvertCommentBodyAsHtmlStyles = {
261
271
  */
262
272
  link: CSSProperties;
263
273
  };
264
- type PrepareThreadNotificationEmailAsHtmlOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
274
+ type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailOptions<U> & {
265
275
  /**
266
276
  * The styles used to customize the html elements in the resulting html safe string inside a comment body.
267
277
  * Each styles has priority over the base styles inherited.
@@ -295,7 +305,7 @@ type ThreadNotificationEmailDataAsHtml<U extends BaseUserMeta = DU> = ThreadNoti
295
305
  * )
296
306
  *
297
307
  */
298
- declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<string, BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
308
+ declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
299
309
  type CommentBodyContainerComponentProps = {
300
310
  /**
301
311
  * The blocks of the comment body
@@ -357,11 +367,7 @@ type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
357
367
  */
358
368
  Mention: ComponentType<CommentBodyMentionComponentProps<U>>;
359
369
  };
360
- type PrepareThreadNotificationEmailAsReactOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
361
- /**
362
- * A function that returns info from user IDs.
363
- */
364
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
370
+ type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailOptions<U> & {
365
371
  /**
366
372
  * The components used to customize the resulting React nodes inside a comment body.
367
373
  * Each components has priority over the base components inherited internally defined.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { detectDupes } from "@liveblocks/core";
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/emails";
6
- var PKG_VERSION = "2.21.0-emails1";
6
+ var PKG_VERSION = "2.21.0-emails3";
7
7
  var PKG_FORMAT = "esm";
8
8
 
9
9
  // ../../node_modules/lib0/map.js
@@ -8500,7 +8500,7 @@ var extractThreadNotificationData = async ({
8500
8500
  comments: unreadComments
8501
8501
  };
8502
8502
  };
8503
- async function prepareThreadNotificationEmail(client, event, options) {
8503
+ async function prepareThreadNotificationEmail(client, event, options, elements, callerName) {
8504
8504
  const data = await extractThreadNotificationData({ client, event });
8505
8505
  if (data === null) {
8506
8506
  return null;
@@ -8512,7 +8512,7 @@ async function prepareThreadNotificationEmail(client, event, options) {
8512
8512
  };
8513
8513
  const batchUsersResolver = createBatchUsersResolver({
8514
8514
  resolveUsers: options.resolveUsers,
8515
- callerName: "prepareThreadNotificationEmail"
8515
+ callerName
8516
8516
  });
8517
8517
  switch (data.type) {
8518
8518
  case "unreadMention": {
@@ -8523,7 +8523,7 @@ async function prepareThreadNotificationEmail(client, event, options) {
8523
8523
  });
8524
8524
  const commentBodyPromise = convertCommentBody(comment.body, {
8525
8525
  resolveUsers: batchUsersResolver.resolveUsers,
8526
- elements: options.elements
8526
+ elements
8527
8527
  });
8528
8528
  await batchUsersResolver.resolve();
8529
8529
  const [authorsInfo, commentBody] = await Promise.all([
@@ -8561,7 +8561,7 @@ async function prepareThreadNotificationEmail(client, event, options) {
8561
8561
  const commentBodiesPromises = comments.map(
8562
8562
  (c) => convertCommentBody(c.body, {
8563
8563
  resolveUsers: batchUsersResolver.resolveUsers,
8564
- elements: options.elements
8564
+ elements
8565
8565
  })
8566
8566
  );
8567
8567
  await batchUsersResolver.resolve();
@@ -8623,40 +8623,41 @@ async function prepareThreadNotificationEmailAsHtml(client, event, options = {})
8623
8623
  event,
8624
8624
  {
8625
8625
  resolveUsers: options.resolveUsers,
8626
- resolveRoomInfo: options.resolveRoomInfo,
8627
- elements: {
8628
- container: ({ children }) => children.join("\n"),
8629
- paragraph: ({ children }) => {
8630
- const unsafe = children.join("");
8631
- return unsafe ? html2`<p style="${toInlineCSSString(styles.paragraph)}">${htmlSafe2(unsafe)}</p>` : unsafe;
8632
- },
8633
- text: ({ element }) => {
8634
- let children = element.text;
8635
- if (!children) {
8636
- return html2`${children}`;
8637
- }
8638
- if (element.bold) {
8639
- children = html2`<strong style="${toInlineCSSString(styles.strong)}">${children}</strong>`;
8640
- }
8641
- if (element.italic) {
8642
- children = html2`<em>${children}</em>`;
8643
- }
8644
- if (element.strikethrough) {
8645
- children = html2`<s>${children}</s>`;
8646
- }
8647
- if (element.code) {
8648
- children = html2`<code style="${toInlineCSSString(styles.code)}">${children}</code>`;
8649
- }
8626
+ resolveRoomInfo: options.resolveRoomInfo
8627
+ },
8628
+ {
8629
+ container: ({ children }) => children.join("\n"),
8630
+ paragraph: ({ children }) => {
8631
+ const unsafe = children.join("");
8632
+ return unsafe ? html2`<p style="${toInlineCSSString(styles.paragraph)}">${htmlSafe2(unsafe)}</p>` : unsafe;
8633
+ },
8634
+ text: ({ element }) => {
8635
+ let children = element.text;
8636
+ if (!children) {
8650
8637
  return html2`${children}`;
8651
- },
8652
- link: ({ element, href }) => {
8653
- return html2`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ? html2`${element.text}` : element.url}</a>`;
8654
- },
8655
- mention: ({ element, user }) => {
8656
- return html2`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${user?.name ? html2`${user?.name}` : element.id}</span>`;
8657
8638
  }
8639
+ if (element.bold) {
8640
+ children = html2`<strong style="${toInlineCSSString(styles.strong)}">${children}</strong>`;
8641
+ }
8642
+ if (element.italic) {
8643
+ children = html2`<em>${children}</em>`;
8644
+ }
8645
+ if (element.strikethrough) {
8646
+ children = html2`<s>${children}</s>`;
8647
+ }
8648
+ if (element.code) {
8649
+ children = html2`<code style="${toInlineCSSString(styles.code)}">${children}</code>`;
8650
+ }
8651
+ return html2`${children}`;
8652
+ },
8653
+ link: ({ element, href }) => {
8654
+ return html2`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ? html2`${element.text}` : element.url}</a>`;
8655
+ },
8656
+ mention: ({ element, user }) => {
8657
+ return html2`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${user?.name ? html2`${user?.name}` : element.id}</span>`;
8658
8658
  }
8659
- }
8659
+ },
8660
+ "prepareThreadNotificationEmailAsHtml"
8660
8661
  );
8661
8662
  if (data === null) {
8662
8663
  return null;
@@ -8711,35 +8712,36 @@ async function prepareThreadNotificationEmailAsReact(client, event, options = {}
8711
8712
  event,
8712
8713
  {
8713
8714
  resolveUsers: options.resolveUsers,
8714
- resolveRoomInfo: options.resolveRoomInfo,
8715
- elements: {
8716
- container: ({ children }) => /* @__PURE__ */ jsx2(Components.Container, { children }, "lb-comment-body-container"),
8717
- paragraph: ({ children }, index) => /* @__PURE__ */ jsx2(Components.Paragraph, { children }, `lb-comment-body-paragraph-${index}`),
8718
- text: ({ element }, index) => /* @__PURE__ */ jsx2(
8719
- Components.Text,
8720
- {
8721
- element
8722
- },
8723
- `lb-comment-body-text-${index}`
8724
- ),
8725
- link: ({ element, href }, index) => /* @__PURE__ */ jsx2(
8726
- Components.Link,
8727
- {
8728
- element,
8729
- href
8730
- },
8731
- `lb-comment-body-link-${index}`
8732
- ),
8733
- mention: ({ element, user }, index) => element.id ? /* @__PURE__ */ jsx2(
8734
- Components.Mention,
8735
- {
8736
- element,
8737
- user
8738
- },
8739
- `lb-comment-body-mention-${index}`
8740
- ) : null
8741
- }
8742
- }
8715
+ resolveRoomInfo: options.resolveRoomInfo
8716
+ },
8717
+ {
8718
+ container: ({ children }) => /* @__PURE__ */ jsx2(Components.Container, { children }, "lb-comment-body-container"),
8719
+ paragraph: ({ children }, index) => /* @__PURE__ */ jsx2(Components.Paragraph, { children }, `lb-comment-body-paragraph-${index}`),
8720
+ text: ({ element }, index) => /* @__PURE__ */ jsx2(
8721
+ Components.Text,
8722
+ {
8723
+ element
8724
+ },
8725
+ `lb-comment-body-text-${index}`
8726
+ ),
8727
+ link: ({ element, href }, index) => /* @__PURE__ */ jsx2(
8728
+ Components.Link,
8729
+ {
8730
+ element,
8731
+ href
8732
+ },
8733
+ `lb-comment-body-link-${index}`
8734
+ ),
8735
+ mention: ({ element, user }, index) => element.id ? /* @__PURE__ */ jsx2(
8736
+ Components.Mention,
8737
+ {
8738
+ element,
8739
+ user
8740
+ },
8741
+ `lb-comment-body-mention-${index}`
8742
+ ) : null
8743
+ },
8744
+ "prepareThreadNotificationEmailAsReact"
8743
8745
  );
8744
8746
  if (data === null) {
8745
8747
  return null;