@liveblocks/core 1.2.3 → 1.3.0
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 +373 -28
- package/dist/index.d.ts +373 -28
- package/dist/index.js +449 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +408 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -570,6 +570,11 @@ declare type CustomAuthenticationResult = {
|
|
|
570
570
|
reason: string;
|
|
571
571
|
};
|
|
572
572
|
|
|
573
|
+
declare type BaseUserInfo = {
|
|
574
|
+
[key: string]: Json | undefined;
|
|
575
|
+
name?: string;
|
|
576
|
+
avatar?: string;
|
|
577
|
+
};
|
|
573
578
|
/**
|
|
574
579
|
* This type is used by clients to define the metadata for a user.
|
|
575
580
|
*/
|
|
@@ -582,9 +587,160 @@ declare type BaseUserMeta = {
|
|
|
582
587
|
/**
|
|
583
588
|
* Additional user information that has been set in the authentication endpoint.
|
|
584
589
|
*/
|
|
585
|
-
info?:
|
|
590
|
+
info?: BaseUserInfo;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
declare enum Permission {
|
|
594
|
+
Read = "room:read",
|
|
595
|
+
Write = "room:write",
|
|
596
|
+
PresenceWrite = "room:presence:write",
|
|
597
|
+
CommentsWrite = "comments:write",
|
|
598
|
+
CommentsRead = "comments:read"
|
|
599
|
+
}
|
|
600
|
+
declare type LiveblocksPermissions = Record<string, Permission[]>;
|
|
601
|
+
declare enum TokenKind {
|
|
602
|
+
SECRET_LEGACY = "sec-legacy",
|
|
603
|
+
ACCESS_TOKEN = "acc",
|
|
604
|
+
ID_TOKEN = "id"
|
|
605
|
+
}
|
|
606
|
+
declare type JwtMeta = {
|
|
607
|
+
iat: number;
|
|
608
|
+
exp: number;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Legacy Secret Token.
|
|
612
|
+
*/
|
|
613
|
+
declare type LegacySecretToken = {
|
|
614
|
+
k: TokenKind.SECRET_LEGACY;
|
|
615
|
+
roomId: string;
|
|
616
|
+
scopes: string[];
|
|
617
|
+
id?: string;
|
|
618
|
+
info?: BaseUserInfo;
|
|
619
|
+
[other: string]: Json | undefined;
|
|
620
|
+
} & JwtMeta;
|
|
621
|
+
/**
|
|
622
|
+
* New authorization Access Token.
|
|
623
|
+
*/
|
|
624
|
+
declare type AccessToken = {
|
|
625
|
+
k: TokenKind.ACCESS_TOKEN;
|
|
626
|
+
pid: string;
|
|
627
|
+
uid: string;
|
|
628
|
+
perms: LiveblocksPermissions;
|
|
629
|
+
ui?: BaseUserInfo;
|
|
630
|
+
} & JwtMeta;
|
|
631
|
+
/**
|
|
632
|
+
* New authorization ID Token.
|
|
633
|
+
*/
|
|
634
|
+
declare type IDToken = {
|
|
635
|
+
k: TokenKind.ID_TOKEN;
|
|
636
|
+
pid: string;
|
|
637
|
+
uid: string;
|
|
638
|
+
gids?: string[];
|
|
639
|
+
ui?: BaseUserInfo;
|
|
640
|
+
} & JwtMeta;
|
|
641
|
+
declare type AuthToken = AccessToken | IDToken | LegacySecretToken;
|
|
642
|
+
declare type ParsedAuthToken = {
|
|
643
|
+
readonly raw: string;
|
|
644
|
+
readonly parsed: AuthToken;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
declare type AuthValue = {
|
|
648
|
+
type: "secret";
|
|
649
|
+
token: ParsedAuthToken;
|
|
650
|
+
} | {
|
|
651
|
+
type: "public";
|
|
652
|
+
publicApiKey: string;
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
declare type BaseMetadata = Record<string, string | boolean | number>;
|
|
656
|
+
|
|
657
|
+
declare type CommentBodyBlockElement = CommentBodyParagraph;
|
|
658
|
+
declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention;
|
|
659
|
+
declare type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
|
|
660
|
+
declare type CommentBodyParagraph = {
|
|
661
|
+
type: "paragraph";
|
|
662
|
+
children: CommentBodyInlineElement[];
|
|
663
|
+
};
|
|
664
|
+
declare type CommentBodyMention = {
|
|
665
|
+
type: "mention";
|
|
666
|
+
id: string;
|
|
667
|
+
};
|
|
668
|
+
declare type CommentBodyText = {
|
|
669
|
+
bold?: boolean;
|
|
670
|
+
italic?: boolean;
|
|
671
|
+
strikethrough?: boolean;
|
|
672
|
+
code?: boolean;
|
|
673
|
+
text: string;
|
|
674
|
+
};
|
|
675
|
+
declare type CommentBody = {
|
|
676
|
+
version: 1;
|
|
677
|
+
content: CommentBodyBlockElement[];
|
|
586
678
|
};
|
|
587
679
|
|
|
680
|
+
/**
|
|
681
|
+
* Represents a comment.
|
|
682
|
+
*/
|
|
683
|
+
declare type CommentData = {
|
|
684
|
+
type: "comment";
|
|
685
|
+
id: string;
|
|
686
|
+
threadId: string;
|
|
687
|
+
roomId: string;
|
|
688
|
+
userId: string;
|
|
689
|
+
createdAt: string;
|
|
690
|
+
editedAt?: string;
|
|
691
|
+
} & ({
|
|
692
|
+
body: CommentBody;
|
|
693
|
+
deletedAt?: never;
|
|
694
|
+
} | {
|
|
695
|
+
body?: never;
|
|
696
|
+
deletedAt: string;
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Represents a thread of comments.
|
|
701
|
+
*/
|
|
702
|
+
declare type ThreadData<ThreadMetadata extends BaseMetadata = never> = {
|
|
703
|
+
type: "thread";
|
|
704
|
+
id: string;
|
|
705
|
+
roomId: string;
|
|
706
|
+
createdAt: string;
|
|
707
|
+
updatedAt?: string;
|
|
708
|
+
comments: CommentData[];
|
|
709
|
+
metadata: [ThreadMetadata] extends [never] ? Record<string, never> : ThreadMetadata;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
declare type Options = {
|
|
713
|
+
serverEndpoint: string;
|
|
714
|
+
};
|
|
715
|
+
declare type CommentsApi<ThreadMetadata extends BaseMetadata> = {
|
|
716
|
+
getThreads(): Promise<ThreadData<ThreadMetadata>[]>;
|
|
717
|
+
createThread(options: {
|
|
718
|
+
threadId: string;
|
|
719
|
+
commentId: string;
|
|
720
|
+
metadata: ThreadMetadata | undefined;
|
|
721
|
+
body: CommentBody;
|
|
722
|
+
}): Promise<ThreadData<ThreadMetadata>>;
|
|
723
|
+
editThreadMetadata(options: {
|
|
724
|
+
metadata: Partial<ThreadMetadata>;
|
|
725
|
+
threadId: string;
|
|
726
|
+
}): Promise<ThreadData<ThreadMetadata>>;
|
|
727
|
+
createComment(options: {
|
|
728
|
+
threadId: string;
|
|
729
|
+
commentId: string;
|
|
730
|
+
body: CommentBody;
|
|
731
|
+
}): Promise<CommentData>;
|
|
732
|
+
editComment(options: {
|
|
733
|
+
threadId: string;
|
|
734
|
+
commentId: string;
|
|
735
|
+
body: CommentBody;
|
|
736
|
+
}): Promise<CommentData>;
|
|
737
|
+
deleteComment(options: {
|
|
738
|
+
threadId: string;
|
|
739
|
+
commentId: string;
|
|
740
|
+
}): Promise<void>;
|
|
741
|
+
};
|
|
742
|
+
declare function createCommentsApi<ThreadMetadata extends BaseMetadata>(roomId: string, getAuthValue: () => Promise<AuthValue>, { serverEndpoint }: Options): CommentsApi<ThreadMetadata>;
|
|
743
|
+
|
|
588
744
|
declare type Callback<T> = (event: T) => void;
|
|
589
745
|
declare type UnsubscribeCallback = () => void;
|
|
590
746
|
declare type Observable<T> = {
|
|
@@ -606,6 +762,59 @@ declare type Observable<T> = {
|
|
|
606
762
|
*/
|
|
607
763
|
waitUntil(predicate?: (event: T) => boolean): Promise<T>;
|
|
608
764
|
};
|
|
765
|
+
declare type EventSource<T> = Observable<T> & {
|
|
766
|
+
/**
|
|
767
|
+
* Notify all subscribers about the event.
|
|
768
|
+
*/
|
|
769
|
+
notify(event: T): void;
|
|
770
|
+
/**
|
|
771
|
+
* Clear all registered event listeners. None of the registered functions
|
|
772
|
+
* will ever get called again. Be careful when using this API, because the
|
|
773
|
+
* subscribers may not have any idea they won't be notified anymore.
|
|
774
|
+
*/
|
|
775
|
+
clear(): void;
|
|
776
|
+
/**
|
|
777
|
+
* Returns the number of active subscribers.
|
|
778
|
+
*/
|
|
779
|
+
count(): number;
|
|
780
|
+
/**
|
|
781
|
+
* Pauses event delivery until unpaused. Any .notify() calls made while
|
|
782
|
+
* paused will get buffered into memory and emitted later.
|
|
783
|
+
*/
|
|
784
|
+
pause(): void;
|
|
785
|
+
/**
|
|
786
|
+
* Emits all in-memory buffered events, and unpauses. Any .notify() calls
|
|
787
|
+
* made after this will be synchronously delivered again.
|
|
788
|
+
*/
|
|
789
|
+
unpause(): void;
|
|
790
|
+
/**
|
|
791
|
+
* Observable instance, which can be used to subscribe to this event source
|
|
792
|
+
* in a readonly fashion. Safe to publicly expose.
|
|
793
|
+
*/
|
|
794
|
+
observable: Observable<T>;
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* makeEventSource allows you to generate a subscribe/notify pair of functions
|
|
798
|
+
* to make subscribing easy and to get notified about events.
|
|
799
|
+
*
|
|
800
|
+
* The events are anonymous, so you can use it to define events, like so:
|
|
801
|
+
*
|
|
802
|
+
* const event1 = makeEventSource();
|
|
803
|
+
* const event2 = makeEventSource();
|
|
804
|
+
*
|
|
805
|
+
* event1.subscribe(foo);
|
|
806
|
+
* event1.subscribe(bar);
|
|
807
|
+
* event2.subscribe(qux);
|
|
808
|
+
*
|
|
809
|
+
* // Unsubscription is pretty standard
|
|
810
|
+
* const unsub = event2.subscribe(foo);
|
|
811
|
+
* unsub();
|
|
812
|
+
*
|
|
813
|
+
* event1.notify(); // Now foo and bar will get called
|
|
814
|
+
* event2.notify(); // Now qux will get called (but foo will not, since it's unsubscribed)
|
|
815
|
+
*
|
|
816
|
+
*/
|
|
817
|
+
declare function makeEventSource<T>(): EventSource<T>;
|
|
609
818
|
|
|
610
819
|
interface IWebSocketEvent {
|
|
611
820
|
type: string;
|
|
@@ -760,12 +969,41 @@ declare enum ServerMsgCode {
|
|
|
760
969
|
INITIAL_STORAGE_STATE = 200,
|
|
761
970
|
UPDATE_STORAGE = 201,
|
|
762
971
|
REJECT_STORAGE_OP = 299,
|
|
763
|
-
UPDATE_YDOC = 300
|
|
972
|
+
UPDATE_YDOC = 300,
|
|
973
|
+
THREAD_CREATED = 400,
|
|
974
|
+
THREAD_METADATA_UPDATED = 401,
|
|
975
|
+
COMMENT_CREATED = 402,
|
|
976
|
+
COMMENT_EDITED = 403,
|
|
977
|
+
COMMENT_DELETED = 404
|
|
764
978
|
}
|
|
765
979
|
/**
|
|
766
980
|
* Messages that can be sent from the server to the client.
|
|
767
981
|
*/
|
|
768
|
-
declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdate;
|
|
982
|
+
declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdate | CommentsEventServerMsg;
|
|
983
|
+
declare type CommentsEventServerMsg = ThreadCreatedEvent | ThreadMetadataUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent;
|
|
984
|
+
declare type ThreadCreatedEvent = {
|
|
985
|
+
type: ServerMsgCode.THREAD_CREATED;
|
|
986
|
+
threadId: string;
|
|
987
|
+
};
|
|
988
|
+
declare type ThreadMetadataUpdatedEvent = {
|
|
989
|
+
type: ServerMsgCode.THREAD_METADATA_UPDATED;
|
|
990
|
+
threadId: string;
|
|
991
|
+
};
|
|
992
|
+
declare type CommentCreatedEvent = {
|
|
993
|
+
type: ServerMsgCode.COMMENT_CREATED;
|
|
994
|
+
threadId: string;
|
|
995
|
+
commentId: string;
|
|
996
|
+
};
|
|
997
|
+
declare type CommentEditedEvent = {
|
|
998
|
+
type: ServerMsgCode.COMMENT_EDITED;
|
|
999
|
+
threadId: string;
|
|
1000
|
+
commentId: string;
|
|
1001
|
+
};
|
|
1002
|
+
declare type CommentDeletedEvent = {
|
|
1003
|
+
type: ServerMsgCode.COMMENT_DELETED;
|
|
1004
|
+
threadId: string;
|
|
1005
|
+
commentId: string;
|
|
1006
|
+
};
|
|
769
1007
|
/**
|
|
770
1008
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
771
1009
|
* a User updated their presence. For example, when a user moves their cursor.
|
|
@@ -928,18 +1166,6 @@ declare type RejectedStorageOpServerMsg = {
|
|
|
928
1166
|
readonly reason: string;
|
|
929
1167
|
};
|
|
930
1168
|
|
|
931
|
-
declare type ReadonlyArrayWithLegacyMethods<T> = readonly T[] & {
|
|
932
|
-
/**
|
|
933
|
-
* @deprecated Prefer the normal .length property on arrays.
|
|
934
|
-
*/
|
|
935
|
-
readonly count: number;
|
|
936
|
-
/**
|
|
937
|
-
* @deprecated Calling .toArray() is no longer needed
|
|
938
|
-
*/
|
|
939
|
-
readonly toArray: () => readonly T[];
|
|
940
|
-
};
|
|
941
|
-
declare function asArrayWithLegacyMethods<T>(arr: readonly T[]): ReadonlyArrayWithLegacyMethods<T>;
|
|
942
|
-
|
|
943
1169
|
/**
|
|
944
1170
|
* Represents a user connected in a room. Treated as immutable.
|
|
945
1171
|
*/
|
|
@@ -972,12 +1198,16 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
|
|
|
972
1198
|
* can only read but not mutate it.
|
|
973
1199
|
*/
|
|
974
1200
|
readonly canWrite: boolean;
|
|
1201
|
+
/**
|
|
1202
|
+
* True if the user can comment on a thread
|
|
1203
|
+
*/
|
|
1204
|
+
readonly canComment: boolean;
|
|
975
1205
|
};
|
|
976
1206
|
|
|
977
1207
|
/**
|
|
978
|
-
*
|
|
1208
|
+
* @deprecated Use `readonly User<TPresence, TUserMeta>[]` instead of `Others<TPresence, TUserMeta>`.
|
|
979
1209
|
*/
|
|
980
|
-
declare type Others<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> =
|
|
1210
|
+
declare type Others<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = readonly User<TPresence, TUserMeta>[];
|
|
981
1211
|
declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
|
|
982
1212
|
type: "leave";
|
|
983
1213
|
user: User<TPresence, TUserMeta>;
|
|
@@ -1109,7 +1339,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1109
1339
|
* });
|
|
1110
1340
|
*
|
|
1111
1341
|
*/
|
|
1112
|
-
(type: "others", listener: (others:
|
|
1342
|
+
(type: "others", listener: (others: readonly User<TPresence, TUserMeta>[], event: OthersEvent<TPresence, TUserMeta>) => void): () => void;
|
|
1113
1343
|
/**
|
|
1114
1344
|
* Subscribe to events broadcasted by {@link Room.broadcastEvent}
|
|
1115
1345
|
*
|
|
@@ -1239,7 +1469,7 @@ declare type SubscribeFn<TPresence extends JsonObject, _TStorage extends LsonObj
|
|
|
1239
1469
|
*/
|
|
1240
1470
|
(type: "storage-status", listener: Callback<StorageStatus>): () => void;
|
|
1241
1471
|
};
|
|
1242
|
-
declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = {
|
|
1472
|
+
declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = CommentsApi<any> & {
|
|
1243
1473
|
/**
|
|
1244
1474
|
* The id of the room.
|
|
1245
1475
|
*/
|
|
@@ -1294,7 +1524,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1294
1524
|
* @example
|
|
1295
1525
|
* const others = room.getOthers();
|
|
1296
1526
|
*/
|
|
1297
|
-
getOthers():
|
|
1527
|
+
getOthers(): readonly User<TPresence, TUserMeta>[];
|
|
1298
1528
|
/**
|
|
1299
1529
|
* Updates the presence of the current user. Only pass the properties you want to update. No need to send the full presence.
|
|
1300
1530
|
* @param patch A partial object that contains the properties you want to update.
|
|
@@ -1370,7 +1600,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1370
1600
|
readonly self: Observable<User<TPresence, TUserMeta>>;
|
|
1371
1601
|
readonly myPresence: Observable<TPresence>;
|
|
1372
1602
|
readonly others: Observable<{
|
|
1373
|
-
others:
|
|
1603
|
+
others: readonly User<TPresence, TUserMeta>[];
|
|
1374
1604
|
event: OthersEvent<TPresence, TUserMeta>;
|
|
1375
1605
|
}>;
|
|
1376
1606
|
readonly error: Observable<Error>;
|
|
@@ -1384,6 +1614,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
|
|
|
1384
1614
|
readonly storageDidLoad: Observable<void>;
|
|
1385
1615
|
readonly storageStatus: Observable<StorageStatus>;
|
|
1386
1616
|
readonly ydoc: Observable<YDocUpdate>;
|
|
1617
|
+
readonly comments: Observable<CommentsEventServerMsg>;
|
|
1387
1618
|
};
|
|
1388
1619
|
/**
|
|
1389
1620
|
* Batches modifications made during the given function.
|
|
@@ -1569,6 +1800,93 @@ declare function assert(condition: boolean, errmsg: string): asserts condition;
|
|
|
1569
1800
|
*/
|
|
1570
1801
|
declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
|
|
1571
1802
|
|
|
1803
|
+
declare type AsyncFunction<T, A extends any[] = any[]> = (...args: A) => Promise<T>;
|
|
1804
|
+
declare type AsyncCacheOptions<T, E> = {
|
|
1805
|
+
isStateEqual?: (a: AsyncState<T, E>, b: AsyncState<T, E>) => boolean;
|
|
1806
|
+
};
|
|
1807
|
+
declare type AsyncStateInitial = {
|
|
1808
|
+
readonly isLoading: false;
|
|
1809
|
+
readonly data?: never;
|
|
1810
|
+
readonly error?: never;
|
|
1811
|
+
};
|
|
1812
|
+
declare type AsyncStateLoading<T> = {
|
|
1813
|
+
readonly isLoading: true;
|
|
1814
|
+
readonly data?: T;
|
|
1815
|
+
readonly error?: never;
|
|
1816
|
+
};
|
|
1817
|
+
declare type AsyncStateSuccess<T> = {
|
|
1818
|
+
readonly isLoading: false;
|
|
1819
|
+
readonly data: T;
|
|
1820
|
+
readonly error?: never;
|
|
1821
|
+
};
|
|
1822
|
+
declare type AsyncStateError<T, E> = {
|
|
1823
|
+
readonly isLoading: false;
|
|
1824
|
+
readonly data?: T;
|
|
1825
|
+
readonly error: E;
|
|
1826
|
+
};
|
|
1827
|
+
declare type AsyncState<T, E> = AsyncStateInitial | AsyncStateLoading<T> | AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1828
|
+
declare type AsyncStateResolved<T, E> = AsyncStateSuccess<T> | AsyncStateError<T, E>;
|
|
1829
|
+
declare type AsyncCacheItem<T, E> = Observable<AsyncState<T, E>> & {
|
|
1830
|
+
setAsyncFunction(asyncFunction: AsyncFunction<T, [string]>): void;
|
|
1831
|
+
get(): Promise<AsyncStateResolved<T, E>>;
|
|
1832
|
+
getState(): AsyncState<T, E>;
|
|
1833
|
+
revalidate(): Promise<AsyncStateResolved<T, E>>;
|
|
1834
|
+
};
|
|
1835
|
+
declare type AsyncCache<T, E> = {
|
|
1836
|
+
/**
|
|
1837
|
+
* @private
|
|
1838
|
+
*
|
|
1839
|
+
* Creates a key in the cache.
|
|
1840
|
+
*
|
|
1841
|
+
* @param key The key to create.
|
|
1842
|
+
* @param asyncFunction Override the cache's function for this key.
|
|
1843
|
+
*/
|
|
1844
|
+
create(key: string, asyncFunction?: AsyncFunction<T, [string]>): AsyncCacheItem<T, E>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Returns a promise which resolves with the state of the key.
|
|
1847
|
+
*
|
|
1848
|
+
* @param key The key to get.
|
|
1849
|
+
*/
|
|
1850
|
+
get(key: string): Promise<AsyncStateResolved<T, E>>;
|
|
1851
|
+
/**
|
|
1852
|
+
* Returns the current state of the key synchronously.
|
|
1853
|
+
*
|
|
1854
|
+
* @param key The key to get the state of.
|
|
1855
|
+
*/
|
|
1856
|
+
getState(key: string): AsyncState<T, E> | undefined;
|
|
1857
|
+
/**
|
|
1858
|
+
* Revalidates the key.
|
|
1859
|
+
*
|
|
1860
|
+
* @param key The key to revalidate.
|
|
1861
|
+
*/
|
|
1862
|
+
revalidate(key: string): Promise<AsyncStateResolved<T, E>>;
|
|
1863
|
+
/**
|
|
1864
|
+
* Subscribes to the key's changes.
|
|
1865
|
+
*
|
|
1866
|
+
* @param key The key to subscribe to.
|
|
1867
|
+
* @param callback The function invoked on every change.
|
|
1868
|
+
*/
|
|
1869
|
+
subscribe(key: string, callback: Callback<AsyncState<T, E>>): UnsubscribeCallback;
|
|
1870
|
+
/**
|
|
1871
|
+
* Subscribes to the key's changes once.
|
|
1872
|
+
*
|
|
1873
|
+
* @param key The key to subscribe to.
|
|
1874
|
+
* @param callback The function invoked on every change.
|
|
1875
|
+
*/
|
|
1876
|
+
subscribeOnce(key: string, callback: Callback<AsyncState<T, E>>): UnsubscribeCallback;
|
|
1877
|
+
/**
|
|
1878
|
+
* Returns whether a key already exists in the cache.
|
|
1879
|
+
*
|
|
1880
|
+
* @param key The key to look for.
|
|
1881
|
+
*/
|
|
1882
|
+
has(key: string): boolean;
|
|
1883
|
+
/**
|
|
1884
|
+
* Clears all keys.
|
|
1885
|
+
*/
|
|
1886
|
+
clear(): void;
|
|
1887
|
+
};
|
|
1888
|
+
declare function createAsyncCache<T, E>(asyncFunction: AsyncFunction<T, [string]>, options?: AsyncCacheOptions<T, E>): AsyncCache<T, E>;
|
|
1889
|
+
|
|
1572
1890
|
/**
|
|
1573
1891
|
* Displays a deprecation warning in the dev console. Only in dev mode, and
|
|
1574
1892
|
* only once per message/key. In production, this is a no-op.
|
|
@@ -1595,12 +1913,39 @@ declare function throwUsageError(message: string): void;
|
|
|
1595
1913
|
*/
|
|
1596
1914
|
declare function errorIf(condition: unknown, message: string): void;
|
|
1597
1915
|
|
|
1916
|
+
declare const warn: (message: string, ...args: readonly unknown[]) => void;
|
|
1917
|
+
declare const error: (message: string, ...args: readonly unknown[]) => void;
|
|
1918
|
+
declare const warnWithTitle: (title: string, message: string, ...args: readonly unknown[]) => void;
|
|
1919
|
+
declare const errorWithTitle: (title: string, message: string, ...args: readonly unknown[]) => void;
|
|
1920
|
+
|
|
1921
|
+
declare const fancyConsole_error: typeof error;
|
|
1922
|
+
declare const fancyConsole_errorWithTitle: typeof errorWithTitle;
|
|
1923
|
+
declare const fancyConsole_warn: typeof warn;
|
|
1924
|
+
declare const fancyConsole_warnWithTitle: typeof warnWithTitle;
|
|
1925
|
+
declare namespace fancyConsole {
|
|
1926
|
+
export {
|
|
1927
|
+
fancyConsole_error as error,
|
|
1928
|
+
fancyConsole_errorWithTitle as errorWithTitle,
|
|
1929
|
+
fancyConsole_warn as warn,
|
|
1930
|
+
fancyConsole_warnWithTitle as warnWithTitle,
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1598
1934
|
/**
|
|
1599
1935
|
* Freezes the given argument, but only in development builds. In production
|
|
1600
1936
|
* builds, this is a no-op for performance reasons.
|
|
1601
1937
|
*/
|
|
1602
1938
|
declare const freeze: typeof Object.freeze;
|
|
1603
1939
|
|
|
1940
|
+
declare type Poller = {
|
|
1941
|
+
start(interval: number): void;
|
|
1942
|
+
restart(interval: number): void;
|
|
1943
|
+
pause(): void;
|
|
1944
|
+
resume(): void;
|
|
1945
|
+
stop(): void;
|
|
1946
|
+
};
|
|
1947
|
+
declare function makePoller(callback: () => Promise<void> | void): Poller;
|
|
1948
|
+
|
|
1604
1949
|
declare const brand: unique symbol;
|
|
1605
1950
|
declare type Brand<T, TBrand extends string> = T & {
|
|
1606
1951
|
[brand]: TBrand;
|
|
@@ -1800,15 +2145,15 @@ declare type TreeNode = LsonTreeNode | UserTreeNode;
|
|
|
1800
2145
|
type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
|
|
1801
2146
|
type DevToolsTreeNode_LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = LiveTreeNode<TName>;
|
|
1802
2147
|
type DevToolsTreeNode_LsonTreeNode = LsonTreeNode;
|
|
1803
|
-
type DevToolsTreeNode_UserTreeNode = UserTreeNode;
|
|
1804
2148
|
type DevToolsTreeNode_TreeNode = TreeNode;
|
|
2149
|
+
type DevToolsTreeNode_UserTreeNode = UserTreeNode;
|
|
1805
2150
|
declare namespace DevToolsTreeNode {
|
|
1806
2151
|
export {
|
|
1807
2152
|
DevToolsTreeNode_JsonTreeNode as JsonTreeNode,
|
|
1808
2153
|
DevToolsTreeNode_LiveTreeNode as LiveTreeNode,
|
|
1809
2154
|
DevToolsTreeNode_LsonTreeNode as LsonTreeNode,
|
|
1810
|
-
DevToolsTreeNode_UserTreeNode as UserTreeNode,
|
|
1811
2155
|
DevToolsTreeNode_TreeNode as TreeNode,
|
|
2156
|
+
DevToolsTreeNode_UserTreeNode as UserTreeNode,
|
|
1812
2157
|
};
|
|
1813
2158
|
}
|
|
1814
2159
|
|
|
@@ -1908,16 +2253,16 @@ declare type FullClientToPanelMessage = ClientToPanelMessage & {
|
|
|
1908
2253
|
source: "liveblocks-devtools-client";
|
|
1909
2254
|
};
|
|
1910
2255
|
|
|
1911
|
-
type protocol_PanelToClientMessage = PanelToClientMessage;
|
|
1912
2256
|
type protocol_ClientToPanelMessage = ClientToPanelMessage;
|
|
1913
|
-
type protocol_FullPanelToClientMessage = FullPanelToClientMessage;
|
|
1914
2257
|
type protocol_FullClientToPanelMessage = FullClientToPanelMessage;
|
|
2258
|
+
type protocol_FullPanelToClientMessage = FullPanelToClientMessage;
|
|
2259
|
+
type protocol_PanelToClientMessage = PanelToClientMessage;
|
|
1915
2260
|
declare namespace protocol {
|
|
1916
2261
|
export {
|
|
1917
|
-
protocol_PanelToClientMessage as PanelToClientMessage,
|
|
1918
2262
|
protocol_ClientToPanelMessage as ClientToPanelMessage,
|
|
1919
|
-
protocol_FullPanelToClientMessage as FullPanelToClientMessage,
|
|
1920
2263
|
protocol_FullClientToPanelMessage as FullClientToPanelMessage,
|
|
2264
|
+
protocol_FullPanelToClientMessage as FullPanelToClientMessage,
|
|
2265
|
+
protocol_PanelToClientMessage as PanelToClientMessage,
|
|
1921
2266
|
};
|
|
1922
2267
|
}
|
|
1923
2268
|
|
|
@@ -1933,4 +2278,4 @@ declare type EnsureJson<T> = [
|
|
|
1933
2278
|
[K in keyof T]: EnsureJson<T[K]>;
|
|
1934
2279
|
};
|
|
1935
2280
|
|
|
1936
|
-
export { AckOp, BaseAuthResult, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, CustomAuthenticationResult, Delegates, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, 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, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, Status, StorageStatus, StorageUpdate, ToImmutable, ToJson, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UpdateYDocClientMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes,
|
|
2281
|
+
export { AckOp, AsyncCache, AsyncState, AsyncStateError, AsyncStateInitial, AsyncStateLoading, AsyncStateResolved, AsyncStateSuccess, BaseAuthResult, BaseMetadata, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, CommentBody, CommentBodyElement, CommentBodyMention, CommentBodyParagraph, CommentData, 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, 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, asPos, assert, assertNever, b64decode, fancyConsole as console, createAsyncCache, createClient, createCommentsApi, deprecate, deprecateIf, detectDupes, errorIf, freeze, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, toPlainLson, tryParseJson, withTimeout };
|