@liveblocks/core 2.3.0 → 2.4.0-test1

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.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.3.0";
9
+ var PKG_VERSION = "2.4.0-test1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -2078,25 +2078,32 @@ function createNotificationsApi({
2078
2078
  }
2079
2079
  return body;
2080
2080
  }
2081
- async function getInboxNotifications(options) {
2082
- const json = await fetchJson("/inbox-notifications", void 0, {
2083
- limit: _optionalChain([options, 'optionalAccess', _46 => _46.limit]),
2084
- since: _optionalChain([options, 'optionalAccess', _47 => _47.since, 'optionalAccess', _48 => _48.toISOString, 'call', _49 => _49()])
2085
- });
2081
+ async function getInboxNotifications() {
2082
+ const json = await fetchJson("/inbox-notifications", void 0, {});
2086
2083
  return {
2087
- threads: json.threads.map((thread) => convertToThreadData(thread)),
2084
+ threads: json.threads.map(convertToThreadData),
2088
2085
  inboxNotifications: json.inboxNotifications.map(
2089
- (notification) => convertToInboxNotificationData(notification)
2090
- ),
2091
- deletedThreads: json.deletedThreads.map(
2092
- (info) => convertToThreadDeleteInfo(info)
2086
+ convertToInboxNotificationData
2093
2087
  ),
2094
- deletedInboxNotifications: json.deletedInboxNotifications.map(
2095
- (info) => convertToInboxNotificationDeleteInfo(info)
2096
- ),
2097
- meta: {
2098
- requestedAt: new Date(json.meta.requestedAt)
2099
- }
2088
+ requestedAt: new Date(json.meta.requestedAt)
2089
+ };
2090
+ }
2091
+ async function getInboxNotificationsSince(options) {
2092
+ const json = await fetchJson("/inbox-notifications", void 0, {
2093
+ since: options.since.toISOString()
2094
+ });
2095
+ return {
2096
+ threads: {
2097
+ modified: json.threads.map(convertToThreadData),
2098
+ deleted: json.deletedThreads.map(convertToThreadDeleteInfo)
2099
+ },
2100
+ inboxNotifications: {
2101
+ modified: json.inboxNotifications.map(convertToInboxNotificationData),
2102
+ deleted: json.deletedInboxNotifications.map(
2103
+ convertToInboxNotificationDeleteInfo
2104
+ )
2105
+ },
2106
+ requestedAt: new Date(json.meta.requestedAt)
2100
2107
  };
2101
2108
  }
2102
2109
  async function getUnreadInboxNotificationsCount() {
@@ -2147,6 +2154,7 @@ function createNotificationsApi({
2147
2154
  }
2148
2155
  return {
2149
2156
  getInboxNotifications,
2157
+ getInboxNotificationsSince,
2150
2158
  getUnreadInboxNotificationsCount,
2151
2159
  markAllInboxNotificationsAsRead,
2152
2160
  markInboxNotificationAsRead,
@@ -2494,14 +2502,10 @@ function isChildCrdt(crdt) {
2494
2502
  }
2495
2503
 
2496
2504
  // src/lib/nanoid.ts
2497
- function nanoid(length = 7) {
2498
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,./;[]~!@#$%&*()_+=-";
2499
- const len = alphabet.length;
2500
- return Array.from(
2501
- { length },
2502
- () => alphabet.charAt(Math.floor(Math.random() * len))
2503
- ).join("");
2504
- }
2505
+ var nanoid = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce(
2506
+ (t2, e) => t2 += (e &= 63) < 36 ? e.toString(36) : e < 62 ? (e - 26).toString(36).toUpperCase() : e < 63 ? "_" : "-",
2507
+ ""
2508
+ );
2505
2509
 
2506
2510
  // src/crdts/LiveRegister.ts
2507
2511
  var LiveRegister = class _LiveRegister extends AbstractCrdt {
@@ -2528,7 +2532,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
2528
2532
  return [
2529
2533
  {
2530
2534
  type: 8 /* CREATE_REGISTER */,
2531
- opId: _optionalChain([pool, 'optionalAccess', _50 => _50.generateOpId, 'call', _51 => _51()]),
2535
+ opId: _optionalChain([pool, 'optionalAccess', _46 => _46.generateOpId, 'call', _47 => _47()]),
2532
2536
  id: this._id,
2533
2537
  parentId,
2534
2538
  parentKey,
@@ -2630,7 +2634,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2630
2634
  const ops = [];
2631
2635
  const op = {
2632
2636
  id: this._id,
2633
- opId: _optionalChain([pool, 'optionalAccess', _52 => _52.generateOpId, 'call', _53 => _53()]),
2637
+ opId: _optionalChain([pool, 'optionalAccess', _48 => _48.generateOpId, 'call', _49 => _49()]),
2634
2638
  type: 2 /* CREATE_LIST */,
2635
2639
  parentId,
2636
2640
  parentKey
@@ -2907,7 +2911,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2907
2911
  _applyInsertUndoRedo(op) {
2908
2912
  const { id, parentKey: key } = op;
2909
2913
  const child = creationOpToLiveNode(op);
2910
- if (_optionalChain([this, 'access', _54 => _54._pool, 'optionalAccess', _55 => _55.getNode, 'call', _56 => _56(id)]) !== void 0) {
2914
+ if (_optionalChain([this, 'access', _50 => _50._pool, 'optionalAccess', _51 => _51.getNode, 'call', _52 => _52(id)]) !== void 0) {
2911
2915
  return { modified: false };
2912
2916
  }
2913
2917
  child._attach(id, nn(this._pool));
@@ -2915,8 +2919,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
2915
2919
  const existingItemIndex = this._indexOfPosition(key);
2916
2920
  let newKey = key;
2917
2921
  if (existingItemIndex !== -1) {
2918
- const before2 = _optionalChain([this, 'access', _57 => _57._items, 'access', _58 => _58[existingItemIndex], 'optionalAccess', _59 => _59._parentPos]);
2919
- const after2 = _optionalChain([this, 'access', _60 => _60._items, 'access', _61 => _61[existingItemIndex + 1], 'optionalAccess', _62 => _62._parentPos]);
2922
+ const before2 = _optionalChain([this, 'access', _53 => _53._items, 'access', _54 => _54[existingItemIndex], 'optionalAccess', _55 => _55._parentPos]);
2923
+ const after2 = _optionalChain([this, 'access', _56 => _56._items, 'access', _57 => _57[existingItemIndex + 1], 'optionalAccess', _58 => _58._parentPos]);
2920
2924
  newKey = makePosition(before2, after2);
2921
2925
  child._setParentLink(this, newKey);
2922
2926
  }
@@ -2931,7 +2935,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2931
2935
  _applySetUndoRedo(op) {
2932
2936
  const { id, parentKey: key } = op;
2933
2937
  const child = creationOpToLiveNode(op);
2934
- if (_optionalChain([this, 'access', _63 => _63._pool, 'optionalAccess', _64 => _64.getNode, 'call', _65 => _65(id)]) !== void 0) {
2938
+ if (_optionalChain([this, 'access', _59 => _59._pool, 'optionalAccess', _60 => _60.getNode, 'call', _61 => _61(id)]) !== void 0) {
2935
2939
  return { modified: false };
2936
2940
  }
2937
2941
  this._unacknowledgedSets.set(key, nn(op.opId));
@@ -3053,7 +3057,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3053
3057
  } else {
3054
3058
  this._items[existingItemIndex]._setParentLink(
3055
3059
  this,
3056
- makePosition(newKey, _optionalChain([this, 'access', _66 => _66._items, 'access', _67 => _67[existingItemIndex + 1], 'optionalAccess', _68 => _68._parentPos]))
3060
+ makePosition(newKey, _optionalChain([this, 'access', _62 => _62._items, 'access', _63 => _63[existingItemIndex + 1], 'optionalAccess', _64 => _64._parentPos]))
3057
3061
  );
3058
3062
  const previousIndex = this._items.indexOf(child);
3059
3063
  child._setParentLink(this, newKey);
@@ -3079,7 +3083,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3079
3083
  if (existingItemIndex !== -1) {
3080
3084
  this._items[existingItemIndex]._setParentLink(
3081
3085
  this,
3082
- makePosition(newKey, _optionalChain([this, 'access', _69 => _69._items, 'access', _70 => _70[existingItemIndex + 1], 'optionalAccess', _71 => _71._parentPos]))
3086
+ makePosition(newKey, _optionalChain([this, 'access', _65 => _65._items, 'access', _66 => _66[existingItemIndex + 1], 'optionalAccess', _67 => _67._parentPos]))
3083
3087
  );
3084
3088
  }
3085
3089
  child._setParentLink(this, newKey);
@@ -3098,7 +3102,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3098
3102
  if (existingItemIndex !== -1) {
3099
3103
  this._items[existingItemIndex]._setParentLink(
3100
3104
  this,
3101
- makePosition(newKey, _optionalChain([this, 'access', _72 => _72._items, 'access', _73 => _73[existingItemIndex + 1], 'optionalAccess', _74 => _74._parentPos]))
3105
+ makePosition(newKey, _optionalChain([this, 'access', _68 => _68._items, 'access', _69 => _69[existingItemIndex + 1], 'optionalAccess', _70 => _70._parentPos]))
3102
3106
  );
3103
3107
  }
3104
3108
  child._setParentLink(this, newKey);
@@ -3126,7 +3130,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3126
3130
  if (existingItemIndex !== -1) {
3127
3131
  this._items[existingItemIndex]._setParentLink(
3128
3132
  this,
3129
- makePosition(newKey, _optionalChain([this, 'access', _75 => _75._items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]))
3133
+ makePosition(newKey, _optionalChain([this, 'access', _71 => _71._items, 'access', _72 => _72[existingItemIndex + 1], 'optionalAccess', _73 => _73._parentPos]))
3130
3134
  );
3131
3135
  }
3132
3136
  child._setParentLink(this, newKey);
@@ -3184,7 +3188,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3184
3188
  * @param element The element to add to the end of the LiveList.
3185
3189
  */
3186
3190
  push(element) {
3187
- _optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.assertStorageIsWritable, 'call', _80 => _80()]);
3191
+ _optionalChain([this, 'access', _74 => _74._pool, 'optionalAccess', _75 => _75.assertStorageIsWritable, 'call', _76 => _76()]);
3188
3192
  return this.insert(element, this.length);
3189
3193
  }
3190
3194
  /**
@@ -3193,7 +3197,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3193
3197
  * @param index The index at which you want to insert the element.
3194
3198
  */
3195
3199
  insert(element, index) {
3196
- _optionalChain([this, 'access', _81 => _81._pool, 'optionalAccess', _82 => _82.assertStorageIsWritable, 'call', _83 => _83()]);
3200
+ _optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.assertStorageIsWritable, 'call', _79 => _79()]);
3197
3201
  if (index < 0 || index > this._items.length) {
3198
3202
  throw new Error(
3199
3203
  `Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
@@ -3223,7 +3227,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3223
3227
  * @param targetIndex The index where the element should be after moving.
3224
3228
  */
3225
3229
  move(index, targetIndex) {
3226
- _optionalChain([this, 'access', _84 => _84._pool, 'optionalAccess', _85 => _85.assertStorageIsWritable, 'call', _86 => _86()]);
3230
+ _optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
3227
3231
  if (targetIndex < 0) {
3228
3232
  throw new Error("targetIndex cannot be less than 0");
3229
3233
  }
@@ -3281,7 +3285,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3281
3285
  * @param index The index of the element to delete
3282
3286
  */
3283
3287
  delete(index) {
3284
- _optionalChain([this, 'access', _87 => _87._pool, 'optionalAccess', _88 => _88.assertStorageIsWritable, 'call', _89 => _89()]);
3288
+ _optionalChain([this, 'access', _83 => _83._pool, 'optionalAccess', _84 => _84.assertStorageIsWritable, 'call', _85 => _85()]);
3285
3289
  if (index < 0 || index >= this._items.length) {
3286
3290
  throw new Error(
3287
3291
  `Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
@@ -3314,7 +3318,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3314
3318
  }
3315
3319
  }
3316
3320
  clear() {
3317
- _optionalChain([this, 'access', _90 => _90._pool, 'optionalAccess', _91 => _91.assertStorageIsWritable, 'call', _92 => _92()]);
3321
+ _optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
3318
3322
  if (this._pool) {
3319
3323
  const ops = [];
3320
3324
  const reverseOps = [];
@@ -3348,7 +3352,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3348
3352
  }
3349
3353
  }
3350
3354
  set(index, item) {
3351
- _optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
3355
+ _optionalChain([this, 'access', _89 => _89._pool, 'optionalAccess', _90 => _90.assertStorageIsWritable, 'call', _91 => _91()]);
3352
3356
  if (index < 0 || index >= this._items.length) {
3353
3357
  throw new Error(
3354
3358
  `Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
@@ -3496,7 +3500,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3496
3500
  _shiftItemPosition(index, key) {
3497
3501
  const shiftedPosition = makePosition(
3498
3502
  key,
3499
- this._items.length > index + 1 ? _optionalChain([this, 'access', _96 => _96._items, 'access', _97 => _97[index + 1], 'optionalAccess', _98 => _98._parentPos]) : void 0
3503
+ this._items.length > index + 1 ? _optionalChain([this, 'access', _92 => _92._items, 'access', _93 => _93[index + 1], 'optionalAccess', _94 => _94._parentPos]) : void 0
3500
3504
  );
3501
3505
  this._items[index]._setParentLink(this, shiftedPosition);
3502
3506
  }
@@ -3625,7 +3629,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3625
3629
  const ops = [];
3626
3630
  const op = {
3627
3631
  id: this._id,
3628
- opId: _optionalChain([pool, 'optionalAccess', _99 => _99.generateOpId, 'call', _100 => _100()]),
3632
+ opId: _optionalChain([pool, 'optionalAccess', _95 => _95.generateOpId, 'call', _96 => _96()]),
3629
3633
  type: 7 /* CREATE_MAP */,
3630
3634
  parentId,
3631
3635
  parentKey
@@ -3772,7 +3776,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3772
3776
  * @param value The value of the element to add. Should be serializable to JSON.
3773
3777
  */
3774
3778
  set(key, value) {
3775
- _optionalChain([this, 'access', _101 => _101._pool, 'optionalAccess', _102 => _102.assertStorageIsWritable, 'call', _103 => _103()]);
3779
+ _optionalChain([this, 'access', _97 => _97._pool, 'optionalAccess', _98 => _98.assertStorageIsWritable, 'call', _99 => _99()]);
3776
3780
  const oldValue = this._map.get(key);
3777
3781
  if (oldValue) {
3778
3782
  oldValue._detach();
@@ -3818,7 +3822,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3818
3822
  * @returns true if an element existed and has been removed, or false if the element does not exist.
3819
3823
  */
3820
3824
  delete(key) {
3821
- _optionalChain([this, 'access', _104 => _104._pool, 'optionalAccess', _105 => _105.assertStorageIsWritable, 'call', _106 => _106()]);
3825
+ _optionalChain([this, 'access', _100 => _100._pool, 'optionalAccess', _101 => _101.assertStorageIsWritable, 'call', _102 => _102()]);
3822
3826
  const item = this._map.get(key);
3823
3827
  if (item === void 0) {
3824
3828
  return false;
@@ -3996,7 +4000,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
3996
4000
  if (this._id === void 0) {
3997
4001
  throw new Error("Cannot serialize item is not attached");
3998
4002
  }
3999
- const opId = _optionalChain([pool, 'optionalAccess', _107 => _107.generateOpId, 'call', _108 => _108()]);
4003
+ const opId = _optionalChain([pool, 'optionalAccess', _103 => _103.generateOpId, 'call', _104 => _104()]);
4000
4004
  const ops = [];
4001
4005
  const op = {
4002
4006
  type: 4 /* CREATE_OBJECT */,
@@ -4274,7 +4278,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4274
4278
  * @param value The value of the property to add
4275
4279
  */
4276
4280
  set(key, value) {
4277
- _optionalChain([this, 'access', _109 => _109._pool, 'optionalAccess', _110 => _110.assertStorageIsWritable, 'call', _111 => _111()]);
4281
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4278
4282
  this.update({ [key]: value });
4279
4283
  }
4280
4284
  /**
@@ -4289,7 +4293,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4289
4293
  * @param key The key of the property to delete
4290
4294
  */
4291
4295
  delete(key) {
4292
- _optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.assertStorageIsWritable, 'call', _114 => _114()]);
4296
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4293
4297
  const keyAsString = key;
4294
4298
  const oldValue = this._map.get(keyAsString);
4295
4299
  if (oldValue === void 0) {
@@ -4342,7 +4346,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4342
4346
  * @param patch The object used to overrides properties
4343
4347
  */
4344
4348
  update(patch) {
4345
- _optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
4349
+ _optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
4346
4350
  if (this._pool === void 0 || this._id === void 0) {
4347
4351
  for (const key in patch) {
4348
4352
  const newValue = patch[key];
@@ -4715,6 +4719,23 @@ function findNonSerializableValue(value, path = "") {
4715
4719
  return false;
4716
4720
  }
4717
4721
 
4722
+ // src/lib/createIds.ts
4723
+ var THREAD_ID_PREFIX = "th";
4724
+ var COMMENT_ID_PREFIX = "cm";
4725
+ var INBOX_NOTIFICATION_ID_PREFIX = "in";
4726
+ function createOptimisticId(prefix) {
4727
+ return `${prefix}_${nanoid()}`;
4728
+ }
4729
+ function createThreadId() {
4730
+ return createOptimisticId(THREAD_ID_PREFIX);
4731
+ }
4732
+ function createCommentId() {
4733
+ return createOptimisticId(COMMENT_ID_PREFIX);
4734
+ }
4735
+ function createInboxNotificationId() {
4736
+ return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
4737
+ }
4738
+
4718
4739
  // src/lib/debug.ts
4719
4740
  function captureStackTrace(msg, traceRoot) {
4720
4741
  const errorLike = { name: msg };
@@ -5101,15 +5122,15 @@ function installBackgroundTabSpy() {
5101
5122
  const doc = typeof document !== "undefined" ? document : void 0;
5102
5123
  const inBackgroundSince = { current: null };
5103
5124
  function onVisibilityChange() {
5104
- if (_optionalChain([doc, 'optionalAccess', _118 => _118.visibilityState]) === "hidden") {
5125
+ if (_optionalChain([doc, 'optionalAccess', _114 => _114.visibilityState]) === "hidden") {
5105
5126
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
5106
5127
  } else {
5107
5128
  inBackgroundSince.current = null;
5108
5129
  }
5109
5130
  }
5110
- _optionalChain([doc, 'optionalAccess', _119 => _119.addEventListener, 'call', _120 => _120("visibilitychange", onVisibilityChange)]);
5131
+ _optionalChain([doc, 'optionalAccess', _115 => _115.addEventListener, 'call', _116 => _116("visibilitychange", onVisibilityChange)]);
5111
5132
  const unsub = () => {
5112
- _optionalChain([doc, 'optionalAccess', _121 => _121.removeEventListener, 'call', _122 => _122("visibilitychange", onVisibilityChange)]);
5133
+ _optionalChain([doc, 'optionalAccess', _117 => _117.removeEventListener, 'call', _118 => _118("visibilitychange", onVisibilityChange)]);
5113
5134
  };
5114
5135
  return [inBackgroundSince, unsub];
5115
5136
  }
@@ -5152,15 +5173,57 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5152
5173
  }
5153
5174
  return body;
5154
5175
  }
5176
+ async function getThreadsSince(options) {
5177
+ const response = await fetchCommentsApi(
5178
+ "/threads",
5179
+ {
5180
+ since: _optionalChain([options, 'optionalAccess', _119 => _119.since, 'optionalAccess', _120 => _120.toISOString, 'call', _121 => _121()])
5181
+ },
5182
+ {
5183
+ headers: {
5184
+ "Content-Type": "application/json"
5185
+ }
5186
+ }
5187
+ );
5188
+ if (response.ok) {
5189
+ const json = await response.json();
5190
+ return {
5191
+ threads: {
5192
+ modified: json.data.map(convertToThreadData),
5193
+ deleted: json.deletedThreads.map(convertToThreadDeleteInfo)
5194
+ },
5195
+ inboxNotifications: {
5196
+ modified: json.inboxNotifications.map(convertToInboxNotificationData),
5197
+ deleted: json.deletedInboxNotifications.map(
5198
+ convertToInboxNotificationDeleteInfo
5199
+ )
5200
+ },
5201
+ requestedAt: new Date(json.meta.requestedAt)
5202
+ };
5203
+ } else if (response.status === 404) {
5204
+ return {
5205
+ threads: {
5206
+ modified: [],
5207
+ deleted: []
5208
+ },
5209
+ inboxNotifications: {
5210
+ modified: [],
5211
+ deleted: []
5212
+ },
5213
+ requestedAt: /* @__PURE__ */ new Date()
5214
+ };
5215
+ } else {
5216
+ throw new Error("There was an error while getting threads.");
5217
+ }
5218
+ }
5155
5219
  async function getThreads(options) {
5156
5220
  let query;
5157
- if (_optionalChain([options, 'optionalAccess', _123 => _123.query])) {
5221
+ if (_optionalChain([options, 'optionalAccess', _122 => _122.query])) {
5158
5222
  query = objectToQuery(options.query);
5159
5223
  }
5160
5224
  const response = await fetchCommentsApi(
5161
5225
  "/threads",
5162
5226
  {
5163
- since: _optionalChain([options, 'optionalAccess', _124 => _124.since, 'optionalAccess', _125 => _125.toISOString, 'call', _126 => _126()]),
5164
5227
  query
5165
5228
  },
5166
5229
  {
@@ -5172,19 +5235,11 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5172
5235
  if (response.ok) {
5173
5236
  const json = await response.json();
5174
5237
  return {
5175
- threads: json.data.map((thread) => convertToThreadData(thread)),
5238
+ threads: json.data.map(convertToThreadData),
5176
5239
  inboxNotifications: json.inboxNotifications.map(
5177
- (notification) => convertToInboxNotificationData(notification)
5178
- ),
5179
- deletedThreads: json.deletedThreads.map(
5180
- (info) => convertToThreadDeleteInfo(info)
5240
+ convertToInboxNotificationData
5181
5241
  ),
5182
- deletedInboxNotifications: json.deletedInboxNotifications.map(
5183
- (info) => convertToInboxNotificationDeleteInfo(info)
5184
- ),
5185
- meta: {
5186
- requestedAt: new Date(json.meta.requestedAt)
5187
- }
5242
+ requestedAt: new Date(json.meta.requestedAt)
5188
5243
  };
5189
5244
  } else if (response.status === 404) {
5190
5245
  return {
@@ -5192,15 +5247,13 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5192
5247
  inboxNotifications: [],
5193
5248
  deletedThreads: [],
5194
5249
  deletedInboxNotifications: [],
5195
- meta: {
5196
- requestedAt: /* @__PURE__ */ new Date()
5197
- }
5250
+ requestedAt: /* @__PURE__ */ new Date()
5198
5251
  };
5199
5252
  } else {
5200
5253
  throw new Error("There was an error while getting threads.");
5201
5254
  }
5202
5255
  }
5203
- async function getThread({ threadId }) {
5256
+ async function getThread(threadId) {
5204
5257
  const response = await fetchCommentsApi(
5205
5258
  `/thread-with-notification/${threadId}`
5206
5259
  );
@@ -5211,7 +5264,10 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5211
5264
  inboxNotification: json.inboxNotification ? convertToInboxNotificationData(json.inboxNotification) : void 0
5212
5265
  };
5213
5266
  } else if (response.status === 404) {
5214
- return;
5267
+ return {
5268
+ thread: void 0,
5269
+ inboxNotification: void 0
5270
+ };
5215
5271
  } else {
5216
5272
  throw new Error(`There was an error while getting thread ${threadId}.`);
5217
5273
  }
@@ -5219,8 +5275,8 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5219
5275
  async function createThread({
5220
5276
  metadata,
5221
5277
  body,
5222
- commentId,
5223
- threadId
5278
+ commentId = createCommentId(),
5279
+ threadId = createThreadId()
5224
5280
  }) {
5225
5281
  const thread = await fetchJson("/threads", {
5226
5282
  method: "POST",
@@ -5238,7 +5294,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5238
5294
  });
5239
5295
  return convertToThreadData(thread);
5240
5296
  }
5241
- async function deleteThread({ threadId }) {
5297
+ async function deleteThread(threadId) {
5242
5298
  await fetchJson(`/threads/${encodeURIComponent(threadId)}`, {
5243
5299
  method: "DELETE"
5244
5300
  });
@@ -5258,7 +5314,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5258
5314
  }
5259
5315
  );
5260
5316
  }
5261
- async function markThreadAsResolved({ threadId }) {
5317
+ async function markThreadAsResolved(threadId) {
5262
5318
  await fetchJson(
5263
5319
  `/threads/${encodeURIComponent(threadId)}/mark-as-resolved`,
5264
5320
  {
@@ -5266,7 +5322,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5266
5322
  }
5267
5323
  );
5268
5324
  }
5269
- async function markThreadAsUnresolved({ threadId }) {
5325
+ async function markThreadAsUnresolved(threadId) {
5270
5326
  await fetchJson(
5271
5327
  `/threads/${encodeURIComponent(threadId)}/mark-as-unresolved`,
5272
5328
  {
@@ -5276,7 +5332,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5276
5332
  }
5277
5333
  async function createComment({
5278
5334
  threadId,
5279
- commentId,
5335
+ commentId = createCommentId(),
5280
5336
  body
5281
5337
  }) {
5282
5338
  const comment = await fetchJson(
@@ -5363,6 +5419,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5363
5419
  }
5364
5420
  return {
5365
5421
  getThreads,
5422
+ getThreadsSince,
5366
5423
  getThread,
5367
5424
  createThread,
5368
5425
  deleteThread,
@@ -5564,7 +5621,7 @@ function createRoom(options, config) {
5564
5621
  }
5565
5622
  },
5566
5623
  assertStorageIsWritable: () => {
5567
- const scopes = _optionalChain([context, 'access', _127 => _127.dynamicSessionInfo, 'access', _128 => _128.current, 'optionalAccess', _129 => _129.scopes]);
5624
+ const scopes = _optionalChain([context, 'access', _123 => _123.dynamicSessionInfo, 'access', _124 => _124.current, 'optionalAccess', _125 => _125.scopes]);
5568
5625
  if (scopes === void 0) {
5569
5626
  return;
5570
5627
  }
@@ -5598,12 +5655,12 @@ function createRoom(options, config) {
5598
5655
  `/v2/c/rooms/${encodeURIComponent(roomId)}${endpoint}`,
5599
5656
  params
5600
5657
  );
5601
- const fetcher = _optionalChain([config, 'access', _130 => _130.polyfills, 'optionalAccess', _131 => _131.fetch]) || /* istanbul ignore next */
5658
+ const fetcher = _optionalChain([config, 'access', _126 => _126.polyfills, 'optionalAccess', _127 => _127.fetch]) || /* istanbul ignore next */
5602
5659
  fetch;
5603
5660
  return await fetcher(url, {
5604
5661
  ...options2,
5605
5662
  headers: {
5606
- ..._optionalChain([options2, 'optionalAccess', _132 => _132.headers]),
5663
+ ..._optionalChain([options2, 'optionalAccess', _128 => _128.headers]),
5607
5664
  Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
5608
5665
  }
5609
5666
  });
@@ -5676,7 +5733,7 @@ function createRoom(options, config) {
5676
5733
  }
5677
5734
  function sendMessages(messages) {
5678
5735
  const serializedPayload = JSON.stringify(messages);
5679
- const nonce = _optionalChain([context, 'access', _133 => _133.dynamicSessionInfo, 'access', _134 => _134.current, 'optionalAccess', _135 => _135.nonce]);
5736
+ const nonce = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.nonce]);
5680
5737
  if (config.unstable_fallbackToHTTP && nonce) {
5681
5738
  const size = new TextEncoder().encode(serializedPayload).length;
5682
5739
  if (size > MAX_SOCKET_MESSAGE_SIZE) {
@@ -5738,7 +5795,7 @@ function createRoom(options, config) {
5738
5795
  } else {
5739
5796
  context.root = LiveObject._fromItems(message.items, pool);
5740
5797
  }
5741
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.canWrite]), () => ( true));
5798
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _132 => _132.current, 'optionalAccess', _133 => _133.canWrite]), () => ( true));
5742
5799
  const stackSizeBefore = context.undoStack.length;
5743
5800
  for (const key in context.initialStorage) {
5744
5801
  if (context.root.get(key) === void 0) {
@@ -5943,7 +6000,7 @@ function createRoom(options, config) {
5943
6000
  }
5944
6001
  context.myPresence.patch(patch);
5945
6002
  if (context.activeBatch) {
5946
- if (_optionalChain([options2, 'optionalAccess', _138 => _138.addToHistory])) {
6003
+ if (_optionalChain([options2, 'optionalAccess', _134 => _134.addToHistory])) {
5947
6004
  context.activeBatch.reverseOps.unshift({
5948
6005
  type: "presence",
5949
6006
  data: oldValues
@@ -5953,7 +6010,7 @@ function createRoom(options, config) {
5953
6010
  } else {
5954
6011
  flushNowOrSoon();
5955
6012
  batchUpdates(() => {
5956
- if (_optionalChain([options2, 'optionalAccess', _139 => _139.addToHistory])) {
6013
+ if (_optionalChain([options2, 'optionalAccess', _135 => _135.addToHistory])) {
5957
6014
  addToUndoStack(
5958
6015
  [{ type: "presence", data: oldValues }],
5959
6016
  doNotBatchUpdates
@@ -6151,7 +6208,7 @@ function createRoom(options, config) {
6151
6208
  if (process.env.NODE_ENV !== "production") {
6152
6209
  const traces = /* @__PURE__ */ new Set();
6153
6210
  for (const opId of message.opIds) {
6154
- const trace = _optionalChain([context, 'access', _140 => _140.opStackTraces, 'optionalAccess', _141 => _141.get, 'call', _142 => _142(opId)]);
6211
+ const trace = _optionalChain([context, 'access', _136 => _136.opStackTraces, 'optionalAccess', _137 => _137.get, 'call', _138 => _138(opId)]);
6155
6212
  if (trace) {
6156
6213
  traces.add(trace);
6157
6214
  }
@@ -6285,7 +6342,7 @@ ${Array.from(traces).join("\n\n")}`
6285
6342
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
6286
6343
  createOrUpdateRootFromMessage(message, doNotBatchUpdates);
6287
6344
  applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
6288
- _optionalChain([_resolveStoragePromise, 'optionalCall', _143 => _143()]);
6345
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _139 => _139()]);
6289
6346
  notifyStorageStatus();
6290
6347
  eventHub.storageDidLoad.notify();
6291
6348
  }
@@ -6542,12 +6599,12 @@ ${Array.from(traces).join("\n\n")}`
6542
6599
  }
6543
6600
  return body;
6544
6601
  }
6545
- function getRoomNotificationSettings() {
6602
+ function getNotificationSettings() {
6546
6603
  return fetchNotificationsJson(
6547
6604
  "/notification-settings"
6548
6605
  );
6549
6606
  }
6550
- function updateRoomNotificationSettings(settings) {
6607
+ function updateNotificationSettings(settings) {
6551
6608
  return fetchNotificationsJson(
6552
6609
  "/notification-settings",
6553
6610
  {
@@ -6583,7 +6640,7 @@ ${Array.from(traces).join("\n\n")}`
6583
6640
  {
6584
6641
  [kInternal]: {
6585
6642
  get presenceBuffer() {
6586
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _144 => _144.buffer, 'access', _145 => _145.presenceUpdates, 'optionalAccess', _146 => _146.data]), () => ( null)));
6643
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _140 => _140.buffer, 'access', _141 => _141.presenceUpdates, 'optionalAccess', _142 => _142.data]), () => ( null)));
6587
6644
  },
6588
6645
  // prettier-ignore
6589
6646
  get undoStack() {
@@ -6608,14 +6665,6 @@ ${Array.from(traces).join("\n\n")}`
6608
6665
  // These exist only for our E2E testing app
6609
6666
  explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
6610
6667
  rawSend: (data) => managedSocket.send(data)
6611
- },
6612
- comments: {
6613
- ...commentsApi
6614
- },
6615
- notifications: {
6616
- getRoomNotificationSettings,
6617
- updateRoomNotificationSettings,
6618
- markInboxNotificationAsRead
6619
6668
  }
6620
6669
  },
6621
6670
  id: config.roomId,
@@ -6656,7 +6705,11 @@ ${Array.from(traces).join("\n\n")}`
6656
6705
  getSelf: () => self.current,
6657
6706
  // Presence
6658
6707
  getPresence: () => context.myPresence.current,
6659
- getOthers: () => context.others.current
6708
+ getOthers: () => context.others.current,
6709
+ getNotificationSettings,
6710
+ updateNotificationSettings,
6711
+ markInboxNotificationAsRead,
6712
+ ...commentsApi
6660
6713
  },
6661
6714
  // Explictly make the internal field non-enumerable, to avoid aggressive
6662
6715
  // freezing when used with Immer
@@ -6718,6 +6771,10 @@ function makeClassicSubscribeFn(events) {
6718
6771
  return events.storageStatus.subscribe(
6719
6772
  callback
6720
6773
  );
6774
+ case "comments":
6775
+ return events.comments.subscribe(
6776
+ callback
6777
+ );
6721
6778
  default:
6722
6779
  return assertNever(
6723
6780
  first,
@@ -6735,7 +6792,7 @@ function makeClassicSubscribeFn(events) {
6735
6792
  }
6736
6793
  if (isLiveNode(first)) {
6737
6794
  const node = first;
6738
- if (_optionalChain([options, 'optionalAccess', _147 => _147.isDeep])) {
6795
+ if (_optionalChain([options, 'optionalAccess', _143 => _143.isDeep])) {
6739
6796
  const storageCallback = second;
6740
6797
  return subscribeToLiveStructureDeeply(node, storageCallback);
6741
6798
  } else {
@@ -6750,7 +6807,7 @@ function makeClassicSubscribeFn(events) {
6750
6807
  return subscribe;
6751
6808
  }
6752
6809
  function isRoomEventName(value) {
6753
- return value === "my-presence" || value === "others" || value === "event" || value === "error" || value === "history" || value === "status" || value === "storage-status" || value === "lost-connection" || value === "connection";
6810
+ return value === "my-presence" || value === "others" || value === "event" || value === "error" || value === "history" || value === "status" || value === "storage-status" || value === "lost-connection" || value === "connection" || value === "comments";
6754
6811
  }
6755
6812
  function makeAuthDelegateForRoom(roomId, authManager) {
6756
6813
  return async () => {
@@ -7145,7 +7202,7 @@ function upsertComment(thread, comment) {
7145
7202
  );
7146
7203
  if (existingComment === void 0) {
7147
7204
  const updatedAt = new Date(
7148
- Math.max(_optionalChain([thread, 'access', _148 => _148.updatedAt, 'optionalAccess', _149 => _149.getTime, 'call', _150 => _150()]) || 0, comment.createdAt.getTime())
7205
+ Math.max(_optionalChain([thread, 'access', _144 => _144.updatedAt, 'optionalAccess', _145 => _145.getTime, 'call', _146 => _146()]) || 0, comment.createdAt.getTime())
7149
7206
  );
7150
7207
  const updatedThread = {
7151
7208
  ...thread,
@@ -7165,8 +7222,8 @@ function upsertComment(thread, comment) {
7165
7222
  ...thread,
7166
7223
  updatedAt: new Date(
7167
7224
  Math.max(
7168
- _optionalChain([thread, 'access', _151 => _151.updatedAt, 'optionalAccess', _152 => _152.getTime, 'call', _153 => _153()]) || 0,
7169
- _optionalChain([comment, 'access', _154 => _154.editedAt, 'optionalAccess', _155 => _155.getTime, 'call', _156 => _156()]) || comment.createdAt.getTime()
7225
+ _optionalChain([thread, 'access', _147 => _147.updatedAt, 'optionalAccess', _148 => _148.getTime, 'call', _149 => _149()]) || 0,
7226
+ _optionalChain([comment, 'access', _150 => _150.editedAt, 'optionalAccess', _151 => _151.getTime, 'call', _152 => _152()]) || comment.createdAt.getTime()
7170
7227
  )
7171
7228
  ),
7172
7229
  comments: updatedComments
@@ -7231,7 +7288,7 @@ function addReaction(thread, commentId, reaction) {
7231
7288
  return {
7232
7289
  ...thread,
7233
7290
  updatedAt: new Date(
7234
- Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _157 => _157.updatedAt, 'optionalAccess', _158 => _158.getTime, 'call', _159 => _159()]) || 0)
7291
+ Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0)
7235
7292
  ),
7236
7293
  comments: updatedComments
7237
7294
  };
@@ -7264,7 +7321,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
7264
7321
  return {
7265
7322
  ...thread,
7266
7323
  updatedAt: new Date(
7267
- Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _160 => _160.updatedAt, 'optionalAccess', _161 => _161.getTime, 'call', _162 => _162()]) || 0)
7324
+ Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _156 => _156.updatedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 0)
7268
7325
  ),
7269
7326
  comments: updatedComments
7270
7327
  };
@@ -7375,12 +7432,12 @@ function createClient(options) {
7375
7432
  createSocket: makeCreateSocketDelegateForRoom(
7376
7433
  roomId,
7377
7434
  baseUrl,
7378
- _optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
7435
+ _optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.WebSocket])
7379
7436
  ),
7380
7437
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7381
7438
  })),
7382
7439
  enableDebugLogging: clientOptions.enableDebugLogging,
7383
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
7440
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _161 => _161.unstable_batchedUpdates]),
7384
7441
  baseUrl,
