Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor/rules/swift.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ When writing Swift:
- When writing a JSON string, favour using Swift raw string literals instead of escaping double quotes.
- When you need to import the following modules inside the AblyLiveObjects library code (that is, in non-test code), do so in the following way:
- Ably: use `import Ably`
- AblyPlugin: use `internal import AblyPlugin`
- `_AblyPluginSupportPrivate`: use `internal import _AblyPluginSupportPrivate`
- When writing an array literal that starts with an initializer expression, start the initializer expression on the line after the opening square bracket of the array literal. That is, instead of writing:
```swift
objectMessages: [InboundObjectMessage(
Expand Down
2 changes: 1 addition & 1 deletion .cursor/rules/testing.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ When writing tests:
- When you need to import the following modules in the tests, do so in the following way:
- Ably: use `import Ably`
- AblyLiveObjects: use `@testable import AblyLiveObjects`
- AblyPlugin: use `import AblyPlugin`; _do not_ do `internal import`
- `_AblyPluginSupportPrivate`: use `import _AblyPluginSupportPrivate`; _do not_ do `internal import`
- When you need to pass a logger to internal components in the tests, pass `TestLogger()`.
- When you need to unwrap an optional value in the tests, favour using `#require` instead of `guard let`.
- When creating `testsOnly_` property declarations, do not write generic comments of the form "Test-only access to the private createOperationIsMerged property"; the meaning of these properties is already well understood.
4 changes: 2 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- run: swift run BuildTool lint

# TODO: Restore in https://github.com/ably/ably-cocoa-liveobjects-plugin/issues/2 once we've seen what form the LiveObjects spec takes
# TODO: Restore in https://github.com/ably/ably-liveobjects-swift-plugin/issues/2 once we've seen what form the LiveObjects spec takes
#
# spec-coverage:
# runs-on: macos-15
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK }}:role/ably-sdk-builds-ably-cocoa-liveobjects-plugin
role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK }}:role/ably-sdk-builds-ably-liveobjects-swift-plugin
role-session-name: "${{ github.run_id }}-${{ github.run_number }}"

# Upload the generated documentation
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Example:

For the initial stage of development of this plugin, where we need to also iterate heavily on ably-cocoa, I've added ably-cocoa as a Git submodule, which can be found in [`ably-cocoa`](./ably-cocoa). This allows you to edit ably-cocoa from within this repo's Xcode workspace.

Nearer launch, we'll remove this submodule in https://github.com/ably/ably-cocoa-liveobjects-plugin/issues/7.
Nearer launch, we'll remove this submodule in https://github.com/ably/ably-liveobjects-swift-plugin/issues/7.

## Release process

