@liveblocks/emails 2.18.2 → 2.18.4-uns1

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.
@@ -1,10 +1,10 @@
1
- // src/index.ts
2
- import { detectDupes } from "@liveblocks/core";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/index.ts
2
+ var _core = require('@liveblocks/core');
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/emails";
6
- var PKG_VERSION = "2.18.2";
7
- var PKG_FORMAT = "esm";
6
+ var PKG_VERSION = "2.18.4-uns1";
7
+ var PKG_FORMAT = "cjs";
8
8
 
9
9
  // ../../node_modules/lib0/map.js
10
10
  var create = () => /* @__PURE__ */ new Map();
@@ -763,14 +763,14 @@ var StringDecoder = class {
763
763
  };
764
764
 
765
765
  // ../../node_modules/lib0/webcrypto.node.js
766
- import { webcrypto } from "node:crypto";
766
+ var _crypto = require('crypto');
767
767
  var subtle = (
768
768
  /** @type {any} */
769
- webcrypto.subtle
769
+ _crypto.webcrypto.subtle
770
770
  );
771
771
  var getRandomValues = (
772
772
  /** @type {any} */
773
- webcrypto.getRandomValues.bind(webcrypto)
773
+ _crypto.webcrypto.getRandomValues.bind(_crypto.webcrypto)
774
774
  );
775
775
 
776
776
  // ../../node_modules/lib0/random.js
@@ -950,7 +950,7 @@ var PURPLE = create5();
950
950
  var ORANGE = create5();
951
951
  var UNCOLOR = create5();
