Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: version packages #603

Merged
merged 1 commit into from
Jan 9, 2025
Merged

chore: version packages #603

merged 1 commit into from
Jan 9, 2025

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 4, 2025

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

[email protected]

Minor Changes

  • ddafb7e: feat: diff, applyDiff, and revertTo feat: diff, revertTo, and applyDiff #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 feat: find id spans between #607

Patch Changes

  • 9c1005d: fix: should not merge remote changes due to small interval

@github-actions github-actions bot force-pushed the changeset-release/main branch 6 times, most recently from 8e0c10a to de2a24a Compare January 9, 2025 04:02
@github-actions github-actions bot force-pushed the changeset-release/main branch from de2a24a to 9b75f96 Compare January 9, 2025 04:41
@zxch3n zxch3n merged commit 9caae23 into main Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant