@liveblocks/core 3.17.0-rc1 → 3.18.0-rc1
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.cjs +1250 -1576
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +197 -203
- package/dist/index.d.ts +197 -203
- package/dist/index.js +1147 -1473
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,16 @@ type JsonArray = Json[];
|
|
|
93
93
|
type JsonObject = {
|
|
94
94
|
[key: string]: Json | undefined;
|
|
95
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Like Json, but with readonly arrays and objects.
|
|
98
|
+
*/
|
|
99
|
+
type ReadonlyJson = JsonScalar | readonly ReadonlyJson[] | ReadonlyJsonObject;
|
|
100
|
+
/**
|
|
101
|
+
* Like JsonObject, but readonly.
|
|
102
|
+
*/
|
|
103
|
+
type ReadonlyJsonObject = {
|
|
104
|
+
readonly [key: string]: ReadonlyJson | undefined;
|
|
105
|
+
};
|
|
96
106
|
declare function isJsonScalar(data: Json): data is JsonScalar;
|
|
97
107
|
declare function isJsonArray(data: Json): data is JsonArray;
|
|
98
108
|
declare function isJsonObject(data: Json): data is JsonObject;
|
|
@@ -520,18 +530,6 @@ type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
|
520
530
|
opId?: undefined;
|
|
521
531
|
};
|
|
522
532
|
|
|
523
|
-
/**
|
|
524
|
-
* Represents an indefinitely deep arbitrary immutable data
|
|
525
|
-
* structure, as returned by the .toImmutable().
|
|
526
|
-
*/
|
|
527
|
-
type Immutable = Scalar | ImmutableList | ImmutableObject | ImmutableMap;
|
|
528
|
-
type Scalar = string | number | boolean | null;
|
|
529
|
-
type ImmutableList = readonly Immutable[];
|
|
530
|
-
type ImmutableObject = {
|
|
531
|
-
readonly [key: string]: Immutable | undefined;
|
|
532
|
-
};
|
|
533
|
-
type ImmutableMap = ReadonlyMap<string, Immutable>;
|
|
534
|
-
|
|
535
533
|
type UpdateDelta = {
|
|
536
534
|
type: "update";
|
|
537
535
|
} | {
|
|
@@ -540,61 +538,77 @@ type UpdateDelta = {
|
|
|
540
538
|
};
|
|
541
539
|
|
|
542
540
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
546
|
-
*
|
|
547
|
-
* In the client, you would typically create LSON values using:
|
|
548
|
-
*
|
|
549
|
-
* new LiveObject({ x: 0, y: 0 })
|
|
550
|
-
*
|
|
551
|
-
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
552
|
-
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
553
|
-
* control which parts of their data structure should be considered "Live"
|
|
554
|
-
* objects, and which parts are "normal" objects.
|
|
555
|
-
*
|
|
556
|
-
* So if they have a structure like:
|
|
557
|
-
*
|
|
558
|
-
* { x: 0, y: 0 }
|
|
559
|
-
*
|
|
560
|
-
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
561
|
-
* a special "annotation":
|
|
562
|
-
*
|
|
563
|
-
* {
|
|
564
|
-
* "liveblocksType": "LiveObject",
|
|
565
|
-
* "data": { x: 0, y: 0 },
|
|
566
|
-
* }
|
|
567
|
-
*
|
|
568
|
-
* This "Plain LSON" data format defines exactly those wrappings.
|
|
569
|
-
*
|
|
570
|
-
* To summarize:
|
|
571
|
-
*
|
|
572
|
-
* LSON value | Plain LSON equivalent
|
|
573
|
-
* ----------------------+----------------------------------------------
|
|
574
|
-
* 42 | 42
|
|
575
|
-
* [1, 2, 3] | [1, 2, 3]
|
|
576
|
-
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
577
|
-
* ----------------------+----------------------------------------------
|
|
578
|
-
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
579
|
-
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
580
|
-
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
581
|
-
*
|
|
541
|
+
* A LiveMap notification that is sent in-client to any subscribers whenever
|
|
542
|
+
* one or more of the values inside the LiveMap instance have changed.
|
|
582
543
|
*/
|
|
583
|
-
|
|
584
|
-
type
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
};
|
|
589
|
-
type PlainLsonMap = {
|
|
590
|
-
liveblocksType: "LiveMap";
|
|
591
|
-
data: PlainLsonFields;
|
|
592
|
-
};
|
|
593
|
-
type PlainLsonList = {
|
|
594
|
-
liveblocksType: "LiveList";
|
|
595
|
-
data: PlainLson[];
|
|
544
|
+
type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
|
|
545
|
+
type: "LiveMap";
|
|
546
|
+
node: LiveMap<TKey, TValue>;
|
|
547
|
+
updates: {
|
|
548
|
+
[key: string]: UpdateDelta;
|
|
549
|
+
};
|
|
596
550
|
};
|
|
597
|
-
|
|
551
|
+
/**
|
|
552
|
+
* The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
|
|
553
|
+
* Keys should be a string, and values should be serializable to JSON.
|
|
554
|
+
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
555
|
+
*/
|
|
556
|
+
declare class LiveMap<TKey extends string, TValue extends Lson> extends AbstractCrdt {
|
|
557
|
+
#private;
|
|
558
|
+
constructor(entries?: readonly (readonly [TKey, TValue])[] | undefined);
|
|
559
|
+
/**
|
|
560
|
+
* Returns a specified element from the LiveMap.
|
|
561
|
+
* @param key The key of the element to return.
|
|
562
|
+
* @returns The element associated with the specified key, or undefined if the key can't be found in the LiveMap.
|
|
563
|
+
*/
|
|
564
|
+
get(key: TKey): TValue | undefined;
|
|
565
|
+
/**
|
|
566
|
+
* Adds or updates an element with a specified key and a value.
|
|
567
|
+
* @param key The key of the element to add. Should be a string.
|
|
568
|
+
* @param value The value of the element to add. Should be serializable to JSON.
|
|
569
|
+
*/
|
|
570
|
+
set(key: TKey, value: TValue): void;
|
|
571
|
+
/**
|
|
572
|
+
* Returns the number of elements in the LiveMap.
|
|
573
|
+
*/
|
|
574
|
+
get size(): number;
|
|
575
|
+
/**
|
|
576
|
+
* Returns a boolean indicating whether an element with the specified key exists or not.
|
|
577
|
+
* @param key The key of the element to test for presence.
|
|
578
|
+
*/
|
|
579
|
+
has(key: TKey): boolean;
|
|
580
|
+
/**
|
|
581
|
+
* Removes the specified element by key.
|
|
582
|
+
* @param key The key of the element to remove.
|
|
583
|
+
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
584
|
+
*/
|
|
585
|
+
delete(key: TKey): boolean;
|
|
586
|
+
/**
|
|
587
|
+
* Returns a new Iterator object that contains the [key, value] pairs for each element.
|
|
588
|
+
*/
|
|
589
|
+
entries(): IterableIterator<[TKey, TValue]>;
|
|
590
|
+
/**
|
|
591
|
+
* Same function object as the initial value of the entries method.
|
|
592
|
+
*/
|
|
593
|
+
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
594
|
+
/**
|
|
595
|
+
* Returns a new Iterator object that contains the keys for each element.
|
|
596
|
+
*/
|
|
597
|
+
keys(): IterableIterator<TKey>;
|
|
598
|
+
/**
|
|
599
|
+
* Returns a new Iterator object that contains the values for each element.
|
|
600
|
+
*/
|
|
601
|
+
values(): IterableIterator<TValue>;
|
|
602
|
+
/**
|
|
603
|
+
* Executes a provided function once per each key/value pair in the Map object, in insertion order.
|
|
604
|
+
* @param callback Function to execute for each entry in the map.
|
|
605
|
+
*/
|
|
606
|
+
forEach(callback: (value: TValue, key: TKey, map: LiveMap<TKey, TValue>) => void): void;
|
|
607
|
+
toJSON(): {
|
|
608
|
+
readonly [P in TKey]: ToJson<TValue>;
|
|
609
|
+
};
|
|
610
|
+
clone(): LiveMap<TKey, TValue>;
|
|
611
|
+
}
|
|
598
612
|
|
|
599
613
|
type CrdtType = (typeof CrdtType)[keyof typeof CrdtType];
|
|
600
614
|
declare const CrdtType: Readonly<{
|
|
@@ -776,10 +790,6 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
776
790
|
constructor(obj?: O);
|
|
777
791
|
/** @private */
|
|
778
792
|
keys(): Set<string>;
|
|
779
|
-
/**
|
|
780
|
-
* Transform the LiveObject into a javascript object
|
|
781
|
-
*/
|
|
782
|
-
toObject(): O;
|
|
783
793
|
/**
|
|
784
794
|
* Adds or updates a property with a specified key and a value.
|
|
785
795
|
* @param key The key of the property to add
|
|
@@ -789,10 +799,9 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
789
799
|
/**
|
|
790
800
|
* @experimental
|
|
791
801
|
*
|
|
792
|
-
* Sets a local-only property that is not synchronized over the wire.
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* for this key.
|
|
802
|
+
* Sets a local-only property that is not synchronized over the wire. The
|
|
803
|
+
* value will be visible via get(), and toJSON() on this client only. Other
|
|
804
|
+
* clients and the server will see `undefined` for this key.
|
|
796
805
|
*
|
|
797
806
|
* Caveat: this method will not add changes to the undo/redo stack.
|
|
798
807
|
*/
|
|
@@ -814,117 +823,34 @@ declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
|
814
823
|
update(patch: Partial<O>): void;
|
|
815
824
|
/**
|
|
816
825
|
* Creates a new LiveObject from a plain JSON object, recursively converting
|
|
817
|
-
* nested objects to LiveObjects and arrays to LiveLists.
|
|
818
|
-
* SyncConfig controls per-key behavior (local-only, atomic, or deep).
|
|
819
|
-
*
|
|
820
|
-
* @private
|
|
826
|
+
* nested objects to LiveObjects and arrays to LiveLists.
|
|
821
827
|
*/
|
|
828
|
+
static from(obj: JsonObject): LiveObject<LsonObject>;
|
|
829
|
+
/** @private */
|
|
822
830
|
static from(obj: JsonObject, config?: SyncConfig): LiveObject<LsonObject>;
|
|
823
831
|
/**
|
|
824
|
-
* Reconciles
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
* @private
|
|
832
|
+
* Reconciles this LiveObject tree to match the given JSON object. Only
|
|
833
|
+
* mutates keys that actually changed. Keys present on this LiveObject but
|
|
834
|
+
* absent from `jsonObj` will be deleted. Nested structures are recursively
|
|
835
|
+
* reconciled.
|
|
829
836
|
*/
|
|
837
|
+
reconcile(jsonObj: JsonObject): void;
|
|
838
|
+
/** @private */
|
|
830
839
|
reconcile(jsonObj: JsonObject, config?: SyncConfig): void;
|
|
831
|
-
toImmutable(): ToImmutable<O>;
|
|
832
|
-
clone(): LiveObject<O>;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* Helper type to convert any valid Lson type to the equivalent Json type.
|
|
837
|
-
*
|
|
838
|
-
* Examples:
|
|
839
|
-
*
|
|
840
|
-
* ToImmutable<42> // 42
|
|
841
|
-
* ToImmutable<'hi'> // 'hi'
|
|
842
|
-
* ToImmutable<number> // number
|
|
843
|
-
* ToImmutable<string> // string
|
|
844
|
-
* ToImmutable<string | LiveList<number>> // string | readonly number[]
|
|
845
|
-
* ToImmutable<LiveMap<string, LiveList<number>>>
|
|
846
|
-
* // ReadonlyMap<string, readonly number[]>
|
|
847
|
-
* ToImmutable<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
848
|
-
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
849
|
-
*
|
|
850
|
-
*/
|
|
851
|
-
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 ? {
|
|
852
|
-
readonly [K in keyof L]: ToImmutable<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
853
|
-
} : L extends Json ? L : never;
|
|
854
|
-
/**
|
|
855
|
-
* Returns PlainLson for a given Json or LiveStructure, suitable for calling the storage init api
|
|
856
|
-
*/
|
|
857
|
-
declare function toPlainLson(lson: Lson): PlainLson;
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* A LiveMap notification that is sent in-client to any subscribers whenever
|
|
861
|
-
* one or more of the values inside the LiveMap instance have changed.
|
|
862
|
-
*/
|
|
863
|
-
type LiveMapUpdates<TKey extends string, TValue extends Lson> = {
|
|
864
|
-
type: "LiveMap";
|
|
865
|
-
node: LiveMap<TKey, TValue>;
|
|
866
|
-
updates: {
|
|
867
|
-
[key: string]: UpdateDelta;
|
|
868
|
-
};
|
|
869
|
-
};
|
|
870
|
-
/**
|
|
871
|
-
* The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
|
|
872
|
-
* Keys should be a string, and values should be serializable to JSON.
|
|
873
|
-
* If multiple clients update the same property simultaneously, the last modification received by the Liveblocks servers is the winner.
|
|
874
|
-
*/
|
|
875
|
-
declare class LiveMap<TKey extends string, TValue extends Lson> extends AbstractCrdt {
|
|
876
|
-
#private;
|
|
877
|
-
constructor(entries?: readonly (readonly [TKey, TValue])[] | undefined);
|
|
878
840
|
/**
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
*
|
|
886
|
-
*
|
|
887
|
-
* @
|
|
888
|
-
*/
|
|
889
|
-
set(key: TKey, value: TValue): void;
|
|
890
|
-
/**
|
|
891
|
-
* Returns the number of elements in the LiveMap.
|
|
892
|
-
*/
|
|
893
|
-
get size(): number;
|
|
894
|
-
/**
|
|
895
|
-
* Returns a boolean indicating whether an element with the specified key exists or not.
|
|
896
|
-
* @param key The key of the element to test for presence.
|
|
897
|
-
*/
|
|
898
|
-
has(key: TKey): boolean;
|
|
899
|
-
/**
|
|
900
|
-
* Removes the specified element by key.
|
|
901
|
-
* @param key The key of the element to remove.
|
|
902
|
-
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
903
|
-
*/
|
|
904
|
-
delete(key: TKey): boolean;
|
|
905
|
-
/**
|
|
906
|
-
* Returns a new Iterator object that contains the [key, value] pairs for each element.
|
|
907
|
-
*/
|
|
908
|
-
entries(): IterableIterator<[TKey, TValue]>;
|
|
909
|
-
/**
|
|
910
|
-
* Same function object as the initial value of the entries method.
|
|
911
|
-
*/
|
|
912
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
913
|
-
/**
|
|
914
|
-
* Returns a new Iterator object that contains the keys for each element.
|
|
915
|
-
*/
|
|
916
|
-
keys(): IterableIterator<TKey>;
|
|
917
|
-
/**
|
|
918
|
-
* Returns a new Iterator object that contains the values for each element.
|
|
919
|
-
*/
|
|
920
|
-
values(): IterableIterator<TValue>;
|
|
921
|
-
/**
|
|
922
|
-
* Executes a provided function once per each key/value pair in the Map object, in insertion order.
|
|
923
|
-
* @param callback Function to execute for each entry in the map.
|
|
841
|
+
* Like reconcile(), but only touches the top-level keys present in
|
|
842
|
+
* `partialObj`. Keys on this LiveObject that are absent from `partialObj`
|
|
843
|
+
* are left untouched. Typically called on the storage root when
|
|
844
|
+
* reconciling a subset of keys without affecting other keys on the root.
|
|
845
|
+
*
|
|
846
|
+
* Note: the partial behavior only applies to the top-level keys of this
|
|
847
|
+
* object. Nested structures are always fully reconciled.
|
|
848
|
+
*
|
|
849
|
+
* @private
|
|
924
850
|
*/
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
clone():
|
|
851
|
+
reconcilePartially(partialObj: JsonObject, config?: SyncConfig): void;
|
|
852
|
+
toJSON(): ToJson<O>;
|
|
853
|
+
clone(): LiveObject<O>;
|
|
928
854
|
}
|
|
929
855
|
|
|
930
856
|
type StorageCallback = (updates: StorageUpdate[]) => void;
|
|
@@ -995,14 +921,17 @@ declare abstract class AbstractCrdt {
|
|
|
995
921
|
get roomId(): string | null;
|
|
996
922
|
/**
|
|
997
923
|
* @private
|
|
998
|
-
* Returns true if the cached
|
|
999
|
-
*
|
|
924
|
+
* Returns true if the cached JSON snapshot exists and is reference-equal
|
|
925
|
+
* to the given value. Does not trigger a recompute.
|
|
1000
926
|
*/
|
|
1001
|
-
|
|
927
|
+
hasCache(value: unknown): boolean;
|
|
1002
928
|
/**
|
|
1003
|
-
* Return
|
|
929
|
+
* Return a JSON-compatible snapshot of this Live node and its children.
|
|
930
|
+
* LiveObject values become plain objects, LiveList values become arrays,
|
|
931
|
+
* and LiveMap values also become plain objects (not Map instances).
|
|
932
|
+
* The result is cached and only recomputed when the contents change.
|
|
1004
933
|
*/
|
|
1005
|
-
|
|
934
|
+
toJSON(): ReadonlyJson;
|
|
1006
935
|
/**
|
|
1007
936
|
* Returns a deep clone of the current LiveStructure, suitable for insertion
|
|
1008
937
|
* in the tree elsewhere.
|
|
@@ -1071,10 +1000,6 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
1071
1000
|
delete(index: number): void;
|
|
1072
1001
|
clear(): void;
|
|
1073
1002
|
set(index: number, item: TItem): void;
|
|
1074
|
-
/**
|
|
1075
|
-
* Returns an Array of all the elements in the LiveList.
|
|
1076
|
-
*/
|
|
1077
|
-
toArray(): TItem[];
|
|
1078
1003
|
/**
|
|
1079
1004
|
* Tests whether all elements pass the test implemented by the provided function.
|
|
1080
1005
|
* @param predicate Function to test for each element, taking two arguments (the element and its index).
|
|
@@ -1118,10 +1043,10 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
1118
1043
|
*/
|
|
1119
1044
|
indexOf(searchElement: TItem, fromIndex?: number): number;
|
|
1120
1045
|
/**
|
|
1121
|
-
* Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The
|
|
1046
|
+
* Returns the last index at which a given element can be found in the LiveList, or -1 if it is not present. The LiveList is searched backwards, starting at fromIndex.
|
|
1122
1047
|
* @param searchElement Element to locate.
|
|
1123
1048
|
* @param fromIndex The index at which to start searching backwards.
|
|
1124
|
-
* @returns
|
|
1049
|
+
* @returns The last index of the element in the LiveList; -1 if not found.
|
|
1125
1050
|
*/
|
|
1126
1051
|
lastIndexOf(searchElement: TItem, fromIndex?: number): number;
|
|
1127
1052
|
/**
|
|
@@ -1137,7 +1062,7 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
1137
1062
|
*/
|
|
1138
1063
|
some(predicate: (value: TItem, index: number) => unknown): boolean;
|
|
1139
1064
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
1140
|
-
|
|
1065
|
+
toJSON(): readonly ToJson<TItem>[];
|
|
1141
1066
|
clone(): LiveList<TItem>;
|
|
1142
1067
|
}
|
|
1143
1068
|
|
|
@@ -1179,18 +1104,17 @@ type LsonObject = {
|
|
|
1179
1104
|
* ToJson<'hi'> // 'hi'
|
|
1180
1105
|
* ToJson<number> // number
|
|
1181
1106
|
* ToJson<string> // string
|
|
1182
|
-
* ToJson<string | LiveList<number>> // string | number[]
|
|
1107
|
+
* ToJson<string | LiveList<number>> // string | readonly number[]
|
|
1183
1108
|
* ToJson<LiveMap<string, LiveList<number>>>
|
|
1184
|
-
* // { [key: string]: number[] }
|
|
1109
|
+
* // { readonly [key: string]: readonly number[] }
|
|
1185
1110
|
* ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
1186
|
-
* // { a: null, b: string[], c?: number }
|
|
1187
|
-
*
|
|
1111
|
+
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
1188
1112
|
*/
|
|
1189
|
-
type ToJson<
|
|
1190
|
-
[
|
|
1191
|
-
} :
|
|
1192
|
-
[K in
|
|
1193
|
-
} : never;
|
|
1113
|
+
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToJson<I>[] : L extends LiveObject<infer O> ? ToJson<O> : L extends LiveMap<infer KS, infer V> ? {
|
|
1114
|
+
readonly [P in KS]: ToJson<V>;
|
|
1115
|
+
} : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
1116
|
+
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
1117
|
+
} : L extends Json ? L : never;
|
|
1194
1118
|
|
|
1195
1119
|
type DateToString<T> = {
|
|
1196
1120
|
[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];
|
|
@@ -2203,7 +2127,7 @@ type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS> = Resolv
|
|
|
2203
2127
|
/**
|
|
2204
2128
|
* The initial Storage to use when entering a new Room.
|
|
2205
2129
|
*/
|
|
2206
|
-
initialStorage: S | ((roomId: string) => S);
|
|
2130
|
+
initialStorage: S | LiveObject<S> | ((roomId: string) => S | LiveObject<S>);
|
|
2207
2131
|
}>>;
|
|
2208
2132
|
type SyncStatus = "synchronizing" | "synchronized";
|
|
2209
2133
|
/**
|
|
@@ -4965,9 +4889,67 @@ ChildStorageNode[]>;
|
|
|
4965
4889
|
declare function isLiveNode(value: unknown): value is LiveNode;
|
|
4966
4890
|
declare function cloneLson<L extends Lson | undefined>(value: L): L;
|
|
4967
4891
|
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4892
|
+
/**
|
|
4893
|
+
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
4894
|
+
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
4895
|
+
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
4896
|
+
*
|
|
4897
|
+
* In the client, you would typically create LSON values using:
|
|
4898
|
+
*
|
|
4899
|
+
* new LiveObject({ x: 0, y: 0 })
|
|
4900
|
+
*
|
|
4901
|
+
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
4902
|
+
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
4903
|
+
* control which parts of their data structure should be considered "Live"
|
|
4904
|
+
* objects, and which parts are "normal" objects.
|
|
4905
|
+
*
|
|
4906
|
+
* So if they have a structure like:
|
|
4907
|
+
*
|
|
4908
|
+
* { x: 0, y: 0 }
|
|
4909
|
+
*
|
|
4910
|
+
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
4911
|
+
* a special "annotation":
|
|
4912
|
+
*
|
|
4913
|
+
* {
|
|
4914
|
+
* "liveblocksType": "LiveObject",
|
|
4915
|
+
* "data": { x: 0, y: 0 },
|
|
4916
|
+
* }
|
|
4917
|
+
*
|
|
4918
|
+
* This "Plain LSON" data format defines exactly those wrappings.
|
|
4919
|
+
*
|
|
4920
|
+
* To summarize:
|
|
4921
|
+
*
|
|
4922
|
+
* LSON value | Plain LSON equivalent
|
|
4923
|
+
* ----------------------+----------------------------------------------
|
|
4924
|
+
* 42 | 42
|
|
4925
|
+
* [1, 2, 3] | [1, 2, 3]
|
|
4926
|
+
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
4927
|
+
* ----------------------+----------------------------------------------
|
|
4928
|
+
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
4929
|
+
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
4930
|
+
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
4931
|
+
*
|
|
4932
|
+
*/
|
|
4933
|
+
|
|
4934
|
+
type PlainLsonFields = Record<string, PlainLson>;
|
|
4935
|
+
type PlainLsonObject = {
|
|
4936
|
+
liveblocksType: "LiveObject";
|
|
4937
|
+
data: PlainLsonFields;
|
|
4938
|
+
};
|
|
4939
|
+
type PlainLsonMap = {
|
|
4940
|
+
liveblocksType: "LiveMap";
|
|
4941
|
+
data: PlainLsonFields;
|
|
4942
|
+
};
|
|
4943
|
+
type PlainLsonList = {
|
|
4944
|
+
liveblocksType: "LiveList";
|
|
4945
|
+
data: PlainLson[];
|
|
4946
|
+
};
|
|
4947
|
+
type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
4948
|
+
|
|
4949
|
+
/**
|
|
4950
|
+
* Returns PlainLson for a given Json or LiveStructure, suitable for calling the storage init api
|
|
4951
|
+
*/
|
|
4952
|
+
declare function toPlainLson(lson: Lson): PlainLson;
|
|
4971
4953
|
|
|
4972
4954
|
/**
|
|
4973
4955
|
* Like `new AbortController()`, but where the result can be unpacked
|
|
@@ -5526,6 +5508,18 @@ declare function warnOnce(message: string, key?: string): void;
|
|
|
5526
5508
|
*/
|
|
5527
5509
|
declare function warnOnceIf(condition: boolean | (() => boolean), message: string, key?: string): void;
|
|
5528
5510
|
|
|
5511
|
+
/**
|
|
5512
|
+
* Represents an indefinitely deep arbitrary immutable data
|
|
5513
|
+
* structure.
|
|
5514
|
+
*/
|
|
5515
|
+
type Immutable = Scalar | ImmutableList | ImmutableObject | ImmutableMap;
|
|
5516
|
+
type Scalar = string | number | boolean | null;
|
|
5517
|
+
type ImmutableList = readonly Immutable[];
|
|
5518
|
+
type ImmutableObject = {
|
|
5519
|
+
readonly [key: string]: Immutable | undefined;
|
|
5520
|
+
};
|
|
5521
|
+
type ImmutableMap = ReadonlyMap<string, Immutable>;
|
|
5522
|
+
|
|
5529
5523
|
/**
|
|
5530
5524
|
* Definition of all messages the Panel can send to the Client.
|
|
5531
5525
|
*/
|
|
@@ -5658,4 +5652,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5658
5652
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5659
5653
|
};
|
|
5660
5654
|
|
|
5661
|
-
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type
|
|
5655
|
+
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, nodeStreamToCompactNodes, objectToQuery, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|