952
952
  var computeNoColorLoggingArgs = (args2) => {
953
- if (args2.length === 1 && args2[0]?.constructor === Function) {
953
+ if (args2.length === 1 && _optionalChain([args2, 'access', _ => _[0], 'optionalAccess', _2 => _2.constructor]) === Function) {
954
954
  args2 = /** @type {Array<string|Symbol|Object|number>} */
955
955
  /** @type {[function]} */
956
956
  args2[0]();
@@ -994,7 +994,7 @@ var _nodeStyleMap = {
994
994
  [UNCOLOR]: "\x1B[0m"
995
995
  };
996
996
  var computeNodeLoggingArgs = (args2) => {
997
- if (args2.length === 1 && args2[0]?.constructor === Function) {
997
+ if (args2.length === 1 && _optionalChain([args2, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.constructor]) === Function) {
998
998
  args2 = /** @type {Array<string|Symbol|Object|number>} */
999
999
  /** @type {[function]} */
1000
1000
  args2[0]();
@@ -3356,7 +3356,7 @@ var AbstractType = class {
3356
3356
  }
3357
3357
  };
3358
3358
  var typeListSlice = (type, start, end) => {
3359
- type.doc ?? warnPrematureAccess();
3359
+ _nullishCoalesce(type.doc, () => ( warnPrematureAccess()));
3360
3360
  if (start < 0) {
3361
3361
  start = type._length + start;
3362
3362
  }
@@ -3384,7 +3384,7 @@ var typeListSlice = (type, start, end) => {
3384
3384
  return cs;
3385
3385
  };
3386
3386
  var typeListToArray = (type) => {
3387
- type.doc ?? warnPrematureAccess();
3387
+ _nullishCoalesce(type.doc, () => ( warnPrematureAccess()));
3388
3388
  const cs = [];
3389
3389
  let n = type._start;
3390
3390
  while (n !== null) {
@@ -3401,7 +3401,7 @@ var typeListToArray = (type) => {
3401
3401
  var typeListForEach = (type, f) => {
3402
3402
  let index = 0;
3403
3403
  let n = type._start;
3404
- type.doc ?? warnPrematureAccess();
3404
+ _nullishCoalesce(type.doc, () => ( warnPrematureAccess()));
3405
3405
  while (n !== null) {
3406
3406
  if (n.countable && !n.deleted) {
3407
3407
  const c = n.content.getContent();
@@ -3454,7 +3454,7 @@ var typeListCreateIterator = (type) => {
3454
3454
  };
3455
3455
  };
3456
3456
  var typeListGet = (type, index) => {
3457
- type.doc ?? warnPrematureAccess();
3457
+ _nullishCoalesce(type.doc, () => ( warnPrematureAccess()));
3458
3458
  const marker = findMarker(type, index);
3459
3459
  let n = type._start;
3460
3460
  if (marker !== null) {
@@ -3662,13 +3662,13 @@ var typeMapSet = (transaction, parent, key, value) => {
3662
3662
  new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, null, null, parent, key, content).integrate(transaction, 0);
3663
3663
  };
3664
3664
  var typeMapGet = (parent, key) => {
3665
- parent.doc ?? warnPrematureAccess();
3665
+ _nullishCoalesce(parent.doc, () => ( warnPrematureAccess()));
3666
3666
  const val = parent._map.get(key);
3667
3667
  return val !== void 0 && !val.deleted ? val.content.getContent()[val.length - 1] : void 0;
3668
3668
  };
3669
3669
  var typeMapGetAll = (parent) => {
3670
3670
  const res = {};
3671
- parent.doc ?? warnPrematureAccess();
3671
+ _nullishCoalesce(parent.doc, () => ( warnPrematureAccess()));
3672
3672
  parent._map.forEach((value, key) => {
3673
3673
  if (!value.deleted) {
3674
3674
  res[key] = value.content.getContent()[value.length - 1];
@@ -3677,7 +3677,7 @@ var typeMapGetAll = (parent) => {
3677
3677
  return res;
3678
3678
  };
3679
3679
  var typeMapHas = (parent, key) => {
3680
- parent.doc ?? warnPrematureAccess();
3680
+ _nullishCoalesce(parent.doc, () => ( warnPrematureAccess()));
3681
3681
  const val = parent._map.get(key);
3682
3682
  return val !== void 0 && !val.deleted;
3683
3683
  };
@@ -3695,7 +3695,7 @@ var typeMapGetAllSnapshot = (parent, snapshot) => {
3695
3695
  return res;
3696
3696
  };
3697
3697
  var createMapIterator = (type) => {
3698
- type.doc ?? warnPrematureAccess();
3698
+ _nullishCoalesce(type.doc, () => ( warnPrematureAccess()));
3699
3699
  return iteratorFilter(
3700
3700
  type._map.entries(),
3701
3701
  /** @param {any} entry */
@@ -3764,7 +3764,7 @@ var YArray = class _YArray extends AbstractType {
3764
3764
  return arr;
3765
3765
  }
3766
3766
  get length() {
3767
- this.doc ?? warnPrematureAccess();
3767
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
3768
3768
  return this._length;
3769
3769
  }
3770
3770
  /**
@@ -4006,7 +4006,7 @@ var YMap = class _YMap extends AbstractType {
4006
4006
  * @return {Object<string,any>}
4007
4007
  */
4008
4008
  toJSON() {
4009
- this.doc ?? warnPrematureAccess();
4009
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
4010
4010
  const map = {};
4011
4011
  this._map.forEach((item, key) => {
4012
4012
  if (!item.deleted) {
@@ -4069,7 +4069,7 @@ var YMap = class _YMap extends AbstractType {
4069
4069
  * @param {function(MapType,string,YMap<MapType>):void} f A function to execute on every element of this YArray.
4070
4070
  */
4071
4071
  forEach(f) {
4072
- this.doc ?? warnPrematureAccess();
4072
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
4073
4073
  this._map.forEach((item, key) => {
4074
4074
  if (!item.deleted) {
4075
4075
  f(item.content.getContent()[item.length - 1], key, this);
@@ -4285,10 +4285,10 @@ var minimizeAttributeChanges = (currPos, attributes) => {
4285
4285
  if (currPos.right === null) {
4286
4286
  break;
4287
4287
  } else if (currPos.right.deleted || currPos.right.content.constructor === ContentFormat && equalAttrs(
4288
- attributes[
4288
+ _nullishCoalesce(attributes[
4289
4289
  /** @type {ContentFormat} */
4290
4290
  currPos.right.content.key
4291
- ] ?? null,
4291
+ ], () => ( null)),
4292
4292
  /** @type {ContentFormat} */
4293
4293
  currPos.right.content.value
4294
4294
  )) ;
@@ -4304,7 +4304,7 @@ var insertAttributes = (transaction, parent, currPos, attributes) => {
4304
4304
  const negatedAttributes = /* @__PURE__ */ new Map();
4305
4305
  for (const key in attributes) {
4306
4306
  const val = attributes[key];
4307
- const currentVal = currPos.currentAttributes.get(key) ?? null;
4307
+ const currentVal = _nullishCoalesce(currPos.currentAttributes.get(key), () => ( null));
4308
4308
  if (!equalAttrs(currentVal, val)) {
4309
4309
  negatedAttributes.set(key, currentVal);
4310
4310
  const { left, right } = currPos;
@@ -4417,11 +4417,11 @@ var cleanupFormattingGap = (transaction, start, curr, startAttributes, currAttri
4417
4417
  /** @type {ContentFormat} */
4418
4418
  content
4419
4419
  );
4420
- const startAttrValue = startAttributes.get(key) ?? null;
4420
+ const startAttrValue = _nullishCoalesce(startAttributes.get(key), () => ( null));
4421
4421
  if (endFormats.get(key) !== content || startAttrValue === value) {
4422
4422
  start.delete(transaction);
4423
4423
  cleanups++;
4424
- if (!reachedCurr && (currAttributes.get(key) ?? null) === value && startAttrValue !== value) {
4424
+ if (!reachedCurr && (_nullishCoalesce(currAttributes.get(key), () => ( null))) === value && startAttrValue !== value) {
4425
4425
  if (startAttrValue === null) {
4426
4426
  currAttributes.delete(key);
4427
4427
  } else {
@@ -4737,12 +4737,12 @@ var YTextEvent = class extends YEvent {
4737
4737
  );
4738
4738
  if (this.adds(item)) {
4739
4739
  if (!this.deletes(item)) {
4740
- const curVal = currentAttributes.get(key) ?? null;
4740
+ const curVal = _nullishCoalesce(currentAttributes.get(key), () => ( null));
4741
4741
  if (!equalAttrs(curVal, value)) {
4742
4742
  if (action === "retain") {
4743
4743
  addOp();
4744
4744
  }
4745
- if (equalAttrs(value, oldAttributes.get(key) ?? null)) {
4745
+ if (equalAttrs(value, _nullishCoalesce(oldAttributes.get(key), () => ( null)))) {
4746
4746
  delete attributes[key];
4747
4747
  } else {
4748
4748
  attributes[key] = value;
@@ -4753,7 +4753,7 @@ var YTextEvent = class extends YEvent {
4753
4753
  }
4754
4754
  } else if (this.deletes(item)) {
4755
4755
  oldAttributes.set(key, value);
4756
- const curVal = currentAttributes.get(key) ?? null;
4756
+ const curVal = _nullishCoalesce(currentAttributes.get(key), () => ( null));
4757
4757
  if (!equalAttrs(curVal, value)) {
4758
4758
  if (action === "retain") {
4759
4759
  addOp();
@@ -4827,7 +4827,7 @@ var YText = class _YText extends AbstractType {
4827
4827
  * @type {number}
4828
4828
  */
4829
4829
  get length() {
4830
- this.doc ?? warnPrematureAccess();
4830
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
4831
4831
  return this._length;
4832
4832
  }
4833
4833
  /**
@@ -4878,7 +4878,7 @@ var YText = class _YText extends AbstractType {
4878
4878
  * @public
4879
4879
  */
4880
4880
  toString() {
4881
- this.doc ?? warnPrematureAccess();
4881
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
4882
4882
  let str = "";
4883
4883
  let n = this._start;
4884
4884
  while (n !== null) {
@@ -4942,7 +4942,7 @@ var YText = class _YText extends AbstractType {
4942
4942
  * @public
4943
4943
  */
4944
4944
  toDelta(snapshot, prevSnapshot, computeYChange) {
4945
- this.doc ?? warnPrematureAccess();
4945
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
4946
4946
  const ops = [];
4947
4947
  const currentAttributes = /* @__PURE__ */ new Map();
4948
4948
  const doc = (
@@ -5225,7 +5225,7 @@ var YXmlTreeWalker = class {
5225
5225
  this._currentNode = /** @type {Item} */
5226
5226
  root._start;
5227
5227
  this._firstCall = true;
5228
- root.doc ?? warnPrematureAccess();
5228
+ _nullishCoalesce(root.doc, () => ( warnPrematureAccess()));
5229
5229
  }
5230
5230
  [Symbol.iterator]() {
5231
5231
  return this;
@@ -5323,7 +5323,7 @@ var YXmlFragment = class _YXmlFragment extends AbstractType {
5323
5323
  return el;
5324
5324
  }
5325
5325
  get length() {
5326
- this.doc ?? warnPrematureAccess();
5326
+ _nullishCoalesce(this.doc, () => ( warnPrematureAccess()));
5327
5327
  return this._prelimContent === null ? this._length : this._prelimContent.length;
5328
5328
  }
5329
5329
  /**
@@ -7598,7 +7598,7 @@ var resolveAuthorsInfo = async ({
7598
7598
  }
7599
7599
  const users = await resolveUsers({ userIds });
7600
7600
  for (const [index, userId] of userIds.entries()) {
7601
- const user = users?.[index];
7601
+ const user = _optionalChain([users, 'optionalAccess', _5 => _5[index]]);
7602
7602
  if (user) {
7603
7603
  resolvedUsers.set(userId, user);
7604
7604
  }
@@ -7607,7 +7607,7 @@ var resolveAuthorsInfo = async ({
7607
7607
  };
7608
7608
 
7609
7609
  // src/lib/batch-users-resolver.ts
7610
- import { Promise_withResolvers } from "@liveblocks/core";
7610
+
7611
7611
 
7612
7612
  // src/lib/warning.ts
7613
7613
  var createDevelopmentWarning = (condition, ...args2) => {
@@ -7626,15 +7626,15 @@ var createDevelopmentWarning = (condition, ...args2) => {
7626
7626
  };
7627
7627
 
7628
7628
  // src/lib/batch-users-resolver.ts
7629
- var BatchUsersResolver = class {
7630
- isResolved;
7631
- markAsResolved;
7632
- resolvePromise;
7633
- primeResolveUsersFn;
7634
- usersById;
7635
- warnAsAlreadyResolved;
7636
- constructor(resolveUsers) {
7637
- const { promise, resolve } = Promise_withResolvers();
7629
+ var BatchUsersResolver = (_class = class {
7630
+
7631
+
7632
+
7633
+
7634
+
7635
+
7636
+ constructor(resolveUsers) {;_class.prototype.__init.call(this);
7637
+ const { promise, resolve } = _core.Promise_withResolvers.call(void 0, );
7638
7638
  this.isResolved = false;
7639
7639
  this.markAsResolved = resolve;
7640
7640
  this.resolvePromise = promise;
@@ -7645,7 +7645,7 @@ var BatchUsersResolver = class {
7645
7645
  "Batch users resolver promise already resolved. It can only resolve once."
7646
7646
  );
7647
7647
  }
7648
- resolveUsers = async (args2) => {
7648
+ __init() {this.resolveUsers = async (args2) => {
7649
7649
  if (this.isResolved) {
7650
7650
  this.warnAsAlreadyResolved();
7651
7651
  return void 0;
@@ -7655,22 +7655,22 @@ var BatchUsersResolver = class {
7655
7655
  }
7656
7656
  await this.resolvePromise;
7657
7657
  return args2.userIds.map((userId) => this.usersById.get(userId));
7658
- };
7658
+ }}
7659
7659
  async resolve() {
7660
7660
  if (this.isResolved) {
7661
7661
  this.warnAsAlreadyResolved();
7662
7662
  return;
7663
7663
  }
7664
7664
  const userIds = Array.from(this.usersById.keys());
7665
- const users = await this.primeResolveUsersFn?.({ userIds });
7665
+ const users = await _optionalChain([this, 'access', _6 => _6.primeResolveUsersFn, 'optionalCall', _7 => _7({ userIds })]);
7666
7666
  for (const [index, userId] of userIds.entries()) {
7667
- const user = users?.[index];
7667
+ const user = _optionalChain([users, 'optionalAccess', _8 => _8[index]]);
7668
7668
  this.usersById.set(userId, user);
7669
7669
  }
7670
7670
  this.isResolved = true;
7671
7671
  this.markAsResolved();
7672
7672
  }
7673
- };
7673
+ }, _class);
7674
7674
  function createBatchUsersResolver({
7675
7675
  resolveUsers,
7676
7676
  callerName
@@ -7691,7 +7691,7 @@ function createBatchUsersResolver({
7691
7691
  }
7692
7692
 
7693
7693
  // src/liveblocks-text-editor.tsx
7694
- import { html, htmlSafe } from "@liveblocks/core";
7694
+
7695
7695
 
7696
7696
  // src/lib/constants.ts
7697
7697
  var MENTION_CHARACTER = "@";
@@ -7925,7 +7925,7 @@ function findTiptapMentionNodeWithContext({
7925
7925
  }
7926
7926
 
7927
7927
  // src/liveblocks-text-editor.tsx
7928
- import { jsx, jsxs } from "react/jsx-runtime";
7928
+ var _jsxruntime = require('react/jsx-runtime');
7929
7929
  var baseLiveblocksTextEditorTextFormat = {
7930
7930
  bold: false,
7931
7931
  italic: false,
@@ -8056,41 +8056,41 @@ var resolveUsersInLiveblocksTextEditorNodes = async (nodes, resolveUsers) => {
8056
8056
  return resolvedUsers;
8057
8057
  };
8058
8058
  var baseComponents = {
8059
- Container: ({ children }) => /* @__PURE__ */ jsx("div", { children }),
8060
- Mention: ({ element, user }) => /* @__PURE__ */ jsxs("span", { "data-mention": true, children: [
8059
+ Container: ({ children }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children }),
8060
+ Mention: ({ element, user }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-mention": true, children: [
8061
8061
  MENTION_CHARACTER,
8062
- user?.name ?? element.userId
8062
+ _nullishCoalesce(_optionalChain([user, 'optionalAccess', _9 => _9.name]), () => ( element.userId))
8063
8063
  ] }),
8064
8064
  Text: ({ element }) => {
8065
8065
  let children = element.text;
8066
8066
  if (element.bold) {
8067
- children = /* @__PURE__ */ jsx("strong", { children });
8067
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children });
8068
8068
  }
8069
8069
  if (element.italic) {
8070
- children = /* @__PURE__ */ jsx("em", { children });
8070
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "em", { children });
8071
8071
  }
8072
8072
  if (element.strikethrough) {
8073
- children = /* @__PURE__ */ jsx("s", { children });
8073
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "s", { children });
8074
8074
  }
8075
8075
  if (element.code) {
8076
- children = /* @__PURE__ */ jsx("code", { children });
8076
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children });
8077
8077
  }
8078
- return /* @__PURE__ */ jsx("span", { children });
8078
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children });
8079
8079
  }
8080
8080
  };
8081
8081
  async function convertTextEditorNodesAsReact(nodes, options) {
8082
8082
  const Components = {
8083
8083
  ...baseComponents,
8084
- ...options?.components
8084
+ ..._optionalChain([options, 'optionalAccess', _10 => _10.components])
8085
8085
  };
8086
8086
  const resolvedUsers = await resolveUsersInLiveblocksTextEditorNodes(
8087
8087
  nodes,
8088
- options?.resolveUsers
8088
+ _optionalChain([options, 'optionalAccess', _11 => _11.resolveUsers])
8089
8089
  );
8090
8090
  const children = nodes.map((node, index) => {
8091
8091
  switch (node.type) {
8092
8092
  case "mention":
8093
- return /* @__PURE__ */ jsx(
8093
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
8094
8094
  Components.Mention,
8095
8095
  {
8096
8096
  element: node,
@@ -8099,7 +8099,7 @@ async function convertTextEditorNodesAsReact(nodes, options) {
8099
8099
  `lb-text-editor-mention-${index}-${node.userId}`
8100
8100
  );
8101
8101
  case "text":
8102
- return /* @__PURE__ */ jsx(
8102
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
8103
8103
  Components.Text,
8104
8104
  {
8105
8105
  element: node
@@ -8108,7 +8108,7 @@ async function convertTextEditorNodesAsReact(nodes, options) {
8108
8108
  );
8109
8109
  }
8110
8110
  });
8111
- return /* @__PURE__ */ jsx(Components.Container, { children }, "lb-text-editor-container");
8111
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Components.Container, { children }, "lb-text-editor-container");
8112
8112
  }
8113
8113
  var baseStyles = {
8114
8114
  container: {
@@ -8128,41 +8128,41 @@ var baseStyles = {
8128
8128
  }
8129
8129
  };
8130
8130
  async function convertTextEditorNodesAsHtml(nodes, options) {
8131
- const styles = { ...baseStyles, ...options?.styles };
8131
+ const styles = { ...baseStyles, ..._optionalChain([options, 'optionalAccess', _12 => _12.styles]) };
8132
8132
  const resolvedUsers = await resolveUsersInLiveblocksTextEditorNodes(
8133
8133
  nodes,
8134
- options?.resolveUsers
8134
+ _optionalChain([options, 'optionalAccess', _13 => _13.resolveUsers])
8135
8135
  );
8136
8136
  const children = nodes.map((node) => {
8137
8137
  switch (node.type) {
8138
8138
  case "mention": {
8139
8139
  const user = resolvedUsers.get(node.userId);
8140
- return html`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${user?.name ?? node.userId}</span>`;
8140
+ return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _14 => _14.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _15 => _15.name])}` : node.userId}</span>`;
8141
8141
  }
8142
8142
  case "text": {
8143
8143
  let children2 = node.text;
8144
8144
  if (!children2) {
8145
- return children2;
8145
+ return _core.html`${children2}`;
8146
8146
  }
8147
8147
  if (node.bold) {
8148
- children2 = html`<strong style="${toInlineCSSString(styles.strong)}">${children2}</strong>`;
8148
+ children2 = _core.html`<strong style="${toInlineCSSString(styles.strong)}">${children2}</strong>`;
8149
8149
  }
8150
8150
  if (node.italic) {
8151
- children2 = html`<em>${children2}</em>`;
8151
+ children2 = _core.html`<em>${children2}</em>`;
8152
8152
  }
8153
8153
  if (node.strikethrough) {
8154
- children2 = html`<s>${children2}</s>`;
8154
+ children2 = _core.html`<s>${children2}</s>`;
8155
8155
  }
8156
8156
  if (node.code) {
8157
- children2 = html`<code style="${toInlineCSSString(styles.code)}">${children2}</code>`;
8157
+ children2 = _core.html`<code style="${toInlineCSSString(styles.code)}">${children2}</code>`;
8158
8158
  }
8159
- return children2;
8159
+ return _core.html`${children2}`;
8160
8160
  }
8161
8161
  }
8162
8162
  }).join("");
8163
8163
  const content = [
8164
8164
  // prettier-ignore
8165
- html`<div style="${toInlineCSSString(styles.container)}">${htmlSafe(children)}</div>`
8165
+ _core.html`<div style="${toInlineCSSString(styles.container)}">${_core.htmlSafe.call(void 0, children)}</div>`
8166
8166
  ];
8167
8167
  return content.join("\n");
8168
8168
  }
@@ -8241,7 +8241,7 @@ var prepareTextMentionNotificationEmailBaseData = async ({
8241
8241
  const roomInfo = options.resolveRoomInfo ? await options.resolveRoomInfo({ roomId }) : void 0;
8242
8242
  const resolvedRoomInfo = {
8243
8243
  ...roomInfo,
8244
- name: roomInfo?.name ?? roomId
8244
+ name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _16 => _16.name]), () => ( roomId))
8245
8245
  };
8246
8246
  const data = await extractTextMentionNotificationData({ client, event });
8247
8247
  if (data === null) {
@@ -8313,7 +8313,7 @@ async function prepareTextMentionNotificationEmailAsReact(client, event, options
8313
8313
  id: mention.id,
8314
8314
  author: {
8315
8315
  id: mention.userId,
8316
- info: authorInfo ?? { name: mention.userId }
8316
+ info: _nullishCoalesce(authorInfo, () => ( { name: mention.userId }))
8317
8317
  },
8318
8318
  roomId: mention.roomId,
8319
8319
  reactContent,
@@ -8357,7 +8357,7 @@ async function prepareTextMentionNotificationEmailAsHtml(client, event, options
8357
8357
  id: mention.id,
8358
8358
  author: {
8359
8359
  id: mention.userId,
8360
- info: authorInfo ?? { name: mention.userId }
8360
+ info: _nullishCoalesce(authorInfo, () => ( { name: mention.userId }))
8361
8361
  },
8362
8362
  roomId: mention.roomId,
8363
8363
  htmlContent,
@@ -8368,63 +8368,63 @@ async function prepareTextMentionNotificationEmailAsHtml(client, event, options
8368
8368
  }
8369
8369
 
8370
8370
  // src/thread-notification.tsx
8371
- import {
8372
- generateCommentUrl,
8373
- getMentionedIdsFromCommentBody
8374
- } from "@liveblocks/core";
8371
+
8372
+
8373
+
8374
+
8375
8375
 
8376
8376
  // src/comment-body.tsx
8377
- import {
8378
- html as html2,
8379
- htmlSafe as htmlSafe2,
8380
- isCommentBodyLink,
8381
- isCommentBodyMention,
8382
- isCommentBodyText,
8383
- resolveUsersInCommentBody,
8384
- stringifyCommentBody,
8385
- toAbsoluteUrl
8386
- } from "@liveblocks/core";
8387
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
8377
+
8378
+
8379
+
8380
+
8381
+
8382
+
8383
+
8384
+
8385
+
8386
+
8387
+
8388
8388
  var baseComponents2 = {
8389
- Container: ({ children }) => /* @__PURE__ */ jsx2("div", { children }),
8390
- Paragraph: ({ children }) => /* @__PURE__ */ jsx2("p", { children }),
8389
+ Container: ({ children }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children }),
8390
+ Paragraph: ({ children }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children }),
8391
8391
  Text: ({ element }) => {
8392
8392
  let children = element.text;
8393
8393
  if (element.bold) {
8394
- children = /* @__PURE__ */ jsx2("strong", { children });
8394
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children });
8395
8395
  }
8396
8396
  if (element.italic) {
8397
- children = /* @__PURE__ */ jsx2("em", { children });
8397
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "em", { children });
8398
8398
  }
8399
8399
  if (element.strikethrough) {
8400
- children = /* @__PURE__ */ jsx2("s", { children });
8400
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "s", { children });
8401
8401
  }
8402
8402
  if (element.code) {
8403
- children = /* @__PURE__ */ jsx2("code", { children });
8403
+ children = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children });
8404
8404
  }
8405
- return /* @__PURE__ */ jsx2("span", { children });
8405
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children });
8406
8406
  },
8407
- Link: ({ element, href }) => /* @__PURE__ */ jsx2("a", { href, target: "_blank", rel: "noopener noreferrer", children: element.text ?? element.url }),
8408
- Mention: ({ element, user }) => /* @__PURE__ */ jsxs2("span", { "data-mention": true, children: [
8407
+ Link: ({ element, href }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, target: "_blank", rel: "noopener noreferrer", children: _nullishCoalesce(element.text, () => ( element.url)) }),
8408
+ Mention: ({ element, user }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-mention": true, children: [
8409
8409
  MENTION_CHARACTER,
8410
- user?.name ?? element.id
8410
+ _nullishCoalesce(_optionalChain([user, 'optionalAccess', _17 => _17.name]), () => ( element.id))
8411
8411
  ] })
8412
8412
  };
8413
8413
  async function convertCommentBodyAsReact(body, options) {
8414
8414
  const Components = {
8415
8415
  ...baseComponents2,
8416
- ...options?.components
8416
+ ..._optionalChain([options, 'optionalAccess', _18 => _18.components])
8417
8417
  };
8418
- const resolvedUsers = await resolveUsersInCommentBody(
8418
+ const resolvedUsers = await _core.resolveUsersInCommentBody.call(void 0,
8419
8419
  body,
8420
- options?.resolveUsers
8420
+ _optionalChain([options, 'optionalAccess', _19 => _19.resolveUsers])
8421
8421
  );
8422
8422
  const blocks = body.content.map((block, index) => {
8423
8423
  switch (block.type) {
8424
8424
  case "paragraph": {
8425
8425
  const children = block.children.map((inline, inlineIndex) => {
8426
- if (isCommentBodyMention(inline)) {
8427
- return inline.id ? /* @__PURE__ */ jsx2(
8426
+ if (_core.isCommentBodyMention.call(void 0, inline)) {
8427
+ return inline.id ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
8428
8428
  Components.Mention,
8429
8429
  {
8430
8430
  element: inline,
@@ -8433,9 +8433,9 @@ async function convertCommentBodyAsReact(body, options) {
8433
8433
  `lb-comment-body-mention-${inlineIndex}`
8434
8434
  ) : null;
8435
8435
  }
8436
- if (isCommentBodyLink(inline)) {
8437
- const href = toAbsoluteUrl(inline.url) ?? inline.url;
8438
- return /* @__PURE__ */ jsx2(
8436
+ if (_core.isCommentBodyLink.call(void 0, inline)) {
8437
+ const href = _nullishCoalesce(_core.toAbsoluteUrl.call(void 0, inline.url), () => ( inline.url));
8438
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
8439
8439
  Components.Link,
8440
8440
  {
8441
8441
  element: inline,
@@ -8444,8 +8444,8 @@ async function convertCommentBodyAsReact(body, options) {
8444
8444
  `lb-comment-body-link-${inlineIndex}`
8445
8445
  );
8446
8446
  }
8447
- if (isCommentBodyText(inline)) {
8448
- return /* @__PURE__ */ jsx2(
8447
+ if (_core.isCommentBodyText.call(void 0, inline)) {
8448
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
8449
8449
  Components.Text,
8450
8450
  {
8451
8451
  element: inline
@@ -8455,7 +8455,7 @@ async function convertCommentBodyAsReact(body, options) {
8455
8455
  }
8456
8456
  return null;
8457
8457
  });
8458
- return /* @__PURE__ */ jsx2(Components.Paragraph, { children }, `lb-comment-body-paragraph-${index}`);
8458
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Components.Paragraph, { children }, `lb-comment-body-paragraph-${index}`);
8459
8459
  }
8460
8460
  default:
8461
8461
  console.warn(
@@ -8464,7 +8464,7 @@ async function convertCommentBodyAsReact(body, options) {
8464
8464
  return null;
8465
8465
  }
8466
8466
  });
8467
- return /* @__PURE__ */ jsx2(Components.Container, { children: blocks }, "lb-comment-body-container");
8467
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Components.Container, { children: blocks }, "lb-comment-body-container");
8468
8468
  }
8469
8469
  var baseStyles2 = {
8470
8470
  paragraph: {
@@ -8487,40 +8487,40 @@ var baseStyles2 = {
8487
8487
  }
8488
8488
  };
8489
8489
  async function convertCommentBodyAsHtml(body, options) {
8490
- const styles = { ...baseStyles2, ...options?.styles };
8491
- const htmlBody = await stringifyCommentBody(body, {
8490
+ const styles = { ...baseStyles2, ..._optionalChain([options, 'optionalAccess', _20 => _20.styles]) };
8491
+ const htmlBody = await _core.stringifyCommentBody.call(void 0, body, {
8492
8492
  format: "html",
8493
- resolveUsers: options?.resolveUsers,
8493
+ resolveUsers: _optionalChain([options, 'optionalAccess', _21 => _21.resolveUsers]),
8494
8494
  elements: {
8495
8495
  // NOTE: using prettier-ignore to preserve template strings
8496
8496
  paragraph: ({ children }) => (
8497
8497
  // prettier-ignore
8498
- children ? html2`<p style="${toInlineCSSString(styles.paragraph)}">${htmlSafe2(children)}</p>` : children
8498
+ children ? _core.html`<p style="${toInlineCSSString(styles.paragraph)}">${_core.htmlSafe.call(void 0, children)}</p>` : children
8499
8499
  ),
8500
8500
  text: ({ element }) => {
8501
8501
  let children = element.text;
8502
8502
  if (!children) {
8503
- return children;
8503
+ return _core.html`${children}`;
8504
8504
  }
8505
8505
  if (element.bold) {
8506
- children = html2`<strong style="${toInlineCSSString(styles.strong)}">${children}</strong>`;
8506
+ children = _core.html`<strong style="${toInlineCSSString(styles.strong)}">${children}</strong>`;
8507
8507
  }
8508
8508
  if (element.italic) {
8509
- children = html2`<em>${children}</em>`;
8509
+ children = _core.html`<em>${children}</em>`;
8510
8510
  }
8511
8511
  if (element.strikethrough) {
8512
- children = html2`<s>${children}</s>`;
8512
+ children = _core.html`<s>${children}</s>`;
8513
8513
  }
8514
8514
  if (element.code) {
8515
- children = html2`<code style="${toInlineCSSString(styles.code)}">${children}</code>`;
8515
+ children = _core.html`<code style="${toInlineCSSString(styles.code)}">${children}</code>`;
8516
8516
  }
8517
- return children;
8517
+ return _core.html`${children}`;
8518
8518
  },
8519
8519
  link: ({ element, href }) => {
8520
- return html2`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ?? element.url}</a>`;
8520
+ return _core.html`<a href="${href}" target="_blank" rel="noopener noreferrer" style="${toInlineCSSString(styles.link)}">${element.text ? _core.html`${element.text}` : element.url}</a>`;
8521
8521
  },
8522
8522
  mention: ({ element, user }) => {
8523
- return html2`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${user?.name ?? element.id}</span>`;
8523
+ return _core.html`<span data-mention style="${toInlineCSSString(styles.mention)}">${MENTION_CHARACTER}${_optionalChain([user, 'optionalAccess', _22 => _22.name]) ? _core.html`${_optionalChain([user, 'optionalAccess', _23 => _23.name])}` : element.id}</span>`;
8524
8524
  }
8525
8525
  }
8526
8526
  });
@@ -8544,7 +8544,6 @@ function filterCommentsWithBody(comments) {
8544
8544
  // src/thread-notification.tsx
8545
8545
  var getUnreadComments = ({
8546
8546
  comments,
8547
- previousUnreadInboxNotification,
8548
8547
  inboxNotification,
8549
8548
  userId
8550
8549
  }) => {
@@ -8555,9 +8554,6 @@ var getUnreadComments = ({
8555
8554
  if (readAt !== null) {
8556
8555
  return c.createdAt > readAt && c.createdAt <= inboxNotification.notifiedAt;
8557
8556
  }
8558
- if (previousUnreadInboxNotification !== null) {
8559
- return c.createdAt >= previousUnreadInboxNotification.notifiedAt && c.createdAt <= inboxNotification.notifiedAt;
8560
- }
8561
8557
  return c.createdAt <= inboxNotification.notifiedAt;
8562
8558
  });
8563
8559
  };
@@ -8565,27 +8561,22 @@ var getLastUnreadCommentWithMention = ({
8565
8561
  comments,
8566
8562
  mentionedUserId
8567
8563
  }) => {
8568
- return Array.from(comments).reverse().filter((c) => c.userId !== mentionedUserId).find((c) => {
8569
- const mentionedUserIds = getMentionedIdsFromCommentBody(c.body);
8564
+ return _nullishCoalesce(Array.from(comments).reverse().filter((c) => c.userId !== mentionedUserId).find((c) => {
8565
+ const mentionedUserIds = _core.getMentionedIdsFromCommentBody.call(void 0, c.body);
8570
8566
  return mentionedUserIds.includes(mentionedUserId);
8571
- }) ?? null;
8567
+ }), () => ( null));
8572
8568
  };
8573
8569
  var extractThreadNotificationData = async ({
8574
8570
  client,
8575
8571
  event
8576
8572
  }) => {
8577
8573
  const { threadId, roomId, userId, inboxNotificationId } = event.data;
8578
- const [thread, inboxNotification, { data: inboxNotifications }] = await Promise.all([
8574
+ const [thread, inboxNotification] = await Promise.all([
8579
8575
  client.getThread({ roomId, threadId }),
8580
- client.getInboxNotification({ inboxNotificationId, userId }),
8581
- client.getInboxNotifications({ userId, query: { unread: true } })
8576
+ client.getInboxNotification({ inboxNotificationId, userId })
8582
8577
  ]);
8583
- const previousUnreadInboxNotification = inboxNotifications.sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()).filter(
8584
- ({ id: id2, kind }) => kind === "thread" && id2 !== inboxNotification.id
8585
- )[0] ?? null;
8586
8578
  const unreadComments = getUnreadComments({
8587
8579
  comments: thread.comments,
8588
- previousUnreadInboxNotification,
8589
8580
  inboxNotification,
8590
8581
  userId
8591
8582
  });
@@ -8608,8 +8599,8 @@ var makeCommentEmailBaseData = ({
8608
8599
  roomInfo,
8609
8600
  comment
8610
8601
  }) => {
8611
- const url = roomInfo?.url ? generateCommentUrl({
8612
- roomUrl: roomInfo?.url,
8602
+ const url = _optionalChain([roomInfo, 'optionalAccess', _24 => _24.url]) ? _core.generateCommentUrl.call(void 0, {
8603
+ roomUrl: _optionalChain([roomInfo, 'optionalAccess', _25 => _25.url]),
8613
8604
  commentId: comment.id
8614
8605
  }) : void 0;
8615
8606
  return {
@@ -8631,7 +8622,7 @@ var prepareThreadNotificationEmailBaseData = async ({
8631
8622
  const roomInfo = options.resolveRoomInfo ? await options.resolveRoomInfo({ roomId }) : void 0;
8632
8623
  const resolvedRoomInfo = {
8633
8624
  ...roomInfo,
8634
- name: roomInfo?.name ?? roomId
8625
+ name: _nullishCoalesce(_optionalChain([roomInfo, 'optionalAccess', _26 => _26.name]), () => ( roomId))
8635
8626
  };
8636
8627
  const data = await extractThreadNotificationData({ client, event });
8637
8628
  if (data === null) {
@@ -8696,7 +8687,7 @@ async function prepareThreadNotificationEmailAsHtml(client, event, options = {})
8696
8687
  roomId: comment.roomId,
8697
8688
  author: {
8698
8689
  id: comment.userId,
8699
- info: authorInfo ?? { name: comment.userId }
8690
+ info: _nullishCoalesce(authorInfo, () => ( { name: comment.userId }))
8700
8691
  },
8701
8692
  createdAt: comment.createdAt,
8702
8693
  url: comment.url,
@@ -8733,11 +8724,11 @@ async function prepareThreadNotificationEmailAsHtml(client, event, options = {})
8733
8724
  roomId: comment.roomId,
8734
8725
  author: {
8735
8726
  id: comment.userId,
8736
- info: authorInfo ?? { name: comment.userId }
8727
+ info: _nullishCoalesce(authorInfo, () => ( { name: comment.userId }))
8737
8728
  },
8738
8729
  createdAt: comment.createdAt,
8739
8730
  url: comment.url,
8740
- htmlBody: commentBodyHtml ?? ""
8731
+ htmlBody: _nullishCoalesce(commentBodyHtml, () => ( ""))
8741
8732
  };
8742
8733
  }),
8743
8734
  roomInfo: data.roomInfo
@@ -8783,7 +8774,7 @@ async function prepareThreadNotificationEmailAsReact(client, event, options = {}
8783
8774
  roomId: comment.roomId,
8784
8775
  author: {
8785
8776
  id: comment.userId,
8786
- info: authorInfo ?? { name: comment.userId }
8777
+ info: _nullishCoalesce(authorInfo, () => ( { name: comment.userId }))
8787
8778
  },
8788
8779
  createdAt: comment.createdAt,
8789
8780
  url: comment.url,
@@ -8820,11 +8811,11 @@ async function prepareThreadNotificationEmailAsReact(client, event, options = {}
8820
8811
  roomId: comment.roomId,
8821
8812
  author: {
8822
8813
  id: comment.userId,
8823
- info: authorInfo ?? { name: comment.userId }
8814
+ info: _nullishCoalesce(authorInfo, () => ( { name: comment.userId }))
8824
8815
  },
8825
8816
  createdAt: comment.createdAt,
8826
8817
  url: comment.url,
8827
- reactBody: commentBodyReact ?? null
8818
+ reactBody: _nullishCoalesce(commentBodyReact, () => ( null))
8828
8819
  };
8829
8820
  }),
8830
8821
  roomInfo: data.roomInfo
@@ -8834,11 +8825,11 @@ async function prepareThreadNotificationEmailAsReact(client, event, options = {}
8834
8825
  }
8835
8826
 
8836
8827
  // src/index.ts
8837
- detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8838
- export {
8839
- prepareTextMentionNotificationEmailAsHtml,
8840
- prepareTextMentionNotificationEmailAsReact,
8841
- prepareThreadNotificationEmailAsHtml,
8842
- prepareThreadNotificationEmailAsReact
8843
- };
8844
- //# sourceMappingURL=index.mjs.map
8828
+ _core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
8829
+
8830
+
8831
+
8832
+
8833
+
8834
+ exports.prepareTextMentionNotificationEmailAsHtml = prepareTextMentionNotificationEmailAsHtml; exports.prepareTextMentionNotificationEmailAsReact = prepareTextMentionNotificationEmailAsReact; exports.prepareThreadNotificationEmailAsHtml = prepareThreadNotificationEmailAsHtml; exports.prepareThreadNotificationEmailAsReact = prepareThreadNotificationEmailAsReact;
8835
+ //# sourceMappingURL=index.cjs.map