@liveblocks/core 2.8.0-beta2 → 2.8.0-beta3

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.8.0-beta2";
9
+ var PKG_VERSION = "2.8.0-beta3";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -5248,6 +5248,19 @@ function installBackgroundTabSpy() {
5248
5248
  var GET_ATTACHMENT_URLS_BATCH_DELAY = 50;
5249
5249
  var ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
5250
5250
  var ATTACHMENT_PART_BATCH_SIZE = 5;
5251
+ var RETRY_ATTEMPTS = 10;
5252
+ var RETRY_DELAYS = [
5253
+ 2e3,
5254
+ 2e3,
5255
+ 2e3,
5256
+ 2e3,
5257
+ 2e3,
5258
+ 2e3,
5259
+ 2e3,
5260
+ 2e3,
5261
+ 2e3,
5262
+ 2e3
5263
+ ];
5251
5264
  function splitFileIntoParts(file) {
5252
5265
  const parts = [];
5253
5266
  let start = 0;
@@ -6721,6 +6734,15 @@ ${Array.from(traces).join("\n\n")}`
6721
6734
  if (_optionalChain([abortSignal, 'optionalAccess', _142 => _142.aborted])) {
6722
6735
  throw abortError;
6723
6736
  }
6737
+ const handleRetryError = (err) => {
6738
+ if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
6739
+ throw abortError;
6740
+ }
6741
+ if (err instanceof CommentsApiError && err.status === 413) {
6742
+ throw err;
6743
+ }
6744
+ return false;
6745
+ };
6724
6746
  if (attachment.size <= ATTACHMENT_PART_SIZE) {
6725
6747
  return autoRetry(
6726
6748
  () => fetchCommentsJson(
@@ -6734,14 +6756,9 @@ ${Array.from(traces).join("\n\n")}`
6734
6756
  fileSize: attachment.size
6735
6757
  }
6736
6758
  ),
6737
- 10,
6738
- [2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3],
6739
- () => {
6740
- if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
6741
- throw abortError;
6742
- }
6743
- return false;
6744
- }
6759
+ RETRY_ATTEMPTS,
6760
+ RETRY_DELAYS,
6761
+ handleRetryError
6745
6762
  );
6746
6763
  } else {
6747
6764
  let uploadId;
@@ -6757,19 +6774,14 @@ ${Array.from(traces).join("\n\n")}`
6757
6774
  fileSize: attachment.size
6758
6775
  }
6759
6776
  ),
6760
- 10,
6761
- [2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3],
6762
- () => {
6763
- if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
6764
- throw abortError;
6765
- }
6766
- return false;
6767
- }
6777
+ RETRY_ATTEMPTS,
6778
+ RETRY_DELAYS,
6779
+ handleRetryError
6768
6780
  );
6769
6781
  try {
6770
6782
  uploadId = createMultiPartUpload.uploadId;
6771
6783
  const parts = splitFileIntoParts(attachment.file);
6772
- if (_optionalChain([abortSignal, 'optionalAccess', _145 => _145.aborted])) {
6784
+ if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
6773
6785
  throw abortError;
6774
6786
  }
6775
6787
  const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
@@ -6786,20 +6798,15 @@ ${Array.from(traces).join("\n\n")}`
6786
6798
  signal: abortSignal
6787
6799
  }
6788
6800
  ),
6789
- 10,
6790
- [2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3, 2e3],
6791
- () => {
6792
- if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
6793
- throw abortError;
6794
- }
6795
- return false;
6796
- }
6801
+ RETRY_ATTEMPTS,
6802
+ RETRY_DELAYS,
6803
+ handleRetryError
6797
6804
  )
6798
6805
  );
6799
6806
  }
6800
6807
  uploadedParts.push(...await Promise.all(uploadedPartsPromises));
6801
6808
  }
