Skip to content

Commit 826a4e0

Browse files
committed
chore: release v1.1.3
1 parent 55e2496 commit 826a4e0

File tree

8 files changed

+1325
-250
lines changed

8 files changed

+1325
-250
lines changed

Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ let FFIbinaryTarget: PackageDescription.Target
99
if ProcessInfo.processInfo.environment["LOCAL_BUILD"] != nil {
1010
FFIbinaryTarget = .binaryTarget(name: "LoroFFI", path: "./loroFFI.xcframework.zip")
1111
}else {
12-
FFIbinaryTarget = .binaryTarget(
13-
name: "LoroFFI",
14-
url: "https://github.com/loro-dev/loro-swift/releases/download/1.0.0-alpha.5/loroFFI.xcframework.zip",
15-
checksum: "2b9c11aecf4f90ead28e12c8487b072e3fc406885e91ab2d1999b8c83040bd6c"
16-
)
12+
FFIbinaryTarget = .binaryTarget(
13+
name: "LoroFFI",
14+
url: "https://github.com/loro-dev/loro-swift/releases/download/1.1.3/loroFFI.xcframework.zip",
15+
checksum: "354ece5ad8825e1c74d88ea59429d8508576b8eca1e4b9ab3d2f7506f7541846"
16+
)
1717
}
1818

1919
let package = Package(

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
</a>
1313
</p>
1414

15-
This repository contains experimental Swift bindings for [Loro CRDT](https://github.com/loro-dev/loro).
15+
This repository contains experimental Swift bindings for
16+
[Loro CRDT](https://github.com/loro-dev/loro).
1617

17-
If you have any suggestions for API, please feel free to create an issue or join our [Discord](https://discord.gg/tUsBSVfqzf) community.
18+
If you have any suggestions for API, please feel free to create an issue or join
19+
our [Discord](https://discord.gg/tUsBSVfqzf) community.
1820

1921
## TODO
2022

@@ -37,7 +39,7 @@ let package = Package(
3739
products: [......],
3840
dependencies:[
3941
...,
40-
.package(url: "https://github.com/loro-dev/loro-swift.git", from: "1.0.0-alpha.5")
42+
.package(url: "https://github.com/loro-dev/loro-swift.git", from: "1.1.3")
4143
],
4244
targets:[
4345
.executableTarget(
@@ -46,7 +48,6 @@ let package = Package(
4648
)
4749
]
4850
)
49-
5051
```
5152

5253
## Examples
@@ -72,8 +73,8 @@ let sub = doc.subscribeRoot{ diffEvent in
7273

7374
// export updates or snapshot
7475
let doc2 = LoroDoc()
75-
let snapshot = doc.exportSnapshot()
76-
let updates = doc.exportFrom(vv: VersionVector())
76+
let snapshot = doc.export(mode: ExportMode.snapshot)
77+
let updates = doc.export(mode: ExportMode.updates(from: VersionVector()))
7778

7879
// import updates or snapshot
7980
let status = try! doc2.import(snapshot)
@@ -89,7 +90,8 @@ doc.checkoutToLatest()
8990

9091
## Develop
9192

92-
If you wanna build and develop this project with MacOS, you need first run this script:
93+
If you wanna build and develop this project with MacOS, you need first run this
94+
script:
9395

9496
```bash
9597
export LOCAL_BUILD=1
@@ -100,4 +102,5 @@ The script will run `uniffi` and generate the `loroFFI.xcframework.zip`.
100102

101103
# Credits
102104

103-
- [Automerge-swift](https://github.com/automerge/automerge-swift): `loro-swift` uses many of `automerge-swift`'s scripts for building and CI.
105+
- [Automerge-swift](https://github.com/automerge/automerge-swift): `loro-swift`
106+
uses many of `automerge-swift`'s scripts for building and CI.

Sources/Loro/Loro.swift

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,39 @@
99

1010
import Foundation
1111

12+
public enum ExportMode {
13+
case snapshot
14+
case updates(from: VersionVector)
15+
case updatesInRange(spans: [IdSpan])
16+
case shallowSnapshot(Frontiers)
17+
case stateOnly(Frontiers?)
18+
case snapshotAt(version: Frontiers)
19+
}
20+
21+
extension LoroDoc{
22+
public func export(mode: ExportMode) throws -> Data{
23+
switch mode {
24+
case .snapshot:
25+
return try self.exportSnapshot()
26+
case .updates(let from):
27+
return try self.exportUpdates(vv: from)
28+
case .updatesInRange(let spans):
29+
return try self.exportUpdatesInRange(spans: spans)
30+
case .shallowSnapshot(let frontiers):
31+
return try self.exportShallowSnapshot(frontiers: frontiers)
32+
case .stateOnly(let frontiers):
33+
return try self.exportStateOnly(frontiers: frontiers)
34+
case .snapshotAt(let frontiers):
35+
return try self.exportSnapshotAt(frontiers: frontiers)
36+
}
37+
}
38+
39+
public func travelChangeAncestors(ids: [Id], f: @escaping (ChangeMeta)->Bool) throws {
40+
let closureSubscriber = ChangeAncestorsTravel(closure: f)
41+
try self.travelChangeAncestors(ids: ids, f: closureSubscriber)
42+
}
43+
}
44+
1245

1346
class ClosureOnPush: OnPush {
1447
private let closure: (UndoOrRedo, CounterSpan) ->UndoItemMeta
@@ -67,9 +100,3 @@ class ChangeAncestorsTravel: ChangeAncestorsTraveler{
67100
}
68101
}
69102

70-
extension LoroDoc{
71-
public func travelChangeAncestors(ids: [Id], f: @escaping (ChangeMeta)->Bool) throws {
72-
let closureSubscriber = ChangeAncestorsTravel(closure: f)
73-
try self.travelChangeAncestors(ids: ids, f: closureSubscriber)
74-
}
75-
}

0 commit comments

Comments
 (0)