Skip to content

Commit

Permalink
chore: version packages
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and zxch3n committed Jan 9, 2025
1 parent ddafb7e commit 9caae23
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 128 deletions.
112 changes: 0 additions & 112 deletions .changeset/new-dryers-decide.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/popular-ghosts-travel.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rude-candles-jog.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/tame-spies-attack.md

This file was deleted.

120 changes: 120 additions & 0 deletions crates/loro-wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/loro-wasm/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 9caae23

Please sign in to comment.