mirror of
https://github.com/loro-dev/loro.git
synced 2024-11-28 09:25:36 +00:00
chore: rename tree event (#520)
This commit is contained in:
parent
dedc8e087e
commit
3e4005d113
6 changed files with 34 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::time::Instant;
|
||||
|
||||
use bench_utils::TextAction;
|
||||
use loro_internal::LoroDoc;
|
||||
use loro_internal::{loro::ExportMode, LoroDoc};
|
||||
|
||||
fn main() {
|
||||
let actions = bench_utils::get_automerge_actions();
|
||||
|
@ -54,6 +54,23 @@ fn main() {
|
|||
output.len(),
|
||||
);
|
||||
|
||||
let start = Instant::now();
|
||||
let shallow_snapshot = loro
|
||||
.export(ExportMode::shallow_snapshot(&loro.oplog_frontiers()))
|
||||
.unwrap();
|
||||
println!("Shallow Snapshot time {}ms", start.elapsed().as_millis());
|
||||
let output = miniz_oxide::deflate::compress_to_vec(&shallow_snapshot, 6);
|
||||
println!(
|
||||
"Shallow Snapshot+compression time {}ms",
|
||||
start.elapsed().as_millis()
|
||||
);
|
||||
|
||||
println!(
|
||||
"Shallow snapshot size {} after compression {}",
|
||||
shallow_snapshot.len(),
|
||||
output.len(),
|
||||
);
|
||||
|
||||
let updates = loro.export_from(&Default::default());
|
||||
let output = miniz_oxide::deflate::compress_to_vec(&updates, 6);
|
||||
println!(
|
||||
|
|
|
@ -566,7 +566,7 @@ pub mod wasm {
|
|||
js_sys::Reflect::set(&obj, &"index".into(), &(*index).into()).unwrap();
|
||||
js_sys::Reflect::set(
|
||||
&obj,
|
||||
&"fractional_index".into(),
|
||||
&"fractionalIndex".into(),
|
||||
&position.to_string().into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -578,11 +578,11 @@ pub mod wasm {
|
|||
js_sys::Reflect::set(&obj, &"action".into(), &"delete".into()).unwrap();
|
||||
js_sys::Reflect::set(
|
||||
&obj,
|
||||
&"old_parent".into(),
|
||||
&"oldParent".into(),
|
||||
&JsValue::from(old_parent.tree_id()),
|
||||
)
|
||||
.unwrap();
|
||||
js_sys::Reflect::set(&obj, &"old_index".into(), &(*old_index).into())
|
||||
js_sys::Reflect::set(&obj, &"oldIndex".into(), &(*old_index).into())
|
||||
.unwrap();
|
||||
}
|
||||
TreeExternalDiff::Move {
|
||||
|
@ -602,17 +602,17 @@ pub mod wasm {
|
|||
js_sys::Reflect::set(&obj, &"index".into(), &(*index).into()).unwrap();
|
||||
js_sys::Reflect::set(
|
||||
&obj,
|
||||
&"fractional_index".into(),
|
||||
&"fractionalIndex".into(),
|
||||
&position.to_string().into(),
|
||||
)
|
||||
.unwrap();
|
||||
js_sys::Reflect::set(
|
||||
&obj,
|
||||
&"old_parent".into(),
|
||||
&"oldParent".into(),
|
||||
&JsValue::from(old_parent.tree_id()),
|
||||
)
|
||||
.unwrap();
|
||||
js_sys::Reflect::set(&obj, &"old_index".into(), &(*old_index).into())
|
||||
js_sys::Reflect::set(&obj, &"oldIndex".into(), &(*old_index).into())
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3525,7 +3525,7 @@ impl LoroTree {
|
|||
js_sys::Reflect::set(&obj, &"index".into(), &JsValue::from(index))?;
|
||||
js_sys::Reflect::set(
|
||||
&obj,
|
||||
&"fractional_index".into(),
|
||||
&"fractionalIndex".into(),
|
||||
&JsValue::from_str(&position),
|
||||
)?;
|
||||
js_sys::Reflect::set(&obj, &"meta".into(), &map.into())?;
|
||||
|
|
|
@ -95,17 +95,17 @@ export type TreeDiffItem =
|
|||
action: "create";
|
||||
parent: TreeID | undefined;
|
||||
index: number;
|
||||
fractional_index: string;
|
||||
fractionalIndex: string;
|
||||
}
|
||||
| { target: TreeID; action: "delete"; old_parent: TreeID | undefined; old_index: number }
|
||||
| { target: TreeID; action: "delete"; oldParent: TreeID | undefined; oldIndex: number }
|
||||
| {
|
||||
target: TreeID;
|
||||
action: "move";
|
||||
parent: TreeID | undefined;
|
||||
index: number;
|
||||
fractional_index: string;
|
||||
old_parent: TreeID | undefined;
|
||||
old_index: number;
|
||||
fractionalIndex: string;
|
||||
oldParent: TreeID | undefined;
|
||||
oldIndex: number;
|
||||
};
|
||||
|
||||
export type TreeDiff = {
|
||||
|
|
|
@ -246,6 +246,7 @@ describe("type", () => {
|
|||
describe("list stable position", () => {
|
||||
it("basic tests", () => {
|
||||
const loro = new LoroDoc();
|
||||
loro.oplogFrontiers
|
||||
const list = loro.getList("list");
|
||||
list.insert(0, "a");
|
||||
const pos0 = list.getCursor(0);
|
||||
|
|
|
@ -93,7 +93,7 @@ describe("loro tree", () => {
|
|||
assert(keys.includes("id"));
|
||||
assert(keys.includes("parent"));
|
||||
assert(keys.includes("index"));
|
||||
assert(keys.includes("fractional_index"));
|
||||
assert(keys.includes("fractionalIndex"));
|
||||
assert(keys.includes("meta"));
|
||||
assert(keys.includes("children"));
|
||||
});
|
||||
|
@ -212,8 +212,8 @@ describe("loro tree node", () => {
|
|||
if (e.events[0].diff.type == "tree") {
|
||||
const diff = e.events[0].diff as TreeDiff;
|
||||
if (diff.diff[0].action == "move") {
|
||||
assertEquals(diff.diff[0].old_parent, root.id);
|
||||
assertEquals(diff.diff[0].old_index, 1);
|
||||
assertEquals(diff.diff[0].oldParent, root.id);
|
||||
assertEquals(diff.diff[0].oldIndex, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue