@liveblocks/core 2.2.3-alpha2 → 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.2.3-alpha2";
9
+ var PKG_VERSION = "2.4.0-test1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -645,7 +645,9 @@ function memoizeOnSuccess(factoryFn) {
645
645
  return () => {
646
646
  if (cached === null) {
647
647
  cached = factoryFn().catch((err) => {
648
- cached = null;
648
+ setTimeout(() => {
649
+ cached = null;
650
+ }, 5e3);
649
651
  throw err;
650
652
  });
651
653
  }
@@ -1776,15 +1778,13 @@ function stringify(object, ...args) {
1776
1778
 
1777
1779
  // src/lib/batch.ts
1778
1780
  var DEFAULT_SIZE = 50;
1779
- var DEFAULT_DELAY = 100;
1780
- var noop = () => {
1781
- };
1782
1781
  var BatchCall = class {
1783
- constructor(args) {
1784
- this.resolve = noop;
1785
- this.reject = noop;
1786
- this.promise = new Promise(noop);
1787
- this.args = args;
1782
+ constructor(input) {
1783
+ this.input = input;
1784
+ const { promise, resolve, reject } = Promise_withResolvers();
1785
+ this.promise = promise;
1786
+ this.resolve = resolve;
1787
+ this.reject = reject;
1788
1788
  }
1789
1789
  };
1790
1790
  var Batch = class {
@@ -1792,8 +1792,8 @@ var Batch = class {
1792
1792
  this.queue = [];
1793
1793
  this.error = false;
1794
1794
  this.callback = callback;
1795
- this.size = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.size]), () => ( DEFAULT_SIZE));
1796
- this.delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.delay]), () => ( DEFAULT_DELAY));
1795
+ this.size = _nullishCoalesce(options.size, () => ( DEFAULT_SIZE));
1796
+ this.delay = options.delay;
1797
1797
  }
