@liveblocks/core 2.7.0-beta1 → 2.7.0-versions

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.7.0-beta1";
9
+ var PKG_VERSION = "2.7.0-versions";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1859,7 +1859,8 @@ var Batch = class {
1859
1859
  this.clearDelayTimeout();
1860
1860
  }
1861
1861
  };
1862
- function createBatchStore(batch) {
1862
+ function createBatchStore(callback, options) {
1863
+ const batch = new Batch(callback, options);
1863
1864
  const cache = /* @__PURE__ */ new Map();
1864
1865
  const eventSource2 = makeEventSource();
1865
1866
  function getCacheKey(args) {
@@ -4748,19 +4749,9 @@ function findNonSerializableValue(value, path = "") {
4748
4749
  return false;
4749
4750
  }
4750
4751
 
4751
- // src/lib/chunk.ts
4752
- function chunk(array, size) {
4753
- const chunks = [];
4754
- for (let i = 0, j = array.length; i < j; i += size) {
4755
- chunks.push(array.slice(i, i + size));
4756
- }
4757
- return chunks;
4758
- }
4759
-
4760
4752
  // src/lib/createIds.ts
4761
4753
  var THREAD_ID_PREFIX = "th";
4762
4754
  var COMMENT_ID_PREFIX = "cm";
4763
- var COMMENT_ATTACHMENT_ID_PREFIX = "at";
4764
4755
  var INBOX_NOTIFICATION_ID_PREFIX = "in";
4765
4756
  function createOptimisticId(prefix) {
4766
4757
  return `${prefix}_${nanoid()}`;
@@ -4771,9 +4762,6 @@ function createThreadId() {
4771
4762
  function createCommentId() {
4772
4763
  return createOptimisticId(COMMENT_ID_PREFIX);
4773
4764
  }
4774
- function createCommentAttachmentId() {
4775
- return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
4776
- }
4777
4765
  function createInboxNotificationId() {
4778
4766
  return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
4779
4767
  }
@@ -5176,22 +5164,6 @@ function installBackgroundTabSpy() {
5176
5164
  };
5177
5165
  return [inBackgroundSince, unsub];
5178
5166
  }
5179
- var GET_ATTACHMENT_URLS_BATCH_DELAY = 50;
5180
- var ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
5181
- var ATTACHMENT_PART_BATCH_SIZE = 5;
5182
- function splitFileIntoParts(file) {
5183
- const parts = [];
5184
- let start = 0;
5185
- while (start < file.size) {
5186
- const end = Math.min(start + ATTACHMENT_PART_SIZE, file.size);
5187
- parts.push({
5188
- partNumber: parts.length + 1,
5189
- part: file.slice(start, end)
5190
- });
5191
- start = end;
5192
- }
5193
- return parts;
5194
- }
5195
5167
  var CommentsApiError = class extends Error {
5196
5168
  constructor(message, status, details) {
5197
5169
  super(message);
@@ -5501,6 +5473,29 @@ function createRoom(options, config) {
5501
5473
  })
5502
5474
  });
5503
5475
  }
5476
+ async function listTextVersions() {
5477
+ const authValue = await delegates.authenticate();
5478
+ return fetchClientApi(config.roomId, "/versions/", authValue, {
5479
+ method: "GET"
5480
+ });
5481
+ }
5482
+ async function getTextVersion(versionId) {
5483
+ const authValue = await delegates.authenticate();
5484
+ return fetchClientApi(
5485
+ config.roomId,
5486
+ `/y-version/${encodeURIComponent(versionId)}`,
5487
+ authValue,
5488
+ {
5489
+ method: "GET"
5490
+ }
5491
+ );
5492
+ }
5493
+ async function createTextVersion() {
5494
+ const authValue = await delegates.authenticate();
5495
+ return fetchClientApi(config.roomId, "/version", authValue, {
5496
+ method: "POST"
5497
+ });
5498
+ }
5504
5499
  function sendMessages(messages) {
5505
5500
  const serializedPayload = JSON.stringify(messages);
5506
5501
  const nonce = _optionalChain([context, 'access', _125 => _125.dynamicSessionInfo, 'access', _126 => _126.current, 'optionalAccess', _127 => _127.nonce]);
@@ -6462,8 +6457,7 @@ ${Array.from(traces).join("\n\n")}`
6462
6457
  metadata,
6463
6458
  body,
6464
6459
  commentId = createCommentId(),
6465
- threadId = createThreadId(),
6466
- attachmentIds
6460
+ threadId = createThreadId()
6467
6461
  }) {
6468
6462
  const thread = await fetchCommentsJson("/threads", {
6469
6463
  method: "POST",
@@ -6474,8 +6468,7 @@ ${Array.from(traces).join("\n\n")}`
6474
6468
  id: threadId,
6475
6469
  comment: {
6476
6470
  id: commentId,
6477
- body,
6478
- attachmentIds
6471
+ body
6479
6472
  },
6480
6473
  metadata
6481
6474
  })
@@ -6521,8 +6514,7 @@ ${Array.from(traces).join("\n\n")}`
6521
6514
  async function createComment({
6522
6515
  threadId,
6523
6516
  commentId = createCommentId(),
6524
- body,
6525
- attachmentIds
6517
+ body
6526
6518
  }) {
6527
6519
  const comment = await fetchCommentsJson(
6528
6520
  `/threads/${encodeURIComponent(threadId)}/comments`,
@@ -6533,8 +6525,7 @@ ${Array.from(traces).join("\n\n")}`
6533
6525
  },
