loro-wasm

Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.

MIT 81 个版本
安装
npm install loro-wasm
yarn add loro-wasm
pnpm add loro-wasm
bun add loro-wasm
README

Loro

Reimagine state management with CRDTs 🦜
Make your app state synchronized and collaborative effortlessly.

Documentation | Getting Started | Rust Doc

https://github.com/loro-dev/loro/assets/18425020/fe246c47-a120-44b3-91d4-1e7232a5b4ac

Loro is a CRDTs(Conflict-free Replicated Data Types) library that makes building local-first apps easier. It is currently available for JavaScript (via WASM) and Rust developers.

Explore our vision in our blog: ✨ Reimagine State Management with CRDTs.

Features

Basic Features Provided by CRDTs

  • P2P Synchronization
  • Automatic Merging
  • Local Availability
  • Scalability
  • Delta Updates

Supported CRDT Algorithms

Advanced Features in Loro

https://github.com/loro-dev/loro/assets/18425020/ec2d20a3-3d8c-4483-a601-b200243c9792

Example

Open in StackBlitz

import { expect, test } from 'vitest';
import { Loro, LoroList } from 'loro-crdt';

/**
 * Demonstrates synchronization of two documents with two rounds of exchanges.
 */
// Initialize document A
const docA = new Loro();
const listA: LoroList = docA.getList('list');
listA.insert(0, 'A');
listA.insert(1, 'B');
listA.insert(2, 'C');

// Export the state of document A as a byte array
const bytes: Uint8Array = docA.exportFrom();

// Simulate sending `bytes` across the network to another peer, B
const docB = new Loro();
// Peer B imports the updates from A
docB.import(bytes);

// Verify that B's state matches A's state
expect(docB.toJSON()).toStrictEqual({
  list: ['A', 'B', 'C'],
});

// Get the current operation log version of document B
const version = docB.oplogVersion();

// Simulate editing at B: delete item 'B'
const listB: LoroList = docB.getList('list');
listB.delete(1, 1);

// Export the updates from B since the last synchronization point
const bytesB: Uint8Array = docB.exportFrom(version);

// Simulate sending `bytesB` back across the network to A
// A imports the updates from B
docA.import(bytesB);

// Verify that the list at A now matches the list at B after merging
expect(docA.toJSON()).toStrictEqual({
  list: ['A', 'C'],
});

Credits

Loro draws inspiration from the innovative work of the following projects and individuals:

  • Ink & Switch: The principles of Local-first Software have greatly influenced this project. The Peritext project has also shaped our approach to rich text CRDTs.
  • Diamond-types: The Replayable Event Graph (REG) algorithm from @josephg has been adapted to reduce the computation and space usage of CRDTs.
  • Automerge: Their use of columnar encoding for CRDTs has informed our strategies for efficient data encoding.
  • Yjs: We have incorporated a similar algorithm for effectively merging collaborative editing operations, thanks to their pioneering works.
  • Matthew Weidner: His work on the Fugue algorithm has been invaluable, enhancing our text editing capabilities.
  • Martin Kleppmann: His work on CRDTs has significantly influenced our comprehension of the field.
版本列表
1.0.7 2024-10-23
1.0.1 2024-10-23
1.0.0-beta.5 2024-10-22
1.0.0-beta.4 2024-10-19
1.0.0-beta.3 2024-10-19
1.0.0-beta.2 2024-10-17
1.0.0-beta.1 2024-10-16
1.0.0-alpha.5 2024-10-09
1.0.0-alpha.4 2024-10-09
1.0.0-alpha.3 2024-09-24
1.0.0-alpha.2 2024-09-23
1.0.0-alpha.1 2024-09-20
1.0.0-alpha.0 2024-09-12
1.0.0 2024-10-23
0.16.12 2024-09-07
0.16.11 2024-09-05
0.16.10 2024-08-27
0.16.9 2024-08-27
0.16.8 2024-08-27
0.16.7 2024-07-14
0.16.6 2024-06-27
0.16.5 2024-06-21
0.16.4-alpha.0 2024-06-07
0.16.4 2024-06-13
0.16.3 2024-06-06
0.16.2 2024-05-23
0.16.1 2024-05-21
0.16.0 2024-05-20
0.15.5-alpha.0 2024-06-07
0.15.4 2024-05-09
0.15.3 2024-05-09
0.15.2 2024-05-04
0.15.1 2024-05-02
0.15.0 2024-04-26
0.14.6 2024-04-24
0.14.5 2024-04-18
0.14.4 2024-04-17
0.14.3 2024-04-14
0.14.2 2024-04-10
0.14.1 2024-04-09
0.14.0 2024-04-04
0.13.1 2024-03-30
0.13.0 2024-03-30
0.12.0 2024-03-27
0.11.1 2024-02-17
0.11.0 2024-02-10
0.10.1 2024-01-24
0.10.0 2024-01-22
0.9.4 2024-01-21
0.9.3 2024-01-19
0.9.2 2024-01-19
0.9.1 2024-01-18
0.9.0 2024-01-17
0.8.0 2024-01-05
0.7.2-alpha.4 2023-12-27
0.7.2-alpha.3 2023-12-27
0.7.2-alpha.2 2023-12-27
0.7.2-alpha.1 2023-12-26
0.7.2-alpha.0 2023-12-26
0.7.1 2023-12-26
0.7.0 2023-12-08
0.6.5 2023-12-07
0.6.4 2023-12-06
0.6.1 2023-12-05
0.6.0 2023-12-05
0.5.0 2023-11-27
0.4.3 2023-11-16
0.4.2 2023-11-16
0.4.1 2023-11-12
0.4.0-alpha.0 2024-05-05
0.4.0 2023-11-10
0.3.0 2023-05-11
0.2.5 2023-04-06
0.2.4 2023-03-28
0.2.3 2023-03-27
0.2.2 2023-03-24
0.2.1 2023-03-23
0.2.0 2023-03-23
0.1.2 2023-03-22
0.1.1 2023-03-21
0.1.0 2023-03-21