Skip to content

Commit 65e1a60

Browse files
committed
chore: pre release 1.5.8
1 parent 3a7d98c commit 65e1a60

File tree

6 files changed

+388
-15
lines changed

6 files changed

+388
-15
lines changed

Sources/Loro/Ephemeral.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Ephemeral.swift
3+
//
4+
//
5+
// Created by Leon Zhao on 2025/6/4.
6+
//
7+
8+
import Foundation
9+
10+
class ClosureEphemeralSubscriber: EphemeralSubscriber {
11+
private let closure: (EphemeralStoreEvent) -> Void
12+
13+
public init(closure: @escaping (EphemeralStoreEvent) -> Void) {
14+
self.closure = closure
15+
}
16+
17+
public func onEphemeralEvent(event: EphemeralStoreEvent) {
18+
closure(event)
19+
}
20+
}
21+
22+
class ClosureLocalEphemeralListener:LocalEphemeralListener{
23+
24+
private let closure: (Data) -> Void
25+
26+
public init(closure: @escaping (Data) -> Void) {
27+
self.closure = closure
28+
}
29+
30+
public func onEphemeralUpdate(update: Data) {
31+
closure(update)
32+
}
33+
}
34+
35+
extension EphemeralStore{
36+
public func subscribe(cb: @escaping (EphemeralStoreEvent) -> Void) -> Subscription{
37+
let closureSubscriber = ClosureEphemeralSubscriber(closure: cb)
38+
return self.subscribe(listener: closureSubscriber)
39+
}
40+
41+
public func subscribeLocalUpdate(cb: @escaping (Data) -> Void) -> Subscription{
42+
let closureListener = ClosureLocalEphemeralListener(closure: cb)
43+
return self.subscribeLocalUpdate(listener: closureListener)
44+
}
45+
}

Sources/Loro/LoroFFI.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,6 +3261,17 @@ public protocol LoroDocProtocol : AnyObject {
32613261
*/
32623262
func configTextStyle(textStyle: StyleConfigMap)
32633263

3264+
/**
3265+
* Delete all content from a root container and hide it from the document.
3266+
*
3267+
* When a root container is empty and hidden:
3268+
* - It won't show up in `get_deep_value()` results
3269+
* - It won't be included in document snapshots
3270+
*
3271+
* Only works on root containers (containers without parents).
3272+
*/
3273+
func deleteRootContainer(cid: ContainerId)
3274+
32643275
/**
32653276
* Force the document enter the detached mode.
32663277
*
@@ -3653,6 +3664,11 @@ public protocol LoroDocProtocol : AnyObject {
36533664
*/
36543665
func setChangeMergeInterval(interval: Int64)
36553666

3667+
/**
3668+
* Set whether to hide empty root containers.
3669+
*/
3670+
func setHideEmptyRootContainers(hide: Bool)
3671+
36563672
/**
36573673
* Set commit message for the current uncommitted changes
36583674
*
@@ -4022,6 +4038,22 @@ open func configTextStyle(textStyle: StyleConfigMap) {try! rustCall() {
40224038
FfiConverterTypeStyleConfigMap.lower(textStyle),$0
40234039
)
40244040
}
4041+
}
4042+
4043+
/**
4044+
* Delete all content from a root container and hide it from the document.
4045+
*
4046+
* When a root container is empty and hidden:
4047+
* - It won't show up in `get_deep_value()` results
4048+
* - It won't be included in document snapshots
4049+
*
4050+
* Only works on root containers (containers without parents).
4051+
*/
4052+
open func deleteRootContainer(cid: ContainerId) {try! rustCall() {
4053+
uniffi_loro_fn_method_lorodoc_delete_root_container(self.uniffiClonePointer(),
4054+
FfiConverterTypeContainerID.lower(cid),$0
4055+
)
4056+
}
40254057
}
40264058

40274059
/**
@@ -4702,6 +4734,16 @@ open func setChangeMergeInterval(interval: Int64) {try! rustCall() {
47024734
FfiConverterInt64.lower(interval),$0
47034735
)
47044736
}
4737+
}
4738+
4739+
/**
4740+
* Set whether to hide empty root containers.
4741+
*/
4742+
open func setHideEmptyRootContainers(hide: Bool) {try! rustCall() {
4743+
uniffi_loro_fn_method_lorodoc_set_hide_empty_root_containers(self.uniffiClonePointer(),
4744+
FfiConverterBool.lower(hide),$0
4745+
)
4746+
}
47054747
}
47064748

47074749
/**
@@ -13002,6 +13044,8 @@ public enum LoroError {
1300213044

1300313045
case ContainersNotFound(message: String)
1300413046

13047+
case UndoGroupAlreadyStarted(message: String)
13048+
1300513049
}
1300613050

1300713051

@@ -13166,6 +13210,10 @@ public struct FfiConverterTypeLoroError: FfiConverterRustBuffer {
1316613210
message: try FfiConverterString.read(from: &buf)
1316713211
)
1316813212

13213+
case 38: return .UndoGroupAlreadyStarted(
13214+
message: try FfiConverterString.read(from: &buf)
13215+
)
13216+
1316913217

1317013218
default: throw UniffiInternalError.unexpectedEnumCase
1317113219
}
@@ -13251,6 +13299,8 @@ public struct FfiConverterTypeLoroError: FfiConverterRustBuffer {
1325113299
writeInt(&buf, Int32(36))
1325213300
case .ContainersNotFound(_ /* message is ignored*/):
1325313301
writeInt(&buf, Int32(37))
13302+
case .UndoGroupAlreadyStarted(_ /* message is ignored*/):
13303+
writeInt(&buf, Int32(38))
1325413304

1325513305

1325613306
}
@@ -15499,6 +15549,9 @@ private var initializationResult: InitializationResult = {
1549915549
if (uniffi_loro_checksum_method_lorodoc_config_text_style() != 52393) {
1550015550
return InitializationResult.apiChecksumMismatch
1550115551
}
15552+
if (uniffi_loro_checksum_method_lorodoc_delete_root_container() != 40125) {
15553+
return InitializationResult.apiChecksumMismatch
15554+
}
1550215555
if (uniffi_loro_checksum_method_lorodoc_detach() != 61399) {
1550315556
return InitializationResult.apiChecksumMismatch
1550415557
}
@@ -15652,6 +15705,9 @@ private var initializationResult: InitializationResult = {
1565215705
if (uniffi_loro_checksum_method_lorodoc_set_change_merge_interval() != 55133) {
1565315706
return InitializationResult.apiChecksumMismatch
1565415707
}
15708+
if (uniffi_loro_checksum_method_lorodoc_set_hide_empty_root_containers() != 34137) {
15709+
return InitializationResult.apiChecksumMismatch
15710+
}
1565515711
if (uniffi_loro_checksum_method_lorodoc_set_next_commit_message() != 18940) {
1565615712
return InitializationResult.apiChecksumMismatch
1565715713
}

0 commit comments

Comments
 (0)