6534
6526
  body: JSON.stringify({
6535
6527
  id: commentId,
6536
- body,
6537
- attachmentIds
6528
+ body
6538
6529
  })
6539
6530
  }
6540
6531
  );
@@ -6543,8 +6534,7 @@ ${Array.from(traces).join("\n\n")}`
6543
6534
  async function editComment({
6544
6535
  threadId,
6545
6536
  commentId,
6546
- body,
6547
- attachmentIds
6537
+ body
6548
6538
  }) {
6549
6539
  const comment = await fetchCommentsJson(
6550
6540
  `/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
@@ -6556,8 +6546,7 @@ ${Array.from(traces).join("\n\n")}`
6556
6546
  "Content-Type": "application/json"
6557
6547
  },
6558
6548
  body: JSON.stringify({
6559
- body,
6560
- attachmentIds
6549
+ body
6561
6550
  })
6562
6551
  }
6563
6552
  );
@@ -6609,126 +6598,6 @@ ${Array.from(traces).join("\n\n")}`
6609
6598
  }
6610
6599
  );
6611
6600
  }
6612
- function prepareAttachment(file) {
6613
- return {
6614
- type: "localAttachment",
6615
- status: "idle",
6616
- id: createCommentAttachmentId(),
6617
- name: file.name,
6618
- size: file.size,
6619
- mimeType: file.type,
6620
- file
6621
- };
6622
- }
6623
- async function uploadAttachment(attachment, options2 = {}) {
6624
- const abortSignal = options2.signal;
6625
- const abortError = abortSignal ? new DOMException(
6626
- `Upload of attachment ${attachment.id} was aborted.`,
6627
- "AbortError"
6628
- ) : void 0;
6629
- if (_optionalChain([abortSignal, 'optionalAccess', _140 => _140.aborted])) {
6630
- throw abortError;
6631
- }
6632
- if (attachment.size <= ATTACHMENT_PART_SIZE) {
6633
- return fetchCommentsJson(
6634
- `/attachments/${encodeURIComponent(attachment.id)}/upload/${encodeURIComponent(attachment.name)}`,
6635
- {
6636
- method: "PUT",
6637
- body: attachment.file,
6638
- signal: abortSignal
6639
- }
6640
- );
6641
- } else {
6642
- let uploadId;
6643
- const uploadedParts = [];
6644
- try {
6645
- const createMultiPartUpload = await fetchCommentsJson(
6646
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(attachment.name)}`,
6647
- {
6648
- method: "POST",
6649
- signal: abortSignal
6650
- }
6651
- );
6652
- uploadId = createMultiPartUpload.uploadId;
6653
- const parts = splitFileIntoParts(attachment.file);
6654
- if (_optionalChain([abortSignal, 'optionalAccess', _141 => _141.aborted])) {
6655
- throw abortError;
6656
- }
6657
- const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
6658
- for (const parts2 of batches) {
6659
- const uploadedPartsPromises = [];
6660
- for (const { part, partNumber } of parts2) {
6661
- uploadedPartsPromises.push(
6662
- fetchCommentsJson(
6663
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/${encodeURIComponent(partNumber)}`,
6664
- {
6665
- method: "PUT",
6666
- body: part,
6667
- signal: abortSignal
6668
- }
6669
- )
6670
- );
6671
- }
6672
- uploadedParts.push(...await Promise.all(uploadedPartsPromises));
6673
- }
6674
- if (_optionalChain([abortSignal, 'optionalAccess', _142 => _142.aborted])) {
6675
- throw abortError;
6676
- }
6677
- const sortedUploadedParts = uploadedParts.sort(
6678
- (a, b) => a.partNumber - b.partNumber
6679
- );
6680
- return fetchCommentsJson(
6681
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/complete`,
6682
- {
6683
- method: "POST",
6684
- headers: {
6685
- "Content-Type": "application/json"
6686
- },
6687
- body: JSON.stringify({ parts: sortedUploadedParts }),
6688
- signal: abortSignal
6689
- }
6690
- );
6691
- } catch (error3) {
6692
- if (uploadId && _optionalChain([error3, 'optionalAccess', _143 => _143.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
6693
- await fetchCommentsApi(
6694
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
6695
- void 0,
6696
- {
6697
- method: "DELETE"
6698
- }
6699
- );
6700
- }
6701
- throw error3;
6702
- }
6703
- }
6704
- }
6705
- async function getAttachmentUrls(attachmentIds) {
6706
- const { urls } = await fetchCommentsJson(
6707
- "/attachments/presigned-urls",
6708
- {
6709
- method: "POST",
6710
- headers: {
6711
- "Content-Type": "application/json"
6712
- },
6713
- body: JSON.stringify({ attachmentIds })
6714
- }
6715
- );
6716
- return urls;
6717
- }
6718
- const batchedGetAttachmentUrls = new Batch(
6719
- async (batchedAttachmentIds) => {
6720
- const attachmentIds = batchedAttachmentIds.flat();
6721
- const attachmentUrls = await getAttachmentUrls(attachmentIds);
6722
- return attachmentUrls.map(
6723
- (url) => _nullishCoalesce(url, () => ( new Error("There was an error while getting this attachment's URL")))
6724
- );
6725
- },
6726
- { delay: GET_ATTACHMENT_URLS_BATCH_DELAY }
6727
- );
6728
- const attachmentUrlsStore = createBatchStore(batchedGetAttachmentUrls);
6729
- function getAttachmentUrl(attachmentId) {
6730
- return batchedGetAttachmentUrls.get(attachmentId);
6731
- }
6732
6601
  async function fetchNotificationsJson(endpoint, options2) {
6733
6602
  const authValue = await delegates.authenticate();
6734
6603
  const response = await fetchClientApi(
@@ -6805,7 +6674,7 @@ ${Array.from(traces).join("\n\n")}`
6805
6674
  {
6806
6675
  [kInternal]: {
6807
6676
  get presenceBuffer() {
6808
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _144 => _144.buffer, 'access', _145 => _145.presenceUpdates, 'optionalAccess', _146 => _146.data]), () => ( null)));
6677
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _140 => _140.buffer, 'access', _141 => _141.presenceUpdates, 'optionalAccess', _142 => _142.data]), () => ( null)));
6809
6678
  },
