@loro-dev/flock 3.1.0 → 4.0.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 +20 -2
- package/dist/index.d.ts +20 -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 +6 -0
- package/src/_moon_flock.ts +8180 -7808
- package/src/index.ts +391 -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,6 +144,14 @@ 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;
|
|
139
156
|
version(): VersionVector;
|
|
140
157
|
private exportJsonInternal;
|
|
@@ -147,6 +164,7 @@ declare class Flock {
|
|
|
147
164
|
private importJsonWithHooks;
|
|
148
165
|
importJson(bundle: ExportBundle): ImportReport;
|
|
149
166
|
importJson(options: ImportOptions): Promise<ImportReport>;
|
|
167
|
+
importJsonStr(bundle: string): ImportReport;
|
|
150
168
|
getMaxPhysicalTime(): number;
|
|
151
169
|
peerId(): string;
|
|
152
170
|
digest(): string;
|
|
@@ -157,5 +175,5 @@ declare class Flock {
|
|
|
157
175
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
158
176
|
}
|
|
159
177
|
//#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 };
|
|
178
|
+
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
179
|
//# 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,6 +144,14 @@ 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;
|
|
139
156
|
version(): VersionVector;
|
|
140
157
|
private exportJsonInternal;
|
|
@@ -147,6 +164,7 @@ declare class Flock {
|
|
|
147
164
|
private importJsonWithHooks;
|
|
148
165
|
importJson(bundle: ExportBundle): ImportReport;
|
|
149
166
|
importJson(options: ImportOptions): Promise<ImportReport>;
|
|
167
|
+
importJsonStr(bundle: string): ImportReport;
|
|
150
168
|
getMaxPhysicalTime(): number;
|
|
151
169
|
peerId(): string;
|
|
152
170
|
digest(): string;
|
|
@@ -157,5 +175,5 @@ declare class Flock {
|
|
|
157
175
|
subscribe(listener: (batch: EventBatch) => void): () => void;
|
|
158
176
|
}
|
|
159
177
|
//#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 };
|
|
178
|
+
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
179
|
//# sourceMappingURL=index.d.ts.map
|