Expand All @@ -137,7 +137,7 @@ For each release, the following needs to be done:
- Update the following (we have https://github.com/ably/ably-chat-swift/issues/277 for adding a script to do this):
- the `version` constant in [`Sources/AblyLiveObjects/Version.swift`](Sources/AblyLiveObjects/Version.swift)
- the `from: "…"` in the SPM installation instructions in [`README.md`](README.md)
- Go to [Github releases](https://github.com/ably/ably-cocoa-liveobjects-plugin/releases) and press the `Draft a new release` button. Choose your new branch as a target
- Go to [Github releases](https://github.com/ably/ably-liveobjects-swift-plugin/releases) and press the `Draft a new release` button. Choose your new branch as a target
- Press the `Choose a tag` dropdown and start typing a new tag, Github will suggest the `Create new tag x.x.x on publish` option. After you select it Github will unveil the `Generate release notes` button
- From the newly generated changes remove everything that don't make much sense to the library user
- Copy the final list of changes to the top of the `CHANGELOG.md` file. Modify as necessary to fit the existing format of this file
Expand Down
11 changes: 10 additions & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ let package = Package(
.package(
path: "ably-cocoa",
),
.package(
url: "https://github.com/ably/ably-cocoa-plugin-support",
from: "0.1.0",
),
.package(
url: "https://github.com/apple/swift-argument-parser",
from: "1.5.0",
Expand All @@ -47,8 +51,8 @@ let package = Package(
package: "ably-cocoa",
),
.product(
name: "AblyPlugin",
package: "ably-cocoa",
name: "_AblyPluginSupportPrivate",
package: "ably-cocoa-plugin-support",
),
],
),
Expand All @@ -61,8 +65,8 @@ let package = Package(
package: "ably-cocoa",
),
.product(
name: "AblyPlugin",
package: "ably-cocoa",
name: "_AblyPluginSupportPrivate",
package: "ably-cocoa-plugin-support",
),
],
resources: [
Expand Down
11 changes: 6 additions & 5 deletions Sources/AblyLiveObjects/Internal/ARTClientOptions+Objects.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
internal import AblyPlugin
internal import _AblyPluginSupportPrivate
import Ably

internal extension ARTClientOptions {
private class Box<T> {
Expand All @@ -14,9 +15,9 @@ internal extension ARTClientOptions {
/// Can be overriden for testing purposes.
var garbageCollectionOptions: InternalDefaultRealtimeObjects.GarbageCollectionOptions? {
get {
let optionsValue = PluginAPI.sharedInstance().pluginOptionsValue(
let optionsValue = Plugin.defaultPluginAPI.pluginOptionsValue(
forKey: Self.garbageCollectionOptionsKey,
clientOptions: self,
clientOptions: asPluginPublicClientOptions,
)

guard let optionsValue else {
Expand All @@ -35,10 +36,10 @@ internal extension ARTClientOptions {
preconditionFailure("Not implemented the ability to un-set GC options")
}

PluginAPI.sharedInstance().setPluginOptionsValue(
Plugin.defaultPluginAPI.setPluginOptionsValue(
Box<InternalDefaultRealtimeObjects.GarbageCollectionOptions>(boxed: newValue),
forKey: Self.garbageCollectionOptionsKey,
clientOptions: self,
clientOptions: asPluginPublicClientOptions,
)
}
}
Expand Down
26 changes: 13 additions & 13 deletions Sources/AblyLiveObjects/Internal/CoreSDK.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
internal import _AblyPluginSupportPrivate
import Ably
internal import AblyPlugin

/// The API that the internal components of the SDK (that is, `DefaultLiveObjects` and down) use to interact with our core SDK (i.e. ably-cocoa).
///
/// This provides us with a mockable interface to ably-cocoa, and it also allows internal components and their tests not to need to worry about some of the boring details of how we bridge Swift types to AblyPlugin's Objective-C API (i.e. boxing).
/// This provides us with a mockable interface to ably-cocoa, and it also allows internal components and their tests not to need to worry about some of the boring details of how we bridge Swift types to `_AblyPluginSupportPrivate`'s Objective-C API (i.e. boxing).
internal protocol CoreSDK: AnyObject, Sendable {
/// Implements the internal `#publish` method of RTO15.
func publish(objectMessages: [OutboundObjectMessage]) async throws(InternalError)
Expand All @@ -14,17 +14,17 @@ internal protocol CoreSDK: AnyObject, Sendable {
func testsOnly_overridePublish(with newImplementation: @escaping ([OutboundObjectMessage]) async throws(InternalError) -> Void)

/// Returns the current state of the Realtime channel that this wraps.
var channelState: ARTRealtimeChannelState { get }
var channelState: _AblyPluginSupportPrivate.RealtimeChannelState { get }
}

internal final class DefaultCoreSDK: CoreSDK {
/// Used to synchronize access to internal mutable state.
private let mutex = NSLock()

private let channel: AblyPlugin.RealtimeChannel
private let client: AblyPlugin.RealtimeClient
private let channel: _AblyPluginSupportPrivate.RealtimeChannel
private let client: _AblyPluginSupportPrivate.RealtimeClient
private let pluginAPI: PluginAPIProtocol
private let logger: AblyPlugin.Logger
private let logger: Logger

/// If set to true, ``publish(objectMessages:)`` will behave like a no-op.
///
Expand All @@ -34,10 +34,10 @@ internal final class DefaultCoreSDK: CoreSDK {
private nonisolated(unsafe) var overriddenPublishImplementation: (([OutboundObjectMessage]) async throws -> Void)?

internal init(
channel: AblyPlugin.RealtimeChannel,
client: AblyPlugin.RealtimeClient,
channel: _AblyPluginSupportPrivate.RealtimeChannel,
client: _AblyPluginSupportPrivate.RealtimeClient,
pluginAPI: PluginAPIProtocol,
logger: AblyPlugin.Logger
logger: Logger
) {
self.channel = channel
self.client = client
Expand Down Expand Up @@ -66,7 +66,7 @@ internal final class DefaultCoreSDK: CoreSDK {
return
}

// TODO: Implement the full spec of RTO15 (https://github.com/ably/ably-cocoa-liveobjects-plugin/issues/47)
// TODO: Implement the full spec of RTO15 (https://github.com/ably/ably-liveobjects-swift-plugin/issues/47)
try await DefaultInternalPlugin.sendObject(
objectMessages: objectMessages,
channel: channel,
Expand All @@ -81,8 +81,8 @@ internal final class DefaultCoreSDK: CoreSDK {
}
}

internal var channelState: ARTRealtimeChannelState {
channel.state
internal var channelState: _AblyPluginSupportPrivate.RealtimeChannelState {
pluginAPI.state(for: channel)
}
}

Expand All @@ -97,7 +97,7 @@ internal extension CoreSDK {
/// - operationDescription: A description of the operation being performed, used in error messages
/// - Throws: `ARTErrorInfo` with code 90001 and statusCode 400 if the channel is in any of the invalid states
func validateChannelState(
notIn invalidStates: [ARTRealtimeChannelState],
notIn invalidStates: [_AblyPluginSupportPrivate.RealtimeChannelState],
operationDescription: String,
) throws(ARTErrorInfo) {
let currentChannelState = channelState
Expand Down
Loading
Loading