Skip to content

Commit 05ac679

Browse files
authored
Docs: introduce loro-inspector (#721)
* docs: add intro for loro-inspector * docs: refine structure
1 parent 2450248 commit 05ac679

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,33 @@ Loro is a [CRDTs(Conflict-free Replicated Data Types)](https://crdt.tech/) libra
7070
- 🚀 [Fast Document Loading](https://loro.dev/blog/v1.0)
7171
- ⏱️ Fast [Time Travel](https://loro.dev/docs/tutorial/time_travel) Through History
7272
- 🏛️ [Version Control with Real-Time Collaboration](https://loro.dev/blog/v1.0#version-control)
73-
- 📦 [Shallow Snapshot](https://loro.dev/docs/advanced/shallow_snapshot) that Works like Git Shallow Clone
73+
- 📦 [Shallow Snapshot](https://loro.dev/docs/advanced/shallow_snapshot) that Works like Git Shallow Clone
7474

7575
https://github.com/user-attachments/assets/68e0017a-4987-4f71-b2cf-4ed28a210987
7676

77-
> In this example, we demonstrate importing an entire Loro codebase into a Loro-powered
77+
> In this example, we demonstrate importing an entire Loro codebase into a Loro-powered
7878
> version controller, preserving the complete Git DAG history while enabling fast version switching.
7979
8080
# Example
8181

8282
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/loro-basic-test?file=test%2Floro-sync.test.ts)
8383

8484
```ts
85-
import { expect, test } from 'vitest';
86-
import { LoroDoc, LoroList } from 'loro-crdt';
85+
import { expect, test } from "vitest";
86+
import { LoroDoc, LoroList } from "loro-crdt";
8787

88-
test('sync example', () => {
88+
test("sync example", () => {
8989
// Sync two docs with two rounds of exchanges
9090

9191
// Initialize document A
9292
const docA = new LoroDoc();
93-
const listA: LoroList = docA.getList('list');
94-
listA.insert(0, 'A');
95-
listA.insert(1, 'B');
96-
listA.insert(2, 'C');
93+
const listA: LoroList = docA.getList("list");
94+
listA.insert(0, "A");
95+
listA.insert(1, "B");
96+
listA.insert(2, "C");
9797

9898
// Export all updates from docA
99-
const bytes: Uint8Array = docA.export({ mode: 'update' });
99+
const bytes: Uint8Array = docA.export({ mode: "update" });
100100

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

@@ -106,18 +106,18 @@ test('sync example', () => {
106106

107107
// B's state matches A's state
108108
expect(docB.toJSON()).toStrictEqual({
109-
list: ['A', 'B', 'C'],
109+
list: ["A", "B", "C"],
110110
});
111111

112112
// Get the current version of docB
113113
const version = docB.oplogVersion();
114114

115115
// Simulate editing at B: delete item 'B'
116-
const listB: LoroList = docB.getList('list');
116+
const listB: LoroList = docB.getList("list");
117117
listB.delete(1, 1);
118118

119119
// Export the updates from B since the last sync point
120-
const bytesB: Uint8Array = docB.export({ mode: 'update', from: version });
120+
const bytesB: Uint8Array = docB.export({ mode: "update", from: version });
121121

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

@@ -126,11 +126,20 @@ test('sync example', () => {
126126

127127
// A has the same state as B
128128
expect(docA.toJSON()).toStrictEqual({
129-
list: ['A', 'C'],
129+
list: ["A", "C"],
130130
});
131131
});
132132
```
133133

134+
# DevTools
135+
136+
## Loro Inspector
137+
138+
You can use the [Loro Inspector](https://inspector.loro.dev) to inspect the state and history of a Loro document.
139+
140+
https://github.com/user-attachments/assets/ceeb7450-80ce-42f2-aef4-2e08fa2d1f1b
141+
142+
134143
# Blog
135144

136145
- [Loro 1.0](https://loro.dev/blog/v1.0)
@@ -147,7 +156,6 @@ Loro draws inspiration from the innovative work of the following projects and in
147156
- [Yjs](https://github.com/yjs/yjs): We have incorporated a similar algorithm for effectively merging collaborative editing operations, thanks to their pioneering work.
148157
- [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.
149158
- [Martin Kleppmann](https://martin.kleppmann.com/): His work on CRDTs has significantly influenced our comprehension of the field.
150-
151159

152160
[local-first]: https://www.inkandswitch.com/local-first/
153161
[Fugue]: https://arxiv.org/abs/2305.00583

0 commit comments

Comments
 (0)