You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/tutorial/event.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ with changes in the document state.
19
19
- When `LoroDoc.commit()` is explicitly called
20
20
- Automatically before an import or export operation
21
21
22
-
Starting from `[email protected]`, events are emitted synchronously during the commit cycle. If you are using an older version (<=1.7.x),youwillstillneedtoawaitamicrotaskforthecallbackstofire.
22
+
Starting from `[email protected]`, events are emitted synchronously during the commit cycle. If you are using an older version (`<=1.7.x`), you will still need to await a microtask for the callbacks to fire.
<description><![CDATA[The Loro Protocol multiplexes CRDT sync workloads over one WebSocket connection and ships the open-source loro-websocket, loro-adaptors, plus Rust client and server implementations that speak the same protocol.]]></description>
<p>The open-source Loro Protocol project includes the <code>loro-websocket</code> package, the adaptor suite in <code>loro-adaptors</code>, and matching Rust client and server implementations that all interoperate on the same wire format.</p>
19
+
<p>The <a href="https://github.com/loro-dev/protocol"><strong>Loro Protocol</strong></a> is a wire protocol designed for real-time CRDT synchronization. Learn about the design in detail <a href="https://github.com/loro-dev/protocol/blob/main/protocol.md">here</a>.</p>
20
+
<p>It efficiently runs multiple, independent "rooms" over a single WebSocket connection.</p>
21
+
<p>This allows you to synchronize your application state, such as a Loro document, ephemeral cursor positions, and end-to-end encrypted documents, over one connection. It is also compatible with Yjs.</p>
22
+
<h3>Quick Start: Server & Client Example</h3>
23
+
<p>The protocol is implemented by the <code>loro-websocket</code> client and a minimal <code>SimpleServer</code> for testing. These components are bridged to your CRDT state using <code>loro-adaptors</code>.</p>
24
+
<p><strong>Server</strong></p>
25
+
<p>For development, you can run the <code>SimpleServer</code> (from <code>loro-websocket</code>) in a Node.js environment.</p>
26
+
<pre><code class="language-tsx">// server.ts
27
+
28
+
const server = new SimpleServer({
29
+
port: 8787,
30
+
// SimpleServer accepts hooks for authentication and data persistence:
<p>Each binary message is prefixed with four magic bytes that identify the data type, followed by the <code>roomId</code>. This structure allows the server to route messages to the correct handler. A single client can join:</p>
75
+
<ul>
76
+
<li><code>%LOR</code> (Loro Document)</li>
77
+
<li><code>%EPH</code> (Loro Ephemeral Store, for cursors and presence)</li>
78
+
<li><code>%ELO</code> (End-to-End Encrypted Loro Document)</li>
79
+
<li><code>%YJS</code> and <code>%YAW</code> (for Yjs Document and Awareness interoperability)</li>
80
+
</ul>
81
+
<p>All traffic runs on the same socket.</p>
82
+
<h4>Compatibility</h4>
83
+
<p>The Loro Protocol is designed to accommodate environments like Cloudflare:</p>
84
+
<ul>
85
+
<li>Fragmentation: Large updates are automatically split into fragments under 256 KiB and reassembled by the receiver. This addresses platforms that enforce WebSocket message size limits.</li>
86
+
<li>Application-level keepalive: The protocol defines simple <code>"ping"</code> and <code>"pong"</code> text frames. These bypass the binary envelope and allow the client to check connection liveness, which is useful in browser or serverless environments where transport-level TCP keepalives are not exposed.</li>
87
+
</ul>
88
+
<p>This repository also ships Rust clients and servers that mirror the TypeScript packages.</p>
89
+
<h4>Experimental E2E Encryption</h4>
90
+
<p>End-to-end encrypted Loro is included in <code>loro-protocol</code>, but the feature is currently experimental: expect wire formats and key-management APIs to change, and do not rely on it for production-grade security audits yet. When paired with <code>EloLoroAdaptor</code> on the client, the server relays encrypted records without decrypting them.</p>
91
+
<h3>Status and Licensing</h3>
92
+
<p>The Loro Protocol is mostly stable. We welcome community feedback and contributions, especially regarding use cases that are difficult to satisfy with the current design.</p>
93
+
<p>All the packages in inside <a href="https://github.com/loro-dev/protocol">https://github.com/loro-dev/protocol</a> are open-sourced under the permissive MIT license.</p>
94
+
]]></content:encoded>
95
+
</item>
10
96
<item>
11
97
<title><![CDATA[Loro Mirror: Make UI State Collaborative by Mirroring to CRDTs]]></title>
<p>Like Git, Loro saves a complete directed acyclic graph (DAG) of edit history. In Loro, the DAG is used to represent the dependencies between edits, similar to how Git represents commit history.</p>
490
+
<p>Like Git, Loro saves a complete directed acyclic graph (DAG) of edit history. In Loro, the DAG is used to represent the dependencies between edits, similar to how Git represents commit history.</p>
406
491
<p>Loro supports primitives that allow users to switch between different versions, fork new branches, edit on new branches, and merge branches.</p>
407
492
<p>Based on this operation primitive, applications can build various Git-like capabilities:</p>
408
493
<ul>
@@ -474,7 +559,7 @@ solved through additional libraries.</p>
474
559
475
560
<h3>Leveraging the potential of the <a href="https://arxiv.org/abs/2409.14252">Eg-walker</a></h3>
476
561
<p><a href="/docs/advanced/event_graph_walker">Event Graph Walker (Eg-walker)</a> is a pioneering collaboration algorithm that combines the strengths of
477
-
Operational Transformation (OT) and CRDT, two widely used algorithms for real-time collaboration.</p>
562
+
Operational Transformation (OT) and CRDT, two widely used algorithms for real-time collaboration.</p>
478
563
<p>While OT is centralized and CRDT is decentralized, OT traditionally had an advantage
479
564
in terms of lower document overhead. CRDTs initially had higher overhead, but recent
480
565
optimizations have significantly reduced this gap, making CRDTs increasingly competitive.
@@ -1270,7 +1360,8 @@ CRDTs. Thus, the simplest solution is not to perform any tombstone collection.</
1270
1360
<h3>Brief Introduction to Event Graph Walker</h3>
1271
1361
<p>Eg-walker is a novel CRDT algorithm introduced in:</p>
1272
1362
<blockquote>
1273
-
<p><a href="https://arxiv.org/abs/2409.14252">Collaborative Text Editing with Eg-walker: Better, Faster, Smaller</a><br>By: Joseph Gentle, Martin Kleppmann</p>
1363
+
<p><a href="https://arxiv.org/abs/2409.14252">Collaborative Text Editing with Eg-walker: Better, Faster, Smaller</a>
1364
+
By: Joseph Gentle, Martin Kleppmann</p>
1274
1365
</blockquote>
1275
1366
<p>Eg-walker is a novel CRDT algorithm that combines the strengths of both OT and CRDTs.
1276
1367
It has the distributed nature of CRDT that enables P2P collaboration and data
@@ -1924,7 +2015,7 @@ any proposals for collaboration, please reach out to <a href="mailto:[email protected]
1924
2015
<div style={{ display: "inline" }}>
1925
2016
Loro, our high-performance CRDTs library, is now open source
1926
2017
</div>
1927
-
2018
+
1928
2019
<div style={{ display: "inline" }}>.</div>
1929
2020
</div>
1930
2021
@@ -2010,17 +2101,20 @@ state management tool, Pinia:</p>
2010
2101
}),
2011
2102
getters: {
2012
2103
items: (state): Array<{ name: string; amount: number }> =>
0 commit comments