yrby 0.9.0-aarch64-linux → 0.9.1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c1d9b86b8778b8120f728232c70de38d9a0dfc09ff99973f7ac7ad772c6bcd8
4
- data.tar.gz: 32e33a4f2cab0777d3e15953aca69085fcedd4189de11a57756fadda5d760553
3
+ metadata.gz: a69cc79803a3137602633c19123423132ef86b8749a0d9ea00f932f68b47eafd
4
+ data.tar.gz: cb0215b6e2dfe1ef31e30d21ee6895b578ca4777dc9d4a606bd741fed6077670
5
5
  SHA512:
6
- metadata.gz: 6bb73b454506e9e766fc7ff22074363a517ac5624075185b79f2c19d0c0cd754997c1b48d6a1341c4a7a0ccfa442f8f6d501d23d38a94100183083417da94107
7
- data.tar.gz: 45fcbb30ba7e37a59803b6f7ba2d4ac051bf3c59d342eb1dbdef8724e4461661ca3ce64c0fd5a9218d5d44173dc10b0e78baa7b430355976c8ee2e0a084c1c79
6
+ metadata.gz: 5d50e7f0f90d7f80558935d8963cbb7676eeb5a2366a8864b4a9560f1ef15e8a73f87bc8b95e8bf04398eb58419be61d8078138830f55539789f3bcb8127c3c3
7
+ data.tar.gz: 4ffe58aa9a84206deb0859ee45acb71bc712c00e42f84f9b8d373c1c40a1efd70d6323598dd7745704230756b1734c8e81c63c92052e353858bed34b67d69ede
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
- # changed nothing.
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
- # the update its writes produced, or nil when the document didn't change.
8
- # The document has the edit either way. The update is what a process
9
- # saves and broadcasts, one call per chunk as it streams into a document.
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 update holds everything the document gained while the block ran,
12
- # so a write another thread or peer made meanwhile is in it too. Applying
13
- # an update twice changes nothing, so that only adds bytes.
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
- before = native_snapshot
16
- yield self
17
- native_update_since(before)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Y
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
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.0
4
+ version: 0.9.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - JP Camara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-03 00:00:00.000000000 Z
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