6802
- if (_optionalChain([abortSignal, 'optionalAccess', _147 => _147.aborted])) {
6809
+ if (_optionalChain([abortSignal, 'optionalAccess', _145 => _145.aborted])) {
6803
6810
  throw abortError;
6804
6811
  }
6805
6812
  const sortedUploadedParts = uploadedParts.sort(
@@ -6817,7 +6824,7 @@ ${Array.from(traces).join("\n\n")}`
6817
6824
  }
6818
6825
  );
6819
6826
  } catch (error3) {
6820
- if (uploadId && _optionalChain([error3, 'optionalAccess', _148 => _148.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
6827
+ if (uploadId && _optionalChain([error3, 'optionalAccess', _146 => _146.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
6821
6828
  try {
6822
6829
  await fetchCommentsApi(
6823
6830
  `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
@@ -6936,7 +6943,7 @@ ${Array.from(traces).join("\n\n")}`
6936
6943
  {
6937
6944
  [kInternal]: {
6938
6945
  get presenceBuffer() {
6939
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _149 => _149.buffer, 'access', _150 => _150.presenceUpdates, 'optionalAccess', _151 => _151.data]), () => ( null)));
6946
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _147 => _147.buffer, 'access', _148 => _148.presenceUpdates, 'optionalAccess', _149 => _149.data]), () => ( null)));
6940
6947
  },
6941
6948
  // prettier-ignore
6942
6949
  get undoStack() {
@@ -7120,7 +7127,7 @@ function makeClassicSubscribeFn(events) {
7120
7127
  }
7121
7128
  if (isLiveNode(first)) {
7122
7129
  const node = first;
7123
- if (_optionalChain([options, 'optionalAccess', _152 => _152.isDeep])) {
7130
+ if (_optionalChain([options, 'optionalAccess', _150 => _150.isDeep])) {
7124
7131
  const storageCallback = second;
7125
7132
  return subscribeToLiveStructureDeeply(node, storageCallback);
7126
7133
  } else {
@@ -7247,12 +7254,12 @@ function createClient(options) {
7247
7254
  createSocket: makeCreateSocketDelegateForRoom(
7248
7255
  roomId,
7249
7256
  baseUrl,
7250
- _optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.WebSocket])
7257
+ _optionalChain([clientOptions, 'access', _151 => _151.polyfills, 'optionalAccess', _152 => _152.WebSocket])
7251
7258
  ),
7252
7259
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7253
7260
  })),
7254
7261
  enableDebugLogging: clientOptions.enableDebugLogging,
7255
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _155 => _155.unstable_batchedUpdates]),
7262
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _153 => _153.unstable_batchedUpdates]),
7256
7263
  baseUrl,
7257
7264
  unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7258
7265
  unstable_streamData: !!clientOptions.unstable_streamData
@@ -7268,7 +7275,7 @@ function createClient(options) {
7268
7275
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7269
7276
  if (shouldConnect) {
7270
7277
  if (typeof atob === "undefined") {
7271
- if (_optionalChain([clientOptions, 'access', _156 => _156.polyfills, 'optionalAccess', _157 => _157.atob]) === void 0) {
7278
+ if (_optionalChain([clientOptions, 'access', _154 => _154.polyfills, 'optionalAccess', _155 => _155.atob]) === void 0) {
7272
7279
  throw new Error(
7273
7280
  "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"
7274
7281
  );
@@ -7280,7 +7287,7 @@ function createClient(options) {
7280
7287
  return leaseRoom(newRoomDetails);
7281
7288
  }
7282
7289
  function getRoom(roomId) {
7283
- const room = _optionalChain([roomsById, 'access', _158 => _158.get, 'call', _159 => _159(roomId), 'optionalAccess', _160 => _160.room]);
7290
+ const room = _optionalChain([roomsById, 'access', _156 => _156.get, 'call', _157 => _157(roomId), 'optionalAccess', _158 => _158.room]);
7284
7291
  return room ? room : null;
7285
7292
  }
7286
7293
  function logout() {
@@ -7304,7 +7311,7 @@ function createClient(options) {
7304
7311
  getThreadsSince
7305
7312
  } = createNotificationsApi({
7306
7313
  baseUrl,
7307
- fetcher: _optionalChain([clientOptions, 'access', _161 => _161.polyfills, 'optionalAccess', _162 => _162.fetch]) || /* istanbul ignore next */
7314
+ fetcher: _optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.fetch]) || /* istanbul ignore next */
7308
7315
  fetch,
7309
7316
  authManager,
7310
7317
  currentUserIdStore
@@ -7317,7 +7324,7 @@ function createClient(options) {
7317
7324
  const batchedResolveUsers = new Batch(
7318
7325
  async (batchedUserIds) => {
7319
7326
  const userIds = batchedUserIds.flat();
7320
- const users = await _optionalChain([resolveUsers, 'optionalCall', _163 => _163({ userIds })]);
7327
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _161 => _161({ userIds })]);
7321
7328
  warnIfNoResolveUsers();
7322
7329
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7323
7330
  },
@@ -7332,7 +7339,7 @@ function createClient(options) {
7332
7339
  const batchedResolveRoomsInfo = new Batch(
7333
7340
  async (batchedRoomIds) => {
7334
7341
  const roomIds = batchedRoomIds.flat();
7335
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _164 => _164({ roomIds })]);
7342
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _162 => _162({ roomIds })]);
7336
7343
  warnIfNoResolveRoomsInfo();
7337
7344
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
7338
7345
  },
@@ -7448,7 +7455,7 @@ var commentBodyElementsTypes = {
7448
7455
  mention: "inline"
7449
7456
  };
7450
7457
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7451
- if (!body || !_optionalChain([body, 'optionalAccess', _165 => _165.content])) {
7458
+ if (!body || !_optionalChain([body, 'optionalAccess', _163 => _163.content])) {
7452
7459
  return;
7453
7460
  }
7454
7461
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -7458,13 +7465,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7458
7465
  for (const block of body.content) {
7459
7466
  if (type === "all" || type === "block") {
7460
7467
  if (guard(block)) {
7461
- _optionalChain([visitor, 'optionalCall', _166 => _166(block)]);
7468
+ _optionalChain([visitor, 'optionalCall', _164 => _164(block)]);
7462
7469
  }
7463
7470
  }
7464
7471
  if (type === "all" || type === "inline") {
7465
7472
  for (const inline of block.children) {
7466
7473
  if (guard(inline)) {
7467
- _optionalChain([visitor, 'optionalCall', _167 => _167(inline)]);
7474
+ _optionalChain([visitor, 'optionalCall', _165 => _165(inline)]);
7468
7475
  }
7469
7476
  }
7470
7477
  }
@@ -7489,7 +7496,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
7489
7496
  userIds
7490
7497
  });
7491
7498
  for (const [index, userId] of userIds.entries()) {
7492
- const user = _optionalChain([users, 'optionalAccess', _168 => _168[index]]);
7499
+ const user = _optionalChain([users, 'optionalAccess', _166 => _166[index]]);
7493
7500
  if (user) {
7494
7501
  resolvedUsers.set(userId, user);
7495
7502
  }
@@ -7612,7 +7619,7 @@ var stringifyCommentBodyPlainElements = {
7612
7619
  text: ({ element }) => element.text,
7613
7620
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7614
7621
  mention: ({ element, user }) => {
7615
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _169 => _169.name]), () => ( element.id))}`;
7622
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _167 => _167.name]), () => ( element.id))}`;
7616
7623
  }
7617
7624
  };
7618
7625
  var stringifyCommentBodyHtmlElements = {
@@ -7642,7 +7649,7 @@ var stringifyCommentBodyHtmlElements = {
7642
7649
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
7643
7650
  },
7644
7651
  mention: ({ element, user }) => {
7645
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _170 => _170.name]), () => ( element.id))}</span>`;
7652
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}</span>`;
7646
7653
  }
7647
7654
  };
7648
7655
  var stringifyCommentBodyMarkdownElements = {
@@ -7672,19 +7679,19 @@ var stringifyCommentBodyMarkdownElements = {
7672
7679
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
7673
7680
  },
7674
7681
  mention: ({ element, user }) => {
7675
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _171 => _171.name]), () => ( element.id))}`;
7682
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _169 => _169.name]), () => ( element.id))}`;
7676
7683
  }
7677
7684
  };
7678
7685
  async function stringifyCommentBody(body, options) {
7679
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.format]), () => ( "plain"));
7680
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _173 => _173.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
7686
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.format]), () => ( "plain"));
7687
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _171 => _171.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
7681
7688
  const elements = {
7682
7689
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
7683
- ..._optionalChain([options, 'optionalAccess', _174 => _174.elements])
7690
+ ..._optionalChain([options, 'optionalAccess', _172 => _172.elements])
7684
7691
  };
7685
7692
  const resolvedUsers = await resolveUsersInCommentBody(
7686
7693
  body,
7687
- _optionalChain([options, 'optionalAccess', _175 => _175.resolveUsers])
7694
+ _optionalChain([options, 'optionalAccess', _173 => _173.resolveUsers])
7688
7695
  );
7689
7696
  const blocks = body.content.flatMap((block, blockIndex) => {
7690
7697
  switch (block.type) {
@@ -7959,12 +7966,12 @@ function legacy_patchImmutableNode(state, path, update) {
7959
7966
  }
7960
7967
  const newState = Object.assign({}, state);
7961
7968
  for (const key in update.updates) {
7962
- if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "update") {
7969
+ if (_optionalChain([update, 'access', _174 => _174.updates, 'access', _175 => _175[key], 'optionalAccess', _176 => _176.type]) === "update") {
7963
7970
  const val = update.node.get(key);
7964
7971
  if (val !== void 0) {
7965
7972
  newState[key] = lsonToJson(val);
7966
7973
  }
7967
- } else if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "delete") {
7974
+ } else if (_optionalChain([update, 'access', _177 => _177.updates, 'access', _178 => _178[key], 'optionalAccess', _179 => _179.type]) === "delete") {
7968
7975
  delete newState[key];
7969
7976
  }
7970
7977
  }
@@ -8025,12 +8032,12 @@ function legacy_patchImmutableNode(state, path, update) {
8025
8032
  }
8026
8033
  const newState = Object.assign({}, state);
8027
8034
  for (const key in update.updates) {
8028
- if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
8035
+ if (_optionalChain([update, 'access', _180 => _180.updates, 'access', _181 => _181[key], 'optionalAccess', _182 => _182.type]) === "update") {
8029
8036
  const value = update.node.get(key);
8030
8037
  if (value !== void 0) {
8031
8038
  newState[key] = lsonToJson(value);
8032
8039
  }
8033
- } else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
8040
+ } else if (_optionalChain([update, 'access', _183 => _183.updates, 'access', _184 => _184[key], 'optionalAccess', _185 => _185.type]) === "delete") {
8034
8041
  delete newState[key];
8035
8042
  }
8036
8043
  }