mirror of
https://github.com/loro-dev/loro.git
synced 2024-11-28 09:25:36 +00:00
fix: export CommitOptions & JsonSchema (#389)
This commit is contained in:
parent
2940029b63
commit
fb028f861d
3 changed files with 8 additions and 9 deletions
|
@ -615,17 +615,16 @@ impl TreeHandler {
|
|||
}
|
||||
|
||||
// TODO: iterator
|
||||
pub fn children(&self, parent: Option<TreeID>) -> Vec<TreeID> {
|
||||
pub fn children(&self, parent: Option<TreeID>) -> Option<Vec<TreeID>> {
|
||||
match &self.inner {
|
||||
MaybeDetached::Detached(t) => {
|
||||
let t = t.try_lock().unwrap();
|
||||
t.value.get_children(parent).unwrap()
|
||||
t.value.get_children(parent)
|
||||
}
|
||||
MaybeDetached::Attached(a) => a.with_state(|state| {
|
||||
let a = state.as_tree_state().unwrap();
|
||||
a.get_children(&TreeParentId::from(parent))
|
||||
.unwrap()
|
||||
.collect()
|
||||
.map(|x| x.collect())
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +695,7 @@ impl TreeHandler {
|
|||
}
|
||||
|
||||
pub fn roots(&self) -> Vec<TreeID> {
|
||||
self.children(None)
|
||||
self.children(None).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
|
|
|
@ -2939,7 +2939,7 @@ impl LoroTreeNode {
|
|||
/// the WASM boundary.
|
||||
#[wasm_bindgen(skip_typescript)]
|
||||
pub fn children(&self) -> Array {
|
||||
let children = self.tree.children(Some(self.id));
|
||||
let children = self.tree.children(Some(self.id)).unwrap_or_default();
|
||||
let children = children.into_iter().map(|c| {
|
||||
let node = LoroTreeNode::from_tree(c, self.tree.clone(), self.doc.clone());
|
||||
JsValue::from(node)
|
||||
|
|
|
@ -11,9 +11,7 @@ use loro_internal::cursor::Side;
|
|||
use loro_internal::encoding::ImportBlobMetadata;
|
||||
use loro_internal::handler::HandlerTrait;
|
||||
use loro_internal::handler::ValueOrHandler;
|
||||
use loro_internal::loro::CommitOptions;
|
||||
use loro_internal::undo::{OnPop, OnPush};
|
||||
use loro_internal::JsonSchema;
|
||||
use loro_internal::LoroDoc as InnerLoroDoc;
|
||||
use loro_internal::OpLog;
|
||||
|
||||
|
@ -40,10 +38,12 @@ pub use loro_internal::delta::{TreeDeltaItem, TreeDiff, TreeExternalDiff};
|
|||
pub use loro_internal::event::Index;
|
||||
pub use loro_internal::handler::TextDelta;
|
||||
pub use loro_internal::id::{PeerID, TreeID, ID};
|
||||
pub use loro_internal::loro::CommitOptions;
|
||||
pub use loro_internal::obs::SubID;
|
||||
pub use loro_internal::oplog::FrontiersNotIncluded;
|
||||
pub use loro_internal::undo;
|
||||
pub use loro_internal::version::{Frontiers, VersionVector};
|
||||
pub use loro_internal::JsonSchema;
|
||||
pub use loro_internal::UndoManager as InnerUndoManager;
|
||||
pub use loro_internal::{loro_value, to_value};
|
||||
pub use loro_internal::{LoroError, LoroResult, LoroValue, ToJson};
|
||||
|
@ -1368,7 +1368,7 @@ impl LoroTree {
|
|||
}
|
||||
|
||||
/// Return all children of the target node.
|
||||
pub fn children(&self, parent: Option<TreeID>) -> Vec<TreeID> {
|
||||
pub fn children(&self, parent: Option<TreeID>) -> Option<Vec<TreeID>> {
|
||||
self.handler.children(parent)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue