@liveblocks/core 1.4.5 → 1.4.6
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 +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +25 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -712,31 +712,34 @@ declare type CommentData = {
|
|
|
712
712
|
/**
|
|
713
713
|
* Represents a thread of comments.
|
|
714
714
|
*/
|
|
715
|
-
declare type ThreadData<
|
|
715
|
+
declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
716
716
|
type: "thread";
|
|
717
717
|
id: string;
|
|
718
718
|
roomId: string;
|
|
719
719
|
createdAt: string;
|
|
720
720
|
updatedAt?: string;
|
|
721
721
|
comments: CommentData[];
|
|
722
|
-
metadata: [
|
|
722
|
+
metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
723
723
|
};
|
|
724
724
|
|
|
725
725
|
declare type Options = {
|
|
726
726
|
serverEndpoint: string;
|
|
727
727
|
};
|
|
728
|
-
declare type
|
|
729
|
-
|
|
728
|
+
declare type PartialNullable<T> = {
|
|
729
|
+
[P in keyof T]?: T[P] | null | undefined;
|
|
730
|
+
};
|
|
731
|
+
declare type CommentsApi<TThreadMetadata extends BaseMetadata> = {
|
|
732
|
+
getThreads(): Promise<ThreadData<TThreadMetadata>[]>;
|
|
730
733
|
createThread(options: {
|
|
731
734
|
threadId: string;
|
|
732
735
|
commentId: string;
|
|
733
|
-
metadata:
|
|
736
|
+
metadata: TThreadMetadata | undefined;
|
|
734
737
|
body: CommentBody;
|
|
735
|
-
}): Promise<ThreadData<
|
|
738
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
736
739
|
editThreadMetadata(options: {
|
|
737
|
-
metadata:
|
|
740
|
+
metadata: PartialNullable<TThreadMetadata>;
|
|
738
741
|
threadId: string;
|
|
739
|
-
}): Promise<ThreadData<
|
|
742
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
740
743
|
createComment(options: {
|
|
741
744
|
threadId: string;
|
|
742
745
|
commentId: string;
|
|
@@ -762,7 +765,7 @@ declare type CommentsApi<ThreadMetadata extends BaseMetadata> = {
|
|
|
762
765
|
emoji: string;
|
|
763
766
|
}): Promise<CommentData>;
|
|
764
767
|
};
|
|
765
|
-
declare function createCommentsApi<
|
|
768
|
+
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, { serverEndpoint }: Options): CommentsApi<TThreadMetadata>;
|
|
766
769
|
|
|
767
770
|
declare type Callback<T> = (event: T) => void;
|
|
768
771
|
declare type UnsubscribeCallback = () => void;
|
|
@@ -1927,7 +1930,8 @@ declare function assert(condition: boolean, errmsg: string): asserts condition;
|
|
|
1927
1930
|
*/
|
|
1928
1931
|
declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
|
|
1929
1932
|
|
|
1930
|
-
declare type
|
|
1933
|
+
declare type PromiseOrNot<T> = T | Promise<T>;
|
|
1934
|
+
declare type AsyncCacheFunction<T, A extends any[] = any[]> = (...args: A) => PromiseOrNot<T>;
|
|
1931
1935
|
declare type AsyncCacheOptions<T, E> = {
|
|
1932
1936
|
isStateEqual?: (a: AsyncState<T, E>, b: AsyncState<T, E>) => boolean;
|
|
1933
1937
|
};
|
|
@@ -1954,7 +1958,6 @@ declare type AsyncStateError<T, E> = {
|
|
|
1954
1958
|
declare type AsyncState<T, E> = AsyncStateInitial | AsyncStateLoading<T> | AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1955
1959
|
declare type AsyncStateResolved<T, E> = AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1956
1960
|
declare type AsyncCacheItem<T, E> = Observable<AsyncState<T, E>> & {
|
|
1957
|
-
setAsyncFunction(asyncFunction: AsyncFunction<T, [string]>): void;
|
|
1958
1961
|
get(): Promise<AsyncStateResolved<T, E>>;
|
|
1959
1962
|
getState(): AsyncState<T, E>;
|
|
1960
1963
|
revalidate(): Promise<AsyncStateResolved<T, E>>;
|
|
@@ -1968,7 +1971,7 @@ declare type AsyncCache<T, E> = {
|
|
|
1968
1971
|
* @param key The key to create.
|
|
1969
1972
|
* @param asyncFunction Override the cache's function for this key.
|
|
1970
1973
|
*/
|
|
1971
|
-
create(key: string, asyncFunction?:
|
|
1974
|
+
create(key: string, asyncFunction?: AsyncCacheFunction<T, [string]>): AsyncCacheItem<T, E>;
|
|
1972
1975
|
/**
|
|
1973
1976
|
* Returns a promise which resolves with the state of the key.
|
|
1974
1977
|
*
|
|
@@ -2012,7 +2015,7 @@ declare type AsyncCache<T, E> = {
|
|
|
2012
2015
|
*/
|
|
2013
2016
|
clear(): void;
|
|
2014
2017
|
};
|
|
2015
|
-
declare function createAsyncCache<T, E>(asyncFunction:
|
|
2018
|
+
declare function createAsyncCache<T, E>(asyncFunction: AsyncCacheFunction<T, [string]>, options?: AsyncCacheOptions<T, E>): AsyncCache<T, E>;
|
|
2016
2019
|
|
|
2017
2020
|
/**
|
|
2018
2021
|
* Displays a deprecation warning in the dev console. Only in dev mode, and
|
|
@@ -2172,6 +2175,9 @@ declare function asPos(str: string): Pos;
|
|
|
2172
2175
|
*/
|
|
2173
2176
|
declare function shallow(a: unknown, b: unknown): boolean;
|
|
2174
2177
|
|
|
2178
|
+
declare type OmitFirstTupleElement<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
|
2179
|
+
declare function stringify(object: Parameters<typeof JSON.stringify>[0], ...args: OmitFirstTupleElement<Parameters<typeof JSON.stringify>>): string;
|
|
2180
|
+
|
|
2175
2181
|
declare type JsonTreeNode = {
|
|
2176
2182
|
readonly type: "Json";
|
|
2177
2183
|
readonly id: string;
|
|
@@ -2360,4 +2366,4 @@ declare type EnsureJson<T> = [
|
|
|
2360
2366
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2361
2367
|
};
|
|
2362
2368
|
|
|
2363
|
-
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2369
|
+
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -712,31 +712,34 @@ declare type CommentData = {
|
|
|
712
712
|
/**
|
|
713
713
|
* Represents a thread of comments.
|
|
714
714
|
*/
|
|
715
|
-
declare type ThreadData<
|
|
715
|
+
declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
716
716
|
type: "thread";
|
|
717
717
|
id: string;
|
|
718
718
|
roomId: string;
|
|
719
719
|
createdAt: string;
|
|
720
720
|
updatedAt?: string;
|
|
721
721
|
comments: CommentData[];
|
|
722
|
-
metadata: [
|
|
722
|
+
metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
723
723
|
};
|
|
724
724
|
|
|
725
725
|
declare type Options = {
|
|
726
726
|
serverEndpoint: string;
|
|
727
727
|
};
|
|
728
|
-
declare type
|
|
729
|
-
|
|
728
|
+
declare type PartialNullable<T> = {
|
|
729
|
+
[P in keyof T]?: T[P] | null | undefined;
|
|
730
|
+
};
|
|
731
|
+
declare type CommentsApi<TThreadMetadata extends BaseMetadata> = {
|
|
732
|
+
getThreads(): Promise<ThreadData<TThreadMetadata>[]>;
|
|
730
733
|
createThread(options: {
|
|
731
734
|
threadId: string;
|
|
732
735
|
commentId: string;
|
|
733
|
-
metadata:
|
|
736
|
+
metadata: TThreadMetadata | undefined;
|
|
734
737
|
body: CommentBody;
|
|
735
|
-
}): Promise<ThreadData<
|
|
738
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
736
739
|
editThreadMetadata(options: {
|
|
737
|
-
metadata:
|
|
740
|
+
metadata: PartialNullable<TThreadMetadata>;
|
|
738
741
|
threadId: string;
|
|
739
|
-
}): Promise<ThreadData<
|
|
742
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
740
743
|
createComment(options: {
|
|
741
744
|
threadId: string;
|
|
742
745
|
commentId: string;
|
|
@@ -762,7 +765,7 @@ declare type CommentsApi<ThreadMetadata extends BaseMetadata> = {
|
|
|
762
765
|
emoji: string;
|
|
763
766
|
}): Promise<CommentData>;
|
|
764
767
|
};
|
|
765
|
-
declare function createCommentsApi<
|
|
768
|
+
declare function createCommentsApi<TThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, { serverEndpoint }: Options): CommentsApi<TThreadMetadata>;
|
|
766
769
|
|
|
767
770
|
declare type Callback<T> = (event: T) => void;
|
|
768
771
|
declare type UnsubscribeCallback = () => void;
|
|
@@ -1927,7 +1930,8 @@ declare function assert(condition: boolean, errmsg: string): asserts condition;
|
|
|
1927
1930
|
*/
|
|
1928
1931
|
declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
|
|
1929
1932
|
|
|
1930
|
-
declare type
|
|
1933
|
+
declare type PromiseOrNot<T> = T | Promise<T>;
|
|
1934
|
+
declare type AsyncCacheFunction<T, A extends any[] = any[]> = (...args: A) => PromiseOrNot<T>;
|
|
1931
1935
|
declare type AsyncCacheOptions<T, E> = {
|
|
1932
1936
|
isStateEqual?: (a: AsyncState<T, E>, b: AsyncState<T, E>) => boolean;
|
|
1933
1937
|
};
|
|
@@ -1954,7 +1958,6 @@ declare type AsyncStateError<T, E> = {
|
|
|
1954
1958
|
declare type AsyncState<T, E> = AsyncStateInitial | AsyncStateLoading<T> | AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1955
1959
|
declare type AsyncStateResolved<T, E> = AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1956
1960
|
declare type AsyncCacheItem<T, E> = Observable<AsyncState<T, E>> & {
|
|
1957
|
-
setAsyncFunction(asyncFunction: AsyncFunction<T, [string]>): void;
|
|
1958
1961
|
get(): Promise<AsyncStateResolved<T, E>>;
|
|
1959
1962
|
getState(): AsyncState<T, E>;
|
|
1960
1963
|
revalidate(): Promise<AsyncStateResolved<T, E>>;
|
|
@@ -1968,7 +1971,7 @@ declare type AsyncCache<T, E> = {
|
|
|
1968
1971
|
* @param key The key to create.
|
|
1969
1972
|
* @param asyncFunction Override the cache's function for this key.
|
|
1970
1973
|
*/
|
|
1971
|
-
create(key: string, asyncFunction?:
|
|
1974
|
+
create(key: string, asyncFunction?: AsyncCacheFunction<T, [string]>): AsyncCacheItem<T, E>;
|
|
1972
1975
|
/**
|
|
1973
1976
|
* Returns a promise which resolves with the state of the key.
|
|
1974
1977
|
*
|
|
@@ -2012,7 +2015,7 @@ declare type AsyncCache<T, E> = {
|
|
|
2012
2015
|
*/
|
|
2013
2016
|
clear(): void;
|
|
2014
2017
|
};
|
|
2015
|
-
declare function createAsyncCache<T, E>(asyncFunction:
|
|
2018
|
+
declare function createAsyncCache<T, E>(asyncFunction: AsyncCacheFunction<T, [string]>, options?: AsyncCacheOptions<T, E>): AsyncCache<T, E>;
|
|
2016
2019
|
|
|
2017
2020
|
/**
|
|
2018
2021
|
* Displays a deprecation warning in the dev console. Only in dev mode, and
|
|
@@ -2172,6 +2175,9 @@ declare function asPos(str: string): Pos;
|
|
|
2172
2175
|
*/
|
|
2173
2176
|
declare function shallow(a: unknown, b: unknown): boolean;
|
|
2174
2177
|
|
|
2178
|
+
declare type OmitFirstTupleElement<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
|
2179
|
+
declare function stringify(object: Parameters<typeof JSON.stringify>[0], ...args: OmitFirstTupleElement<Parameters<typeof JSON.stringify>>): string;
|
|
2180
|
+
|
|
2175
2181
|
declare type JsonTreeNode = {
|
|
2176
2182
|
readonly type: "Json";
|
|
2177
2183
|
readonly id: string;
|
|
@@ -2360,4 +2366,4 @@ declare type EnsureJson<T> = [
|
|
|
2360
2366
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
2361
2367
|
};
|
|
2362
2368
|
|
|
2363
|
-
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|
|
2369
|
+
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyLink, CommentBodyMention, CommentBodyParagraph, CommentBodyText, CommentData, CommentReaction, CommentsApi, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, EventSource, FetchStorageClientMsg, FetchYDocClientMsg, History, IWebSocket, IWebSocketCloseEvent, IWebSocketEvent, IWebSocketInstance, IWebSocketMessageEvent, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LegacyConnectionStatus, LiveList, LiveListUpdate, LiveMap, LiveMapUpdate, LiveNode, LiveObject, LiveObjectUpdate, LiveStructure, LostConnectionEvent, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, PlainLson, PlainLsonFields, PlainLsonList, PlainLsonMap, PlainLsonObject, RejectedStorageOpServerMsg, Resolve, Room, RoomEventMessage, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ThreadData, ToImmutable, ToJson, UnsubscribeCallback, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, YDocUpdateServerMsg, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, stringify, throwUsageError, toPlainLson, tryParseJson, 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 = "1.4.
|
|
9
|
+
var PKG_VERSION = "1.4.6";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -5727,10 +5727,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5727
5727
|
getSelf_forDevTools: () => selfAsTreeNode.current,
|
|
5728
5728
|
getOthers_forDevTools: () => others_forDevTools.current,
|
|
5729
5729
|
// prettier-ignore
|
|
5730
|
-
|
|
5730
|
+
simulate: {
|
|
5731
5731
|
// These exist only for our E2E testing app
|
|
5732
5732
|
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
5733
|
-
|
|
5733
|
+
rawSend: (data) => managedSocket.send(data)
|
|
5734
5734
|
}
|
|
5735
5735
|
},
|
|
5736
5736
|
id: config.roomId,
|
|
@@ -6382,8 +6382,8 @@ function isShallowEqual(a, b) {
|
|
|
6382
6382
|
return shallow(a.data, b.data) && shallow(a.error, b.error);
|
|
6383
6383
|
}
|
|
6384
6384
|
}
|
|
6385
|
-
function createCacheItem(key,
|
|
6386
|
-
|
|
6385
|
+
function createCacheItem(key, asyncFunction, options) {
|
|
6386
|
+
const $asyncFunction = async () => asyncFunction(key);
|
|
6387
6387
|
const context = {
|
|
6388
6388
|
isInvalid: true
|
|
6389
6389
|
};
|
|
@@ -6426,7 +6426,7 @@ function createCacheItem(key, defaultAsyncFunction, options) {
|
|
|
6426
6426
|
if (context.isInvalid) {
|
|
6427
6427
|
if (!context.promise) {
|
|
6428
6428
|
context.isInvalid = true;
|
|
6429
|
-
context.promise = asyncFunction(
|
|
6429
|
+
context.promise = $asyncFunction();
|
|
6430
6430
|
state = { isLoading: true, data: state.data };
|
|
6431
6431
|
notify();
|
|
6432
6432
|
}
|
|
@@ -6437,12 +6437,8 @@ function createCacheItem(key, defaultAsyncFunction, options) {
|
|
|
6437
6437
|
function getState() {
|
|
6438
6438
|
return state;
|
|
6439
6439
|
}
|
|
6440
|
-
function setAsyncFunction(overrideAsyncFunction) {
|
|
6441
|
-
asyncFunction = overrideAsyncFunction;
|
|
6442
|
-
}
|
|
6443
6440
|
return {
|
|
6444
6441
|
...eventSource2.observable,
|
|
6445
|
-
setAsyncFunction,
|
|
6446
6442
|
get,
|
|
6447
6443
|
getState,
|
|
6448
6444
|
revalidate
|
|
@@ -6450,19 +6446,12 @@ function createCacheItem(key, defaultAsyncFunction, options) {
|
|
|
6450
6446
|
}
|
|
6451
6447
|
function createAsyncCache(asyncFunction, options) {
|
|
6452
6448
|
const cache = /* @__PURE__ */ new Map();
|
|
6453
|
-
function create(key
|
|
6449
|
+
function create(key) {
|
|
6454
6450
|
let cacheItem = cache.get(key);
|
|
6455
6451
|
if (cacheItem) {
|
|
6456
|
-
if (overrideAsyncFunction) {
|
|
6457
|
-
cacheItem.setAsyncFunction(overrideAsyncFunction);
|
|
6458
|
-
}
|
|
6459
6452
|
return cacheItem;
|
|
6460
6453
|
}
|
|
6461
|
-
cacheItem = createCacheItem(
|
|
6462
|
-
key,
|
|
6463
|
-
_nullishCoalesce(overrideAsyncFunction, () => ( asyncFunction)),
|
|
6464
|
-
options
|
|
6465
|
-
);
|
|
6454
|
+
cacheItem = createCacheItem(key, asyncFunction, options);
|
|
6466
6455
|
cache.set(key, cacheItem);
|
|
6467
6456
|
return cacheItem;
|
|
6468
6457
|
}
|
|
@@ -6588,6 +6577,21 @@ function makePoller(callback) {
|
|
|
6588
6577
|
};
|
|
6589
6578
|
}
|
|
6590
6579
|
|
|
6580
|
+
// src/lib/stringify.ts
|
|
6581
|
+
function stringify(object, ...args) {
|
|
6582
|
+
if (typeof object !== "object" || object === null || Array.isArray(object)) {
|
|
6583
|
+
return JSON.stringify(object, ...args);
|
|
6584
|
+
}
|
|
6585
|
+
const sortedObject = Object.keys(object).sort().reduce(
|
|
6586
|
+
(sortedObject2, key) => {
|
|
6587
|
+
sortedObject2[key] = object[key];
|
|
6588
|
+
return sortedObject2;
|
|
6589
|
+
},
|
|
6590
|
+
{}
|
|
6591
|
+
);
|
|
6592
|
+
return JSON.stringify(sortedObject, ...args);
|
|
6593
|
+
}
|
|
6594
|
+
|
|
6591
6595
|
// src/index.ts
|
|
6592
6596
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
6593
6597
|
|
|
@@ -6631,5 +6635,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
6631
6635
|
|
|
6632
6636
|
|
|
6633
6637
|
|
|
6634
|
-
|
|
6638
|
+
|
|
6639
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.console = fancy_console_exports; exports.createAsyncCache = createAsyncCache; exports.createClient = createClient; exports.createCommentsApi = createCommentsApi; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.shallow = shallow; exports.stringify = stringify; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
|
|
6635
6640
|
//# sourceMappingURL=index.js.map
|