Skip to content

chore(deps): update dependency loro-crdt to v1 #727

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 23, 2024

This PR contains the following updates:

Package Change Age Confidence
loro-crdt (source) ^0.4.1 -> ^1.0.0 age confidence

Release Notes

loro-dev/loro (loro-crdt)

v1.5.10

Compare Source

Patch Changes

v1.5.9

Compare Source

Patch Changes

v1.5.8

Compare Source

Patch Changes
  • 19c064a: fix: snapshot origin of event

v1.5.7

Compare Source

Patch Changes
  • 70a3bf3: Feat: support group_start and group_end for UndoManager #​720
  • 24a7f53: fix: panic when calling get_deep_value with an empty tree #​740

v1.5.6

Compare Source

Patch Changes

v1.5.5

Compare Source

Patch Changes
  • 0bfbb3b: fix: update EphemeralStore to support generic types (#​718)

v1.5.4

Compare Source

Patch Changes
  • 37c2a17: fix: checkout should renew txn if not detached

v1.5.3

Compare Source

Patch Changes

v1.5.2

Compare Source

Patch Changes
  • 81c7bb7: fix ephemeral store recursive use by adding mutex in the inner
  • bf94a03: feat: add functionality to delete and hide empty root containers #​708

v1.5.1

Compare Source

Patch Changes

v1.5.0

Compare Source

Minor Changes
  • 8dfcad4: # New Hooks: pre-commit and first-commit-from-peer

doc.subscribePreCommit(listener)

The `pre-commit` hook enables users to modify commit options before any commit is processed.

This hook is particularly useful because `doc.commit()` is often invoked implicitly in various methods such as `doc.import`, `doc.export`, `doc.checkout`, and `doc.exportJsonUpdates`. Without this hook, users attempting to add custom messages to each commit might miss these implicit commit triggers.

```ts
const doc = new LoroDoc();
doc.setPeerId(0);
doc.subscribePreCommit((e) => {
  e.modifier.setMessage("test").setTimestamp(Date.now());
});
doc.getList("list").insert(0, 100);
doc.commit();
expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
```
Advanced Example: Creating a Merkle DAG
By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:

```ts
const doc = new LoroDoc();
doc.setPeerId(0);
doc.subscribePreCommit((e) => {
  const changes = doc.exportJsonInIdSpan(e.changeMeta);
  expect(changes).toHaveLength(1);
  const hash = crypto.createHash("sha256");
  const change = {
    ...changes[0],
    deps: changes[0].deps.map((d) => {
      const depChange = doc.getChangeAt(idStrToId(d));
      return depChange.message;
    }),
  };
  hash.update(JSON.stringify(change));
  const sha256Hash = hash.digest("hex");
  e.modifier.setMessage(sha256Hash);
});

console.log(change); // The output is shown below
doc.getList("list").insert(0, 100);
doc.commit();
// Change 0
// {
//   id: '0@​0',
//   timestamp: 0,
//   deps: [],
//   lamport: 0,
//   msg: undefined,
//   ops: [
//     {
//       container: 'cid:root-list:List',
//       content: { type: 'insert', pos: 0, value: [100] },
//       counter: 0
//     }
//   ]
// }

doc.getList("list").insert(0, 200);
doc.commit();
// Change 1
// {
//   id: '1@​0',
//   timestamp: 0,
//   deps: [
//     '2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853'
//   ],
//   lamport: 1,
//   msg: undefined,
//   ops: [
//     {
//       container: 'cid:root-list:List',
//       content: { type: 'insert', pos: 0, value: [200] },
//       counter: 1
//     }
//   ]
// }

expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe(
  "2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853",
);
expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe(
  "aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f",
);
```

doc.subscribeFirstCommitFromPeer(listener)

The `first-commit-from-peer` event triggers when a peer performs operations on the document for the first time.
This provides an ideal point to associate peer information (such as author identity) with the document.

```ts
const doc = new LoroDoc();
doc.setPeerId(0);
doc.subscribeFirstCommitFromPeer((e) => {
  doc.getMap("users").set(e.peer, "user-" + e.peer);
});
doc.getList("list").insert(0, 100);
doc.commit();
expect(doc.getMap("users").get("0")).toBe("user-0");
```
  • a997885: # EphemeralStore: An Alternative to Awareness

    Awareness is commonly used as a state-based CRDT for handling ephemeral states in real-time collaboration scenarios, such as cursor positions and application component highlights. As application complexity grows, Awareness may be set in multiple places, from cursor positions to user presence. However, the current version of Awareness doesn't support partial state updates, which means even minor mouse movements require synchronizing the entire Awareness state.

    awareness.setLocalState({
      ...awareness.getLocalState(),
      x: 167,
    });

    Since Awareness is primarily used in real-time collaboration scenarios where consistency requirements are relatively low, we can make it more flexible. We've introduced EphemeralStore as an alternative to Awareness. Think of it as a simple key-value store that uses timestamp-based last-write-wins for conflict resolution. You can choose the appropriate granularity for your key-value pairs based on your application's needs, and only modified key-value pairs are synchronized.

Examples

```ts
import {
    EphemeralStore,
    EphemeralListener,
    EphemeralStoreEvent,
} from "loro-crdt";

const store = new EphemeralStore();
// Set ephemeral data
store.set("loro-prosemirror", {
    anchor: ...,
    focus: ...,
    user: "Alice"
});
store.set("online-users", ["Alice", "Bob"]);

expect(storeB.get("online-users")).toEqual(["Alice", "Bob"]);
// Encode only the data for `loro-prosemirror`
const encoded = store.encode("loro-prosemirror")

store.subscribe((e: EphemeralStoreEvent) => {
    // Listen to changes from `local`, `remote`, or `timeout` events
});
```
Patch Changes

v1.4.6

Compare Source

Patch Changes
  • 0b0ac7c: fix: entity index when the tree is empty

v1.4.5

Compare Source

Patch Changes

v1.4.4

Compare Source

Patch Changes
  • 28d1264: feat(wasm): enhance toJsonWithReplacer to handle nested containers in replacer returned value

  • 28d1264: fix(wasm): add toJSON to LoroText

    Now all containers have toJSON method.

v1.4.3

Compare Source

Patch Changes

v1.4.2

Compare Source

Patch Changes
  • e0948d8: feat: add container existence check methods & avoid panic in wasm/js #​651
  • 9955500: fix: an internal iter_change err that may cause fork_at panic #​649

v1.4.1

Compare Source

Patch Changes

v1.4.0

Compare Source

Minor Changes
Patch Changes

v1.3.5

Compare Source

Patch Changes
  • c2a61f3: fix: improve shallow snapshot and JSON export handling #​639

v1.3.4

Compare Source

Patch Changes
  • b58e6bd: fix: should be able to call subscription after diffing #​637

v1.3.3

Compare Source

Patch Changes
  • 8fdb25e: fix: move tree node within the self parent with 16 siblings #​635

v1.3.2

Compare Source

Patch Changes

v1.3.1

Compare Source

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

v1.3.0

Compare Source

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

v1.2.7

Compare Source

Patch Changes

v1.2.6

Compare Source

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

v1.2.5

Compare Source

Patch Changes

v1.2.4

Compare Source

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

v1.2.3

Compare Source

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

v1.2.2

Compare Source

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)

