loro-crdt 1.1.1 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 70c4942: Add base64 build target
8
+ - 35e7ea5: Add changeCount and opCount methods
9
+
3
10
  ## 1.1.1
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,72 @@
1
+ export * from "./loro_wasm";
2
+ export type * from "./loro_wasm";
3
+ import { AwarenessWasm, PeerID, Container, ContainerID, ContainerType, LoroCounter, LoroDoc, LoroList, LoroMap, LoroText, LoroTree, OpId, Value, AwarenessListener } from "./loro_wasm";
4
+ /**
5
+ * @deprecated Please use LoroDoc
6
+ */
7
+ export declare class Loro extends LoroDoc {
8
+ }
9
+ export declare function isContainerId(s: string): s is ContainerID;
10
+ /** Whether the value is a container.
11
+ *
12
+ * # Example
13
+ *
14
+ * ```ts
15
+ * const doc = new LoroDoc();
16
+ * const map = doc.getMap("map");
17
+ * const list = doc.getList("list");
18
+ * const text = doc.getText("text");
19
+ * isContainer(map); // true
20
+ * isContainer(list); // true
21
+ * isContainer(text); // true
22
+ * isContainer(123); // false
23
+ * isContainer("123"); // false
24
+ * isContainer({}); // false
25
+ * ```
26
+ */
27
+ export declare function isContainer(value: any): value is Container;
28
+ /** Get the type of a value that may be a container.
29
+ *
30
+ * # Example
31
+ *
32
+ * ```ts
33
+ * const doc = new LoroDoc();
34
+ * const map = doc.getMap("map");
35
+ * const list = doc.getList("list");
36
+ * const text = doc.getText("text");
37
+ * getType(map); // "Map"
38
+ * getType(list); // "List"
39
+ * getType(text); // "Text"
40
+ * getType(123); // "Json"
41
+ * getType("123"); // "Json"
42
+ * getType({}); // "Json"
43
+ * ```
44
+ */
45
+ export declare function getType<T>(value: T): T extends LoroText ? "Text" : T extends LoroMap<any> ? "Map" : T extends LoroTree<any> ? "Tree" : T extends LoroList<any> ? "List" : T extends LoroCounter ? "Counter" : "Json";
46
+ export declare function newContainerID(id: OpId, type: ContainerType): ContainerID;
47
+ export declare function newRootContainerID(name: string, type: ContainerType): ContainerID;
48
+ /**
49
+ * Awareness is a structure that allows to track the ephemeral state of the peers.
50
+ *
51
+ * If we don't receive a state update from a peer within the timeout, we will remove their state.
52
+ * The timeout is in milliseconds. This can be used to handle the off-line state of a peer.
53
+ */
54
+ export declare class Awareness<T extends Value = Value> {
55
+ inner: AwarenessWasm<T>;
56
+ private peer;
57
+ private timer;
58
+ private timeout;
59
+ private listeners;
60
+ constructor(peer: PeerID, timeout?: number);
61
+ apply(bytes: Uint8Array, origin?: string): void;
62
+ setLocalState(state: T): void;
63
+ getLocalState(): T | undefined;
64
+ getAllStates(): Record<PeerID, T>;
65
+ encode(peers: PeerID[]): Uint8Array;
66
+ encodeAll(): Uint8Array;
67
+ addListener(listener: AwarenessListener): void;
68
+ removeListener(listener: AwarenessListener): void;
69
+ peers(): PeerID[];
70
+ destroy(): void;
71
+ private startTimerIfNotEmpty;
72
+ }