1798
1798
  clearDelayTimeout() {
1799
1799
  if (this.delayTimeoutId !== void 0) {
@@ -1814,12 +1814,12 @@ var Batch = class {
1814
1814
  return;
1815
1815
  }
1816
1816
  const calls = this.queue.splice(0);
1817
- const args = calls.map((call) => call.args);
1817
+ const inputs = calls.map((call) => call.input);
1818
1818
  try {
1819
- const results = await this.callback(args);
1819
+ const results = await this.callback(inputs);
1820
1820
  this.error = false;
1821
1821
  calls.forEach((call, index) => {
1822
- const result = _optionalChain([results, 'optionalAccess', _46 => _46[index]]);
1822
+ const result = _optionalChain([results, 'optionalAccess', _44 => _44[index]]);
1823
1823
  if (!Array.isArray(results)) {
1824
1824
  call.reject(new Error("Callback must return an array."));
1825
1825
  } else if (calls.length !== results.length) {
@@ -1841,18 +1841,14 @@ var Batch = class {
1841
1841
  });
1842
1842
  }
1843
1843
  }
1844
- get(...args) {
1844
+ get(input) {
1845
1845
  const existingCall = this.queue.find(
1846
- (call2) => stringify(call2.args) === stringify(args)
1846
+ (call2) => stringify(call2.input) === stringify(input)
1847
1847
  );
1848
1848
  if (existingCall) {
1849
1849
  return existingCall.promise;
1850
1850
  }
1851
- const call = new BatchCall(args);
1852
- call.promise = new Promise((resolve, reject) => {
1853
- call.resolve = resolve;
1854
- call.reject = reject;
1855
- });
1851
+ const call = new BatchCall(input);
1856
1852
  this.queue.push(call);
1857
1853
  this.schedule();
1858
1854
  return call.promise;
@@ -1871,21 +1867,17 @@ function createBatchStore(callback, options) {
1871
1867
  return stringify(args);
1872
1868
  }
1873
1869
  function setStateAndNotify(cacheKey, state) {
1874
- if (state) {
1875
- cache.set(cacheKey, state);
1876
- } else {
1877
- cache.delete(cacheKey);
1878
- }
1879
- eventSource2.notify(state);
1870
+ cache.set(cacheKey, state);
1871
+ eventSource2.notify();
1880
1872
  }
1881
- async function get(...args) {
1882
- const cacheKey = getCacheKey(args);
1873
+ async function get(input) {
1874
+ const cacheKey = getCacheKey(input);
1883
1875
  if (cache.has(cacheKey)) {
1884
1876
  return;
1885
1877
  }
1886
1878
  try {
1887
1879
  setStateAndNotify(cacheKey, { isLoading: true });
1888
- const result = await batch.get(...args);
1880
+ const result = await batch.get(input);
1889
1881
  setStateAndNotify(cacheKey, { isLoading: false, data: result });
1890
1882
  } catch (error3) {
1891
1883
  setStateAndNotify(cacheKey, {
@@ -1894,12 +1886,12 @@ function createBatchStore(callback, options) {
1894
1886
  });
1895
1887
  }
1896
1888
  }
1897
- function getState(...args) {
1898
- const cacheKey = getCacheKey(args);
1889
+ function getState(input) {
1890
+ const cacheKey = getCacheKey(input);
1899
1891
  return cache.get(cacheKey);
1900
1892
  }
1901
1893
  return {
1902
- ...eventSource2,
1894
+ ...eventSource2.observable,
1903
1895
  get,
1904
1896
  getState
1905
1897
  };
@@ -2055,7 +2047,7 @@ function createNotificationsApi({
2055
2047
  const response = await fetcher(url.toString(), {
2056
2048
  ...options,
2057
2049
  headers: {
2058
- ..._optionalChain([options, 'optionalAccess', _47 => _47.headers]),
2050
+ ..._optionalChain([options, 'optionalAccess', _45 => _45.headers]),
2059
2051
  Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
2060
2052
  }
2061
2053
  });
@@ -2086,25 +2078,32 @@ function createNotificationsApi({
2086
2078
  }
2087
2079
  return body;
2088
2080
  }
2089
- async function getInboxNotifications(options) {
2090
- const json = await fetchJson("/inbox-notifications", void 0, {
2091
- limit: _optionalChain([options, 'optionalAccess', _48 => _48.limit]),
2092
- since: _optionalChain([options, 'optionalAccess', _49 => _49.since, 'optionalAccess', _50 => _50.toISOString, 'call', _51 => _51()])
2093
- });
2081
+ async function getInboxNotifications() {
2082
+ const json = await fetchJson("/inbox-notifications", void 0, {});
2094
2083
  return {
2095
- threads: json.threads.map((thread) => convertToThreadData(thread)),
2084
+ threads: json.threads.map(convertToThreadData),
2096
2085
  inboxNotifications: json.inboxNotifications.map(
2097
- (notification) => convertToInboxNotificationData(notification)
2098
- ),
2099
- deletedThreads: json.deletedThreads.map(
2100
- (info) => convertToThreadDeleteInfo(info)
2086
+ convertToInboxNotificationData
2101
2087
  ),
2102
- deletedInboxNotifications: json.deletedInboxNotifications.map(
2103
- (info) => convertToInboxNotificationDeleteInfo(info)
2104
- ),
2105
- meta: {
2106
- requestedAt: new Date(json.meta.requestedAt)
2107
- }
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)
2108
2107
  };
2109
2108
  }
2110
2109
  async function getUnreadInboxNotificationsCount() {
@@ -2140,11 +2139,27 @@ function createNotificationsApi({
2140
2139
  async function markInboxNotificationAsRead(inboxNotificationId) {
2141
2140
  await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
2142
2141
  }
2142
+ async function deleteAllInboxNotifications() {
2143
+ await fetchJson("/inbox-notifications", {
2144
+ method: "DELETE"
2145
+ });
2146
+ }
2147
+ async function deleteInboxNotification(inboxNotificationId) {
2148
+ await fetchJson(
2149
+ `/inbox-notifications/${encodeURIComponent(inboxNotificationId)}`,
2150
+ {
2151
+ method: "DELETE"
2152
+ }
2153
+ );
2154
+ }
2143
2155
  return {
2144
2156
  getInboxNotifications,
2157
+ getInboxNotificationsSince,
2145
2158
  getUnreadInboxNotificationsCount,
2146
2159
  markAllInboxNotificationsAsRead,
2147
- markInboxNotificationAsRead
2160
+ markInboxNotificationAsRead,
2161
+ deleteAllInboxNotifications,
2162
+ deleteInboxNotification
2148
2163
  };
2149
2164
  }
2150
2165
 
@@ -2487,14 +2502,10 @@ function isChildCrdt(crdt) {
2487
2502
  }
2488
2503
 
2489
2504
  // src/lib/nanoid.ts
2490
- function nanoid(length = 7) {
2491
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,./;[]~!@#$%&*()_+=-";
2492
- const len = alphabet.length;
2493
- return Array.from(
2494
- { length },
2495
- () => alphabet.charAt(Math.floor(Math.random() * len))
2496
- ).join("");
2497
- }
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
+ );
2498
2509
 
2499
2510
  // src/crdts/LiveRegister.ts
2500
2511
  var LiveRegister = class _LiveRegister extends AbstractCrdt {
@@ -2521,7 +2532,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
2521
2532
  return [
2522
2533
  {
2523
2534
  type: 8 /* CREATE_REGISTER */,
2524
- opId: _optionalChain([pool, 'optionalAccess', _52 => _52.generateOpId, 'call', _53 => _53()]),
2535
+ opId: _optionalChain([pool, 'optionalAccess', _46 => _46.generateOpId, 'call', _47 => _47()]),
2525
2536
  id: this._id,
2526
2537
  parentId,
2527
2538
  parentKey,
@@ -2623,7 +2634,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2623
2634
  const ops = [];
2624
2635
  const op = {
2625
2636
  id: this._id,
2626
- opId: _optionalChain([pool, 'optionalAccess', _54 => _54.generateOpId, 'call', _55 => _55()]),
2637
+ opId: _optionalChain([pool, 'optionalAccess', _48 => _48.generateOpId, 'call', _49 => _49()]),
2627
2638
  type: 2 /* CREATE_LIST */,
2628
2639
  parentId,
2629
2640
  parentKey
@@ -2900,7 +2911,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2900
2911
  _applyInsertUndoRedo(op) {
2901
2912
  const { id, parentKey: key } = op;
2902
2913
  const child = creationOpToLiveNode(op);
2903
- if (_optionalChain([this, 'access', _56 => _56._pool, 'optionalAccess', _57 => _57.getNode, 'call', _58 => _58(id)]) !== void 0) {
2914
+ if (_optionalChain([this, 'access', _50 => _50._pool, 'optionalAccess', _51 => _51.getNode, 'call', _52 => _52(id)]) !== void 0) {
2904
2915
  return { modified: false };
2905
2916
  }
2906
2917
  child._attach(id, nn(this._pool));
@@ -2908,8 +2919,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
2908
2919
  const existingItemIndex = this._indexOfPosition(key);
2909
2920
  let newKey = key;
2910
2921
  if (existingItemIndex !== -1) {
2911
- const before2 = _optionalChain([this, 'access', _59 => _59._items, 'access', _60 => _60[existingItemIndex], 'optionalAccess', _61 => _61._parentPos]);
2912
- const after2 = _optionalChain([this, 'access', _62 => _62._items, 'access', _63 => _63[existingItemIndex + 1], 'optionalAccess', _64 => _64._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]);
2913
2924
  newKey = makePosition(before2, after2);
2914
2925
  child._setParentLink(this, newKey);
2915
2926
  }
@@ -2924,7 +2935,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2924
2935
  _applySetUndoRedo(op) {
2925
2936
  const { id, parentKey: key } = op;
2926
2937
  const child = creationOpToLiveNode(op);
2927
- if (_optionalChain([this, 'access', _65 => _65._pool, 'optionalAccess', _66 => _66.getNode, 'call', _67 => _67(id)]) !== void 0) {
2938
+ if (_optionalChain([this, 'access', _59 => _59._pool, 'optionalAccess', _60 => _60.getNode, 'call', _61 => _61(id)]) !== void 0) {
2928
2939
  return { modified: false };
2929
2940
  }
2930
2941
  this._unacknowledgedSets.set(key, nn(op.opId));
@@ -3046,7 +3057,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3046
3057
  } else {
3047
3058
  this._items[existingItemIndex]._setParentLink(
3048
3059
  this,
3049
- makePosition(newKey, _optionalChain([this, 'access', _68 => _68._items, 'access', _69 => _69[existingItemIndex + 1], 'optionalAccess', _70 => _70._parentPos]))
3060
+ makePosition(newKey, _optionalChain([this, 'access', _62 => _62._items, 'access', _63 => _63[existingItemIndex + 1], 'optionalAccess', _64 => _64._parentPos]))
3050
3061
  );
3051
3062
  const previousIndex = this._items.indexOf(child);
3052
3063
  child._setParentLink(this, newKey);
@@ -3072,7 +3083,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3072
3083
  if (existingItemIndex !== -1) {
3073
3084
  this._items[existingItemIndex]._setParentLink(
3074
3085
  this,
3075
- makePosition(newKey, _optionalChain([this, 'access', _71 => _71._items, 'access', _72 => _72[existingItemIndex + 1], 'optionalAccess', _73 => _73._parentPos]))
3086
+ makePosition(newKey, _optionalChain([this, 'access', _65 => _65._items, 'access', _66 => _66[existingItemIndex + 1], 'optionalAccess', _67 => _67._parentPos]))
3076
3087
  );
3077
3088
  }
3078
3089
  child._setParentLink(this, newKey);
@@ -3091,7 +3102,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3091
3102
  if (existingItemIndex !== -1) {
3092
3103
  this._items[existingItemIndex]._setParentLink(
3093
3104
  this,
3094
- makePosition(newKey, _optionalChain([this, 'access', _74 => _74._items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]))
3105
+ makePosition(newKey, _optionalChain([this, 'access', _68 => _68._items, 'access', _69 => _69[existingItemIndex + 1], 'optionalAccess', _70 => _70._parentPos]))
3095
3106
  );
3096
3107
  }
3097
3108
  child._setParentLink(this, newKey);
@@ -3119,7 +3130,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3119
3130
  if (existingItemIndex !== -1) {
3120
3131
  this._items[existingItemIndex]._setParentLink(
3121
3132
  this,
3122
- makePosition(newKey, _optionalChain([this, 'access', _77 => _77._items, 'access', _78 => _78[existingItemIndex + 1], 'optionalAccess', _79 => _79._parentPos]))
3133
+ makePosition(newKey, _optionalChain([this, 'access', _71 => _71._items, 'access', _72 => _72[existingItemIndex + 1], 'optionalAccess', _73 => _73._parentPos]))
3123
3134
  );
3124
3135
  }
3125
3136
  child._setParentLink(this, newKey);
@@ -3177,7 +3188,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3177
3188
  * @param element The element to add to the end of the LiveList.
3178
3189
  */
3179
3190
  push(element) {
3180
- _optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
3191
+ _optionalChain([this, 'access', _74 => _74._pool, 'optionalAccess', _75 => _75.assertStorageIsWritable, 'call', _76 => _76()]);
3181
3192
  return this.insert(element, this.length);
3182
3193
  }
3183
3194
  /**
@@ -3186,7 +3197,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3186
3197
  * @param index The index at which you want to insert the element.
3187
3198
  */
3188
3199
  insert(element, index) {
3189
- _optionalChain([this, 'access', _83 => _83._pool, 'optionalAccess', _84 => _84.assertStorageIsWritable, 'call', _85 => _85()]);
3200
+ _optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.assertStorageIsWritable, 'call', _79 => _79()]);
3190
3201
  if (index < 0 || index > this._items.length) {
3191
3202
  throw new Error(
3192
3203
  `Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
@@ -3216,7 +3227,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3216
3227
  * @param targetIndex The index where the element should be after moving.
3217
3228
  */
3218
3229
  move(index, targetIndex) {
3219
- _optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
3230
+ _optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
3220
3231
  if (targetIndex < 0) {
3221
3232
  throw new Error("targetIndex cannot be less than 0");
3222
3233
  }
@@ -3274,7 +3285,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3274
3285
  * @param index The index of the element to delete
3275
3286
  */
3276
3287
  delete(index) {
3277
- _optionalChain([this, 'access', _89 => _89._pool, 'optionalAccess', _90 => _90.assertStorageIsWritable, 'call', _91 => _91()]);
3288
+ _optionalChain([this, 'access', _83 => _83._pool, 'optionalAccess', _84 => _84.assertStorageIsWritable, 'call', _85 => _85()]);
3278
3289
  if (index < 0 || index >= this._items.length) {
3279
3290
  throw new Error(
3280
3291
  `Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
@@ -3307,7 +3318,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3307
3318
  }
3308
3319
  }
3309
3320
  clear() {
3310
- _optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
3321
+ _optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
3311
3322
  if (this._pool) {
3312
3323
  const ops = [];
3313
3324
  const reverseOps = [];
@@ -3341,7 +3352,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3341
3352
  }
3342
3353
  }
3343
3354
  set(index, item) {
3344
- _optionalChain([this, 'access', _95 => _95._pool, 'optionalAccess', _96 => _96.assertStorageIsWritable, 'call', _97 => _97()]);
3355
+ _optionalChain([this, 'access', _89 => _89._pool, 'optionalAccess', _90 => _90.assertStorageIsWritable, 'call', _91 => _91()]);
3345
3356
  if (index < 0 || index >= this._items.length) {
3346
3357
  throw new Error(
3347
3358
  `Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
@@ -3489,7 +3500,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
3489
3500
  _shiftItemPosition(index, key) {
3490
3501
  const shiftedPosition = makePosition(
3491
3502
  key,
3492
- this._items.length > index + 1 ? _optionalChain([this, 'access', _98 => _98._items, 'access', _99 => _99[index + 1], 'optionalAccess', _100 => _100._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
3493
3504
  );
3494
3505
  this._items[index]._setParentLink(this, shiftedPosition);
3495
3506
  }
@@ -3618,7 +3629,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3618
3629
  const ops = [];
3619
3630
  const op = {
3620
3631
  id: this._id,
3621
- opId: _optionalChain([pool, 'optionalAccess', _101 => _101.generateOpId, 'call', _102 => _102()]),
3632
+ opId: _optionalChain([pool, 'optionalAccess', _95 => _95.generateOpId, 'call', _96 => _96()]),
3622
3633
  type: 7 /* CREATE_MAP */,
3623
3634
  parentId,
3624
3635
  parentKey
@@ -3765,7 +3776,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3765
3776
  * @param value The value of the element to add. Should be serializable to JSON.
3766
3777
  */
3767
3778
  set(key, value) {
3768
- _optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.assertStorageIsWritable, 'call', _105 => _105()]);
3779
+ _optionalChain([this, 'access', _97 => _97._pool, 'optionalAccess', _98 => _98.assertStorageIsWritable, 'call', _99 => _99()]);
3769
3780
  const oldValue = this._map.get(key);
3770
3781
  if (oldValue) {
3771
3782
  oldValue._detach();
@@ -3811,7 +3822,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
3811
3822
  * @returns true if an element existed and has been removed, or false if the element does not exist.
3812
3823
  */
3813
3824
  delete(key) {
3814
- _optionalChain([this, 'access', _106 => _106._pool, 'optionalAccess', _107 => _107.assertStorageIsWritable, 'call', _108 => _108()]);
3825
+ _optionalChain([this, 'access', _100 => _100._pool, 'optionalAccess', _101 => _101.assertStorageIsWritable, 'call', _102 => _102()]);
3815
3826
  const item = this._map.get(key);
3816
3827
  if (item === void 0) {
3817
3828
  return false;
@@ -3989,7 +4000,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
3989
4000
  if (this._id === void 0) {
3990
4001
  throw new Error("Cannot serialize item is not attached");
3991
4002
  }
3992
- const opId = _optionalChain([pool, 'optionalAccess', _109 => _109.generateOpId, 'call', _110 => _110()]);
4003
+ const opId = _optionalChain([pool, 'optionalAccess', _103 => _103.generateOpId, 'call', _104 => _104()]);
3993
4004
  const ops = [];
3994
4005
  const op = {
3995
4006
  type: 4 /* CREATE_OBJECT */,
@@ -4267,7 +4278,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4267
4278
  * @param value The value of the property to add
4268
4279
  */
4269
4280
  set(key, value) {
4270
- _optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
4281
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4271
4282
  this.update({ [key]: value });
4272
4283
  }
4273
4284
  /**
@@ -4282,7 +4293,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4282
4293
  * @param key The key of the property to delete
4283
4294
  */
4284
4295
  delete(key) {
4285
- _optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.assertStorageIsWritable, 'call', _116 => _116()]);
4296
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4286
4297
  const keyAsString = key;
4287
4298
  const oldValue = this._map.get(keyAsString);
4288
4299
  if (oldValue === void 0) {
@@ -4335,7 +4346,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
4335
4346
  * @param patch The object used to overrides properties
4336
4347
  */
4337
4348
  update(patch) {
4338
- _optionalChain([this, 'access', _117 => _117._pool, 'optionalAccess', _118 => _118.assertStorageIsWritable, 'call', _119 => _119()]);
4349
+ _optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
4339
4350
  if (this._pool === void 0 || this._id === void 0) {
4340
4351
  for (const key in patch) {
4341
4352
  const newValue = patch[key];
@@ -4708,6 +4719,23 @@ function findNonSerializableValue(value, path = "") {
4708
4719
  return false;
4709
4720
  }
4710
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
+
4711
4739
  // src/lib/debug.ts
4712
4740
  function captureStackTrace(msg, traceRoot) {
4713
4741
  const errorLike = { name: msg };
@@ -5094,15 +5122,15 @@ function installBackgroundTabSpy() {
5094
5122
  const doc = typeof document !== "undefined" ? document : void 0;
5095
5123
  const inBackgroundSince = { current: null };
5096
5124
  function onVisibilityChange() {
5097
- if (_optionalChain([doc, 'optionalAccess', _120 => _120.visibilityState]) === "hidden") {
5125
+ if (_optionalChain([doc, 'optionalAccess', _114 => _114.visibilityState]) === "hidden") {
5098
5126
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
5099
5127
  } else {
5100
5128
  inBackgroundSince.current = null;
5101
5129
  }
5102
5130
  }
5103
- _optionalChain([doc, 'optionalAccess', _121 => _121.addEventListener, 'call', _122 => _122("visibilitychange", onVisibilityChange)]);
5131
+ _optionalChain([doc, 'optionalAccess', _115 => _115.addEventListener, 'call', _116 => _116("visibilitychange", onVisibilityChange)]);
5104
5132
  const unsub = () => {
5105
- _optionalChain([doc, 'optionalAccess', _123 => _123.removeEventListener, 'call', _124 => _124("visibilitychange", onVisibilityChange)]);
5133
+ _optionalChain([doc, 'optionalAccess', _117 => _117.removeEventListener, 'call', _118 => _118("visibilitychange", onVisibilityChange)]);
5106
5134
  };
5107
5135
  return [inBackgroundSince, unsub];
5108
5136
  }
@@ -5145,15 +5173,57 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5145
5173
  }
5146
5174
  return body;
5147
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
+ }
5148
5219
  async function getThreads(options) {
5149
5220
  let query;
5150
- if (_optionalChain([options, 'optionalAccess', _125 => _125.query])) {
5221
+ if (_optionalChain([options, 'optionalAccess', _122 => _122.query])) {
5151
5222
  query = objectToQuery(options.query);
5152
5223
  }
5153
5224
  const response = await fetchCommentsApi(
5154
5225
  "/threads",
5155
5226
  {
5156
- since: _optionalChain([options, 'optionalAccess', _126 => _126.since, 'optionalAccess', _127 => _127.toISOString, 'call', _128 => _128()]),
5157
5227
  query
5158
5228
  },
5159
5229
  {
@@ -5165,19 +5235,11 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5165
5235
  if (response.ok) {
5166
5236
  const json = await response.json();
5167
5237
  return {
5168
- threads: json.data.map((thread) => convertToThreadData(thread)),
5238
+ threads: json.data.map(convertToThreadData),
5169
5239
  inboxNotifications: json.inboxNotifications.map(
5170
- (notification) => convertToInboxNotificationData(notification)
5171
- ),
5172
- deletedThreads: json.deletedThreads.map(
5173
- (info) => convertToThreadDeleteInfo(info)
5174
- ),
5175
- deletedInboxNotifications: json.deletedInboxNotifications.map(
5176
- (info) => convertToInboxNotificationDeleteInfo(info)
5240
+ convertToInboxNotificationData
5177
5241
  ),
5178
- meta: {
5179
- requestedAt: new Date(json.meta.requestedAt)
5180
- }
5242
+ requestedAt: new Date(json.meta.requestedAt)
5181
5243
  };
5182
5244
  } else if (response.status === 404) {
5183
5245
  return {
@@ -5185,15 +5247,13 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5185
5247
  inboxNotifications: [],
5186
5248
  deletedThreads: [],
5187
5249
  deletedInboxNotifications: [],
5188
- meta: {
5189
- requestedAt: /* @__PURE__ */ new Date()
5190
- }
5250
+ requestedAt: /* @__PURE__ */ new Date()
5191
5251
  };
5192
5252
  } else {
5193
5253
  throw new Error("There was an error while getting threads.");
5194
5254
  }
5195
5255
  }
5196
- async function getThread({ threadId }) {
5256
+ async function getThread(threadId) {
5197
5257
  const response = await fetchCommentsApi(
5198
5258
  `/thread-with-notification/${threadId}`
5199
5259
  );
@@ -5204,7 +5264,10 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5204
5264
  inboxNotification: json.inboxNotification ? convertToInboxNotificationData(json.inboxNotification) : void 0
5205
5265
  };
5206
5266
  } else if (response.status === 404) {
5207
- return;
5267
+ return {
5268
+ thread: void 0,
5269
+ inboxNotification: void 0
5270
+ };
5208
5271
  } else {
5209
5272
  throw new Error(`There was an error while getting thread ${threadId}.`);
5210
5273
  }
@@ -5212,8 +5275,8 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5212
5275
  async function createThread({
5213
5276
  metadata,
5214
5277
  body,
5215
- commentId,
5216
- threadId
5278
+ commentId = createCommentId(),
5279
+ threadId = createThreadId()
5217
5280
  }) {
5218
5281
  const thread = await fetchJson("/threads", {
5219
5282
  method: "POST",
@@ -5231,7 +5294,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5231
5294
  });
5232
5295
  return convertToThreadData(thread);
5233
5296
  }
5234
- async function deleteThread({ threadId }) {
5297
+ async function deleteThread(threadId) {
5235
5298
  await fetchJson(`/threads/${encodeURIComponent(threadId)}`, {
5236
5299
  method: "DELETE"
5237
5300
  });
@@ -5251,7 +5314,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5251
5314
  }
5252
5315
  );
5253
5316
  }
5254
- async function markThreadAsResolved({ threadId }) {
5317
+ async function markThreadAsResolved(threadId) {
5255
5318
  await fetchJson(
5256
5319
  `/threads/${encodeURIComponent(threadId)}/mark-as-resolved`,
5257
5320
  {
@@ -5259,7 +5322,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5259
5322
  }
5260
5323
  );
5261
5324
  }
5262
- async function markThreadAsUnresolved({ threadId }) {
5325
+ async function markThreadAsUnresolved(threadId) {
5263
5326
  await fetchJson(
5264
5327
  `/threads/${encodeURIComponent(threadId)}/mark-as-unresolved`,
5265
5328
  {
@@ -5269,7 +5332,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5269
5332
  }
5270
5333
  async function createComment({
5271
5334
  threadId,
5272
- commentId,
5335
+ commentId = createCommentId(),
5273
5336
  body
5274
5337
  }) {
5275
5338
  const comment = await fetchJson(
@@ -5356,6 +5419,7 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
5356
5419
  }
5357
5420
  return {
5358
5421
  getThreads,
5422
+ getThreadsSince,
5359
5423
  getThread,
5360
5424
  createThread,
5361
5425
  deleteThread,
@@ -5557,7 +5621,7 @@ function createRoom(options, config) {
5557
5621
  }
5558
5622
  },
5559
5623
  assertStorageIsWritable: () => {
5560
- const scopes = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.scopes]);
5624
+ const scopes = _optionalChain([context, 'access', _123 => _123.dynamicSessionInfo, 'access', _124 => _124.current, 'optionalAccess', _125 => _125.scopes]);
5561
5625
  if (scopes === void 0) {
5562
5626
  return;
5563
5627
  }
@@ -5591,12 +5655,12 @@ function createRoom(options, config) {
5591
5655
  `/v2/c/rooms/${encodeURIComponent(roomId)}${endpoint}`,
5592
5656
  params
5593
5657
  );
5594
- const fetcher = _optionalChain([config, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.fetch]) || /* istanbul ignore next */
5658
+ const fetcher = _optionalChain([config, 'access', _126 => _126.polyfills, 'optionalAccess', _127 => _127.fetch]) || /* istanbul ignore next */
5595
5659
  fetch;
5596
5660
  return await fetcher(url, {
5597
5661
  ...options2,
5598
5662
  headers: {
5599
- ..._optionalChain([options2, 'optionalAccess', _134 => _134.headers]),
5663
+ ..._optionalChain([options2, 'optionalAccess', _128 => _128.headers]),
5600
5664
  Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
5601
5665
  }
5602
5666
  });
@@ -5669,7 +5733,7 @@ function createRoom(options, config) {
5669
5733
  }
5670
5734
  function sendMessages(messages) {
5671
5735
  const serializedPayload = JSON.stringify(messages);
5672
- const nonce = _optionalChain([context, 'access', _135 => _135.dynamicSessionInfo, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.nonce]);
5736
+ const nonce = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.nonce]);
5673
5737
  if (config.unstable_fallbackToHTTP && nonce) {
5674
5738
  const size = new TextEncoder().encode(serializedPayload).length;
5675
5739
  if (size > MAX_SOCKET_MESSAGE_SIZE) {
@@ -5731,7 +5795,7 @@ function createRoom(options, config) {
5731
5795
  } else {
5732
5796
  context.root = LiveObject._fromItems(message.items, pool);
5733
5797
  }
5734
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _138 => _138.current, 'optionalAccess', _139 => _139.canWrite]), () => ( true));
5798
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _132 => _132.current, 'optionalAccess', _133 => _133.canWrite]), () => ( true));
5735
5799
  const stackSizeBefore = context.undoStack.length;
5736
5800
  for (const key in context.initialStorage) {
5737
5801
  if (context.root.get(key) === void 0) {
@@ -5936,7 +6000,7 @@ function createRoom(options, config) {
5936
6000
  }
5937
6001
  context.myPresence.patch(patch);
5938
6002
  if (context.activeBatch) {
5939
- if (_optionalChain([options2, 'optionalAccess', _140 => _140.addToHistory])) {
6003
+ if (_optionalChain([options2, 'optionalAccess', _134 => _134.addToHistory])) {
5940
6004
  context.activeBatch.reverseOps.unshift({
5941
6005
  type: "presence",
5942
6006
  data: oldValues
@@ -5946,7 +6010,7 @@ function createRoom(options, config) {
5946
6010
  } else {
5947
6011
  flushNowOrSoon();
5948
6012
  batchUpdates(() => {
5949
- if (_optionalChain([options2, 'optionalAccess', _141 => _141.addToHistory])) {
6013
+ if (_optionalChain([options2, 'optionalAccess', _135 => _135.addToHistory])) {
5950
6014
  addToUndoStack(
5951
6015
  [{ type: "presence", data: oldValues }],
5952
6016
  doNotBatchUpdates
@@ -6144,7 +6208,7 @@ function createRoom(options, config) {
6144
6208
  if (process.env.NODE_ENV !== "production") {
6145
6209
  const traces = /* @__PURE__ */ new Set();
6146
6210
  for (const opId of message.opIds) {
6147
- const trace = _optionalChain([context, 'access', _142 => _142.opStackTraces, 'optionalAccess', _143 => _143.get, 'call', _144 => _144(opId)]);
6211
+ const trace = _optionalChain([context, 'access', _136 => _136.opStackTraces, 'optionalAccess', _137 => _137.get, 'call', _138 => _138(opId)]);
6148
6212
  if (trace) {
6149
6213
  traces.add(trace);
6150
6214
  }
@@ -6278,7 +6342,7 @@ ${Array.from(traces).join("\n\n")}`
6278
6342
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
6279
6343
  createOrUpdateRootFromMessage(message, doNotBatchUpdates);
6280
6344
  applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
6281
- _optionalChain([_resolveStoragePromise, 'optionalCall', _145 => _145()]);
6345
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _139 => _139()]);
6282
6346
  notifyStorageStatus();
6283
6347
  eventHub.storageDidLoad.notify();
6284
6348
  }
@@ -6535,12 +6599,12 @@ ${Array.from(traces).join("\n\n")}`
6535
6599
  }
6536
6600
  return body;
6537
6601
  }
6538
- function getRoomNotificationSettings() {
6602
+ function getNotificationSettings() {
6539
6603
  return fetchNotificationsJson(
6540
6604
  "/notification-settings"
6541
6605
  );
6542
6606
  }
6543
- function updateRoomNotificationSettings(settings) {
6607
+ function updateNotificationSettings(settings) {
6544
6608
  return fetchNotificationsJson(
6545
6609
  "/notification-settings",
6546
6610
  {
@@ -6576,7 +6640,7 @@ ${Array.from(traces).join("\n\n")}`
6576
6640
  {
6577
6641
  [kInternal]: {
6578
6642
  get presenceBuffer() {
6579
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _146 => _146.buffer, 'access', _147 => _147.presenceUpdates, 'optionalAccess', _148 => _148.data]), () => ( null)));
6643
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _140 => _140.buffer, 'access', _141 => _141.presenceUpdates, 'optionalAccess', _142 => _142.data]), () => ( null)));
6580
6644
  },
6581
6645
  // prettier-ignore
6582
6646
  get undoStack() {
@@ -6601,14 +6665,6 @@ ${Array.from(traces).join("\n\n")}`
6601
6665
  // These exist only for our E2E testing app
6602
6666
  explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
6603
6667
  rawSend: (data) => managedSocket.send(data)
6604
- },
6605
- comments: {
6606
- ...commentsApi
6607
- },
6608
- notifications: {
6609
- getRoomNotificationSettings,
6610
- updateRoomNotificationSettings,
6611
- markInboxNotificationAsRead
6612
6668
  }
6613
6669
  },
6614
6670
  id: config.roomId,
@@ -6649,7 +6705,11 @@ ${Array.from(traces).join("\n\n")}`
6649
6705
  getSelf: () => self.current,
6650
6706
  // Presence
6651
6707
  getPresence: () => context.myPresence.current,
6652
- getOthers: () => context.others.current
6708
+ getOthers: () => context.others.current,
6709
+ getNotificationSettings,
6710
+ updateNotificationSettings,
6711
+ markInboxNotificationAsRead,
6712
+ ...commentsApi
6653
6713
  },
6654
6714
  // Explictly make the internal field non-enumerable, to avoid aggressive
6655
6715
  // freezing when used with Immer
@@ -6711,6 +6771,10 @@ function makeClassicSubscribeFn(events) {
6711
6771
  return events.storageStatus.subscribe(
6712
6772
  callback
6713
6773
  );
6774
+ case "comments":
6775
+ return events.comments.subscribe(
6776
+ callback
6777
+ );
6714
6778
  default:
6715
6779
  return assertNever(
6716
6780
  first,
@@ -6728,7 +6792,7 @@ function makeClassicSubscribeFn(events) {
6728
6792
  }
6729
6793
  if (isLiveNode(first)) {
6730
6794
  const node = first;
6731
- if (_optionalChain([options, 'optionalAccess', _149 => _149.isDeep])) {
6795
+ if (_optionalChain([options, 'optionalAccess', _143 => _143.isDeep])) {
6732
6796
  const storageCallback = second;
6733
6797
  return subscribeToLiveStructureDeeply(node, storageCallback);
6734
6798
  } else {
@@ -6743,7 +6807,7 @@ function makeClassicSubscribeFn(events) {
6743
6807
  return subscribe;
6744
6808
  }
6745
6809
  function isRoomEventName(value) {
6746
- 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";
6747
6811
  }
6748
6812
  function makeAuthDelegateForRoom(roomId, authManager) {
6749
6813
  return async () => {
@@ -6828,9 +6892,7 @@ function createClientStore() {
6828
6892
  ),
6829
6893
  queries: queryKey !== void 0 ? {
6830
6894
  ...state.queries,
6831
- [queryKey]: {
6832
- isLoading: false
6833
- }
6895
+ [queryKey]: { isLoading: false, data: void 0 }
6834
6896
  } : state.queries
6835
6897
  }));
6836
6898
  },
@@ -6843,9 +6905,7 @@ function createClientStore() {
6843
6905
  },
6844
6906
  queries: {
6845
6907
  ...state.queries,
6846
- [queryKey]: {
6847
- isLoading: false
6848
- }
6908
+ [queryKey]: { isLoading: false, data: void 0 }
6849
6909
  }
6850
6910
  }));
6851
6911
  },
@@ -7046,7 +7106,7 @@ function applyOptimisticUpdates(state) {
7046
7106
  };
7047
7107
  break;
7048
7108
  }
7049
- case "mark-inbox-notifications-as-read": {
7109
+ case "mark-all-inbox-notifications-as-read": {
7050
7110
  for (const id in result.inboxNotifications) {
7051
7111
  result.inboxNotifications[id] = {
7052
7112
  ...result.inboxNotifications[id],
@@ -7055,6 +7115,18 @@ function applyOptimisticUpdates(state) {
7055
7115
  }
7056
7116
  break;
7057
7117
  }
7118
+ case "delete-inbox-notification": {
7119
+ const {
7120
+ [optimisticUpdate.inboxNotificationId]: _,
7121
+ ...inboxNotifications
7122
+ } = result.inboxNotifications;
7123
+ result.inboxNotifications = inboxNotifications;
7124
+ break;
7125
+ }
7126
+ case "delete-all-inbox-notifications": {
7127
+ result.inboxNotifications = {};
7128
+ break;
7129
+ }
7058
7130
  case "update-notification-settings": {
7059
7131
  result.notificationSettings[optimisticUpdate.roomId] = {
7060
7132
  ...result.notificationSettings[optimisticUpdate.roomId],
@@ -7130,7 +7202,7 @@ function upsertComment(thread, comment) {
7130
7202
  );
7131
7203
  if (existingComment === void 0) {
7132
7204
  const updatedAt = new Date(
7133
- Math.max(_optionalChain([thread, 'access', _150 => _150.updatedAt, 'optionalAccess', _151 => _151.getTime, 'call', _152 => _152()]) || 0, comment.createdAt.getTime())
7205
+ Math.max(_optionalChain([thread, 'access', _144 => _144.updatedAt, 'optionalAccess', _145 => _145.getTime, 'call', _146 => _146()]) || 0, comment.createdAt.getTime())
7134
7206
  );
7135
7207
  const updatedThread = {
7136
7208
  ...thread,
@@ -7150,8 +7222,8 @@ function upsertComment(thread, comment) {
7150
7222
  ...thread,
7151
7223
  updatedAt: new Date(
7152
7224
  Math.max(
7153
- _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0,
7154
- _optionalChain([comment, 'access', _156 => _156.editedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 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()
7155
7227
  )
7156
7228
  ),
7157
7229
  comments: updatedComments
@@ -7216,7 +7288,7 @@ function addReaction(thread, commentId, reaction) {
7216
7288
  return {
7217
7289
  ...thread,
7218
7290
  updatedAt: new Date(
7219
- Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _159 => _159.updatedAt, 'optionalAccess', _160 => _160.getTime, 'call', _161 => _161()]) || 0)
7291
+ Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0)
7220
7292
  ),
7221
7293
  comments: updatedComments
7222
7294
  };
@@ -7249,7 +7321,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
7249
7321
  return {
7250
7322
  ...thread,
7251
7323
  updatedAt: new Date(
7252
- Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _162 => _162.updatedAt, 'optionalAccess', _163 => _163.getTime, 'call', _164 => _164()]) || 0)
7324
+ Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _156 => _156.updatedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 0)
7253
7325
  ),
7254
7326
  comments: updatedComments
7255
7327
  };
@@ -7360,12 +7432,12 @@ function createClient(options) {
7360
7432
  createSocket: makeCreateSocketDelegateForRoom(
7361
7433
  roomId,
7362
7434
  baseUrl,
7363
- _optionalChain([clientOptions, 'access', _165 => _165.polyfills, 'optionalAccess', _166 => _166.WebSocket])
7435
+ _optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.WebSocket])
7364
7436
  ),
7365
7437
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7366
7438
  })),
7367
7439
  enableDebugLogging: clientOptions.enableDebugLogging,
7368
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _167 => _167.unstable_batchedUpdates]),
7440
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _161 => _161.unstable_batchedUpdates]),
7369
7441
  baseUrl,
7370
7442
  unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7371
7443
  unstable_streamData: !!clientOptions.unstable_streamData
@@ -7381,7 +7453,7 @@ function createClient(options) {
7381
7453
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7382
7454
  if (shouldConnect) {
7383
7455
  if (typeof atob === "undefined") {
7384
- if (_optionalChain([clientOptions, 'access', _168 => _168.polyfills, 'optionalAccess', _169 => _169.atob]) === void 0) {
7456
+ if (_optionalChain([clientOptions, 'access', _162 => _162.polyfills, 'optionalAccess', _163 => _163.atob]) === void 0) {
7385
7457
  throw new Error(
7386
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"
7387
7459
  );
@@ -7393,7 +7465,7 @@ function createClient(options) {
7393
7465
  return leaseRoom(newRoomDetails);
7394
7466
  }
7395
7467
  function getRoom(roomId) {
7396
- const room = _optionalChain([roomsById, 'access', _170 => _170.get, 'call', _171 => _171(roomId), 'optionalAccess', _172 => _172.room]);
7468
+ const room = _optionalChain([roomsById, 'access', _164 => _164.get, 'call', _165 => _165(roomId), 'optionalAccess', _166 => _166.room]);
7397
7469
  return room ? room : null;
7398
7470
  }
7399
7471
  function logout() {
@@ -7407,12 +7479,15 @@ function createClient(options) {
7407
7479
  const currentUserIdStore = createStore(null);
7408
7480
  const {
7409
7481
  getInboxNotifications,
7482
+ getInboxNotificationsSince,
7410
7483
  getUnreadInboxNotificationsCount,
7411
7484
  markAllInboxNotificationsAsRead,
7412
- markInboxNotificationAsRead
7485
+ markInboxNotificationAsRead,
7486
+ deleteAllInboxNotifications,
7487
+ deleteInboxNotification
7413
7488
  } = createNotificationsApi({
7414
7489
  baseUrl,
7415
- fetcher: _optionalChain([clientOptions, 'access', _173 => _173.polyfills, 'optionalAccess', _174 => _174.fetch]) || /* istanbul ignore next */
7490
+ fetcher: _optionalChain([clientOptions, 'access', _167 => _167.polyfills, 'optionalAccess', _168 => _168.fetch]) || /* istanbul ignore next */
7416
7491
  fetch,
7417
7492
  authManager,
7418
7493
  currentUserIdStore
@@ -7426,7 +7501,7 @@ function createClient(options) {
7426
7501
  const usersStore = createBatchStore(
7427
7502
  async (batchedUserIds) => {
7428
7503
  const userIds = batchedUserIds.flat();
7429
- const users = await _optionalChain([resolveUsers, 'optionalCall', _175 => _175({ userIds })]);
7504
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
7430
7505
  warnIfNoResolveUsers();
7431
7506
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7432
7507
  },
@@ -7440,7 +7515,7 @@ function createClient(options) {
7440
7515
  const roomsInfoStore = createBatchStore(
7441
7516
  async (batchedRoomIds) => {
7442
7517
  const roomIds = batchedRoomIds.flat();
7443
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _176 => _176({ roomIds })]);
7518
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
7444
7519
  warnIfNoResolveRoomsInfo();
7445
7520
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
7446
7521
  },
@@ -7451,14 +7526,15 @@ function createClient(options) {
7451
7526
  enterRoom,
7452
7527
  getRoom,
7453
7528
  logout,
7529
+ getInboxNotifications,
7530
+ getInboxNotificationsSince,
7531
+ getUnreadInboxNotificationsCount,
7532
+ markAllInboxNotificationsAsRead,
7533
+ markInboxNotificationAsRead,
7534
+ deleteAllInboxNotifications,
7535
+ deleteInboxNotification,
7454
7536
  // Internal
7455
7537
  [kInternal]: {
7456
- notifications: {
7457
- getInboxNotifications,
7458
- getUnreadInboxNotificationsCount,
7459
- markAllInboxNotificationsAsRead,
7460
- markInboxNotificationAsRead
7461
- },
7462
7538
  currentUserIdStore,
7463
7539
  resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
7464
7540
  cacheStore,
@@ -7552,7 +7628,7 @@ var commentBodyElementsTypes = {
7552
7628
  mention: "inline"
7553
7629
  };
7554
7630
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7555
- if (!body || !_optionalChain([body, 'optionalAccess', _177 => _177.content])) {
7631
+ if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
7556
7632
  return;
7557
7633
  }
7558
7634
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -7562,13 +7638,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7562
7638
  for (const block of body.content) {
7563
7639
  if (type === "all" || type === "block") {
7564
7640
  if (guard(block)) {
7565
- _optionalChain([visitor, 'optionalCall', _178 => _178(block)]);
7641
+ _optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
7566
7642
  }
7567
7643
  }
7568
7644
  if (type === "all" || type === "inline") {
7569
7645
  for (const inline of block.children) {
7570
7646
  if (guard(inline)) {
7571
- _optionalChain([visitor, 'optionalCall', _179 => _179(inline)]);
7647
+ _optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
7572
7648
  }
7573
7649
  }
7574
7650
  }
@@ -7593,7 +7669,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
7593
7669
  userIds
7594
7670
  });
7595
7671
  for (const [index, userId] of userIds.entries()) {
7596
- const user = _optionalChain([users, 'optionalAccess', _180 => _180[index]]);
7672
+ const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
7597
7673
  if (user) {
7598
7674
  resolvedUsers.set(userId, user);
7599
7675
  }
@@ -7716,7 +7792,7 @@ var stringifyCommentBodyPlainElements = {
7716
7792
  text: ({ element }) => element.text,
7717
7793
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7718
7794
  mention: ({ element, user }) => {
7719
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
7795
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
7720
7796
  }
7721
7797
  };
7722
7798
  var stringifyCommentBodyHtmlElements = {
@@ -7746,7 +7822,7 @@ var stringifyCommentBodyHtmlElements = {
7746
7822
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
7747
7823
  },
7748
7824
  mention: ({ element, user }) => {
7749
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _182 => _182.name]), () => ( element.id))}</span>`;
7825
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _176 => _176.name]), () => ( element.id))}</span>`;
7750
7826
  }
7751
7827
  };
7752
7828
  var stringifyCommentBodyMarkdownElements = {
@@ -7776,19 +7852,19 @@ var stringifyCommentBodyMarkdownElements = {
7776
7852
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
7777
7853
  },
7778
7854
  mention: ({ element, user }) => {
7779
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _183 => _183.name]), () => ( element.id))}`;
7855
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
7780
7856
  }
7781
7857
  };
7782
7858
  async function stringifyCommentBody(body, options) {
7783
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _184 => _184.format]), () => ( "plain"));
7784
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _185 => _185.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")));
7785
7861
  const elements = {
7786
7862
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
7787
- ..._optionalChain([options, 'optionalAccess', _186 => _186.elements])
7863
+ ..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
7788
7864
  };
7789
7865
  const resolvedUsers = await resolveUsersInCommentBody(
7790
7866
  body,
7791
- _optionalChain([options, 'optionalAccess', _187 => _187.resolveUsers])
7867
+ _optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
7792
7868
  );
7793
7869
  const blocks = body.content.flatMap((block, blockIndex) => {
7794
7870
  switch (block.type) {
@@ -8063,12 +8139,12 @@ function legacy_patchImmutableNode(state, path, update) {
8063
8139
  }
8064
8140
  const newState = Object.assign({}, state);
8065
8141
  for (const key in update.updates) {
8066
- if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
8142
+ if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
8067
8143
  const val = update.node.get(key);
8068
8144
  if (val !== void 0) {
8069
8145
  newState[key] = lsonToJson(val);
8070
8146
  }
8071
- } else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
8147
+ } else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
8072
8148
  delete newState[key];
8073
8149
  }
8074
8150
  }
@@ -8129,12 +8205,12 @@ function legacy_patchImmutableNode(state, path, update) {
8129
8205
  }
8130
8206
  const newState = Object.assign({}, state);
8131
8207
  for (const key in update.updates) {
8132
- if (_optionalChain([update, 'access', _194 => _194.updates, 'access', _195 => _195[key], 'optionalAccess', _196 => _196.type]) === "update") {
8208
+ if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
8133
8209
  const value = update.node.get(key);
8134
8210
  if (value !== void 0) {
8135
8211
  newState[key] = lsonToJson(value);
8136
8212
  }
8137
- } else if (_optionalChain([update, 'access', _197 => _197.updates, 'access', _198 => _198[key], 'optionalAccess', _199 => _199.type]) === "delete") {
8213
+ } else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
8138
8214
  delete newState[key];
8139
8215
  }
8140
8216
  }
@@ -8389,5 +8465,9 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8389
8465
 
8390
8466
 
8391
8467
 
8392
- 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;
8393
8473
  //# sourceMappingURL=index.js.map