@loro-dev/flock 1.1.1 → 2.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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/_moon_flock.ts +5683 -4709
- package/src/index.ts +11 -11
- package/src/moonbit.d.ts +57 -0
package/src/index.ts
CHANGED
|
@@ -75,7 +75,7 @@ export type ExportRecord = {
|
|
|
75
75
|
m?: MetadataMap;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
export type ExportBundle = Record<string, ExportRecord
|
|
78
|
+
export type ExportBundle = { version: number, entries: Record<string, ExportRecord> };
|
|
79
79
|
|
|
80
80
|
export type EntryClock = {
|
|
81
81
|
physicalTime: number;
|
|
@@ -495,9 +495,9 @@ function decodeImportReport(raw: unknown): ImportReport {
|
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
function cloneBundle(bundle: ExportBundle): ExportBundle {
|
|
498
|
-
const next: ExportBundle = {};
|
|
499
|
-
for (const [key, record] of Object.entries(bundle)) {
|
|
500
|
-
next[key] = cloneRecord(record);
|
|
498
|
+
const next: ExportBundle = { version: bundle.version, entries: {} };
|
|
499
|
+
for (const [key, record] of Object.entries(bundle.entries)) {
|
|
500
|
+
next.entries[key] = cloneRecord(record);
|
|
501
501
|
}
|
|
502
502
|
return next;
|
|
503
503
|
}
|
|
@@ -634,8 +634,8 @@ export class Flock {
|
|
|
634
634
|
if (!transform) {
|
|
635
635
|
return base;
|
|
636
636
|
}
|
|
637
|
-
const result: ExportBundle = {};
|
|
638
|
-
for (const [key, record] of Object.entries(base)) {
|
|
637
|
+
const result: ExportBundle = { version: base.version, entries: {} };
|
|
638
|
+
for (const [key, record] of Object.entries(base.entries)) {
|
|
639
639
|
const context = buildContext(key, record);
|
|
640
640
|
const basePayload = createExportPayload(record);
|
|
641
641
|
const workingPayload = clonePayload(basePayload);
|
|
@@ -644,7 +644,7 @@ export class Flock {
|
|
|
644
644
|
basePayload,
|
|
645
645
|
transformed ?? workingPayload,
|
|
646
646
|
);
|
|
647
|
-
result[key] = buildRecord(record.c, finalPayload);
|
|
647
|
+
result.entries[key] = buildRecord(record.c, finalPayload);
|
|
648
648
|
}
|
|
649
649
|
return result;
|
|
650
650
|
}
|
|
@@ -674,8 +674,8 @@ export class Flock {
|
|
|
674
674
|
const working = preprocess ? cloneBundle(options.bundle) : options.bundle;
|
|
675
675
|
const skippedByHooks: Array<{ key: KeyPart[]; reason: string }> = [];
|
|
676
676
|
if (preprocess) {
|
|
677
|
-
for (const key of Object.keys(working)) {
|
|
678
|
-
const record = working[key];
|
|
677
|
+
for (const key of Object.keys(working.entries)) {
|
|
678
|
+
const record = working.entries[key];
|
|
679
679
|
if (!record) {
|
|
680
680
|
continue;
|
|
681
681
|
}
|
|
@@ -685,10 +685,10 @@ export class Flock {
|
|
|
685
685
|
const normalized = normalizeImportDecision(decision);
|
|
686
686
|
if (!normalized.accept) {
|
|
687
687
|
skippedByHooks.push({ key: context.key, reason: normalized.reason });
|
|
688
|
-
delete working[key];
|
|
688
|
+
delete working.entries[key];
|
|
689
689
|
continue;
|
|
690
690
|
}
|
|
691
|
-
working[key] = buildRecord(record.c, basePayload);
|
|
691
|
+
working.entries[key] = buildRecord(record.c, basePayload);
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
694
|
const coreReport = this.importJsonInternal(working);
|
package/src/moonbit.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A non-public unique symbol used to mark the brand of a type.
|
|
3
|
+
* And avoid user to construct values of the type.
|
|
4
|
+
*/
|
|
5
|
+
export const __brand: unique symbol;
|
|
6
|
+
|
|
7
|
+
export type Unit = undefined;
|
|
8
|
+
export type Bool = boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A signed integer in 32-bit two's complement format.
|
|
12
|
+
*/
|
|
13
|
+
export type Int = number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An unsigned integer in 32-bit two's complement format.
|
|
17
|
+
*/
|
|
18
|
+
export type UInt = number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A character in the range 0-0x10FFFF.
|
|
22
|
+
*/
|
|
23
|
+
export type Char = number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A byte in the range 0-255.
|
|
27
|
+
*/
|
|
28
|
+
export type Byte = number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Single-precision floating point number.
|
|
32
|
+
*/
|
|
33
|
+
export type Float = number;
|
|
34
|
+
|
|
35
|
+
export type Double = number;
|
|
36
|
+
|
|
37
|
+
export type Int64 = { [__brand]: 568910272 };
|
|
38
|
+
|
|
39
|
+
export type UInt64 = { [__brand]: 689305396 };
|
|
40
|
+
|
|
41
|
+
export type String = string;
|
|
42
|
+
|
|
43
|
+
export type Bytes = Uint8Array;
|
|
44
|
+
|
|
45
|
+
export type FixedArray<T> = T[];
|
|
46
|
+
|
|
47
|
+
export type UnboxedOption<T> =
|
|
48
|
+
| /* Some */ T
|
|
49
|
+
| /* None */ undefined;
|
|
50
|
+
|
|
51
|
+
export type UnboxedOptionAsInt<T> =
|
|
52
|
+
| /* Some */ T
|
|
53
|
+
| /* None */ -1;
|
|
54
|
+
|
|
55
|
+
export type Result<T, E> =
|
|
56
|
+
| /* Ok */ { $tag: 1, _0: T }
|
|
57
|
+
| /* Err */ { $tag: 0, _0: E };
|