@liveblocks/core 2.17.0 → 2.18.0-yjsfactory

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.17.0";
9
+ var PKG_VERSION = "2.18.0-yjsfactory";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -181,6 +181,12 @@ function raise(msg) {
181
181
  function entries(obj) {
182
182
  return Object.entries(obj);
183
183
  }
184
+ function keys(obj) {
185
+ return Object.keys(obj);
186
+ }
187
+ function values(obj) {
188
+ return Object.values(obj);
189
+ }
184
190
  function mapValues(obj, mapFn) {
185
191
  const result = {};
186
192
  for (const pair of Object.entries(obj)) {
@@ -1058,9 +1064,9 @@ function urljoin(baseUrl, path, params) {
1058
1064
  }
1059
1065
  return url2.toString();
1060
1066
  }
1061
- function url(strings, ...values) {
1067
+ function url(strings, ...values2) {
1062
1068
  return strings.reduce(
1063
- (result, str, i) => result + encodeURIComponent(_nullishCoalesce(values[i - 1], () => ( ""))) + str
1069
+ (result, str, i) => result + encodeURIComponent(_nullishCoalesce(values2[i - 1], () => ( ""))) + str
1064
1070
  );
1065
1071
  }
1066
1072
 
@@ -1728,9 +1734,24 @@ function createApiClient({
1728
1734
  await authManager.getAuthValue({ requestedScope: "comments:read" })
1729
1735
  );
1730
1736
  }
1737
+ async function getUserNotificationSettings(options) {
1738
+ return httpClient.get(
1739
+ url`/v2/c/notification-settings`,
1740
+ await authManager.getAuthValue({ requestedScope: "comments:read" }),
1741
+ void 0,
1742
+ { signal: _optionalChain([options, 'optionalAccess', _18 => _18.signal]) }
1743
+ );
1744
+ }
1745
+ async function updateUserNotificationSettings(settings) {
1746
+ return httpClient.post(
1747
+ url`/v2/c/notification-settings`,
1748
+ await authManager.getAuthValue({ requestedScope: "comments:read" }),
1749
+ settings
1750
+ );
1751
+ }
1731
1752
  async function getUserThreads_experimental(options) {
1732
1753
  let query;
1733
- if (_optionalChain([options, 'optionalAccess', _18 => _18.query])) {
1754
+ if (_optionalChain([options, 'optionalAccess', _19 => _19.query])) {
1734
1755
  query = objectToQuery(options.query);
1735
1756
  }
1736
1757
  const PAGE_SIZE = 50;
@@ -1738,7 +1759,7 @@ function createApiClient({
1738
1759
  url`/v2/c/threads`,
1739
1760
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
1740
1761
  {
1741
- cursor: _optionalChain([options, 'optionalAccess', _19 => _19.cursor]),
1762
+ cursor: _optionalChain([options, 'optionalAccess', _20 => _20.cursor]),
1742
1763
  query,
1743
1764
  limit: PAGE_SIZE
1744
1765
  }
@@ -1790,10 +1811,10 @@ function createApiClient({
1790
1811
  removeReaction,
1791
1812
  markThreadAsResolved,
1792
1813
  markThreadAsUnresolved,
1793
- // Room notifications
1794
1814
  markRoomInboxNotificationAsRead,
1795
- updateNotificationSettings,
1815
+ // Room notifications
1796
1816
  getNotificationSettings,
1817
+ updateNotificationSettings,
1797
1818
  // Room text editor
1798
1819
  createTextMention,
1799
1820
  deleteTextMention,
@@ -1817,6 +1838,8 @@ function createApiClient({
1817
1838
  markInboxNotificationAsRead,
1818
1839
  deleteAllInboxNotifications,
1819
1840
  deleteInboxNotification,
1841
+ getUserNotificationSettings,
1842
+ updateUserNotificationSettings,
1820
1843
  // User threads
1821
1844
  getUserThreads_experimental,
1822
1845
  getUserThreadsSince_experimental,
@@ -1865,7 +1888,7 @@ var HttpClient = class {
1865
1888
  // These headers are default, but can be overriden by custom headers
1866
1889
  "Content-Type": "application/json; charset=utf-8",
1867
1890
  // Possible header overrides
1868
- ..._optionalChain([options, 'optionalAccess', _20 => _20.headers]),
1891
+ ..._optionalChain([options, 'optionalAccess', _21 => _21.headers]),
1869
1892
  // Cannot be overriden by custom headers
1870
1893
  Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
1871
1894
  "X-LB-Client": PKG_VERSION || "dev"
@@ -2340,7 +2363,7 @@ var FSM = class {
2340
2363
  });
2341
2364
  }
2342
2365
  #getTargetFn(eventName) {
2343
- return _optionalChain([this, 'access', _21 => _21.#allowedTransitions, 'access', _22 => _22.get, 'call', _23 => _23(this.currentState), 'optionalAccess', _24 => _24.get, 'call', _25 => _25(eventName)]);
2366
+ return _optionalChain([this, 'access', _22 => _22.#allowedTransitions, 'access', _23 => _23.get, 'call', _24 => _24(this.currentState), 'optionalAccess', _25 => _25.get, 'call', _26 => _26(eventName)]);
2344
2367
  }
2345
2368
  /**
2346
2369
  * Exits the current state, and executes any necessary cleanup functions.
@@ -2357,7 +2380,7 @@ var FSM = class {
2357
2380
  this.#currentContext.allowPatching((patchableContext) => {
2358
2381
  levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
2359
2382
  for (let i = 0; i < levels; i++) {
2360
- _optionalChain([this, 'access', _26 => _26.#cleanupStack, 'access', _27 => _27.pop, 'call', _28 => _28(), 'optionalCall', _29 => _29(patchableContext)]);
2383
+ _optionalChain([this, 'access', _27 => _27.#cleanupStack, 'access', _28 => _28.pop, 'call', _29 => _29(), 'optionalCall', _30 => _30(patchableContext)]);
2361
2384
  }
2362
2385
  });
2363
2386
  }
@@ -2373,7 +2396,7 @@ var FSM = class {
2373
2396
  this.#currentContext.allowPatching((patchableContext) => {
2374
2397
  for (const pattern of enterPatterns) {
2375
2398
  const enterFn = this.#enterFns.get(pattern);
2376
- const cleanupFn = _optionalChain([enterFn, 'optionalCall', _30 => _30(patchableContext)]);
2399
+ const cleanupFn = _optionalChain([enterFn, 'optionalCall', _31 => _31(patchableContext)]);
2377
2400
  if (typeof cleanupFn === "function") {
2378
2401
  this.#cleanupStack.push(cleanupFn);
2379
2402
  } else {
@@ -2767,7 +2790,7 @@ function createConnectionStateMachine(delegates, options) {
2767
2790
  }
2768
2791
  function waitForActorId(event) {
2769
2792
  const serverMsg = tryParseJson(event.data);
2770
- if (_optionalChain([serverMsg, 'optionalAccess', _31 => _31.type]) === 104 /* ROOM_STATE */) {
2793
+ if (_optionalChain([serverMsg, 'optionalAccess', _32 => _32.type]) === 104 /* ROOM_STATE */) {
2771
2794
  didReceiveActor();
2772
2795
  }
2773
2796
  }
@@ -2876,12 +2899,12 @@ function createConnectionStateMachine(delegates, options) {
2876
2899
  const sendHeartbeat = {
2877
2900
  target: "@ok.awaiting-pong",
2878
2901
  effect: (ctx) => {
2879
- _optionalChain([ctx, 'access', _32 => _32.socket, 'optionalAccess', _33 => _33.send, 'call', _34 => _34("ping")]);
2902
+ _optionalChain([ctx, 'access', _33 => _33.socket, 'optionalAccess', _34 => _34.send, 'call', _35 => _35("ping")]);
2880
2903
  }
2881
2904
  };
2882
2905
  const maybeHeartbeat = () => {
2883
2906
  const doc = typeof document !== "undefined" ? document : void 0;
2884
- const canZombie = _optionalChain([doc, 'optionalAccess', _35 => _35.visibilityState]) === "hidden" && delegates.canZombie();
2907
+ const canZombie = _optionalChain([doc, 'optionalAccess', _36 => _36.visibilityState]) === "hidden" && delegates.canZombie();
2885
2908
  return canZombie ? "@idle.zombie" : sendHeartbeat;
2886
2909
  };
2887
2910
  machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
@@ -2920,7 +2943,7 @@ function createConnectionStateMachine(delegates, options) {
2920
2943
  // socket, or not. So always check to see if the socket is still OPEN or
2921
2944
  // not. When still OPEN, don't transition.
2922
2945
  EXPLICIT_SOCKET_ERROR: (_, context) => {
2923
- if (_optionalChain([context, 'access', _36 => _36.socket, 'optionalAccess', _37 => _37.readyState]) === 1) {
2946
+ if (_optionalChain([context, 'access', _37 => _37.socket, 'optionalAccess', _38 => _38.readyState]) === 1) {
2924
2947
  return null;
2925
2948
  }
2926
2949
  return {
@@ -2972,17 +2995,17 @@ function createConnectionStateMachine(delegates, options) {
2972
2995
  machine.send({ type: "NAVIGATOR_ONLINE" });
2973
2996
  }
2974
2997
  function onVisibilityChange() {
2975
- if (_optionalChain([doc, 'optionalAccess', _38 => _38.visibilityState]) === "visible") {
2998
+ if (_optionalChain([doc, 'optionalAccess', _39 => _39.visibilityState]) === "visible") {
2976
2999
  machine.send({ type: "WINDOW_GOT_FOCUS" });
2977
3000
  }
2978
3001
  }
2979
- _optionalChain([win, 'optionalAccess', _39 => _39.addEventListener, 'call', _40 => _40("online", onNetworkBackOnline)]);
2980
- _optionalChain([win, 'optionalAccess', _41 => _41.addEventListener, 'call', _42 => _42("offline", onNetworkOffline)]);
2981
- _optionalChain([root, 'optionalAccess', _43 => _43.addEventListener, 'call', _44 => _44("visibilitychange", onVisibilityChange)]);
3002
+ _optionalChain([win, 'optionalAccess', _40 => _40.addEventListener, 'call', _41 => _41("online", onNetworkBackOnline)]);
3003
+ _optionalChain([win, 'optionalAccess', _42 => _42.addEventListener, 'call', _43 => _43("offline", onNetworkOffline)]);
3004
+ _optionalChain([root, 'optionalAccess', _44 => _44.addEventListener, 'call', _45 => _45("visibilitychange", onVisibilityChange)]);
2982
3005
  return () => {
2983
- _optionalChain([root, 'optionalAccess', _45 => _45.removeEventListener, 'call', _46 => _46("visibilitychange", onVisibilityChange)]);
2984
- _optionalChain([win, 'optionalAccess', _47 => _47.removeEventListener, 'call', _48 => _48("online", onNetworkBackOnline)]);
2985
- _optionalChain([win, 'optionalAccess', _49 => _49.removeEventListener, 'call', _50 => _50("offline", onNetworkOffline)]);
3006
+ _optionalChain([root, 'optionalAccess', _46 => _46.removeEventListener, 'call', _47 => _47("visibilitychange", onVisibilityChange)]);
3007
+ _optionalChain([win, 'optionalAccess', _48 => _48.removeEventListener, 'call', _49 => _49("online", onNetworkBackOnline)]);
3008
+ _optionalChain([win, 'optionalAccess', _50 => _50.removeEventListener, 'call', _51 => _51("offline", onNetworkOffline)]);
2986
3009
  teardownSocket(ctx.socket);
2987
3010
  };
2988
3011
  });
@@ -3071,7 +3094,7 @@ var ManagedSocket = class {
3071
3094
  * message if this is somehow impossible.
3072
3095
  */
3073
3096
  send(data) {
3074
- const socket = _optionalChain([this, 'access', _51 => _51.#machine, 'access', _52 => _52.context, 'optionalAccess', _53 => _53.socket]);
3097
+ const socket = _optionalChain([this, 'access', _52 => _52.#machine, 'access', _53 => _53.context, 'optionalAccess', _54 => _54.socket]);
3075
3098
  if (socket === null) {
3076
3099
  warn("Cannot send: not connected yet", data);
3077
3100
  } else if (socket.readyState !== 1) {
@@ -3175,7 +3198,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3175
3198
  return void 0;
3176
3199
  }
3177
3200
  async function makeAuthRequest(options) {
3178
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _54 => _54.polyfills, 'optionalAccess', _55 => _55.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
3201
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _55 => _55.polyfills, 'optionalAccess', _56 => _56.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
3179
3202
  if (authentication.type === "private") {
3180
3203
  if (fetcher === void 0) {
3181
3204
  throw new StopRetrying(
@@ -3191,7 +3214,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3191
3214
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
3192
3215
  );
3193
3216
  }
3194
- _optionalChain([onAuthenticate, 'optionalCall', _56 => _56(parsed.parsed)]);
3217
+ _optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
3195
3218
  return parsed;
3196
3219
  }
3197
3220
  if (authentication.type === "custom") {
@@ -3199,7 +3222,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3199
3222
  if (response && typeof response === "object") {
3200
3223
  if (typeof response.token === "string") {
3201
3224
  const parsed = parseAuthToken(response.token);
3202
- _optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
3225
+ _optionalChain([onAuthenticate, 'optionalCall', _58 => _58(parsed.parsed)]);
3203
3226
  return parsed;
3204
3227
  } else if (typeof response.error === "string") {
3205
3228
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -3360,7 +3383,7 @@ function sendToPanel(message, options) {
3360
3383
  ...message,
3361
3384
  source: "liveblocks-devtools-client"
3362
3385
  };
3363
- if (!(_optionalChain([options, 'optionalAccess', _58 => _58.force]) || _bridgeActive)) {
3386
+ if (!(_optionalChain([options, 'optionalAccess', _59 => _59.force]) || _bridgeActive)) {
3364
3387
  return;
3365
3388
  }
3366
3389
  window.postMessage(fullMsg, "*");
@@ -3368,7 +3391,7 @@ function sendToPanel(message, options) {
3368
3391
  var eventSource = makeEventSource();
3369
3392
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
3370
3393
  window.addEventListener("message", (event) => {
3371
- if (event.source === window && _optionalChain([event, 'access', _59 => _59.data, 'optionalAccess', _60 => _60.source]) === "liveblocks-devtools-panel") {
3394
+ if (event.source === window && _optionalChain([event, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.source]) === "liveblocks-devtools-panel") {
3372
3395
  eventSource.notify(event.data);
3373
3396
  } else {
3374
3397
  }
@@ -3510,7 +3533,7 @@ function fullSync(room) {
3510
3533
  msg: "room::sync::full",
3511
3534
  roomId: room.id,
3512
3535
  status: room.getStatus(),
3513
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _61 => _61.toTreeNode, 'call', _62 => _62("root"), 'access', _63 => _63.payload]), () => ( null)),
3536
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _62 => _62.toTreeNode, 'call', _63 => _63("root"), 'access', _64 => _64.payload]), () => ( null)),
3514
3537
  me,
3515
3538
  others
3516
3539
  });
@@ -3934,7 +3957,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
3934
3957
  return [
3935
3958
  {
3936
3959
  type: 8 /* CREATE_REGISTER */,
3937
- opId: _optionalChain([pool, 'optionalAccess', _64 => _64.generateOpId, 'call', _65 => _65()]),
3960
+ opId: _optionalChain([pool, 'optionalAccess', _65 => _65.generateOpId, 'call', _66 => _66()]),
3938
3961
  id: this._id,
3939
3962
  parentId,
3940
3963
  parentKey,
@@ -4040,7 +4063,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4040
4063
  const ops = [];
4041
4064
  const op = {
4042
4065
  id: this._id,
4043
- opId: _optionalChain([pool, 'optionalAccess', _66 => _66.generateOpId, 'call', _67 => _67()]),
4066
+ opId: _optionalChain([pool, 'optionalAccess', _67 => _67.generateOpId, 'call', _68 => _68()]),
4044
4067
  type: 2 /* CREATE_LIST */,
4045
4068
  parentId,
4046
4069
  parentKey
@@ -4311,7 +4334,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4311
4334
  #applyInsertUndoRedo(op) {
4312
4335
  const { id, parentKey: key } = op;
4313
4336
  const child = creationOpToLiveNode(op);
4314
- if (_optionalChain([this, 'access', _68 => _68._pool, 'optionalAccess', _69 => _69.getNode, 'call', _70 => _70(id)]) !== void 0) {
4337
+ if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
4315
4338
  return { modified: false };
4316
4339
  }
4317
4340
  child._attach(id, nn(this._pool));
@@ -4319,8 +4342,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
4319
4342
  const existingItemIndex = this._indexOfPosition(key);
4320
4343
  let newKey = key;
4321
4344
  if (existingItemIndex !== -1) {
4322
- const before2 = _optionalChain([this, 'access', _71 => _71.#items, 'access', _72 => _72[existingItemIndex], 'optionalAccess', _73 => _73._parentPos]);
4323
- const after2 = _optionalChain([this, 'access', _74 => _74.#items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]);
4345
+ const before2 = _optionalChain([this, 'access', _72 => _72.#items, 'access', _73 => _73[existingItemIndex], 'optionalAccess', _74 => _74._parentPos]);
4346
+ const after2 = _optionalChain([this, 'access', _75 => _75.#items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]);
4324
4347
  newKey = makePosition(before2, after2);
4325
4348
  child._setParentLink(this, newKey);
4326
4349
  }
@@ -4334,7 +4357,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4334
4357
  #applySetUndoRedo(op) {
4335
4358
  const { id, parentKey: key } = op;
4336
4359
  const child = creationOpToLiveNode(op);
4337
- if (_optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.getNode, 'call', _79 => _79(id)]) !== void 0) {
4360
+ if (_optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.getNode, 'call', _80 => _80(id)]) !== void 0) {
4338
4361
  return { modified: false };
4339
4362
  }
4340
4363
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -4455,7 +4478,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4455
4478
  } else {
4456
4479
  this.#items[existingItemIndex]._setParentLink(
4457
4480
  this,
4458
- makePosition(newKey, _optionalChain([this, 'access', _80 => _80.#items, 'access', _81 => _81[existingItemIndex + 1], 'optionalAccess', _82 => _82._parentPos]))
4481
+ makePosition(newKey, _optionalChain([this, 'access', _81 => _81.#items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
4459
4482
  );
4460
4483
  const previousIndex = this.#items.indexOf(child);
4461
4484
  child._setParentLink(this, newKey);
@@ -4480,7 +4503,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4480
4503
  if (existingItemIndex !== -1) {
4481
4504
  this.#items[existingItemIndex]._setParentLink(
4482
4505
  this,
4483
- makePosition(newKey, _optionalChain([this, 'access', _83 => _83.#items, 'access', _84 => _84[existingItemIndex + 1], 'optionalAccess', _85 => _85._parentPos]))
4506
+ makePosition(newKey, _optionalChain([this, 'access', _84 => _84.#items, 'access', _85 => _85[existingItemIndex + 1], 'optionalAccess', _86 => _86._parentPos]))
4484
4507
  );
4485
4508
  }
4486
4509
  child._setParentLink(this, newKey);
@@ -4499,7 +4522,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4499
4522
  if (existingItemIndex !== -1) {
4500
4523
  this.#items[existingItemIndex]._setParentLink(
4501
4524
  this,
4502
- makePosition(newKey, _optionalChain([this, 'access', _86 => _86.#items, 'access', _87 => _87[existingItemIndex + 1], 'optionalAccess', _88 => _88._parentPos]))
4525
+ makePosition(newKey, _optionalChain([this, 'access', _87 => _87.#items, 'access', _88 => _88[existingItemIndex + 1], 'optionalAccess', _89 => _89._parentPos]))
4503
4526
  );
4504
4527
  }
4505
4528
  child._setParentLink(this, newKey);
@@ -4526,7 +4549,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4526
4549
  if (existingItemIndex !== -1) {
4527
4550
  this.#items[existingItemIndex]._setParentLink(
4528
4551
  this,
4529
- makePosition(newKey, _optionalChain([this, 'access', _89 => _89.#items, 'access', _90 => _90[existingItemIndex + 1], 'optionalAccess', _91 => _91._parentPos]))
4552
+ makePosition(newKey, _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex + 1], 'optionalAccess', _92 => _92._parentPos]))
4530
4553
  );
4531
4554
  }
4532
4555
  child._setParentLink(this, newKey);
@@ -4584,7 +4607,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4584
4607
  * @param element The element to add to the end of the LiveList.
4585
4608
  */
4586
4609
  push(element) {
4587
- _optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
4610
+ _optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
4588
4611
  return this.insert(element, this.length);
4589
4612
  }
4590
4613
  /**
@@ -4593,7 +4616,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4593
4616
  * @param index The index at which you want to insert the element.
4594
4617
  */
4595
4618
  insert(element, index) {
4596
- _optionalChain([this, 'access', _95 => _95._pool, 'optionalAccess', _96 => _96.assertStorageIsWritable, 'call', _97 => _97()]);
4619
+ _optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
4597
4620
  if (index < 0 || index > this.#items.length) {
4598
4621
  throw new Error(
4599
4622
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -4623,7 +4646,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4623
4646
  * @param targetIndex The index where the element should be after moving.
4624
4647
  */
4625
4648
  move(index, targetIndex) {
4626
- _optionalChain([this, 'access', _98 => _98._pool, 'optionalAccess', _99 => _99.assertStorageIsWritable, 'call', _100 => _100()]);
4649
+ _optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
4627
4650
  if (targetIndex < 0) {
4628
4651
  throw new Error("targetIndex cannot be less than 0");
4629
4652
  }
@@ -4681,7 +4704,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4681
4704
  * @param index The index of the element to delete
4682
4705
  */
4683
4706
  delete(index) {
4684
- _optionalChain([this, 'access', _101 => _101._pool, 'optionalAccess', _102 => _102.assertStorageIsWritable, 'call', _103 => _103()]);
4707
+ _optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
4685
4708
  if (index < 0 || index >= this.#items.length) {
4686
4709
  throw new Error(
4687
4710
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4714,7 +4737,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4714
4737
  }
4715
4738
  }
4716
4739
  clear() {
4717
- _optionalChain([this, 'access', _104 => _104._pool, 'optionalAccess', _105 => _105.assertStorageIsWritable, 'call', _106 => _106()]);
4740
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4718
4741
  if (this._pool) {
4719
4742
  const ops = [];
4720
4743
  const reverseOps = [];
@@ -4748,7 +4771,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4748
4771
  }
4749
4772
  }
4750
4773
  set(index, item) {
4751
- _optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.assertStorageIsWritable, 'call', _109 => _109()]);
4774
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4752
4775
  if (index < 0 || index >= this.#items.length) {
4753
4776
  throw new Error(
4754
4777
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4894,7 +4917,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4894
4917
  #shiftItemPosition(index, key) {
4895
4918
  const shiftedPosition = makePosition(
4896
4919
  key,
4897
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[index + 1], 'optionalAccess', _112 => _112._parentPos]) : void 0
4920
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[index + 1], 'optionalAccess', _113 => _113._parentPos]) : void 0
4898
4921
  );
4899
4922
  this.#items[index]._setParentLink(this, shiftedPosition);
4900
4923
  }
@@ -5019,7 +5042,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5019
5042
  const ops = [];
5020
5043
  const op = {
5021
5044
  id: this._id,
5022
- opId: _optionalChain([pool, 'optionalAccess', _113 => _113.generateOpId, 'call', _114 => _114()]),
5045
+ opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
5023
5046
  type: 7 /* CREATE_MAP */,
5024
5047
  parentId,
5025
5048
  parentKey
@@ -5154,7 +5177,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5154
5177
  * @param value The value of the element to add. Should be serializable to JSON.
5155
5178
  */
5156
5179
  set(key, value) {
5157
- _optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
5180
+ _optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.assertStorageIsWritable, 'call', _118 => _118()]);
5158
5181
  const oldValue = this.#map.get(key);
5159
5182
  if (oldValue) {
5160
5183
  oldValue._detach();
@@ -5200,7 +5223,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5200
5223
  * @returns true if an element existed and has been removed, or false if the element does not exist.
5201
5224
  */
5202
5225
  delete(key) {
5203
- _optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.assertStorageIsWritable, 'call', _120 => _120()]);
5226
+ _optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.assertStorageIsWritable, 'call', _121 => _121()]);
5204
5227
  const item = this.#map.get(key);
5205
5228
  if (item === void 0) {
5206
5229
  return false;
@@ -5379,7 +5402,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5379
5402
  if (this._id === void 0) {
5380
5403
  throw new Error("Cannot serialize item is not attached");
5381
5404
  }
5382
- const opId = _optionalChain([pool, 'optionalAccess', _121 => _121.generateOpId, 'call', _122 => _122()]);
5405
+ const opId = _optionalChain([pool, 'optionalAccess', _122 => _122.generateOpId, 'call', _123 => _123()]);
5383
5406
  const ops = [];
5384
5407
  const op = {
5385
5408
  type: 4 /* CREATE_OBJECT */,
@@ -5651,7 +5674,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5651
5674
  * @param value The value of the property to add
5652
5675
  */
5653
5676
  set(key, value) {
5654
- _optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
5677
+ _optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
5655
5678
  this.update({ [key]: value });
5656
5679
  }
5657
5680
  /**
@@ -5666,7 +5689,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5666
5689
  * @param key The key of the property to delete
5667
5690
  */
5668
5691
  delete(key) {
5669
- _optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
5692
+ _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
5670
5693
  const keyAsString = key;
5671
5694
  const oldValue = this.#map.get(keyAsString);
5672
5695
  if (oldValue === void 0) {
@@ -5719,7 +5742,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5719
5742
  * @param patch The object used to overrides properties
5720
5743
  */
5721
5744
  update(patch) {
5722
- _optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
5745
+ _optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
5723
5746
  if (this._pool === void 0 || this._id === void 0) {
5724
5747
  for (const key in patch) {
5725
5748
  const newValue = patch[key];
@@ -6339,6 +6362,8 @@ function defaultMessageFromContext(context) {
6339
6362
  return "Could not delete all inbox notifications";
6340
6363
  case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
6341
6364
  return "Could not update notification settings";
6365
+ case "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR":
6366
+ return "Could not update user notification settings";
6342
6367
  default:
6343
6368
  return assertNever(context, "Unhandled case");
6344
6369
  }
@@ -6368,15 +6393,15 @@ function installBackgroundTabSpy() {
6368
6393
  const doc = typeof document !== "undefined" ? document : void 0;
6369
6394
  const inBackgroundSince = { current: null };
6370
6395
  function onVisibilityChange() {
6371
- if (_optionalChain([doc, 'optionalAccess', _132 => _132.visibilityState]) === "hidden") {
6396
+ if (_optionalChain([doc, 'optionalAccess', _133 => _133.visibilityState]) === "hidden") {
6372
6397
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
6373
6398
  } else {
6374
6399
  inBackgroundSince.current = null;
6375
6400
  }
6376
6401
  }
6377
- _optionalChain([doc, 'optionalAccess', _133 => _133.addEventListener, 'call', _134 => _134("visibilitychange", onVisibilityChange)]);
6402
+ _optionalChain([doc, 'optionalAccess', _134 => _134.addEventListener, 'call', _135 => _135("visibilitychange", onVisibilityChange)]);
6378
6403
  const unsub = () => {
6379
- _optionalChain([doc, 'optionalAccess', _135 => _135.removeEventListener, 'call', _136 => _136("visibilitychange", onVisibilityChange)]);
6404
+ _optionalChain([doc, 'optionalAccess', _136 => _136.removeEventListener, 'call', _137 => _137("visibilitychange", onVisibilityChange)]);
6380
6405
  };
6381
6406
  return [inBackgroundSince, unsub];
6382
6407
  }
@@ -6561,7 +6586,7 @@ function createRoom(options, config) {
6561
6586
  }
6562
6587
  },
6563
6588
  assertStorageIsWritable: () => {
6564
- const scopes = _optionalChain([context, 'access', _137 => _137.dynamicSessionInfoSig, 'access', _138 => _138.get, 'call', _139 => _139(), 'optionalAccess', _140 => _140.scopes]);
6589
+ const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
6565
6590
  if (scopes === void 0) {
6566
6591
  return;
6567
6592
  }
@@ -6586,7 +6611,8 @@ function createRoom(options, config) {
6586
6611
  storageDidLoad: makeEventSource(),
6587
6612
  storageStatus: makeEventSource(),
6588
6613
  ydoc: makeEventSource(),
6589
- comments: makeEventSource()
6614
+ comments: makeEventSource(),
6615
+ roomWillDestroy: makeEventSource()
6590
6616
  };
6591
6617
  const roomId = config.roomId;
6592
6618
  async function createTextMention(userId, mentionId) {
@@ -6687,7 +6713,7 @@ function createRoom(options, config) {
6687
6713
  }
6688
6714
  case "experimental-fallback-to-http": {
6689
6715
  warn("Message is too large for websockets, so sending over HTTP instead");
6690
- const nonce = _nullishCoalesce(_optionalChain([context, 'access', _141 => _141.dynamicSessionInfoSig, 'access', _142 => _142.get, 'call', _143 => _143(), 'optionalAccess', _144 => _144.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
6716
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _142 => _142.dynamicSessionInfoSig, 'access', _143 => _143.get, 'call', _144 => _144(), 'optionalAccess', _145 => _145.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
6691
6717
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
6692
6718
  if (!resp.ok && resp.status === 403) {
6693
6719
  managedSocket.reconnect();
@@ -6738,7 +6764,7 @@ function createRoom(options, config) {
6738
6764
  } else {
6739
6765
  context.root = LiveObject._fromItems(message.items, pool);
6740
6766
  }
6741
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _145 => _145.get, 'call', _146 => _146(), 'optionalAccess', _147 => _147.canWrite]), () => ( true));
6767
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _146 => _146.get, 'call', _147 => _147(), 'optionalAccess', _148 => _148.canWrite]), () => ( true));
6742
6768
  const stackSizeBefore = context.undoStack.length;
6743
6769
  for (const key in context.initialStorage) {
6744
6770
  if (context.root.get(key) === void 0) {
@@ -6941,7 +6967,7 @@ function createRoom(options, config) {
6941
6967
  }
6942
6968
  context.myPresence.patch(patch);
6943
6969
  if (context.activeBatch) {
6944
- if (_optionalChain([options2, 'optionalAccess', _148 => _148.addToHistory])) {
6970
+ if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
6945
6971
  context.activeBatch.reverseOps.unshift({
6946
6972
  type: "presence",
6947
6973
  data: oldValues
@@ -6950,7 +6976,7 @@ function createRoom(options, config) {
6950
6976
  context.activeBatch.updates.presence = true;
6951
6977
  } else {
6952
6978
  flushNowOrSoon();
6953
- if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
6979
+ if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
6954
6980
  addToUndoStack([{ type: "presence", data: oldValues }]);
6955
6981
  }
6956
6982
  notify({ presence: true });
@@ -7147,7 +7173,7 @@ function createRoom(options, config) {
7147
7173
  if (process.env.NODE_ENV !== "production") {
7148
7174
  const traces = /* @__PURE__ */ new Set();
7149
7175
  for (const opId of message.opIds) {
7150
- const trace = _optionalChain([context, 'access', _150 => _150.opStackTraces, 'optionalAccess', _151 => _151.get, 'call', _152 => _152(opId)]);
7176
+ const trace = _optionalChain([context, 'access', _151 => _151.opStackTraces, 'optionalAccess', _152 => _152.get, 'call', _153 => _153(opId)]);
7151
7177
  if (trace) {
7152
7178
  traces.add(trace);
7153
7179
  }
@@ -7281,7 +7307,7 @@ ${Array.from(traces).join("\n\n")}`
7281
7307
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
7282
7308
  createOrUpdateRootFromMessage(message);
7283
7309
  applyAndSendOps(unacknowledgedOps);
7284
- _optionalChain([_resolveStoragePromise, 'optionalCall', _153 => _153()]);
7310
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _154 => _154()]);
7285
7311
  notifyStorageStatus();
7286
7312
  eventHub.storageDidLoad.notify();
7287
7313
  }
@@ -7491,7 +7517,8 @@ ${Array.from(traces).join("\n\n")}`
7491
7517
  storageDidLoad: eventHub.storageDidLoad.observable,
7492
7518
  storageStatus: eventHub.storageStatus.observable,
7493
7519
  ydoc: eventHub.ydoc.observable,
7494
- comments: eventHub.comments.observable
7520
+ comments: eventHub.comments.observable,
7521
+ roomWillDestroy: eventHub.roomWillDestroy.observable
7495
7522
  };
7496
7523
  async function getThreadsSince(options2) {
7497
7524
  return httpClient.getThreadsSince({
@@ -7503,8 +7530,8 @@ ${Array.from(traces).join("\n\n")}`
7503
7530
  async function getThreads(options2) {
7504
7531
  return httpClient.getThreads({
7505
7532
  roomId,
7506
- query: _optionalChain([options2, 'optionalAccess', _154 => _154.query]),
7507
- cursor: _optionalChain([options2, 'optionalAccess', _155 => _155.cursor])
7533
+ query: _optionalChain([options2, 'optionalAccess', _155 => _155.query]),
7534
+ cursor: _optionalChain([options2, 'optionalAccess', _156 => _156.cursor])
7508
7535
  });
7509
7536
  }
7510
7537
  async function getThread(threadId) {
@@ -7605,7 +7632,7 @@ ${Array.from(traces).join("\n\n")}`
7605
7632
  function getNotificationSettings(options2) {
7606
7633
  return httpClient.getNotificationSettings({
7607
7634
  roomId,
7608
- signal: _optionalChain([options2, 'optionalAccess', _156 => _156.signal])
7635
+ signal: _optionalChain([options2, 'optionalAccess', _157 => _157.signal])
7609
7636
  });
7610
7637
  }
7611
7638
  function updateNotificationSettings(settings) {
@@ -7627,7 +7654,7 @@ ${Array.from(traces).join("\n\n")}`
7627
7654
  {
7628
7655
  [kInternal]: {
7629
7656
  get presenceBuffer() {
7630
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _157 => _157.buffer, 'access', _158 => _158.presenceUpdates, 'optionalAccess', _159 => _159.data]), () => ( null)));
7657
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _158 => _158.buffer, 'access', _159 => _159.presenceUpdates, 'optionalAccess', _160 => _160.data]), () => ( null)));
7631
7658
  },
7632
7659
  // prettier-ignore
7633
7660
  get undoStack() {
@@ -7642,9 +7669,9 @@ ${Array.from(traces).join("\n\n")}`
7642
7669
  return context.yjsProvider;
7643
7670
  },
7644
7671
  setYjsProvider(newProvider) {
7645
- _optionalChain([context, 'access', _160 => _160.yjsProvider, 'optionalAccess', _161 => _161.off, 'call', _162 => _162("status", yjsStatusDidChange)]);
7672
+ _optionalChain([context, 'access', _161 => _161.yjsProvider, 'optionalAccess', _162 => _162.off, 'call', _163 => _163("status", yjsStatusDidChange)]);
7646
7673
  context.yjsProvider = newProvider;
7647
- _optionalChain([newProvider, 'optionalAccess', _163 => _163.on, 'call', _164 => _164("status", yjsStatusDidChange)]);
7674
+ _optionalChain([newProvider, 'optionalAccess', _164 => _164.on, 'call', _165 => _165("status", yjsStatusDidChange)]);
7648
7675
  context.yjsProviderDidChange.notify();
7649
7676
  },
7650
7677
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -7685,11 +7712,17 @@ ${Array.from(traces).join("\n\n")}`
7685
7712
  reconnect: () => managedSocket.reconnect(),
7686
7713
  disconnect: () => managedSocket.disconnect(),
7687
7714
  destroy: () => {
7715
+ const { roomWillDestroy, ...eventsExceptDestroy } = eventHub;
7716
+ for (const source of Object.values(eventsExceptDestroy)) {
7717
+ source[Symbol.dispose]();
7718
+ }
7719
+ eventHub.roomWillDestroy.notify();
7720
+ _optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
7688
7721
  syncSourceForStorage.destroy();
7689
- _optionalChain([context, 'access', _165 => _165.yjsProvider, 'optionalAccess', _166 => _166.off, 'call', _167 => _167("status", yjsStatusDidChange)]);
7690
7722
  syncSourceForYjs.destroy();
7691
7723
  uninstallBgTabSpy();
7692
7724
  managedSocket.destroy();
7725
+ roomWillDestroy[Symbol.dispose]();
7693
7726
  },
7694
7727
  // Presence
7695
7728
  updatePresence,
@@ -7830,7 +7863,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
7830
7863
  }
7831
7864
  if (isLiveNode(first)) {
7832
7865
  const node = first;
7833
- if (_optionalChain([options, 'optionalAccess', _168 => _168.isDeep])) {
7866
+ if (_optionalChain([options, 'optionalAccess', _169 => _169.isDeep])) {
7834
7867
  const storageCallback = second;
7835
7868
  return subscribeToLiveStructureDeeply(node, storageCallback);
7836
7869
  } else {
@@ -7909,8 +7942,8 @@ function createClient(options) {
7909
7942
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
7910
7943
  currentUserId.set(() => userId);
7911
7944
  });
7912
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _169 => _169.polyfills, 'optionalAccess', _170 => _170.fetch]) || /* istanbul ignore next */
7913
- _optionalChain([globalThis, 'access', _171 => _171.fetch, 'optionalAccess', _172 => _172.bind, 'call', _173 => _173(globalThis)]);
7945
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _170 => _170.polyfills, 'optionalAccess', _171 => _171.fetch]) || /* istanbul ignore next */
7946
+ _optionalChain([globalThis, 'access', _172 => _172.fetch, 'optionalAccess', _173 => _173.bind, 'call', _174 => _174(globalThis)]);
7914
7947
  const httpClient = createApiClient({
7915
7948
  baseUrl,
7916
7949
  fetchPolyfill,
@@ -7961,7 +7994,7 @@ function createClient(options) {
7961
7994
  createSocket: makeCreateSocketDelegateForRoom(
7962
7995
  roomId,
7963
7996
  baseUrl,
7964
- _optionalChain([clientOptions, 'access', _174 => _174.polyfills, 'optionalAccess', _175 => _175.WebSocket])
7997
+ _optionalChain([clientOptions, 'access', _175 => _175.polyfills, 'optionalAccess', _176 => _176.WebSocket])
7965
7998
  ),
7966
7999
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7967
8000
  })),
@@ -7984,7 +8017,7 @@ function createClient(options) {
7984
8017
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7985
8018
  if (shouldConnect) {
7986
8019
  if (typeof atob === "undefined") {
7987
- if (_optionalChain([clientOptions, 'access', _176 => _176.polyfills, 'optionalAccess', _177 => _177.atob]) === void 0) {
8020
+ if (_optionalChain([clientOptions, 'access', _177 => _177.polyfills, 'optionalAccess', _178 => _178.atob]) === void 0) {
7988
8021
  throw new Error(
7989
8022
  "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"
7990
8023
  );
@@ -7996,7 +8029,7 @@ function createClient(options) {
7996
8029
  return leaseRoom(newRoomDetails);
7997
8030
  }
7998
8031
  function getRoom(roomId) {
7999
- const room = _optionalChain([roomsById, 'access', _178 => _178.get, 'call', _179 => _179(roomId), 'optionalAccess', _180 => _180.room]);
8032
+ const room = _optionalChain([roomsById, 'access', _179 => _179.get, 'call', _180 => _180(roomId), 'optionalAccess', _181 => _181.room]);
8000
8033
  return room ? room : null;
8001
8034
  }
8002
8035
  function logout() {
@@ -8016,7 +8049,7 @@ function createClient(options) {
8016
8049
  const batchedResolveUsers = new Batch(
8017
8050
  async (batchedUserIds) => {
8018
8051
  const userIds = batchedUserIds.flat();
8019
- const users = await _optionalChain([resolveUsers, 'optionalCall', _181 => _181({ userIds })]);
8052
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _182 => _182({ userIds })]);
8020
8053
  warnIfNoResolveUsers();
8021
8054
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
8022
8055
  },
@@ -8034,7 +8067,7 @@ function createClient(options) {
8034
8067
  const batchedResolveRoomsInfo = new Batch(
8035
8068
  async (batchedRoomIds) => {
8036
8069
  const roomIds = batchedRoomIds.flat();
8037
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _182 => _182({ roomIds })]);
8070
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _183 => _183({ roomIds })]);
8038
8071
  warnIfNoResolveRoomsInfo();
8039
8072
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
8040
8073
  },
@@ -8087,7 +8120,7 @@ function createClient(options) {
8087
8120
  }
8088
8121
  };
8089
8122
  const win = typeof window !== "undefined" ? window : void 0;
8090
- _optionalChain([win, 'optionalAccess', _183 => _183.addEventListener, 'call', _184 => _184("beforeunload", maybePreventClose)]);
8123
+ _optionalChain([win, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("beforeunload", maybePreventClose)]);
8091
8124
  }
8092
8125
  const client = Object.defineProperty(
8093
8126
  {
@@ -8102,6 +8135,9 @@ function createClient(options) {
8102
8135
  markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
8103
8136
  deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
8104
8137
  deleteInboxNotification: httpClient.deleteInboxNotification,
8138
+ // Public channel notification settings API
8139
+ getNotificationSettings: httpClient.getUserNotificationSettings,
8140
+ updateNotificationSettings: httpClient.updateUserNotificationSettings,
8105
8141
  // Advanced resolvers APIs
8106
8142
  resolvers: {
8107
8143
  invalidateUsers: invalidateResolvedUsers,
@@ -8212,7 +8248,7 @@ var commentBodyElementsTypes = {
8212
8248
  mention: "inline"
8213
8249
  };
8214
8250
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8215
- if (!body || !_optionalChain([body, 'optionalAccess', _185 => _185.content])) {
8251
+ if (!body || !_optionalChain([body, 'optionalAccess', _186 => _186.content])) {
8216
8252
  return;
8217
8253
  }
8218
8254
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -8222,13 +8258,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8222
8258
  for (const block of body.content) {
8223
8259
  if (type === "all" || type === "block") {
8224
8260
  if (guard(block)) {
8225
- _optionalChain([visitor, 'optionalCall', _186 => _186(block)]);
8261
+ _optionalChain([visitor, 'optionalCall', _187 => _187(block)]);
8226
8262
  }
8227
8263
  }
8228
8264
  if (type === "all" || type === "inline") {
8229
8265
  for (const inline of block.children) {
8230
8266
  if (guard(inline)) {
8231
- _optionalChain([visitor, 'optionalCall', _187 => _187(inline)]);
8267
+ _optionalChain([visitor, 'optionalCall', _188 => _188(inline)]);
8232
8268
  }
8233
8269
  }
8234
8270
  }
@@ -8253,7 +8289,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
8253
8289
  userIds
8254
8290
  });
8255
8291
  for (const [index, userId] of userIds.entries()) {
8256
- const user = _optionalChain([users, 'optionalAccess', _188 => _188[index]]);
8292
+ const user = _optionalChain([users, 'optionalAccess', _189 => _189[index]]);
8257
8293
  if (user) {
8258
8294
  resolvedUsers.set(userId, user);
8259
8295
  }
@@ -8298,9 +8334,9 @@ function escapeHtml(value) {
8298
8334
  var HtmlSafeString = class {
8299
8335
  #strings;
8300
8336
  #values;
8301
- constructor(strings, values) {
8337
+ constructor(strings, values2) {
8302
8338
  this.#strings = strings;
8303
- this.#values = values;
8339
+ this.#values = values2;
8304
8340
  }
8305
8341
  toString() {
8306
8342
  return this.#strings.reduce((result, str, i) => {
@@ -8308,8 +8344,8 @@ var HtmlSafeString = class {
8308
8344
  });
8309
8345
  }
8310
8346
  };
8311
- function html(strings, ...values) {
8312
- return new HtmlSafeString(strings, values);
8347
+ function html(strings, ...values2) {
8348
+ return new HtmlSafeString(strings, values2);
8313
8349
  }
8314
8350
  var markdownEscapables = {
8315
8351
  _: "\\_",
@@ -8354,9 +8390,9 @@ function escapeMarkdown(value) {
8354
8390
  var MarkdownSafeString = class {
8355
8391
  #strings;
8356
8392
  #values;
8357
- constructor(strings, values) {
8393
+ constructor(strings, values2) {
8358
8394
  this.#strings = strings;
8359
- this.#values = values;
8395
+ this.#values = values2;
8360
8396
  }
8361
8397
  toString() {
8362
8398
  return this.#strings.reduce((result, str, i) => {
@@ -8364,8 +8400,8 @@ var MarkdownSafeString = class {
8364
8400
  });
8365
8401
  }
8366
8402
  };
8367
- function markdown(strings, ...values) {
8368
- return new MarkdownSafeString(strings, values);
8403
+ function markdown(strings, ...values2) {
8404
+ return new MarkdownSafeString(strings, values2);
8369
8405
  }
8370
8406
  function toAbsoluteUrl(url2) {
8371
8407
  if (url2.startsWith("http://") || url2.startsWith("https://")) {
@@ -8380,7 +8416,7 @@ var stringifyCommentBodyPlainElements = {
8380
8416
  text: ({ element }) => element.text,
8381
8417
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
8382
8418
  mention: ({ element, user }) => {
8383
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _189 => _189.name]), () => ( element.id))}`;
8419
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}`;
8384
8420
  }
8385
8421
  };
8386
8422
  var stringifyCommentBodyHtmlElements = {
@@ -8410,7 +8446,7 @@ var stringifyCommentBodyHtmlElements = {
8410
8446
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
8411
8447
  },
8412
8448
  mention: ({ element, user }) => {
8413
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}</span>`;
8449
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}</span>`;
8414
8450
  }
8415
8451
  };
8416
8452
  var stringifyCommentBodyMarkdownElements = {
@@ -8440,19 +8476,19 @@ var stringifyCommentBodyMarkdownElements = {
8440
8476
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
8441
8477
  },
8442
8478
  mention: ({ element, user }) => {
8443
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}`;
8479
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _192 => _192.name]), () => ( element.id))}`;
8444
8480
  }
8445
8481
  };
8446
8482
  async function stringifyCommentBody(body, options) {
8447
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _192 => _192.format]), () => ( "plain"));
8448
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8483
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.format]), () => ( "plain"));
8484
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8449
8485
  const elements = {
8450
8486
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
8451
- ..._optionalChain([options, 'optionalAccess', _194 => _194.elements])
8487
+ ..._optionalChain([options, 'optionalAccess', _195 => _195.elements])
8452
8488
  };
8453
8489
  const resolvedUsers = await resolveUsersInCommentBody(
8454
8490
  body,
8455
- _optionalChain([options, 'optionalAccess', _195 => _195.resolveUsers])
8491
+ _optionalChain([options, 'optionalAccess', _196 => _196.resolveUsers])
8456
8492
  );
8457
8493
  const blocks = body.content.flatMap((block, blockIndex) => {
8458
8494
  switch (block.type) {
@@ -8743,12 +8779,12 @@ function legacy_patchImmutableNode(state, path, update) {
8743
8779
  }
8744
8780
  const newState = Object.assign({}, state);
8745
8781
  for (const key in update.updates) {
8746
- if (_optionalChain([update, 'access', _196 => _196.updates, 'access', _197 => _197[key], 'optionalAccess', _198 => _198.type]) === "update") {
8782
+ if (_optionalChain([update, 'access', _197 => _197.updates, 'access', _198 => _198[key], 'optionalAccess', _199 => _199.type]) === "update") {
8747
8783
  const val = update.node.get(key);
8748
8784
  if (val !== void 0) {
8749
8785
  newState[key] = lsonToJson(val);
8750
8786
  }
8751
- } else if (_optionalChain([update, 'access', _199 => _199.updates, 'access', _200 => _200[key], 'optionalAccess', _201 => _201.type]) === "delete") {
8787
+ } else if (_optionalChain([update, 'access', _200 => _200.updates, 'access', _201 => _201[key], 'optionalAccess', _202 => _202.type]) === "delete") {
8752
8788
  delete newState[key];
8753
8789
  }
8754
8790
  }
@@ -8809,12 +8845,12 @@ function legacy_patchImmutableNode(state, path, update) {
8809
8845
  }
8810
8846
  const newState = Object.assign({}, state);
8811
8847
  for (const key in update.updates) {
8812
- if (_optionalChain([update, 'access', _202 => _202.updates, 'access', _203 => _203[key], 'optionalAccess', _204 => _204.type]) === "update") {
8848
+ if (_optionalChain([update, 'access', _203 => _203.updates, 'access', _204 => _204[key], 'optionalAccess', _205 => _205.type]) === "update") {
8813
8849
  const value = update.node.get(key);
8814
8850
  if (value !== void 0) {
8815
8851
  newState[key] = lsonToJson(value);
8816
8852
  }
8817
- } else if (_optionalChain([update, 'access', _205 => _205.updates, 'access', _206 => _206[key], 'optionalAccess', _207 => _207.type]) === "delete") {
8853
+ } else if (_optionalChain([update, 'access', _206 => _206.updates, 'access', _207 => _207[key], 'optionalAccess', _208 => _208.type]) === "delete") {
8818
8854
  delete newState[key];
8819
8855
  }
8820
8856
  }
@@ -8885,9 +8921,9 @@ function makePoller(callback, intervalMs, options) {
8885
8921
  const startTime = performance.now();
8886
8922
  const doc = typeof document !== "undefined" ? document : void 0;
8887
8923
  const win = typeof window !== "undefined" ? window : void 0;
8888
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _208 => _208.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8924
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _209 => _209.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8889
8925
  const context = {
8890
- inForeground: _optionalChain([doc, 'optionalAccess', _209 => _209.visibilityState]) !== "hidden",
8926
+ inForeground: _optionalChain([doc, 'optionalAccess', _210 => _210.visibilityState]) !== "hidden",
8891
8927
  lastSuccessfulPollAt: startTime,
8892
8928
  count: 0,
8893
8929
  backoff: 0
@@ -8965,11 +9001,11 @@ function makePoller(callback, intervalMs, options) {
8965
9001
  pollNowIfStale();
8966
9002
  }
8967
9003
  function onVisibilityChange() {
8968
- setInForeground(_optionalChain([doc, 'optionalAccess', _210 => _210.visibilityState]) !== "hidden");
9004
+ setInForeground(_optionalChain([doc, 'optionalAccess', _211 => _211.visibilityState]) !== "hidden");
8969
9005
  }
8970
- _optionalChain([doc, 'optionalAccess', _211 => _211.addEventListener, 'call', _212 => _212("visibilitychange", onVisibilityChange)]);
8971
- _optionalChain([win, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("online", onVisibilityChange)]);
8972
- _optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("focus", pollNowIfStale)]);
9006
+ _optionalChain([doc, 'optionalAccess', _212 => _212.addEventListener, 'call', _213 => _213("visibilitychange", onVisibilityChange)]);
9007
+ _optionalChain([win, 'optionalAccess', _214 => _214.addEventListener, 'call', _215 => _215("online", onVisibilityChange)]);
9008
+ _optionalChain([win, 'optionalAccess', _216 => _216.addEventListener, 'call', _217 => _217("focus", pollNowIfStale)]);
8973
9009
  fsm.start();
8974
9010
  return {
8975
9011
  inc,
@@ -9091,6 +9127,11 @@ var SortedList = class _SortedList {
9091
9127
  }
9092
9128
  };
9093
9129
 
9130
+ // src/protocol/UserNotificationSettings.ts
9131
+ function isNotificationChannelEnabled(settings) {
9132
+ return values(settings).every((enabled) => enabled === true);
9133
+ }
9134
+
9094
9135
  // src/types/Others.ts
9095
9136
  var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9096
9137
  TextEditorType2["Lexical"] = "lexical";
@@ -9188,5 +9229,8 @@ var NotificationsApiError = HttpError;
9188
9229
 
9189
9230
 
9190
9231
 
9191
- exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
9232
+
9233
+
9234
+
9235
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
9192
9236
  //# sourceMappingURL=index.js.map