@liveblocks/core 2.8.0-beta1 → 2.8.0-beta2

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.d.mts CHANGED
@@ -2748,6 +2748,21 @@ declare function assert(condition: boolean, errmsg: string): asserts condition;
2748
2748
  */
2749
2749
  declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
2750
2750
 
2751
+ /**
2752
+ * Wraps a promise factory. Will create promises until one succeeds. If
2753
+ * a promise rejects, it will retry calling the factory for at most `maxTries`
2754
+ * times. Between each attempt, it will inject a a backoff delay (in millis)
2755
+ * from the given array. If the array contains fewer items then `maxTries`,
2756
+ * then the last backoff number will be used indefinitely.
2757
+ *
2758
+ * If the last attempt is rejected too, the returned promise will fail too.
2759
+ *
2760
+ * @param promiseFn The promise factory to execute
2761
+ * @param maxTries The number of total tries (must be >=1)
2762
+ * @param backoff An array of timings to inject between each promise attempt
2763
+ */
2764
+ declare function autoRetry<T>(promiseFn: () => Promise<T>, maxTries: number, backoff: number[], exitCondition?: (error: any) => boolean): Promise<T>;
2765
+
2751
2766
  declare function chunk<T>(array: T[], size: number): T[][];
2752
2767
 
2753
2768
  declare function createThreadId(): string;
@@ -3118,4 +3133,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
3118
3133
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
3119
3134
  };
3120
3135
 
3121
- export { type AckOp, type ActivityData, type AsyncResult, type AsyncResultWithDataField, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, wait, withTimeout };
3136
+ export { type AckOp, type ActivityData, type AsyncResult, type AsyncResultWithDataField, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, wait, withTimeout };
package/dist/index.d.ts CHANGED
@@ -2748,6 +2748,21 @@ declare function assert(condition: boolean, errmsg: string): asserts condition;
2748
2748
  */
2749
2749
  declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
2750
2750
 
2751
+ /**
2752
+ * Wraps a promise factory. Will create promises until one succeeds. If
2753
+ * a promise rejects, it will retry calling the factory for at most `maxTries`
2754
+ * times. Between each attempt, it will inject a a backoff delay (in millis)
2755
+ * from the given array. If the array contains fewer items then `maxTries`,
2756
+ * then the last backoff number will be used indefinitely.
2757
+ *
2758
+ * If the last attempt is rejected too, the returned promise will fail too.
2759
+ *
2760
+ * @param promiseFn The promise factory to execute
2761
+ * @param maxTries The number of total tries (must be >=1)
2762
+ * @param backoff An array of timings to inject between each promise attempt
2763
+ */
2764
+ declare function autoRetry<T>(promiseFn: () => Promise<T>, maxTries: number, backoff: number[], exitCondition?: (error: any) => boolean): Promise<T>;
2765
+
2751
2766
  declare function chunk<T>(array: T[], size: number): T[][];
2752
2767
 
2753
2768
  declare function createThreadId(): string;
@@ -3118,4 +3133,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
3118
3133
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
3119
3134
  };
3120
3135
 
3121
- export { type AckOp, type ActivityData, type AsyncResult, type AsyncResultWithDataField, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, wait, withTimeout };
3136
+ export { type AckOp, type ActivityData, type AsyncResult, type AsyncResultWithDataField, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LostConnectionEvent, type Lson, type LsonObject, type NoInfr, type NodeMap, NotificationsApiError, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PrivateClientApi, type PrivateRoomApi, type QueryMetadata, type RejectedStorageOpServerMsg, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, type Status, type StorageStatus, type StorageUpdate, type Store, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, autoRetry, b64decode, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentId, createInboxNotificationId, createStore, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, getMentionedIdsFromCommentBody, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, shallow, stringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, wait, withTimeout };
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-beta1";
9
+ var PKG_VERSION = "2.8.0-beta2";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -4795,6 +4795,28 @@ function findNonSerializableValue(value, path = "") {
4795
4795
  return false;
4796
4796
  }
4797
4797
 
4798
+ // src/lib/autoRetry.ts
4799
+ async function autoRetry(promiseFn, maxTries, backoff, exitCondition) {
4800
+ const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
4801
+ let attempt = 0;
4802
+ while (true) {
4803
+ attempt++;
4804
+ const promise = promiseFn();
4805
+ try {
4806
+ return await promise;
4807
+ } catch (err) {
4808
+ if (exitCondition && exitCondition(err)) {
4809
+ throw err;
4810
+ }
4811
+ if (attempt >= maxTries) {
4812
+ throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
4813
+ }
4814
+ }
4815
+ const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
4816
+ await wait(delay);
4817
+ }
4818
+ }
4819
+
4798
4820
  // src/lib/chunk.ts
4799
4821
  function chunk(array, size) {
4800
4822
  const chunks = [];
@@ -6700,28 +6722,54 @@ ${Array.from(traces).join("\n\n")}`
6700
6722
  throw abortError;
6701
6723
  }
6702
6724
  if (attachment.size <= ATTACHMENT_PART_SIZE) {
6703
- return fetchCommentsJson(
6704
- `/attachments/${encodeURIComponent(attachment.id)}/upload/${encodeURIComponent(attachment.name)}`,
6705
- {
6706
- method: "PUT",
6707
- body: attachment.file,
6708
- signal: abortSignal
6725
+ return autoRetry(
6726
+ () => fetchCommentsJson(
6727
+ `/attachments/${encodeURIComponent(attachment.id)}/upload/${encodeURIComponent(attachment.name)}`,
6728
+ {
6729
+ method: "PUT",
6730
+ body: attachment.file,
6731
+ signal: abortSignal
6732
+ },
6733
+ {
6734
+ fileSize: attachment.size
6735
+ }
6736
+ ),
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;
6709
6744
  }
6710
6745
  );
6711
6746
  } else {
6712
6747
  let uploadId;
6713
6748
  const uploadedParts = [];
6714
- try {
6715
- const createMultiPartUpload = await fetchCommentsJson(
6749
+ const createMultiPartUpload = await autoRetry(
6750
+ () => fetchCommentsJson(
6716
6751
  `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(attachment.name)}`,
6717
6752
  {
6718
6753
  method: "POST",
6719
6754
  signal: abortSignal
6755
+ },
6756
+ {
6757
+ fileSize: attachment.size
6720
6758
  }
6721
- );
6759
+ ),
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
+ }
6768
+ );
6769
+ try {
6722
6770
  uploadId = createMultiPartUpload.uploadId;
6723
6771
  const parts = splitFileIntoParts(attachment.file);
6724
- if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
6772
+ if (_optionalChain([abortSignal, 'optionalAccess', _145 => _145.aborted])) {
6725
6773
  throw abortError;
6726
6774
  }
6727
6775
  const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
@@ -6729,19 +6777,29 @@ ${Array.from(traces).join("\n\n")}`
6729
6777
  const uploadedPartsPromises = [];
6730
6778
  for (const { part, partNumber } of parts2) {
6731
6779
  uploadedPartsPromises.push(
6732
- fetchCommentsJson(
6733
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/${encodeURIComponent(partNumber)}`,
6734
- {
6735
- method: "PUT",
6736
- body: part,
6737
- signal: abortSignal
6780
+ autoRetry(
6781
+ () => fetchCommentsJson(
6782
+ `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(createMultiPartUpload.uploadId)}/${encodeURIComponent(partNumber)}`,
6783
+ {
6784
+ method: "PUT",
6785
+ body: part,
6786
+ signal: abortSignal
6787
+ }
6788
+ ),
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;
6738
6796
  }
6739
6797
  )
6740
6798
  );
6741
6799
  }
6742
6800
  uploadedParts.push(...await Promise.all(uploadedPartsPromises));
6743
6801
  }
6744
- if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
6802
+ if (_optionalChain([abortSignal, 'optionalAccess', _147 => _147.aborted])) {
6745
6803
  throw abortError;
6746
6804
  }
6747
6805
  const sortedUploadedParts = uploadedParts.sort(
@@ -6759,14 +6817,17 @@ ${Array.from(traces).join("\n\n")}`
6759
6817
  }
6760
6818
  );
