@liveblocks/core 3.13.1-hackathon → 3.13.1

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.cjs 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 = "3.13.1-hackathon";
9
+ var PKG_VERSION = "3.13.1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3132,9 +3132,6 @@ var ServerMsgCode = Object.freeze({
3132
3132
  COMMENT_REACTION_ADDED: 405,
3133
3133
  COMMENT_REACTION_REMOVED: 406,
3134
3134
  COMMENT_METADATA_UPDATED: 409,
3135
- // For Agent Sessions
3136
- AGENT_SESSIONS: 501,
3137
- AGENT_MESSAGES: 503,
3138
3135
  // Error codes
3139
3136
  REJECT_STORAGE_OP: 299
3140
3137
  // Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
@@ -6756,8 +6753,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
6756
6753
  }
6757
6754
  child._setParentLink(this, newKey);
6758
6755
  this._insertAndSort(child);
6756
+ const newIndex = this.#items.indexOf(child);
6759
6757
  return {
6760
- modified: false
6758
+ modified: makeUpdate(this, [insertDelta(newIndex, child)]),
6759
+ reverse: []
6761
6760
  };
6762
6761
  } else {
6763
6762
  if (newKey === previousKey) {
@@ -8510,10 +8509,7 @@ var ClientMsgCode = Object.freeze({
8510
8509
  UPDATE_STORAGE: 201,
8511
8510
  // For Yjs support
8512
8511
  FETCH_YDOC: 300,
8513
- UPDATE_YDOC: 301,
8514
- // For Agent Sessions
8515
- FETCH_AGENT_SESSIONS: 500,
8516
- FETCH_AGENT_MESSAGES: 502
8512
+ UPDATE_YDOC: 301
8517
8513
  });
8518
8514
 
8519
8515
  // src/refs/ManagedOthers.ts
@@ -8971,7 +8967,6 @@ function createRoom(options, config) {
8971
8967
  storageStatus: makeEventSource(),
8972
8968
  ydoc: makeEventSource(),
8973
8969
  comments: makeEventSource(),
8974
- agentSessions: makeEventSource(),
8975
8970
  roomWillDestroy: makeEventSource()
8976
8971
  };
8977
8972
  async function createTextMention(mentionId, mention) {
@@ -9582,45 +9577,6 @@ function createRoom(options, config) {
9582
9577
  eventHub.comments.notify(message);
9583
9578
  break;
9584
9579
  }
9585
- case ServerMsgCode.AGENT_SESSIONS: {
9586
- const agentSessionsMsg = message;
9587
- if (agentSessionsMsg.operation === "list") {
9588
- for (const [
9589
- requestId,
9590
- { resolve }
9591
- ] of pendingAgentSessionsRequests) {
9592
- resolve({
9593
- sessions: agentSessionsMsg.sessions,
9594
- nextCursor: agentSessionsMsg.nextCursor
9595
- });
9596
- pendingAgentSessionsRequests.delete(requestId);
9597
- break;
9598
- }
9599
- }
9600
- eventHub.agentSessions.notify(agentSessionsMsg);
9601
- break;
9602
- }
9603
- case ServerMsgCode.AGENT_MESSAGES: {
9604
- const agentMessagesMsg = message;
9605
- if (agentMessagesMsg.operation === "list") {
9606
- for (const [
9607
- requestId,
9608
- { resolve }
9609
- ] of pendingAgentMessagesRequests) {
9610
- const parsedRequestId = JSON.parse(requestId);
9611
- if (parsedRequestId.sessionId === agentMessagesMsg.sessionId) {
9612
- resolve({
9613
- messages: agentMessagesMsg.messages,
9614
- nextCursor: agentMessagesMsg.nextCursor
9615
- });
9616
- pendingAgentMessagesRequests.delete(requestId);
9617
- break;
9618
- }
9619
- }
9620
- }
9621
- eventHub.agentSessions.notify(agentMessagesMsg);
9622
- break;
9623
- }
9624
9580
  default:
9625
9581
  break;
9626
9582
  }
@@ -9722,8 +9678,6 @@ function createRoom(options, config) {
9722
9678
  }
9723
9679
  let _getStorage$ = null;
9724
9680
  let _resolveStoragePromise = null;
9725
- const pendingAgentSessionsRequests = /* @__PURE__ */ new Map();
9726
- const pendingAgentMessagesRequests = /* @__PURE__ */ new Map();
9727
9681
  function processInitialStorage(message) {
9728
9682
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
9729
9683
  createOrUpdateRootFromMessage(message);
@@ -9791,65 +9745,6 @@ function createRoom(options, config) {
9791
9745
  }
9792
9746
  flushNowOrSoon();
9793
9747
  }
9794
- async function fetchAgentSessions(options2) {
9795
- const requestId = JSON.stringify({
9796
- cursor: _optionalChain([options2, 'optionalAccess', _194 => _194.cursor]),
9797
- since: _optionalChain([options2, 'optionalAccess', _195 => _195.since]),
9798
- limit: _optionalChain([options2, 'optionalAccess', _196 => _196.limit]),
9799
- metadata: _optionalChain([options2, 'optionalAccess', _197 => _197.metadata])
9800
- });
9801
- const { promise, resolve, reject } = Promise_withResolvers();
9802
- pendingAgentSessionsRequests.set(requestId, { resolve, reject });
9803
- const message = {
9804
- type: ClientMsgCode.FETCH_AGENT_SESSIONS,
9805
- cursor: _optionalChain([options2, 'optionalAccess', _198 => _198.cursor]),
9806
- since: _optionalChain([options2, 'optionalAccess', _199 => _199.since]),
9807
- limit: _optionalChain([options2, 'optionalAccess', _200 => _200.limit]),
9808
- metadata: _optionalChain([options2, 'optionalAccess', _201 => _201.metadata])
9809
- };
9810
- context.buffer.messages.push(message);
9811
- flushNowOrSoon();
9812
- setTimeout(() => {
9813
- if (pendingAgentSessionsRequests.has(requestId)) {
9814
- pendingAgentSessionsRequests.delete(requestId);
9815
- reject(new Error("Agent sessions fetch timeout"));
9816
- }
9817
- }, 3e4);
9818
- return promise;
9819
- }
9820
- async function fetchAgentMessages(sessionId, options2) {
9821
- const requestId = JSON.stringify({
9822
- sessionId,
9823
- cursor: _optionalChain([options2, 'optionalAccess', _202 => _202.cursor]),
9824
- since: _optionalChain([options2, 'optionalAccess', _203 => _203.since]),
9825
- limit: _optionalChain([options2, 'optionalAccess', _204 => _204.limit])
9826
- });
9827
- const existingRequest = pendingAgentMessagesRequests.get(requestId);
9828
- if (existingRequest) {
9829
- return new Promise((resolve2, reject2) => {
9830
- existingRequest.resolve = resolve2;
9831
- existingRequest.reject = reject2;
9832
- });
9833
- }
9834
- const { promise, resolve, reject } = Promise_withResolvers();
9835
- pendingAgentMessagesRequests.set(requestId, { resolve, reject });
9836
- const message = {
9837
- type: ClientMsgCode.FETCH_AGENT_MESSAGES,
9838
- sessionId,
9839
- cursor: _optionalChain([options2, 'optionalAccess', _205 => _205.cursor]),
9840
- since: _optionalChain([options2, 'optionalAccess', _206 => _206.since]),
9841
- limit: _optionalChain([options2, 'optionalAccess', _207 => _207.limit])
9842
- };
9843
- context.buffer.messages.push(message);
9844
- flushNowOrSoon();
9845
- setTimeout(() => {
9846
- if (pendingAgentMessagesRequests.has(requestId)) {
9847
- pendingAgentMessagesRequests.delete(requestId);
9848
- reject(new Error("Agent messages fetch timeout"));
9849
- }
9850
- }, 3e4);
9851
- return promise;
9852
- }
9853
9748
  function undo() {
9854
9749
  if (context.activeBatch) {
9855
9750
  throw new Error("undo is not allowed during a batch");
@@ -9992,7 +9887,6 @@ function createRoom(options, config) {
9992
9887
  storageStatus: eventHub.storageStatus.observable,
9993
9888
  ydoc: eventHub.ydoc.observable,
9994
9889
  comments: eventHub.comments.observable,
9995
- agentSessions: eventHub.agentSessions.observable,
9996
9890
  roomWillDestroy: eventHub.roomWillDestroy.observable
9997
9891
  };
9998
9892
  async function getThreadsSince(options2) {
@@ -10005,8 +9899,8 @@ function createRoom(options, config) {
10005
9899
  async function getThreads(options2) {
10006
9900
  return httpClient.getThreads({
10007
9901
  roomId,
10008
- query: _optionalChain([options2, 'optionalAccess', _208 => _208.query]),
10009
- cursor: _optionalChain([options2, 'optionalAccess', _209 => _209.cursor])
9902
+ query: _optionalChain([options2, 'optionalAccess', _194 => _194.query]),
9903
+ cursor: _optionalChain([options2, 'optionalAccess', _195 => _195.cursor])
10010
9904
  });
10011
9905
  }
10012
9906
  async function getThread(threadId) {
@@ -10128,7 +10022,7 @@ function createRoom(options, config) {
10128
10022
  function getSubscriptionSettings(options2) {
10129
10023
  return httpClient.getSubscriptionSettings({
10130
10024
  roomId,
10131
- signal: _optionalChain([options2, 'optionalAccess', _210 => _210.signal])
10025
+ signal: _optionalChain([options2, 'optionalAccess', _196 => _196.signal])
10132
10026
  });
10133
10027
  }
10134
10028
  function updateSubscriptionSettings(settings) {
@@ -10150,7 +10044,7 @@ function createRoom(options, config) {
10150
10044
  {
10151
10045
  [kInternal]: {
10152
10046
  get presenceBuffer() {
10153
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _211 => _211.buffer, 'access', _212 => _212.presenceUpdates, 'optionalAccess', _213 => _213.data]), () => ( null)));
10047
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _197 => _197.buffer, 'access', _198 => _198.presenceUpdates, 'optionalAccess', _199 => _199.data]), () => ( null)));
10154
10048
  },
10155
10049
  // prettier-ignore
10156
10050
  get undoStack() {
@@ -10165,9 +10059,9 @@ function createRoom(options, config) {
10165
10059
  return context.yjsProvider;
10166
10060
  },
10167
10061
  setYjsProvider(newProvider) {
10168
- _optionalChain([context, 'access', _214 => _214.yjsProvider, 'optionalAccess', _215 => _215.off, 'call', _216 => _216("status", yjsStatusDidChange)]);
10062
+ _optionalChain([context, 'access', _200 => _200.yjsProvider, 'optionalAccess', _201 => _201.off, 'call', _202 => _202("status", yjsStatusDidChange)]);
10169
10063
  context.yjsProvider = newProvider;
10170
- _optionalChain([newProvider, 'optionalAccess', _217 => _217.on, 'call', _218 => _218("status", yjsStatusDidChange)]);
10064
+ _optionalChain([newProvider, 'optionalAccess', _203 => _203.on, 'call', _204 => _204("status", yjsStatusDidChange)]);
10171
10065
  context.yjsProviderDidChange.notify();
10172
10066
  },
10173
10067
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -10201,7 +10095,7 @@ function createRoom(options, config) {
10201
10095
  id: roomId,
10202
10096
  subscribe: makeClassicSubscribeFn(
10203
10097
  roomId,
10204
- eventHub,
10098
+ events,
10205
10099
  config.errorEventSource
10206
10100
  ),
10207
10101
  connect: () => managedSocket.connect(),
@@ -10213,7 +10107,7 @@ function createRoom(options, config) {
10213
10107
  source.dispose();
10214
10108
  }
10215
10109
  eventHub.roomWillDestroy.notify();
10216
- _optionalChain([context, 'access', _219 => _219.yjsProvider, 'optionalAccess', _220 => _220.off, 'call', _221 => _221("status", yjsStatusDidChange)]);
10110
+ _optionalChain([context, 'access', _205 => _205.yjsProvider, 'optionalAccess', _206 => _206.off, 'call', _207 => _207("status", yjsStatusDidChange)]);
10217
10111
  syncSourceForStorage.destroy();
10218
10112
  syncSourceForYjs.destroy();
10219
10113
  uninstallBgTabSpy();
@@ -10236,8 +10130,6 @@ function createRoom(options, config) {
10236
10130
  resume: resumeHistory
10237
10131
  },
10238
10132
  fetchYDoc,
10239
- fetchAgentSessions,
10240
- fetchAgentMessages,
10241
10133
  getStorage,
10242
10134
  getStorageSnapshot,
10243
10135
  getStorageStatus,
@@ -10366,7 +10258,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
10366
10258
  }
10367
10259
  if (isLiveNode(first)) {
10368
10260
  const node = first;
10369
- if (_optionalChain([options, 'optionalAccess', _222 => _222.isDeep])) {
10261
+ if (_optionalChain([options, 'optionalAccess', _208 => _208.isDeep])) {
10370
10262
  const storageCallback = second;
10371
10263
  return subscribeToLiveStructureDeeply(node, storageCallback);
10372
10264
  } else {
@@ -10449,8 +10341,8 @@ function createClient(options) {
10449
10341
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
10450
10342
  currentUserId.set(() => userId);
10451
10343
  });
10452
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _223 => _223.polyfills, 'optionalAccess', _224 => _224.fetch]) || /* istanbul ignore next */
10453
- _optionalChain([globalThis, 'access', _225 => _225.fetch, 'optionalAccess', _226 => _226.bind, 'call', _227 => _227(globalThis)]);
10344
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _209 => _209.polyfills, 'optionalAccess', _210 => _210.fetch]) || /* istanbul ignore next */
10345
+ _optionalChain([globalThis, 'access', _211 => _211.fetch, 'optionalAccess', _212 => _212.bind, 'call', _213 => _213(globalThis)]);
10454
10346
  const httpClient = createApiClient({
10455
10347
  baseUrl,
10456
10348
  fetchPolyfill,
@@ -10468,7 +10360,7 @@ function createClient(options) {
10468
10360
  delegates: {
10469
10361
  createSocket: makeCreateSocketDelegateForAi(
10470
10362
  baseUrl,
10471
- _optionalChain([clientOptions, 'access', _228 => _228.polyfills, 'optionalAccess', _229 => _229.WebSocket])
10363
+ _optionalChain([clientOptions, 'access', _214 => _214.polyfills, 'optionalAccess', _215 => _215.WebSocket])
10472
10364
  ),
10473
10365
  authenticate: async () => {
10474
10366
  const resp = await authManager.getAuthValue({
@@ -10530,7 +10422,7 @@ function createClient(options) {
10530
10422
  createSocket: makeCreateSocketDelegateForRoom(
10531
10423
  roomId,
10532
10424
  baseUrl,
10533
- _optionalChain([clientOptions, 'access', _230 => _230.polyfills, 'optionalAccess', _231 => _231.WebSocket]),
10425
+ _optionalChain([clientOptions, 'access', _216 => _216.polyfills, 'optionalAccess', _217 => _217.WebSocket]),
10534
10426
  options2.engine
10535
10427
  ),
10536
10428
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
@@ -10555,7 +10447,7 @@ function createClient(options) {
10555
10447
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
10556
10448
  if (shouldConnect) {
10557
10449
  if (typeof atob === "undefined") {
10558
- if (_optionalChain([clientOptions, 'access', _232 => _232.polyfills, 'optionalAccess', _233 => _233.atob]) === void 0) {
10450
+ if (_optionalChain([clientOptions, 'access', _218 => _218.polyfills, 'optionalAccess', _219 => _219.atob]) === void 0) {
10559
10451
  throw new Error(
10560
10452
  "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"
10561
10453
  );
@@ -10567,7 +10459,7 @@ function createClient(options) {
10567
10459
  return leaseRoom(newRoomDetails);
10568
10460
  }
10569
10461
  function getRoom(roomId) {
10570
- const room = _optionalChain([roomsById, 'access', _234 => _234.get, 'call', _235 => _235(roomId), 'optionalAccess', _236 => _236.room]);
10462
+ const room = _optionalChain([roomsById, 'access', _220 => _220.get, 'call', _221 => _221(roomId), 'optionalAccess', _222 => _222.room]);
10571
10463
  return room ? room : null;
10572
10464
  }
10573
10465
  function logout() {
@@ -10583,7 +10475,7 @@ function createClient(options) {
10583
10475
  const batchedResolveUsers = new Batch(
10584
10476
  async (batchedUserIds) => {
10585
10477
  const userIds = batchedUserIds.flat();
10586
- const users = await _optionalChain([resolveUsers, 'optionalCall', _237 => _237({ userIds })]);
10478
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _223 => _223({ userIds })]);
10587
10479
  warnOnceIf(
10588
10480
  !resolveUsers,
10589
10481
  "Set the resolveUsers option in createClient to specify user info."
@@ -10600,7 +10492,7 @@ function createClient(options) {
10600
10492
  const batchedResolveRoomsInfo = new Batch(
10601
10493
  async (batchedRoomIds) => {
10602
10494
  const roomIds = batchedRoomIds.flat();
10603
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _238 => _238({ roomIds })]);
10495
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _224 => _224({ roomIds })]);
10604
10496
  warnOnceIf(
10605
10497
  !resolveRoomsInfo,
10606
10498
  "Set the resolveRoomsInfo option in createClient to specify room info."
@@ -10617,7 +10509,7 @@ function createClient(options) {
10617
10509
  const batchedResolveGroupsInfo = new Batch(
10618
10510
  async (batchedGroupIds) => {
10619
10511
  const groupIds = batchedGroupIds.flat();
10620
- const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _239 => _239({ groupIds })]);
10512
+ const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _225 => _225({ groupIds })]);
10621
10513
  warnOnceIf(
10622
10514
  !resolveGroupsInfo,
10623
10515
  "Set the resolveGroupsInfo option in createClient to specify group info."
@@ -10673,7 +10565,7 @@ function createClient(options) {
10673
10565
  }
10674
10566
  };
10675
10567
  const win = typeof window !== "undefined" ? window : void 0;
10676
- _optionalChain([win, 'optionalAccess', _240 => _240.addEventListener, 'call', _241 => _241("beforeunload", maybePreventClose)]);
10568
+ _optionalChain([win, 'optionalAccess', _226 => _226.addEventListener, 'call', _227 => _227("beforeunload", maybePreventClose)]);
10677
10569
  }
10678
10570
  async function getNotificationSettings(options2) {
10679
10571
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -10800,7 +10692,7 @@ var commentBodyElementsTypes = {
10800
10692
  mention: "inline"
10801
10693
  };
10802
10694
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10803
- if (!body || !_optionalChain([body, 'optionalAccess', _242 => _242.content])) {
10695
+ if (!body || !_optionalChain([body, 'optionalAccess', _228 => _228.content])) {
10804
10696
  return;
10805
10697
  }
10806
10698
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -10810,13 +10702,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10810
10702
  for (const block of body.content) {
10811
10703
  if (type === "all" || type === "block") {
10812
10704
  if (guard(block)) {
10813
- _optionalChain([visitor, 'optionalCall', _243 => _243(block)]);
10705
+ _optionalChain([visitor, 'optionalCall', _229 => _229(block)]);
10814
10706
  }
10815
10707
  }
10816
10708
  if (type === "all" || type === "inline") {
10817
10709
  for (const inline of block.children) {
10818
10710
  if (guard(inline)) {
10819
- _optionalChain([visitor, 'optionalCall', _244 => _244(inline)]);
10711
+ _optionalChain([visitor, 'optionalCall', _230 => _230(inline)]);
10820
10712
  }
10821
10713
  }
10822
10714
  }
@@ -10986,7 +10878,7 @@ var stringifyCommentBodyPlainElements = {
10986
10878
  text: ({ element }) => element.text,
10987
10879
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
10988
10880
  mention: ({ element, user, group }) => {
10989
- return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _245 => _245.name]), () => ( _optionalChain([group, 'optionalAccess', _246 => _246.name]))), () => ( element.id))}`;
10881
+ return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _231 => _231.name]), () => ( _optionalChain([group, 'optionalAccess', _232 => _232.name]))), () => ( element.id))}`;
10990
10882
  }
10991
10883
  };
10992
10884
  var stringifyCommentBodyHtmlElements = {
@@ -11016,7 +10908,7 @@ var stringifyCommentBodyHtmlElements = {
11016
10908
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
11017
10909
  },
11018
10910
  mention: ({ element, user, group }) => {
11019
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _247 => _247.name]) ? html`${_optionalChain([user, 'optionalAccess', _248 => _248.name])}` : _optionalChain([group, 'optionalAccess', _249 => _249.name]) ? html`${_optionalChain([group, 'optionalAccess', _250 => _250.name])}` : element.id}</span>`;
10911
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _233 => _233.name]) ? html`${_optionalChain([user, 'optionalAccess', _234 => _234.name])}` : _optionalChain([group, 'optionalAccess', _235 => _235.name]) ? html`${_optionalChain([group, 'optionalAccess', _236 => _236.name])}` : element.id}</span>`;
11020
10912
  }
11021
10913
  };
11022
10914
  var stringifyCommentBodyMarkdownElements = {
@@ -11046,20 +10938,20 @@ var stringifyCommentBodyMarkdownElements = {
11046
10938
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
11047
10939
  },
11048
10940
  mention: ({ element, user, group }) => {
11049
- return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _251 => _251.name]), () => ( _optionalChain([group, 'optionalAccess', _252 => _252.name]))), () => ( element.id))}`;
10941
+ return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _237 => _237.name]), () => ( _optionalChain([group, 'optionalAccess', _238 => _238.name]))), () => ( element.id))}`;
11050
10942
  }
11051
10943
  };
11052
10944
  async function stringifyCommentBody(body, options) {
11053
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _253 => _253.format]), () => ( "plain"));
11054
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _254 => _254.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10945
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _239 => _239.format]), () => ( "plain"));
10946
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _240 => _240.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
11055
10947
  const elements = {
11056
10948
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
11057
- ..._optionalChain([options, 'optionalAccess', _255 => _255.elements])
10949
+ ..._optionalChain([options, 'optionalAccess', _241 => _241.elements])
11058
10950
  };
11059
10951
  const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
11060
10952
  body,
11061
- _optionalChain([options, 'optionalAccess', _256 => _256.resolveUsers]),
11062
- _optionalChain([options, 'optionalAccess', _257 => _257.resolveGroupsInfo])
10953
+ _optionalChain([options, 'optionalAccess', _242 => _242.resolveUsers]),
10954
+ _optionalChain([options, 'optionalAccess', _243 => _243.resolveGroupsInfo])
11063
10955
  );
11064
10956
  const blocks = body.content.flatMap((block, blockIndex) => {
11065
10957
  switch (block.type) {
@@ -11190,9 +11082,9 @@ function lsonToJson(value) {
11190
11082
  }
11191
11083
  return value;
11192
11084
  }
11193
- function _deepLiveify(value) {
11085
+ function deepLiveify(value) {
11194
11086
  if (Array.isArray(value)) {
11195
- return new LiveList(value.map(_deepLiveify));
11087
+ return new LiveList(value.map(deepLiveify));
11196
11088
  } else if (isPlainObject(value)) {
11197
11089
  const init = {};
11198
11090
  for (const key in value) {
@@ -11200,7 +11092,7 @@ function _deepLiveify(value) {
11200
11092
  if (val === void 0) {
11201
11093
  continue;
11202
11094
  }
11203
- init[key] = _deepLiveify(val);
11095
+ init[key] = deepLiveify(val);
11204
11096
  }
11205
11097
  return new LiveObject(init);
11206
11098
  } else {
@@ -11237,7 +11129,7 @@ function patchLiveList(liveList, prev, next) {
11237
11129
  if (i > prevEnd) {
11238
11130
  if (i <= nextEnd) {
11239
11131
  while (i <= nextEnd) {
11240
- liveList.insert(_deepLiveify(next[i]), i);
11132
+ liveList.insert(deepLiveify(next[i]), i);
11241
11133
  i++;
11242
11134
  }
11243
11135
  }
@@ -11255,12 +11147,12 @@ function patchLiveList(liveList, prev, next) {
11255
11147
  if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
11256
11148
  patchLiveObject(liveListNode, prevNode, nextNode);
11257
11149
  } else {
11258
- liveList.set(i, _deepLiveify(nextNode));
11150
+ liveList.set(i, deepLiveify(nextNode));
11259
11151
  }
11260
11152
  i++;
11261
11153
  }
11262
11154
  while (i <= nextEnd) {
11263
- liveList.insert(_deepLiveify(next[i]), i);
11155
+ liveList.insert(deepLiveify(next[i]), i);
11264
11156
  i++;
11265
11157
  }
11266
11158
  let localI = i;
@@ -11287,7 +11179,7 @@ Only serializable value can be synced with Liveblocks.`
11287
11179
  if (next === void 0) {
11288
11180
  liveObject.delete(key);
11289
11181
  } else if (value === void 0) {
11290
- liveObject.set(key, _deepLiveify(next));
11182
+ liveObject.set(key, deepLiveify(next));
11291
11183
  } else if (prev === next) {
11292
11184
  return;
11293
11185
  } else if (isLiveList(value) && Array.isArray(prev) && Array.isArray(next)) {
@@ -11295,7 +11187,7 @@ Only serializable value can be synced with Liveblocks.`
11295
11187
  } else if (isLiveObject(value) && isPlainObject(prev) && isPlainObject(next)) {
11296
11188
  patchLiveObject(value, prev, next);
11297
11189
  } else {
11298
- liveObject.set(key, _deepLiveify(next));
11190
+ liveObject.set(key, deepLiveify(next));
11299
11191
  }
11300
11192
  }
11301
11193
  function patchLiveObject(root, prev, next) {
@@ -11346,12 +11238,12 @@ function legacy_patchImmutableNode(state, path, update) {
11346
11238
  }
11347
11239
  const newState = Object.assign({}, state);
11348
11240
  for (const key in update.updates) {
11349
- if (_optionalChain([update, 'access', _258 => _258.updates, 'access', _259 => _259[key], 'optionalAccess', _260 => _260.type]) === "update") {
11241
+ if (_optionalChain([update, 'access', _244 => _244.updates, 'access', _245 => _245[key], 'optionalAccess', _246 => _246.type]) === "update") {
11350
11242
  const val = update.node.get(key);
11351
11243
  if (val !== void 0) {
11352
11244
  newState[key] = lsonToJson(val);
11353
11245
  }
11354
- } else if (_optionalChain([update, 'access', _261 => _261.updates, 'access', _262 => _262[key], 'optionalAccess', _263 => _263.type]) === "delete") {
11246
+ } else if (_optionalChain([update, 'access', _247 => _247.updates, 'access', _248 => _248[key], 'optionalAccess', _249 => _249.type]) === "delete") {
11355
11247
  delete newState[key];
11356
11248
  }
11357
11249
  }
@@ -11412,12 +11304,12 @@ function legacy_patchImmutableNode(state, path, update) {
11412
11304
  }
11413
11305
  const newState = Object.assign({}, state);
11414
11306
  for (const key in update.updates) {
11415
- if (_optionalChain([update, 'access', _264 => _264.updates, 'access', _265 => _265[key], 'optionalAccess', _266 => _266.type]) === "update") {
11307
+ if (_optionalChain([update, 'access', _250 => _250.updates, 'access', _251 => _251[key], 'optionalAccess', _252 => _252.type]) === "update") {
11416
11308
  const value = update.node.get(key);
11417
11309
  if (value !== void 0) {
11418
11310
  newState[key] = lsonToJson(value);
11419
11311
  }
11420
- } else if (_optionalChain([update, 'access', _267 => _267.updates, 'access', _268 => _268[key], 'optionalAccess', _269 => _269.type]) === "delete") {
11312
+ } else if (_optionalChain([update, 'access', _253 => _253.updates, 'access', _254 => _254[key], 'optionalAccess', _255 => _255.type]) === "delete") {
11421
11313
  delete newState[key];
11422
11314
  }
11423
11315
  }
@@ -11497,9 +11389,9 @@ function makePoller(callback, intervalMs, options) {
11497
11389
  const startTime = performance.now();
11498
11390
  const doc = typeof document !== "undefined" ? document : void 0;
11499
11391
  const win = typeof window !== "undefined" ? window : void 0;
11500
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11392
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _256 => _256.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11501
11393
  const context = {
11502
- inForeground: _optionalChain([doc, 'optionalAccess', _271 => _271.visibilityState]) !== "hidden",
11394
+ inForeground: _optionalChain([doc, 'optionalAccess', _257 => _257.visibilityState]) !== "hidden",
11503
11395
  lastSuccessfulPollAt: startTime,
11504
11396
  count: 0,
11505
11397
  backoff: 0
@@ -11580,11 +11472,11 @@ function makePoller(callback, intervalMs, options) {
11580
11472
  pollNowIfStale();
11581
11473
  }
11582
11474
  function onVisibilityChange() {
11583
- setInForeground(_optionalChain([doc, 'optionalAccess', _272 => _272.visibilityState]) !== "hidden");
11475
+ setInForeground(_optionalChain([doc, 'optionalAccess', _258 => _258.visibilityState]) !== "hidden");
11584
11476
  }
11585
- _optionalChain([doc, 'optionalAccess', _273 => _273.addEventListener, 'call', _274 => _274("visibilitychange", onVisibilityChange)]);
11586
- _optionalChain([win, 'optionalAccess', _275 => _275.addEventListener, 'call', _276 => _276("online", onVisibilityChange)]);
11587
- _optionalChain([win, 'optionalAccess', _277 => _277.addEventListener, 'call', _278 => _278("focus", pollNowIfStale)]);
11477
+ _optionalChain([doc, 'optionalAccess', _259 => _259.addEventListener, 'call', _260 => _260("visibilitychange", onVisibilityChange)]);
11478
+ _optionalChain([win, 'optionalAccess', _261 => _261.addEventListener, 'call', _262 => _262("online", onVisibilityChange)]);
11479
+ _optionalChain([win, 'optionalAccess', _263 => _263.addEventListener, 'call', _264 => _264("focus", pollNowIfStale)]);
11588
11480
  fsm.start();
11589
11481
  return {
11590
11482
  inc,
@@ -11596,90 +11488,6 @@ function makePoller(callback, intervalMs, options) {
11596
11488
  };
11597
11489
  }
11598
11490
 
11599
- // src/mutations.ts
11600
- function generateOpsFromJson(nodes, mutation, actorId = 1) {
11601
- const capturedOps = [];
11602
- const pool = createManagedPool("mutation-temp", {
11603
- getCurrentConnectionId: () => actorId,
11604
- onDispatch: (ops) => {
11605
- capturedOps.push(...ops);
11606
- }
11607
- });
11608
- const root = LiveObject._fromItems(nodes, pool);
11609
- if (isPlainObject(mutation)) {
11610
- applyMutationToLiveObject(root, mutation);
11611
- } else {
11612
- throw new Error(
11613
- "Root mutation must be an object. Use a nested key to update specific values."
11614
- );
11615
- }
11616
- return capturedOps;
11617
- }
11618
- function applyMutationToLiveObject(target, mutation) {
11619
- for (const key in mutation) {
11620
- const mutationValue = mutation[key];
11621
- if (mutationValue === void 0) {
11622
- continue;
11623
- }
11624
- const existingValue = target.get(key);
11625
- if (isLiveNode(mutationValue)) {
11626
- target.set(key, mutationValue);
11627
- continue;
11628
- }
11629
- if (isLiveObject(existingValue) && isPlainObject(mutationValue)) {
11630
- applyMutationToLiveObject(
11631
- existingValue,
11632
- mutationValue
11633
- );
11634
- } else if (isLiveMap(existingValue) && isPlainObject(mutationValue)) {
11635
- applyMutationToLiveMap(existingValue, mutationValue);
11636
- } else if (isLiveList(existingValue) && Array.isArray(mutationValue)) {
11637
- applyMutationToLiveList(existingValue, mutationValue);
11638
- } else if (existingValue === void 0 && isPlainObject(mutationValue)) {
11639
- const convertedValue = _deepLiveify(mutationValue);
11640
- target.set(key, convertedValue);
11641
- } else {
11642
- target.set(key, mutationValue);
11643
- }
11644
- }
11645
- }
11646
- function applyMutationToLiveMap(target, mutation) {
11647
- for (const key in mutation) {
11648
- const mutationValue = mutation[key];
11649
- if (mutationValue === void 0) {
11650
- continue;
11651
- }
11652
- const existingValue = target.get(key);
11653
- if (isLiveNode(mutationValue)) {
11654
- target.set(key, mutationValue);
11655
- continue;
11656
- }
11657
- if (isLiveObject(existingValue) && isPlainObject(mutationValue)) {
11658
- applyMutationToLiveObject(
11659
- existingValue,
11660
- mutationValue
11661
- );
11662
- } else if (isLiveMap(existingValue) && isPlainObject(mutationValue)) {
11663
- applyMutationToLiveMap(existingValue, mutationValue);
11664
- } else if (isLiveList(existingValue) && Array.isArray(mutationValue)) {
11665
- applyMutationToLiveList(existingValue, mutationValue);
11666
- } else if (existingValue === void 0 && isPlainObject(mutationValue)) {
11667
- const convertedValue = _deepLiveify(mutationValue);
11668
- target.set(key, convertedValue);
11669
- } else {
11670
- const newValue = isLiveNode(mutationValue) ? mutationValue : mutationValue;
11671
- target.set(key, newValue);
11672
- }
11673
- }
11674
- }
11675
- function applyMutationToLiveList(target, mutation) {
11676
- target.clear();
11677
- for (const item of mutation) {
11678
- const liveItem = isLiveNode(item) ? item : item;
11679
- target.push(liveItem);
11680
- }
11681
- }
11682
-
11683
11491
  // src/protocol/Subscriptions.ts
11684
11492
  function getSubscriptionKey(subscription, subjectId) {
11685
11493
  if (typeof subscription === "string") {
@@ -11800,6 +11608,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
11800
11608
 
11801
11609
 
11802
11610
 
11803
-
11804
- exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; 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.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateOpsFromJson = generateOpsFromJson; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; 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.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; 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.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
11611
+ exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; 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.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; 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.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; 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.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
11805
11612
  //# sourceMappingURL=index.cjs.map