v1.2.1

Compare Source

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

v1.2.0

Compare Source

Minor Changes
  • 01fccc5: Return ImportStatus in the import_batch method
Patch Changes
  • d08a865: fix: getOrCreateContainer should not throw if value is null #​576

v1.1.4

Compare Source

Patch Changes

v1.1.3

Compare Source

Patch Changes
  • d6966ac: The fractional index in LoroTree is now enabled by default with jitter=0.

    To reduce the cost of LoroTree, if the index property in LoroTree is unused, users can still
    call tree.disableFractionalIndex(). However, in the new version, after disabling the fractional
    index, tree.moveTo(), tree.moveBefore(), tree.moveAfter(), and tree.createAt() will
    throw an error

v1.1.2

Compare Source

Patch Changes
  • 70c4942: Add base64 build target
  • 35e7ea5: Add changeCount and opCount methods

v1.1.1

Compare Source

Patch Changes
  • 9abeb81: Add methods to modify VV
  • ee26952: Add isDeleted() method to each container

v1.1.0

Compare Source

Minor Changes
  • 6e878d2: Feat add API to query creators, the last editors/movers
  • 778ca54: Feat: allow users to query the changed containers in the target id range
Patch Changes
  • 6616101: Perf: optimize importBatch

    When using importBatch to import a series of snapshots and updates, we should import the snapshot with the greatest version first.

  • 6e878d2: Feat: getLastEditor on LoroMap

  • 8486234: Fix get encoded blob meta

