Skip to content

Releases: loro-dev/loro

[email protected]

16 Jan 02:56
d5eb300
Compare
Choose a tag to compare

Patch Changes

  • 07500da: fix: map.keys() may return keys from deleted entries #618

[email protected]

09 Jan 04:48
Compare
Choose a tag to compare

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

    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

    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();
    {
      "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

[email protected]

03 Jan 18:13
Compare
Choose a tag to compare

Patch Changes

  • da24910: fix: should commit before travel_change_ancestors #599

[email protected]

31 Dec 06:28
Compare
Choose a tag to compare

Patch Changes

  • d552955: Make getByPath work for "tree/0/key"
  • df81aec: Better event ordering

[email protected]

28 Dec 14:56
Compare
Choose a tag to compare

Patch Changes

[email protected]

27 Dec 02:22
Compare
Choose a tag to compare

Patch Changes

  • 5aa7985: Fixed LoroTree's incorrect index when moving a node within its current parent

[email protected]

23 Dec 06:39
Compare
Choose a tag to compare

Patch Changes

  • 42949c0: Fix VersionVector ownership issue in WASM binding
  • 1ca1275: feat: UndoManager's onPush now can access the change event

[email protected]

17 Dec 05:19
56216ef
Compare
Choose a tag to compare

Patch Changes

  • 3b7a738: Add getShallowValue and toJsonWIthReplacer

    • Add getShallowValue for each container (#581)
    • Implement toJsonWithReplacer method for LoroDoc to customize JSON serialization (#582)
    • Rename importUpdateBatch into importBatch & refine type (#580)

[email protected]

11 Dec 09:29
Compare
Choose a tag to compare

Patch Changes

  • adb6ab8: fix: panic when returned non-boolean value from text.iter(f) #578

[email protected]

10 Dec 08:38
Compare
Choose a tag to compare

Minor Changes

  • 01fccc5: Return ImportStatus in the import_batch method

Patch Changes

  • d08a865: fix: getOrCreateContainer should not throw if value is null #576