8000 release-v0.23.4 by Horusiath · Pull Request #556 · y-crdt/y-crdt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

release-v0.23.4 #556

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

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests-wasm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions yffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yffi"
version = "0.23.3"
version = "0.23.4"
authors = ["Kevin Jahns <kevin.jahns@protonmail.com>", "Bartosz Sypytkowski <b.sypytkowski@gmail.com>"]
keywords = ["crdt", "c-ffi", "yrs"]
edition = "2018"
Expand All @@ -12,7 +12,7 @@ description = "Bindings for the Yrs native C foreign function interface"
[dev-dependencies]

[dependencies]
yrs = { path = "../yrs", version = "0.23.3", features = ["weak"] }
yrs = { path = "../yrs", version = "0.23.4", features = ["weak"] }
serde_json = { version = "1.0" }

[lib]
Expand Down
2 changes: 1 addition & 1 deletion yrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yrs"
version = "0.23.3"
version = "0.23.4"
description = "High performance implementation of the Yjs CRDT"
license = "MIT"
authors = ["Kevin Jahns <kevin.jahns@pm.me>", "Bartosz Sypytkowski <b.sypytkowski@gmail.com>"]
Expand Down
71 changes: 69 additions & 2 deletions yrs/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,105 @@ pub trait ReadTxn: Sized {
self.store().encode_state_from_snapshot(snapshot, encoder)
}

/// Encodes the difference between remove peer state given its `state_vector` and the state
/// of a current local peer
/// Encodes the difference between remote peer state given its `state_vector` and the state
10000 /// of a current local peer.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update] encodes full document state including pending updates and
/// entire delete set.
/// - [Self::encode_diff] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_diff<E: Encoder>(&self, state_vector: &StateVector, encoder: &mut E) {
self.store().encode_diff(state_vector, encoder)
}

/// Encodes the difference between remote peer state given its `state_vector` and the state
/// of a current local peer, using lib0 v1 encoding.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update_v1] encodes full document state including pending updates
/// and entire delete set.
/// - [Self::encode_diff_v1] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update_v1] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_diff_v1(&self, state_vector: &StateVector) -> Vec<u8> {
let mut encoder = EncoderV1::new();
self.encode_diff(state_vector, &mut encoder);
encoder.to_vec()
}

/// Encodes the difference between remote peer state given its `state_vector` and the state
/// of a current local peer, using lib0 v2 encoding.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update_v2] encodes full document state including pending updates
/// and entire delete set.
/// - [Self::encode_diff_v2] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update_v2] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_diff_v2(&self, state_vector: &StateVector) -> Vec<u8> {
let mut encoder = EncoderV2::new();
self.encode_diff(state_vector, &mut encoder);
encoder.to_vec()
}

/// Encodes the difference between remote peer state given its `state_vector` and the state
/// of a current local peer. Also includes pending updates which were not yet integrated into
/// the main document state and entire delete set.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update] encodes full document state including pending updates and
/// entire delete set.
/// - [Self::encode_diff] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_state_as_update<E: Encoder>(&self, sv: &StateVector, encoder: &mut E) {
let store = self.store();
store.write_blocks_from(sv, encoder);
let ds = DeleteSet::from(&store.blocks);
ds.encode(encoder);
}

/// Encodes the difference between remote peer state given its `state_vector` and the state
/// of a current local peer, using lib0 v1 encoding. Also includes pending updates which were
/// not yet integrated into the main document state and entire delete set.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update_v1] encodes full document state including pending updates
/// and entire delete set.
/// - [Self::encode_diff_v1] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update_v1] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_state_as_update_v1(&self, sv: &StateVector) -> Vec<u8> {
let mut encoder = EncoderV1::new();
self.encode_state_as_update(sv, &mut encoder);
// check for pending data
merge_pending_v1(encoder.to_vec(), self.store())
}

/// Encodes the difference between remote peer state given its `state_vector` and the state
/// of a current local peer, using lib0 v2 encoding. Also includes pending updates which were
/// not yet integrated into the main document state and entire delete set.
///
/// # Differences between alternative methods
///
/// - [Self::encode_state_as_update_v2] encodes full document state including pending updates
/// and entire delete set.
/// - [Self::encode_diff_v2] encodes only the difference between the current state and
/// the given state vector, including entire delete set. Pending updates are not included.
/// - [TransactionMut::encode_update_v2] encodes only inserts and deletes made within the scope
/// of the current transaction.
fn encode_state_as_update_v2(&self, sv: &StateVector) -> Vec<u8> {
let mut encoder = EncoderV2::new();
self.encode_state_as_update(sv, &mut encoder);
Expand Down
4 changes: 2 additions & 2 deletions ywasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ywasm"
version = "0.23.3"
version = "0.23.4"
authors = ["Kevin Jahns <kevin.jahns@protonmail.com>", "Bartosz Sypytkowski <b.sypytkowski@gmail.com>"]
keywords = ["crdt", "wasm", "yrs"]
edition = "2018"
Expand All @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook"]

[dependencies]
yrs = { path = "../yrs", version = "0.23.3", features = ["weak"] }
yrs = { path = "../yrs", version = "0.23.4", features = ["weak"] }
wasm-bindgen = { version = "0.2" }
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
Expand Down
Loading
0