Skip to content

Commit 97ae618

Browse files
committed
chore:
1 parent 7fc34d4 commit 97ae618

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"tabWidth": 4,
3-
"useTabs": false
3+
"useTabs": false,
4+
"trailingComma": "none"
45
}

packages/core/src/core/diff.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
isContainer,
55
LoroDoc,
66
LoroMap,
7-
TreeID,
7+
TreeID
88
} from "loro-crdt";
99
import {
1010
ContainerSchemaType,
@@ -21,7 +21,7 @@ import {
2121
LoroTextSchemaType,
2222
LoroTreeSchema,
2323
RootSchemaType,
24-
SchemaType,
24+
SchemaType
2525
} from "../schema";
2626
import { ChangeKinds, InferContainerOptions, type Change } from "./mirror";
2727
import { CID_KEY } from "../constants";
@@ -41,7 +41,7 @@ import {
4141
isStringLike,
4242
isArrayLike,
4343
isTreeID,
44-
defineCidProperty,
44+
defineCidProperty
4545
} from "./utils";
4646

4747
/**
@@ -325,8 +325,8 @@ export function diffText(
325325
container: containerId,
326326
key: "",
327327
value: newState,
328-
kind: "insert",
329-
},
328+
kind: "insert"
329+
}
330330
];
331331
}
332332

@@ -399,7 +399,7 @@ export function diffTree(
399399
changes.push({
400400
container: containerId,
401401
kind: "tree-delete",
402-
target: info.id as TreeID,
402+
target: info.id as TreeID
403403
});
404404
}
405405

@@ -449,7 +449,7 @@ export function diffTree(
449449
for (const c of notifySet) {
450450
c.parent = id;
451451
}
452-
},
452+
}
453453
};
454454
changes.push(c);
455455
notifyWhenParentCreated?.push(c);
@@ -483,7 +483,7 @@ export function diffTree(
483483
kind: "tree-move",
484484
target: id as TreeID,
485485
parent: newInfo.parent as TreeID | undefined,
486-
index: newInfo.index,
486+
index: newInfo.index
487487
});
488488
}
489489

@@ -578,7 +578,7 @@ export function diffMovableList<S extends ArrayLike>(
578578
oldIndex: oldEntry.index,
579579
newIndex,
580580
oldItem: oldEntry.item,
581-
newItem: item,
581+
newItem: item
582582
});
583583
}
584584
}
@@ -591,7 +591,7 @@ export function diffMovableList<S extends ArrayLike>(
591591
container: containerId,
592592
key: index,
593593
value: undefined,
594-
kind: "delete" as const,
594+
kind: "delete" as const
595595
});
596596
}
597597
}
@@ -622,7 +622,7 @@ export function diffMovableList<S extends ArrayLike>(
622622
value: undefined,
623623
kind: "move",
624624
fromIndex: from,
625-
toIndex: target,
625+
toIndex: target
626626
});
627627

628628
const [moved] = order.splice(from, 1);
@@ -643,7 +643,7 @@ export function diffMovableList<S extends ArrayLike>(
643643
container: containerId,
644644
key: newIndex,
645645
value: item,
646-
kind: "insert",
646+
kind: "insert"
647647
},
648648
true,
649649
schema?.itemSchema
@@ -675,7 +675,7 @@ export function diffMovableList<S extends ArrayLike>(
675675
container: containerId,
676676
key: info.newIndex,
677677
value: info.newItem,
678-
kind: "set",
678+
kind: "set"
679679
},
680680
true,
681681
schema?.itemSchema
@@ -744,7 +744,7 @@ export function diffListWithIdSelector<S extends ArrayLike>(
744744
container: containerId,
745745
key: index + offset,
746746
value: undefined,
747-
kind: "delete",
747+
kind: "delete"
748748
});
749749
offset--;
750750
index++;
@@ -779,15 +779,15 @@ export function diffListWithIdSelector<S extends ArrayLike>(
779779
container: containerId,
780780
key: index + offset,
781781
value: undefined,
782-
kind: "delete",
782+
kind: "delete"
783783
});
784784
changes.push(
785785
tryUpdateToContainer(
786786
{
787787
container: containerId,
788788
key: index + offset,
789789
value: newItem,
790-
kind: "insert",
790+
kind: "insert"
791791
},
792792
useContainer,
793793
schema?.itemSchema
@@ -808,7 +808,7 @@ export function diffListWithIdSelector<S extends ArrayLike>(
808808
container: containerId,
809809
key: index + offset,
810810
value: newItem,
811-
kind: "insert",
811+
kind: "insert"
812812
},
813813
useContainer,
814814
schema?.itemSchema
@@ -825,7 +825,7 @@ export function diffListWithIdSelector<S extends ArrayLike>(
825825
container: containerId,
826826
key: index + offset,
827827
value: undefined,
828-
kind: "delete",
828+
kind: "delete"
829829
});
830830
offset--;
831831
index++;
@@ -839,7 +839,7 @@ export function diffListWithIdSelector<S extends ArrayLike>(
839839
container: containerId,
840840
key: index + offset,
841841
value: newItem,
842-
kind: "insert",
842+
kind: "insert"
843843
},
844844
useContainer,
845845
schema?.itemSchema
@@ -928,15 +928,15 @@ export function diffList<S extends ArrayLike>(
928928
container: containerId,
929929
key: i,
930930
value: undefined,
931-
kind: "delete",
931+
kind: "delete"
932932
});
933933
changes.push(
934934
tryUpdateToContainer(
935935
{
936936
container: containerId,
937937
key: i,
938938
value: newState[i],
939-
kind: "insert",
939+
kind: "insert"
940940
},
941941
true,
942942
schema?.itemSchema
@@ -952,7 +952,7 @@ export function diffList<S extends ArrayLike>(
952952
container: containerId,
953953
key: start + overlap,
954954
value: undefined,
955-
kind: "delete",
955+
kind: "delete"
956956
});
957957
}
958958

@@ -965,7 +965,7 @@ export function diffList<S extends ArrayLike>(
965965
container: containerId,
966966
key: insertIndex,
967967
value: newState[insertIndex],
968-
kind: "insert",
968+
kind: "insert"
969969
},
970970
true,
971971
schema?.itemSchema
@@ -1027,7 +1027,7 @@ export function diffMap<S extends ObjectLike>(
10271027
container: containerId,
10281028
key,
10291029
value: undefined,
1030-
kind: "delete",
1030+
kind: "delete"
10311031
});
10321032
}
10331033
}
@@ -1091,15 +1091,15 @@ export function diffMap<S extends ObjectLike>(
10911091
key,
10921092
value: newItem,
10931093
kind: "insert-container",
1094-
childContainerType: containerType,
1094+
childContainerType: containerType
10951095
});
10961096
// Inserted a new value
10971097
} else {
10981098
changes.push({
10991099
container: containerId,
11001100
key,
11011101
value: newItem,
1102-
kind: "insert",
1102+
kind: "insert"
11031103
});
11041104
}
11051105
continue;

packages/core/src/core/loroEventApply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
LoroCounter,
77
LoroEvent,
88
LoroEventBatch,
9-
TreeID,
9+
TreeID
1010
} from "loro-crdt";
1111
import { defineCidProperty, isTreeID } from "./utils";
1212

@@ -480,7 +480,7 @@ function applyTreeDiff(
480480
const node: Node = {
481481
id: d.target as string,
482482
data: {},
483-
children: [],
483+
children: []
484484
};
485485
if (treeId && nodeDataWithCid?.(treeId)) {
486486
const cid = getNodeDataCid?.(treeId, d.target);

packages/core/src/core/mirror.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
LoroMovableList,
1616
LoroText,
1717
LoroTree,
18-
TreeID,
18+
TreeID
1919
} from "loro-crdt";
2020

2121
import { applyEventBatchToState } from "./loroEventApply";
@@ -35,7 +35,7 @@ import {
3535
LoroMapSchemaWithCatchall,
3636
RootSchemaType,
3737
SchemaType,
38-
validateSchema,
38+
validateSchema
3939
} from "../schema";
4040
import {
4141
deepEqual,
@@ -45,7 +45,7 @@ import {
4545
schemaToContainerType,
4646
tryInferContainerType,
4747
getRootContainerByType,
48-
defineCidProperty,
48+
defineCidProperty
4949
} from "./utils";
5050
import { diffContainer, diffTree } from "./diff";
5151
import { CID_KEY } from "../constants";
@@ -78,7 +78,7 @@ export enum SyncDirection {
7878
/**
7979
* Initial sync or manual sync operations
8080
*/
81-
BIDIRECTIONAL = "BIDIRECTIONAL",
81+
BIDIRECTIONAL = "BIDIRECTIONAL"
8282
}
8383

