Skip to content

Commit 9b7502c

Browse files
committed
chore: release 1.4.2 -> [email protected]
1 parent cf09d06 commit 9b7502c

File tree

6 files changed

+139
-13
lines changed

6 files changed

+139
-13
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "loro_py"
3-
version = "1.4.1"
3+
version = "1.4.2"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
# loro = { path = "../loro/crates/loro", features = ["counter", "jsonpath"] }
13-
loro = { git = "https://github.com/loro-dev/loro.git", tag = "[email protected].0", features = [
13+
loro = { git = "https://github.com/loro-dev/loro.git", tag = "[email protected].6", features = [
1414
"counter",
1515
"jsonpath",
1616
] }

loro.pyi

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import typing
22
from enum import Enum
33

4+
LORO_VERSION: str
45
LoroValue = typing.Union[
56
None,
67
bool,
@@ -800,6 +801,65 @@ class LoroDoc:
800801
"""
801802
...
802803

804+
def config_default_text_style(self, text_style: typing.Optional[ExpandType] = None) -> None:
805+
r"""
806+
Configures the default text style for the document.
807+
808+
This method sets the default text style configuration for the document when using LoroText.
809+
If `None` is provided, the default style is reset.
810+
811+
# Parameters
812+
813+
- `text_style`: The style configuration to set as the default. `None` to reset.
814+
"""
815+
...
816+
817+
def set_next_commit_origin(self, origin: str) -> None:
818+
r"""
819+
Set `origin` for the current uncommitted changes, it can be used to track the source of changes in an event.
820+
821+
It will NOT be persisted.
822+
"""
823+
...
824+
825+
def set_next_commit_timestamp(self, timestamp: int) -> None:
826+
r"""
827+
Set the timestamp of the next commit.
828+
829+
It will be persisted and stored in the `OpLog`.
830+
You can get the timestamp from the [`Change`] type.
831+
"""
832+
...
833+
834+
def set_next_commit_options(
835+
self,
836+
origin: typing.Optional[str] = None,
837+
timestamp: typing.Optional[int] = None,
838+
immediate_renew: typing.Optional[bool] = True,
839+
commit_msg: typing.Optional[str] = None,
840+
) -> None:
841+
r"""
842+
Set the options of the next commit.
843+
844+
It will be used when the next commit is performed.
845+
"""
846+
...
847+
848+
def clear_next_commit_options(self) -> None:
849+
r"""
850+
Clear the options of the next commit.
851+
"""
852+
...
853+
854+
def has_container(self, id: ContainerID) -> bool:
855+
r"""
856+
Check if the doc contains the target container.
857+
858+
A root container always exists, while a normal container exists
859+
if it has ever been created on the doc.
860+
"""
861+
...
862+
803863
class LoroList:
804864
is_attached: bool
805865
id: ContainerID

src/doc.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ impl LoroDoc {
183183
self.doc.config_text_style(text_style.0)
184184
}
185185

186+
/// Configures the default text style for the document.
187+
///
188+
/// This method sets the default text style configuration for the document when using LoroText.
189+
/// If `None` is provided, the default style is reset.
190+
///
191+
/// # Parameters
192+
///
193+
/// - `text_style`: The style configuration to set as the default. `None` to reset.
194+
#[pyo3(signature = (text_style=None))]
195+
pub fn config_default_text_style(&self, text_style: Option<ExpandType>) {
196+
self.doc
197+
.config_default_text_style(text_style.map(|c| loro::StyleConfig { expand: c.into() }));
198+
}
199+
186200
/// Attach the document state to the latest known version.
187201
///
188202
/// > The document becomes detached during a `checkout` operation.
@@ -359,6 +373,45 @@ impl LoroDoc {
359373
self.doc.set_next_commit_message(msg)
360374
}
361375

376+
/// Set `origin` for the current uncommitted changes, it can be used to track the source of changes in an event.
377+
///
378+
/// It will NOT be persisted.
379+
pub fn set_next_commit_origin(&self, origin: &str) {
380+
self.doc.set_next_commit_origin(origin)
381+
}
382+
383+
/// Set the timestamp of the next commit.
384+
///
385+
/// It will be persisted and stored in the `OpLog`.
386+
/// You can get the timestamp from the [`Change`] type.
387+
pub fn set_next_commit_timestamp(&self, timestamp: i64) {
388+
self.doc.set_next_commit_timestamp(timestamp)
389+
}
390+
391+
/// Set the options of the next commit.
392+
///
393+
/// It will be used when the next commit is performed.
394+
#[pyo3(signature = (origin=None, timestamp=None, immediate_renew=true, commit_msg=None))]
395+
pub fn set_next_commit_options(
396+
&self,
397+
origin: Option<&str>,
398+
timestamp: Option<i64>,
399+
immediate_renew: Option<bool>,
400+
commit_msg: Option<&str>,
401+
) {
402+
self.doc.set_next_commit_options(loro::CommitOptions {
403+
origin: origin.map(|s| s.into()),
404+
immediate_renew: immediate_renew.unwrap_or(true),
405+
timestamp,
406+
commit_msg: commit_msg.map(|s| s.into()),
407+
})
408+
}
409+
410+
/// Clear the options of the next commit.
411+
pub fn clear_next_commit_options(&self) {
412+
self.doc.clear_next_commit_options()
413+
}
414+
362415
/// Whether the document is in detached mode, where the [loro_internal::DocState] is not
363416
/// synchronized with the latest version of the [loro_internal::OpLog].
364417
#[inline]
@@ -882,6 +935,14 @@ impl LoroDoc {
882935
let ans = self.doc.diff(&a.into(), &b.into())?;
883936
Ok(ans.into())
884937
}
938+
939+
/// Check if the doc contains the target container.
940+
///
941+
/// A root container always exists, while a normal container exists
942+
/// if it has ever been created on the doc.
943+
pub fn has_container(&self, id: &ContainerID) -> bool {
944+
self.doc.has_container(&id.into())
945+
}
885946
}
886947

887948
#[pyclass(frozen)]

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![doc = include_str!("../README.md")]
2+
use loro::LORO_VERSION;
23
use pyo3::prelude::*;
34

45
mod awareness;
@@ -12,14 +13,15 @@ mod value;
1213
mod version;
1314

1415
/// Python bindings for Loro
15-
#[pymodule]
16-
fn loro(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
16+
#[pymodule(name = "loro")]
17+
fn loro_py(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
1718
doc::register_class(m)?;
1819
container::register_class(m)?;
1920
event::register_class(m)?;
2021
value::register_class(m)?;
2122
version::register_class(m)?;
2223
undo::register_class(m)?;
2324
awareness::register_class(m)?;
25+
m.add("LORO_VERSION", LORO_VERSION)?;
2426
Ok(())
2527
}

tests/test_basic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from loro import LoroDoc, ExportMode, VersionVector
1+
from loro import LoroDoc, ExportMode, VersionVector, LORO_VERSION
2+
3+
def test_version():
4+
assert LORO_VERSION == "1.4.2"
25

36
def test_basic():
47
doc = LoroDoc()

0 commit comments

Comments
 (0)