@liveblocks/core 3.23.0-file1 → 3.23.0-file3

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.cts CHANGED
@@ -1184,6 +1184,7 @@ type BatchStore<O, I> = {
1184
1184
  setData: (entries: [I, O][]) => void;
1185
1185
  getItemState: (input: I) => AsyncResult<O> | undefined;
1186
1186
  getData: (input: I) => O | undefined;
1187
+ waitUntilItemCacheExpires: (input: I) => Promise<void> | undefined;
1187
1188
  invalidate: (inputs?: I[]) => void;
1188
1189
  };
1189
1190
 
@@ -1731,6 +1732,10 @@ type MakeOptionalFieldsNullable<T> = {
1731
1732
  */
1732
1733
  type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1733
1734
 
1735
+ type FileUrlData = {
1736
+ readonly url: string;
1737
+ readonly expiresAt: number;
1738
+ };
1734
1739
  interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1735
1740
  getThreads(options: {
1736
1741
  roomId: string;
@@ -1906,7 +1911,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1906
1911
  file: File;
1907
1912
  signal?: AbortSignal;
1908
1913
  }): Promise<LiveFile>;
1909
- getOrCreateFileUrlsStore(roomId: string): BatchStore<string, string>;
1914
+ getOrCreateFileUrlsStore(roomId: string): BatchStore<FileUrlData, string>;
1910
1915
  createTextMention({ roomId, mentionId, mention, }: {
1911
1916
  roomId: string;
1912
1917
  mentionId: string;
@@ -3314,7 +3319,13 @@ type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
3314
3319
  readonly key: string;
3315
3320
  readonly payload: LsonTreeNode[];
3316
3321
  };
3317
- type LsonTreeNode = LiveTreeNode | JsonTreeNode;
3322
+ type LiveFileTreeNode = {
3323
+ readonly type: "LiveFile";
3324
+ readonly id: string;
3325
+ readonly key: string;
3326
+ readonly payload: LiveFileData;
3327
+ };
3328
+ type LsonTreeNode = LiveTreeNode | LiveFileTreeNode | JsonTreeNode;
3318
3329
  type UserTreeNode = {
3319
3330
  readonly type: "User";
3320
3331
  readonly id: string;
@@ -3338,12 +3349,13 @@ type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
3338
3349
 
3339
3350
  type DevToolsTreeNode_CustomEventTreeNode = CustomEventTreeNode;
3340
3351
  type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
3352
+ type DevToolsTreeNode_LiveFileTreeNode = LiveFileTreeNode;
3341
3353
  type DevToolsTreeNode_LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = LiveTreeNode<TName>;
3342
3354
  type DevToolsTreeNode_LsonTreeNode = LsonTreeNode;
3343
3355
  type DevToolsTreeNode_TreeNode = TreeNode;
3344
3356
  type DevToolsTreeNode_UserTreeNode = UserTreeNode;
3345
3357
  declare namespace DevToolsTreeNode {
3346
- export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
3358
+ export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveFileTreeNode as LiveFileTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
3347
3359
  }
3348
3360
 
3349
3361
  type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
@@ -4258,7 +4270,7 @@ type PrivateRoomApi = {
4258
4270
  incomingMessage(data: string): void;
4259
4271
  };
4260
4272
  attachmentUrlsStore: BatchStore<string, string>;
4261
- fileUrlsStore: BatchStore<string, string>;
4273
+ fileUrlsStore: BatchStore<FileUrlData, string>;
4262
4274
  };
4263
4275
  type Stackframe<P extends JsonObject> = Op | PresenceStackframe<P>;
4264
4276
  type PresenceStackframe<P extends JsonObject> = {
@@ -5878,4 +5890,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
5878
5890
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
5879
5891
  };
5880
5892
 
5881
- export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
5893
+ export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type FileUrlData, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
package/dist/index.d.ts CHANGED
@@ -1184,6 +1184,7 @@ type BatchStore<O, I> = {
1184
1184
  setData: (entries: [I, O][]) => void;
1185
1185
  getItemState: (input: I) => AsyncResult<O> | undefined;
1186
1186
  getData: (input: I) => O | undefined;
1187
+ waitUntilItemCacheExpires: (input: I) => Promise<void> | undefined;
1187
1188
  invalidate: (inputs?: I[]) => void;
1188
1189
  };
1189
1190
 
@@ -1731,6 +1732,10 @@ type MakeOptionalFieldsNullable<T> = {
1731
1732
  */
1732
1733
  type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
1733
1734
 
1735
+ type FileUrlData = {
1736
+ readonly url: string;
1737
+ readonly expiresAt: number;
1738
+ };
1734
1739
  interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1735
1740
  getThreads(options: {
1736
1741
  roomId: string;
@@ -1906,7 +1911,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
1906
1911
  file: File;
1907
1912
  signal?: AbortSignal;
1908
1913
  }): Promise<LiveFile>;
1909
- getOrCreateFileUrlsStore(roomId: string): BatchStore<string, string>;
1914
+ getOrCreateFileUrlsStore(roomId: string): BatchStore<FileUrlData, string>;
1910
1915
  createTextMention({ roomId, mentionId, mention, }: {
1911
1916
  roomId: string;
1912
1917
  mentionId: string;
@@ -3314,7 +3319,13 @@ type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
3314
3319
  readonly key: string;
3315
3320
  readonly payload: LsonTreeNode[];
3316
3321
  };
3317
- type LsonTreeNode = LiveTreeNode | JsonTreeNode;
3322
+ type LiveFileTreeNode = {
3323
+ readonly type: "LiveFile";
3324
+ readonly id: string;
3325
+ readonly key: string;
3326
+ readonly payload: LiveFileData;
3327
+ };
3328
+ type LsonTreeNode = LiveTreeNode | LiveFileTreeNode | JsonTreeNode;
3318
3329
  type UserTreeNode = {
3319
3330
  readonly type: "User";
3320
3331
  readonly id: string;
@@ -3338,12 +3349,13 @@ type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
3338
3349
 
3339
3350
  type DevToolsTreeNode_CustomEventTreeNode = CustomEventTreeNode;
3340
3351
  type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
3352
+ type DevToolsTreeNode_LiveFileTreeNode = LiveFileTreeNode;
3341
3353
  type DevToolsTreeNode_LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = LiveTreeNode<TName>;
3342
3354
  type DevToolsTreeNode_LsonTreeNode = LsonTreeNode;
3343
3355
  type DevToolsTreeNode_TreeNode = TreeNode;
3344
3356
  type DevToolsTreeNode_UserTreeNode = UserTreeNode;
3345
3357
  declare namespace DevToolsTreeNode {
3346
- export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
3358
+ export type { DevToolsTreeNode_CustomEventTreeNode as CustomEventTreeNode, DevToolsTreeNode_JsonTreeNode as JsonTreeNode, DevToolsTreeNode_LiveFileTreeNode as LiveFileTreeNode, DevToolsTreeNode_LiveTreeNode as LiveTreeNode, DevToolsTreeNode_LsonTreeNode as LsonTreeNode, DevToolsTreeNode_TreeNode as TreeNode, DevToolsTreeNode_UserTreeNode as UserTreeNode };
3347
3359
  }
3348
3360
 
3349
3361
  type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
@@ -4258,7 +4270,7 @@ type PrivateRoomApi = {
4258
4270
  incomingMessage(data: string): void;
4259
4271
  };
4260
4272
  attachmentUrlsStore: BatchStore<string, string>;
4261
- fileUrlsStore: BatchStore<string, string>;
4273
+ fileUrlsStore: BatchStore<FileUrlData, string>;
4262
4274
  };
4263
4275
  type Stackframe<P extends JsonObject> = Op | PresenceStackframe<P>;
4264
4276
  type PresenceStackframe<P extends JsonObject> = {
@@ -5878,4 +5890,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
5878
5890
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
5879
5891
  };
5880
5892
 
5881
- export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
5893
+ export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, 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, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type FileUrlData, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, 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 = "3.23.0-file1";
9
+ var PKG_VERSION = "3.23.0-file3";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1663,7 +1663,7 @@ var LiveFile = class _LiveFile extends AbstractCrdt {
1663
1663
  /** @internal */
1664
1664
  _toTreeNode(key) {
1665
1665
  return {
1666
- type: "Json",
1666
+ type: "LiveFile",
1667
1667
  id: this._id ?? nanoid(),
1668
1668
  key,
1669
1669
  payload: this.#data
@@ -1919,8 +1919,10 @@ var Batch = class {
1919
1919
  this.#clearDelayTimeout();
1920
1920
  }
1921
1921
  };
1922
- function createBatchStore(batch2) {
1922
+ function createBatchStore(batch2, options) {
1923
1923
  const signal = new MutableSignal(/* @__PURE__ */ new Map());
1924
+ const cacheExpiryTimeouts = /* @__PURE__ */ new Map();
1925
+ const pendingEnqueues = /* @__PURE__ */ new Map();
1924
1926
  function getCacheKey(args) {
1925
1927
  return stableStringify(args);
1926
1928
  }
@@ -1935,7 +1937,42 @@ function createBatchStore(batch2) {
1935
1937
  }
1936
1938
  });
1937
1939
  }
1940
+ function clearCacheExpiry(cacheKey) {
1941
+ const timeoutId = cacheExpiryTimeouts.get(cacheKey);
1942
+ if (timeoutId !== void 0) {
1943
+ clearTimeout(timeoutId);
1944
+ cacheExpiryTimeouts.delete(cacheKey);
1945
+ }
1946
+ }
1947
+ function scheduleCacheExpiry(input, expiresAt) {
1948
+ const cacheKey = getCacheKey(input);
1949
+ clearCacheExpiry(cacheKey);
1950
+ if (expiresAt === void 0 || !Number.isFinite(expiresAt)) {
1951
+ return;
1952
+ }
1953
+ const timeoutId = setTimeout(
1954
+ () => {
1955
+ cacheExpiryTimeouts.delete(cacheKey);
1956
+ invalidate([input]);
1957
+ },
1958
+ Math.max(0, expiresAt - Date.now())
1959
+ );
1960
+ cacheExpiryTimeouts.set(cacheKey, timeoutId);
1961
+ }
1938
1962
  function invalidate(inputs) {
1963
+ if (Array.isArray(inputs)) {
1964
+ for (const input of inputs) {
1965
+ const cacheKey = getCacheKey(input);
1966
+ clearCacheExpiry(cacheKey);
1967
+ pendingEnqueues.delete(cacheKey);
1968
+ }
1969
+ } else {
1970
+ for (const timeoutId of cacheExpiryTimeouts.values()) {
1971
+ clearTimeout(timeoutId);
1972
+ }
1973
+ cacheExpiryTimeouts.clear();
1974
+ pendingEnqueues.clear();
1975
+ }
1939
1976
  signal.mutate((cache) => {
1940
1977
  if (Array.isArray(inputs)) {
1941
1978
  for (const input of inputs) {
@@ -1946,23 +1983,54 @@ function createBatchStore(batch2) {
1946
1983
  }
1947
1984
  });
1948
1985
  }
1949
- async function enqueue(input) {
1950
- const cacheKey = getCacheKey(input);
1951
- const cache = signal.get();
1952
- if (cache.has(cacheKey)) {
1953
- return;
1954
- }
1986
+ async function processEnqueue(input, cacheKey, batchResult$, pendingEnqueueId) {
1955
1987
  try {
1956
- update({ key: cacheKey, state: { isLoading: true } });
1957
- const result = await batch2.get(input);
1988
+ const result = await batchResult$;
1989
+ if (pendingEnqueues.get(cacheKey)?.id !== pendingEnqueueId) {
1990
+ return;
1991
+ }
1958
1992
  update({ key: cacheKey, state: { isLoading: false, data: result } });
1993
+ scheduleCacheExpiry(input, options?.getCacheExpiry?.(result));
1959
1994
  } catch (error3) {
1995
+ if (pendingEnqueues.get(cacheKey)?.id !== pendingEnqueueId) {
1996
+ return;
1997
+ }
1998
+ scheduleCacheExpiry(input, options?.getErrorCacheExpiry?.(error3));
1960
1999
  update({
1961
2000
  key: cacheKey,
1962
2001
  state: { isLoading: false, error: error3 }
1963
2002
  });
2003
+ } finally {
2004
+ if (pendingEnqueues.get(cacheKey)?.id === pendingEnqueueId) {
2005
+ pendingEnqueues.delete(cacheKey);
2006
+ }
1964
2007
  }
1965
2008
  }
2009
+ function enqueue(input) {
2010
+ const cacheKey = getCacheKey(input);
2011
+ const existingEnqueue = pendingEnqueues.get(cacheKey);
2012
+ if (existingEnqueue !== void 0) {
2013
+ return existingEnqueue.promise;
2014
+ }
2015
+ const cache = signal.get();
2016
+ if (cache.has(cacheKey)) {
2017
+ return Promise.resolve();
2018
+ }
2019
+ const batchResult$ = batch2.get(input);
2020
+ const pendingEnqueueId = /* @__PURE__ */ Symbol();
2021
+ const pendingEnqueue$ = processEnqueue(
2022
+ input,
2023
+ cacheKey,
2024
+ batchResult$,
2025
+ pendingEnqueueId
2026
+ );
2027
+ pendingEnqueues.set(cacheKey, {
2028
+ id: pendingEnqueueId,
2029
+ promise: pendingEnqueue$
2030
+ });
2031
+ update({ key: cacheKey, state: { isLoading: true } });
2032
+ return pendingEnqueue$;
2033
+ }
1966
2034
  function setData(entries2) {
1967
2035
  update(
1968
2036
  entries2.map((entry) => ({
@@ -1970,6 +2038,9 @@ function createBatchStore(batch2) {
1970
2038
  state: { isLoading: false, data: entry[1] }
1971
2039
  }))
1972
2040
  );
2041
+ for (const [input, output] of entries2) {
2042
+ scheduleCacheExpiry(input, options?.getCacheExpiry?.(output));
2043
+ }
1973
2044
  }
1974
2045
  function getItemState(input) {
1975
2046
  const cacheKey = getCacheKey(input);
@@ -1981,6 +2052,21 @@ function createBatchStore(batch2) {
1981
2052
  const cache = signal.get();
1982
2053
  return cache.get(cacheKey)?.data;
1983
2054
  }
2055
+ function waitUntilItemCacheExpires(input) {
2056
+ const cacheKey = getCacheKey(input);
2057
+ if (!cacheExpiryTimeouts.has(cacheKey)) {
2058
+ return void 0;
2059
+ }
2060
+ const initialState = signal.get().get(cacheKey);
2061
+ return new Promise((resolve) => {
2062
+ const unsubscribe = signal.subscribe(() => {
2063
+ if (signal.get().get(cacheKey) !== initialState) {
2064
+ unsubscribe();
2065
+ resolve();
2066
+ }
2067
+ });
2068
+ });
2069
+ }
1984
2070
  function _cacheKeys() {
1985
2071
  const cache = signal.get();
1986
2072
  return [...cache.keys()];
@@ -1991,6 +2077,7 @@ function createBatchStore(batch2) {
1991
2077
  setData,
1992
2078
  getItemState,
1993
2079
  getData,
2080
+ waitUntilItemCacheExpires,
1994
2081
  invalidate,
1995
2082
  batch: batch2,
1996
2083
  _cacheKeys
@@ -2274,6 +2361,10 @@ function isUrl(string) {
2274
2361
  // src/api-client.ts
2275
2362
  var ROOM_FILE_PART_SIZE = 5 * 1024 * 1024;
2276
2363
  var ROOM_FILE_RETRY_ATTEMPTS = 10;
2364
+ var FILE_URL_EXPIRY_BUFFER = 3e4;
2365
+ var FILE_URL_ERROR_RETRY_DELAY = 1e3;
2366
+ var FILE_URL_ERROR_MAX_ATTEMPTS = 3;
2367
+ var FILE_URL_ERROR_ATTEMPTS_EXPIRY = 3e4;
2277
2368
  var ROOM_FILE_RETRY_DELAYS = [
2278
2369
  2e3,
2279
2370
  2e3,
@@ -2286,10 +2377,13 @@ var ROOM_FILE_RETRY_DELAYS = [
2286
2377
  2e3,
2287
2378
  2e3
2288
2379
  ];
2380
+ var FileUrlRetryableError = class extends Error {
2381
+ };
2289
2382
  async function uploadRoomFile({
2290
2383
  file,
2291
2384
  signal,
2292
2385
  abortErrorMessage,
2386
+ retryMultipartCompletion,
2293
2387
  uploadSingle,
2294
2388
  createMultipartUpload,
2295
2389
  uploadMultipartPart,
@@ -2304,10 +2398,7 @@ async function uploadRoomFile({
2304
2398
  if (signal?.aborted) {
2305
2399
  throw abortError;
2306
2400
  }
2307
- if (err instanceof HttpError && err.status === 413) {
2308
- throw err;
2309
- }
2310
- return false;
2401
+ return err instanceof HttpError && err.status >= 400 && err.status < 500;
2311
2402
  };
2312
2403
  if (file.size <= ROOM_FILE_PART_SIZE) {
2313
2404
  return autoRetry(
@@ -2319,12 +2410,7 @@ async function uploadRoomFile({
2319
2410
  }
2320
2411
  let uploadId;
2321
2412
  const uploadedParts = [];
2322
- const multipartUpload = await autoRetry(
2323
- createMultipartUpload,
2324
- ROOM_FILE_RETRY_ATTEMPTS,
2325
- ROOM_FILE_RETRY_DELAYS,
2326
- handleRetryError
2327
- );
2413
+ const multipartUpload = await createMultipartUpload();
2328
2414
  try {
2329
2415
  uploadId = multipartUpload.uploadId;
2330
2416
  if (signal?.aborted) {
@@ -2348,12 +2434,17 @@ async function uploadRoomFile({
2348
2434
  if (signal?.aborted) {
2349
2435
  throw abortError;
2350
2436
  }
2351
- return completeMultipartUpload(
2352
- uploadId,
2353
- uploadedParts.sort((a, b) => a.partNumber - b.partNumber)
2437
+ const sortedParts = uploadedParts.sort(
2438
+ (a, b) => a.partNumber - b.partNumber
2354
2439
  );
2440
+ return retryMultipartCompletion ? autoRetry(
2441
+ () => completeMultipartUpload(multipartUpload.uploadId, sortedParts),
2442
+ ROOM_FILE_RETRY_ATTEMPTS,
2443
+ ROOM_FILE_RETRY_DELAYS,
2444
+ handleRetryError
2445
+ ) : completeMultipartUpload(uploadId, sortedParts);
2355
2446
  } catch (error3) {
2356
- if (uploadId && isAbortOrTimeoutError(error3)) {
2447
+ if (uploadId) {
2357
2448
  try {
2358
2449
  await abortMultipartUpload(uploadId);
2359
2450
  } catch {
@@ -2375,9 +2466,6 @@ function splitFileIntoParts(file) {
2375
2466
  }
2376
2467
  return parts;
2377
2468
  }
2378
- function isAbortOrTimeoutError(error3) {
2379
- return error3 instanceof Error && (error3.name === "AbortError" || error3.name === "TimeoutError");
2380
- }
2381
2469
  function createAbortError(message) {
2382
2470
  if (typeof DOMException === "function") {
2383
2471
  return new DOMException(message, "AbortError");
@@ -2706,6 +2794,7 @@ function createApiClient({
2706
2794
  file: attachment.file,
2707
2795
  signal: options.signal,
2708
2796
  abortErrorMessage: `Upload of attachment ${attachment.id} was aborted.`,
2797
+ retryMultipartCompletion: false,
2709
2798
  uploadSingle: async () => httpClient.putBlob(
2710
2799
  url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/upload/${attachment.name}`,
2711
2800
  await authManager.getAuthValue({
@@ -2769,6 +2858,7 @@ function createApiClient({
2769
2858
  file,
2770
2859
  signal: options.signal,
2771
2860
  abortErrorMessage: `Upload of file ${fileId} was aborted.`,
2861
+ retryMultipartCompletion: true,
2772
2862
  uploadSingle: async () => httpClient.putBlob(
2773
2863
  url`/v2/c/rooms/${roomId}/storage/files/${fileId}/upload/${file.name}`,
2774
2864
  await authManager.getAuthValue({
@@ -2854,10 +2944,37 @@ function createApiClient({
2854
2944
  return batch2.get(options.attachmentId);
2855
2945
  }
2856
2946
  const fileUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
2947
+ const errorAttempts = /* @__PURE__ */ new Map();
2948
+ const clearErrorAttempts = (fileId) => {
2949
+ const attempts = errorAttempts.get(fileId);
2950
+ if (attempts !== void 0) {
2951
+ clearTimeout(attempts.cleanupTimeoutId);
2952
+ errorAttempts.delete(fileId);
2953
+ }
2954
+ };
2955
+ const shouldRetryFileUrlError = (fileId) => {
2956
+ const previousAttempts = errorAttempts.get(fileId);
2957
+ if (previousAttempts !== void 0) {
2958
+ clearTimeout(previousAttempts.cleanupTimeoutId);
2959
+ }
2960
+ const count = (previousAttempts?.count ?? 0) + 1;
2961
+ if (count >= FILE_URL_ERROR_MAX_ATTEMPTS) {
2962
+ errorAttempts.delete(fileId);
2963
+ return false;
2964
+ }
2965
+ errorAttempts.set(fileId, {
2966
+ count,
2967
+ cleanupTimeoutId: setTimeout(
2968
+ () => errorAttempts.delete(fileId),
2969
+ FILE_URL_ERROR_ATTEMPTS_EXPIRY
2970
+ )
2971
+ });
2972
+ return true;
2973
+ };
2857
2974
  const batch2 = new Batch(
2858
2975
  async (batchedFileIds) => {
2859
2976
  const fileIds = batchedFileIds.flat();
2860
- const { urls } = await httpClient.post(
2977
+ const { urls, expiresAt } = await httpClient.post(
2861
2978
  url`/v2/c/rooms/${roomId}/storage/files/presigned-urls`,
2862
2979
  await authManager.getAuthValue({
2863
2980
  roomId,
@@ -2866,20 +2983,34 @@ function createApiClient({
2866
2983
  }),
2867
2984
  { fileIds }
2868
2985
  );
2869
- return urls.map(
2870
- (url2) => url2 ?? new Error("There was an error while getting this file's URL")
2871
- );
2986
+ const expiresAtTimestamp = Date.parse(expiresAt);
2987
+ return urls.map((url2, index) => {
2988
+ const fileId = fileIds[index];
2989
+ if (url2 !== null) {
2990
+ clearErrorAttempts(fileId);
2991
+ return { url: url2, expiresAt: expiresAtTimestamp };
2992
+ }
2993
+ if (shouldRetryFileUrlError(fileId)) {
2994
+ return new FileUrlRetryableError(
2995
+ "There was an error while getting this file's URL"
2996
+ );
2997
+ }
2998
+ return new Error("There was an error while getting this file's URL");
2999
+ });
2872
3000
  },
2873
3001
  { delay: 50 }
2874
3002
  );
2875
- return createBatchStore(batch2);
3003
+ return createBatchStore(batch2, {
3004
+ getCacheExpiry: ({ expiresAt }) => expiresAt - FILE_URL_EXPIRY_BUFFER,
3005
+ getErrorCacheExpiry: (error3) => error3 instanceof FileUrlRetryableError ? Date.now() + FILE_URL_ERROR_RETRY_DELAY : void 0
3006
+ });
2876
3007
  });
2877
3008
  function getOrCreateFileUrlsStore(roomId) {
2878
3009
  return fileUrlsBatchStoresByRoom.getOrCreate(roomId);
2879
3010
  }
2880
- function getFileUrl(options) {
3011
+ async function getFileUrl(options) {
2881
3012
  const batch2 = getOrCreateFileUrlsStore(options.roomId).batch;
2882
- return batch2.get(options.fileId);
3013
+ return (await batch2.get(options.fileId)).url;
2883
3014
  }
2884
3015
  async function getSubscriptionSettings(options) {
2885
3016
  return httpClient.get(
@@ -8247,6 +8378,8 @@ function reconcile(live, json, config) {
8247
8378
  return reconcileLiveList(live, json, config);
8248
8379
  } else if (isLiveMap(live) && isPlainObject(json)) {
8249
8380
  return reconcileLiveMap(live, config);
8381
+ } else if (isLiveFile(live) && shallow(live.data, json)) {
8382
+ return live;
8250
8383
  } else {
8251
8384
  return deepLiveify(json, config);
8252
8385
  }
@@ -9173,8 +9306,31 @@ function isJsonEq(a, b) {
9173
9306
  }
9174
9307
  function diffNodeMap(prev, next) {
9175
9308
  const ops = [];
9176
- prev.forEach((_, id) => {
9177
- if (!next.get(id)) {
9309
+ const idsToRecreate = /* @__PURE__ */ new Set();
9310
+ next.forEach((nextCrdt, id) => {
9311
+ const currentCrdt = prev.get(id);
9312
+ if (currentCrdt === void 0) {
9313
+ return;
9314
+ }
9315
+ if (currentCrdt.type !== nextCrdt.type || currentCrdt.type === CrdtType.FILE && nextCrdt.type === CrdtType.FILE && (currentCrdt.data.id !== nextCrdt.data.id || currentCrdt.data.name !== nextCrdt.data.name || currentCrdt.data.size !== nextCrdt.data.size || currentCrdt.data.mimeType !== nextCrdt.data.mimeType)) {
9316
+ idsToRecreate.add(id);
9317
+ }
9318
+ });
9319
+ let foundDescendant = true;
9320
+ while (foundDescendant) {
9321
+ foundDescendant = false;
9322
+ for (const nodes of [prev, next]) {
9323
+ nodes.forEach((crdt, id) => {
9324
+ if (!idsToRecreate.has(id) && crdt.parentId !== void 0 && idsToRecreate.has(crdt.parentId)) {
9325
+ idsToRecreate.add(id);
9326
+ foundDescendant = true;
9327
+ }
9328
+ });
9329
+ }
9330
+ }
9331
+ prev.forEach((crdt, id) => {
9332
+ const parentWillBeRecreated = crdt.parentId !== void 0 && idsToRecreate.has(crdt.parentId);
9333
+ if ((!next.has(id) || idsToRecreate.has(id)) && !parentWillBeRecreated) {
9178
9334
  ops.push({ type: OpCode.DELETE_CRDT, id });
9179
9335
  }
9180
9336
  });
@@ -9185,7 +9341,7 @@ function diffNodeMap(prev, next) {
9185
9341
  }
9186
9342
  emitted.add(id);
9187
9343
  const parentId = crdt.parentId;
9188
- if (parentId !== void 0 && !prev.has(parentId)) {
9344
+ if (parentId !== void 0 && (!prev.has(parentId) || idsToRecreate.has(parentId))) {
9189
9345
  const parentCrdt = next.get(parentId);
9190
9346
  if (parentCrdt !== void 0) {
9191
9347
  emitCreate(parentId, parentCrdt);
@@ -9244,29 +9400,25 @@ function diffNodeMap(prev, next) {
9244
9400
  }
9245
9401
  next.forEach((crdt, id) => {
9246
9402
  const currentCrdt = prev.get(id);
9247
- if (currentCrdt) {
9248
- if (crdt.type === CrdtType.OBJECT) {
9249
- if (currentCrdt.type !== CrdtType.OBJECT) {
9250
- ops.push({ type: OpCode.UPDATE_OBJECT, id, data: crdt.data });
9251
- } else {
9252
- const changed = /* @__PURE__ */ new Map();
9253
- for (const key of Object.keys(crdt.data)) {
9254
- const value = crdt.data[key];
9255
- if (value !== void 0 && !isJsonEq(value, currentCrdt.data[key])) {
9256
- changed.set(key, value);
9257
- }
9258
- }
9259
- if (changed.size > 0) {
9260
- ops.push({
9261
- type: OpCode.UPDATE_OBJECT,
9262
- id,
9263
- data: Object.fromEntries(changed)
9264
- });
9403
+ if (currentCrdt && !idsToRecreate.has(id)) {
9404
+ if (crdt.type === CrdtType.OBJECT && currentCrdt.type === CrdtType.OBJECT) {
9405
+ const changed = /* @__PURE__ */ new Map();
9406
+ for (const key of Object.keys(crdt.data)) {
9407
+ const value = crdt.data[key];
9408
+ if (value !== void 0 && !isJsonEq(value, currentCrdt.data[key])) {
9409
+ changed.set(key, value);
9265
9410
  }
9266
- for (const key of Object.keys(currentCrdt.data)) {
9267
- if (!(key in crdt.data)) {
9268
- ops.push({ type: OpCode.DELETE_OBJECT_KEY, id, key });
9269
- }
9411
+ }
9412
+ if (changed.size > 0) {
9413
+ ops.push({
9414
+ type: OpCode.UPDATE_OBJECT,
9415
+ id,
9416
+ data: Object.fromEntries(changed)
9417
+ });
9418
+ }
9419
+ for (const key of Object.keys(currentCrdt.data)) {
9420
+ if (!(key in crdt.data)) {
9421
+ ops.push({ type: OpCode.DELETE_OBJECT_KEY, id, key });
9270
9422
  }
9271
9423
  }
9272
9424
  }