@liveblocks/core 2.17.0-rc1 → 2.17.0-usrnotsettings2

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-rc1";
9
+ var PKG_VERSION = "2.17.0-usrnotsettings2";
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
 
@@ -1705,9 +1711,24 @@ function createApiClient({
1705
1711
  await authManager.getAuthValue({ requestedScope: "comments:read" })
1706
1712
  );
1707
1713
  }
1714
+ async function getUserNotificationSettings(options) {
1715
+ return httpClient.get(
1716
+ url`/v2/c/notification-settings`,
1717
+ await authManager.getAuthValue({ requestedScope: "comments:read" }),
1718
+ void 0,
1719
+ { signal: _optionalChain([options, 'optionalAccess', _18 => _18.signal]) }
1720
+ );
1721
+ }
1722
+ async function updateUserNotificationSettings(settings) {
1723
+ return httpClient.post(
1724
+ url`/v2/c/notification-settings`,
1725
+ await authManager.getAuthValue({ requestedScope: "comments:read" }),
1726
+ settings
1727
+ );
1728
+ }
1708
1729
  async function getUserThreads_experimental(options) {
1709
1730
  let query;
1710
- if (_optionalChain([options, 'optionalAccess', _18 => _18.query])) {
1731
+ if (_optionalChain([options, 'optionalAccess', _19 => _19.query])) {
1711
1732
  query = objectToQuery(options.query);
1712
1733
  }
1713
1734
  const PAGE_SIZE = 50;
@@ -1715,7 +1736,7 @@ function createApiClient({
1715
1736
  url`/v2/c/threads`,
1716
1737
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
1717
1738
  {
1718
- cursor: _optionalChain([options, 'optionalAccess', _19 => _19.cursor]),
1739
+ cursor: _optionalChain([options, 'optionalAccess', _20 => _20.cursor]),
1719
1740
  query,
1720
1741
  limit: PAGE_SIZE
1721
1742
  }
@@ -1767,10 +1788,10 @@ function createApiClient({
1767
1788
  removeReaction,
1768
1789
  markThreadAsResolved,
1769
1790
  markThreadAsUnresolved,
1770
- // Room notifications
1771
1791
  markRoomInboxNotificationAsRead,
1772
- updateNotificationSettings,
1792
+ // Room notifications
1773
1793
  getNotificationSettings,
1794
+ updateNotificationSettings,
1774
1795
  // Room text editor
1775
1796
  createTextMention,
1776
1797
  deleteTextMention,
@@ -1794,6 +1815,8 @@ function createApiClient({
1794
1815
  markInboxNotificationAsRead,
1795
1816
  deleteAllInboxNotifications,
1796
1817
  deleteInboxNotification,
1818
+ getUserNotificationSettings,
1819
+ updateUserNotificationSettings,
1797
1820
  // User threads
1798
1821
  getUserThreads_experimental,
1799
1822
  getUserThreadsSince_experimental
@@ -1840,7 +1863,7 @@ var HttpClient = class {
1840
1863
  // These headers are default, but can be overriden by custom headers
1841
1864
  "Content-Type": "application/json; charset=utf-8",
1842
1865
  // Possible header overrides
1843
- ..._optionalChain([options, 'optionalAccess', _20 => _20.headers]),
1866
+ ..._optionalChain([options, 'optionalAccess', _21 => _21.headers]),
1844
1867
  // Cannot be overriden by custom headers
1845
1868
  Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
1846
1869
  "X-LB-Client": PKG_VERSION || "dev"
@@ -2315,7 +2338,7 @@ var FSM = class {
2315
2338
  });
2316
2339
  }
2317
2340
  #getTargetFn(eventName) {
2318
- return _optionalChain([this, 'access', _21 => _21.#allowedTransitions, 'access', _22 => _22.get, 'call', _23 => _23(this.currentState), 'optionalAccess', _24 => _24.get, 'call', _25 => _25(eventName)]);
2341
+ return _optionalChain([this, 'access', _22 => _22.#allowedTransitions, 'access', _23 => _23.get, 'call', _24 => _24(this.currentState), 'optionalAccess', _25 => _25.get, 'call', _26 => _26(eventName)]);
2319
2342
  }
2320
2343
  /**
2321
2344
  * Exits the current state, and executes any necessary cleanup functions.
@@ -2332,7 +2355,7 @@ var FSM = class {
2332
2355
  this.#currentContext.allowPatching((patchableContext) => {
2333
2356
  levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
2334
2357
  for (let i = 0; i < levels; i++) {
2335
- _optionalChain([this, 'access', _26 => _26.#cleanupStack, 'access', _27 => _27.pop, 'call', _28 => _28(), 'optionalCall', _29 => _29(patchableContext)]);
2358
+ _optionalChain([this, 'access', _27 => _27.#cleanupStack, 'access', _28 => _28.pop, 'call', _29 => _29(), 'optionalCall', _30 => _30(patchableContext)]);
2336
2359
  }
2337
2360
  });
2338
2361
  }
@@ -2348,7 +2371,7 @@ var FSM = class {
2348
2371
  this.#currentContext.allowPatching((patchableContext) => {
2349
2372
  for (const pattern of enterPatterns) {
2350
2373
  const enterFn = this.#enterFns.get(pattern);
2351
- const cleanupFn = _optionalChain([enterFn, 'optionalCall', _30 => _30(patchableContext)]);
2374
+ const cleanupFn = _optionalChain([enterFn, 'optionalCall', _31 => _31(patchableContext)]);
2352
2375
  if (typeof cleanupFn === "function") {
2353
2376
  this.#cleanupStack.push(cleanupFn);
2354
2377
  } else {
@@ -2742,7 +2765,7 @@ function createConnectionStateMachine(delegates, options) {
2742
2765
  }
2743
2766
  function waitForActorId(event) {
2744
2767
  const serverMsg = tryParseJson(event.data);
2745
- if (_optionalChain([serverMsg, 'optionalAccess', _31 => _31.type]) === 104 /* ROOM_STATE */) {
2768
+ if (_optionalChain([serverMsg, 'optionalAccess', _32 => _32.type]) === 104 /* ROOM_STATE */) {
2746
2769
  didReceiveActor();
2747
2770
  }
2748
2771
  }
@@ -2851,12 +2874,12 @@ function createConnectionStateMachine(delegates, options) {
2851
2874
  const sendHeartbeat = {
2852
2875
  target: "@ok.awaiting-pong",
2853
2876
  effect: (ctx) => {
2854
- _optionalChain([ctx, 'access', _32 => _32.socket, 'optionalAccess', _33 => _33.send, 'call', _34 => _34("ping")]);
2877
+ _optionalChain([ctx, 'access', _33 => _33.socket, 'optionalAccess', _34 => _34.send, 'call', _35 => _35("ping")]);
2855
2878
  }
2856
2879
  };
2857
2880
  const maybeHeartbeat = () => {
2858
2881
  const doc = typeof document !== "undefined" ? document : void 0;
2859
- const canZombie = _optionalChain([doc, 'optionalAccess', _35 => _35.visibilityState]) === "hidden" && delegates.canZombie();
2882
+ const canZombie = _optionalChain([doc, 'optionalAccess', _36 => _36.visibilityState]) === "hidden" && delegates.canZombie();
2860
2883
  return canZombie ? "@idle.zombie" : sendHeartbeat;
2861
2884
  };
2862
2885
  machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
@@ -2895,7 +2918,7 @@ function createConnectionStateMachine(delegates, options) {
2895
2918
  // socket, or not. So always check to see if the socket is still OPEN or
2896
2919
  // not. When still OPEN, don't transition.
2897
2920
  EXPLICIT_SOCKET_ERROR: (_, context) => {
2898
- if (_optionalChain([context, 'access', _36 => _36.socket, 'optionalAccess', _37 => _37.readyState]) === 1) {
2921
+ if (_optionalChain([context, 'access', _37 => _37.socket, 'optionalAccess', _38 => _38.readyState]) === 1) {
2899
2922
  return null;
2900
2923
  }
2901
2924
  return {
@@ -2947,17 +2970,17 @@ function createConnectionStateMachine(delegates, options) {
2947
2970
  machine.send({ type: "NAVIGATOR_ONLINE" });
2948
2971
  }
2949
2972
  function onVisibilityChange() {
2950
- if (_optionalChain([doc, 'optionalAccess', _38 => _38.visibilityState]) === "visible") {
2973
+ if (_optionalChain([doc, 'optionalAccess', _39 => _39.visibilityState]) === "visible") {
2951
2974
  machine.send({ type: "WINDOW_GOT_FOCUS" });
2952
2975
  }
2953
2976
  }
2954
- _optionalChain([win, 'optionalAccess', _39 => _39.addEventListener, 'call', _40 => _40("online", onNetworkBackOnline)]);
2955
- _optionalChain([win, 'optionalAccess', _41 => _41.addEventListener, 'call', _42 => _42("offline", onNetworkOffline)]);
2956
- _optionalChain([root, 'optionalAccess', _43 => _43.addEventListener, 'call', _44 => _44("visibilitychange", onVisibilityChange)]);
2977
+ _optionalChain([win, 'optionalAccess', _40 => _40.addEventListener, 'call', _41 => _41("online", onNetworkBackOnline)]);
2978
+ _optionalChain([win, 'optionalAccess', _42 => _42.addEventListener, 'call', _43 => _43("offline", onNetworkOffline)]);
2979
+ _optionalChain([root, 'optionalAccess', _44 => _44.addEventListener, 'call', _45 => _45("visibilitychange", onVisibilityChange)]);
2957
2980
  return () => {
2958
- _optionalChain([root, 'optionalAccess', _45 => _45.removeEventListener, 'call', _46 => _46("visibilitychange", onVisibilityChange)]);
2959
- _optionalChain([win, 'optionalAccess', _47 => _47.removeEventListener, 'call', _48 => _48("online", onNetworkBackOnline)]);
2960
- _optionalChain([win, 'optionalAccess', _49 => _49.removeEventListener, 'call', _50 => _50("offline", onNetworkOffline)]);
2981
+ _optionalChain([root, 'optionalAccess', _46 => _46.removeEventListener, 'call', _47 => _47("visibilitychange", onVisibilityChange)]);
2982
+ _optionalChain([win, 'optionalAccess', _48 => _48.removeEventListener, 'call', _49 => _49("online", onNetworkBackOnline)]);
2983
+ _optionalChain([win, 'optionalAccess', _50 => _50.removeEventListener, 'call', _51 => _51("offline", onNetworkOffline)]);
2961
2984
  teardownSocket(ctx.socket);
2962
2985
  };
2963
2986
  });
@@ -3046,7 +3069,7 @@ var ManagedSocket = class {
3046
3069
  * message if this is somehow impossible.
3047
3070
  */
3048
3071
  send(data) {
3049
- const socket = _optionalChain([this, 'access', _51 => _51.#machine, 'access', _52 => _52.context, 'optionalAccess', _53 => _53.socket]);
3072
+ const socket = _optionalChain([this, 'access', _52 => _52.#machine, 'access', _53 => _53.context, 'optionalAccess', _54 => _54.socket]);
3050
3073
  if (socket === null) {
3051
3074
  warn("Cannot send: not connected yet", data);
3052
3075
  } else if (socket.readyState !== 1) {
@@ -3150,7 +3173,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3150
3173
  return void 0;
3151
3174
  }
3152
3175
  async function makeAuthRequest(options) {
3153
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _54 => _54.polyfills, 'optionalAccess', _55 => _55.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
3176
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _55 => _55.polyfills, 'optionalAccess', _56 => _56.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
3154
3177
  if (authentication.type === "private") {
3155
3178
  if (fetcher === void 0) {
3156
3179
  throw new StopRetrying(
@@ -3166,7 +3189,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3166
3189
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
3167
3190
  );
3168
3191
  }
3169
- _optionalChain([onAuthenticate, 'optionalCall', _56 => _56(parsed.parsed)]);
3192
+ _optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
3170
3193
  return parsed;
3171
3194
  }
3172
3195
  if (authentication.type === "custom") {
@@ -3174,7 +3197,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3174
3197
  if (response && typeof response === "object") {
3175
3198
  if (typeof response.token === "string") {
3176
3199
  const parsed = parseAuthToken(response.token);
3177
- _optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
3200
+ _optionalChain([onAuthenticate, 'optionalCall', _58 => _58(parsed.parsed)]);
3178
3201
  return parsed;
3179
3202
  } else if (typeof response.error === "string") {
3180
3203
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -3335,7 +3358,7 @@ function sendToPanel(message, options) {
3335
3358
  ...message,
3336
3359
  source: "liveblocks-devtools-client"
3337
3360
  };
3338
- if (!(_optionalChain([options, 'optionalAccess', _58 => _58.force]) || _bridgeActive)) {
3361
+ if (!(_optionalChain([options, 'optionalAccess', _59 => _59.force]) || _bridgeActive)) {
3339
3362
  return;
3340
3363
  }
3341
3364
  window.postMessage(fullMsg, "*");
@@ -3343,7 +3366,7 @@ function sendToPanel(message, options) {
3343
3366
  var eventSource = makeEventSource();
3344
3367
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
3345
3368
  window.addEventListener("message", (event) => {
3346
- if (event.source === window && _optionalChain([event, 'access', _59 => _59.data, 'optionalAccess', _60 => _60.source]) === "liveblocks-devtools-panel") {
3369
+ if (event.source === window && _optionalChain([event, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.source]) === "liveblocks-devtools-panel") {
3347
3370
  eventSource.notify(event.data);
3348
3371
  } else {
3349
3372
  }
@@ -3485,7 +3508,7 @@ function fullSync(room) {
3485
3508
  msg: "room::sync::full",
3486
3509
  roomId: room.id,
3487
3510
  status: room.getStatus(),
3488
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _61 => _61.toTreeNode, 'call', _62 => _62("root"), 'access', _63 => _63.payload]), () => ( null)),
3511
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _62 => _62.toTreeNode, 'call', _63 => _63("root"), 'access', _64 => _64.payload]), () => ( null)),
3489
3512
  me,
3490
3513
  others
3491
3514
  });
@@ -3909,7 +3932,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
3909
3932
  return [
3910
3933
  {
3911
3934
  type: 8 /* CREATE_REGISTER */,
3912
- opId: _optionalChain([pool, 'optionalAccess', _64 => _64.generateOpId, 'call', _65 => _65()]),
3935
+ opId: _optionalChain([pool, 'optionalAccess', _65 => _65.generateOpId, 'call', _66 => _66()]),
3913
3936
  id: this._id,
3914
3937
  parentId,
3915
3938
  parentKey,
@@ -4015,7 +4038,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4015
4038
  const ops = [];
4016
4039
  const op = {
4017
4040
  id: this._id,
4018
- opId: _optionalChain([pool, 'optionalAccess', _66 => _66.generateOpId, 'call', _67 => _67()]),
4041
+ opId: _optionalChain([pool, 'optionalAccess', _67 => _67.generateOpId, 'call', _68 => _68()]),
4019
4042
  type: 2 /* CREATE_LIST */,
4020
4043
  parentId,
4021
4044
  parentKey
@@ -4286,7 +4309,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4286
4309
  #applyInsertUndoRedo(op) {
4287
4310
  const { id, parentKey: key } = op;
4288
4311
  const child = creationOpToLiveNode(op);
4289
- if (_optionalChain([this, 'access', _68 => _68._pool, 'optionalAccess', _69 => _69.getNode, 'call', _70 => _70(id)]) !== void 0) {
4312
+ if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
4290
4313
  return { modified: false };
4291
4314
  }
4292
4315
  child._attach(id, nn(this._pool));
@@ -4294,8 +4317,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
4294
4317
  const existingItemIndex = this._indexOfPosition(key);
4295
4318
  let newKey = key;
4296
4319
  if (existingItemIndex !== -1) {
4297
- const before2 = _optionalChain([this, 'access', _71 => _71.#items, 'access', _72 => _72[existingItemIndex], 'optionalAccess', _73 => _73._parentPos]);
4298
- const after2 = _optionalChain([this, 'access', _74 => _74.#items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]);
4320
+ const before2 = _optionalChain([this, 'access', _72 => _72.#items, 'access', _73 => _73[existingItemIndex], 'optionalAccess', _74 => _74._parentPos]);
4321
+ const after2 = _optionalChain([this, 'access', _75 => _75.#items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]);
4299
4322
  newKey = makePosition(before2, after2);
4300
4323
  child._setParentLink(this, newKey);
4301
4324
  }
@@ -4309,7 +4332,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4309
4332
  #applySetUndoRedo(op) {
4310
4333
  const { id, parentKey: key } = op;
4311
4334
  const child = creationOpToLiveNode(op);
4312
- if (_optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.getNode, 'call', _79 => _79(id)]) !== void 0) {
4335
+ if (_optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.getNode, 'call', _80 => _80(id)]) !== void 0) {
4313
4336
  return { modified: false };
4314
4337
  }
4315
4338
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -4430,7 +4453,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4430
4453
  } else {
4431
4454
  this.#items[existingItemIndex]._setParentLink(
4432
4455
  this,
4433
- makePosition(newKey, _optionalChain([this, 'access', _80 => _80.#items, 'access', _81 => _81[existingItemIndex + 1], 'optionalAccess', _82 => _82._parentPos]))
4456
+ makePosition(newKey, _optionalChain([this, 'access', _81 => _81.#items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
4434
4457
  );
4435
4458
  const previousIndex = this.#items.indexOf(child);
4436
4459
  child._setParentLink(this, newKey);
@@ -4455,7 +4478,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4455
4478
  if (existingItemIndex !== -1) {
4456
4479
  this.#items[existingItemIndex]._setParentLink(
4457
4480
  this,
4458
- makePosition(newKey, _optionalChain([this, 'access', _83 => _83.#items, 'access', _84 => _84[existingItemIndex + 1], 'optionalAccess', _85 => _85._parentPos]))
4481
+ makePosition(newKey, _optionalChain([this, 'access', _84 => _84.#items, 'access', _85 => _85[existingItemIndex + 1], 'optionalAccess', _86 => _86._parentPos]))
4459
4482
  );
4460
4483
  }
4461
4484
  child._setParentLink(this, newKey);
@@ -4474,7 +4497,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4474
4497
  if (existingItemIndex !== -1) {
4475
4498
  this.#items[existingItemIndex]._setParentLink(
4476
4499
  this,
4477
- makePosition(newKey, _optionalChain([this, 'access', _86 => _86.#items, 'access', _87 => _87[existingItemIndex + 1], 'optionalAccess', _88 => _88._parentPos]))
4500
+ makePosition(newKey, _optionalChain([this, 'access', _87 => _87.#items, 'access', _88 => _88[existingItemIndex + 1], 'optionalAccess', _89 => _89._parentPos]))
4478
4501
  );
4479
4502
  }
4480
4503
  child._setParentLink(this, newKey);
@@ -4501,7 +4524,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4501
4524
  if (existingItemIndex !== -1) {
4502
4525
  this.#items[existingItemIndex]._setParentLink(
4503
4526
  this,
4504
- makePosition(newKey, _optionalChain([this, 'access', _89 => _89.#items, 'access', _90 => _90[existingItemIndex + 1], 'optionalAccess', _91 => _91._parentPos]))
4527
+ makePosition(newKey, _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex + 1], 'optionalAccess', _92 => _92._parentPos]))
4505
4528
  );
4506
4529
  }
4507
4530
  child._setParentLink(this, newKey);
@@ -4559,7 +4582,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4559
4582
  * @param element The element to add to the end of the LiveList.
4560
4583
  */
4561
4584
  push(element) {
4562
- _optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
4585
+ _optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
4563
4586
  return this.insert(element, this.length);
4564
4587
  }
4565
4588
  /**
@@ -4568,7 +4591,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4568
4591
  * @param index The index at which you want to insert the element.
4569
4592
  */
4570
4593
  insert(element, index) {
4571
- _optionalChain([this, 'access', _95 => _95._pool, 'optionalAccess', _96 => _96.assertStorageIsWritable, 'call', _97 => _97()]);
4594
+ _optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
4572
4595
  if (index < 0 || index > this.#items.length) {
4573
4596
  throw new Error(
4574
4597
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -4598,7 +4621,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4598
4621
  * @param targetIndex The index where the element should be after moving.
4599
4622
  */
4600
4623
  move(index, targetIndex) {
4601
- _optionalChain([this, 'access', _98 => _98._pool, 'optionalAccess', _99 => _99.assertStorageIsWritable, 'call', _100 => _100()]);
4624
+ _optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
4602
4625
  if (targetIndex < 0) {
4603
4626
  throw new Error("targetIndex cannot be less than 0");
4604
4627
  }
@@ -4656,7 +4679,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4656
4679
  * @param index The index of the element to delete
4657
4680
  */
4658
4681
  delete(index) {
4659
- _optionalChain([this, 'access', _101 => _101._pool, 'optionalAccess', _102 => _102.assertStorageIsWritable, 'call', _103 => _103()]);
4682
+ _optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
4660
4683
  if (index < 0 || index >= this.#items.length) {
4661
4684
  throw new Error(
4662
4685
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4689,7 +4712,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4689
4712
  }
4690
4713
  }
4691
4714
  clear() {
4692
- _optionalChain([this, 'access', _104 => _104._pool, 'optionalAccess', _105 => _105.assertStorageIsWritable, 'call', _106 => _106()]);
4715
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4693
4716
  if (this._pool) {
4694
4717
  const ops = [];
4695
4718
  const reverseOps = [];
@@ -4723,7 +4746,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4723
4746
  }
4724
4747
  }
4725
4748
  set(index, item) {
4726
- _optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.assertStorageIsWritable, 'call', _109 => _109()]);
4749
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4727
4750
  if (index < 0 || index >= this.#items.length) {
4728
4751
  throw new Error(
4729
4752
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4869,7 +4892,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4869
4892
  #shiftItemPosition(index, key) {
4870
4893
  const shiftedPosition = makePosition(
4871
4894
  key,
4872
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[index + 1], 'optionalAccess', _112 => _112._parentPos]) : void 0
4895
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[index + 1], 'optionalAccess', _113 => _113._parentPos]) : void 0
4873
4896
  );
4874
4897
  this.#items[index]._setParentLink(this, shiftedPosition);
4875
4898
  }
@@ -4994,7 +5017,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
4994
5017
  const ops = [];
4995
5018
  const op = {
4996
5019
  id: this._id,
4997
- opId: _optionalChain([pool, 'optionalAccess', _113 => _113.generateOpId, 'call', _114 => _114()]),
5020
+ opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
4998
5021
  type: 7 /* CREATE_MAP */,
4999
5022
  parentId,
5000
5023
  parentKey
@@ -5129,7 +5152,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5129
5152
  * @param value The value of the element to add. Should be serializable to JSON.
5130
5153
  */
5131
5154
  set(key, value) {
5132
- _optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
5155
+ _optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.assertStorageIsWritable, 'call', _118 => _118()]);
5133
5156
  const oldValue = this.#map.get(key);
5134
5157
  if (oldValue) {
5135
5158
  oldValue._detach();
@@ -5175,7 +5198,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5175
5198
  * @returns true if an element existed and has been removed, or false if the element does not exist.
5176
5199
  */
5177
5200
  delete(key) {
5178
- _optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.assertStorageIsWritable, 'call', _120 => _120()]);
5201
+ _optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.assertStorageIsWritable, 'call', _121 => _121()]);
5179
5202
  const item = this.#map.get(key);
5180
5203
  if (item === void 0) {
5181
5204
  return false;
@@ -5354,7 +5377,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5354
5377
  if (this._id === void 0) {
5355
5378
  throw new Error("Cannot serialize item is not attached");
5356
5379
  }
5357
- const opId = _optionalChain([pool, 'optionalAccess', _121 => _121.generateOpId, 'call', _122 => _122()]);
5380
+ const opId = _optionalChain([pool, 'optionalAccess', _122 => _122.generateOpId, 'call', _123 => _123()]);
5358
5381
  const ops = [];
5359
5382
  const op = {
5360
5383
  type: 4 /* CREATE_OBJECT */,
@@ -5626,7 +5649,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5626
5649
  * @param value The value of the property to add
5627
5650
  */
5628
5651
  set(key, value) {
5629
- _optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
5652
+ _optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
5630
5653
  this.update({ [key]: value });
5631
5654
  }
5632
5655
  /**
@@ -5641,7 +5664,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5641
5664
  * @param key The key of the property to delete
5642
5665
  */
5643
5666
  delete(key) {
5644
- _optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
5667
+ _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
5645
5668
  const keyAsString = key;
5646
5669
  const oldValue = this.#map.get(keyAsString);
5647
5670
  if (oldValue === void 0) {
@@ -5694,7 +5717,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5694
5717
  * @param patch The object used to overrides properties
5695
5718
  */
5696
5719
  update(patch) {
5697
- _optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
5720
+ _optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
5698
5721
  if (this._pool === void 0 || this._id === void 0) {
5699
5722
  for (const key in patch) {
5700
5723
  const newValue = patch[key];
@@ -6320,7 +6343,7 @@ function defaultMessageFromContext(context) {
6320
6343
  }
6321
6344
 
6322
6345
  // src/room.ts
6323
- var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 512;
6346
+ var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 1024;
6324
6347
  function makeIdFactory(connectionId) {
6325
6348
  let count = 0;
6326
6349
  return () => `${connectionId}:${count++}`;
@@ -6343,15 +6366,15 @@ function installBackgroundTabSpy() {
6343
6366
  const doc = typeof document !== "undefined" ? document : void 0;
6344
6367
  const inBackgroundSince = { current: null };
6345
6368
  function onVisibilityChange() {
6346
- if (_optionalChain([doc, 'optionalAccess', _132 => _132.visibilityState]) === "hidden") {
6369
+ if (_optionalChain([doc, 'optionalAccess', _133 => _133.visibilityState]) === "hidden") {
6347
6370
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
6348
6371
  } else {
6349
6372
  inBackgroundSince.current = null;
6350
6373
  }
6351
6374
  }
6352
- _optionalChain([doc, 'optionalAccess', _133 => _133.addEventListener, 'call', _134 => _134("visibilitychange", onVisibilityChange)]);
6375
+ _optionalChain([doc, 'optionalAccess', _134 => _134.addEventListener, 'call', _135 => _135("visibilitychange", onVisibilityChange)]);
6353
6376
  const unsub = () => {
6354
- _optionalChain([doc, 'optionalAccess', _135 => _135.removeEventListener, 'call', _136 => _136("visibilitychange", onVisibilityChange)]);
6377
+ _optionalChain([doc, 'optionalAccess', _136 => _136.removeEventListener, 'call', _137 => _137("visibilitychange", onVisibilityChange)]);
6355
6378
  };
6356
6379
  return [inBackgroundSince, unsub];
6357
6380
  }
@@ -6536,7 +6559,7 @@ function createRoom(options, config) {
6536
6559
  }
6537
6560
  },
6538
6561
  assertStorageIsWritable: () => {
6539
- const scopes = _optionalChain([context, 'access', _137 => _137.dynamicSessionInfoSig, 'access', _138 => _138.get, 'call', _139 => _139(), 'optionalAccess', _140 => _140.scopes]);
6562
+ const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
6540
6563
  if (scopes === void 0) {
6541
6564
  return;
6542
6565
  }
@@ -6589,82 +6612,24 @@ function createRoom(options, config) {
6589
6612
  async function createTextVersion() {
6590
6613
  return httpClient.createTextVersion({ roomId });
6591
6614
  }
6592
- function* chunkOps(msg) {
6593
- const { ops, ...rest } = msg;
6594
- if (ops.length < 2) {
6595
- throw new Error("Cannot split ops into smaller chunks");
6596
- }
6597
- const mid = Math.floor(ops.length / 2);
6598
- const firstHalf = ops.slice(0, mid);
6599
- const secondHalf = ops.slice(mid);
6600
- for (const halfOps of [firstHalf, secondHalf]) {
6601
- const half = { ops: halfOps, ...rest };
6602
- const text = JSON.stringify([half]);
6603
- if (!isTooBigForWebSocket(text)) {
6604
- yield text;
6605
- } else {
6606
- yield* chunkOps(half);
6607
- }
6608
- }
6609
- }
6610
- function* chunkMessages(messages) {
6611
- if (messages.length < 2) {
6612
- if (messages[0].type === 201 /* UPDATE_STORAGE */) {
6613
- yield* chunkOps(messages[0]);
6614
- return;
6615
- } else {
6616
- throw new Error(
6617
- "Cannot split into chunks smaller than the allowed message size"
6618
- );
6619
- }
6620
- }
6621
- const mid = Math.floor(messages.length / 2);
6622
- const firstHalf = messages.slice(0, mid);
6623
- const secondHalf = messages.slice(mid);
6624
- for (const half of [firstHalf, secondHalf]) {
6625
- const text = JSON.stringify(half);
6626
- if (!isTooBigForWebSocket(text)) {
6627
- yield text;
6628
- } else {
6629
- yield* chunkMessages(half);
6630
- }
6631
- }
6632
- }
6633
- function isTooBigForWebSocket(text) {
6634
- if (text.length * 4 < MAX_SOCKET_MESSAGE_SIZE) {
6635
- return false;
6636
- }
6637
- return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
6638
- }
6639
6615
  function sendMessages(messages) {
6640
- const strategy = _nullishCoalesce(config.largeMessageStrategy, () => ( "default"));
6641
- const text = JSON.stringify(messages);
6642
- if (!isTooBigForWebSocket(text)) {
6643
- return managedSocket.send(text);
6644
- }
6645
- switch (strategy) {
6646
- case "default": {
6647
- error2("Message is too large for websockets, not sending. Configure largeMessageStrategy option to deal with this.");
6648
- return;
6649
- }
6650
- case "split": {
6651
- warn("Message is too large for websockets, splitting into smaller chunks");
6652
- for (const chunk2 of chunkMessages(messages)) {
6653
- managedSocket.send(chunk2);
6654
- }
6655
- return;
6656
- }
6657
- case "experimental-fallback-to-http": {
6658
- warn("Message is too large for websockets, so sending over HTTP instead");
6659
- 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")));
6616
+ const serializedPayload = JSON.stringify(messages);
6617
+ const nonce = _optionalChain([context, 'access', _142 => _142.dynamicSessionInfoSig, 'access', _143 => _143.get, 'call', _144 => _144(), 'optionalAccess', _145 => _145.nonce]);
6618
+ if (config.unstable_fallbackToHTTP && nonce) {
6619
+ const size = new TextEncoder().encode(serializedPayload).length;
6620
+ if (size > MAX_SOCKET_MESSAGE_SIZE) {
6660
6621
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
6661
6622
  if (!resp.ok && resp.status === 403) {
6662
6623
  managedSocket.reconnect();
6663
6624
  }
6664
6625
  });
6626
+ warn(
6627
+ "Message was too large for websockets and sent over HTTP instead"
6628
+ );
6665
6629
  return;
6666
6630
  }
6667
6631
  }
6632
+ managedSocket.send(serializedPayload);
6668
6633
  }
6669
6634
  const self = DerivedSignal.from(
6670
6635
  context.staticSessionInfoSig,
@@ -6707,7 +6672,7 @@ function createRoom(options, config) {
6707
6672
  } else {
6708
6673
  context.root = LiveObject._fromItems(message.items, pool);
6709
6674
  }
6710
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _145 => _145.get, 'call', _146 => _146(), 'optionalAccess', _147 => _147.canWrite]), () => ( true));
6675
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _146 => _146.get, 'call', _147 => _147(), 'optionalAccess', _148 => _148.canWrite]), () => ( true));
6711
6676
  const stackSizeBefore = context.undoStack.length;
6712
6677
  for (const key in context.initialStorage) {
6713
6678
  if (context.root.get(key) === void 0) {
@@ -6910,7 +6875,7 @@ function createRoom(options, config) {
6910
6875
  }
6911
6876
  context.myPresence.patch(patch);
6912
6877
  if (context.activeBatch) {
6913
- if (_optionalChain([options2, 'optionalAccess', _148 => _148.addToHistory])) {
6878
+ if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
6914
6879
  context.activeBatch.reverseOps.unshift({
6915
6880
  type: "presence",
6916
6881
  data: oldValues
@@ -6919,7 +6884,7 @@ function createRoom(options, config) {
6919
6884
  context.activeBatch.updates.presence = true;
6920
6885
  } else {
6921
6886
  flushNowOrSoon();
6922
- if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
6887
+ if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
6923
6888
  addToUndoStack([{ type: "presence", data: oldValues }]);
6924
6889
  }
6925
6890
  notify({ presence: true });
@@ -7116,7 +7081,7 @@ function createRoom(options, config) {
7116
7081
  if (process.env.NODE_ENV !== "production") {
7117
7082
  const traces = /* @__PURE__ */ new Set();
7118
7083
  for (const opId of message.opIds) {
7119
- const trace = _optionalChain([context, 'access', _150 => _150.opStackTraces, 'optionalAccess', _151 => _151.get, 'call', _152 => _152(opId)]);
7084
+ const trace = _optionalChain([context, 'access', _151 => _151.opStackTraces, 'optionalAccess', _152 => _152.get, 'call', _153 => _153(opId)]);
7120
7085
  if (trace) {
7121
7086
  traces.add(trace);
7122
7087
  }
@@ -7250,7 +7215,7 @@ ${Array.from(traces).join("\n\n")}`
7250
7215
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
7251
7216
  createOrUpdateRootFromMessage(message);
7252
7217
  applyAndSendOps(unacknowledgedOps);
7253
- _optionalChain([_resolveStoragePromise, 'optionalCall', _153 => _153()]);
7218
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _154 => _154()]);
7254
7219
  notifyStorageStatus();
7255
7220
  eventHub.storageDidLoad.notify();
7256
7221
  }
@@ -7472,8 +7437,8 @@ ${Array.from(traces).join("\n\n")}`
7472
7437
  async function getThreads(options2) {
7473
7438
  return httpClient.getThreads({
7474
7439
  roomId,
7475
- query: _optionalChain([options2, 'optionalAccess', _154 => _154.query]),
7476
- cursor: _optionalChain([options2, 'optionalAccess', _155 => _155.cursor])
7440
+ query: _optionalChain([options2, 'optionalAccess', _155 => _155.query]),
7441
+ cursor: _optionalChain([options2, 'optionalAccess', _156 => _156.cursor])
7477
7442
  });
7478
7443
  }
7479
7444
  async function getThread(threadId) {
@@ -7574,7 +7539,7 @@ ${Array.from(traces).join("\n\n")}`
7574
7539
  function getNotificationSettings(options2) {
7575
7540
  return httpClient.getNotificationSettings({
7576
7541
  roomId,
7577
- signal: _optionalChain([options2, 'optionalAccess', _156 => _156.signal])
7542
+ signal: _optionalChain([options2, 'optionalAccess', _157 => _157.signal])
7578
7543
  });
7579
7544
  }
7580
7545
  function updateNotificationSettings(settings) {
@@ -7596,7 +7561,7 @@ ${Array.from(traces).join("\n\n")}`
7596
7561
  {
7597
7562
  [kInternal]: {
7598
7563
  get presenceBuffer() {
7599
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _157 => _157.buffer, 'access', _158 => _158.presenceUpdates, 'optionalAccess', _159 => _159.data]), () => ( null)));
7564
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _158 => _158.buffer, 'access', _159 => _159.presenceUpdates, 'optionalAccess', _160 => _160.data]), () => ( null)));
7600
7565
  },
7601
7566
  // prettier-ignore
7602
7567
  get undoStack() {
@@ -7611,9 +7576,9 @@ ${Array.from(traces).join("\n\n")}`
7611
7576
  return context.yjsProvider;
7612
7577
  },
7613
7578
  setYjsProvider(newProvider) {
7614
- _optionalChain([context, 'access', _160 => _160.yjsProvider, 'optionalAccess', _161 => _161.off, 'call', _162 => _162("status", yjsStatusDidChange)]);
7579
+ _optionalChain([context, 'access', _161 => _161.yjsProvider, 'optionalAccess', _162 => _162.off, 'call', _163 => _163("status", yjsStatusDidChange)]);
7615
7580
  context.yjsProvider = newProvider;
7616
- _optionalChain([newProvider, 'optionalAccess', _163 => _163.on, 'call', _164 => _164("status", yjsStatusDidChange)]);
7581
+ _optionalChain([newProvider, 'optionalAccess', _164 => _164.on, 'call', _165 => _165("status", yjsStatusDidChange)]);
7617
7582
  context.yjsProviderDidChange.notify();
7618
7583
  },
7619
7584
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -7653,7 +7618,7 @@ ${Array.from(traces).join("\n\n")}`
7653
7618
  disconnect: () => managedSocket.disconnect(),
7654
7619
  destroy: () => {
7655
7620
  syncSourceForStorage.destroy();
7656
- _optionalChain([context, 'access', _165 => _165.yjsProvider, 'optionalAccess', _166 => _166.off, 'call', _167 => _167("status", yjsStatusDidChange)]);
7621
+ _optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
7657
7622
  syncSourceForYjs.destroy();
7658
7623
  uninstallBgTabSpy();
7659
7624
  managedSocket.destroy();
@@ -7797,7 +7762,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
7797
7762
  }
7798
7763
  if (isLiveNode(first)) {
7799
7764
  const node = first;
7800
- if (_optionalChain([options, 'optionalAccess', _168 => _168.isDeep])) {
7765
+ if (_optionalChain([options, 'optionalAccess', _169 => _169.isDeep])) {
7801
7766
  const storageCallback = second;
7802
7767
  return subscribeToLiveStructureDeeply(node, storageCallback);
7803
7768
  } else {
@@ -7876,8 +7841,8 @@ function createClient(options) {
7876
7841
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
7877
7842
  currentUserId.set(() => userId);
7878
7843
  });
7879
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _169 => _169.polyfills, 'optionalAccess', _170 => _170.fetch]) || /* istanbul ignore next */
7880
- _optionalChain([globalThis, 'access', _171 => _171.fetch, 'optionalAccess', _172 => _172.bind, 'call', _173 => _173(globalThis)]);
7844
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _170 => _170.polyfills, 'optionalAccess', _171 => _171.fetch]) || /* istanbul ignore next */
7845
+ _optionalChain([globalThis, 'access', _172 => _172.fetch, 'optionalAccess', _173 => _173.bind, 'call', _174 => _174(globalThis)]);
7881
7846
  const httpClient = createApiClient({
7882
7847
  baseUrl,
7883
7848
  fetchPolyfill,
@@ -7928,14 +7893,14 @@ function createClient(options) {
7928
7893
  createSocket: makeCreateSocketDelegateForRoom(
7929
7894
  roomId,
7930
7895
  baseUrl,
7931
- _optionalChain([clientOptions, 'access', _174 => _174.polyfills, 'optionalAccess', _175 => _175.WebSocket])
7896
+ _optionalChain([clientOptions, 'access', _175 => _175.polyfills, 'optionalAccess', _176 => _176.WebSocket])
7932
7897
  ),
7933
7898
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7934
7899
  })),
7935
7900
  enableDebugLogging: clientOptions.enableDebugLogging,
7936
7901
  baseUrl,
7937
7902
  errorEventSource: liveblocksErrorSource,
7938
- largeMessageStrategy: _nullishCoalesce(clientOptions.largeMessageStrategy, () => ( (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0))),
7903
+ unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7939
7904
  unstable_streamData: !!clientOptions.unstable_streamData,
7940
7905
  roomHttpClient: httpClient,
7941
7906
  createSyncSource
@@ -7951,7 +7916,7 @@ function createClient(options) {
7951
7916
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7952
7917
  if (shouldConnect) {
7953
7918
  if (typeof atob === "undefined") {
7954
- if (_optionalChain([clientOptions, 'access', _176 => _176.polyfills, 'optionalAccess', _177 => _177.atob]) === void 0) {
7919
+ if (_optionalChain([clientOptions, 'access', _177 => _177.polyfills, 'optionalAccess', _178 => _178.atob]) === void 0) {
7955
7920
  throw new Error(
7956
7921
  "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"
7957
7922
  );
@@ -7963,7 +7928,7 @@ function createClient(options) {
7963
7928
  return leaseRoom(newRoomDetails);
7964
7929
  }
7965
7930
  function getRoom(roomId) {
7966
- const room = _optionalChain([roomsById, 'access', _178 => _178.get, 'call', _179 => _179(roomId), 'optionalAccess', _180 => _180.room]);
7931
+ const room = _optionalChain([roomsById, 'access', _179 => _179.get, 'call', _180 => _180(roomId), 'optionalAccess', _181 => _181.room]);
7967
7932
  return room ? room : null;
7968
7933
  }
7969
7934
  function logout() {
@@ -7983,7 +7948,7 @@ function createClient(options) {
7983
7948
  const batchedResolveUsers = new Batch(
7984
7949
  async (batchedUserIds) => {
7985
7950
  const userIds = batchedUserIds.flat();
7986
- const users = await _optionalChain([resolveUsers, 'optionalCall', _181 => _181({ userIds })]);
7951
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _182 => _182({ userIds })]);
7987
7952
  warnIfNoResolveUsers();
7988
7953
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7989
7954
  },
@@ -8001,7 +7966,7 @@ function createClient(options) {
8001
7966
  const batchedResolveRoomsInfo = new Batch(
8002
7967
  async (batchedRoomIds) => {
8003
7968
  const roomIds = batchedRoomIds.flat();
8004
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _182 => _182({ roomIds })]);
7969
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _183 => _183({ roomIds })]);
8005
7970
  warnIfNoResolveRoomsInfo();
8006
7971
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
8007
7972
  },
@@ -8054,7 +8019,7 @@ function createClient(options) {
8054
8019
  }
8055
8020
  };
8056
8021
  const win = typeof window !== "undefined" ? window : void 0;
8057
- _optionalChain([win, 'optionalAccess', _183 => _183.addEventListener, 'call', _184 => _184("beforeunload", maybePreventClose)]);
8022
+ _optionalChain([win, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("beforeunload", maybePreventClose)]);
8058
8023
  }
8059
8024
  const client = Object.defineProperty(
8060
8025
  {
@@ -8069,6 +8034,9 @@ function createClient(options) {
8069
8034
  markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
8070
8035
  deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
8071
8036
  deleteInboxNotification: httpClient.deleteInboxNotification,
8037
+ // Public channel notification settings API
8038
+ getNotificationSettings: httpClient.getUserNotificationSettings,
8039
+ updateNotificationSettings: httpClient.updateUserNotificationSettings,
8072
8040
  // Advanced resolvers APIs
8073
8041
  resolvers: {
8074
8042
  invalidateUsers: invalidateResolvedUsers,
@@ -8179,7 +8147,7 @@ var commentBodyElementsTypes = {
8179
8147
  mention: "inline"
8180
8148
  };
8181
8149
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8182
- if (!body || !_optionalChain([body, 'optionalAccess', _185 => _185.content])) {
8150
+ if (!body || !_optionalChain([body, 'optionalAccess', _186 => _186.content])) {
8183
8151
  return;
8184
8152
  }
8185
8153
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -8189,13 +8157,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8189
8157
  for (const block of body.content) {
8190
8158
  if (type === "all" || type === "block") {
8191
8159
  if (guard(block)) {
8192
- _optionalChain([visitor, 'optionalCall', _186 => _186(block)]);
8160
+ _optionalChain([visitor, 'optionalCall', _187 => _187(block)]);
8193
8161
  }
8194
8162
  }
8195
8163
  if (type === "all" || type === "inline") {
8196
8164
  for (const inline of block.children) {
8197
8165
  if (guard(inline)) {
8198
- _optionalChain([visitor, 'optionalCall', _187 => _187(inline)]);
8166
+ _optionalChain([visitor, 'optionalCall', _188 => _188(inline)]);
8199
8167
  }
8200
8168
  }
8201
8169
  }
@@ -8220,7 +8188,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
8220
8188
  userIds
8221
8189
  });
8222
8190
  for (const [index, userId] of userIds.entries()) {
8223
- const user = _optionalChain([users, 'optionalAccess', _188 => _188[index]]);
8191
+ const user = _optionalChain([users, 'optionalAccess', _189 => _189[index]]);
8224
8192
  if (user) {
8225
8193
  resolvedUsers.set(userId, user);
8226
8194
  }
@@ -8265,9 +8233,9 @@ function escapeHtml(value) {
8265
8233
  var HtmlSafeString = class {
8266
8234
  #strings;
8267
8235
  #values;
8268
- constructor(strings, values) {
8236
+ constructor(strings, values2) {
8269
8237
  this.#strings = strings;
8270
- this.#values = values;
8238
+ this.#values = values2;
8271
8239
  }
8272
8240
  toString() {
8273
8241
  return this.#strings.reduce((result, str, i) => {
@@ -8275,8 +8243,8 @@ var HtmlSafeString = class {
8275
8243
  });
8276
8244
  }
8277
8245
  };
8278
- function html(strings, ...values) {
8279
- return new HtmlSafeString(strings, values);
8246
+ function html(strings, ...values2) {
8247
+ return new HtmlSafeString(strings, values2);
8280
8248
  }
8281
8249
  var markdownEscapables = {
8282
8250
  _: "\\_",
@@ -8321,9 +8289,9 @@ function escapeMarkdown(value) {
8321
8289
  var MarkdownSafeString = class {
8322
8290
  #strings;
8323
8291
  #values;
8324
- constructor(strings, values) {
8292
+ constructor(strings, values2) {
8325
8293
  this.#strings = strings;
8326
- this.#values = values;
8294
+ this.#values = values2;
8327
8295
  }
8328
8296
  toString() {
8329
8297
  return this.#strings.reduce((result, str, i) => {
@@ -8331,8 +8299,8 @@ var MarkdownSafeString = class {
8331
8299
  });
8332
8300
  }
8333
8301
  };
8334
- function markdown(strings, ...values) {
8335
- return new MarkdownSafeString(strings, values);
8302
+ function markdown(strings, ...values2) {
8303
+ return new MarkdownSafeString(strings, values2);
8336
8304
  }
8337
8305
  function toAbsoluteUrl(url2) {
8338
8306
  if (url2.startsWith("http://") || url2.startsWith("https://")) {
@@ -8347,7 +8315,7 @@ var stringifyCommentBodyPlainElements = {
8347
8315
  text: ({ element }) => element.text,
8348
8316
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
8349
8317
  mention: ({ element, user }) => {
8350
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _189 => _189.name]), () => ( element.id))}`;
8318
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}`;
8351
8319
  }
8352
8320
  };
8353
8321
  var stringifyCommentBodyHtmlElements = {
@@ -8377,7 +8345,7 @@ var stringifyCommentBodyHtmlElements = {
8377
8345
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
8378
8346
  },
8379
8347
  mention: ({ element, user }) => {
8380
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}</span>`;
8348
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}</span>`;
8381
8349
  }
8382
8350
  };
8383
8351
  var stringifyCommentBodyMarkdownElements = {
@@ -8407,19 +8375,19 @@ var stringifyCommentBodyMarkdownElements = {
8407
8375
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
8408
8376
  },
8409
8377
  mention: ({ element, user }) => {
8410
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}`;
8378
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _192 => _192.name]), () => ( element.id))}`;
8411
8379
  }
8412
8380
  };
8413
8381
  async function stringifyCommentBody(body, options) {
8414
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _192 => _192.format]), () => ( "plain"));
8415
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8382
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.format]), () => ( "plain"));
8383
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8416
8384
  const elements = {
8417
8385
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
8418
- ..._optionalChain([options, 'optionalAccess', _194 => _194.elements])
8386
+ ..._optionalChain([options, 'optionalAccess', _195 => _195.elements])
8419
8387
  };
8420
8388
  const resolvedUsers = await resolveUsersInCommentBody(
8421
8389
  body,
8422
- _optionalChain([options, 'optionalAccess', _195 => _195.resolveUsers])
8390
+ _optionalChain([options, 'optionalAccess', _196 => _196.resolveUsers])
8423
8391
  );
8424
8392
  const blocks = body.content.flatMap((block, blockIndex) => {
8425
8393
  switch (block.type) {
@@ -8710,12 +8678,12 @@ function legacy_patchImmutableNode(state, path, update) {
8710
8678
  }
8711
8679
  const newState = Object.assign({}, state);
8712
8680
  for (const key in update.updates) {
8713
- if (_optionalChain([update, 'access', _196 => _196.updates, 'access', _197 => _197[key], 'optionalAccess', _198 => _198.type]) === "update") {
8681
+ if (_optionalChain([update, 'access', _197 => _197.updates, 'access', _198 => _198[key], 'optionalAccess', _199 => _199.type]) === "update") {
8714
8682
  const val = update.node.get(key);
8715
8683
  if (val !== void 0) {
8716
8684
  newState[key] = lsonToJson(val);
8717
8685
  }
8718
- } else if (_optionalChain([update, 'access', _199 => _199.updates, 'access', _200 => _200[key], 'optionalAccess', _201 => _201.type]) === "delete") {
8686
+ } else if (_optionalChain([update, 'access', _200 => _200.updates, 'access', _201 => _201[key], 'optionalAccess', _202 => _202.type]) === "delete") {
8719
8687
  delete newState[key];
8720
8688
  }
8721
8689
  }
@@ -8776,12 +8744,12 @@ function legacy_patchImmutableNode(state, path, update) {
8776
8744
  }
8777
8745
  const newState = Object.assign({}, state);
8778
8746
  for (const key in update.updates) {
8779
- if (_optionalChain([update, 'access', _202 => _202.updates, 'access', _203 => _203[key], 'optionalAccess', _204 => _204.type]) === "update") {
8747
+ if (_optionalChain([update, 'access', _203 => _203.updates, 'access', _204 => _204[key], 'optionalAccess', _205 => _205.type]) === "update") {
8780
8748
  const value = update.node.get(key);
8781
8749
  if (value !== void 0) {
8782
8750
  newState[key] = lsonToJson(value);
8783
8751
  }
8784
- } else if (_optionalChain([update, 'access', _205 => _205.updates, 'access', _206 => _206[key], 'optionalAccess', _207 => _207.type]) === "delete") {
8752
+ } else if (_optionalChain([update, 'access', _206 => _206.updates, 'access', _207 => _207[key], 'optionalAccess', _208 => _208.type]) === "delete") {
8785
8753
  delete newState[key];
8786
8754
  }
8787
8755
  }
@@ -8852,9 +8820,9 @@ function makePoller(callback, intervalMs, options) {
8852
8820
  const startTime = performance.now();
8853
8821
  const doc = typeof document !== "undefined" ? document : void 0;
8854
8822
  const win = typeof window !== "undefined" ? window : void 0;
8855
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _208 => _208.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8823
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _209 => _209.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8856
8824
  const context = {
8857
- inForeground: _optionalChain([doc, 'optionalAccess', _209 => _209.visibilityState]) !== "hidden",
8825
+ inForeground: _optionalChain([doc, 'optionalAccess', _210 => _210.visibilityState]) !== "hidden",
8858
8826
  lastSuccessfulPollAt: startTime,
8859
8827
  count: 0,
8860
8828
  backoff: 0
@@ -8932,11 +8900,11 @@ function makePoller(callback, intervalMs, options) {
8932
8900
  pollNowIfStale();
8933
8901
  }
8934
8902
  function onVisibilityChange() {
8935
- setInForeground(_optionalChain([doc, 'optionalAccess', _210 => _210.visibilityState]) !== "hidden");
8903
+ setInForeground(_optionalChain([doc, 'optionalAccess', _211 => _211.visibilityState]) !== "hidden");
8936
8904
  }
8937
- _optionalChain([doc, 'optionalAccess', _211 => _211.addEventListener, 'call', _212 => _212("visibilitychange", onVisibilityChange)]);
8938
- _optionalChain([win, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("online", onVisibilityChange)]);
8939
- _optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("focus", pollNowIfStale)]);
8905
+ _optionalChain([doc, 'optionalAccess', _212 => _212.addEventListener, 'call', _213 => _213("visibilitychange", onVisibilityChange)]);
8906
+ _optionalChain([win, 'optionalAccess', _214 => _214.addEventListener, 'call', _215 => _215("online", onVisibilityChange)]);
8907
+ _optionalChain([win, 'optionalAccess', _216 => _216.addEventListener, 'call', _217 => _217("focus", pollNowIfStale)]);
8940
8908
  fsm.start();
8941
8909
  return {
8942
8910
  inc,
@@ -9058,6 +9026,11 @@ var SortedList = class _SortedList {
9058
9026
  }
9059
9027
  };
9060
9028
 
9029
+ // src/protocol/UserNotificationSettings.ts
9030
+ function isNotificationChannelEnabled(settings) {
9031
+ return values(settings).every((enabled) => enabled === true);
9032
+ }
9033
+
9061
9034
  // src/types/Others.ts
9062
9035
  var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9063
9036
  TextEditorType2["Lexical"] = "lexical";
@@ -9155,5 +9128,8 @@ var NotificationsApiError = HttpError;
9155
9128
 
9156
9129
 
9157
9130
 
9158
- 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;
9131
+
9132
+
9133
+
9134
+ 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;
9159
9135
  //# sourceMappingURL=index.js.map