v1.0.9

Compare Source

Patch Changes
  • 7bf6db7: Add push to LoroText and pushContainer to LoroList LoroMovableList

  • 9b60d01: Define the behavior of doc.fork() when the doc is detached

    It will fork at the current state_frontiers, which is equivalent to calling doc.fork_at(&doc.state_frontiers())

v1.0.8

Compare Source

Patch Changes

v1.0.7: v1.0

Compare Source

We are very excited to announce the release of Loro v1.0, a major milestone.

It has a stable encoding format, faster document import and export speed, better version control capabilities, and a shallow snapshot. For more information, please check the blog.

The following are the specific API changes:

New

LoroDoc
  • getChange(id: ID): get ChangeMeta by ID.
  • setDetachedEditing(flag: boolean): Enables editing in detached mode, which is disabled by default.
  • isDetachedEditingEnabled(): Whether the editing is enabled in detached mode.
  • setNextCommitMessage(msg: string): Set the commit message of the next commit.
  • shallowSinceVV(): The doc only contains the history since this version.
  • shallowSinceFrontiers(): The doc only contains the history since this version.
  • export(mode: ExportMode): Export the document based on the specified ExportMode. see more details here.
  • getDeepValueWithID(): Get deep value of the document with container id.
  • subscribeLocalUpdates(callback:(bytes: Uint8Array) => void): Subscribe to updates from local edits.
  • getPathToContainer(id: ContainerID): Get the path from the root to the container.
  • JSONPath(jsonPath: string): Evaluate JSONPath against a LoroDoc.
  • forkAt(frontiers: Frontiers): LoroDoc: Creates a new LoroDoc at a specified version (Frontiers)
  • getPendingTxnLength():number: Get the number of operations in the pending transaction.
  • travelChangeAncestors(ids: ID[], callback: (meta: ChangeMeta)->bool): Iterate over all changes including the input id in order, and stop iterating if the callback returns false.
LoroText
  • updateByLine(text: string): Update the current text based on the provided text line by line like git.
LoroList
  • toArray(): ValueOrContainer[]: Get elements of the list. If the value is a child container, the corresponding Container will be returned.
  • clear(): Delete all elements in the list.
LoroMovableList
  • toArray(): ValueOrContainer[]: Get elements of the list. If the value is a child container, the corresponding Container will be returned.
  • clear(): Delete all elements in the list.
LoroMap
  • clear(): Delete all key-value pairs in the map.
LoroTree
  • enableFractionalIndex(jitter: number): Set whether to generate a fractional index for Tree Position.
  • disableFractionalIndex(): Disable the fractional index generation for Tree Position when
    you don't need the Tree's siblings to be sorted. The fractional index will always be the default.
  • isFractionalIndexEnabled(): Whether the tree enables the fractional index generation.
  • isNodeDeleted(id: TreeID): Return undefined if the node does not exist; otherwise, return true if the node is deleted.
  • getNodes(prop: getNodesProp): LoroTreeNode[]: Get the flat array of the forest. If with_deleted is true, the deleted nodes will be included.
UndoManager
  • clear(): Clear the Undo and Redo stack of UndoManager

Changes

LoroDoc
  • Move setFractionalIndexJitter() to LoroTree; you can set whether to enable or disable it for each Tree Container.
  • import(), importWith(), and importJsonUpdates will return ImportStatus, which indicates which ops have been successfully applied and which ops are pending.
  • New Subscription for events.
  • In Loro 1.0, doc.version() doc.frontiers() doc.oplogVersion() and doc.oplogFrontiers() even if ops has not been committed, it indicates the latest version of all operations.
  • rename Loro to LoroDoc.
