@liveblocks/core 2.7.0-versions2 → 2.7.1
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 +40 -156
- package/dist/index.d.ts +40 -156
- package/dist/index.js +125 -609
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -549
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2212,11 +2212,19 @@ declare type BatchStore<O, I> = Observable<void> & {
|
|
|
2212
2212
|
getState: (input: I) => AsyncResult<O> | undefined;
|
|
2213
2213
|
};
|
|
2214
2214
|
|
|
2215
|
+
/**
|
|
2216
|
+
* A Store is just a mini Zustand store.
|
|
2217
|
+
*/
|
|
2215
2218
|
declare type Store<T> = {
|
|
2216
|
-
get: () => T
|
|
2217
|
-
set: (callback: (currentState: T) => T) => void;
|
|
2218
|
-
subscribe: (callback: (
|
|
2219
|
+
get: () => Readonly<T>;
|
|
2220
|
+
set: (callback: (currentState: Readonly<T>) => Readonly<T>) => void;
|
|
2221
|
+
subscribe: (callback: () => void) => () => void;
|
|
2222
|
+
batch: (callback: () => void) => void;
|
|
2219
2223
|
};
|
|
2224
|
+
/**
|
|
2225
|
+
* Create a store for an immutable state. Close to Zustand's vanilla store conceptually but with less features.
|
|
2226
|
+
*/
|
|
2227
|
+
declare function createStore<T>(initialState: T): Store<T>;
|
|
2220
2228
|
|
|
2221
2229
|
/**
|
|
2222
2230
|
* Back-port of TypeScript 5.4's built-in NoInfer utility type.
|
|
@@ -2224,155 +2232,6 @@ declare type Store<T> = {
|
|
|
2224
2232
|
*/
|
|
2225
2233
|
declare type NoInfr<A> = [A][A extends any ? 0 : never];
|
|
2226
2234
|
|
|
2227
|
-
declare type HistoryVersion = {
|
|
2228
|
-
type: "historyVersion";
|
|
2229
|
-
kind: "yjs";
|
|
2230
|
-
createdAt: Date;
|
|
2231
|
-
id: string;
|
|
2232
|
-
authors: {
|
|
2233
|
-
id: string;
|
|
2234
|
-
}[];
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
|
-
declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | MarkThreadAsResolvedOptimisticUpdate | MarkThreadAsUnresolvedOptimisticUpdate | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | DeleteInboxNotificationOptimisticUpdate | DeleteAllInboxNotificationsOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
|
|
2238
|
-
declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
|
|
2239
|
-
type: "create-thread";
|
|
2240
|
-
id: string;
|
|
2241
|
-
roomId: string;
|
|
2242
|
-
thread: ThreadData<M>;
|
|
2243
|
-
};
|
|
2244
|
-
declare type DeleteThreadOptimisticUpdate = {
|
|
2245
|
-
type: "delete-thread";
|
|
2246
|
-
id: string;
|
|
2247
|
-
roomId: string;
|
|
2248
|
-
threadId: string;
|
|
2249
|
-
deletedAt: Date;
|
|
2250
|
-
};
|
|
2251
|
-
declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
|
|
2252
|
-
type: "edit-thread-metadata";
|
|
2253
|
-
id: string;
|
|
2254
|
-
threadId: string;
|
|
2255
|
-
metadata: Resolve<Patchable<M>>;
|
|
2256
|
-
updatedAt: Date;
|
|
2257
|
-
};
|
|
2258
|
-
declare type MarkThreadAsResolvedOptimisticUpdate = {
|
|
2259
|
-
type: "mark-thread-as-resolved";
|
|
2260
|
-
id: string;
|
|
2261
|
-
threadId: string;
|
|
2262
|
-
updatedAt: Date;
|
|
2263
|
-
};
|
|
2264
|
-
declare type MarkThreadAsUnresolvedOptimisticUpdate = {
|
|
2265
|
-
type: "mark-thread-as-unresolved";
|
|
2266
|
-
id: string;
|
|
2267
|
-
threadId: string;
|
|
2268
|
-
updatedAt: Date;
|
|
2269
|
-
};
|
|
2270
|
-
declare type CreateCommentOptimisticUpdate = {
|
|
2271
|
-
type: "create-comment";
|
|
2272
|
-
id: string;
|
|
2273
|
-
comment: CommentData;
|
|
2274
|
-
};
|
|
2275
|
-
declare type EditCommentOptimisticUpdate = {
|
|
2276
|
-
type: "edit-comment";
|
|
2277
|
-
id: string;
|
|
2278
|
-
comment: CommentData;
|
|
2279
|
-
};
|
|
2280
|
-
declare type DeleteCommentOptimisticUpdate = {
|
|
2281
|
-
type: "delete-comment";
|
|
2282
|
-
id: string;
|
|
2283
|
-
roomId: string;
|
|
2284
|
-
threadId: string;
|
|
2285
|
-
deletedAt: Date;
|
|
2286
|
-
commentId: string;
|
|
2287
|
-
};
|
|
2288
|
-
declare type AddReactionOptimisticUpdate = {
|
|
2289
|
-
type: "add-reaction";
|
|
2290
|
-
id: string;
|
|
2291
|
-
threadId: string;
|
|
2292
|
-
commentId: string;
|
|
2293
|
-
reaction: CommentUserReaction;
|
|
2294
|
-
};
|
|
2295
|
-
declare type RemoveReactionOptimisticUpdate = {
|
|
2296
|
-
type: "remove-reaction";
|
|
2297
|
-
id: string;
|
|
2298
|
-
threadId: string;
|
|
2299
|
-
commentId: string;
|
|
2300
|
-
emoji: string;
|
|
2301
|
-
userId: string;
|
|
2302
|
-
removedAt: Date;
|
|
2303
|
-
};
|
|
2304
|
-
declare type MarkInboxNotificationAsReadOptimisticUpdate = {
|
|
2305
|
-
type: "mark-inbox-notification-as-read";
|
|
2306
|
-
id: string;
|
|
2307
|
-
inboxNotificationId: string;
|
|
2308
|
-
readAt: Date;
|
|
2309
|
-
};
|
|
2310
|
-
declare type MarkAllInboxNotificationsAsReadOptimisticUpdate = {
|
|
2311
|
-
type: "mark-all-inbox-notifications-as-read";
|
|
2312
|
-
id: string;
|
|
2313
|
-
readAt: Date;
|
|
2314
|
-
};
|
|
2315
|
-
declare type DeleteInboxNotificationOptimisticUpdate = {
|
|
2316
|
-
type: "delete-inbox-notification";
|
|
2317
|
-
id: string;
|
|
2318
|
-
inboxNotificationId: string;
|
|
2319
|
-
deletedAt: Date;
|
|
2320
|
-
};
|
|
2321
|
-
declare type DeleteAllInboxNotificationsOptimisticUpdate = {
|
|
2322
|
-
type: "delete-all-inbox-notifications";
|
|
2323
|
-
id: string;
|
|
2324
|
-
deletedAt: Date;
|
|
2325
|
-
};
|
|
2326
|
-
declare type UpdateNotificationSettingsOptimisticUpdate = {
|
|
2327
|
-
type: "update-notification-settings";
|
|
2328
|
-
id: string;
|
|
2329
|
-
roomId: string;
|
|
2330
|
-
settings: Partial<RoomNotificationSettings>;
|
|
2331
|
-
};
|
|
2332
|
-
declare type QueryState = AsyncResult<undefined>;
|
|
2333
|
-
declare type CacheState<M extends BaseMetadata> = {
|
|
2334
|
-
/**
|
|
2335
|
-
* Threads by ID.
|
|
2336
|
-
*/
|
|
2337
|
-
threads: Record<string, ThreadDataWithDeleteInfo<M>>;
|
|
2338
|
-
/**
|
|
2339
|
-
* Keep track of loading and error status of all the queries made by the client.
|
|
2340
|
-
*/
|
|
2341
|
-
queries: Record<string, QueryState>;
|
|
2342
|
-
/**
|
|
2343
|
-
* Optimistic updates that have not been acknowledged by the server yet.
|
|
2344
|
-
* They are applied on top of the threads in selectors.
|
|
2345
|
-
*/
|
|
2346
|
-
optimisticUpdates: OptimisticUpdate<M>[];
|
|
2347
|
-
/**
|
|
2348
|
-
* Inbox notifications by ID.
|
|
2349
|
-
*/
|
|
2350
|
-
inboxNotifications: Record<string, InboxNotificationData>;
|
|
2351
|
-
/**
|
|
2352
|
-
* Notification settings per room id
|
|
2353
|
-
*/
|
|
2354
|
-
notificationSettings: Record<string, RoomNotificationSettings>;
|
|
2355
|
-
/**
|
|
2356
|
-
* Versions per roomId
|
|
2357
|
-
*/
|
|
2358
|
-
versions: Record<string, HistoryVersion[]>;
|
|
2359
|
-
};
|
|
2360
|
-
interface CacheStore<M extends BaseMetadata> extends Store<CacheState<M>> {
|
|
2361
|
-
deleteThread(threadId: string): void;
|
|
2362
|
-
updateThreadAndNotification(thread: ThreadData<M>, inboxNotification?: InboxNotificationData): void;
|
|
2363
|
-
updateThreadsAndNotifications(threads: ThreadData<M>[], inboxNotifications: InboxNotificationData[], deletedThreads: ThreadDeleteInfo[], deletedInboxNotifications: InboxNotificationDeleteInfo[], queryKey?: string): void;
|
|
2364
|
-
updateRoomInboxNotificationSettings(roomId: string, settings: RoomNotificationSettings, queryKey: string): void;
|
|
2365
|
-
updateRoomVersions(roomId: string, versions: HistoryVersion[], queryKey: string): void;
|
|
2366
|
-
pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<M>): void;
|
|
2367
|
-
setQueryState(queryKey: string, queryState: QueryState): void;
|
|
2368
|
-
optimisticUpdatesEventSource: ReturnType<typeof makeEventSource<OptimisticUpdate<M>>>;
|
|
2369
|
-
}
|
|
2370
|
-
declare function applyOptimisticUpdates<M extends BaseMetadata>(state: CacheState<M>): Pick<CacheState<M>, "threads" | "inboxNotifications" | "notificationSettings">;
|
|
2371
|
-
declare function upsertComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, comment: CommentData): ThreadDataWithDeleteInfo<M>;
|
|
2372
|
-
declare function deleteComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<M>;
|
|
2373
|
-
declare function addReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<M>;
|
|
2374
|
-
declare function removeReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<M>;
|
|
2375
|
-
|
|
2376
2235
|
declare type OptionalPromise<T> = T | Promise<T>;
|
|
2377
2236
|
|
|
2378
2237
|
declare type ResolveMentionSuggestionsArgs = {
|
|
@@ -2437,18 +2296,17 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2437
2296
|
declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
2438
2297
|
readonly currentUserIdStore: Store<string | null>;
|
|
2439
2298
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
2440
|
-
readonly cacheStore: CacheStore<BaseMetadata>;
|
|
2441
2299
|
readonly usersStore: BatchStore<U["info"] | undefined, string>;
|
|
2442
2300
|
readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
|
|
2443
2301
|
readonly getRoomIds: () => string[];
|
|
2444
|
-
readonly getThreads: () => Promise<{
|
|
2302
|
+
readonly getThreads: (options: GetThreadsOptions<M>) => Promise<{
|
|
2445
2303
|
threads: ThreadData<M>[];
|
|
2446
2304
|
inboxNotifications: InboxNotificationData[];
|
|
2447
2305
|
requestedAt: Date;
|
|
2448
2306
|
}>;
|
|
2449
2307
|
readonly getThreadsSince: (options: {
|
|
2450
2308
|
since: Date;
|
|
2451
|
-
}) => Promise<{
|
|
2309
|
+
} & GetThreadsOptions<M>) => Promise<{
|
|
2452
2310
|
inboxNotifications: {
|
|
2453
2311
|
updated: InboxNotificationData[];
|
|
2454
2312
|
deleted: InboxNotificationDeleteInfo[];
|
|
@@ -2911,6 +2769,7 @@ declare const brand: unique symbol;
|
|
|
2911
2769
|
declare type Brand<T, TBrand extends string> = T & {
|
|
2912
2770
|
[brand]: TBrand;
|
|
2913
2771
|
};
|
|
2772
|
+
declare type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
|
|
2914
2773
|
/**
|
|
2915
2774
|
* Throw an error, but as an expression instead of a statement.
|
|
2916
2775
|
*/
|
|
@@ -2918,6 +2777,13 @@ declare function raise(msg: string): never;
|
|
|
2918
2777
|
declare function isPlainObject(blob: unknown): blob is {
|
|
2919
2778
|
[key: string]: unknown;
|
|
2920
2779
|
};
|
|
2780
|
+
/**
|
|
2781
|
+
* Creates a new object by mapping a function over all values. Keys remain the
|
|
2782
|
+
* same. Think Array.prototype.map(), but for values in an object.
|
|
2783
|
+
*/
|
|
2784
|
+
declare function mapValues<V, O extends Record<string, unknown>>(obj: O, mapFn: (value: O[keyof O], key: keyof O) => V): {
|
|
2785
|
+
[K in keyof O]: V;
|
|
2786
|
+
};
|
|
2921
2787
|
/**
|
|
2922
2788
|
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
2923
2789
|
* string cannot be parsed, this will return `undefined`.
|
|
@@ -2927,6 +2793,14 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
|
2927
2793
|
* Decode base64 string.
|
|
2928
2794
|
*/
|
|
2929
2795
|
declare function b64decode(b64value: string): string;
|
|
2796
|
+
declare type RemoveUndefinedValues<T> = {
|
|
2797
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* Returns a new object instance where all explictly-undefined values are
|
|
2801
|
+
* removed.
|
|
2802
|
+
*/
|
|
2803
|
+
declare function compactObject<O extends Record<string, unknown>>(obj: O): RemoveUndefinedValues<O>;
|
|
2930
2804
|
/**
|
|
2931
2805
|
* Returns a promise that resolves after the given number of milliseconds.
|
|
2932
2806
|
*/
|
|
@@ -3024,6 +2898,16 @@ declare function shallow(a: unknown, b: unknown): boolean;
|
|
|
3024
2898
|
declare type OmitFirstTupleElement<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
|
3025
2899
|
declare function stringify(object: Parameters<typeof JSON.stringify>[0], ...args: OmitFirstTupleElement<Parameters<typeof JSON.stringify>>): string;
|
|
3026
2900
|
|
|
2901
|
+
declare type HistoryVersion = {
|
|
2902
|
+
type: "historyVersion";
|
|
2903
|
+
kind: "yjs";
|
|
2904
|
+
createdAt: Date;
|
|
2905
|
+
id: string;
|
|
2906
|
+
authors: {
|
|
2907
|
+
id: string;
|
|
2908
|
+
}[];
|
|
2909
|
+
};
|
|
2910
|
+
|
|
3027
2911
|
/**
|
|
3028
2912
|
* Definition of all messages the Panel can send to the Client.
|
|
3029
2913
|
*/
|
|
@@ -3156,4 +3040,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
|
|
|
3156
3040
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
3157
3041
|
};
|
|
3158
3042
|
|
|
3159
|
-
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
|
|
3043
|
+
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 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 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 User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, 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
|
@@ -2212,11 +2212,19 @@ declare type BatchStore<O, I> = Observable<void> & {
|
|
|
2212
2212
|
getState: (input: I) => AsyncResult<O> | undefined;
|
|
2213
2213
|
};
|
|
2214
2214
|
|
|
2215
|
+
/**
|
|
2216
|
+
* A Store is just a mini Zustand store.
|
|
2217
|
+
*/
|
|
2215
2218
|
declare type Store<T> = {
|
|
2216
|
-
get: () => T
|
|
2217
|
-
set: (callback: (currentState: T) => T) => void;
|
|
2218
|
-
subscribe: (callback: (
|
|
2219
|
+
get: () => Readonly<T>;
|
|
2220
|
+
set: (callback: (currentState: Readonly<T>) => Readonly<T>) => void;
|
|
2221
|
+
subscribe: (callback: () => void) => () => void;
|
|
2222
|
+
batch: (callback: () => void) => void;
|
|
2219
2223
|
};
|
|
2224
|
+
/**
|
|
2225
|
+
* Create a store for an immutable state. Close to Zustand's vanilla store conceptually but with less features.
|
|
2226
|
+
*/
|
|
2227
|
+
declare function createStore<T>(initialState: T): Store<T>;
|
|
2220
2228
|
|
|
2221
2229
|
/**
|
|
2222
2230
|
* Back-port of TypeScript 5.4's built-in NoInfer utility type.
|
|
@@ -2224,155 +2232,6 @@ declare type Store<T> = {
|
|
|
2224
2232
|
*/
|
|
2225
2233
|
declare type NoInfr<A> = [A][A extends any ? 0 : never];
|
|
2226
2234
|
|
|
2227
|
-
declare type HistoryVersion = {
|
|
2228
|
-
type: "historyVersion";
|
|
2229
|
-
kind: "yjs";
|
|
2230
|
-
createdAt: Date;
|
|
2231
|
-
id: string;
|
|
2232
|
-
authors: {
|
|
2233
|
-
id: string;
|
|
2234
|
-
}[];
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
|
-
declare type OptimisticUpdate<M extends BaseMetadata> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | MarkThreadAsResolvedOptimisticUpdate | MarkThreadAsUnresolvedOptimisticUpdate | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | DeleteInboxNotificationOptimisticUpdate | DeleteAllInboxNotificationsOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
|
|
2238
|
-
declare type CreateThreadOptimisticUpdate<M extends BaseMetadata> = {
|
|
2239
|
-
type: "create-thread";
|
|
2240
|
-
id: string;
|
|
2241
|
-
roomId: string;
|
|
2242
|
-
thread: ThreadData<M>;
|
|
2243
|
-
};
|
|
2244
|
-
declare type DeleteThreadOptimisticUpdate = {
|
|
2245
|
-
type: "delete-thread";
|
|
2246
|
-
id: string;
|
|
2247
|
-
roomId: string;
|
|
2248
|
-
threadId: string;
|
|
2249
|
-
deletedAt: Date;
|
|
2250
|
-
};
|
|
2251
|
-
declare type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata> = {
|
|
2252
|
-
type: "edit-thread-metadata";
|
|
2253
|
-
id: string;
|
|
2254
|
-
threadId: string;
|
|
2255
|
-
metadata: Resolve<Patchable<M>>;
|
|
2256
|
-
updatedAt: Date;
|
|
2257
|
-
};
|
|
2258
|
-
declare type MarkThreadAsResolvedOptimisticUpdate = {
|
|
2259
|
-
type: "mark-thread-as-resolved";
|
|
2260
|
-
id: string;
|
|
2261
|
-
threadId: string;
|
|
2262
|
-
updatedAt: Date;
|
|
2263
|
-
};
|
|
2264
|
-
declare type MarkThreadAsUnresolvedOptimisticUpdate = {
|
|
2265
|
-
type: "mark-thread-as-unresolved";
|
|
2266
|
-
id: string;
|
|
2267
|
-
threadId: string;
|
|
2268
|
-
updatedAt: Date;
|
|
2269
|
-
};
|
|
2270
|
-
declare type CreateCommentOptimisticUpdate = {
|
|
2271
|
-
type: "create-comment";
|
|
2272
|
-
id: string;
|
|
2273
|
-
comment: CommentData;
|
|
2274
|
-
};
|
|
2275
|
-
declare type EditCommentOptimisticUpdate = {
|
|
2276
|
-
type: "edit-comment";
|
|
2277
|
-
id: string;
|
|
2278
|
-
comment: CommentData;
|
|
2279
|
-
};
|
|
2280
|
-
declare type DeleteCommentOptimisticUpdate = {
|
|
2281
|
-
type: "delete-comment";
|
|
2282
|
-
id: string;
|
|
2283
|
-
roomId: string;
|
|
2284
|
-
threadId: string;
|
|
2285
|
-
deletedAt: Date;
|
|
2286
|
-
commentId: string;
|
|
2287
|
-
};
|
|
2288
|
-
declare type AddReactionOptimisticUpdate = {
|
|
2289
|
-
type: "add-reaction";
|
|
2290
|
-
id: string;
|
|
2291
|
-
threadId: string;
|
|
2292
|
-
commentId: string;
|
|
2293
|
-
reaction: CommentUserReaction;
|
|
2294
|
-
};
|
|
2295
|
-
declare type RemoveReactionOptimisticUpdate = {
|
|
2296
|
-
type: "remove-reaction";
|
|
2297
|
-
id: string;
|
|
2298
|
-
threadId: string;
|
|
2299
|
-
commentId: string;
|
|
2300
|
-
emoji: string;
|
|
2301
|
-
userId: string;
|
|
2302
|
-
removedAt: Date;
|
|
2303
|
-
};
|
|
2304
|
-
declare type MarkInboxNotificationAsReadOptimisticUpdate = {
|
|
2305
|
-
type: "mark-inbox-notification-as-read";
|
|
2306
|
-
id: string;
|
|
2307
|
-
inboxNotificationId: string;
|
|
2308
|
-
readAt: Date;
|
|
2309
|
-
};
|
|
2310
|
-
declare type MarkAllInboxNotificationsAsReadOptimisticUpdate = {
|
|
2311
|
-
type: "mark-all-inbox-notifications-as-read";
|
|
2312
|
-
id: string;
|
|
2313
|
-
readAt: Date;
|
|
2314
|
-
};
|
|
2315
|
-
declare type DeleteInboxNotificationOptimisticUpdate = {
|
|
2316
|
-
type: "delete-inbox-notification";
|
|
2317
|
-
id: string;
|
|
2318
|
-
inboxNotificationId: string;
|
|
2319
|
-
deletedAt: Date;
|
|
2320
|
-
};
|
|
2321
|
-
declare type DeleteAllInboxNotificationsOptimisticUpdate = {
|
|
2322
|
-
type: "delete-all-inbox-notifications";
|
|
2323
|
-
id: string;
|
|
2324
|
-
deletedAt: Date;
|
|
2325
|
-
};
|
|
2326
|
-
declare type UpdateNotificationSettingsOptimisticUpdate = {
|
|
2327
|
-
type: "update-notification-settings";
|
|
2328
|
-
id: string;
|
|
2329
|
-
roomId: string;
|
|
2330
|
-
settings: Partial<RoomNotificationSettings>;
|
|
2331
|
-
};
|
|
2332
|
-
declare type QueryState = AsyncResult<undefined>;
|
|
2333
|
-
declare type CacheState<M extends BaseMetadata> = {
|
|
2334
|
-
/**
|
|
2335
|
-
* Threads by ID.
|
|
2336
|
-
*/
|
|
2337
|
-
threads: Record<string, ThreadDataWithDeleteInfo<M>>;
|
|
2338
|
-
/**
|
|
2339
|
-
* Keep track of loading and error status of all the queries made by the client.
|
|
2340
|
-
*/
|
|
2341
|
-
queries: Record<string, QueryState>;
|
|
2342
|
-
/**
|
|
2343
|
-
* Optimistic updates that have not been acknowledged by the server yet.
|
|
2344
|
-
* They are applied on top of the threads in selectors.
|
|
2345
|
-
*/
|
|
2346
|
-
optimisticUpdates: OptimisticUpdate<M>[];
|
|
2347
|
-
/**
|
|
2348
|
-
* Inbox notifications by ID.
|
|
2349
|
-
*/
|
|
2350
|
-
inboxNotifications: Record<string, InboxNotificationData>;
|
|
2351
|
-
/**
|
|
2352
|
-
* Notification settings per room id
|
|
2353
|
-
*/
|
|
2354
|
-
notificationSettings: Record<string, RoomNotificationSettings>;
|
|
2355
|
-
/**
|
|
2356
|
-
* Versions per roomId
|
|
2357
|
-
*/
|
|
2358
|
-
versions: Record<string, HistoryVersion[]>;
|
|
2359
|
-
};
|
|
2360
|
-
interface CacheStore<M extends BaseMetadata> extends Store<CacheState<M>> {
|
|
2361
|
-
deleteThread(threadId: string): void;
|
|
2362
|
-
updateThreadAndNotification(thread: ThreadData<M>, inboxNotification?: InboxNotificationData): void;
|
|
2363
|
-
updateThreadsAndNotifications(threads: ThreadData<M>[], inboxNotifications: InboxNotificationData[], deletedThreads: ThreadDeleteInfo[], deletedInboxNotifications: InboxNotificationDeleteInfo[], queryKey?: string): void;
|
|
2364
|
-
updateRoomInboxNotificationSettings(roomId: string, settings: RoomNotificationSettings, queryKey: string): void;
|
|
2365
|
-
updateRoomVersions(roomId: string, versions: HistoryVersion[], queryKey: string): void;
|
|
2366
|
-
pushOptimisticUpdate(optimisticUpdate: OptimisticUpdate<M>): void;
|
|
2367
|
-
setQueryState(queryKey: string, queryState: QueryState): void;
|
|
2368
|
-
optimisticUpdatesEventSource: ReturnType<typeof makeEventSource<OptimisticUpdate<M>>>;
|
|
2369
|
-
}
|
|
2370
|
-
declare function applyOptimisticUpdates<M extends BaseMetadata>(state: CacheState<M>): Pick<CacheState<M>, "threads" | "inboxNotifications" | "notificationSettings">;
|
|
2371
|
-
declare function upsertComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, comment: CommentData): ThreadDataWithDeleteInfo<M>;
|
|
2372
|
-
declare function deleteComment<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, deletedAt: Date): ThreadDataWithDeleteInfo<M>;
|
|
2373
|
-
declare function addReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, reaction: CommentUserReaction): ThreadDataWithDeleteInfo<M>;
|
|
2374
|
-
declare function removeReaction<M extends BaseMetadata>(thread: ThreadDataWithDeleteInfo<M>, commentId: string, emoji: string, userId: string, removedAt: Date): ThreadDataWithDeleteInfo<M>;
|
|
2375
|
-
|
|
2376
2235
|
declare type OptionalPromise<T> = T | Promise<T>;
|
|
2377
2236
|
|
|
2378
2237
|
declare type ResolveMentionSuggestionsArgs = {
|
|
@@ -2437,18 +2296,17 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2437
2296
|
declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
2438
2297
|
readonly currentUserIdStore: Store<string | null>;
|
|
2439
2298
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
2440
|
-
readonly cacheStore: CacheStore<BaseMetadata>;
|
|
2441
2299
|
readonly usersStore: BatchStore<U["info"] | undefined, string>;
|
|
2442
2300
|
readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
|
|
2443
2301
|
readonly getRoomIds: () => string[];
|
|
2444
|
-
readonly getThreads: () => Promise<{
|
|
2302
|
+
readonly getThreads: (options: GetThreadsOptions<M>) => Promise<{
|
|
2445
2303
|
threads: ThreadData<M>[];
|
|
2446
2304
|
inboxNotifications: InboxNotificationData[];
|
|
2447
2305
|
requestedAt: Date;
|
|
2448
2306
|
}>;
|
|
2449
2307
|
readonly getThreadsSince: (options: {
|
|
2450
2308
|
since: Date;
|
|
2451
|
-
}) => Promise<{
|
|
2309
|
+
} & GetThreadsOptions<M>) => Promise<{
|
|
2452
2310
|
inboxNotifications: {
|
|
2453
2311
|
updated: InboxNotificationData[];
|
|
2454
2312
|
deleted: InboxNotificationDeleteInfo[];
|
|
@@ -2911,6 +2769,7 @@ declare const brand: unique symbol;
|
|
|
2911
2769
|
declare type Brand<T, TBrand extends string> = T & {
|
|
2912
2770
|
[brand]: TBrand;
|
|
2913
2771
|
};
|
|
2772
|
+
declare type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
|
|
2914
2773
|
/**
|
|
2915
2774
|
* Throw an error, but as an expression instead of a statement.
|
|
2916
2775
|
*/
|
|
@@ -2918,6 +2777,13 @@ declare function raise(msg: string): never;
|
|
|
2918
2777
|
declare function isPlainObject(blob: unknown): blob is {
|
|
2919
2778
|
[key: string]: unknown;
|
|
2920
2779
|
};
|
|
2780
|
+
/**
|
|
2781
|
+
* Creates a new object by mapping a function over all values. Keys remain the
|
|
2782
|
+
* same. Think Array.prototype.map(), but for values in an object.
|
|
2783
|
+
*/
|
|
2784
|
+
declare function mapValues<V, O extends Record<string, unknown>>(obj: O, mapFn: (value: O[keyof O], key: keyof O) => V): {
|
|
2785
|
+
[K in keyof O]: V;
|
|
2786
|
+
};
|
|
2921
2787
|
/**
|
|
2922
2788
|
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
2923
2789
|
* string cannot be parsed, this will return `undefined`.
|
|
@@ -2927,6 +2793,14 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
|
2927
2793
|
* Decode base64 string.
|
|
2928
2794
|
*/
|
|
2929
2795
|
declare function b64decode(b64value: string): string;
|
|
2796
|
+
declare type RemoveUndefinedValues<T> = {
|
|
2797
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* Returns a new object instance where all explictly-undefined values are
|
|
2801
|
+
* removed.
|
|
2802
|
+
*/
|
|
2803
|
+
declare function compactObject<O extends Record<string, unknown>>(obj: O): RemoveUndefinedValues<O>;
|
|
2930
2804
|
/**
|
|
2931
2805
|
* Returns a promise that resolves after the given number of milliseconds.
|
|
2932
2806
|
*/
|
|
@@ -3024,6 +2898,16 @@ declare function shallow(a: unknown, b: unknown): boolean;
|
|
|
3024
2898
|
declare type OmitFirstTupleElement<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
|
3025
2899
|
declare function stringify(object: Parameters<typeof JSON.stringify>[0], ...args: OmitFirstTupleElement<Parameters<typeof JSON.stringify>>): string;
|
|
3026
2900
|
|
|
2901
|
+
declare type HistoryVersion = {
|
|
2902
|
+
type: "historyVersion";
|
|
2903
|
+
kind: "yjs";
|
|
2904
|
+
createdAt: Date;
|
|
2905
|
+
id: string;
|
|
2906
|
+
authors: {
|
|
2907
|
+
id: string;
|
|
2908
|
+
}[];
|
|
2909
|
+
};
|
|
2910
|
+
|
|
3027
2911
|
/**
|
|
3028
2912
|
* Definition of all messages the Panel can send to the Client.
|
|
3029
2913
|
*/
|
|
@@ -3156,4 +3040,4 @@ declare type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (En
|
|
|
3156
3040
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
3157
3041
|
};
|
|
3158
3042
|
|
|
3159
|
-
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
|
|
3043
|
+
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 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 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 User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, ackOp, asPos, assert, assertNever, b64decode, 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 };
|