y-rb 0.5.5-x86_64-linux-musl → 0.6.0-x86_64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/yrb/Cargo.toml +5 -5
- data/ext/yrb/src/lib.rs +17 -1
- data/ext/yrb/src/yattrs.rs +9 -18
- data/ext/yrb/src/ydiff.rs +19 -0
- data/ext/yrb/src/ytext.rs +41 -4
- data/lib/3.1/yrb.so +0 -0
- data/lib/3.2/yrb.so +0 -0
- data/lib/3.3/yrb.so +0 -0
- data/lib/3.4/yrb.so +0 -0
- data/lib/y/array.rb +2 -2
- data/lib/y/diff.rb +38 -0
- data/lib/y/text.rb +15 -0
- data/lib/y/version.rb +1 -1
- data/lib/y-rb.rb +1 -0
- metadata +20 -20
- data/lib/3.0/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: 2248eab6d670ea7e2dafb38a963c865696ec8714054649e687d9720da40390a1
|
4
|
+
data.tar.gz: 558653cd60d5deb4c1a568be2c6e434ada6c78485abfeedaffdd53075522e030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f57b1dd3db12edc1a10be1fd3ea9c2d2b477d29bbf0d88687277ed6eee25fbafedde2fe73ad4518e3e9ff2a705e5917649e8ec933dc738beda5b944f126184ff
|
7
|
+
data.tar.gz: 496abab2b4ec08166cbf47a9cdcb37f953ebb88bd283c87bddee4e4ffa67286726e275cd55bd6f43205a3dbefcbb0da5559a472c977dc82131ddb3007f9bdfc4
|
data/ext/yrb/Cargo.toml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
[package]
|
2
2
|
name = "yrb"
|
3
|
-
version = "0.
|
3
|
+
version = "0.6.0"
|
4
4
|
authors = ["Hannes Moser <box@hannesmoser.at>"]
|
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
|
-
magnus = "=0.
|
11
|
-
thiserror = "
|
10
|
+
magnus = "=0.7.1"
|
11
|
+
thiserror = "2.0.11"
|
12
12
|
yrs = "=0.17.4"
|
13
13
|
y-sync = "=0.4.0"
|
14
|
-
rb-sys = "0.9
|
14
|
+
rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
|
15
15
|
|
16
16
|
[dev-dependencies]
|
17
|
-
magnus = { version = "0.
|
17
|
+
magnus = { version = "0.7", features = ["embed"] }
|
18
18
|
|
19
19
|
[lib]
|
20
20
|
name = "yrb"
|
data/ext/yrb/src/lib.rs
CHANGED
@@ -2,6 +2,7 @@ extern crate core;
|
|
2
2
|
|
3
3
|
use crate::yarray::YArray;
|
4
4
|
use crate::yawareness::{YAwareness, YAwarenessEvent};
|
5
|
+
use crate::ydiff::YDiff;
|
5
6
|
use crate::ydoc::YDoc;
|
6
7
|
use crate::ymap::YMap;
|
7
8
|
use crate::ytext::YText;
|
@@ -9,6 +10,7 @@ use crate::ytransaction::YTransaction;
|
|
9
10
|
use crate::yxml_element::YXmlElement;
|
10
11
|
use crate::yxml_fragment::YXmlFragment;
|
11
12
|
use crate::yxml_text::YXmlText;
|
13
|
+
|
12
14
|
use magnus::{class, define_module, function, method, Error, Module, Object};
|
13
15
|
|
14
16
|
mod utils;
|
@@ -16,6 +18,7 @@ mod yany;
|
|
16
18
|
mod yarray;
|
17
19
|
mod yattrs;
|
18
20
|
mod yawareness;
|
21
|
+
mod ydiff;
|
19
22
|
mod ydoc;
|
20
23
|
mod ymap;
|
21
24
|
mod ytext;
|
@@ -224,6 +227,9 @@ fn init() -> Result<(), Error> {
|
|
224
227
|
.define_class("Text", class::object())
|
225
228
|
.expect("cannot define class Y::Text");
|
226
229
|
|
230
|
+
ytext
|
231
|
+
.define_private_method("ytext_diff", method!(YText::ytext_diff, 1))
|
232
|
+
.expect("cannot define private method: ytext_diff");
|
227
233
|
ytext
|
228
234
|
.define_private_method("ytext_format", method!(YText::ytext_format, 4))
|
229
235
|
.expect("cannot define private method: ytext_format");
|
@@ -618,7 +624,7 @@ fn init() -> Result<(), Error> {
|
|
618
624
|
|
619
625
|
let yawareness_event = module
|
620
626
|
.define_class("AwarenessEvent", class::object())
|
621
|
-
.expect("cannot define class Y
|
627
|
+
.expect("cannot define class Y::AwarenessEvent");
|
622
628
|
yawareness_event
|
623
629
|
.define_method("added", method!(YAwarenessEvent::added, 0))
|
624
630
|
.expect("cannot define private method: added");
|
@@ -629,5 +635,15 @@ fn init() -> Result<(), Error> {
|
|
629
635
|
.define_method("removed", method!(YAwarenessEvent::removed, 0))
|
630
636
|
.expect("cannot define private method: removed");
|
631
637
|
|
638
|
+
let ydiff = module
|
639
|
+
.define_class("Diff", class::object())
|
640
|
+
.expect("cannot define class Y::Diff");
|
641
|
+
ydiff
|
642
|
+
.define_private_method("ydiff_insert", method!(YDiff::ydiff_insert, 0))
|
643
|
+
.expect("cannot define private method: insert");
|
644
|
+
ydiff
|
645
|
+
.define_private_method("ydiff_attrs", method!(YDiff::ydiff_attrs, 0))
|
646
|
+
.expect("cannot define private method: attrs");
|
647
|
+
|
632
648
|
Ok(())
|
633
649
|
}
|
data/ext/yrb/src/yattrs.rs
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
use crate::yvalue::YValue;
|
2
2
|
use magnus::r_hash::ForEach::Continue;
|
3
3
|
use magnus::{RHash, Value};
|
4
|
-
use std::
|
4
|
+
use std::cell::RefCell;
|
5
5
|
use std::sync::Arc;
|
6
6
|
use yrs::types::Attrs;
|
7
7
|
use yrs::Any;
|
8
8
|
|
9
|
-
|
9
|
+
#[magnus::wrap(class = "Y::Attrs")]
|
10
|
+
#[derive(Clone)]
|
11
|
+
pub(crate) struct YAttrs(pub(crate) RefCell<Attrs>);
|
12
|
+
|
13
|
+
/// SAFETY: This is safe because we only access this data when the GVL is held.
|
14
|
+
unsafe impl Send for YAttrs {}
|
10
15
|
|
11
16
|
impl From<Attrs> for YAttrs {
|
12
17
|
fn from(value: Attrs) -> Self {
|
13
|
-
YAttrs(value)
|
18
|
+
YAttrs(RefCell::from(value))
|
14
19
|
}
|
15
20
|
}
|
16
21
|
|
@@ -29,20 +34,6 @@ impl From<RHash> for YAttrs {
|
|
29
34
|
})
|
30
35
|
.expect("cannot iterate attributes hash");
|
31
36
|
|
32
|
-
YAttrs(attrs)
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
impl Deref for YAttrs {
|
37
|
-
type Target = Attrs;
|
38
|
-
|
39
|
-
fn deref(&self) -> &Self::Target {
|
40
|
-
&self.0
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
impl DerefMut for YAttrs {
|
45
|
-
fn deref_mut(&mut self) -> &mut Self::Target {
|
46
|
-
&mut self.0
|
37
|
+
YAttrs(RefCell::from(attrs))
|
47
38
|
}
|
48
39
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
use magnus::{IntoValue, RHash, Value};
|
2
|
+
|
3
|
+
unsafe impl Send for YDiff {}
|
4
|
+
|
5
|
+
#[magnus::wrap(class = "Y::Diff")]
|
6
|
+
pub(crate) struct YDiff {
|
7
|
+
pub(crate) ydiff_insert: Value,
|
8
|
+
pub(crate) ydiff_attrs: Option<RHash>,
|
9
|
+
}
|
10
|
+
|
11
|
+
impl YDiff {
|
12
|
+
pub(crate) fn ydiff_insert(&self) -> Value {
|
13
|
+
self.ydiff_insert
|
14
|
+
}
|
15
|
+
|
16
|
+
pub(crate) fn ydiff_attrs(&self) -> Option<Value> {
|
17
|
+
self.ydiff_attrs.as_ref().map(|value| value.into_value())
|
18
|
+
}
|
19
|
+
}
|
data/ext/yrb/src/ytext.rs
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
use crate::yattrs::YAttrs;
|
2
|
+
use crate::ydiff::YDiff;
|
2
3
|
use crate::yvalue::YValue;
|
3
4
|
use crate::YTransaction;
|
4
5
|
use magnus::block::Proc;
|
5
6
|
use magnus::value::Qnil;
|
6
|
-
use magnus::
|
7
|
+
use magnus::RArray;
|
8
|
+
pub(crate) use magnus::{Error, IntoValue, RHash, Symbol, Value};
|
7
9
|
use std::cell::RefCell;
|
10
|
+
use yrs::types::text::YChange;
|
8
11
|
use yrs::types::Delta;
|
9
12
|
use yrs::{Any, GetString, Observable, Text, TextRef};
|
10
13
|
|
@@ -15,6 +18,38 @@ pub(crate) struct YText(pub(crate) RefCell<TextRef>);
|
|
15
18
|
unsafe impl Send for YText {}
|
16
19
|
|
17
20
|
impl YText {
|
21
|
+
pub(crate) fn ytext_diff(&self, transaction: &YTransaction) -> RArray {
|
22
|
+
let tx = transaction.transaction();
|
23
|
+
let tx = tx.as_ref().unwrap();
|
24
|
+
|
25
|
+
RArray::from_iter(
|
26
|
+
self.0
|
27
|
+
.borrow()
|
28
|
+
.diff(tx, YChange::identity)
|
29
|
+
.iter()
|
30
|
+
.map(move |diff| {
|
31
|
+
let yvalue = YValue::from(diff.insert.clone());
|
32
|
+
let insert = yvalue.0.into_inner();
|
33
|
+
let attributes = diff.attributes.as_ref().map_or_else(
|
34
|
+
|| None,
|
35
|
+
|boxed_attrs| {
|
36
|
+
let attributes = RHash::new();
|
37
|
+
for (key, value) in boxed_attrs.iter() {
|
38
|
+
let key = key.to_string();
|
39
|
+
let value = YValue::from(value.clone()).0.into_inner();
|
40
|
+
attributes.aset(key, value).expect("cannot add value");
|
41
|
+
}
|
42
|
+
Some(attributes)
|
43
|
+
},
|
44
|
+
);
|
45
|
+
YDiff {
|
46
|
+
ydiff_insert: insert,
|
47
|
+
ydiff_attrs: attributes,
|
48
|
+
}
|
49
|
+
.into_value()
|
50
|
+
}),
|
51
|
+
)
|
52
|
+
}
|
18
53
|
pub(crate) fn ytext_format(
|
19
54
|
&self,
|
20
55
|
transaction: &YTransaction,
|
@@ -27,7 +62,9 @@ impl YText {
|
|
27
62
|
|
28
63
|
let a = YAttrs::from(attrs);
|
29
64
|
|
30
|
-
self.0
|
65
|
+
self.0
|
66
|
+
.borrow_mut()
|
67
|
+
.format(tx, index, length, a.0.into_inner())
|
31
68
|
}
|
32
69
|
pub(crate) fn ytext_insert(&self, transaction: &YTransaction, index: u32, chunk: String) {
|
33
70
|
let mut tx = transaction.transaction();
|
@@ -66,7 +103,7 @@ impl YText {
|
|
66
103
|
|
67
104
|
self.0
|
68
105
|
.borrow_mut()
|
69
|
-
.insert_embed_with_attributes(tx, index, avalue, a.0);
|
106
|
+
.insert_embed_with_attributes(tx, index, avalue, a.0.into_inner());
|
70
107
|
}
|
71
108
|
pub(crate) fn ytext_insert_with_attributes(
|
72
109
|
&self,
|
@@ -82,7 +119,7 @@ impl YText {
|
|
82
119
|
|
83
120
|
self.0
|
84
121
|
.borrow_mut()
|
85
|
-
.insert_with_attributes(tx, index, chunk.as_str(), a.0)
|
122
|
+
.insert_with_attributes(tx, index, chunk.as_str(), a.0.into_inner())
|
86
123
|
}
|
87
124
|
pub(crate) fn ytext_length(&self, transaction: &YTransaction) -> u32 {
|
88
125
|
let tx = transaction.transaction();
|
data/lib/3.1/yrb.so
CHANGED
Binary file
|
data/lib/3.2/yrb.so
CHANGED
Binary file
|
data/lib/3.3/yrb.so
CHANGED
Binary file
|
data/lib/3.4/yrb.so
ADDED
Binary file
|
data/lib/y/array.rb
CHANGED
@@ -115,8 +115,8 @@ module Y
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# @return [void]
|
118
|
-
def each(
|
119
|
-
document.current_transaction { |tx| yarray_each(tx,
|
118
|
+
def each(...)
|
119
|
+
document.current_transaction { |tx| yarray_each(tx, ...) }
|
120
120
|
end
|
121
121
|
|
122
122
|
# Check if the array is empty
|
data/lib/y/diff.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Y
|
4
|
+
# A representation of an uniformly-formatted chunk of rich context stored by
|
5
|
+
# Text or XmlText. It contains a value (which could be a string, embedded
|
6
|
+
# object or another shared type) with optional formatting attributes wrapping
|
7
|
+
# around this chunk.
|
8
|
+
class Diff
|
9
|
+
# @return [Object]
|
10
|
+
def insert
|
11
|
+
ydiff_insert
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Hash]
|
15
|
+
def attrs
|
16
|
+
ydiff_attrs
|
17
|
+
end
|
18
|
+
|
19
|
+
# Convert the diff to a Hash representation
|
20
|
+
#
|
21
|
+
# @return [Hash]
|
22
|
+
def to_h
|
23
|
+
{
|
24
|
+
insert: ydiff_insert,
|
25
|
+
attrs: ydiff_attrs
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# @!method ydiff_insert()
|
30
|
+
# Returns string representation of text
|
31
|
+
#
|
32
|
+
# @return [Object]
|
33
|
+
|
34
|
+
# @!method ydiff_attrs()
|
35
|
+
#
|
36
|
+
# @return [Hash]
|
37
|
+
end
|
38
|
+
end
|
data/lib/y/text.rb
CHANGED
@@ -80,6 +80,15 @@ module Y
|
|
80
80
|
ytext_unobserve(subscription_id)
|
81
81
|
end
|
82
82
|
|
83
|
+
# Diff
|
84
|
+
#
|
85
|
+
# @return[Array<YDiff>]
|
86
|
+
def diff
|
87
|
+
document.current_transaction do |tx|
|
88
|
+
ytext_diff(tx)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
83
92
|
# Checks if text is empty
|
84
93
|
#
|
85
94
|
# @example Check if text is empty
|
@@ -284,6 +293,12 @@ module Y
|
|
284
293
|
value.is_a?(Hash)
|
285
294
|
end
|
286
295
|
|
296
|
+
# @!method ytext_diff(tx)
|
297
|
+
# Returns text changes as list of diffs
|
298
|
+
#
|
299
|
+
# @param transaction [Y::Transaction]
|
300
|
+
# @return [Array<YDiff>]
|
301
|
+
|
287
302
|
# @!method ytext_insert(tx, index, chunk)
|
288
303
|
# Insert into text at position
|
289
304
|
#
|
data/lib/y/version.rb
CHANGED
data/lib/y-rb.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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: x86_64-linux-musl
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,58 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '13.
|
19
|
+
version: '13.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '13.
|
27
|
-
force_ruby_platform: false
|
26
|
+
version: '13.2'
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
28
|
name: rb_sys
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
31
30
|
requirements:
|
32
31
|
- - "~>"
|
33
32
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.9.
|
33
|
+
version: 0.9.110
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
38
|
- - "~>"
|
40
39
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.9.
|
42
|
-
force_ruby_platform: false
|
40
|
+
version: 0.9.110
|
43
41
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
42
|
+
name: base64
|
45
43
|
requirement: !ruby/object:Gem::Requirement
|
46
44
|
requirements:
|
47
|
-
- - "
|
45
|
+
- - ">="
|
48
46
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
47
|
+
version: '0'
|
50
48
|
type: :development
|
51
49
|
prerelease: false
|
52
50
|
version_requirements: !ruby/object:Gem::Requirement
|
53
51
|
requirements:
|
54
|
-
- - "
|
52
|
+
- - ">="
|
55
53
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
54
|
+
version: '0'
|
57
55
|
- !ruby/object:Gem::Dependency
|
58
|
-
name: rake-compiler
|
56
|
+
name: rake-compiler
|
59
57
|
requirement: !ruby/object:Gem::Requirement
|
60
58
|
requirements:
|
61
59
|
- - "~>"
|
62
60
|
- !ruby/object:Gem::Version
|
63
|
-
version: 1.
|
61
|
+
version: 1.2.1
|
64
62
|
type: :development
|
65
63
|
prerelease: false
|
66
64
|
version_requirements: !ruby/object:Gem::Requirement
|
67
65
|
requirements:
|
68
66
|
- - "~>"
|
69
67
|
- !ruby/object:Gem::Version
|
70
|
-
version: 1.
|
68
|
+
version: 1.2.1
|
71
69
|
description: Ruby bindings for yrs. Yrs "wires" is a Rust port of the Yjs framework.
|
72
70
|
email:
|
73
71
|
- hmoser@gitlab.com
|
@@ -84,6 +82,7 @@ files:
|
|
84
82
|
- ext/yrb/src/yarray.rs
|
85
83
|
- ext/yrb/src/yattrs.rs
|
86
84
|
- ext/yrb/src/yawareness.rs
|
85
|
+
- ext/yrb/src/ydiff.rs
|
87
86
|
- ext/yrb/src/ydoc.rs
|
88
87
|
- ext/yrb/src/ymap.rs
|
89
88
|
- ext/yrb/src/ytext.rs
|
@@ -92,14 +91,15 @@ files:
|
|
92
91
|
- ext/yrb/src/yxml_element.rs
|
93
92
|
- ext/yrb/src/yxml_fragment.rs
|
94
93
|
- ext/yrb/src/yxml_text.rs
|
95
|
-
- lib/3.0/yrb.so
|
96
94
|
- lib/3.1/yrb.so
|
97
95
|
- lib/3.2/yrb.so
|
98
96
|
- lib/3.3/yrb.so
|
97
|
+
- lib/3.4/yrb.so
|
99
98
|
- lib/y-rb.rb
|
100
99
|
- lib/y.rb
|
101
100
|
- lib/y/array.rb
|
102
101
|
- lib/y/awareness.rb
|
102
|
+
- lib/y/diff.rb
|
103
103
|
- lib/y/doc.rb
|
104
104
|
- lib/y/map.rb
|
105
105
|
- lib/y/text.rb
|
@@ -123,10 +123,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: '3.
|
126
|
+
version: '3.1'
|
127
127
|
- - "<"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 3.
|
129
|
+
version: 3.5.dev
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: 3.3.22
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.5.23
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Ruby bindings for yrs
|
data/lib/3.0/yrb.so
DELETED
Binary file
|