feat(native): sync yocto codes (#14243)

#### PR Dependency Tree


* **PR #14243** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Batch management API for coordinated document mutations and change
tracking.
* New document accessors (IDs, state snapshots, change/delete set
queries) and subscriber count.

* **Chores**
  * Upgraded Rust edition across packages to 2024.
  * Repository-wide formatting, stylistic cleanups and test adjustments.

* **Breaking Changes**
* Removed the Node native bindings package and its JS/TS declarations
and tests (no longer published/available).

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-01-11 06:08:33 +08:00
committed by GitHub
parent d515d295ce
commit ca2462f987
143 changed files with 1396 additions and 4841 deletions

View File

@@ -1,6 +1,6 @@
[package]
authors = ["x1a0t <405028157@qq.com>", "DarkSky <darksky2048@gmail.com>"]
edition = "2021"
edition = "2024"
license = "MIT"
name = "y-octo-utils"
version = "0.0.1"

View File

@@ -2,7 +2,7 @@ mod utils;
use std::time::Duration;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use path_ext::PathExt;
use utils::Files;
@@ -19,7 +19,7 @@ fn apply(c: &mut Criterion) {
&file.content,
|b, content| {
b.iter(|| {
use yrs::{updates::decoder::Decode, Doc, Transact, Update};
use yrs::{Doc, Transact, Update, updates::decoder::Decode};
let update = Update::decode_v1(content).unwrap();
let doc = Doc::new();
doc.transact_mut().apply_update(update).unwrap();

View File

@@ -1,6 +1,6 @@
use std::time::Duration;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use rand::{Rng, SeedableRng};
fn operations(c: &mut Criterion) {

View File

@@ -1,4 +1,4 @@
use criterion::{criterion_group, criterion_main, Criterion, SamplingMode};
use criterion::{Criterion, SamplingMode, criterion_group, criterion_main};
use lib0::{
decoding::{Cursor, Read},
encoding::Write,

View File

@@ -1,6 +1,6 @@
use std::time::Duration;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
fn operations(c: &mut Criterion) {
let mut group = c.benchmark_group("ops/map");

View File

@@ -1,6 +1,6 @@
use std::time::Duration;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use rand::{Rng, SeedableRng};
fn operations(c: &mut Criterion) {

View File

@@ -2,7 +2,7 @@ mod utils;
use std::time::Duration;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use path_ext::PathExt;
use utils::Files;
@@ -19,7 +19,7 @@ fn update(c: &mut Criterion) {
&file.content,
|b, content| {
b.iter(|| {
use yrs::{updates::decoder::Decode, Update};
use yrs::{Update, updates::decoder::Decode};
Update::decode_v1(content).unwrap()
});
},

View File

@@ -87,12 +87,7 @@ fn convert_to_markdown() -> impl Iterator<Item = String> {
let diff = -(1.0 - changes_dur_secs / base_dur_secs) * 100.0;
difference = format!("{diff:+.2}%");
if is_significant(
changes_dur_secs,
changes_err_secs,
base_dur_secs,
base_err_secs,
) {
if is_significant(changes_dur_secs, changes_err_secs, base_dur_secs, base_err_secs) {
difference = format!("**{difference}**");
}
}
@@ -100,16 +95,8 @@ fn convert_to_markdown() -> impl Iterator<Item = String> {
Some(format!(
"| {} | {} | {} | {} |",
name.replace('|', "\\|"),
if base_undefined {
"N/A"
} else {
&base_duration
},
if changes_undefined {
"N/A"
} else {
&changes_duration
},
if base_undefined { "N/A" } else { &base_duration },
if changes_undefined { "N/A" } else { &changes_duration },
difference
))
})

View File

@@ -1,5 +1,5 @@
[package]
edition = "2021"
edition = "2024"
name = "y-octo-fuzz"
publish = false
version = "0.0.0"

View File

@@ -69,10 +69,7 @@ pub fn yrs_create_array_from_nest_type(
let str = text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(text.insert_embed(&mut trx, byte_start_offset as u32, array_prelim))
}
@@ -80,10 +77,7 @@ pub fn yrs_create_array_from_nest_type(
let str = xml_text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(xml_text.insert_embed(&mut trx, byte_start_offset as u32, array_prelim))
}
@@ -114,26 +108,14 @@ mod tests {
nest_data_op_type: NestDataOpType::Insert,
};
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::ArrayType(array_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::ArrayType(array_ref.clone()), params.clone());
assert_eq!(array_ref.len(&doc.transact()), 1);
params.nest_data_op_type = NestDataOpType::Delete;
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::ArrayType(array_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::ArrayType(array_ref.clone()), params.clone());
assert_eq!(array_ref.len(&doc.transact()), 0);
params.nest_data_op_type = NestDataOpType::Clear;
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::ArrayType(array_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::ArrayType(array_ref.clone()), params.clone());
assert_eq!(array_ref.len(&doc.transact()), 0);
}

View File

@@ -26,9 +26,7 @@ fn remove_op(doc: &yrs::Doc, nest_input: &YrsNestType, params: CRDTParam) {
random_pick_num((len - 1) as u32, &params.insert_pos)
};
iter
.nth(skip_step as usize)
.map(|(key, _value)| key.to_string())
iter.nth(skip_step as usize).map(|(key, _value)| key.to_string())
};
if let Some(key) = rand_key {
@@ -77,10 +75,7 @@ pub fn yrs_create_map_from_nest_type(
let str = text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(text.insert_embed(&mut trx, byte_start_offset as u32, map_prelim))
}
@@ -88,10 +83,7 @@ pub fn yrs_create_map_from_nest_type(
let str = xml_text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(xml_text.insert_embed(&mut trx, byte_start_offset as u32, map_prelim))
}

View File

@@ -14,8 +14,8 @@ use xml_element::*;
use xml_fragment::*;
use xml_text::*;
use yrs::{
Array, ArrayPrelim, ArrayRef, Doc, GetString, Map, MapPrelim, MapRef, Text, TextPrelim, TextRef,
Transact, XmlFragment, XmlTextPrelim, XmlTextRef,
Array, ArrayPrelim, ArrayRef, Doc, GetString, Map, MapPrelim, MapRef, Text, TextPrelim, TextRef, Transact,
XmlFragment, XmlTextPrelim, XmlTextRef,
};
use super::*;
@@ -66,12 +66,7 @@ impl OpsRegistry<'_> {
}
}
pub fn operate_yrs_nest_type(
&self,
doc: &yrs::Doc,
cur_crdt_nest_type: YrsNestType,
crdt_param: CRDTParam,
) {
pub fn operate_yrs_nest_type(&self, doc: &yrs::Doc, cur_crdt_nest_type: YrsNestType, crdt_param: CRDTParam) {
let ops = self.get_ops_from_yrs_nest_type(&cur_crdt_nest_type);
ops
.get(match &crdt_param.nest_data_op_type {
@@ -83,11 +78,7 @@ impl OpsRegistry<'_> {
}
}
pub fn yrs_create_nest_type_from_root(
doc: &yrs::Doc,
target_type: CRDTNestType,
key: &str,
) -> YrsNestType {
pub fn yrs_create_nest_type_from_root(doc: &yrs::Doc, target_type: CRDTNestType, key: &str) -> YrsNestType {
match target_type {
CRDTNestType::Array => YrsNestType::ArrayType(doc.get_or_insert_array(key)),
CRDTNestType::Map => YrsNestType::MapType(doc.get_or_insert_map(key)),
@@ -141,17 +132,13 @@ pub fn gen_nest_type_from_nest_type(
nest_type: &mut YrsNestType,
) -> Option<YrsNestType> {
match crdt_param.new_nest_type {
CRDTNestType::Array => {
yrs_create_array_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key)
.map(YrsNestType::ArrayType)
}
CRDTNestType::Array => yrs_create_array_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key)
.map(YrsNestType::ArrayType),
CRDTNestType::Map => {
yrs_create_map_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key)
.map(YrsNestType::MapType)
yrs_create_map_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key).map(YrsNestType::MapType)
}
CRDTNestType::Text => {
yrs_create_text_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key)
.map(YrsNestType::TextType)
yrs_create_text_from_nest_type(doc, nest_type, &crdt_param.insert_pos, crdt_param.key).map(YrsNestType::TextType)
}
_ => None,
}

View File

@@ -12,10 +12,7 @@ fn insert_op(doc: &yrs::Doc, nest_input: &YrsNestType, params: CRDTParam) {
let str = text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, &params.insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
text.insert(&mut trx, byte_start_offset as u32, &params.value);
}
@@ -33,10 +30,7 @@ fn remove_op(doc: &yrs::Doc, nest_input: &YrsNestType, params: CRDTParam) {
return;
}
let index = random_pick_num(len - 1, &params.insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
let char_byte_len = str.chars().nth(index).unwrap().len_utf8();
text.remove_range(&mut trx, byte_start_offset as u32, char_byte_len as u32);
@@ -80,10 +74,7 @@ pub fn yrs_create_text_from_nest_type(
let str = text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(text.insert_embed(&mut trx, byte_start_offset as u32, text_prelim))
}
@@ -91,10 +82,7 @@ pub fn yrs_create_text_from_nest_type(
let str = xml_text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
Some(xml_text.insert_embed(&mut trx, byte_start_offset as u32, text_prelim))
}
@@ -122,26 +110,14 @@ mod tests {
nest_data_op_type: NestDataOpType::Insert,
};
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::TextType(text_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::TextType(text_ref.clone()), params.clone());
assert_eq!(text_ref.len(&doc.transact()), 10);
params.nest_data_op_type = NestDataOpType::Delete;
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::TextType(text_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::TextType(text_ref.clone()), params.clone());
assert_eq!(text_ref.len(&doc.transact()), 9);
params.nest_data_op_type = NestDataOpType::Clear;
ops_registry.operate_yrs_nest_type(
&doc,
YrsNestType::TextType(text_ref.clone()),
params.clone(),
);
ops_registry.operate_yrs_nest_type(&doc, YrsNestType::TextType(text_ref.clone()), params.clone());
assert_eq!(text_ref.len(&doc.transact()), 0);
}

View File

@@ -12,10 +12,7 @@ fn insert_op(doc: &yrs::Doc, nest_input: &YrsNestType, params: CRDTParam) {
let str = xml_text.get_string(&trx);
let len = str.chars().fold(0, |acc, _| acc + 1);
let index = random_pick_num(len, &params.insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
xml_text.insert(&mut trx, byte_start_offset as u32, &params.value);
}
@@ -33,10 +30,7 @@ fn remove_op(doc: &yrs::Doc, nest_input: &YrsNestType, params: CRDTParam) {
return;
}
let index = random_pick_num(len - 1, &params.insert_pos) as usize;
let byte_start_offset = str
.chars()
.take(index)
.fold(0, |acc, ch| acc + ch.len_utf8());
let byte_start_offset = str.chars().take(index).fold(0, |acc, ch| acc + ch.len_utf8());
let char_byte_len = str.chars().nth(index).unwrap().len_utf8();
xml_text.remove_range(&mut trx, byte_start_offset as u32, char_byte_len as u32);