LoroTree
  • contains(id: TreeID): Return true even if the node exists in the internal state and has been deleted.
  • nodes(): deleted nodes will be included now. You can use isDeleted() to filter.
  • toJSON(): Now use the hierarchical approach to express the tree structure.

Deprecation

LoroDoc
  • exportFrom(version) and exportSnapshot() are deprecated, use export(mode: ExportMode) instead.

v0.16.12

Compare Source

Patch Changes

v0.16.11

Compare Source

Patch Changes

v0.16.10

Compare Source

Patch Changes

v0.16.9

Compare Source

Patch Changes

v0.16.8

Compare Source

Patch Changes
  • 38b4bcf: Add text update API

    • Remove the patch for crypto
    • Add text update API (#​404)
    • Check invalid root container name (#​411)
🐛 Bug Fixes
-   Workaround lldb bug make loro crate debuggable (#​414)
-   Delete the **bring back** tree node from the undo container remap (#​423)
📚 Documentation
-   Fix typo
-   Refine docs about event (#​417)
🎨 Styling
-   Use clippy to perf code (#​407)
⚙️ Miscellaneous Tasks
-   Add test tools (#​410)

v0.16.7

Compare Source

Patch Changes
  • 45c98d5: Better text APIs and bug fixes
🚀 Features
-   Add insert_utf8 and delete_utf8 for Rust Text API (#​396)
-   Add text iter (#​400)
-   Add more text api (#​398)
🐛 Bug Fixes
-   Tree undo when processing deleted node (#​399)
-   Tree diff calc children should be sorted by idlp (#​401)
-   When computing the len of the map, do not count elements that are None (#​402)
📚 Documentation
-   Update wasm docs
-   Rm experimental warning
⚙️ Miscellaneous Tasks
-   Update fuzz config
-   Pnpm
-   Rename position to fractional_index (#​381)

v0.16.6

Compare Source

Patch Changes

v0.16.5

Compare Source

Patch Changes

v0.16.4

Compare Source

Patch Changes

v0.16.3

Compare Source

Patch Changes

v0.16.2

Compare Source

Patch Changes
  • 34f6064: Better undo events & transform cursors by undo manager (#​369)
🧪 Testing
-   Enable compatibility test (#​367)

v0.16.1

Compare Source

Patch Changes
  • 5cd80b0: Refine undo impl

    • Add "undo" origin for undo and redo event
    • Allow users to skip certain local operations
    • Skip undo/redo ops that are not visible to users
    • Add returned bool value to indicate whether undo/redo is executed
  • Updated dependencies [5cd80b0]

v0.16.0

Compare Source

Minor Changes
  • c12c2b9: Movable Tree Children & Undo
🐛 Bug Fixes
-   Refine error message on corrupted data (#​356)
-   Add MovableList to CONTAINER_TYPES (#​359)
-   Better jitter for fractional index (#​360)
🧪 Testing
-   Add compatibility tests (#​357)
Feat
-   Make the encoding format forward and backward compatible (#​329)
-   Undo (#​361)
-   Use fractional index to order the children of the tree (#​298)
🐛 Bug Fixes
-   Tree fuzz sort value (#​351)
-   Upgrade wasm-bindgen to fix str free err (#​353)
Patch Changes

v0.15.4

Compare Source

v0.15.3

Compare Source

Patch Changes
  • 43506cc: Fix unsound issue caused by wasm-bindgen
🐛 Bug Fixes
-   Fix potential movable list bug (#​354)
-   Tree fuzz sort value (#​351)
-   Upgrade wasm-bindgen to fix str free err (#​353)
📚 Documentation
-   Simplify readme (#​352)

v0.15.2

Compare Source

Patch Changes
  • e30678d: Perf: fix deletions merge
🐛 Bug Fixes
-   _(wasm)_ Movable list .kind() (#​342)
⚡ Performance
-   Delete span merge err (#​348)
⚙️ Miscellaneous Tasks
-   Warn missing debug impl (#​347)

<!-- generated by git-cliff -->

v0.15.1

Compare Source

Patch Changes
  • 04c6290: Bug fixes and improvements.
🐛 Bug Fixes
-   Impl a few unimplemented! for movable tree (#&#8203;335)
-   Refine ts type; reject invalid operations (#&#8203;334)
-   Get cursor err on text and movable list (#&#8203;337)
-   Missing MovableList in all container type (#&#8203;343)
-   Upgrade generic-btree to allow large btree (#&#8203;344)
📚 Documentation
-   Add warn(missing_docs) to loro and loro-wasm (#&#8203;339)
-   Minor fix on set_change_merge_interval api (#&#8203;341)
⚙️ Miscellaneous Tasks
-   Skip the checking if not debug_assertions (#&#8203;340)

<!-- generated by git-cliff -->

v0.15.0

Compare Source

Minor Changes
  • 35b9b6e: Movable List (#​293)

    Loro's List supports insert and delete operations but lacks built-in methods for set and move. To simulate set and move, developers might combine delete and insert. However, this approach can lead to issues during concurrent operations on the same element, often resulting in duplicate entries upon merging.

    For instance, consider a list [0, 1, 2]. If user A moves the element '0' to position 1, while user B moves it to position 2, the ideal merged outcome should be either [1, 0, 2] or [1, 2, 0]. However, using the delete-insert method to simulate a move results in [1, 0, 2, 0], as both users delete '0' from its original position and insert it independently at new positions.

    To address this, we introduce a MovableList container. This new container type directly supports move and set operations, aligning more closely with user expectations and preventing the issues associated with simulated moves.

Example

```ts
import { Loro } from "loro-crdt";
import { expect } from "vitest";

const doc = new Loro();
const list = doc.getMovableList("list");
list.push("a");
list.push("b");
list.push("c");
expect(list.toArray()).toEqual(["a", "b", "c"]);
list.set(2, "d");
list.move(0, 1);
const doc2 = new Loro();
const list2 = doc2.getMovableList("list");
expect(list2.length).toBe(0);
doc2.import(doc.exportFrom());
expect(list2.length).toBe(3);
expect(list2.get(0)).toBe("b");
expect(list2.get(1)).toBe("a");
expect(list2.get(2)).toBe("d");
```
Patch Changes

v0.14.6

Compare Source

Patch Changes
🐛 Bug Fixes
-   Attached container can be inserted to `Map` or `List` (#&#8203;331)

v0.14.5

Compare Source

Patch Changes
🐛 Bug Fixes
-   _(js)_ Allow convert from undefined to LoroValue (#&#8203;323)
🚜 Refactor
-   Refine ts type (#&#8203;322)

v0.14.4

Compare Source

Patch Changes
  • 598d97e: ### 🚜 Refactor

    • Refine the TS Type of Awareness
    • Parse Uint8array to LoroValue::Binary (#​320)
📚 Documentation
-   Update how to publish new npm pkgs

v0.14.3

Compare Source

Patch Changes

v0.14.2

Compare Source

v0.14.1

Compare Source

v0.14.0

Compare Source

v0.13.1

Compare Source

v0.13.0

Compare Source

v0.12.0

Compare Source

v0.11.1

Compare Source

v0.11.0

Compare Source

v0.10.1

Compare Source

v0.10.0

Compare Source

v0.9.4

Compare Source

v0.9.3

Compare Source

v0.9.2

Compare Source

v0.9.1

Compare Source

v0.9.0

Compare Source

v0.8.0

Compare Source

v0.7.1

Compare Source

v0.7.0

Compare Source

v0.6.5

Compare Source

v0.6.4

Compare Source

v0.6.3

Compare Source

v0.6.2

Compare Source

v0.6.1

Compare Source

v0.6.0

Compare Source

v0.5.0

Compare Source


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/loro-crdt-1.x branch from 89f9b83 to 3c9ca02 Compare August 5, 2025 18:10
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.

0 participants