yrby 0.9.0-x86_64-linux → 0.9.1-x86_64-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/CHANGELOG.md +27 -0
- data/lib/y/3.4/yrby.so +0 -0
- data/lib/y/4.0/yrby.so +0 -0
- data/lib/y/array.rb +17 -0
- data/lib/y/collaborative/attribute.rb +1 -1
- data/lib/y/doc.rb +52 -9
- data/lib/y/map.rb +12 -0
- data/lib/y/version.rb +1 -1
- data/lib/y.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1049b610869e2b8bef51bc5fcb0dc9fbc7a8efb4a5c1e4bab96a238921e3bea
|
|
4
|
+
data.tar.gz: 179ccae46e5955c8c1520a81d717601c8c34a510318e5d9aed8b9a214b0969d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bc4fa76aecee5cea98dfd87eff06ac8da3c12efd49d5db0872e46eb13521ac1a5f8ba44184f1c9b1d3b83d25d178d3d23d7812421658a335b679b04484717c7
|
|
7
|
+
data.tar.gz: 537d7f5ebf4b232601f19c7e9845144b9c6b8636060cd1312a6d9dcd3366bcceed2c7f2451ab7b996ebd5b5430bb0adca39739cf5b757c7b3fe5208ce474cc8f
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,33 @@ to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.1] - 2026-11-08
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- yrby builds against yrs 0.28.1. An insert into a text no longer recounts
|
|
14
|
+
the UTF-16 length of each string before it, so appending to a long text
|
|
15
|
+
costs about the same at any length: 80k one-character appends took 2.5 s
|
|
16
|
+
and now take 48 ms.
|
|
17
|
+
|
|
18
|
+
### Experimental
|
|
19
|
+
|
|
20
|
+
- `Y::Doc#edit` returns the document's own writes and never a peer's. The
|
|
21
|
+
document keeps the update of every local transaction until an edit returns
|
|
22
|
+
it, merged into one, so a write made outside an edit, from another thread
|
|
23
|
+
or fiber, or in a block that raised comes with the next edit. Before this,
|
|
24
|
+
the edit returned everything the document gained while the block ran, so
|
|
25
|
+
an update applied from a peer meanwhile was sent again as the edit's own,
|
|
26
|
+
and a caller had to lock the document to keep them apart. Each edit takes
|
|
27
|
+
everything unsent at once, so the updates edits return have no gaps
|
|
28
|
+
between them. A peer's update doesn't wait for an edit.
|
|
29
|
+
|
|
30
|
+
- `Y::Map#set_text(key, content = "")` stores a new `Y.Text` at a key and
|
|
31
|
+
returns its live `Y::Text`. `Y::Array#push_text(content = "")` and
|
|
32
|
+
`#insert_text(index, content = "")` do the same in a list. Before this,
|
|
33
|
+
Ruby could edit a nested `Y.Text` a browser made but couldn't make one,
|
|
34
|
+
so a server couldn't set up a form whose fields merge typing.
|
|
35
|
+
|
|
9
36
|
## yrby-client 0.7.1 - 2026-11-03
|
|
10
37
|
|
|
11
38
|
### Fixed
|
data/lib/y/3.4/yrby.so
CHANGED
|
Binary file
|
data/lib/y/4.0/yrby.so
CHANGED
|
Binary file
|
data/lib/y/array.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Y
|
|
4
|
+
# Inside module Y, `Array` is this class.
|
|
5
|
+
class Array
|
|
6
|
+
# Insert a new Y.Text holding `content` at `index` and return a live
|
|
7
|
+
# Y::Text for it. Indexes work as in `insert`: -1 appends.
|
|
8
|
+
def insert_text(index, content = "")
|
|
9
|
+
native_insert_text(index, content)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Append a new Y.Text holding `content` and return a live Y::Text for it.
|
|
13
|
+
def push_text(content = "")
|
|
14
|
+
insert_text(-1, content)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -43,7 +43,7 @@ module Y
|
|
|
43
43
|
# Edits the document from Ruby the way a browser does: yields the
|
|
44
44
|
# current document, records what the block changed, and broadcasts it so
|
|
45
45
|
# open editors apply it. Returns the update, or nil when the block
|
|
46
|
-
#
|
|
46
|
+
# wrote nothing.
|
|
47
47
|
#
|
|
48
48
|
# post.collaborative_document(:body).edit do |doc|
|
|
49
49
|
# Y::Lexxy.append_paragraph(doc, "Reviewed by ops.")
|
data/lib/y/doc.rb
CHANGED
|
@@ -4,17 +4,43 @@ module Y
|
|
|
4
4
|
# Ruby-side conveniences over the native document.
|
|
5
5
|
class Doc
|
|
6
6
|
# Runs the block, which edits this document through handles, and returns
|
|
7
|
-
#
|
|
8
|
-
# The document has the
|
|
9
|
-
# saves and broadcasts, one call per chunk as it
|
|
7
|
+
# an update with every local write no edit has returned yet, or nil when
|
|
8
|
+
# there's nothing to send. The document has the writes either way. The
|
|
9
|
+
# update is what a process saves and broadcasts, one call per chunk as it
|
|
10
|
+
# streams into a document.
|
|
10
11
|
#
|
|
11
|
-
# The
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# The document keeps every local write until an edit returns it, so none
|
|
13
|
+
# is left out: a write made outside an edit, from another thread or
|
|
14
|
+
# fiber, or in a block that raised comes with the next edit's update. An
|
|
15
|
+
# update applied from a peer is never in it, and doesn't wait for the
|
|
16
|
+
# block. Each edit takes everything unsent at once, so the updates edits
|
|
17
|
+
# return have no gaps between them. An edit inside another, including one
|
|
18
|
+
# in a fiber or thread the outer block starts, returns what it took and
|
|
19
|
+
# leaves it for the outer edit to return again. Once the outer edit
|
|
20
|
+
# returns, a thread it started edits on its own.
|
|
21
|
+
#
|
|
22
|
+
# So send every update an edit returns. An edit in a thread the block
|
|
23
|
+
# didn't start, such as a pool thread, isn't nested: it takes the outer
|
|
24
|
+
# block's writes too, and they're sent only if its update is.
|
|
25
|
+
#
|
|
26
|
+
# An exception raised as `edit` returns, such as a Thread#raise or a
|
|
27
|
+
# signal trap, loses the update the edit took. A caller that must send
|
|
28
|
+
# every update masks interrupts around `edit` and doesn't raise from a
|
|
29
|
+
# trap.
|
|
14
30
|
def edit
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
31
|
+
# The edits running in this fiber, inherited by the fibers and threads
|
|
32
|
+
# their blocks start. Each is `[doc]` until it ends, then empty.
|
|
33
|
+
outer = (Fiber[:yrby_editing] || []).reject(&:empty?)
|
|
34
|
+
nested = outer.any? { |running| running.include?(self) }
|
|
35
|
+
running = [self]
|
|
36
|
+
Fiber[:yrby_editing] = [*outer, running]
|
|
37
|
+
begin
|
|
38
|
+
yield self
|
|
39
|
+
ensure
|
|
40
|
+
running.clear
|
|
41
|
+
Fiber[:yrby_editing] = outer
|
|
42
|
+
end
|
|
43
|
+
take_unsent(nested)
|
|
18
44
|
end
|
|
19
45
|
|
|
20
46
|
# The ordinal of the top-level block a position falls in, or nil at the
|
|
@@ -32,5 +58,22 @@ module Y
|
|
|
32
58
|
def find(anchor)
|
|
33
59
|
native_find(anchor.position, anchor.root)
|
|
34
60
|
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
# An interrupt that arrives during the take is raised once the masked
|
|
65
|
+
# block ends, and the taken update goes back to the document first, for
|
|
66
|
+
# the next edit to return. A nested edit has already put it back.
|
|
67
|
+
def take_unsent(nested)
|
|
68
|
+
taken = nil
|
|
69
|
+
Thread.handle_interrupt(Object => :never) do
|
|
70
|
+
taken = native_take_unsent
|
|
71
|
+
native_keep_unsent(taken) if taken && nested
|
|
72
|
+
end
|
|
73
|
+
taken
|
|
74
|
+
rescue Exception # rubocop:disable Lint/RescueException -- an interrupt is any exception
|
|
75
|
+
native_keep_unsent(taken) if taken && !nested
|
|
76
|
+
raise
|
|
77
|
+
end
|
|
35
78
|
end
|
|
36
79
|
end
|
data/lib/y/map.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Y
|
|
4
|
+
class Map
|
|
5
|
+
# Store a new Y.Text holding `content` at `key`, replacing what was
|
|
6
|
+
# there, and return a live Y::Text for it. `map[key] = "..."` stores a
|
|
7
|
+
# plain string instead, and the last write to it wins.
|
|
8
|
+
def set_text(key, content = "")
|
|
9
|
+
native_set_text(key, content)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/y/version.rb
CHANGED
data/lib/y.rb
CHANGED
|
@@ -19,6 +19,8 @@ require_relative "y/lexical_markdown"
|
|
|
19
19
|
require_relative "y/anchor"
|
|
20
20
|
require_relative "y/xml_text"
|
|
21
21
|
require_relative "y/text"
|
|
22
|
+
require_relative "y/map"
|
|
23
|
+
require_relative "y/array"
|
|
22
24
|
require_relative "y/doc"
|
|
23
25
|
require_relative "y/tiptap"
|
|
24
26
|
require_relative "y/decoder"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yrby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.1
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- JP Camara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -73,6 +73,7 @@ files:
|
|
|
73
73
|
- lib/y/3.4/yrby.so
|
|
74
74
|
- lib/y/4.0/yrby.so
|
|
75
75
|
- lib/y/anchor.rb
|
|
76
|
+
- lib/y/array.rb
|
|
76
77
|
- lib/y/collaborative.rb
|
|
77
78
|
- lib/y/collaborative/attribute.rb
|
|
78
79
|
- lib/y/collaborative/helper.rb
|
|
@@ -81,6 +82,7 @@ files:
|
|
|
81
82
|
- lib/y/lexical_markdown.rb
|
|
82
83
|
- lib/y/lexical_writer.rb
|
|
83
84
|
- lib/y/lexxy.rb
|
|
85
|
+
- lib/y/map.rb
|
|
84
86
|
- lib/y/rendering.rb
|
|
85
87
|
- lib/y/text.rb
|
|
86
88
|
- lib/y/tiptap.rb
|