@loro-dev/flock 3.1.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_moon_flock.d.ts +10 -0
- package/src/_moon_flock.ts +8835 -8011
- package/src/index.ts +412 -49
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,11 @@ type VersionVectorEntry = {
|
|
|
14
14
|
physicalTime: number;
|
|
15
15
|
logicalCounter: number;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
interface VersionVector {
|
|
18
|
+
[peer: string]: VersionVectorEntry | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare function encodeVersionVector(vector: VersionVector): Uint8Array;
|
|
21
|
+
declare function decodeVersionVector(bytes: Uint8Array): VersionVector;
|
|
18
22
|
type Value = string | number | boolean | null | Array<Value> | {
|
|
19
23
|
[key: string]: Value;
|
|
20
24
|
};
|
|
@@ -34,6 +38,11 @@ type EntryClock = {
|
|
|
34
38
|
logicalCounter: number;
|
|
35
39
|
peerId: string;
|
|
36
40
|
};
|
|
41
|
+
type EntryInfo = {
|
|
42
|
+
data?: Value;
|
|
43
|
+
metadata: MetadataMap;
|
|
44
|
+
clock: EntryClock;
|
|
45
|
+
};
|
|
37
46
|
type ExportPayload = {
|
|
38
47
|
data?: Value;
|
|
39
48
|
metadata?: MetadataMap;
|
|
@@ -135,8 +144,30 @@ declare class Flock {
|
|
|
135
144
|
*/
|
|
136
145
|
delete(key: KeyPart[], now?: number): void;
|
|
137
146
|
get(key: KeyPart[]): Value | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the full entry payload (data, metadata, and clock) for a key.
|
|
149
|
+
*
|
|
150
|
+
* Unlike `get`, this distinguishes between a missing key (`undefined`) and a
|
|
151
|
+
* tombstone (returns the clock and metadata with `data` omitted). Metadata is
|
|
152
|
+
* cloned and defaults to `{}` when absent.
|
|
153
|
+
*/
|
|
154
|
+
getEntry(key: KeyPart[]): EntryInfo | undefined;
|
|
138
155
|
merge(other: Flock): void;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the exclusive version vector, which only includes peers that have
|
|
158
|
+
* at least one entry in the current state. This is consistent with the state
|
|
159
|
+
* after export and re-import.
|
|
160
|
+
*
|
|
161
|
+
* Use this version when sending to other peers for incremental sync.
|
|
162
|
+
*/
|
|
139
163
|
version(): VersionVector;
|
|
164
|
+
/**
|
|
165
|
+
* Returns the inclusive version vector, which includes all peers ever seen,
|
|
166
|
+
* even if their entries have been overridden by other peers.
|
|
167
|
+
*
|
|
168
|
+
* Use this version when checking if you have received all data from another peer.
|
|
169
|
+
*/
|
|
170
|
+
inclusiveVersion(): VersionVector;
|
|
140
171
|
private exportJsonInternal;
|
|
141
172
|
private exportJsonWithHooks;
|
|
142
173
|
exportJson(): ExportBundle;
|
|
@@ -147,6 +178,7 @@ declare class Flock {
|
|
|
147
178
|
private importJsonWithHooks;
|
|
148
179
|
importJson(bundle: ExportBundle): ImportReport;
|
|
149
180
|
importJson(options: ImportOptions): Promise<ImportReport>;
|
|
181
|
+
importJsonStr(bundle: string): ImportReport;
|
|
150
182
|
getMaxPhysicalTime(): number;
|
|
151
183
|
peerId(): string;
|
|
152
184
|
digest(): string;
|
|
@@ -157,5 +189,5 @@ declare class Flock {
|
|
|
157
189
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
158
190
|
}
|
|
159
191
|
//#endregion
|
|
160
|
-
export { EntryClock, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry };
|
|
192
|
+
export { EntryClock, EntryInfo, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry, decodeVersionVector, encodeVersionVector };
|
|
161
193
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ type VersionVectorEntry = {
|
|
|
14
14
|
physicalTime: number;
|
|
15
15
|
logicalCounter: number;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
interface VersionVector {
|
|
18
|
+
[peer: string]: VersionVectorEntry | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare function encodeVersionVector(vector: VersionVector): Uint8Array;
|
|
21
|
+
declare function decodeVersionVector(bytes: Uint8Array): VersionVector;
|
|
18
22
|
type Value = string | number | boolean | null | Array<Value> | {
|
|
19
23
|
[key: string]: Value;
|
|
20
24
|
};
|
|
@@ -34,6 +38,11 @@ type EntryClock = {
|
|
|
34
38
|
logicalCounter: number;
|
|
35
39
|
peerId: string;
|
|
36
40
|
};
|
|
41
|
+
type EntryInfo = {
|
|
42
|
+
data?: Value;
|
|
43
|
+
metadata: MetadataMap;
|
|
44
|
+
clock: EntryClock;
|
|
45
|
+
};
|
|
37
46
|
type ExportPayload = {
|
|
38
47
|
data?: Value;
|
|
39
48
|
metadata?: MetadataMap;
|
|
@@ -135,8 +144,30 @@ declare class Flock {
|
|
|
135
144
|
*/
|
|
136
145
|
delete(key: KeyPart[], now?: number): void;
|
|
137
146
|
get(key: KeyPart[]): Value | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the full entry payload (data, metadata, and clock) for a key.
|
|
149
|
+
*
|
|
150
|
+
* Unlike `get`, this distinguishes between a missing key (`undefined`) and a
|
|
151
|
+
* tombstone (returns the clock and metadata with `data` omitted). Metadata is
|
|
152
|
+
* cloned and defaults to `{}` when absent.
|
|
153
|
+
*/
|
|
154
|
+
getEntry(key: KeyPart[]): EntryInfo | undefined;
|
|
138
155
|
merge(other: Flock): void;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the exclusive version vector, which only includes peers that have
|
|
158
|
+
* at least one entry in the current state. This is consistent with the state
|
|
159
|
+
* after export and re-import.
|
|
160
|
+
*
|
|
161
|
+
* Use this version when sending to other peers for incremental sync.
|
|
162
|
+
*/
|
|
139
163
|
version(): VersionVector;
|
|
164
|
+
/**
|
|
165
|
+
* Returns the inclusive version vector, which includes all peers ever seen,
|
|
166
|
+
* even if their entries have been overridden by other peers.
|
|
167
|
+
*
|
|
168
|
+
* Use this version when checking if you have received all data from another peer.
|
|
169
|
+
*/
|
|
170
|
+
inclusiveVersion(): VersionVector;
|
|
140
171
|
private exportJsonInternal;
|
|
141
172
|
private exportJsonWithHooks;
|
|
142
173
|
exportJson(): ExportBundle;
|
|
@@ -147,6 +178,7 @@ declare class Flock {
|
|
|
147
178
|
private importJsonWithHooks;
|
|
148
179
|
importJson(bundle: ExportBundle): ImportReport;
|
|
149
180
|
importJson(options: ImportOptions): Promise<ImportReport>;
|
|
181
|
+
importJsonStr(bundle: string): ImportReport;
|
|
150
182
|
getMaxPhysicalTime(): number;
|
|
151
183
|
peerId(): string;
|
|
152
184
|
digest(): string;
|
|
@@ -157,5 +189,5 @@ declare class Flock {
|
|
|
157
189
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
158
190
|
}
|
|
159
191
|
//#endregion
|
|
160
|
-
export { EntryClock, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry };
|
|
192
|
+
export { EntryClock, EntryInfo, Event, EventBatch, EventPayload, ExportBundle, ExportHookContext, ExportHooks, ExportPayload, ExportRecord, Flock, ImportAccept, ImportDecision, ImportHookContext, ImportHooks, ImportPayload, ImportReport, ImportSkip, KeyPart, MetadataMap, PutHookContext, PutHooks, PutPayload, PutWithMetaOptions, ScanBound, ScanOptions, ScanRow, Value, VersionVector, VersionVectorEntry, decodeVersionVector, encodeVersionVector };
|
|
161
193
|
//# sourceMappingURL=index.d.ts.map
|