chore: version packages
Some checks are pending
Release WASM / Release (push) Waiting to run
Test All / build (push) Waiting to run

This commit is contained in:
github-actions[bot] 2025-01-09 04:41:28 +00:00 committed by Zixuan Chen
parent ddafb7e899
commit 9caae235c1
6 changed files with 121 additions and 128 deletions

View file

@ -1,112 +0,0 @@
---
"loro-crdt": minor
---
feat: diff, applyDiff, and revertTo #610
Add new version-control-related primitives:
- **`diff(from, to)`**: calculate the difference between two versions. The returned results have similar structures to the differences in events.
- **`revertTo(targetVersion)`**: revert the document back to the target version. The difference between this and `checkout(targetVersion)` is this method will generate a series of new operations, which will transform the current doc into the same as the target version.
- **`applyDiff(diff)`**: you can use it to apply the differences generated from `diff(from, to)`.
You can use these primitives to implement version-control functions like `squash` and `revert`.
# Examples
`revertTo`
```ts
const doc = new LoroDoc();
doc.setPeerId("1");
doc.getText("text").update("Hello");
doc.commit();
doc.revertTo([{ peer: "1", counter: 1 }]);
expect(doc.getText("text").toString()).toBe("He");
```
`diff`
```ts
const doc = new LoroDoc();
doc.setPeerId("1");
// Text edits with formatting
const text = doc.getText("text");
text.update("Hello");
text.mark({ start: 0, end: 5 }, "bold", true);
doc.commit();
// Map edits
const map = doc.getMap("map");
map.set("key1", "value1");
map.set("key2", 42);
doc.commit();
// List edits
const list = doc.getList("list");
list.insert(0, "item1");
list.insert(1, "item2");
list.delete(1, 1);
doc.commit();
// Tree edits
const tree = doc.getTree("tree");
const a = tree.createNode();
a.createNode();
doc.commit();
const diff = doc.diff([], doc.frontiers());
expect(diff).toMatchSnapshot()
```
```js
{
"cid:root-list:List": {
"diff": [
{
"insert": [
"item1",
],
},
],
"type": "list",
},
"cid:root-map:Map": {
"type": "map",
"updated": {
"key1": "value1",
"key2": 42,
},
},
"cid:root-text:Text": {
"diff": [
{
"attributes": {
"bold": true,
},
"insert": "Hello",
},
],
"type": "text",
},
"cid:root-tree:Tree": {
"diff": [
{
"action": "create",
"fractionalIndex": "80",
"index": 0,
"parent": undefined,
"target": "12@1",
},
{
"action": "create",
"fractionalIndex": "80",
"index": 0,
"parent": "12@1",
"target": "13@1",
},
],
"type": "tree",
},
}
```

View file

@ -1,5 +0,0 @@
---
"loro-crdt": minor
---
feat: add exportJsonInIdSpan and make peer compression optional

View file

@ -1,5 +0,0 @@
---
"loro-crdt": patch
---
fix: should not merge remote changes due to small interval

View file

@ -1,5 +0,0 @@
---
"loro-crdt": minor
---
feat: find id spans between #607

View file

@ -1,5 +1,125 @@
# Changelog
## 1.3.0
### Minor Changes
- ddafb7e: feat: diff, applyDiff, and revertTo #610
Add new version-control-related primitives:
- **`diff(from, to)`**: calculate the difference between two versions. The returned results have similar structures to the differences in events.
- **`revertTo(targetVersion)`**: revert the document back to the target version. The difference between this and `checkout(targetVersion)` is this method will generate a series of new operations, which will transform the current doc into the same as the target version.
- **`applyDiff(diff)`**: you can use it to apply the differences generated from `diff(from, to)`.
You can use these primitives to implement version-control functions like `squash` and `revert`.
# Examples
`revertTo`
```ts
const doc = new LoroDoc();
doc.setPeerId("1");
doc.getText("text").update("Hello");
doc.commit();
doc.revertTo([{ peer: "1", counter: 1 }]);
expect(doc.getText("text").toString()).toBe("He");
```
`diff`
```ts
const doc = new LoroDoc();
doc.setPeerId("1");
// Text edits with formatting
const text = doc.getText("text");
text.update("Hello");
text.mark({ start: 0, end: 5 }, "bold", true);
doc.commit();
// Map edits
const map = doc.getMap("map");
map.set("key1", "value1");
map.set("key2", 42);
doc.commit();
// List edits
const list = doc.getList("list");
list.insert(0, "item1");
list.insert(1, "item2");
list.delete(1, 1);
doc.commit();
// Tree edits
const tree = doc.getTree("tree");
const a = tree.createNode();
a.createNode();
doc.commit();
const diff = doc.diff([], doc.frontiers());
expect(diff).toMatchSnapshot();
```
```js
{
"cid:root-list:List": {
"diff": [
{
"insert": [
"item1",
],
},
],
"type": "list",
},
"cid:root-map:Map": {
"type": "map",
"updated": {
"key1": "value1",
"key2": 42,
},
},
"cid:root-text:Text": {
"diff": [
{
"attributes": {
"bold": true,
},
"insert": "Hello",
},
],
"type": "text",
},
"cid:root-tree:Tree": {
"diff": [
{
"action": "create",
"fractionalIndex": "80",
"index": 0,
"parent": undefined,
"target": "12@1",
},
{
"action": "create",
"fractionalIndex": "80",
"index": 0,
"parent": "12@1",
"target": "13@1",
},
],
"type": "tree",
},
}
```
- ac51ceb: feat: add exportJsonInIdSpan and make peer compression optional
- 8039e44: feat: find id spans between #607
### Patch Changes
- 9c1005d: fix: should not merge remote changes due to small interval
## 1.2.7
### Patch Changes

View file

@ -1,6 +1,6 @@
{
"name": "loro-crdt",
"version": "1.2.7",
"version": "1.3.0",
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
"keywords": [
"crdt",