6810
6679
  // prettier-ignore
6811
6680
  get undoStack() {
@@ -6830,6 +6699,12 @@ ${Array.from(traces).join("\n\n")}`
6830
6699
  createTextMention,
6831
6700
  // delete a text mention when using a text editor
6832
6701
  deleteTextMention,
6702
+ // list versions of the document
6703
+ listTextVersions,
6704
+ // get a specific version
6705
+ getTextVersion,
6706
+ // create a version
6707
+ createTextVersion,
6833
6708
  // Support for the Liveblocks browser extension
6834
6709
  getSelf_forDevTools: () => selfAsTreeNode.current,
6835
6710
  getOthers_forDevTools: () => others_forDevTools.current,
@@ -6838,8 +6713,7 @@ ${Array.from(traces).join("\n\n")}`
6838
6713
  // These exist only for our E2E testing app
6839
6714
  explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
6840
6715
  rawSend: (data) => managedSocket.send(data)
6841
- },
6842
- attachmentUrlsStore
6716
+ }
6843
6717
  },
6844
6718
  id: config.roomId,
6845
6719
  subscribe: makeClassicSubscribeFn(events),
@@ -6894,9 +6768,6 @@ ${Array.from(traces).join("\n\n")}`
6894
6768
  deleteComment: deleteComment2,
6895
6769
  addReaction: addReaction2,
6896
6770
  removeReaction: removeReaction2,
6897
- prepareAttachment,
6898
- uploadAttachment,
6899
- getAttachmentUrl,
6900
6771
  // Notifications
6901
6772
  getNotificationSettings,
6902
6773
  updateNotificationSettings,
@@ -6983,7 +6854,7 @@ function makeClassicSubscribeFn(events) {
6983
6854
  }
6984
6855
  if (isLiveNode(first)) {
6985
6856
  const node = first;
6986
- if (_optionalChain([options, 'optionalAccess', _147 => _147.isDeep])) {
6857
+ if (_optionalChain([options, 'optionalAccess', _143 => _143.isDeep])) {
6987
6858
  const storageCallback = second;
6988
6859
  return subscribeToLiveStructureDeeply(node, storageCallback);
6989
6860
  } else {
@@ -7036,7 +6907,8 @@ function createClientStore() {
7036
6907
  queries: {},
7037
6908
  optimisticUpdates: [],
7038
6909
  inboxNotifications: {},
7039
- notificationSettings: {}
6910
+ notificationSettings: {},
6911
+ versions: {}
7040
6912
  });
7041
6913
  const optimisticUpdatesEventSource = makeEventSource();
7042
6914
  return {
@@ -7067,6 +6939,19 @@ function createClientStore() {
7067
6939
  };
7068
6940
  });
7069
6941
  },
6942
+ updateRoomVersions(roomId, versions, queryKey) {
6943
+ store.set((state) => ({
6944
+ ...state,
6945
+ versions: {
6946
+ ...state.versions,
6947
+ [roomId]: versions
6948
+ },
6949
+ queries: queryKey !== void 0 ? {
6950
+ ...state.queries,
6951
+ [queryKey]: { isLoading: false, data: void 0 }
6952
+ } : state.queries
6953
+ }));
6954
+ },
7070
6955
  updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads, deletedInboxNotifications, queryKey) {
7071
6956
  store.set((state) => ({
7072
6957
  ...state,
@@ -7393,7 +7278,7 @@ function upsertComment(thread, comment) {
7393
7278
  );
7394
7279
  if (existingComment === void 0) {
7395
7280
  const updatedAt = new Date(
7396
- Math.max(_optionalChain([thread, 'access', _148 => _148.updatedAt, 'optionalAccess', _149 => _149.getTime, 'call', _150 => _150()]) || 0, comment.createdAt.getTime())
7281
+ Math.max(_optionalChain([thread, 'access', _144 => _144.updatedAt, 'optionalAccess', _145 => _145.getTime, 'call', _146 => _146()]) || 0, comment.createdAt.getTime())
7397
7282
  );
7398
7283
  const updatedThread = {
7399
7284
  ...thread,
@@ -7413,8 +7298,8 @@ function upsertComment(thread, comment) {
7413
7298
  ...thread,
7414
7299
  updatedAt: new Date(
7415
7300
  Math.max(
7416
- _optionalChain([thread, 'access', _151 => _151.updatedAt, 'optionalAccess', _152 => _152.getTime, 'call', _153 => _153()]) || 0,
7417
- _optionalChain([comment, 'access', _154 => _154.editedAt, 'optionalAccess', _155 => _155.getTime, 'call', _156 => _156()]) || comment.createdAt.getTime()
7301
+ _optionalChain([thread, 'access', _147 => _147.updatedAt, 'optionalAccess', _148 => _148.getTime, 'call', _149 => _149()]) || 0,
7302
+ _optionalChain([comment, 'access', _150 => _150.editedAt, 'optionalAccess', _151 => _151.getTime, 'call', _152 => _152()]) || comment.createdAt.getTime()
7418
7303
  )
7419
7304
  ),
7420
7305
  comments: updatedComments
@@ -7479,7 +7364,7 @@ function addReaction(thread, commentId, reaction) {
7479
7364
  return {
7480
7365
  ...thread,
7481
7366
  updatedAt: new Date(
7482
- Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _157 => _157.updatedAt, 'optionalAccess', _158 => _158.getTime, 'call', _159 => _159()]) || 0)
7367
+ Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0)
7483
7368
  ),
7484
7369
  comments: updatedComments
7485
7370
  };
@@ -7512,7 +7397,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
7512
7397
  return {
7513
7398
  ...thread,
7514
7399
  updatedAt: new Date(
7515
- Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _160 => _160.updatedAt, 'optionalAccess', _161 => _161.getTime, 'call', _162 => _162()]) || 0)
7400
+ Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _156 => _156.updatedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 0)
7516
7401
  ),
7517
7402
  comments: updatedComments
7518
7403
  };
@@ -7623,12 +7508,12 @@ function createClient(options) {
7623
7508
  createSocket: makeCreateSocketDelegateForRoom(
7624
7509
  roomId,
7625
7510
  baseUrl,
7626
- _optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
7511
+ _optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.WebSocket])
7627
7512
  ),
7628
7513
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7629
7514
  })),
7630
7515
  enableDebugLogging: clientOptions.enableDebugLogging,
7631
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
7516
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _161 => _161.unstable_batchedUpdates]),
7632
7517
  baseUrl,
7633
7518
  unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7634
7519
  unstable_streamData: !!clientOptions.unstable_streamData
@@ -7644,7 +7529,7 @@ function createClient(options) {
7644
7529
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7645
7530
  if (shouldConnect) {
7646
7531
  if (typeof atob === "undefined") {
7647
- if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
7532
+ if (_optionalChain([clientOptions, 'access', _162 => _162.polyfills, 'optionalAccess', _163 => _163.atob]) === void 0) {
7648
7533
  throw new Error(
7649
7534
  "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"
7650
7535
  );
@@ -7656,7 +7541,7 @@ function createClient(options) {
7656
7541
  return leaseRoom(newRoomDetails);
7657
7542
  }
7658
7543
  function getRoom(roomId) {
7659
- const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
7544
+ const room = _optionalChain([roomsById, 'access', _164 => _164.get, 'call', _165 => _165(roomId), 'optionalAccess', _166 => _166.room]);
7660
7545
  return room ? room : null;
7661
7546
  }
7662
7547
  function logout() {
@@ -7680,7 +7565,7 @@ function createClient(options) {
7680
7565
  getThreadsSince
7681
7566
  } = createNotificationsApi({
7682
7567
  baseUrl,
7683
- fetcher: _optionalChain([clientOptions, 'access', _171 => _171.polyfills, 'optionalAccess', _172 => _172.fetch]) || /* istanbul ignore next */
7568
+ fetcher: _optionalChain([clientOptions, 'access', _167 => _167.polyfills, 'optionalAccess', _168 => _168.fetch]) || /* istanbul ignore next */
7684
7569
  fetch,
7685
7570
  authManager,
7686
7571
  currentUserIdStore
@@ -7691,31 +7576,29 @@ function createClient(options) {
7691
7576
  () => !resolveUsers,
7692
7577
  "Set the resolveUsers option in createClient to specify user info."
7693
7578
  );
7694
- const batchedResolveUsers = new Batch(
7579
+ const usersStore = createBatchStore(
7695
7580
  async (batchedUserIds) => {
7696
7581
  const userIds = batchedUserIds.flat();
7697
- const users = await _optionalChain([resolveUsers, 'optionalCall', _173 => _173({ userIds })]);
7582
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
7698
7583
  warnIfNoResolveUsers();
7699
7584
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7700
7585
  },
7701
7586
  { delay: RESOLVE_USERS_BATCH_DELAY }
7702
7587
  );
7703
- const usersStore = createBatchStore(batchedResolveUsers);
7704
7588
  const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
7705
7589
  const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
7706
7590
  () => !resolveRoomsInfo,
7707
7591
  "Set the resolveRoomsInfo option in createClient to specify room info."
7708
7592
  );
7709
- const batchedResolveRoomsInfo = new Batch(
7593
+ const roomsInfoStore = createBatchStore(
7710
7594
  async (batchedRoomIds) => {
7711
7595
  const roomIds = batchedRoomIds.flat();
7712
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _174 => _174({ roomIds })]);
7596
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
7713
7597
  warnIfNoResolveRoomsInfo();
7714
7598
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
7715
7599
  },
7716
7600
  { delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
7717
7601
  );
7718
- const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
7719
7602
  return Object.defineProperty(
7720
7603
  {
7721
7604
  enterRoom,
@@ -7826,7 +7709,7 @@ var commentBodyElementsTypes = {
7826
7709
  mention: "inline"
7827
7710
  };
7828
7711
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7829
- if (!body || !_optionalChain([body, 'optionalAccess', _175 => _175.content])) {
7712
+ if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
7830
7713
  return;
7831
7714
  }
7832
7715
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -7836,13 +7719,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7836
7719
  for (const block of body.content) {
7837
7720
  if (type === "all" || type === "block") {
7838
7721
  if (guard(block)) {
7839
- _optionalChain([visitor, 'optionalCall', _176 => _176(block)]);
7722
+ _optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
7840
7723
  }
7841
7724
  }
7842
7725
  if (type === "all" || type === "inline") {
7843
7726
  for (const inline of block.children) {
7844
7727
  if (guard(inline)) {
7845
- _optionalChain([visitor, 'optionalCall', _177 => _177(inline)]);
7728
+ _optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
7846
7729
  }
7847
7730
  }
7848
7731
  }
@@ -7867,7 +7750,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
7867
7750
  userIds
7868
7751
  });
7869
7752
  for (const [index, userId] of userIds.entries()) {
7870
- const user = _optionalChain([users, 'optionalAccess', _178 => _178[index]]);
7753
+ const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
7871
7754
  if (user) {
7872
7755
  resolvedUsers.set(userId, user);
7873
7756
  }
@@ -7990,7 +7873,7 @@ var stringifyCommentBodyPlainElements = {
7990
7873
  text: ({ element }) => element.text,
7991
7874
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7992
7875
  mention: ({ element, user }) => {
7993
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _179 => _179.name]), () => ( element.id))}`;
7876
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
7994
7877
  }
