Skip to content

Commit

Permalink
chore: release v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeeon233 committed Nov 28, 2024
1 parent 55e2496 commit 826a4e0
Show file tree
Hide file tree
Showing 8 changed files with 1,325 additions and 250 deletions.
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ let FFIbinaryTarget: PackageDescription.Target
if ProcessInfo.processInfo.environment["LOCAL_BUILD"] != nil {
FFIbinaryTarget = .binaryTarget(name: "LoroFFI", path: "./loroFFI.xcframework.zip")
}else {
FFIbinaryTarget = .binaryTarget(
name: "LoroFFI",
url: "https://github.com/loro-dev/loro-swift/releases/download/1.0.0-alpha.5/loroFFI.xcframework.zip",
checksum: "2b9c11aecf4f90ead28e12c8487b072e3fc406885e91ab2d1999b8c83040bd6c"
)
FFIbinaryTarget = .binaryTarget(
name: "LoroFFI",
url: "https://github.com/loro-dev/loro-swift/releases/download/1.1.3/loroFFI.xcframework.zip",
checksum: "354ece5ad8825e1c74d88ea59429d8508576b8eca1e4b9ab3d2f7506f7541846"
)
}

let package = Package(
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
</a>
</p>

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

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

## TODO

Expand All @@ -37,7 +39,7 @@ let package = Package(
products: [......],
dependencies:[
...,
.package(url: "https://github.com/loro-dev/loro-swift.git", from: "1.0.0-alpha.5")
.package(url: "https://github.com/loro-dev/loro-swift.git", from: "1.1.3")
],
targets:[
.executableTarget(
Expand All @@ -46,7 +48,6 @@ let package = Package(
)
]
)

```

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

// export updates or snapshot
let doc2 = LoroDoc()
let snapshot = doc.exportSnapshot()
let updates = doc.exportFrom(vv: VersionVector())
let snapshot = doc.export(mode: ExportMode.snapshot)
let updates = doc.export(mode: ExportMode.updates(from: VersionVector()))

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

## Develop

If you wanna build and develop this project with MacOS, you need first run this script:
If you wanna build and develop this project with MacOS, you need first run this
script:

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

# Credits

- [Automerge-swift](https://github.com/automerge/automerge-swift): `loro-swift` uses many of `automerge-swift`'s scripts for building and CI.
- [Automerge-swift](https://github.com/automerge/automerge-swift): `loro-swift`
uses many of `automerge-swift`'s scripts for building and CI.
39 changes: 33 additions & 6 deletions Sources/Loro/Loro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@

import Foundation

public enum ExportMode {
case snapshot
case updates(from: VersionVector)
case updatesInRange(spans: [IdSpan])
case shallowSnapshot(Frontiers)
case stateOnly(Frontiers?)
case snapshotAt(version: Frontiers)
}

extension LoroDoc{
public func export(mode: ExportMode) throws -> Data{
switch mode {
case .snapshot:
return try self.exportSnapshot()
case .updates(let from):
return try self.exportUpdates(vv: from)
case .updatesInRange(let spans):
return try self.exportUpdatesInRange(spans: spans)
case .shallowSnapshot(let frontiers):
return try self.exportShallowSnapshot(frontiers: frontiers)
case .stateOnly(let frontiers):
return try self.exportStateOnly(frontiers: frontiers)
case .snapshotAt(let frontiers):
return try self.exportSnapshotAt(frontiers: frontiers)
}
}

public func travelChangeAncestors(ids: [Id], f: @escaping (ChangeMeta)->Bool) throws {
let closureSubscriber = ChangeAncestorsTravel(closure: f)
try self.travelChangeAncestors(ids: ids, f: closureSubscriber)
}
}


class ClosureOnPush: OnPush {
private let closure: (UndoOrRedo, CounterSpan) ->UndoItemMeta
Expand Down Expand Up @@ -67,9 +100,3 @@ class ChangeAncestorsTravel: ChangeAncestorsTraveler{
}
}

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

0 comments on commit 826a4e0

Please sign in to comment.