yrby 0.3.0-x86_64-linux → 0.3.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 +39 -0
- data/README.md +15 -0
- data/lib/y/3.4/yrby.so +0 -0
- data/lib/y/4.0/yrby.so +0 -0
- data/lib/y/version.rb +1 -1
- metadata +2 -5
- data/lib/y/decoder/version.rb +0 -7
- data/lib/y/decoder.rb +0 -66
- data/lib/yrby-decoder.rb +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c620cb3e9292b752df6043cc54100f53ec8b43c09d2936e3128b9a3a7550e03c
|
|
4
|
+
data.tar.gz: 1842414d1e77000e2c73cee64d6b637ef24be943b7ab50552fd6290475e744e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48d5510ba6bd0870cd2715988291f480627160bc8c3b18e2150d51cd2841f610d6f747ad8af4abcd6345d46e8666aaeef478204549040c33d33668bdc308d59c
|
|
7
|
+
data.tar.gz: cb3e10a0935635b10a755c7ffad0c5bccbb5f21c5e43bdf0dfb9d3d61fe9b8e9f07b9f81ba90cd1db5767700595118deadafac588596a1dbaa5474eab7af9e4e
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,45 @@ to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.3.1] - 2026-07-01
|
|
10
|
+
|
|
11
|
+
Fixes from a full source review.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **`Doc#update_ready?` is now exact.** It previously checked only the
|
|
16
|
+
per-client clock lower bound, but yrs's real integration gate also requires
|
|
17
|
+
every block referenced by an item's origin / right-origin / parent — which
|
|
18
|
+
routinely belong to *other* clients — and post-Skip blocks in a merged update
|
|
19
|
+
sit above the lower bound. An update could pass the clock check yet park as
|
|
20
|
+
pending; downstream, `update_advances?` then misread the parked update as an
|
|
21
|
+
already-applied retry (pending doesn't move a state vector) and the sync
|
|
22
|
+
channel **acked and dropped real content**. `update_ready?` now
|
|
23
|
+
trial-integrates on a throwaway probe seeded with the doc's integrated state
|
|
24
|
+
(the clock check remains as a cheap pre-filter), so a cross-client-origin gap
|
|
25
|
+
is correctly rejected for a resync. `update_advances?` also gained defense in
|
|
26
|
+
depth: an update that would park reports as advancing, never as a duplicate.
|
|
27
|
+
- **`Doc#read_text` could deadlock the process.** It opened a second read
|
|
28
|
+
transaction while still holding the first (a chained temporary); yrs's lock is
|
|
29
|
+
write-preferring, so a concurrent writer between the two acquisitions
|
|
30
|
+
deadlocked reader-vs-writer inside the GVL-released (uninterruptible) region.
|
|
31
|
+
Now uses a single transaction.
|
|
32
|
+
- **TOCTOU in gap-free encoding.** The pending check and the encode ran in
|
|
33
|
+
separate transactions, so a concurrent gappy `apply_update` between them could
|
|
34
|
+
make `handle_sync_message`/`compacted_state_update` serve pending structs
|
|
35
|
+
anyway. Both now happen under one transaction.
|
|
36
|
+
- `read_xml`: Lexical soft line breaks and tabs now come through as `\n`/`\t`
|
|
37
|
+
instead of vanishing (`"foo⏎bar"` no longer extracts as `"foobar"`).
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- `update_advances?` skips its full-document probe when the update carries
|
|
42
|
+
blocks beyond the doc's state vector (a novel update trivially advances) —
|
|
43
|
+
the common case no longer pays O(doc) per frame.
|
|
44
|
+
- The gem no longer packages the `yrby-decoder` gem's files (they ship in that
|
|
45
|
+
gem; the duplicate copy could shadow a newer standalone release), and now
|
|
46
|
+
ships `Cargo.lock` so source builds compile the exact crate graph CI tested.
|
|
47
|
+
|
|
9
48
|
## [0.3.0] - 2026-07-01
|
|
10
49
|
|
|
11
50
|
### Fixed
|
data/README.md
CHANGED
|
@@ -242,6 +242,21 @@ servers:
|
|
|
242
242
|
causal dependencies are already in the store (checked against `on_load`); a
|
|
243
243
|
causally-incomplete update triggers a resync instead, so the log always
|
|
244
244
|
rebuilds cleanly.
|
|
245
|
+
- **An unhealable gap is dropped, not resynced forever.** A resync heals a gap
|
|
246
|
+
whose missing dependency is still in flight. But a *permanently*-orphaned update
|
|
247
|
+
(its dependency is gone for good) stays gappy through every resync, and a client
|
|
248
|
+
retransmitting it would loop endlessly (server resyncs → client resends →
|
|
249
|
+
repeat). After `gap_strike_limit` rejections of the same update on one
|
|
250
|
+
connection (default 3, minimum 2), the channel settles it with
|
|
251
|
+
`{ "ack" => id, "dropped" => true }` and drops it instead of resyncing again —
|
|
252
|
+
breaking the loop while never dropping a *healable* gap (those heal within a
|
|
253
|
+
resync or two, and healing frees the strike). The `dropped` flag lets the
|
|
254
|
+
client surface the loss (`yrby-client` reports it via `onError`) instead of
|
|
255
|
+
silently showing synced. Set `gap_strike_limit nil` to disable. Works on both
|
|
256
|
+
transports: plain ActionCable keeps strikes on the channel instance; under
|
|
257
|
+
AnyCable (fresh instance per RPC command) they persist through
|
|
258
|
+
anycable-rails' `state_attr_accessor` (istate), declared automatically when
|
|
259
|
+
anycable-rails is loaded.
|
|
245
260
|
- **`on_change` is at-least-once, and the durable guarantee is that replaying the
|
|
246
261
|
log reconstructs the document.** Every update triggers `on_change` before it's acked or
|
|
247
262
|
broadcast (record-before-distribute). If exactly-once updates matter for you, **you
|
data/lib/y/3.4/yrby.so
CHANGED
|
Binary file
|
data/lib/y/4.0/yrby.so
CHANGED
|
Binary file
|
data/lib/y/version.rb
CHANGED
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.3.
|
|
4
|
+
version: 0.3.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-07-
|
|
11
|
+
date: 2026-07-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -68,10 +68,7 @@ files:
|
|
|
68
68
|
- lib/y.rb
|
|
69
69
|
- lib/y/3.4/yrby.so
|
|
70
70
|
- lib/y/4.0/yrby.so
|
|
71
|
-
- lib/y/decoder.rb
|
|
72
|
-
- lib/y/decoder/version.rb
|
|
73
71
|
- lib/y/version.rb
|
|
74
|
-
- lib/yrby-decoder.rb
|
|
75
72
|
- lib/yrby.rb
|
|
76
73
|
homepage: https://github.com/jpcamara/yrby
|
|
77
74
|
licenses:
|
data/lib/y/decoder/version.rb
DELETED
data/lib/y/decoder.rb
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "y"
|
|
4
|
-
require "y/decoder/version"
|
|
5
|
-
|
|
6
|
-
module Y
|
|
7
|
-
# Plain-text reconstruction of a stored Yjs document, in pure Ruby — for search
|
|
8
|
-
# indexing and previews. The core `yrby` gem moves and stores opaque CRDT
|
|
9
|
-
# updates without reading them; this reads the text out of the shared type the
|
|
10
|
-
# editor uses (Lexical's `Y.XmlText`, plain `Y.Text`, or ProseMirror's
|
|
11
|
-
# `Y.XmlFragment`), in-process, on the native extension core already ships — no
|
|
12
|
-
# Node, no subprocess, no binary.
|
|
13
|
-
#
|
|
14
|
-
# state = doc.encode_state_as_update # opaque CRDT bytes from the store
|
|
15
|
-
# Y::Decoder.text(state) # => "hello world"
|
|
16
|
-
# Y::Decoder.preview(state, 280) # => "hello world…"
|
|
17
|
-
#
|
|
18
|
-
# Full-fidelity reconstruction (the exact Lexical EditorState / HTML, which
|
|
19
|
-
# needs @lexical/yjs) is a separate, opt-in concern — see the `yrby-decode`
|
|
20
|
-
# package's Bun binary. This gem stays pure Ruby on purpose.
|
|
21
|
-
module Decoder
|
|
22
|
-
class Error < Y::Error; end
|
|
23
|
-
|
|
24
|
-
module_function
|
|
25
|
-
|
|
26
|
-
# Plain text of the document. `field` pins the root key (Lexical: the editor
|
|
27
|
-
# id; ProseMirror: "default"); omit it to use the document's sole root.
|
|
28
|
-
def text(state, field: nil)
|
|
29
|
-
field ||= Y::Doc.new.tap { |d| d.apply_update(state) }.root_names.first
|
|
30
|
-
return "" unless field
|
|
31
|
-
|
|
32
|
-
# A plain `Y.Text` root (a simple shared-text editor) reads straight out.
|
|
33
|
-
# (A yrs root's type is fixed by its first typed access, so each reader
|
|
34
|
-
# gets a fresh doc to try a different shared type against the same state.)
|
|
35
|
-
direct = load(state).read_text(field)
|
|
36
|
-
return normalize(direct) if direct && !direct.strip.empty?
|
|
37
|
-
|
|
38
|
-
# Lexical (each block a sibling `Y.XmlText`) and ProseMirror (blocks are
|
|
39
|
-
# `Y.XmlElement`s) both come back from read_xml as block-per-line markup;
|
|
40
|
-
# strip any element tags to plain text.
|
|
41
|
-
markup = load(state).read_xml(field)
|
|
42
|
-
markup ? normalize(strip_tags(markup)) : ""
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# A compact, single-line preview for list UIs.
|
|
46
|
-
def preview(state, limit: 280, field: nil)
|
|
47
|
-
body = text(state, field: field).gsub(/\s+/, " ").strip
|
|
48
|
-
body.length > limit ? "#{body[0, limit].rstrip}…" : body
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def load(state)
|
|
52
|
-
Y::Doc.new.tap { |doc| doc.apply_update(state) }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def strip_tags(markup)
|
|
56
|
-
markup.gsub(/<[^>]*>/, " ")
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def normalize(text)
|
|
60
|
-
text.gsub(/[ \t]+/, " ") # collapse runs of spaces/tabs
|
|
61
|
-
.gsub(/ *\n */, "\n") # trim spaces left around block separators
|
|
62
|
-
.gsub(/\n{3,}/, "\n\n") # cap blank-line runs
|
|
63
|
-
.strip
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
data/lib/yrby-decoder.rb
DELETED