Overview of Moonbit Loro Codec
maindocs/encoding.md of the main repository) and aims for end-to-end interoperability between Rust and Moonbit implementations.repository·main·Indexed 26 days ago
https://github.com/loro-dev/loroA Conflict-free Replicated Data Types (CRDTs) library for building local-first, collaborative applications. It supports Rust, JavaScript (via WASM and a pure TypeScript implementation in loro.js), and Swift. Loro provides automatic merging, P2P synchronization, and version control for data types including text, rich text, trees, lists, and maps. Key features include time travel, shallow snapshots, and incremental updates via VersionVectors.
docs/encoding.md of the main repository) and aims for end-to-end interoperability between Rust and Moonbit implementations.Loro is a Conflict-free Replicated Data Types (CRDTs) library designed for building local-first and collaborative applications. It supports Rust, JavaScript (via WASM), and Swift.
Key features include:
loro-crdt-map package provides WebAssembly source maps for the loro-crdt package. These source maps are split into different targets: bundler, nodejs, and web. They are hosted on unpkg to allow browsers and development tools to load them on demand via the sourceMappingURL metadata embedded in loro_wasm_bg.wasm, preventing the main npm distribution from becoming bloated.generic-btree crate provides a pure, safe B-Tree implementation designed to be used as a building block for custom, special-purpose B-Tree data structures. It is primarily optimized for the performance requirements of Loro CRDT components.loro-common crate provides the fundamental basic types used across the Loro project. It serves as a shared dependency for core components, specifically loro-internal and loro-preload.docs/encoding.md) using Moonbit. The implementation focuses on ensuring cross-language interoperability between Rust and Moonbit.When designing systems with Loro, keep the following architectural tradeoffs in mind:
loro.js is an experimental TypeScript implementation designed for wire and API compatibility with the Rust loro-crdt package.
LoroDoc.fromSnapshot().diff() preserves parent-before-child ordering, but independent containers at the same depth may appear in a different order than Rust's internal hash-map iteration.UndoManager uses ID-span-based semantic undo for sequence edits and common map/tree/counter changes. Style-only rich-text edits and movable-list move/set undo use simplified behavior.subscribeJsonpath() uses broad invalidation and may produce false positives.Recommendation: Treat the package as experimental when handling data from untrusted or older clients.
Loro utilizes Run Length Encoding (RLE) not only for data encoding but also within its internal vec and tree structures. This allows elements to be merged, sliced, and assigned lengths.
Rle trait is used to express these capabilities. The following types implement the Rle trait:OpChangeRleTreeLoro is transitioning from a split architecture (crates/loro as a public facade and crates/loro-internal as the engine) into a single canonical crate named loro.
Key architectural changes include:
loro will become the sole published Rust crate for the core implementation.LoroDoc, container/value, diff, and event surfaces to remove runtime overhead caused by facade-to-engine conversions.LoroDoc::new() preserves current auto-commit behaviors and that loro-wasm remains functional.Developers using loro-wasm or low-level internal APIs should prepare for a migration as loro-internal is phased out in favor of loro.
Change and Op data structures designed for re-encoding (decode $\rightarrow$ encode) and testing (Golden tests). These structures are intended to carry the core semantics of ChangeBlock (metadata + sequence of operations) and are designed to be serializable into stable JSON for comparison with Rust-side outputs.Loro is a CRDT framework designed for local-first applications that prioritize eventual consistency over strict coordination.
Use Loro when building:
Avoid Loro for: