loro-crdt 0.16.4 β 0.16.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -4
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,8 +1,141 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://loro.dev">
|
|
3
|
+
<picture>
|
|
4
|
+
<img src="./docs/Loro.svg" width="200"/>
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
<h1 align="center">
|
|
9
|
+
<a href="https://loro.dev" alt="loro-site">Loro</a>
|
|
10
|
+
</h1>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<b>Reimagine state management with CRDTs π¦</b><br/>
|
|
13
|
+
Make your app state synchronized and collaborative effortlessly.
|
|
14
|
+
</p>
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://trendshift.io/repositories/4964" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4964" alt="loro-dev%2Floro | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
17
|
+
</p>
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://loro.dev/docs">
|
|
20
|
+
<b>Documentation</b>
|
|
21
|
+
</a>
|
|
22
|
+
|
|
|
23
|
+
<a href="https://loro.dev/docs/tutorial/get_started">
|
|
24
|
+
<b>Getting Started</b>
|
|
25
|
+
</a>
|
|
26
|
+
|
|
|
27
|
+
<a href="https://docs.rs/loro">
|
|
28
|
+
<b>Rust Doc</b>
|
|
29
|
+
</a>
|
|
30
|
+
</p>
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a aria-label="X" href="https://x.com/loro_dev" target="_blank">
|
|
33
|
+
<img alt="" src="https://img.shields.io/badge/Twitter-black?style=for-the-badge&logo=Twitter">
|
|
34
|
+
</a>
|
|
35
|
+
<a aria-label="Discord-Link" href="https://discord.gg/tUsBSVfqzf" target="_blank">
|
|
36
|
+
<img alt="" src="https://img.shields.io/badge/Discord-black?style=for-the-badge&logo=discord">
|
|
37
|
+
</a>
|
|
38
|
+
</p>
|
|
2
39
|
|
|
3
|
-
Loro CRDTs is a high-performance CRDT framework.
|
|
4
40
|
|
|
5
|
-
|
|
41
|
+
https://github.com/loro-dev/loro/assets/18425020/fe246c47-a120-44b3-91d4-1e7232a5b4ac
|
|
6
42
|
|
|
7
|
-
Learn more at https://loro.dev
|
|
8
43
|
|
|
44
|
+
> β οΈ **Notice**: The current API and encoding schema of Loro are **experimental** and **subject to change**. You should not use it in production.
|
|
45
|
+
|
|
46
|
+
Loro is a [CRDTs(Conflict-free Replicated Data Types)](https://crdt.tech/) library that makes building [local-first apps][local-first] easier. It is currently available for JavaScript (via WASM) and Rust developers.
|
|
47
|
+
|
|
48
|
+
Explore our vision in our blog: [**β¨ Reimagine State Management with CRDTs**](https://loro.dev/blog/loro-now-open-source).
|
|
49
|
+
|
|
50
|
+
# Features
|
|
51
|
+
|
|
52
|
+
**Basic Features Provided by CRDTs**
|
|
53
|
+
|
|
54
|
+
- P2P Synchronization
|
|
55
|
+
- Automatic Merging
|
|
56
|
+
- Local Availability
|
|
57
|
+
- Scalability
|
|
58
|
+
- Delta Updates
|
|
59
|
+
|
|
60
|
+
**Supported CRDT Algorithms**
|
|
61
|
+
|
|
62
|
+
- π Text Editing with [Fugue]
|
|
63
|
+
- π [Peritext-like Rich Text CRDT](https://loro.dev/blog/loro-richtext)
|
|
64
|
+
- π² [Moveable Tree](https://loro.dev/docs/tutorial/tree)
|
|
65
|
+
- π [Moveable List](https://loro.dev/docs/tutorial/list)
|
|
66
|
+
- πΊοΈ [Last-Write-Wins Map](https://loro.dev/docs/tutorial/map)
|
|
67
|
+
- π [Replayable Event Graph](https://loro.dev/docs/advanced/replayable_event_graph)
|
|
68
|
+
|
|
69
|
+
**Advanced Features in Loro**
|
|
70
|
+
|
|
71
|
+
- π Preserve Editing History in a [Replayable Event Graph](https://loro.dev/docs/advanced/replayable_event_graph)
|
|
72
|
+
- β±οΈ Fast [Time Travel](https://loro.dev/docs/tutorial/time_travel) Through History
|
|
73
|
+
|
|
74
|
+
https://github.com/loro-dev/loro/assets/18425020/ec2d20a3-3d8c-4483-a601-b200243c9792
|
|
75
|
+
|
|
76
|
+
# Example
|
|
77
|
+
|
|
78
|
+
[](https://stackblitz.com/edit/loro-basic-test?file=test%2Floro-sync.test.ts)
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { expect, test } from 'vitest';
|
|
82
|
+
import { Loro, LoroList } from 'loro-crdt';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Demonstrates synchronization of two documents with two rounds of exchanges.
|
|
86
|
+
*/
|
|
87
|
+
// Initialize document A
|
|
88
|
+
const docA = new Loro();
|
|
89
|
+
const listA: LoroList = docA.getList('list');
|
|
90
|
+
listA.insert(0, 'A');
|
|
91
|
+
listA.insert(1, 'B');
|
|
92
|
+
listA.insert(2, 'C');
|
|
93
|
+
|
|
94
|
+
// Export the state of document A as a byte array
|
|
95
|
+
const bytes: Uint8Array = docA.exportFrom();
|
|
96
|
+
|
|
97
|
+
// Simulate sending `bytes` across the network to another peer, B
|
|
98
|
+
const docB = new Loro();
|
|
99
|
+
// Peer B imports the updates from A
|
|
100
|
+
docB.import(bytes);
|
|
101
|
+
|
|
102
|
+
// Verify that B's state matches A's state
|
|
103
|
+
expect(docB.toJSON()).toStrictEqual({
|
|
104
|
+
list: ['A', 'B', 'C'],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Get the current operation log version of document B
|
|
108
|
+
const version = docB.oplogVersion();
|
|
109
|
+
|
|
110
|
+
// Simulate editing at B: delete item 'B'
|
|
111
|
+
const listB: LoroList = docB.getList('list');
|
|
112
|
+
listB.delete(1, 1);
|
|
113
|
+
|
|
114
|
+
// Export the updates from B since the last synchronization point
|
|
115
|
+
const bytesB: Uint8Array = docB.exportFrom(version);
|
|
116
|
+
|
|
117
|
+
// Simulate sending `bytesB` back across the network to A
|
|
118
|
+
// A imports the updates from B
|
|
119
|
+
docA.import(bytesB);
|
|
120
|
+
|
|
121
|
+
// Verify that the list at A now matches the list at B after merging
|
|
122
|
+
expect(docA.toJSON()).toStrictEqual({
|
|
123
|
+
list: ['A', 'C'],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
# Credits
|
|
128
|
+
|
|
129
|
+
Loro draws inspiration from the innovative work of the following projects and individuals:
|
|
130
|
+
|
|
131
|
+
- [Ink & Switch](https://inkandswitch.com/): The principles of Local-first Software have greatly influenced this project. The [Peritext](https://www.inkandswitch.com/peritext/) project has also shaped our approach to rich text CRDTs.
|
|
132
|
+
- [Diamond-types](https://github.com/josephg/diamond-types): The [Replayable Event Graph (REG)](https://loro.dev/docs/advanced/replayable_event_graph) algorithm from @josephg has been adapted to reduce the computation and space usage of CRDTs.
|
|
133
|
+
- [Automerge](https://github.com/automerge/automerge): Their use of columnar encoding for CRDTs has informed our strategies for efficient data encoding.
|
|
134
|
+
- [Yjs](https://github.com/yjs/yjs): We have incorporated a similar algorithm for effectively merging collaborative editing operations, thanks to their pioneering works.
|
|
135
|
+
- [Matthew Weidner](https://mattweidner.com/): His work on the [Fugue](https://arxiv.org/abs/2305.00583) algorithm has been invaluable, enhancing our text editing capabilities.
|
|
136
|
+
- [Martin Kleppmann](https://martin.kleppmann.com/): His work on CRDTs has significantly influenced our comprehension of the field.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
[local-first]: https://www.inkandswitch.com/local-first/
|
|
140
|
+
[Fugue]: https://arxiv.org/abs/2305.00583
|
|
141
|
+
[Peritext]: https://www.inkandswitch.com/peritext/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loro-crdt",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
4
4
|
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crdt",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"sync",
|
|
11
11
|
"p2p"
|
|
12
12
|
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/loro-dev/loro.git"
|
|
16
|
+
},
|
|
13
17
|
"main": "dist/loro.js",
|
|
14
18
|
"module": "dist/loro.mjs",
|
|
15
19
|
"typings": "dist/loro.d.ts",
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
"homepage": "https://loro.dev",
|
|
18
22
|
"license": "MIT",
|
|
19
23
|
"dependencies": {
|
|
20
|
-
"loro-wasm": "0.16.
|
|
24
|
+
"loro-wasm": "0.16.6"
|
|
21
25
|
},
|
|
22
26
|
"devDependencies": {
|
|
23
27
|
"@rollup/plugin-node-resolve": "^15.0.1",
|