yjs_dart 1.1.0
yjs_dart: ^1.1.0 copied to clipboard
A pure Dart translation of the Yjs CRDT library (yjs v14.0.0-22) and y-protocols (v1.0.5), with no external dependencies. Maintains a 1:1 structural mapping to the JavaScript source for easy diff-base [...]
Yjs Dart #
A pure Dart port of the Yjs CRDT library. This project follows the official JavaScript implementation closely to ensure compatibility and correctness.
Parity Status: Based on yjs v14.0.0-22 and y-protocols v1.0.5.
Features #
- Full CRDT support: Text, Arrays, Maps, and XML elements.
- Binary compatibility: 100% compatible with Yjs binary encoding (v1 & v2).
- Protocols: Sync, Awareness, and Auth protocols implemented.
- Zero dependencies: Built with standard Dart libraries only.
- Undo/Redo: Full
UndoManagerimplementation.
Installation #
dart pub add yjs
Usage #
import 'package:yjs/yjs.dart';
final doc = Doc();
final text = doc.getText('name');
text.observe((event, transaction) {
print(text.toString());
});
text.insert(0, 'Hello World');
Javascript Parity #
This library aims for 1:1 parity with the official JavaScript client.
| Feature | Status | Notes |
|---|---|---|
| Doc | ✅ Supported | Full implementation |
| Transaction | ✅ Supported | Full implementation |
| Shared Types | ✅ Supported | YArray, YMap, YText, YXml supported via YType |
| StructStore | ✅ Supported | Binary search optimized |
| UndoManager | ✅ Supported | Full stack management |
| Protocols | ✅ Supported | Sync (v1/v2), Awareness, Auth |
| Binary Encoding | ✅ Supported | Uint8Array optimization |
| Deltas | 🚧 IP | toDelta in progress |
Differences #
- Unified YType: Instead of separate classes for
YArray,YMap,YText, etc., this library uses a singleYTypeclass that handles all shared type operations. This simplifies the codebase while maintaining functionality.
License #
BSD 3-Clause License. Copyright (c) 2026 Jagtesh Chadha.