Foreign Function Interface (FFI) bindings for Loro, a high-performance CRDT library for building collaborative applications.
Loro FFI provides cross-language bindings for the Loro CRDT library, enabling developers to use Loro's powerful collaborative editing capabilities in various programming languages. Built with UniFFI, this library generates clean, idiomatic bindings for multiple target languages.
- loro-swift: Swift Binding for Loro
- loro-py: Python Binding (pyo3) for Loro
- loro-react-native: React Native Turbo Module Binding for Loro
- loro-cs: C# Binding for Loro (community)
- loro-go: Go Binding for Loro (community)
Read the UniFFI documentation and modify the uniffi.toml configuration in this repository as needed.
Add this repository as a git submodule for your bindings:
git submodule add https://github.com/loro-dev/loro-ffi.git loro-ffi
git add .gitmodules loro-ffi
Build language-specific wrapper layers around the current UniFFI binding results to provide a better developer experience, including but not limited to:
-
Callback Function Wrapping: Provide direct closure support for functions that require callback parameters, such as
LoroDoc::subscribe()
,UndoManager::set_on_push()
, andEphemeralStore::subscribe()
. -
Native Type Extensions: Implement
LoroValueLike
ContainerIdLike
extensions for built-in types in target languages, enabling direct parameter usage:LoroMap.insert("key", "value"); LoroMap.insert("key", 123); LoroMap.insert("key", true); LoroMap.insert("key", [1, 2, 3]); // ... and more
-
Unified Export Interface: Create a unified entry point for
LoroDoc::export
:class LoroDoc { function export(mode: ExportMode) { // Wraps: // exportSnapshot() // exportUpdates(from) // exportUpdatesInRange(spans) // exportShallowSnapshot(frontiers) // exportStateOnly(frontiers) // exportSnapshotAt(frontiers) } }
-
Unified Container Creation Interface: Provide unified entry points for creating child containers in
LoroMap
/LoroList
/LoroMovableList
:class LoroMap { function insertContainer(key: string, child: Container) { // Wraps: // insertListContainer // insertMapContainer // insertTextContainer // insertTreeContainer // insertMovableListContainer // insertCounterContainer } function getOrCreateContainer() {} // ... and more }
-
Standard Language Interfaces: Implement essential interfaces (equality, comparison, ordering, etc.) for necessary data types as required by target programming languages.
-
Additional Enhancements: And many other improvements to enhance usability and developer experience.
- Discord: Join our Discord server
- Twitter: @loro_dev
This project is licensed under the MIT License - see the LICENSE file for details.