1.4.6 β€’ Published 4 months ago

loro-crdt v1.4.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Loro is a CRDTs(Conflict-free Replicated Data Types) library that makes building local-first and collaborative apps easier. You can now use it in Rust, JS (via WASM), and Swift.

Features

Features Provided by CRDTs

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

Supported CRDT Algorithms

Advanced Features in Loro

In this example, we demonstrate importing an entire Loro codebase into a Loro-powered version controller, preserving the complete Git DAG history while enabling fast version switching.

Example

Open in StackBlitz

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

test('sync example', () => {
  // Sync two docs with two rounds of exchanges

  // Initialize document A
  const docA = new LoroDoc();
  const listA: LoroList = docA.getList('list');
  listA.insert(0, 'A');
  listA.insert(1, 'B');
  listA.insert(2, 'C');

  // Export all updates from docA
  const bytes: Uint8Array = docA.export({ mode: 'update' });

  // Simulate sending `bytes` across the network to another peer, B

  const docB = new LoroDoc();
  // Peer B imports the updates from A
  docB.import(bytes);

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

  // Get the current version of docB
  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 sync point
  const bytesB: Uint8Array = docB.export({ mode: 'update', from: version });

  // Simulate sending `bytesB` back across the network to A

  // A imports the updates from B
  docA.import(bytesB);

  // A has the same state as B
  expect(docA.toJSON()).toStrictEqual({
    list: ['A', 'C'],
  });
});

Blog

Credits

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

  • Diamond-types: The Event Graph Walker (Eg-walker) 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 work.
  • 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.2.0

7 months ago

1.2.7

6 months ago

1.2.6

6 months ago

1.2.5

6 months ago

1.2.4

7 months ago

1.2.3

7 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.1.4

7 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.4.6

4 months ago

1.4.5

4 months ago

1.0.9

8 months ago

1.4.4

4 months ago

1.4.3

5 months ago

1.4.2

5 months ago

1.4.1

5 months ago

1.4.0

5 months ago

1.1.3-alpha.0

8 months ago

1.3.5

5 months ago

1.3.4

5 months ago

1.3.3

5 months ago

1.3.2

5 months ago

1.3.1

6 months ago

1.3.0

6 months ago

1.0.8

8 months ago

1.0.8-alpha.0

8 months ago

1.0.8-alpha.1

8 months ago

1.0.8-alpha.2

8 months ago

1.0.8-alpha.3

8 months ago

1.0.7

9 months ago

1.0.0-beta.5

9 months ago

1.0.0-alpha.5

9 months ago

1.0.0-alpha.4

9 months ago

1.0.0-alpha.3

10 months ago

1.0.0-alpha.2

10 months ago

1.0.0-alpha.1

10 months ago

1.0.0-alpha.0

10 months ago

0.16.10

11 months ago

0.16.11

10 months ago

0.16.12

10 months ago

0.16.8

11 months ago

0.16.9

11 months ago

1.0.0-beta.2

9 months ago

1.0.0-beta.3

9 months ago

1.0.0-beta.4

9 months ago

1.0.0-beta.1

9 months ago

0.15.5-alpha.0

1 year ago

0.16.3

1 year ago

0.16.4

1 year ago

0.16.5

1 year ago

0.16.6

1 year ago

0.16.7

12 months ago

0.16.0

1 year ago

0.16.1

1 year ago

0.16.2

1 year ago

0.16.4-alpha.0

1 year ago

0.15.4

1 year ago

0.15.3

1 year ago

0.4.0-alpha.0

1 year ago

0.15.2

1 year ago

0.15.1

1 year ago

0.15.0

1 year ago

0.14.6

1 year ago

0.14.5

1 year ago

0.14.4

1 year ago

0.14.3

1 year ago

0.14.1

1 year ago

0.14.2

1 year ago

0.14.0

1 year ago

0.13.1

1 year ago

0.13.0

1 year ago

0.12.0

1 year ago

0.11.1

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.9.4

1 year ago

0.10.0

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago

0.8.0

2 years ago

0.7.2-alpha.2

2 years ago

0.7.2-alpha.3

2 years ago

0.7.2-alpha.4

2 years ago

0.7.2-alpha.0

2 years ago

0.7.2-alpha.1

2 years ago

0.7.1

2 years ago

0.6.5

2 years ago

0.7.0

2 years ago

0.6.4

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.6.1

2 years ago

0.4.3

2 years ago

0.6.0

2 years ago

0.4.2

2 years ago

0.4.0

2 years ago

0.2.8-alpha-1

2 years ago

0.2.8-alpha

2 years ago

0.3.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago