Skip to content

Commit d100815

Browse files
committed
docs: update llm resources
1 parent 6e32e31 commit d100815

6 files changed

Lines changed: 121 additions & 22 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"highlight.js": "^11.9.0",
4040
"is-equal": "^1.7.0",
4141
"jotai": "^2.6.0",
42-
"loro-crdt": "^1.5.2",
42+
"loro-crdt": "^1.5.10",
4343
"lucide-react": "^0.294.0",
4444
"next": "^13.3.4",
4545
"next-seo": "^5.15.0",

pages/docs/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"concepts": "Concepts",
55
"advanced": "Advanced Topics",
66
"performance": "Performance",
7-
"examples": "Examples"
7+
"examples": "Examples",
8+
"llm": "LLM Resources"
89
}

pages/docs/llm.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# LLM Resouces
2+
3+
- [llms.txt](/llm.txt)
4+
- [llms-full.txt](/llm-full.txt)

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/llms-full.txt

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,7 @@ You can use Loro in your application by using:
32103210
- [`loro`](https://crates.io/crates/loro) Rust crate
32113211
- [`loro-swift`](https://github.com/loro-dev/loro-swift) Swift package
32123212
- [`loro-py`](https://github.com/loro-dev/loro-py) Python package
3213+
- [`loro-cs`](https://github.com/sensslen/loro-cs) Community-maintained C# package
32133214
- You can also find a list of examples in
32143215
[Loro examples in Deno](https://github.com/loro-dev/loro-examples-deno).
32153216

@@ -3242,6 +3243,47 @@ export default defineConfig({
32423243
});
32433244
```
32443245

3246+
<details>
3247+
<summary>⚠️ DOMContentLoaded Timing Issue with Vite</summary>
3248+
3249+
When using Loro with Vite, be aware of module loading timing issues with DOM events:
3250+
3251+
**Problem:** The following code will cause nothing to load on the screen:
3252+
3253+
```ts
3254+
import { LoroDoc } from 'loro-crdt';
3255+
3256+
document.addEventListener("DOMContentLoaded", () => {
3257+
const doc = new LoroDoc();
3258+
// Your code here...
3259+
});
3260+
```
3261+
3262+
**Reason:** This occurs because Vite loads ES modules asynchronously, and the WASM module initialization within `loro-crdt` also happens asynchronously. When you import at the top level but execute code inside `DOMContentLoaded`, the WASM module may not be fully initialized when the event fires, causing the application to fail silently.
3263+
3264+
**Solutions:**
3265+
3266+
1. **Remove the event listener** (recommended for most cases):
3267+
```ts
3268+
import { LoroDoc } from 'loro-crdt';
3269+
3270+
const doc = new LoroDoc();
3271+
// Your code here...
3272+
```
3273+
3274+
2. **Use dynamic import inside the event listener**:
3275+
```ts
3276+
document.addEventListener("DOMContentLoaded", async () => {
3277+
const { LoroDoc } = await import('loro-crdt');
3278+
const doc = new LoroDoc();
3279+
// Your code here...
3280+
});
3281+
```
3282+
3283+
The dynamic import ensures the module and its WASM dependencies are fully loaded before use.
3284+
3285+
</details>
3286+
32453287
If you're using `Next.js`, you should add the following to your next.config.js:
32463288

32473289
```js no-run
@@ -5022,6 +5064,14 @@ For text, you can choose to represent it directly as a Value on a Map (where the
50225064
For Lists, concurrently removing the same element and inserting a single element creates a new element, differentiating from the semantics of Set on a Map (we may consider providing a list set method in the future). For representing coordinates, it's better to use a Map rather than a List. If you represent coordinates as [x, y], and the A client updates the y coordinate by deleting the y element and reinserting a new y_a, and the B client also deletes y and inserts y_b, then after merging, the array will become [x, y_a, y_b], which does not conform to the user's schema. Using a Map can prevent this problem.
50235065

50245066

5067+
# FILE: pages/docs/llm.md
5068+
5069+
# LLM Resouces
5070+
5071+
- [llms.txt](/llm.txt)
5072+
- [llms-full.txt](/llm-full.txt)
5073+
5074+
50255075
# FILE: pages/docs/performance/docsize.md
50265076

50275077
---
@@ -7810,6 +7860,26 @@ export function setDebug(): void;
78107860
* - changeNum
78117861
*/
78127862
export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
7863+
/**
7864+
* Redacts sensitive content in JSON updates within the specified version range.
7865+
*
7866+
* This function allows you to share document history while removing potentially sensitive content.
7867+
* It preserves the document structure and collaboration capabilities while replacing content with
7868+
* placeholders according to these redaction rules:
7869+
*
7870+
* - Preserves delete and move operations
7871+
* - Replaces text insertion content with the Unicode replacement character
7872+
* - Substitutes list and map insert values with null
7873+
* - Maintains structure of child containers
7874+
* - Replaces text mark values with null
7875+
* - Preserves map keys and text annotation keys
7876+
*
7877+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
7878+
* @param {Object} versionRange - Version range defining what content to redact,
7879+
* format: { peerId: [startCounter, endCounter], ... }
7880+
* @returns {Object} The redacted JSON updates
7881+
*/
7882+
export function redactJsonUpdates(json_updates: string | JsonSchema, version_range: any): JsonSchema;
78137883

78147884
/**
78157885
* Container types supported by loro.
@@ -7980,11 +8050,11 @@ interface LoroDoc {
79808050
* doc.commit();
79818051
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
79828052
* ```
7983-
*
8053+
*
79848054
* ### Advanced Example: Creating a Merkle DAG
7985-
*
8055+
*
79868056
* By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:
7987-
*
8057+
*
79888058
* ```ts
79898059
* const doc = new LoroDoc();
79908060
* doc.setPeerId(0);
@@ -8004,7 +8074,7 @@ interface LoroDoc {
80048074
* const sha256Hash = hash.digest('hex');
80058075
* e.modifier.setMessage(sha256Hash);
80068076
* });
8007-
*
8077+
*
80088078
* doc.getList("list").insert(0, 100);
80098079
* doc.commit();
80108080
* // Change 0
@@ -8022,8 +8092,8 @@ interface LoroDoc {
80228092
* // }
80238093
* // ]
80248094
* // }
8025-
*
8026-
*
8095+
*
8096+
*
80278097
* doc.getList("list").insert(0, 200);
80288098
* doc.commit();
80298099
* // Change 1
@@ -8043,13 +8113,13 @@ interface LoroDoc {
80438113
* // }
80448114
* // ]
80458115
* // }
8046-
*
8116+
*
80478117
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853");
80488118
* expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe("aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f");
80498119
* ```
8050-
*
8120+
*
80518121
* @param f - A callback function that receives a pre commit event.
8052-
*
8122+
*
80538123
**/
80548124
subscribePreCommit(f: (e: { changeMeta: Change, origin: string, modifier: ChangeModifier }) => void): () => void
80558125

@@ -8373,9 +8443,6 @@ interface LoroMovableList {
83738443
}
83748444

83758445
export type Side = -1 | 0 | 1;
8376-
8377-
8378-
83798446
export type JsonOpID = `${number}@${PeerID}`;
83808447
export type JsonContainerID = `🦜:${ContainerID}` ;
83818448
export type JsonValue =
@@ -8674,6 +8741,24 @@ interface UndoManager {
86748741
* @param listener - The callback function.
86758742
*/
86768743
setOnPop(listener?: UndoConfig["onPop"]): void;
8744+
8745+
/**
8746+
* Starts a new grouping of undo operations.
8747+
* All changes/commits made after this call will be grouped/merged together.
8748+
* to end the group, call `groupEnd`.
8749+
*
8750+
* If a remote import is received within the group, its possible that the undo item will be
8751+
* split and the group will be automatically ended.
8752+
*
8753+
* Calling `groupStart` within an active group will throw but have no effect.
8754+
*
8755+
*/
8756+
groupStart(): void;
8757+
8758+
/**
8759+
* Ends the current grouping of undo operations.
8760+
*/
8761+
groupEnd(): void;
86778762
}
86788763
interface LoroDoc<T extends Record<string, Container> = Record<string, Container>> {
86798764
/**
@@ -8717,7 +8802,7 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
87178802
* import { LoroDoc } from "loro-crdt";
87188803
*
87198804
* const doc = new LoroDoc();
8720-
* const list = doc.getList("list");
8805+
* const list = doc.getMovableList("list");
87218806
* ```
87228807
*/
87238808
getMovableList<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroMovableList ? T[Key] : LoroMovableList;
@@ -8753,9 +8838,9 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
87538838
* It ensures deterministic output, making it ideal for hash calculations and integrity checks.
87548839
*
87558840
* This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
8756-
*
8841+
*
87578842
* This method will NOT trigger a new commit implicitly.
8758-
*
8843+
*
87598844
* @param idSpan - The id span to export.
87608845
* @returns The changes in the given id span.
87618846
*/
@@ -9932,6 +10017,7 @@ export class LoroDoc {
993210017
* @param mode - The export mode to use. Can be one of:
993310018
* - `{ mode: "snapshot" }`: Export a full snapshot of the document.
993410019
* - `{ mode: "update", from?: VersionVector }`: Export updates from the given version vector.
10020+
* If `from` is not provided, it will export the whole history of the document.
993510021
* - `{ mode: "updates-in-range", spans: { id: ID, len: number }[] }`: Export updates within the specified ID spans.
993610022
* - `{ mode: "shallow-snapshot", frontiers: Frontiers }`: Export a garbage-collected snapshot up to the given frontiers.
993710023
*
@@ -11359,6 +11445,10 @@ export class UndoManager {
1135911445
* Redo the last undone operation.
1136011446
*/
1136111447
redo(): boolean;
11448+
/**
11449+
* Get the peer id of the undo manager.
11450+
*/
11451+
peer(): PeerID;
1136211452
/**
1136311453
* Can undo the last operation.
1136411454
*/

theme.config.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const config: DocsThemeConfig = {
2727
Loro
2828
</span>
2929
),
30+
sidebar: {
31+
defaultMenuCollapseLevel: 1,
32+
autoCollapse: true,
33+
},
3034
nextThemes: {
3135
defaultTheme: "dark",
3236
},

0 commit comments

Comments
 (0)