@liveblocks/core 2.15.2 → 2.16.0-toolbars1
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 +244 -240
- package/dist/index.d.ts +244 -240
- package/dist/index.js +35 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
declare function detectDupes(pkgName: string, pkgVersion: string | false, // false if not built yet
|
|
6
6
|
pkgFormat: string | false): void;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type CustomAuthenticationResult = {
|
|
9
9
|
token: string;
|
|
10
10
|
error?: never;
|
|
11
11
|
} | {
|
|
@@ -28,13 +28,13 @@ declare type CustomAuthenticationResult = {
|
|
|
28
28
|
* - JsonObject a JSON value whose outer type is an object
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
type Json = JsonScalar | JsonArray | JsonObject;
|
|
32
|
+
type JsonScalar = string | number | boolean | null;
|
|
33
|
+
type JsonArray = Json[];
|
|
34
34
|
/**
|
|
35
35
|
* Any valid JSON object.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
type JsonObject = {
|
|
38
38
|
[key: string]: Json | undefined;
|
|
39
39
|
};
|
|
40
40
|
declare function isJsonScalar(data: Json): data is JsonScalar;
|
|
@@ -46,7 +46,7 @@ declare function isJsonObject(data: Json): data is JsonObject;
|
|
|
46
46
|
* object is fine, but _if_ it has a name field, it _must_ be a string."
|
|
47
47
|
* (Ditto for avatar.)
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
type IUserInfo = {
|
|
50
50
|
[key: string]: Json | undefined;
|
|
51
51
|
name?: string;
|
|
52
52
|
avatar?: string;
|
|
@@ -54,7 +54,7 @@ declare type IUserInfo = {
|
|
|
54
54
|
/**
|
|
55
55
|
* This type is used by clients to define the metadata for a user.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
type BaseUserMeta = {
|
|
58
58
|
/**
|
|
59
59
|
* The id of the user that has been set in the authentication endpoint.
|
|
60
60
|
* Useful to get additional information about the connected user.
|
|
@@ -74,9 +74,9 @@ declare enum Permission {
|
|
|
74
74
|
CommentsRead = "comments:read"
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
type Callback<T> = (event: T) => void;
|
|
78
|
+
type UnsubscribeCallback = () => void;
|
|
79
|
+
type Observable<T> = {
|
|
80
80
|
/**
|
|
81
81
|
* Register a callback function to be called whenever the event source emits
|
|
82
82
|
* an event.
|
|
@@ -95,7 +95,7 @@ declare type Observable<T> = {
|
|
|
95
95
|
*/
|
|
96
96
|
waitUntil(predicate?: (event: T) => boolean): Promise<T>;
|
|
97
97
|
};
|
|
98
|
-
|
|
98
|
+
type EventSource<T> = Observable<T> & {
|
|
99
99
|
/**
|
|
100
100
|
* Notify all subscribers about the event.
|
|
101
101
|
*/
|
|
@@ -227,7 +227,7 @@ declare enum WebsocketCloseCodes {
|
|
|
227
227
|
* a Room, as returned by `room.getStatus()`. Can be used to implement
|
|
228
228
|
* a connection status badge.
|
|
229
229
|
*/
|
|
230
|
-
|
|
230
|
+
type Status = "initial" | "connecting" | "connected" | "reconnecting" | "disconnected";
|
|
231
231
|
/**
|
|
232
232
|
* Used to report about app-level reconnection issues.
|
|
233
233
|
*
|
|
@@ -237,7 +237,7 @@ declare type Status = "initial" | "connecting" | "connected" | "reconnecting" |
|
|
|
237
237
|
* to inform your users about, for example, by throwing a toast message on
|
|
238
238
|
* screen, or show a "trying to reconnect" banner.
|
|
239
239
|
*/
|
|
240
|
-
|
|
240
|
+
type LostConnectionEvent = "lost" | "restored" | "failed";
|
|
241
241
|
/**
|
|
242
242
|
* Arbitrary record that will be used as the authentication "authValue". It's the
|
|
243
243
|
* value that is returned by calling the authentication delegate, and will get
|
|
@@ -245,11 +245,11 @@ declare type LostConnectionEvent = "lost" | "restored" | "failed";
|
|
|
245
245
|
* the connection manager, but its value will not be interpreted, so it can be
|
|
246
246
|
* any value (except null).
|
|
247
247
|
*/
|
|
248
|
-
|
|
248
|
+
type BaseAuthResult = NonNullable<Json>;
|
|
249
249
|
declare class LiveblocksError extends Error {
|
|
250
250
|
code: number;
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
type Delegates<T extends BaseAuthResult> = {
|
|
253
253
|
authenticate: () => Promise<T>;
|
|
254
254
|
createSocket: (authValue: T) => IWebSocketInstance;
|
|
255
255
|
canZombie: () => boolean;
|
|
@@ -270,15 +270,15 @@ declare enum OpCode {
|
|
|
270
270
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
271
271
|
* only.
|
|
272
272
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
|
|
274
|
+
type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
275
|
+
type UpdateObjectOp = {
|
|
276
276
|
readonly opId?: string;
|
|
277
277
|
readonly id: string;
|
|
278
278
|
readonly type: OpCode.UPDATE_OBJECT;
|
|
279
279
|
readonly data: Partial<JsonObject>;
|
|
280
280
|
};
|
|
281
|
-
|
|
281
|
+
type CreateObjectOp = {
|
|
282
282
|
readonly opId?: string;
|
|
283
283
|
readonly id: string;
|
|
284
284
|
readonly intent?: "set";
|
|
@@ -288,7 +288,7 @@ declare type CreateObjectOp = {
|
|
|
288
288
|
readonly parentKey: string;
|
|
289
289
|
readonly data: JsonObject;
|
|
290
290
|
};
|
|
291
|
-
|
|
291
|
+
type CreateListOp = {
|
|
292
292
|
readonly opId?: string;
|
|
293
293
|
readonly id: string;
|
|
294
294
|
readonly intent?: "set";
|
|
@@ -297,7 +297,7 @@ declare type CreateListOp = {
|
|
|
297
297
|
readonly parentId: string;
|
|
298
298
|
readonly parentKey: string;
|
|
299
299
|
};
|
|
300
|
-
|
|
300
|
+
type CreateMapOp = {
|
|
301
301
|
readonly opId?: string;
|
|
302
302
|
readonly id: string;
|
|
303
303
|
readonly intent?: "set";
|
|
@@ -306,7 +306,7 @@ declare type CreateMapOp = {
|
|
|
306
306
|
readonly parentId: string;
|
|
307
307
|
readonly parentKey: string;
|
|
308
308
|
};
|
|
309
|
-
|
|
309
|
+
type CreateRegisterOp = {
|
|
310
310
|
readonly opId?: string;
|
|
311
311
|
readonly id: string;
|
|
312
312
|
readonly intent?: "set";
|
|
@@ -316,12 +316,12 @@ declare type CreateRegisterOp = {
|
|
|
316
316
|
readonly parentKey: string;
|
|
317
317
|
readonly data: Json;
|
|
318
318
|
};
|
|
319
|
-
|
|
319
|
+
type DeleteCrdtOp = {
|
|
320
320
|
readonly opId?: string;
|
|
321
321
|
readonly id: string;
|
|
322
322
|
readonly type: OpCode.DELETE_CRDT;
|
|
323
323
|
};
|
|
324
|
-
|
|
324
|
+
type AckOp = {
|
|
325
325
|
readonly type: OpCode.DELETE_CRDT;
|
|
326
326
|
readonly id: "ACK";
|
|
327
327
|
readonly opId: string;
|
|
@@ -345,13 +345,13 @@ declare type AckOp = {
|
|
|
345
345
|
* node does not exist, but as a side-effect the Op will get acknowledged.
|
|
346
346
|
*/
|
|
347
347
|
declare function ackOp(opId: string): AckOp;
|
|
348
|
-
|
|
348
|
+
type SetParentKeyOp = {
|
|
349
349
|
readonly opId?: string;
|
|
350
350
|
readonly id: string;
|
|
351
351
|
readonly type: OpCode.SET_PARENT_KEY;
|
|
352
352
|
readonly parentKey: string;
|
|
353
353
|
};
|
|
354
|
-
|
|
354
|
+
type DeleteObjectKeyOp = {
|
|
355
355
|
readonly opId?: string;
|
|
356
356
|
readonly id: string;
|
|
357
357
|
readonly type: OpCode.DELETE_OBJECT_KEY;
|
|
@@ -362,15 +362,15 @@ declare type DeleteObjectKeyOp = {
|
|
|
362
362
|
* Represents an indefinitely deep arbitrary immutable data
|
|
363
363
|
* structure, as returned by the .toImmutable().
|
|
364
364
|
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
type Immutable = Scalar | ImmutableList | ImmutableObject | ImmutableMap;
|
|
366
|
+
type Scalar = string | number | boolean | null;
|
|
367
|
+
type ImmutableList = readonly Immutable[];
|
|
368
|
+
type ImmutableObject = {
|
|
369
369
|
readonly [key: string]: Immutable | undefined;
|
|
370
370
|
};
|
|
371
|
-
|
|
371
|
+
type ImmutableMap = ReadonlyMap<string, Immutable>;
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
type UpdateDelta = {
|
|
374
374
|
type: "update";
|
|
375
375
|
} | {
|
|
376
376
|
type: "delete";
|
|
@@ -418,20 +418,20 @@ declare type UpdateDelta = {
|
|
|
418
418
|
*
|
|
419
419
|
*/
|
|
420
420
|
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
type PlainLsonFields = Record<string, PlainLson>;
|
|
422
|
+
type PlainLsonObject = {
|
|
423
423
|
liveblocksType: "LiveObject";
|
|
424
424
|
data: PlainLsonFields;
|
|
425
425
|
};
|
|
426
|
-
|
|
426
|
+
type PlainLsonMap = {
|
|
427
427
|
liveblocksType: "LiveMap";
|
|
428
428
|
data: PlainLsonFields;
|
|
429
429
|
};
|
|
430
|
-
|
|
430
|
+
type PlainLsonList = {
|
|
431
431
|
liveblocksType: "LiveList";
|
|
432
432
|
data: PlainLson[];
|
|
433
433
|
};
|
|
434
|
-
|
|
434
|
+
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* Helper type to convert any valid Lson type to the equivalent Json type.
|
|
@@ -449,7 +449,7 @@ declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
|
449
449
|
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
450
450
|
*
|
|
451
451
|
*/
|
|
452
|
-
|
|
452
|
+
type ToImmutable<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToImmutable<I>[] : L extends LiveObject<infer O> ? ToImmutable<O> : L extends LiveMap<infer K, infer V> ? ReadonlyMap<K, ToImmutable<V>> : L extends LsonObject ? {
|
|
453
453
|
readonly [K in keyof L]: ToImmutable<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
454
454
|
} : L extends Json ? L : never;
|
|
455
455
|
/**
|
|
@@ -461,7 +461,7 @@ declare function toPlainLson(lson: Lson): PlainLson;
|
|
|
461
461
|
* A LiveMap notification that is sent in-client to any subscribers whenever
|
|
462
462
|
* one or more of the values inside the LiveMap instance have changed.
|
|
463
463
|
*/
|
|
464
|
-
|
|
464
|
+
type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
|
|
465
465
|
type: "LiveMap";
|
|
466
466
|
node: LiveMap<TKey, TValue>;
|
|
467
467
|
updates: {
|
|
@@ -528,16 +528,16 @@ declare class LiveMap<TKey extends string, TValue extends Lson> extends Abstract
|
|
|
528
528
|
clone(): LiveMap<TKey, TValue>;
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
531
|
+
type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
532
|
+
type LiveMapUpdate = LiveMapUpdates<string, Lson>;
|
|
533
|
+
type LiveObjectUpdate = LiveObjectUpdates<LsonObject>;
|
|
534
|
+
type LiveListUpdate = LiveListUpdates<Lson>;
|
|
535
535
|
/**
|
|
536
536
|
* The payload of notifications sent (in-client) when LiveStructures change.
|
|
537
537
|
* Messages of this kind are not originating from the network, but are 100%
|
|
538
538
|
* in-client.
|
|
539
539
|
*/
|
|
540
|
-
|
|
540
|
+
type StorageUpdate = LiveMapUpdate | LiveObjectUpdate | LiveListUpdate;
|
|
541
541
|
|
|
542
542
|
declare abstract class AbstractCrdt {
|
|
543
543
|
#private;
|
|
@@ -553,7 +553,7 @@ declare abstract class AbstractCrdt {
|
|
|
553
553
|
abstract clone(): Lson;
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
|
|
556
|
+
type LiveListUpdateDelta = {
|
|
557
557
|
type: "insert";
|
|
558
558
|
index: number;
|
|
559
559
|
item: Lson;
|
|
@@ -575,7 +575,7 @@ declare type LiveListUpdateDelta = {
|
|
|
575
575
|
* A LiveList notification that is sent in-client to any subscribers whenever
|
|
576
576
|
* one or more of the items inside the LiveList instance have changed.
|
|
577
577
|
*/
|
|
578
|
-
|
|
578
|
+
type LiveListUpdates<TItem extends Lson> = {
|
|
579
579
|
type: "LiveList";
|
|
580
580
|
node: LiveList<TItem>;
|
|
581
581
|
updates: LiveListUpdateDelta[];
|
|
@@ -694,23 +694,23 @@ declare class LiveRegister<TValue extends Json> extends AbstractCrdt {
|
|
|
694
694
|
clone(): TValue;
|
|
695
695
|
}
|
|
696
696
|
|
|
697
|
-
|
|
697
|
+
type LiveStructure = LiveObject<LsonObject> | LiveList<Lson> | LiveMap<string, Lson>;
|
|
698
698
|
/**
|
|
699
699
|
* Think of Lson as a sibling of the Json data tree, except that the nested
|
|
700
700
|
* data structure can contain a mix of Json values and LiveStructure instances.
|
|
701
701
|
*/
|
|
702
|
-
|
|
702
|
+
type Lson = Json | LiveStructure;
|
|
703
703
|
/**
|
|
704
704
|
* LiveNode is the internal tree for managing Live data structures. The key
|
|
705
705
|
* difference with Lson is that all the Json values get represented in
|
|
706
706
|
* a LiveRegister node.
|
|
707
707
|
*/
|
|
708
|
-
|
|
708
|
+
type LiveNode = LiveStructure | LiveRegister<Json>;
|
|
709
709
|
/**
|
|
710
710
|
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
711
711
|
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
712
712
|
*/
|
|
713
|
-
|
|
713
|
+
type LsonObject = {
|
|
714
714
|
[key: string]: Lson | undefined;
|
|
715
715
|
};
|
|
716
716
|
/**
|
|
@@ -729,13 +729,13 @@ declare type LsonObject = {
|
|
|
729
729
|
* // { a: null, b: string[], c?: number }
|
|
730
730
|
*
|
|
731
731
|
*/
|
|
732
|
-
|
|
732
|
+
type ToJson<T extends Lson | LsonObject> = T extends Json ? T : T extends LsonObject ? {
|
|
733
733
|
[K in keyof T]: ToJson<Exclude<T[K], undefined>> | (undefined extends T[K] ? undefined : never);
|
|
734
734
|
} : T extends LiveList<infer I> ? ToJson<I>[] : T extends LiveObject<infer O> ? ToJson<O> : T extends LiveMap<infer KS, infer V> ? {
|
|
735
735
|
[K in KS]: ToJson<V>;
|
|
736
736
|
} : never;
|
|
737
737
|
|
|
738
|
-
|
|
738
|
+
type LiveObjectUpdateDelta<O extends {
|
|
739
739
|
[key: string]: unknown;
|
|
740
740
|
}> = {
|
|
741
741
|
[K in keyof O]?: UpdateDelta | undefined;
|
|
@@ -744,7 +744,7 @@ declare type LiveObjectUpdateDelta<O extends {
|
|
|
744
744
|
* A LiveObject notification that is sent in-client to any subscribers whenever
|
|
745
745
|
* one or more of the entries inside the LiveObject instance have changed.
|
|
746
746
|
*/
|
|
747
|
-
|
|
747
|
+
type LiveObjectUpdates<TData extends LsonObject> = {
|
|
748
748
|
type: "LiveObject";
|
|
749
749
|
node: LiveObject<TData>;
|
|
750
750
|
updates: LiveObjectUpdateDelta<TData>;
|
|
@@ -786,11 +786,11 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
786
786
|
clone(): LiveObject<O>;
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
|
|
789
|
+
type DateToString<T> = {
|
|
790
790
|
[P in keyof T]: T[P] extends Date ? string : T[P] extends Date | null ? string | null : T[P] extends Date | undefined ? string | undefined : T[P];
|
|
791
791
|
};
|
|
792
792
|
|
|
793
|
-
|
|
793
|
+
type InboxNotificationThreadData = {
|
|
794
794
|
kind: "thread";
|
|
795
795
|
id: string;
|
|
796
796
|
roomId: string;
|
|
@@ -798,7 +798,7 @@ declare type InboxNotificationThreadData = {
|
|
|
798
798
|
notifiedAt: Date;
|
|
799
799
|
readAt: Date | null;
|
|
800
800
|
};
|
|
801
|
-
|
|
801
|
+
type InboxNotificationTextMentionData = {
|
|
802
802
|
kind: "textMention";
|
|
803
803
|
id: string;
|
|
804
804
|
roomId: string;
|
|
@@ -807,14 +807,14 @@ declare type InboxNotificationTextMentionData = {
|
|
|
807
807
|
createdBy: string;
|
|
808
808
|
mentionId: string;
|
|
809
809
|
};
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
810
|
+
type InboxNotificationTextMentionDataPlain = DateToString<InboxNotificationTextMentionData>;
|
|
811
|
+
type ActivityData = Record<string, string | boolean | number | undefined>;
|
|
812
|
+
type InboxNotificationActivity<K extends keyof DAD = keyof DAD> = {
|
|
813
813
|
id: string;
|
|
814
814
|
createdAt: Date;
|
|
815
815
|
data: DAD[K];
|
|
816
816
|
};
|
|
817
|
-
|
|
817
|
+
type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
|
|
818
818
|
kind: K;
|
|
819
819
|
id: string;
|
|
820
820
|
roomId?: string;
|
|
@@ -823,24 +823,24 @@ declare type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
|
|
|
823
823
|
readAt: Date | null;
|
|
824
824
|
activities: InboxNotificationActivity<K>[];
|
|
825
825
|
};
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
826
|
+
type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData;
|
|
827
|
+
type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
|
|
828
|
+
type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
|
|
829
829
|
activities: DateToString<InboxNotificationActivity>[];
|
|
830
830
|
};
|
|
831
|
-
|
|
832
|
-
|
|
831
|
+
type InboxNotificationDataPlain = InboxNotificationThreadDataPlain | InboxNotificationCustomDataPlain | InboxNotificationTextMentionDataPlain;
|
|
832
|
+
type InboxNotificationDeleteInfo = {
|
|
833
833
|
type: "deletedInboxNotification";
|
|
834
834
|
id: string;
|
|
835
835
|
roomId: string;
|
|
836
836
|
deletedAt: Date;
|
|
837
837
|
};
|
|
838
838
|
|
|
839
|
-
|
|
839
|
+
type BaseActivitiesData = {
|
|
840
840
|
[key: `$${string}`]: ActivityData;
|
|
841
841
|
};
|
|
842
842
|
|
|
843
|
-
|
|
843
|
+
type BaseRoomInfo = {
|
|
844
844
|
[key: string]: Json | undefined;
|
|
845
845
|
/**
|
|
846
846
|
* The name of the room.
|
|
@@ -852,22 +852,22 @@ declare type BaseRoomInfo = {
|
|
|
852
852
|
url?: string;
|
|
853
853
|
};
|
|
854
854
|
|
|
855
|
-
|
|
856
|
-
|
|
855
|
+
type BaseMetadata = Record<string, string | boolean | number | undefined>;
|
|
856
|
+
type CommentReaction = {
|
|
857
857
|
emoji: string;
|
|
858
858
|
createdAt: Date;
|
|
859
859
|
users: {
|
|
860
860
|
id: string;
|
|
861
861
|
}[];
|
|
862
862
|
};
|
|
863
|
-
|
|
863
|
+
type CommentAttachment = {
|
|
864
864
|
type: "attachment";
|
|
865
865
|
id: string;
|
|
866
866
|
name: string;
|
|
867
867
|
size: number;
|
|
868
868
|
mimeType: string;
|
|
869
869
|
};
|
|
870
|
-
|
|
870
|
+
type CommentLocalAttachmentIdle = {
|
|
871
871
|
type: "localAttachment";
|
|
872
872
|
status: "idle";
|
|
873
873
|
id: string;
|
|
@@ -876,7 +876,7 @@ declare type CommentLocalAttachmentIdle = {
|
|
|
876
876
|
mimeType: string;
|
|
877
877
|
file: File;
|
|
878
878
|
};
|
|
879
|
-
|
|
879
|
+
type CommentLocalAttachmentUploading = {
|
|
880
880
|
type: "localAttachment";
|
|
881
881
|
status: "uploading";
|
|
882
882
|
id: string;
|
|
@@ -885,7 +885,7 @@ declare type CommentLocalAttachmentUploading = {
|
|
|
885
885
|
mimeType: string;
|
|
886
886
|
file: File;
|
|
887
887
|
};
|
|
888
|
-
|
|
888
|
+
type CommentLocalAttachmentUploaded = {
|
|
889
889
|
type: "localAttachment";
|
|
890
890
|
status: "uploaded";
|
|
891
891
|
id: string;
|
|
@@ -894,7 +894,7 @@ declare type CommentLocalAttachmentUploaded = {
|
|
|
894
894
|
mimeType: string;
|
|
895
895
|
file: File;
|
|
896
896
|
};
|
|
897
|
-
|
|
897
|
+
type CommentLocalAttachmentError = {
|
|
898
898
|
type: "localAttachment";
|
|
899
899
|
status: "error";
|
|
900
900
|
id: string;
|
|
@@ -904,12 +904,12 @@ declare type CommentLocalAttachmentError = {
|
|
|
904
904
|
file: File;
|
|
905
905
|
error: Error;
|
|
906
906
|
};
|
|
907
|
-
|
|
908
|
-
|
|
907
|
+
type CommentLocalAttachment = CommentLocalAttachmentIdle | CommentLocalAttachmentUploading | CommentLocalAttachmentUploaded | CommentLocalAttachmentError;
|
|
908
|
+
type CommentMixedAttachment = CommentAttachment | CommentLocalAttachment;
|
|
909
909
|
/**
|
|
910
910
|
* Represents a comment.
|
|
911
911
|
*/
|
|
912
|
-
|
|
912
|
+
type CommentData = {
|
|
913
913
|
type: "comment";
|
|
914
914
|
id: string;
|
|
915
915
|
threadId: string;
|
|
@@ -926,7 +926,7 @@ declare type CommentData = {
|
|
|
926
926
|
body?: never;
|
|
927
927
|
deletedAt: Date;
|
|
928
928
|
});
|
|
929
|
-
|
|
929
|
+
type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "body"> & {
|
|
930
930
|
reactions: DateToString<CommentReaction>[];
|
|
931
931
|
} & ({
|
|
932
932
|
body: CommentBody;
|
|
@@ -935,43 +935,43 @@ declare type CommentDataPlain = Omit<DateToString<CommentData>, "reactions" | "b
|
|
|
935
935
|
body?: never;
|
|
936
936
|
deletedAt: string;
|
|
937
937
|
});
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
938
|
+
type CommentBodyBlockElement = CommentBodyParagraph;
|
|
939
|
+
type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
|
|
940
|
+
type CommentBodyElement = CommentBodyBlockElement | CommentBodyInlineElement;
|
|
941
|
+
type CommentBodyParagraph = {
|
|
942
942
|
type: "paragraph";
|
|
943
943
|
children: CommentBodyInlineElement[];
|
|
944
944
|
};
|
|
945
|
-
|
|
945
|
+
type CommentBodyMention = {
|
|
946
946
|
type: "mention";
|
|
947
947
|
id: string;
|
|
948
948
|
};
|
|
949
|
-
|
|
949
|
+
type CommentBodyLink = {
|
|
950
950
|
type: "link";
|
|
951
951
|
url: string;
|
|
952
952
|
text?: string;
|
|
953
953
|
};
|
|
954
|
-
|
|
954
|
+
type CommentBodyText = {
|
|
955
955
|
bold?: boolean;
|
|
956
956
|
italic?: boolean;
|
|
957
957
|
strikethrough?: boolean;
|
|
958
958
|
code?: boolean;
|
|
959
959
|
text: string;
|
|
960
960
|
};
|
|
961
|
-
|
|
961
|
+
type CommentBody = {
|
|
962
962
|
version: 1;
|
|
963
963
|
content: CommentBodyBlockElement[];
|
|
964
964
|
};
|
|
965
|
-
|
|
965
|
+
type CommentUserReaction = {
|
|
966
966
|
emoji: string;
|
|
967
967
|
createdAt: Date;
|
|
968
968
|
userId: string;
|
|
969
969
|
};
|
|
970
|
-
|
|
970
|
+
type CommentUserReactionPlain = DateToString<CommentUserReaction>;
|
|
971
971
|
/**
|
|
972
972
|
* Represents a thread of comments.
|
|
973
973
|
*/
|
|
974
|
-
|
|
974
|
+
type ThreadData<M extends BaseMetadata = DM> = {
|
|
975
975
|
type: "thread";
|
|
976
976
|
id: string;
|
|
977
977
|
roomId: string;
|
|
@@ -984,17 +984,17 @@ declare type ThreadData<M extends BaseMetadata = DM> = {
|
|
|
984
984
|
interface ThreadDataWithDeleteInfo<M extends BaseMetadata = DM> extends ThreadData<M> {
|
|
985
985
|
deletedAt?: Date;
|
|
986
986
|
}
|
|
987
|
-
|
|
987
|
+
type ThreadDataPlain<M extends BaseMetadata> = Omit<DateToString<ThreadData<M>>, "comments" | "metadata"> & {
|
|
988
988
|
comments: CommentDataPlain[];
|
|
989
989
|
metadata: M;
|
|
990
990
|
};
|
|
991
|
-
|
|
991
|
+
type ThreadDeleteInfo = {
|
|
992
992
|
type: "deletedThread";
|
|
993
993
|
id: string;
|
|
994
994
|
roomId: string;
|
|
995
995
|
deletedAt: Date;
|
|
996
996
|
};
|
|
997
|
-
|
|
997
|
+
type StringOperators<T> = T | {
|
|
998
998
|
startsWith: string;
|
|
999
999
|
};
|
|
1000
1000
|
/**
|
|
@@ -1005,7 +1005,7 @@ declare type StringOperators<T> = T | {
|
|
|
1005
1005
|
* - to strings:
|
|
1006
1006
|
* - `startsWith` (`^` in query string)
|
|
1007
1007
|
*/
|
|
1008
|
-
|
|
1008
|
+
type QueryMetadata<M extends BaseMetadata> = {
|
|
1009
1009
|
[K in keyof M]: string extends M[K] ? StringOperators<M[K]> : M[K];
|
|
1010
1010
|
};
|
|
1011
1011
|
|
|
@@ -1017,20 +1017,20 @@ declare global {
|
|
|
1017
1017
|
[key: string]: unknown;
|
|
1018
1018
|
}
|
|
1019
1019
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1020
|
+
type ExtendableTypes = "Presence" | "Storage" | "UserMeta" | "RoomEvent" | "ThreadMetadata" | "RoomInfo" | "ActivitiesData";
|
|
1021
|
+
type MakeErrorString<K extends ExtendableTypes, Reason extends string = "does not match its requirements"> = `The type you provided for '${K}' ${Reason}. To learn how to fix this, see https://liveblocks.io/docs/errors/${K}`;
|
|
1022
|
+
type GetOverride<K extends ExtendableTypes, B, Reason extends string = "does not match its requirements"> = GetOverrideOrErrorValue<K, B, MakeErrorString<K, Reason>>;
|
|
1023
|
+
type GetOverrideOrErrorValue<K extends ExtendableTypes, B, ErrorType> = unknown extends Liveblocks[K] ? B : Liveblocks[K] extends B ? Liveblocks[K] : ErrorType;
|
|
1024
|
+
type DP = GetOverride<"Presence", JsonObject, "is not a valid JSON object">;
|
|
1025
|
+
type DS = GetOverride<"Storage", LsonObject, "is not a valid LSON value">;
|
|
1026
|
+
type DU = GetOverrideOrErrorValue<"UserMeta", BaseUserMeta, Record<"id" | "info", MakeErrorString<"UserMeta">>>;
|
|
1027
|
+
type DE = GetOverride<"RoomEvent", Json, "is not a valid JSON value">;
|
|
1028
|
+
type DM = GetOverride<"ThreadMetadata", BaseMetadata>;
|
|
1029
|
+
type DRI = GetOverride<"RoomInfo", BaseRoomInfo>;
|
|
1030
|
+
type DAD = GetOverrideOrErrorValue<"ActivitiesData", BaseActivitiesData, {
|
|
1031
1031
|
[K in keyof Liveblocks["ActivitiesData"]]: "At least one of the custom notification kinds you provided for 'ActivitiesData' does not match its requirements. To learn how to fix this, see https://liveblocks.io/docs/errors/ActivitiesData";
|
|
1032
1032
|
}>;
|
|
1033
|
-
|
|
1033
|
+
type KDAD = keyof DAD extends `$${string}` ? keyof DAD : "Custom notification kinds must start with '$' but your custom 'ActivitiesData' type contains at least one kind which doesn't. To learn how to fix this, see https://liveblocks.io/docs/errors/ActivitiesData";
|
|
1034
1034
|
|
|
1035
1035
|
/**
|
|
1036
1036
|
* Use this symbol to brand an object property as internal.
|
|
@@ -1051,27 +1051,27 @@ declare type KDAD = keyof DAD extends `$${string}` ? keyof DAD : "Custom notific
|
|
|
1051
1051
|
*/
|
|
1052
1052
|
declare const kInternal: unique symbol;
|
|
1053
1053
|
|
|
1054
|
-
|
|
1054
|
+
type RenameDataField<T, TFieldName extends string> = T extends any ? {
|
|
1055
1055
|
[K in keyof T as K extends "data" ? TFieldName : K]: T[K];
|
|
1056
1056
|
} : never;
|
|
1057
|
-
|
|
1057
|
+
type AsyncLoading<F extends string = "data"> = RenameDataField<{
|
|
1058
1058
|
readonly isLoading: true;
|
|
1059
1059
|
readonly data?: never;
|
|
1060
1060
|
readonly error?: never;
|
|
1061
1061
|
}, F>;
|
|
1062
|
-
|
|
1062
|
+
type AsyncSuccess<T, F extends string = "data"> = RenameDataField<{
|
|
1063
1063
|
readonly isLoading: false;
|
|
1064
1064
|
readonly data: T;
|
|
1065
1065
|
readonly error?: never;
|
|
1066
1066
|
}, F>;
|
|
1067
|
-
|
|
1067
|
+
type AsyncError<F extends string = "data"> = RenameDataField<{
|
|
1068
1068
|
readonly isLoading: false;
|
|
1069
1069
|
readonly data?: never;
|
|
1070
1070
|
readonly error: Error;
|
|
1071
1071
|
}, F>;
|
|
1072
|
-
|
|
1072
|
+
type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
|
|
1073
1073
|
|
|
1074
|
-
|
|
1074
|
+
type BatchStore<O, I> = {
|
|
1075
1075
|
subscribe: (callback: Callback<void>) => UnsubscribeCallback;
|
|
1076
1076
|
enqueue: (input: I) => Promise<void>;
|
|
1077
1077
|
getItemState: (input: I) => AsyncResult<O> | undefined;
|
|
@@ -1089,12 +1089,12 @@ declare enum ClientMsgCode {
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Messages that can be sent from the client to the server.
|
|
1091
1091
|
*/
|
|
1092
|
-
|
|
1093
|
-
|
|
1092
|
+
type ClientMsg<P extends JsonObject, E extends Json> = BroadcastEventClientMsg<E> | UpdatePresenceClientMsg<P> | UpdateStorageClientMsg | FetchStorageClientMsg | FetchYDocClientMsg | UpdateYDocClientMsg;
|
|
1093
|
+
type BroadcastEventClientMsg<E extends Json> = {
|
|
1094
1094
|
type: ClientMsgCode.BROADCAST_EVENT;
|
|
1095
1095
|
event: E;
|
|
1096
1096
|
};
|
|
1097
|
-
|
|
1097
|
+
type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
1098
1098
|
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
1099
1099
|
/**
|
|
1100
1100
|
* Set this to any number to signify that this is a Full Presence™
|
|
@@ -1120,56 +1120,56 @@ declare type UpdatePresenceClientMsg<P extends JsonObject> = {
|
|
|
1120
1120
|
readonly targetActor?: undefined;
|
|
1121
1121
|
readonly data: Partial<P>;
|
|
1122
1122
|
};
|
|
1123
|
-
|
|
1123
|
+
type UpdateStorageClientMsg = {
|
|
1124
1124
|
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
1125
1125
|
readonly ops: Op[];
|
|
1126
1126
|
};
|
|
1127
|
-
|
|
1127
|
+
type FetchStorageClientMsg = {
|
|
1128
1128
|
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
1129
1129
|
};
|
|
1130
|
-
|
|
1130
|
+
type FetchYDocClientMsg = {
|
|
1131
1131
|
readonly type: ClientMsgCode.FETCH_YDOC;
|
|
1132
1132
|
readonly vector: string;
|
|
1133
1133
|
readonly guid?: string;
|
|
1134
1134
|
};
|
|
1135
|
-
|
|
1135
|
+
type UpdateYDocClientMsg = {
|
|
1136
1136
|
readonly type: ClientMsgCode.UPDATE_YDOC;
|
|
1137
1137
|
readonly update: string;
|
|
1138
1138
|
readonly guid?: string;
|
|
1139
1139
|
};
|
|
1140
1140
|
|
|
1141
|
-
|
|
1141
|
+
type IdTuple<T> = [id: string, value: T];
|
|
1142
1142
|
declare enum CrdtType {
|
|
1143
1143
|
OBJECT = 0,
|
|
1144
1144
|
LIST = 1,
|
|
1145
1145
|
MAP = 2,
|
|
1146
1146
|
REGISTER = 3
|
|
1147
1147
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1148
|
+
type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
1149
|
+
type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
1150
|
+
type SerializedRootObject = {
|
|
1151
1151
|
readonly type: CrdtType.OBJECT;
|
|
1152
1152
|
readonly data: JsonObject;
|
|
1153
1153
|
readonly parentId?: never;
|
|
1154
1154
|
readonly parentKey?: never;
|
|
1155
1155
|
};
|
|
1156
|
-
|
|
1156
|
+
type SerializedObject = {
|
|
1157
1157
|
readonly type: CrdtType.OBJECT;
|
|
1158
1158
|
readonly parentId: string;
|
|
1159
1159
|
readonly parentKey: string;
|
|
1160
1160
|
readonly data: JsonObject;
|
|
1161
1161
|
};
|
|
1162
|
-
|
|
1162
|
+
type SerializedList = {
|
|
1163
1163
|
readonly type: CrdtType.LIST;
|
|
1164
1164
|
readonly parentId: string;
|
|
1165
1165
|
readonly parentKey: string;
|
|
1166
1166
|
};
|
|
1167
|
-
|
|
1167
|
+
type SerializedMap = {
|
|
1168
1168
|
readonly type: CrdtType.MAP;
|
|
1169
1169
|
readonly parentId: string;
|
|
1170
1170
|
readonly parentKey: string;
|
|
1171
1171
|
};
|
|
1172
|
-
|
|
1172
|
+
type SerializedRegister = {
|
|
1173
1173
|
readonly type: CrdtType.REGISTER;
|
|
1174
1174
|
readonly parentId: string;
|
|
1175
1175
|
readonly parentKey: string;
|
|
@@ -1201,46 +1201,46 @@ declare enum ServerMsgCode {
|
|
|
1201
1201
|
/**
|
|
1202
1202
|
* Messages that can be sent from the server to the client.
|
|
1203
1203
|
*/
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1204
|
+
type ServerMsg<P extends JsonObject, U extends BaseUserMeta, E extends Json> = UpdatePresenceServerMsg<P> | UserJoinServerMsg<U> | UserLeftServerMsg | BroadcastedEventServerMsg<E> | RoomStateServerMsg<U> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg | YDocUpdateServerMsg | CommentsEventServerMsg;
|
|
1205
|
+
type CommentsEventServerMsg = ThreadCreatedEvent | ThreadDeletedEvent | ThreadMetadataUpdatedEvent | ThreadUpdatedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved;
|
|
1206
|
+
type ThreadCreatedEvent = {
|
|
1207
1207
|
type: ServerMsgCode.THREAD_CREATED;
|
|
1208
1208
|
threadId: string;
|
|
1209
1209
|
};
|
|
1210
|
-
|
|
1210
|
+
type ThreadDeletedEvent = {
|
|
1211
1211
|
type: ServerMsgCode.THREAD_DELETED;
|
|
1212
1212
|
threadId: string;
|
|
1213
1213
|
};
|
|
1214
|
-
|
|
1214
|
+
type ThreadMetadataUpdatedEvent = {
|
|
1215
1215
|
type: ServerMsgCode.THREAD_METADATA_UPDATED;
|
|
1216
1216
|
threadId: string;
|
|
1217
1217
|
};
|
|
1218
|
-
|
|
1218
|
+
type ThreadUpdatedEvent = {
|
|
1219
1219
|
type: ServerMsgCode.THREAD_UPDATED;
|
|
1220
1220
|
threadId: string;
|
|
1221
1221
|
};
|
|
1222
|
-
|
|
1222
|
+
type CommentCreatedEvent = {
|
|
1223
1223
|
type: ServerMsgCode.COMMENT_CREATED;
|
|
1224
1224
|
threadId: string;
|
|
1225
1225
|
commentId: string;
|
|
1226
1226
|
};
|
|
1227
|
-
|
|
1227
|
+
type CommentEditedEvent = {
|
|
1228
1228
|
type: ServerMsgCode.COMMENT_EDITED;
|
|
1229
1229
|
threadId: string;
|
|
1230
1230
|
commentId: string;
|
|
1231
1231
|
};
|
|
1232
|
-
|
|
1232
|
+
type CommentDeletedEvent = {
|
|
1233
1233
|
type: ServerMsgCode.COMMENT_DELETED;
|
|
1234
1234
|
threadId: string;
|
|
1235
1235
|
commentId: string;
|
|
1236
1236
|
};
|
|
1237
|
-
|
|
1237
|
+
type CommentReactionAdded = {
|
|
1238
1238
|
type: ServerMsgCode.COMMENT_REACTION_ADDED;
|
|
1239
1239
|
threadId: string;
|
|
1240
1240
|
commentId: string;
|
|
1241
1241
|
emoji: string;
|
|
1242
1242
|
};
|
|
1243
|
-
|
|
1243
|
+
type CommentReactionRemoved = {
|
|
1244
1244
|
type: ServerMsgCode.COMMENT_REACTION_REMOVED;
|
|
1245
1245
|
threadId: string;
|
|
1246
1246
|
commentId: string;
|
|
@@ -1257,7 +1257,7 @@ declare type CommentReactionRemoved = {
|
|
|
1257
1257
|
* those cases, the `targetActor` field indicates the newly connected client,
|
|
1258
1258
|
* so all other existing clients can ignore this broadcasted message.
|
|
1259
1259
|
*/
|
|
1260
|
-
|
|
1260
|
+
type UpdatePresenceServerMsg<P extends JsonObject> = {
|
|
1261
1261
|
readonly type: ServerMsgCode.UPDATE_PRESENCE;
|
|
1262
1262
|
/**
|
|
1263
1263
|
* The User whose Presence has changed.
|
|
@@ -1302,7 +1302,7 @@ declare type UpdatePresenceServerMsg<P extends JsonObject> = {
|
|
|
1302
1302
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1303
1303
|
* a new User has joined the Room.
|
|
1304
1304
|
*/
|
|
1305
|
-
|
|
1305
|
+
type UserJoinServerMsg<U extends BaseUserMeta> = {
|
|
1306
1306
|
readonly type: ServerMsgCode.USER_JOINED;
|
|
1307
1307
|
readonly actor: number;
|
|
1308
1308
|
/**
|
|
@@ -1324,7 +1324,7 @@ declare type UserJoinServerMsg<U extends BaseUserMeta> = {
|
|
|
1324
1324
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1325
1325
|
* a new User has left the Room.
|
|
1326
1326
|
*/
|
|
1327
|
-
|
|
1327
|
+
type UserLeftServerMsg = {
|
|
1328
1328
|
readonly type: ServerMsgCode.USER_LEFT;
|
|
1329
1329
|
readonly actor: number;
|
|
1330
1330
|
};
|
|
@@ -1332,7 +1332,7 @@ declare type UserLeftServerMsg = {
|
|
|
1332
1332
|
* Sent by the WebSocket server when the ydoc is updated or when requested based on stateVector passed.
|
|
1333
1333
|
* Contains a base64 encoded update
|
|
1334
1334
|
*/
|
|
1335
|
-
|
|
1335
|
+
type YDocUpdateServerMsg = {
|
|
1336
1336
|
readonly type: ServerMsgCode.UPDATE_YDOC;
|
|
1337
1337
|
readonly update: string;
|
|
1338
1338
|
readonly isSync: boolean;
|
|
@@ -1343,7 +1343,7 @@ declare type YDocUpdateServerMsg = {
|
|
|
1343
1343
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1344
1344
|
* a User broadcasted an Event to everyone in the Room.
|
|
1345
1345
|
*/
|
|
1346
|
-
|
|
1346
|
+
type BroadcastedEventServerMsg<E extends Json> = {
|
|
1347
1347
|
readonly type: ServerMsgCode.BROADCASTED_EVENT;
|
|
1348
1348
|
/**
|
|
1349
1349
|
* The User who broadcast the Event. Absent when this event is broadcast from
|
|
@@ -1361,7 +1361,7 @@ declare type BroadcastedEventServerMsg<E extends Json> = {
|
|
|
1361
1361
|
* joining the Room, to provide the initial state of the Room. The payload
|
|
1362
1362
|
* includes a list of all other Users that already are in the Room.
|
|
1363
1363
|
*/
|
|
1364
|
-
|
|
1364
|
+
type RoomStateServerMsg<U extends BaseUserMeta> = {
|
|
1365
1365
|
readonly type: ServerMsgCode.ROOM_STATE;
|
|
1366
1366
|
/**
|
|
1367
1367
|
* Informs the client what their actor ID is going to be.
|
|
@@ -1389,7 +1389,7 @@ declare type RoomStateServerMsg<U extends BaseUserMeta> = {
|
|
|
1389
1389
|
* joining the Room, to provide the initial Storage state of the Room. The
|
|
1390
1390
|
* payload includes the entire Storage document.
|
|
1391
1391
|
*/
|
|
1392
|
-
|
|
1392
|
+
type InitialDocumentStateServerMsg = {
|
|
1393
1393
|
readonly type: ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
1394
1394
|
readonly items: IdTuple<SerializedCrdt>[];
|
|
1395
1395
|
};
|
|
@@ -1400,7 +1400,7 @@ declare type InitialDocumentStateServerMsg = {
|
|
|
1400
1400
|
* The payload of this message contains a list of Ops (aka incremental
|
|
1401
1401
|
* mutations to make to the initially loaded document).
|
|
1402
1402
|
*/
|
|
1403
|
-
|
|
1403
|
+
type UpdateStorageServerMsg = {
|
|
1404
1404
|
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
1405
1405
|
readonly ops: Op[];
|
|
1406
1406
|
};
|
|
@@ -1409,13 +1409,13 @@ declare type UpdateStorageServerMsg = {
|
|
|
1409
1409
|
* have been received but were rejected because they caused mutations that are
|
|
1410
1410
|
* incompatible with the Room's schema.
|
|
1411
1411
|
*/
|
|
1412
|
-
|
|
1412
|
+
type RejectedStorageOpServerMsg = {
|
|
1413
1413
|
readonly type: ServerMsgCode.REJECT_STORAGE_OP;
|
|
1414
1414
|
readonly opIds: string[];
|
|
1415
1415
|
readonly reason: string;
|
|
1416
1416
|
};
|
|
1417
1417
|
|
|
1418
|
-
|
|
1418
|
+
type HistoryVersion = {
|
|
1419
1419
|
type: "historyVersion";
|
|
1420
1420
|
kind: "yjs";
|
|
1421
1421
|
createdAt: Date;
|
|
@@ -1425,20 +1425,20 @@ declare type HistoryVersion = {
|
|
|
1425
1425
|
}[];
|
|
1426
1426
|
};
|
|
1427
1427
|
|
|
1428
|
-
|
|
1428
|
+
type JsonTreeNode = {
|
|
1429
1429
|
readonly type: "Json";
|
|
1430
1430
|
readonly id: string;
|
|
1431
1431
|
readonly key: string;
|
|
1432
1432
|
readonly payload: Json;
|
|
1433
1433
|
};
|
|
1434
|
-
|
|
1434
|
+
type LiveTreeNode<TName extends `Live${string}` = `Live${string}`> = {
|
|
1435
1435
|
readonly type: TName;
|
|
1436
1436
|
readonly id: string;
|
|
1437
1437
|
readonly key: string;
|
|
1438
1438
|
readonly payload: LsonTreeNode[];
|
|
1439
1439
|
};
|
|
1440
|
-
|
|
1441
|
-
|
|
1440
|
+
type LsonTreeNode = LiveTreeNode | JsonTreeNode;
|
|
1441
|
+
type UserTreeNode = {
|
|
1442
1442
|
readonly type: "User";
|
|
1443
1443
|
readonly id: string;
|
|
1444
1444
|
readonly key: string;
|
|
@@ -1450,14 +1450,14 @@ declare type UserTreeNode = {
|
|
|
1450
1450
|
readonly isReadOnly: boolean;
|
|
1451
1451
|
};
|
|
1452
1452
|
};
|
|
1453
|
-
|
|
1453
|
+
type CustomEventTreeNode = {
|
|
1454
1454
|
readonly type: "CustomEvent";
|
|
1455
1455
|
readonly id: string;
|
|
1456
1456
|
readonly key: string;
|
|
1457
1457
|
readonly connectionId: number;
|
|
1458
1458
|
readonly payload: Json;
|
|
1459
1459
|
};
|
|
1460
|
-
|
|
1460
|
+
type TreeNode = LsonTreeNode | UserTreeNode | CustomEventTreeNode;
|
|
1461
1461
|
|
|
1462
1462
|
type DevToolsTreeNode_CustomEventTreeNode = CustomEventTreeNode;
|
|
1463
1463
|
type DevToolsTreeNode_JsonTreeNode = JsonTreeNode;
|
|
@@ -1491,14 +1491,14 @@ declare namespace DevToolsTreeNode {
|
|
|
1491
1491
|
* This trick comes from:
|
|
1492
1492
|
* https://effectivetypescript.com/2022/02/25/gentips-4-display/
|
|
1493
1493
|
*/
|
|
1494
|
-
|
|
1494
|
+
type Resolve<T> = T extends (...args: unknown[]) => unknown ? T : {
|
|
1495
1495
|
[K in keyof T]: T[K];
|
|
1496
1496
|
};
|
|
1497
1497
|
|
|
1498
1498
|
/**
|
|
1499
1499
|
* Represents a user connected in a room. Treated as immutable.
|
|
1500
1500
|
*/
|
|
1501
|
-
|
|
1501
|
+
type User<P extends JsonObject = DP, U extends BaseUserMeta = DU> = {
|
|
1502
1502
|
/**
|
|
1503
1503
|
* The connection ID of the User. It is unique and increment at every new connection.
|
|
1504
1504
|
*/
|
|
@@ -1527,7 +1527,7 @@ declare type User<P extends JsonObject = DP, U extends BaseUserMeta = DU> = {
|
|
|
1527
1527
|
readonly canComment: boolean;
|
|
1528
1528
|
};
|
|
1529
1529
|
|
|
1530
|
-
|
|
1530
|
+
type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
|
|
1531
1531
|
type: "leave";
|
|
1532
1532
|
user: User<P, U>;
|
|
1533
1533
|
} | {
|
|
@@ -1541,7 +1541,7 @@ declare type InternalOthersEvent<P extends JsonObject, U extends BaseUserMeta> =
|
|
|
1541
1541
|
type: "reset";
|
|
1542
1542
|
user?: never;
|
|
1543
1543
|
};
|
|
1544
|
-
|
|
1544
|
+
type OthersEvent<P extends JsonObject = DP, U extends BaseUserMeta = DU> = Resolve<InternalOthersEvent<P, U> & {
|
|
1545
1545
|
others: readonly User<P, U>[];
|
|
1546
1546
|
}>;
|
|
1547
1547
|
declare enum TextEditorType {
|
|
@@ -1549,20 +1549,20 @@ declare enum TextEditorType {
|
|
|
1549
1549
|
TipTap = "tiptap"
|
|
1550
1550
|
}
|
|
1551
1551
|
|
|
1552
|
-
|
|
1552
|
+
type OptionalKeys<T> = {
|
|
1553
1553
|
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
1554
1554
|
}[keyof T];
|
|
1555
|
-
|
|
1555
|
+
type MakeOptionalFieldsNullable<T> = {
|
|
1556
1556
|
[K in keyof T]: K extends OptionalKeys<T> ? T[K] | null : T[K];
|
|
1557
1557
|
};
|
|
1558
|
-
|
|
1558
|
+
type Patchable<T> = Partial<MakeOptionalFieldsNullable<T>>;
|
|
1559
1559
|
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
type RoomThreadsNotificationSettings = "all" | "replies_and_mentions" | "none";
|
|
1561
|
+
type RoomNotificationSettings = {
|
|
1562
1562
|
threads: RoomThreadsNotificationSettings;
|
|
1563
1563
|
};
|
|
1564
1564
|
|
|
1565
|
-
|
|
1565
|
+
type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
|
|
1566
1566
|
type: "leave";
|
|
1567
1567
|
user: User<P, U>;
|
|
1568
1568
|
} | {
|
|
@@ -1575,8 +1575,8 @@ declare type LegacyOthersEvent<P extends JsonObject, U extends BaseUserMeta> = {
|
|
|
1575
1575
|
} | {
|
|
1576
1576
|
type: "reset";
|
|
1577
1577
|
};
|
|
1578
|
-
|
|
1579
|
-
|
|
1578
|
+
type LegacyOthersEventCallback<P extends JsonObject, U extends BaseUserMeta> = (others: readonly User<P, U>[], event: LegacyOthersEvent<P, U>) => void;
|
|
1579
|
+
type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E extends Json> = {
|
|
1580
1580
|
/**
|
|
1581
1581
|
* The connection ID of the client that sent the event.
|
|
1582
1582
|
* If this message was broadcast from the server (via the REST API), then
|
|
@@ -1591,7 +1591,7 @@ declare type RoomEventMessage<P extends JsonObject, U extends BaseUserMeta, E ex
|
|
|
1591
1591
|
user: User<P, U> | null;
|
|
1592
1592
|
event: E;
|
|
1593
1593
|
};
|
|
1594
|
-
|
|
1594
|
+
type StorageStatus = "not-loaded" | "loading" | "synchronizing" | "synchronized";
|
|
1595
1595
|
interface History {
|
|
1596
1596
|
/**
|
|
1597
1597
|
* Undoes the last operation executed by the current client.
|
|
@@ -1669,11 +1669,11 @@ interface History {
|
|
|
1669
1669
|
*/
|
|
1670
1670
|
resume: () => void;
|
|
1671
1671
|
}
|
|
1672
|
-
|
|
1672
|
+
type HistoryEvent = {
|
|
1673
1673
|
canUndo: boolean;
|
|
1674
1674
|
canRedo: boolean;
|
|
1675
1675
|
};
|
|
1676
|
-
|
|
1676
|
+
type BroadcastOptions = {
|
|
1677
1677
|
/**
|
|
1678
1678
|
* Whether or not event is queued if the connection is currently closed.
|
|
1679
1679
|
*
|
|
@@ -1681,7 +1681,7 @@ declare type BroadcastOptions = {
|
|
|
1681
1681
|
*/
|
|
1682
1682
|
shouldQueueEventIfNotReady: boolean;
|
|
1683
1683
|
};
|
|
1684
|
-
|
|
1684
|
+
type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U extends BaseUserMeta, E extends Json> = {
|
|
1685
1685
|
/**
|
|
1686
1686
|
* Subscribe to the current user presence updates.
|
|
1687
1687
|
*
|
|
@@ -1814,25 +1814,25 @@ declare type SubscribeFn<P extends JsonObject, _TStorage extends LsonObject, U e
|
|
|
1814
1814
|
(type: "storage-status", listener: Callback<StorageStatus>): () => void;
|
|
1815
1815
|
(type: "comments", listener: Callback<CommentsEventServerMsg>): () => void;
|
|
1816
1816
|
};
|
|
1817
|
-
|
|
1817
|
+
type GetThreadsOptions<M extends BaseMetadata> = {
|
|
1818
1818
|
cursor?: string;
|
|
1819
1819
|
query?: {
|
|
1820
1820
|
resolved?: boolean;
|
|
1821
1821
|
metadata?: Partial<QueryMetadata<M>>;
|
|
1822
1822
|
};
|
|
1823
1823
|
};
|
|
1824
|
-
|
|
1824
|
+
type GetThreadsSinceOptions = {
|
|
1825
1825
|
since: Date;
|
|
1826
1826
|
signal?: AbortSignal;
|
|
1827
1827
|
};
|
|
1828
|
-
|
|
1828
|
+
type UploadAttachmentOptions = {
|
|
1829
1829
|
signal?: AbortSignal;
|
|
1830
1830
|
};
|
|
1831
|
-
|
|
1831
|
+
type ListTextVersionsSinceOptions = {
|
|
1832
1832
|
since: Date;
|
|
1833
1833
|
signal?: AbortSignal;
|
|
1834
1834
|
};
|
|
1835
|
-
|
|
1835
|
+
type GetNotificationSettingsOptions = {
|
|
1836
1836
|
signal?: AbortSignal;
|
|
1837
1837
|
};
|
|
1838
1838
|
/**
|
|
@@ -1840,8 +1840,8 @@ declare type GetNotificationSettingsOptions = {
|
|
|
1840
1840
|
* this type is different from `Room`-without-type-arguments. That represents
|
|
1841
1841
|
* a Room instance using globally augmented types only, which is narrower.
|
|
1842
1842
|
*/
|
|
1843
|
-
|
|
1844
|
-
|
|
1843
|
+
type OpaqueRoom = Room<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata>;
|
|
1844
|
+
type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata = DM> = {
|
|
1845
1845
|
/**
|
|
1846
1846
|
* @private
|
|
1847
1847
|
*
|
|
@@ -2255,7 +2255,7 @@ declare type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extend
|
|
|
2255
2255
|
*/
|
|
2256
2256
|
markInboxNotificationAsRead(notificationId: string): Promise<void>;
|
|
2257
2257
|
};
|
|
2258
|
-
|
|
2258
|
+
type YjsSyncStatus = "loading" | "synchronizing" | "synchronized";
|
|
2259
2259
|
/**
|
|
2260
2260
|
* Interface that @liveblocks/yjs must respect.
|
|
2261
2261
|
* This interface type is declare in @liveblocks/core, so we don't have to
|
|
@@ -2288,7 +2288,7 @@ interface SyncSource {
|
|
|
2288
2288
|
* Liveblocks, NEVER USE ANY OF THESE METHODS DIRECTLY, because bad things
|
|
2289
2289
|
* will probably happen if you do.
|
|
2290
2290
|
*/
|
|
2291
|
-
|
|
2291
|
+
type PrivateRoomApi = {
|
|
2292
2292
|
presenceBuffer: Json | undefined;
|
|
2293
2293
|
undoStack: readonly (readonly Readonly<HistoryOp<JsonObject>>[])[];
|
|
2294
2294
|
nodeCount: number;
|
|
@@ -2316,11 +2316,11 @@ declare type PrivateRoomApi = {
|
|
|
2316
2316
|
};
|
|
2317
2317
|
attachmentUrlsStore: BatchStore<string, string>;
|
|
2318
2318
|
};
|
|
2319
|
-
|
|
2319
|
+
type HistoryOp<P extends JsonObject> = Op | {
|
|
2320
2320
|
readonly type: "presence";
|
|
2321
2321
|
readonly data: P;
|
|
2322
2322
|
};
|
|
2323
|
-
|
|
2323
|
+
type Polyfills = {
|
|
2324
2324
|
atob?: (data: string) => string;
|
|
2325
2325
|
fetch?: typeof fetch;
|
|
2326
2326
|
WebSocket?: IWebSocket;
|
|
@@ -2332,19 +2332,19 @@ declare type Polyfills = {
|
|
|
2332
2332
|
* into:
|
|
2333
2333
|
* [foo?: string; bar?: number]
|
|
2334
2334
|
*/
|
|
2335
|
-
|
|
2335
|
+
type OptionalTuple<T extends any[]> = {
|
|
2336
2336
|
[K in keyof T]?: T[K];
|
|
2337
2337
|
};
|
|
2338
2338
|
/**
|
|
2339
2339
|
* Returns Partial<T> if all fields on C are optional, T otherwise.
|
|
2340
2340
|
*/
|
|
2341
|
-
|
|
2341
|
+
type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
|
|
2342
2342
|
C
|
|
2343
2343
|
] extends [never] ? Partial<T> : T;
|
|
2344
2344
|
/**
|
|
2345
2345
|
* Returns OptionalTupleUnless<T> if all fields on C are optional, T otherwise.
|
|
2346
2346
|
*/
|
|
2347
|
-
|
|
2347
|
+
type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
|
|
2348
2348
|
C
|
|
2349
2349
|
] extends [never] ? OptionalTuple<T> : T;
|
|
2350
2350
|
|
|
@@ -2588,7 +2588,7 @@ interface LiveblocksHttpApi<M extends BaseMetadata> extends RoomHttpApi<M>, Noti
|
|
|
2588
2588
|
* Back-port of TypeScript 5.4's built-in NoInfer utility type.
|
|
2589
2589
|
* See https://stackoverflow.com/a/56688073/148872
|
|
2590
2590
|
*/
|
|
2591
|
-
|
|
2591
|
+
type NoInfr<A> = [A][A extends any ? 0 : never];
|
|
2592
2592
|
|
|
2593
2593
|
declare const kTrigger: unique symbol;
|
|
2594
2594
|
/**
|
|
@@ -2598,7 +2598,7 @@ declare const kTrigger: unique symbol;
|
|
|
2598
2598
|
* Nesting batches is supported.
|
|
2599
2599
|
*/
|
|
2600
2600
|
declare function batch(callback: Callback<void>): void;
|
|
2601
|
-
|
|
2601
|
+
type SignalType<S extends ISignal<any>> = S extends ISignal<infer T> ? T : never;
|
|
2602
2602
|
interface ISignal<T> {
|
|
2603
2603
|
get(): T;
|
|
2604
2604
|
subscribe(callback: Callback<void>): UnsubscribeCallback;
|
|
@@ -2674,9 +2674,9 @@ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
|
|
|
2674
2674
|
mutate(callback?: (state: T) => void | boolean): void;
|
|
2675
2675
|
}
|
|
2676
2676
|
|
|
2677
|
-
|
|
2677
|
+
type OptionalPromise<T> = T | Promise<T>;
|
|
2678
2678
|
|
|
2679
|
-
|
|
2679
|
+
type ResolveMentionSuggestionsArgs = {
|
|
2680
2680
|
/**
|
|
2681
2681
|
* The ID of the current room.
|
|
2682
2682
|
*/
|
|
@@ -2686,19 +2686,19 @@ declare type ResolveMentionSuggestionsArgs = {
|
|
|
2686
2686
|
*/
|
|
2687
2687
|
text: string;
|
|
2688
2688
|
};
|
|
2689
|
-
|
|
2689
|
+
type ResolveUsersArgs = {
|
|
2690
2690
|
/**
|
|
2691
2691
|
* The IDs of the users to resolve.
|
|
2692
2692
|
*/
|
|
2693
2693
|
userIds: string[];
|
|
2694
2694
|
};
|
|
2695
|
-
|
|
2695
|
+
type ResolveRoomsInfoArgs = {
|
|
2696
2696
|
/**
|
|
2697
2697
|
* The IDs of the rooms to resolve.
|
|
2698
2698
|
*/
|
|
2699
2699
|
roomIds: string[];
|
|
2700
2700
|
};
|
|
2701
|
-
|
|
2701
|
+
type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolve<{
|
|
2702
2702
|
/**
|
|
2703
2703
|
* Whether or not the room automatically connects to Liveblock servers.
|
|
2704
2704
|
* Default is true.
|
|
@@ -2719,7 +2719,7 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2719
2719
|
*/
|
|
2720
2720
|
initialStorage: S | ((roomId: string) => S);
|
|
2721
2721
|
}>>;
|
|
2722
|
-
|
|
2722
|
+
type SyncStatus = "synchronizing" | "synchronized";
|
|
2723
2723
|
/**
|
|
2724
2724
|
* "synchronizing" - Liveblocks is in the process of writing changes
|
|
2725
2725
|
* "synchronized" - Liveblocks has persisted all pending changes
|
|
@@ -2727,7 +2727,7 @@ declare type SyncStatus = "synchronizing" | "synchronized";
|
|
|
2727
2727
|
* we're not yet "synchronizing" it until a user
|
|
2728
2728
|
* interaction, like the draft text in a comment box.
|
|
2729
2729
|
*/
|
|
2730
|
-
|
|
2730
|
+
type InternalSyncStatus = SyncStatus | "has-local-changes";
|
|
2731
2731
|
/**
|
|
2732
2732
|
* @private
|
|
2733
2733
|
*
|
|
@@ -2735,7 +2735,7 @@ declare type InternalSyncStatus = SyncStatus | "has-local-changes";
|
|
|
2735
2735
|
* of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
|
|
2736
2736
|
* will probably happen if you do.
|
|
2737
2737
|
*/
|
|
2738
|
-
|
|
2738
|
+
type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
2739
2739
|
readonly currentUserId: Signal<string | undefined>;
|
|
2740
2740
|
readonly mentionSuggestionsCache: Map<string, string[]>;
|
|
2741
2741
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
@@ -2746,7 +2746,7 @@ declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> =
|
|
|
2746
2746
|
as<M2 extends BaseMetadata>(): Client<U, M2>;
|
|
2747
2747
|
createSyncSource(): SyncSource;
|
|
2748
2748
|
};
|
|
2749
|
-
|
|
2749
|
+
type NotificationsApi<M extends BaseMetadata> = {
|
|
2750
2750
|
/**
|
|
2751
2751
|
* Gets a page (or the initial page) for user inbox notifications and their
|
|
2752
2752
|
* associated threads.
|
|
@@ -2847,8 +2847,8 @@ declare type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2847
2847
|
* represents a Client instance using globally augmented types only, which is
|
|
2848
2848
|
* narrower.
|
|
2849
2849
|
*/
|
|
2850
|
-
|
|
2851
|
-
|
|
2850
|
+
type OpaqueClient = Client<BaseUserMeta>;
|
|
2851
|
+
type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> = {
|
|
2852
2852
|
/**
|
|
2853
2853
|
* Gets a room. Returns null if {@link Client.enter} has not been called previously.
|
|
2854
2854
|
*
|
|
@@ -2945,12 +2945,12 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
|
|
|
2945
2945
|
readonly syncStatus: Observable<void>;
|
|
2946
2946
|
};
|
|
2947
2947
|
} & NotificationsApi<M>;
|
|
2948
|
-
|
|
2948
|
+
type AuthEndpoint = string | ((room?: string) => Promise<CustomAuthenticationResult>);
|
|
2949
2949
|
/**
|
|
2950
2950
|
* The authentication endpoint that is called to ensure that the current user has access to a room.
|
|
2951
2951
|
* Can be an url or a callback if you need to add additional headers.
|
|
2952
2952
|
*/
|
|
2953
|
-
|
|
2953
|
+
type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
2954
2954
|
throttle?: number;
|
|
2955
2955
|
lostConnectionTimeout?: number;
|
|
2956
2956
|
backgroundKeepAliveTimeout?: number;
|
|
@@ -3011,7 +3011,7 @@ declare type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
3011
3011
|
*/
|
|
3012
3012
|
declare function createClient<U extends BaseUserMeta = DU>(options: ClientOptions<U>): Client<U>;
|
|
3013
3013
|
|
|
3014
|
-
|
|
3014
|
+
type CommentBodyParagraphElementArgs = {
|
|
3015
3015
|
/**
|
|
3016
3016
|
* The paragraph element.
|
|
3017
3017
|
*/
|
|
@@ -3021,13 +3021,13 @@ declare type CommentBodyParagraphElementArgs = {
|
|
|
3021
3021
|
*/
|
|
3022
3022
|
children: string;
|
|
3023
3023
|
};
|
|
3024
|
-
|
|
3024
|
+
type CommentBodyTextElementArgs = {
|
|
3025
3025
|
/**
|
|
3026
3026
|
* The text element.
|
|
3027
3027
|
*/
|
|
3028
3028
|
element: CommentBodyText;
|
|
3029
3029
|
};
|
|
3030
|
-
|
|
3030
|
+
type CommentBodyLinkElementArgs = {
|
|
3031
3031
|
/**
|
|
3032
3032
|
* The link element.
|
|
3033
3033
|
*/
|
|
@@ -3037,7 +3037,7 @@ declare type CommentBodyLinkElementArgs = {
|
|
|
3037
3037
|
*/
|
|
3038
3038
|
href: string;
|
|
3039
3039
|
};
|
|
3040
|
-
|
|
3040
|
+
type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
|
|
3041
3041
|
/**
|
|
3042
3042
|
* The mention element.
|
|
3043
3043
|
*/
|
|
@@ -3047,7 +3047,7 @@ declare type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
|
|
|
3047
3047
|
*/
|
|
3048
3048
|
user?: U["info"];
|
|
3049
3049
|
};
|
|
3050
|
-
|
|
3050
|
+
type StringifyCommentBodyElements<U extends BaseUserMeta = DU> = {
|
|
3051
3051
|
/**
|
|
3052
3052
|
* The element used to display paragraphs.
|
|
3053
3053
|
*/
|
|
@@ -3065,7 +3065,7 @@ declare type StringifyCommentBodyElements<U extends BaseUserMeta = DU> = {
|
|
|
3065
3065
|
*/
|
|
3066
3066
|
mention: (args: CommentBodyMentionElementArgs<U>, index: number) => string;
|
|
3067
3067
|
};
|
|
3068
|
-
|
|
3068
|
+
type StringifyCommentBodyOptions<U extends BaseUserMeta = DU> = {
|
|
3069
3069
|
/**
|
|
3070
3070
|
* Which format to convert the comment to.
|
|
3071
3071
|
*/
|
|
@@ -3154,13 +3154,13 @@ declare function convertToInboxNotificationData(data: InboxNotificationDataPlain
|
|
|
3154
3154
|
/**
|
|
3155
3155
|
* Lookup table for nodes (= SerializedCrdt values) by their IDs.
|
|
3156
3156
|
*/
|
|
3157
|
-
|
|
3157
|
+
type NodeMap = Map<string, // Node ID
|
|
3158
3158
|
SerializedCrdt>;
|
|
3159
3159
|
/**
|
|
3160
3160
|
* Reverse lookup table for all child nodes (= list of SerializedCrdt values)
|
|
3161
3161
|
* by their parent node's IDs.
|
|
3162
3162
|
*/
|
|
3163
|
-
|
|
3163
|
+
type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
3164
3164
|
IdTuple<SerializedChild>[]>;
|
|
3165
3165
|
|
|
3166
3166
|
declare function isLiveNode(value: unknown): value is LiveNode;
|
|
@@ -3326,6 +3326,16 @@ declare namespace fancyConsole {
|
|
|
3326
3326
|
*/
|
|
3327
3327
|
declare const freeze: typeof Object.freeze;
|
|
3328
3328
|
|
|
3329
|
+
declare function isPlainObject(blob: unknown): blob is {
|
|
3330
|
+
[key: string]: unknown;
|
|
3331
|
+
};
|
|
3332
|
+
/**
|
|
3333
|
+
* Check if value is of shape { startsWith: string }
|
|
3334
|
+
*/
|
|
3335
|
+
declare function isStartsWithOperator(blob: unknown): blob is {
|
|
3336
|
+
startsWith: string;
|
|
3337
|
+
};
|
|
3338
|
+
|
|
3329
3339
|
declare const nanoid: (t?: number) => string;
|
|
3330
3340
|
|
|
3331
3341
|
/**
|
|
@@ -3333,35 +3343,32 @@ declare const nanoid: (t?: number) => string;
|
|
|
3333
3343
|
* Example:
|
|
3334
3344
|
* ```ts
|
|
3335
3345
|
* const query = objectToQuery({
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
});
|
|
3345
|
-
|
|
3346
|
-
console.log(query);
|
|
3347
|
-
// resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
|
|
3348
|
-
|
|
3349
|
-
* ```
|
|
3350
|
-
*
|
|
3346
|
+
* resolved: true,
|
|
3347
|
+
* metadata: {
|
|
3348
|
+
* status: "open",
|
|
3349
|
+
* priority: 3,
|
|
3350
|
+
* org: {
|
|
3351
|
+
* startsWith: "liveblocks:",
|
|
3352
|
+
* },
|
|
3353
|
+
* },
|
|
3354
|
+
* });
|
|
3351
3355
|
*
|
|
3356
|
+
* console.log(query);
|
|
3357
|
+
* // resolved:true AND metadata["status"]:open AND metadata["priority"]:3 AND metadata["org"]^"liveblocks:"
|
|
3358
|
+
* ```
|
|
3352
3359
|
*/
|
|
3353
|
-
|
|
3354
|
-
|
|
3360
|
+
type SimpleFilterValue = string | number | boolean;
|
|
3361
|
+
type OperatorFilterValue = {
|
|
3355
3362
|
startsWith: string;
|
|
3356
3363
|
};
|
|
3357
|
-
|
|
3364
|
+
type FilterValue = SimpleFilterValue | OperatorFilterValue;
|
|
3358
3365
|
declare function objectToQuery(obj: {
|
|
3359
3366
|
[key: string]: FilterValue | {
|
|
3360
3367
|
[key: string]: FilterValue | undefined;
|
|
3361
3368
|
} | undefined;
|
|
3362
3369
|
}): string;
|
|
3363
3370
|
|
|
3364
|
-
|
|
3371
|
+
type Poller = {
|
|
3365
3372
|
/**
|
|
3366
3373
|
* Increments the subscriber count for this poller. If it becomes > 0, the
|
|
3367
3374
|
* poller will be enabled.
|
|
@@ -3414,17 +3421,14 @@ declare function makePoller(callback: (signal: AbortSignal) => Promise<void> | v
|
|
|
3414
3421
|
}): Poller;
|
|
3415
3422
|
|
|
3416
3423
|
declare const brand: unique symbol;
|
|
3417
|
-
|
|
3424
|
+
type Brand<T, TBrand extends string> = T & {
|
|
3418
3425
|
[brand]: TBrand;
|
|
3419
3426
|
};
|
|
3420
|
-
|
|
3427
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
|
|
3421
3428
|
/**
|
|
3422
3429
|
* Throw an error, but as an expression instead of a statement.
|
|
3423
3430
|
*/
|
|
3424
3431
|
declare function raise(msg: string): never;
|
|
3425
|
-
declare function isPlainObject(blob: unknown): blob is {
|
|
3426
|
-
[key: string]: unknown;
|
|
3427
|
-
};
|
|
3428
3432
|
/**
|
|
3429
3433
|
* Creates a new object by mapping a function over all values. Keys remain the
|
|
3430
3434
|
* same. Think Array.prototype.map(), but for values in an object.
|
|
@@ -3441,7 +3445,7 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
|
3441
3445
|
* Decode base64 string.
|
|
3442
3446
|
*/
|
|
3443
3447
|
declare function b64decode(b64value: string): string;
|
|
3444
|
-
|
|
3448
|
+
type RemoveUndefinedValues<T> = {
|
|
3445
3449
|
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
3446
3450
|
};
|
|
3447
3451
|
/**
|
|
@@ -3518,7 +3522,7 @@ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise
|
|
|
3518
3522
|
* A valid/verified "position" string. These values are used as "parentKey"s by
|
|
3519
3523
|
* LiveList children, and define their relative ordering.
|
|
3520
3524
|
*/
|
|
3521
|
-
|
|
3525
|
+
type Pos = Brand<string, "Pos">;
|
|
3522
3526
|
/**
|
|
3523
3527
|
* Given two positions, returns the position value that lies in the middle.
|
|
3524
3528
|
* When given only a high bound, computes the canonical position "before" it.
|
|
@@ -3594,7 +3598,7 @@ declare function stringify(value: unknown): string;
|
|
|
3594
3598
|
*/
|
|
3595
3599
|
declare function unstringify(value: string): unknown;
|
|
3596
3600
|
|
|
3597
|
-
|
|
3601
|
+
type QueryParams = Record<string, string | number | null | undefined> | URLSearchParams;
|
|
3598
3602
|
/**
|
|
3599
3603
|
* Concatenates a path to an existing URL.
|
|
3600
3604
|
*/
|
|
@@ -3603,7 +3607,7 @@ declare function urljoin(baseUrl: string | URL, path: string, params?: QueryPara
|
|
|
3603
3607
|
* A string that is guaranteed to be URL safe (where all arguments are properly
|
|
3604
3608
|
* encoded), only obtainable as the result of using `url` template strings.
|
|
3605
3609
|
*/
|
|
3606
|
-
|
|
3610
|
+
type URLSafeString = Brand<string, "URLSafeString">;
|
|
3607
3611
|
/**
|
|
3608
3612
|
* Builds a URL where each "hole" in the template string will automatically be
|
|
3609
3613
|
* encodeURIComponent()-escaped, so it's impossible to build invalid URLs.
|
|
@@ -3613,7 +3617,7 @@ declare function url(strings: TemplateStringsArray, ...values: string[]): URLSaf
|
|
|
3613
3617
|
/**
|
|
3614
3618
|
* Definition of all messages the Panel can send to the Client.
|
|
3615
3619
|
*/
|
|
3616
|
-
|
|
3620
|
+
type PanelToClientMessage =
|
|
3617
3621
|
/**
|
|
3618
3622
|
* Initial message from the panel to the client, used for two purposes.
|
|
3619
3623
|
* 1. First, it’s eavesdropped by the background script, which uses this
|
|
@@ -3647,7 +3651,7 @@ declare type PanelToClientMessage =
|
|
|
3647
3651
|
/**
|
|
3648
3652
|
* Definition of all messages the Client can send to the Panel.
|
|
3649
3653
|
*/
|
|
3650
|
-
|
|
3654
|
+
type ClientToPanelMessage =
|
|
3651
3655
|
/**
|
|
3652
3656
|
* Initial message sent by the client to test if a dev panel is listening.
|
|
3653
3657
|
* This is necessary in cases where the dev panel is already opened and
|
|
@@ -3714,11 +3718,11 @@ declare type ClientToPanelMessage =
|
|
|
3714
3718
|
roomId: string;
|
|
3715
3719
|
update: YDocUpdateServerMsg | UpdateYDocClientMsg;
|
|
3716
3720
|
};
|
|
3717
|
-
|
|
3721
|
+
type FullPanelToClientMessage = PanelToClientMessage & {
|
|
3718
3722
|
source: "liveblocks-devtools-panel";
|
|
3719
3723
|
tabId: number;
|
|
3720
3724
|
};
|
|
3721
|
-
|
|
3725
|
+
type FullClientToPanelMessage = ClientToPanelMessage & {
|
|
3722
3726
|
source: "liveblocks-devtools-client";
|
|
3723
3727
|
};
|
|
3724
3728
|
|
|
@@ -3736,7 +3740,7 @@ declare namespace protocol {
|
|
|
3736
3740
|
* information, see
|
|
3737
3741
|
* https://liveblocks.io/docs/guides/limits#lson-constraint-and-interfaces
|
|
3738
3742
|
*/
|
|
3739
|
-
|
|
3743
|
+
type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson<I>)[] : [
|
|
3740
3744
|
unknown
|
|
3741
3745
|
] extends [T] ? Json | undefined : T extends Date ? string : T extends (...args: any[]) => any ? never : {
|
|
3742
3746
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
@@ -3747,4 +3751,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3747
3751
|
/** @deprecated Use HttpError instead. */
|
|
3748
3752
|
declare const NotificationsApiError: typeof HttpError;
|
|
3749
3753
|
|
|
3750
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, 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, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, 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, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, unstringify, url, urljoin, wait, withTimeout };
|
|
3754
|
+
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, 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, MutableSignal, type NoInfr, type NodeMap, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalPromise, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, 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, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, unstringify, url, urljoin, wait, withTimeout };
|