7995
7878
  };
7996
7879
  var stringifyCommentBodyHtmlElements = {
@@ -8020,7 +7903,7 @@ var stringifyCommentBodyHtmlElements = {
8020
7903
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
8021
7904
  },
8022
7905
  mention: ({ element, user }) => {
8023
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _180 => _180.name]), () => ( element.id))}</span>`;
7906
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _176 => _176.name]), () => ( element.id))}</span>`;
8024
7907
  }
8025
7908
  };
8026
7909
  var stringifyCommentBodyMarkdownElements = {
@@ -8050,19 +7933,19 @@ var stringifyCommentBodyMarkdownElements = {
8050
7933
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
8051
7934
  },
8052
7935
  mention: ({ element, user }) => {
8053
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
7936
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
8054
7937
  }
8055
7938
  };
8056
7939
  async function stringifyCommentBody(body, options) {
8057
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.format]), () => ( "plain"));
8058
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _183 => _183.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
7940
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.format]), () => ( "plain"));
7941
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8059
7942
  const elements = {
8060
7943
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
8061
- ..._optionalChain([options, 'optionalAccess', _184 => _184.elements])
7944
+ ..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
8062
7945
  };
8063
7946
  const resolvedUsers = await resolveUsersInCommentBody(
8064
7947
  body,
8065
- _optionalChain([options, 'optionalAccess', _185 => _185.resolveUsers])
7948
+ _optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
8066
7949
  );
