y-rb 0.5.1-aarch64-linux → 0.5.2-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/yrb/Cargo.toml +8 -8
- data/ext/yrb/src/lib.rs +14 -0
- data/ext/yrb/src/utils.rs +2 -2
- data/ext/yrb/src/yattrs.rs +2 -2
- data/ext/yrb/src/yawareness.rs +4 -4
- data/ext/yrb/src/ydoc.rs +16 -0
- data/ext/yrb/src/ytransaction.rs +19 -0
- data/lib/3.0/yrb.so +0 -0
- data/lib/3.1/yrb.so +0 -0
- data/lib/3.2/yrb.so +0 -0
- data/lib/y/doc.rb +40 -0
- data/lib/y/transaction.rb +30 -2
- data/lib/y/version.rb +1 -1
- metadata +4 -5
- data/lib/2.7/yrb.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2c86cc879a02a59befa92fcc9158453accdc8b8c8f0bd82262cba646a59032b
|
4
|
+
data.tar.gz: c41f4e5f8318402157faaa024116e8aabfec29e815a000b37e59f8c47651762e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d8e727b9533ede3e0b38666aa50426a01343e2073fb93b3ecc65cdfd0ee03ec88de9bffaa77caba31f27bf89b9e6d91e9f11c384b0587c2ccb68d7479cf952
|
7
|
+
data.tar.gz: dd9b35c50b4b9d1714b67224fdc8e9f5e3ab3a4d574a595b595ff0faa360794553e21cb2df83300a19cde8a40c6d43d89834dff3982a6d104978b7784ed23a5d
|
data/ext/yrb/Cargo.toml
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
[package]
|
2
2
|
name = "yrb"
|
3
|
-
version = "0.5.
|
3
|
+
version = "0.5.2"
|
4
4
|
authors = ["Hannes Moser <box@hannesmoser.at>", "Hannes Moser <hmoser@gitlab.com>"]
|
5
5
|
edition = "2021"
|
6
6
|
homepage = "https://github.com/y-crdt/yrb"
|
7
7
|
repository = "https://github.com/y-crdt/yrb"
|
8
8
|
|
9
9
|
[dependencies]
|
10
|
-
lib0 = "0.16.
|
11
|
-
magnus = "0.5.
|
12
|
-
thiserror = "1.0.
|
13
|
-
yrs = "0.16.
|
14
|
-
y-sync = "0.3.
|
15
|
-
rb-sys = "0.9.
|
10
|
+
lib0 = "0.16.9" # must match yrs version
|
11
|
+
magnus = "0.5.4"
|
12
|
+
thiserror = "1.0.41"
|
13
|
+
yrs = "=0.16.9"
|
14
|
+
y-sync = "=0.3.1"
|
15
|
+
rb-sys = "0.9.79"
|
16
16
|
|
17
17
|
[dev-dependencies]
|
18
|
-
magnus = { version = "0.5.
|
18
|
+
magnus = { version = "0.5.4", features = ["embed"] }
|
19
19
|
|
20
20
|
[lib]
|
21
21
|
name = "yrb"
|
data/ext/yrb/src/lib.rs
CHANGED
@@ -83,6 +83,8 @@ fn init() -> Result<(), Error> {
|
|
83
83
|
.expect("cannot define singleton method: ydoc_new");
|
84
84
|
ydoc.define_private_method("ydoc_encode_diff_v1", method!(YDoc::ydoc_encode_diff_v1, 2))
|
85
85
|
.expect("cannot define private method: ydoc_encode_diff_v1");
|
86
|
+
ydoc.define_private_method("ydoc_encode_diff_v2", method!(YDoc::ydoc_encode_diff_v2, 2))
|
87
|
+
.expect("cannot define private method: ydoc_encode_diff_v2");
|
86
88
|
ydoc.define_private_method(
|
87
89
|
"ydoc_get_or_insert_array",
|
88
90
|
method!(YDoc::ydoc_get_or_insert_array, 1),
|
@@ -154,6 +156,12 @@ fn init() -> Result<(), Error> {
|
|
154
156
|
method!(YTransaction::ytransaction_apply_update, 1),
|
155
157
|
)
|
156
158
|
.expect("cannot define private method: ytransaction_apply_update");
|
159
|
+
ytransaction
|
160
|
+
.define_private_method(
|
161
|
+
"ytransaction_apply_update_v2",
|
162
|
+
method!(YTransaction::ytransaction_apply_update_v2, 1),
|
163
|
+
)
|
164
|
+
.expect("cannot define private method: ytransaction_apply_update_v2");
|
157
165
|
ytransaction
|
158
166
|
.define_private_method(
|
159
167
|
"ytransaction_commit",
|
@@ -205,6 +213,12 @@ fn init() -> Result<(), Error> {
|
|
205
213
|
method!(YTransaction::ytransaction_state_vector, 0),
|
206
214
|
)
|
207
215
|
.expect("cannot define private method: ytransaction_state_vector");
|
216
|
+
ytransaction
|
217
|
+
.define_private_method(
|
218
|
+
"ytransaction_state_vector_v2",
|
219
|
+
method!(YTransaction::ytransaction_state_vector_v2, 0),
|
220
|
+
)
|
221
|
+
.expect("cannot define private method: ytransaction_state_vector_v2");
|
208
222
|
|
209
223
|
let ytext = module
|
210
224
|
.define_class("Text", Default::default())
|
data/ext/yrb/src/utils.rs
CHANGED
@@ -2,7 +2,7 @@ use crate::yvalue::YValue;
|
|
2
2
|
use lib0::any::Any;
|
3
3
|
use magnus::r_hash::ForEach::Continue;
|
4
4
|
use magnus::{exception, Error, RHash, RString, Symbol, Value};
|
5
|
-
use std::
|
5
|
+
use std::sync::Arc;
|
6
6
|
use yrs::types::Attrs;
|
7
7
|
|
8
8
|
#[derive(Debug, Clone)]
|
@@ -18,7 +18,7 @@ pub(crate) fn map_rhash_to_attrs(hash: RHash) -> Result<Attrs, Error> {
|
|
18
18
|
let mut a: Attrs = Default::default();
|
19
19
|
|
20
20
|
let result = hash.foreach(|key: Value, value: Value| {
|
21
|
-
let k =
|
21
|
+
let k = Arc::from(key.to_string());
|
22
22
|
let v = Any::from(YValue::from(value));
|
23
23
|
|
24
24
|
a.insert(k, v);
|
data/ext/yrb/src/yattrs.rs
CHANGED
@@ -3,7 +3,7 @@ use lib0::any::Any;
|
|
3
3
|
use magnus::r_hash::ForEach::Continue;
|
4
4
|
use magnus::{RHash, Value};
|
5
5
|
use std::ops::{Deref, DerefMut};
|
6
|
-
use std::
|
6
|
+
use std::sync::Arc;
|
7
7
|
use yrs::types::Attrs;
|
8
8
|
|
9
9
|
pub(crate) struct YAttrs(pub(crate) Attrs);
|
@@ -23,7 +23,7 @@ impl From<RHash> for YAttrs {
|
|
23
23
|
let k = key.to_string();
|
24
24
|
let yvalue = YValue::from(value);
|
25
25
|
let avalue = Any::from(yvalue);
|
26
|
-
attrs.insert(
|
26
|
+
attrs.insert(Arc::from(k), avalue);
|
27
27
|
|
28
28
|
Ok(Continue)
|
29
29
|
})
|
data/ext/yrb/src/yawareness.rs
CHANGED
@@ -2,7 +2,7 @@ use magnus::{block::Proc, exception, Error, Value};
|
|
2
2
|
use std::borrow::Borrow;
|
3
3
|
use std::cell::RefCell;
|
4
4
|
use std::collections::HashMap;
|
5
|
-
use y_sync::awareness::{Awareness, AwarenessUpdate, Event,
|
5
|
+
use y_sync::awareness::{Awareness, AwarenessUpdate, Event, UpdateSubscription};
|
6
6
|
use yrs::block::ClientID;
|
7
7
|
use yrs::updates::decoder::Decode;
|
8
8
|
use yrs::updates::encoder::Encode;
|
@@ -138,14 +138,14 @@ impl From<&Event> for YAwarenessEvent {
|
|
138
138
|
}
|
139
139
|
|
140
140
|
#[magnus::wrap(class = "Y::AwarenessEvent")]
|
141
|
-
pub(crate) struct YAwarenessSubscription(
|
141
|
+
pub(crate) struct YAwarenessSubscription(UpdateSubscription);
|
142
142
|
|
143
143
|
unsafe impl Send for YAwarenessSubscription {}
|
144
144
|
|
145
145
|
impl YAwarenessSubscription {}
|
146
146
|
|
147
|
-
impl From<
|
148
|
-
fn from(v:
|
147
|
+
impl From<UpdateSubscription> for YAwarenessSubscription {
|
148
|
+
fn from(v: UpdateSubscription) -> Self {
|
149
149
|
YAwarenessSubscription(v)
|
150
150
|
}
|
151
151
|
}
|
data/ext/yrb/src/ydoc.rs
CHANGED
@@ -10,6 +10,7 @@ use magnus::{exception::runtime_error, Error, Integer, RArray, Value};
|
|
10
10
|
use std::borrow::Borrow;
|
11
11
|
use std::cell::RefCell;
|
12
12
|
use yrs::updates::decoder::Decode;
|
13
|
+
use yrs::updates::encoder::{Encoder, EncoderV2};
|
13
14
|
use yrs::{Doc, OffsetKind, Options, ReadTxn, StateVector, SubscriptionId, Transact};
|
14
15
|
|
15
16
|
#[magnus::wrap(class = "Y::Doc")]
|
@@ -43,6 +44,21 @@ impl YDoc {
|
|
43
44
|
.map_err(|_e| Error::new(runtime_error(), "cannot encode diff"))
|
44
45
|
}
|
45
46
|
|
47
|
+
pub(crate) fn ydoc_encode_diff_v2(
|
48
|
+
&self,
|
49
|
+
transaction: &YTransaction,
|
50
|
+
state_vector: Vec<u8>,
|
51
|
+
) -> Result<Vec<u8>, Error> {
|
52
|
+
let mut tx = transaction.transaction();
|
53
|
+
let tx = tx.as_mut().unwrap();
|
54
|
+
let mut encoder = EncoderV2::new();
|
55
|
+
|
56
|
+
StateVector::decode_v2(state_vector.borrow())
|
57
|
+
.map(|sv| tx.encode_diff(&sv, &mut encoder))
|
58
|
+
.map(|_| encoder.to_vec())
|
59
|
+
.map_err(|_e| Error::new(runtime_error(), "cannot encode diff"))
|
60
|
+
}
|
61
|
+
|
46
62
|
pub(crate) fn ydoc_get_or_insert_array(&self, name: String) -> YArray {
|
47
63
|
let array_ref = self.0.borrow().get_or_insert_array(name.as_str());
|
48
64
|
YArray::from(array_ref)
|
data/ext/yrb/src/ytransaction.rs
CHANGED
@@ -38,6 +38,17 @@ impl YTransaction {
|
|
38
38
|
.map(|u| self.transaction().as_mut().unwrap().apply_update(u))
|
39
39
|
}
|
40
40
|
|
41
|
+
pub(crate) fn ytransaction_apply_update_v2(&self, update: Vec<u8>) -> Result<(), Error> {
|
42
|
+
Update::decode_v2(update.as_slice())
|
43
|
+
.map_err(|error| {
|
44
|
+
Error::new(
|
45
|
+
exception::runtime_error(),
|
46
|
+
format!("cannot decode update: {:?}", error),
|
47
|
+
)
|
48
|
+
})
|
49
|
+
.map(|u| self.transaction().as_mut().unwrap().apply_update(u))
|
50
|
+
}
|
51
|
+
|
41
52
|
pub(crate) fn ytransaction_commit(&self) {
|
42
53
|
self.transaction().as_mut().unwrap().commit();
|
43
54
|
}
|
@@ -98,6 +109,14 @@ impl YTransaction {
|
|
98
109
|
.encode_v1()
|
99
110
|
}
|
100
111
|
|
112
|
+
pub(crate) fn ytransaction_state_vector_v2(&self) -> Vec<u8> {
|
113
|
+
self.transaction()
|
114
|
+
.as_ref()
|
115
|
+
.unwrap()
|
116
|
+
.state_vector()
|
117
|
+
.encode_v2()
|
118
|
+
}
|
119
|
+
|
101
120
|
pub(crate) fn ytransaction_free(&self) {
|
102
121
|
self.0.replace(None);
|
103
122
|
}
|
data/lib/3.0/yrb.so
CHANGED
Binary file
|
data/lib/3.1/yrb.so
CHANGED
Binary file
|
data/lib/3.2/yrb.so
CHANGED
Binary file
|
data/lib/y/doc.rb
CHANGED
@@ -19,6 +19,9 @@ module Y
|
|
19
19
|
ZERO_STATE = [0].freeze
|
20
20
|
private_constant :ZERO_STATE
|
21
21
|
|
22
|
+
ZERO_STATE_V2 = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0].freeze
|
23
|
+
private_constant :ZERO_STATE_V2
|
24
|
+
|
22
25
|
# Attach a listener to document changes. If one of the data structures is
|
23
26
|
# changes, the block is called with the update as its only argument.
|
24
27
|
#
|
@@ -55,6 +58,16 @@ module Y
|
|
55
58
|
current_transaction { |tx| ydoc_encode_diff_v1(tx, state) }
|
56
59
|
end
|
57
60
|
|
61
|
+
# Create a v2 diff between this document and another document. The diff is
|
62
|
+
# created based on a state vector provided by the other document. It only
|
63
|
+
# returns the missing blocks, as binary encoded sequence.
|
64
|
+
#
|
65
|
+
# @param state [::Array<Integer>] The state to create the diff against
|
66
|
+
# @return [::Array<Integer>] Binary encoded diff
|
67
|
+
def diff_v2(state = ZERO_STATE_V2)
|
68
|
+
current_transaction { |tx| ydoc_encode_diff_v2(tx, state) }
|
69
|
+
end
|
70
|
+
|
58
71
|
# Creates a full diff for the current document. It is similar to {#diff},
|
59
72
|
# but does not take a state. Instead it creates an empty state and passes it
|
60
73
|
# to the encode_diff function.
|
@@ -152,6 +165,14 @@ module Y
|
|
152
165
|
current_transaction(&:state)
|
153
166
|
end
|
154
167
|
|
168
|
+
# Creates a v2 state vector of this document. This can be used to compare
|
169
|
+
# the state of two documents with each other and to later on sync them.
|
170
|
+
#
|
171
|
+
# @return [::Array<Integer>] Binary encoded state vector
|
172
|
+
def state_v2
|
173
|
+
current_transaction(&:state_v2)
|
174
|
+
end
|
175
|
+
|
155
176
|
# Synchronizes this document with the diff from another document
|
156
177
|
#
|
157
178
|
# @param diff [::Array<Integer>] Binary encoded update
|
@@ -160,6 +181,14 @@ module Y
|
|
160
181
|
current_transaction { |tx| tx.apply(diff) }
|
161
182
|
end
|
162
183
|
|
184
|
+
# Synchronizes this document with the v2 diff from another document
|
185
|
+
#
|
186
|
+
# @param diff [::Array<Integer>] Binary encoded update
|
187
|
+
# @return [void]
|
188
|
+
def sync_v2(diff)
|
189
|
+
current_transaction { |tx| tx.apply_v2(diff) }
|
190
|
+
end
|
191
|
+
|
163
192
|
# Restores a specific document from an update that contains full state
|
164
193
|
#
|
165
194
|
# This is doing the same as {#sync}, but it exists to be explicit about
|
@@ -211,6 +240,17 @@ module Y
|
|
211
240
|
# @return [Array<Integer>] Binary encoded update
|
212
241
|
# @!visibility private
|
213
242
|
|
243
|
+
# @!method ydoc_encode_diff_v2(tx, state_vector)
|
244
|
+
# Encodes the diff of current document state vs provided state in the v2
|
245
|
+
# format
|
246
|
+
#
|
247
|
+
# @example Create transaction on doc
|
248
|
+
# doc = Y::Doc.new
|
249
|
+
# tx = doc.ydoc_encode_diff_v2(other_state)
|
250
|
+
#
|
251
|
+
# @return [Array<Integer>] Binary encoded update
|
252
|
+
# @!visibility private
|
253
|
+
|
214
254
|
# @!method ydoc_transact
|
215
255
|
# Creates a new transaction for the document
|
216
256
|
#
|
data/lib/y/transaction.rb
CHANGED
@@ -22,6 +22,15 @@ module Y
|
|
22
22
|
ytransaction_apply_update(update)
|
23
23
|
end
|
24
24
|
|
25
|
+
# Applies the v2 encoded update on this document. This will bring the
|
26
|
+
# the document to the same state as the one the update is from.
|
27
|
+
#
|
28
|
+
# @param update [::Array<Integer>]
|
29
|
+
# @return [void]
|
30
|
+
def apply_v2(update)
|
31
|
+
ytransaction_apply_update_v2(update)
|
32
|
+
end
|
33
|
+
|
25
34
|
# Commits transaction
|
26
35
|
#
|
27
36
|
# @return [void]
|
@@ -89,15 +98,29 @@ module Y
|
|
89
98
|
xml_text
|
90
99
|
end
|
91
100
|
|
92
|
-
# Return state vector for transaction
|
101
|
+
# Return a state vector for this transaction
|
93
102
|
#
|
94
103
|
# @return [::Array<Integer>]
|
95
104
|
def state
|
96
105
|
ytransaction_state_vector
|
97
106
|
end
|
98
107
|
|
108
|
+
# Returns a v2 state vector for this transaction
|
109
|
+
#
|
110
|
+
# @return [::Array<Integer>]
|
111
|
+
def state_v2
|
112
|
+
ytransaction_state_vector_v2
|
113
|
+
end
|
114
|
+
|
99
115
|
# @!method ytransaction_apply_update(update)
|
100
|
-
#
|
116
|
+
# Apply the encoded update within current transaction
|
117
|
+
#
|
118
|
+
# @param update [::Array<Integer>]
|
119
|
+
# @return [void]
|
120
|
+
# @!visibility private
|
121
|
+
|
122
|
+
# @!method ytransaction_apply_update_v2(update)
|
123
|
+
# Apply the v2 encoded update within current transaction
|
101
124
|
#
|
102
125
|
# @param update [::Array<Integer>]
|
103
126
|
# @return [void]
|
@@ -157,5 +180,10 @@ module Y
|
|
157
180
|
#
|
158
181
|
# @return [Array<Integer>]
|
159
182
|
# @!visibility private
|
183
|
+
|
184
|
+
# @!method ytransaction_state_vector_v2
|
185
|
+
#
|
186
|
+
# @return [Array<Integer>]
|
187
|
+
# @!visibility private
|
160
188
|
end
|
161
189
|
end
|
data/lib/y/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- ext/yrb/src/yxml_element.rs
|
93
93
|
- ext/yrb/src/yxml_fragment.rs
|
94
94
|
- ext/yrb/src/yxml_text.rs
|
95
|
-
- lib/2.7/yrb.so
|
96
95
|
- lib/3.0/yrb.so
|
97
96
|
- lib/3.1/yrb.so
|
98
97
|
- lib/3.2/yrb.so
|
@@ -123,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
122
|
requirements:
|
124
123
|
- - ">="
|
125
124
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
125
|
+
version: '3.0'
|
127
126
|
- - "<"
|
128
127
|
- !ruby/object:Gem::Version
|
129
128
|
version: 3.3.dev
|
@@ -131,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
130
|
requirements:
|
132
131
|
- - ">="
|
133
132
|
- !ruby/object:Gem::Version
|
134
|
-
version: 3.3.
|
133
|
+
version: 3.3.22
|
135
134
|
requirements: []
|
136
135
|
rubygems_version: 3.4.4
|
137
136
|
signing_key:
|
data/lib/2.7/yrb.so
DELETED
Binary file
|