7385
7442
  unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7386
7443
  unstable_streamData: !!clientOptions.unstable_streamData
@@ -7396,7 +7453,7 @@ function createClient(options) {
7396
7453
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7397
7454
  if (shouldConnect) {
7398
7455
  if (typeof atob === "undefined") {
7399
- if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
7456
+ if (_optionalChain([clientOptions, 'access', _162 => _162.polyfills, 'optionalAccess', _163 => _163.atob]) === void 0) {
7400
7457
  throw new Error(
7401
7458
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
7402
7459
  );
@@ -7408,7 +7465,7 @@ function createClient(options) {
7408
7465
  return leaseRoom(newRoomDetails);
7409
7466
  }
7410
7467
  function getRoom(roomId) {
7411
- const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
7468
+ const room = _optionalChain([roomsById, 'access', _164 => _164.get, 'call', _165 => _165(roomId), 'optionalAccess', _166 => _166.room]);
7412
7469
  return room ? room : null;
7413
7470
  }
7414
7471
  function logout() {
@@ -7422,6 +7479,7 @@ function createClient(options) {
7422
7479
  const currentUserIdStore = createStore(null);
7423
7480
  const {
7424
7481
  getInboxNotifications,
7482
+ getInboxNotificationsSince,
7425
7483
  getUnreadInboxNotificationsCount,
7426
7484
  markAllInboxNotificationsAsRead,
7427
7485
  markInboxNotificationAsRead,
@@ -7429,7 +7487,7 @@ function createClient(options) {
7429
7487
  deleteInboxNotification
7430
7488
  } = createNotificationsApi({
7431
7489
  baseUrl,
7432
- fetcher: _optionalChain([clientOptions, 'access', _171 => _171.polyfills, 'optionalAccess', _172 => _172.fetch]) || /* istanbul ignore next */
7490
+ fetcher: _optionalChain([clientOptions, 'access', _167 => _167.polyfills, 'optionalAccess', _168 => _168.fetch]) || /* istanbul ignore next */
7433
7491
  fetch,
7434
7492
  authManager,
7435
7493
  currentUserIdStore
@@ -7443,7 +7501,7 @@ function createClient(options) {
7443
7501
  const usersStore = createBatchStore(
7444
7502
  async (batchedUserIds) => {
7445
7503
  const userIds = batchedUserIds.flat();
7446
- const users = await _optionalChain([resolveUsers, 'optionalCall', _173 => _173({ userIds })]);
7504
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
7447
7505
  warnIfNoResolveUsers();
7448
7506
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7449
7507
  },
@@ -7457,7 +7515,7 @@ function createClient(options) {
7457
7515
  const roomsInfoStore = createBatchStore(
7458
7516
  async (batchedRoomIds) => {
7459
7517
  const roomIds = batchedRoomIds.flat();
7460
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _174 => _174({ roomIds })]);
7518
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
7461
7519
  warnIfNoResolveRoomsInfo();
7462
7520
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
7463
7521
  },
@@ -7468,16 +7526,15 @@ function createClient(options) {
7468
7526
  enterRoom,
7469
7527
  getRoom,
7470
7528
  logout,
7529
+ getInboxNotifications,
7530
+ getInboxNotificationsSince,
7531
+ getUnreadInboxNotificationsCount,
7532
+ markAllInboxNotificationsAsRead,
7533
+ markInboxNotificationAsRead,
7534
+ deleteAllInboxNotifications,
7535
+ deleteInboxNotification,
7471
7536
  // Internal
7472
7537
  [kInternal]: {
7473
- notifications: {
7474
- getInboxNotifications,
7475
- getUnreadInboxNotificationsCount,
7476
- markAllInboxNotificationsAsRead,
7477
- markInboxNotificationAsRead,
7478
- deleteAllInboxNotifications,
7479
- deleteInboxNotification
7480
- },
7481
7538
  currentUserIdStore,
7482
7539
  resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
7483
7540
  cacheStore,
@@ -7571,7 +7628,7 @@ var commentBodyElementsTypes = {
7571
7628
  mention: "inline"
7572
7629
  };
7573
7630
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7574
- if (!body || !_optionalChain([body, 'optionalAccess', _175 => _175.content])) {
7631
+ if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
7575
7632
  return;
7576
7633
  }
7577
7634
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -7581,13 +7638,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7581
7638
  for (const block of body.content) {
7582
7639
  if (type === "all" || type === "block") {
7583
7640
  if (guard(block)) {
7584
- _optionalChain([visitor, 'optionalCall', _176 => _176(block)]);
7641
+ _optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
7585
7642
  }
7586
7643
  }
7587
7644
  if (type === "all" || type === "inline") {
7588
7645
  for (const inline of block.children) {
7589
7646
  if (guard(inline)) {
7590
- _optionalChain([visitor, 'optionalCall', _177 => _177(inline)]);
7647
+ _optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
7591
7648
  }
7592
7649
  }
7593
7650
  }
@@ -7612,7 +7669,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
7612
7669
  userIds
7613
7670
  });
7614
7671
  for (const [index, userId] of userIds.entries()) {
7615
- const user = _optionalChain([users, 'optionalAccess', _178 => _178[index]]);
7672
+ const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
7616
7673
  if (user) {
7617
7674
  resolvedUsers.set(userId, user);
7618
7675
  }
@@ -7735,7 +7792,7 @@ var stringifyCommentBodyPlainElements = {
7735
7792
  text: ({ element }) => element.text,
7736
7793
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7737
7794
  mention: ({ element, user }) => {
7738
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _179 => _179.name]), () => ( element.id))}`;
7795
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
7739
7796
  }
7740
7797
  };
7741
7798
  var stringifyCommentBodyHtmlElements = {
@@ -7765,7 +7822,7 @@ var stringifyCommentBodyHtmlElements = {
7765
7822
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
7766
7823
  },
7767
7824
  mention: ({ element, user }) => {
7768
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _180 => _180.name]), () => ( element.id))}</span>`;
7825
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _176 => _176.name]), () => ( element.id))}</span>`;
7769
7826
  }
7770
7827
  };
7771
7828
  var stringifyCommentBodyMarkdownElements = {
@@ -7795,19 +7852,19 @@ var stringifyCommentBodyMarkdownElements = {
7795
7852
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
7796
7853
  },
7797
7854
  mention: ({ element, user }) => {
7798
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
7855
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
7799
7856
  }
7800
7857
  };
7801
7858
  async function stringifyCommentBody(body, options) {
7802
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.format]), () => ( "plain"));
7803
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _183 => _183.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
7859
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.format]), () => ( "plain"));
7860
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
7804
7861
  const elements = {
7805
7862
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
7806
- ..._optionalChain([options, 'optionalAccess', _184 => _184.elements])
7863
+ ..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
7807
7864
  };
7808
7865
  const resolvedUsers = await resolveUsersInCommentBody(
7809
7866
  body,
7810
- _optionalChain([options, 'optionalAccess', _185 => _185.resolveUsers])
7867
+ _optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
7811
7868
  );
7812
7869
  const blocks = body.content.flatMap((block, blockIndex) => {
7813
7870
  switch (block.type) {
@@ -8082,12 +8139,12 @@ function legacy_patchImmutableNode(state, path, update) {
8082
8139
  }
8083
8140
  const newState = Object.assign({}, state);
8084
8141
  for (const key in update.updates) {
8085
- if (_optionalChain([update, 'access', _186 => _186.updates, 'access', _187 => _187[key], 'optionalAccess', _188 => _188.type]) === "update") {
8142
+ if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
8086
8143
  const val = update.node.get(key);
8087
8144
  if (val !== void 0) {
8088
8145
  newState[key] = lsonToJson(val);
8089
8146
  }
8090
- } else if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "delete") {
8147
+ } else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
8091
8148
  delete newState[key];
8092
8149
  }
8093
8150
  }
@@ -8148,12 +8205,12 @@ function legacy_patchImmutableNode(state, path, update) {
8148
8205
  }
8149
8206
  const newState = Object.assign({}, state);
8150
8207
  for (const key in update.updates) {
8151
- if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
8208
+ if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
8152
8209
  const value = update.node.get(key);
8153
8210
  if (value !== void 0) {
8154
8211
  newState[key] = lsonToJson(value);
8155
8212
  }
8156
- } else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
8213
+ } else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
8157
8214
  delete newState[key];
8158
8215
  }
8159
8216
  }
@@ -8408,5 +8465,9 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8408
8465
 
8409
8466
 
8410
8467
 
8411
- exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
8468
+
8469
+
8470
+
8471
+
8472
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
8412
8473
  //# sourceMappingURL=index.js.map