6761
6819
  } catch (error3) {
6762
- if (uploadId && _optionalChain([error3, 'optionalAccess', _145 => _145.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
6763
- await fetchCommentsApi(
6764
- `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
6765
- void 0,
6766
- {
6767
- method: "DELETE"
6768
- }
6769
- );
6820
+ if (uploadId && _optionalChain([error3, 'optionalAccess', _148 => _148.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
6821
+ try {
6822
+ await fetchCommentsApi(
6823
+ `/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
6824
+ void 0,
6825
+ {
6826
+ method: "DELETE"
6827
+ }
6828
+ );
6829
+ } catch (error4) {
6830
+ }
6770
6831
  }
6771
6832
  throw error3;
6772
6833
  }
@@ -6875,7 +6936,7 @@ ${Array.from(traces).join("\n\n")}`
6875
6936
  {
6876
6937
  [kInternal]: {
6877
6938
  get presenceBuffer() {
6878
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _146 => _146.buffer, 'access', _147 => _147.presenceUpdates, 'optionalAccess', _148 => _148.data]), () => ( null)));
6939
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _149 => _149.buffer, 'access', _150 => _150.presenceUpdates, 'optionalAccess', _151 => _151.data]), () => ( null)));
6879
6940
  },
6880
6941
  // prettier-ignore
6881
6942
  get undoStack() {
@@ -7059,7 +7120,7 @@ function makeClassicSubscribeFn(events) {
7059
7120
  }
7060
7121
  if (isLiveNode(first)) {
7061
7122
  const node = first;
7062
- if (_optionalChain([options, 'optionalAccess', _149 => _149.isDeep])) {
7123
+ if (_optionalChain([options, 'optionalAccess', _152 => _152.isDeep])) {
7063
7124
  const storageCallback = second;
7064
7125
  return subscribeToLiveStructureDeeply(node, storageCallback);
7065
7126
  } else {
@@ -7186,12 +7247,12 @@ function createClient(options) {
7186
7247
  createSocket: makeCreateSocketDelegateForRoom(
7187
7248
  roomId,
7188
7249
  baseUrl,
7189
- _optionalChain([clientOptions, 'access', _150 => _150.polyfills, 'optionalAccess', _151 => _151.WebSocket])
7250
+ _optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.WebSocket])
7190
7251
  ),
7191
7252
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
7192
7253
  })),
7193
7254
  enableDebugLogging: clientOptions.enableDebugLogging,
7194
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _152 => _152.unstable_batchedUpdates]),
7255
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _155 => _155.unstable_batchedUpdates]),
7195
7256
  baseUrl,
7196
7257
  unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
7197
7258
  unstable_streamData: !!clientOptions.unstable_streamData
@@ -7207,7 +7268,7 @@ function createClient(options) {
7207
7268
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
7208
7269
  if (shouldConnect) {
7209
7270
  if (typeof atob === "undefined") {
7210
- if (_optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.atob]) === void 0) {
7271
+ if (_optionalChain([clientOptions, 'access', _156 => _156.polyfills, 'optionalAccess', _157 => _157.atob]) === void 0) {
7211
7272
  throw new Error(
7212
7273
  "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"
7213
7274
  );
@@ -7219,7 +7280,7 @@ function createClient(options) {
7219
7280
  return leaseRoom(newRoomDetails);
7220
7281
  }
7221
7282
  function getRoom(roomId) {
7222
- const room = _optionalChain([roomsById, 'access', _155 => _155.get, 'call', _156 => _156(roomId), 'optionalAccess', _157 => _157.room]);
7283
+ const room = _optionalChain([roomsById, 'access', _158 => _158.get, 'call', _159 => _159(roomId), 'optionalAccess', _160 => _160.room]);
7223
7284
  return room ? room : null;
7224
7285
  }
7225
7286
  function logout() {
@@ -7243,7 +7304,7 @@ function createClient(options) {
7243
7304
  getThreadsSince
7244
7305
  } = createNotificationsApi({
7245
7306
  baseUrl,
7246
- fetcher: _optionalChain([clientOptions, 'access', _158 => _158.polyfills, 'optionalAccess', _159 => _159.fetch]) || /* istanbul ignore next */
7307
+ fetcher: _optionalChain([clientOptions, 'access', _161 => _161.polyfills, 'optionalAccess', _162 => _162.fetch]) || /* istanbul ignore next */
7247
7308
  fetch,
7248
7309
  authManager,
7249
7310
  currentUserIdStore
@@ -7256,7 +7317,7 @@ function createClient(options) {
7256
7317
  const batchedResolveUsers = new Batch(
7257
7318
  async (batchedUserIds) => {
7258
7319
  const userIds = batchedUserIds.flat();
7259
- const users = await _optionalChain([resolveUsers, 'optionalCall', _160 => _160({ userIds })]);
7320
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _163 => _163({ userIds })]);
7260
7321
  warnIfNoResolveUsers();
7261
7322
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
7262
7323
  },
@@ -7271,7 +7332,7 @@ function createClient(options) {
7271
7332
  const batchedResolveRoomsInfo = new Batch(
7272
7333
  async (batchedRoomIds) => {
7273
7334
  const roomIds = batchedRoomIds.flat();
7274
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _161 => _161({ roomIds })]);
7335
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _164 => _164({ roomIds })]);
7275
7336
  warnIfNoResolveRoomsInfo();
7276
7337
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
7277
7338
  },
@@ -7387,7 +7448,7 @@ var commentBodyElementsTypes = {
7387
7448
  mention: "inline"
7388
7449
  };
7389
7450
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7390
- if (!body || !_optionalChain([body, 'optionalAccess', _162 => _162.content])) {
7451
+ if (!body || !_optionalChain([body, 'optionalAccess', _165 => _165.content])) {
7391
7452
  return;
7392
7453
  }
7393
7454
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -7397,13 +7458,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
7397
7458
  for (const block of body.content) {
7398
7459
  if (type === "all" || type === "block") {
7399
7460
  if (guard(block)) {
7400
- _optionalChain([visitor, 'optionalCall', _163 => _163(block)]);
7461
+ _optionalChain([visitor, 'optionalCall', _166 => _166(block)]);
7401
7462
  }
7402
7463
  }
7403
7464
  if (type === "all" || type === "inline") {
7404
7465
  for (const inline of block.children) {
7405
7466
  if (guard(inline)) {
7406
- _optionalChain([visitor, 'optionalCall', _164 => _164(inline)]);
7467
+ _optionalChain([visitor, 'optionalCall', _167 => _167(inline)]);
7407
7468
  }
7408
7469
  }
7409
7470
  }
@@ -7428,7 +7489,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
7428
7489
  userIds
7429
7490
  });
7430
7491
  for (const [index, userId] of userIds.entries()) {
7431
- const user = _optionalChain([users, 'optionalAccess', _165 => _165[index]]);
7492
+ const user = _optionalChain([users, 'optionalAccess', _168 => _168[index]]);
7432
7493
  if (user) {
7433
7494
  resolvedUsers.set(userId, user);
7434
7495
  }
@@ -7551,7 +7612,7 @@ var stringifyCommentBodyPlainElements = {
7551
7612
  text: ({ element }) => element.text,
7552
7613
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
7553
7614
  mention: ({ element, user }) => {
7554
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _166 => _166.name]), () => ( element.id))}`;
7615
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _169 => _169.name]), () => ( element.id))}`;
7555
7616
  }
7556
7617
  };
7557
7618
  var stringifyCommentBodyHtmlElements = {
@@ -7581,7 +7642,7 @@ var stringifyCommentBodyHtmlElements = {
7581
7642
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
7582
7643
  },
7583
7644
  mention: ({ element, user }) => {
7584
- return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _167 => _167.name]), () => ( element.id))}</span>`;
7645
+ return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _170 => _170.name]), () => ( element.id))}</span>`;
7585
7646
  }
7586
7647
  };
7587
7648
  var stringifyCommentBodyMarkdownElements = {
@@ -7611,19 +7672,19 @@ var stringifyCommentBodyMarkdownElements = {
7611
7672
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
7612
7673
  },
7613
7674
  mention: ({ element, user }) => {
7614
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}`;
7675
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _171 => _171.name]), () => ( element.id))}`;
7615
7676
  }
7616
7677
  };
7617
7678
  async function stringifyCommentBody(body, options) {
7618
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _169 => _169.format]), () => ( "plain"));
7619
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
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")));
7620
7681
  const elements = {
7621
7682
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
7622
- ..._optionalChain([options, 'optionalAccess', _171 => _171.elements])
7683
+ ..._optionalChain([options, 'optionalAccess', _174 => _174.elements])
7623
7684
  };
7624
7685
  const resolvedUsers = await resolveUsersInCommentBody(
7625
7686
  body,
7626
- _optionalChain([options, 'optionalAccess', _172 => _172.resolveUsers])
7687
+ _optionalChain([options, 'optionalAccess', _175 => _175.resolveUsers])
7627
7688
  );
7628
7689
  const blocks = body.content.flatMap((block, blockIndex) => {
7629
7690
  switch (block.type) {
@@ -7898,12 +7959,12 @@ function legacy_patchImmutableNode(state, path, update) {
7898
7959
  }
7899
7960
  const newState = Object.assign({}, state);
7900
7961
  for (const key in update.updates) {
7901
- if (_optionalChain([update, 'access', _173 => _173.updates, 'access', _174 => _174[key], 'optionalAccess', _175 => _175.type]) === "update") {
7962
+ if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "update") {
7902
7963
  const val = update.node.get(key);
7903
7964
  if (val !== void 0) {
7904
7965
  newState[key] = lsonToJson(val);
7905
7966
  }
7906
- } else if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "delete") {
7967
+ } else if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "delete") {
7907
7968
  delete newState[key];
7908
7969
  }
7909
7970
  }
@@ -7964,12 +8025,12 @@ function legacy_patchImmutableNode(state, path, update) {
7964
8025
  }
7965
8026
  const newState = Object.assign({}, state);
7966
8027
  for (const key in update.updates) {
7967
- if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "update") {
8028
+ if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
7968
8029
  const value = update.node.get(key);
7969
8030
  if (value !== void 0) {
7970
8031
  newState[key] = lsonToJson(value);
7971
8032
  }
7972
- } else if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "delete") {
8033
+ } else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
7973
8034
  delete newState[key];
7974
8035
  }
7975
8036
  }
@@ -8227,5 +8288,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
8227
8288
 
8228
8289
 
8229
8290
 
8230
- 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.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; 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.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createStore = createStore; exports.createThreadId = createThreadId; 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.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.wait = wait; exports.withTimeout = withTimeout;
8291
+
8292
+ 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.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; 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.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createStore = createStore; exports.createThreadId = createThreadId; 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.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.wait = wait; exports.withTimeout = withTimeout;
8231
8293
  //# sourceMappingURL=index.js.map