8484
/**
@@ -303,7 +303,7 @@ export class Mirror<S extends SchemaType> {
303303
throwOnValidationError: options.throwOnValidationError || false,
304304
debug: options.debug || false,
305305
checkStateConsistency: options.checkStateConsistency || false,
306-
inferOptions: options.inferOptions || {},
306+
inferOptions: options.inferOptions || {}
307307
};
308308

309309
// Pre-create root containers hinted by initialState (no-op in Loro for roots)
@@ -413,7 +413,7 @@ export class Mirror<S extends SchemaType> {
413413
"loro-list",
414414
"loro-text",
415415
"loro-movable-list",
416-
"loro-tree",
416+
"loro-tree"
417417
].includes(fieldSchema.type)
418418
) {
419419
const containerType =
@@ -591,7 +591,7 @@ export class Mirror<S extends SchemaType> {
591591
return { ...e, path: canon } as typeof e;
592592
}
593593
return e;
594-
}),
594+
})
595595
} as LoroEventBatch;
596596
// Incrementally update state using event deltas
597597
this.state = applyEventBatchToState(
@@ -613,7 +613,7 @@ export class Mirror<S extends SchemaType> {
613613
} catch {
614614
return undefined;
615615
}
616-
},
616+
}
617617
}
618618
) as unknown as InferType<S>;
619619
// With canonicalized paths, applyEventBatchToState updates roots precisely.
@@ -753,7 +753,7 @@ export class Mirror<S extends SchemaType> {
753753
// Process changes by container
754754
for (const [
755755
containerId,
756-
containerChanges,
756+
containerChanges
757757
] of changesByContainer.entries()) {
758758
if (containerId === "") {
759759
// Handle root level changes
@@ -1355,7 +1355,7 @@ export class Mirror<S extends SchemaType> {
13551355
private notifySubscribers(direction: SyncDirection, tags?: string[]) {
13561356
const metadata: UpdateMetadata = {
13571357
direction,
1358-
tags,
1358+
tags
13591359
};
13601360

13611361
for (const subscriber of this.subscribers) {
@@ -1928,7 +1928,7 @@ export class Mirror<S extends SchemaType> {
19281928
) {
19291929
this.containerRegistry.set(containerId, {
19301930
schema: schemaType,
1931-
registered: true,
1931+
registered: true
19321932
});
19331933
}
19341934

@@ -2135,7 +2135,7 @@ function mergeInitialIntoBaseWithSchema(
21352135
options: {},
21362136
getContainerType() {
21372137
return "Map";
2138-
},
2138+
}
21392139
} as unknown as RootSchemaType<Record<string, ContainerSchemaType>>);
21402140
continue;
21412141
}

0 commit comments

Comments
 (0)