From 2e21859626e69d992d4dff21338487d372097cb0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 31 Dec 2025 15:06:25 +0900 Subject: feat(crdt): add Automerge document lifecycle management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement document-manager.ts with core CRDT operations: - Document creation, update, merge, save/load functions - Conversion functions between local entities and CRDT documents - Actor ID management for client identification - Conflict detection utilities Completes Phase 1 of CRDT implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/client/sync/crdt/index.ts | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/client/sync/crdt/index.ts (limited to 'src/client/sync/crdt/index.ts') diff --git a/src/client/sync/crdt/index.ts b/src/client/sync/crdt/index.ts new file mode 100644 index 0000000..fa296bd --- /dev/null +++ b/src/client/sync/crdt/index.ts @@ -0,0 +1,69 @@ +/** + * CRDT Module + * + * This module provides Automerge CRDT-based sync functionality for Kioku. + * It enables conflict-free synchronization of data between clients and server. + */ + +// Document lifecycle management +export { + // Core document operations + applyChanges, + // Entity to/from CRDT document conversions + cardToCrdtDocument, + crdtDocumentToCard, + crdtDocumentToDeck, + crdtDocumentToNote, + crdtDocumentToNoteFieldType, + crdtDocumentToNoteFieldValue, + crdtDocumentToNoteType, + crdtDocumentToReviewLog, + createDocument, + // Generic entity conversion + createDocumentFromEntity, + createEmptyDocument, + // Types + type DocumentChange, + type DocumentSnapshot, + deckToCrdtDocument, + // Actor ID management + getActorId, + getChanges, + // Conflict detection and utilities + getLastModified, + hasConflicts, + initDocumentWithActor, + isDeleted, + loadDocument, + loadIncremental, + type MergeResult, + mergeDocuments, + noteFieldTypeToCrdtDocument, + noteFieldValueToCrdtDocument, + noteToCrdtDocument, + noteTypeToCrdtDocument, + reviewLogToCrdtDocument, + saveDocument, + saveIncremental, + updateDocument, +} from "./document-manager"; +// Type definitions +export { + type CrdtCardDocument, + type CrdtDeckDocument, + type CrdtDocument, + type CrdtDocumentMap, + CrdtEntityType, + type CrdtEntityTypeValue, + type CrdtMetadata, + type CrdtNoteDocument, + type CrdtNoteFieldTypeDocument, + type CrdtNoteFieldValueDocument, + type CrdtNoteTypeDocument, + type CrdtReviewLogDocument, + createCrdtMetadata, + createDeletedCrdtMetadata, + createDocumentId, + type DocumentId, + parseDocumentId, +} from "./types"; -- cgit v1.2.3-70-g09d2