8067
7950
  const blocks = body.content.flatMap((block, blockIndex) => {
8068
7951
  switch (block.type) {
@@ -8337,12 +8220,12 @@ function legacy_patchImmutableNode(state, path, update) {
8337
8220
  }
8338
8221
  const newState = Object.assign({}, state);
8339
8222
  for (const key in update.updates) {
8340
- if (_optionalChain([update, 'access', _186 => _186.updates, 'access', _187 => _187[key], 'optionalAccess', _188 => _188.type]) === "update") {
8223
+ if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
8341
8224
  const val = update.node.get(key);
8342
8225
  if (val !== void 0) {
8343
8226
  newState[key] = lsonToJson(val);
8344
8227
  }
8345
- } else if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "delete") {
8228
+ } else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
8346
8229
  delete newState[key];
8347
8230
  }
8348
8231
  }
@@ -8403,12 +8286,12 @@ function legacy_patchImmutableNode(state, path, update) {
8403
8286
  }
8404
8287
  const newState = Object.assign({}, state);
8405
8288
  for (const key in update.updates) {
8406
- if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
8289
+ if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
8407
8290
  const value = update.node.get(key);
8408
8291
  if (value !== void 0) {
8409
8292
  newState[key] = lsonToJson(value);
8410
8293
  }
8411
- } else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
8294
+ } else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
8412
8295
  delete newState[key];
8413
8296
  }
8414
8297
  }
@@ -8667,6 +8550,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8667
8550
 
8668
8551
 
8669
8552
 
8670
-
8671
- exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
8553
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
8672
8554
  //# sourceMappingURL=index.js.map